Changeset View
Changeset View
Standalone View
Standalone View
src/tests/matrix-room-member-list-model-test.cpp
| Show All 20 Lines | |||||
| using namespace Kazv; | using namespace Kazv; | ||||
| class MatrixRoomMemberListModelTest : public QObject | class MatrixRoomMemberListModelTest : public QObject | ||||
| { | { | ||||
| Q_OBJECT | Q_OBJECT | ||||
| private Q_SLOTS: | private Q_SLOTS: | ||||
| void testMembers(); | void testMembers(); | ||||
| void testFilter(); | |||||
| }; | }; | ||||
| static auto data = Kazv::EventList{ | static auto data = Kazv::EventList{ | ||||
| makeRoomMember("@t1:tusooa.xyz", "t1"), | makeRoomMember("@t1:tusooa.xyz", "user 1"), | ||||
| makeRoomMember("@t2:tusooa.xyz"), | makeRoomMember("@t2:tusooa.xyz"), | ||||
| }; | }; | ||||
| void MatrixRoomMemberListModelTest::testMembers() | void MatrixRoomMemberListModelTest::testMembers() | ||||
| { | { | ||||
| MatrixRoomMemberListModel model(lager::make_constant(data)); | MatrixRoomMemberListModel model(lager::make_constant(data)); | ||||
| QCOMPARE(model.count(), 2); | QCOMPARE(model.count(), 2); | ||||
| auto first = toUniquePtr(model.at(0)); | auto first = toUniquePtr(model.at(0)); | ||||
| QCOMPARE(first->name(), "t1"); | QCOMPARE(first->name(), "user 1"); | ||||
| QCOMPARE(first->userId(), "@t1:tusooa.xyz"); | QCOMPARE(first->userId(), "@t1:tusooa.xyz"); | ||||
| auto second = toUniquePtr(model.at(1)); | auto second = toUniquePtr(model.at(1)); | ||||
| QCOMPARE(second->name(), QStringLiteral()); | QCOMPARE(second->name(), QStringLiteral()); | ||||
| QCOMPARE(second->userId(), "@t2:tusooa.xyz"); | QCOMPARE(second->userId(), "@t2:tusooa.xyz"); | ||||
| } | |||||
| void MatrixRoomMemberListModelTest::testFilter() | |||||
| { | |||||
| MatrixRoomMemberListModel model(lager::make_constant(data)); | |||||
| QCOMPARE(model.count(), 2); | |||||
| model.setfilter(QString("@t")); | |||||
| QCOMPARE(model.count(), 2); | |||||
| { | |||||
| model.setfilter(QString("user 1")); | |||||
| QCOMPARE(model.count(), 1); | |||||
| auto first = toUniquePtr(model.at(0)); | |||||
| QCOMPARE(first->userId(), QString("@t1:tusooa.xyz")); | |||||
| } | |||||
| { | |||||
| model.setfilter(QString("t2")); | |||||
| QCOMPARE(model.count(), 1); | |||||
| auto first = toUniquePtr(model.at(0)); | |||||
| QCOMPARE(first->userId(), QString("@t2:tusooa.xyz")); | |||||
| } | |||||
| } | } | ||||
| QTEST_MAIN(MatrixRoomMemberListModelTest) | QTEST_MAIN(MatrixRoomMemberListModelTest) | ||||
| #include "matrix-room-member-list-model-test.moc" | #include "matrix-room-member-list-model-test.moc" | ||||