File indexing completed on 2024-12-01 04:35:29
0001 /* 0002 SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "usersforroomfilterproxymodeltest.h" 0008 #include "model/usersforroomfilterproxymodel.h" 0009 #include "model/usersforroommodel.h" 0010 #include <QTest> 0011 0012 QTEST_GUILESS_MAIN(UsersForRoomFilterProxyModelTest) 0013 0014 UsersForRoomFilterProxyModelTest::UsersForRoomFilterProxyModelTest(QObject *parent) 0015 : QObject(parent) 0016 { 0017 } 0018 0019 UsersForRoomFilterProxyModelTest::~UsersForRoomFilterProxyModelTest() = default; 0020 0021 void UsersForRoomFilterProxyModelTest::shouldHaveDefaultValues() 0022 { 0023 UsersForRoomFilterProxyModel proxy; 0024 UsersForRoomModel model; 0025 proxy.setSourceModel(&model); 0026 QCOMPARE(proxy.rowCount(), 0); 0027 } 0028 0029 void UsersForRoomFilterProxyModelTest::shouldAssignValue() 0030 { 0031 UsersForRoomFilterProxyModel proxy; 0032 UsersForRoomModel model; 0033 proxy.setSourceModel(&model); 0034 QCOMPARE(proxy.rowCount(), 0); 0035 0036 QVector<User> users; 0037 for (int i = 0; i < 10; i++) { 0038 User user; 0039 user.setName(QStringLiteral("name%1").arg(i)); 0040 user.setStatus(User::PresenceStatus::PresenceOffline); 0041 user.setUserId(QStringLiteral("userId%1").arg(i)); 0042 user.setUserName(QStringLiteral("username%1").arg(i)); 0043 users.append(std::move(user)); 0044 } 0045 model.setUsers(users); 0046 QCOMPARE(proxy.rowCount(), 10); 0047 QCOMPARE(model.rowCount(), 10); 0048 } 0049 0050 #include "moc_usersforroomfilterproxymodeltest.cpp"