Changeset View
Changeset View
Standalone View
Standalone View
src/tests/matrix-room-list-test.cpp
| Show All 26 Lines | |||||
| { | { | ||||
| Q_OBJECT | Q_OBJECT | ||||
| private Q_SLOTS: | private Q_SLOTS: | ||||
| void testRoomList(); | void testRoomList(); | ||||
| void testSorted(); | void testSorted(); | ||||
| void testSortedWithTag(); | void testSortedWithTag(); | ||||
| void testFilter(); | void testFilter(); | ||||
| void testPriority(); | |||||
| }; | }; | ||||
| static auto tagEvent = Event{R"({ | static auto tagEvent = Event{R"({ | ||||
| "content": { | "content": { | ||||
| "tags": {"m.favourite": {}} | "tags": {"m.favourite": {}} | ||||
| }, | }, | ||||
| "type": "m.tag" | "type": "m.tag" | ||||
| })"_json}; | })"_json}; | ||||
| ▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | void MatrixRoomListTest::testFilter() | ||||
| QCOMPARE(roomList->count(), 1); | QCOMPARE(roomList->count(), 1); | ||||
| QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room3.roomId)); | QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room3.roomId)); | ||||
| // By custom nickname of user (@foo:tusooa.xyz) | // By custom nickname of user (@foo:tusooa.xyz) | ||||
| roomList->setfilter("xxxx"); | roomList->setfilter("xxxx"); | ||||
| QCOMPARE(roomList->count(), 1); | QCOMPARE(roomList->count(), 1); | ||||
| QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room3.roomId)); | QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room3.roomId)); | ||||
| } | |||||
| void MatrixRoomListTest::testPriority() | |||||
| { | |||||
| auto model = makeTestModel(); | |||||
| RoomModel roomFavourited = makeRoom( | |||||
| withRoomId("!favourite:tusooa.xyz") | |||||
| | withRoomAccountData(immer::flex_vector{ | |||||
| makeEvent(withEventContent(tagEvent))})); | |||||
| RoomModel roomInvited = makeRoom( | |||||
| withRoomId("!invite:tusooa.xyz") | |||||
| | withRoomMembership(RoomMembership::Invite)); | |||||
| model.client.roomList.rooms = model.client.roomList.rooms.set( | |||||
| roomInvited.roomId, roomInvited); | |||||
| model.client.roomList.rooms = model.client.roomList.rooms.set( | |||||
| roomFavourited.roomId, roomFavourited); | |||||
| std::unique_ptr<MatrixSdk> sdk{makeTestSdk(model)}; | |||||
| auto roomList = toUniquePtr(sdk->roomList()); | |||||
| QCOMPARE(roomList->count(), 3); | |||||
| // Priority: Invite > Favourite | |||||
| QCOMPARE(roomList->roomIdAt(0), "!invite:tusooa.xyz"); | |||||
| QCOMPARE(roomList->roomIdAt(1), "!favourite:tusooa.xyz"); | |||||
| } | } | ||||
| QTEST_MAIN(MatrixRoomListTest) | QTEST_MAIN(MatrixRoomListTest) | ||||
| #include "matrix-room-list-test.moc" | #include "matrix-room-list-test.moc" | ||||