Changeset View
Changeset View
Standalone View
Standalone View
src/tests/matrix-room-list-test.cpp
| Show First 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | void MatrixRoomListTest::testFilter() | ||||
| auto room1 = makeRoom( | auto room1 = makeRoom( | ||||
| withRoomState({makeEvent(withStateKey("") | withEventType("m.room.name") | withEventContent(json{{"name", "some room"}}))}) | withRoomState({makeEvent(withStateKey("") | withEventType("m.room.name") | withEventContent(json{{"name", "some room"}}))}) | ||||
| ); | ); | ||||
| auto room2 = makeRoom( | auto room2 = makeRoom( | ||||
| withRoomState({makeEvent(withStateKey("") | withEventType("m.room.name") | withEventContent(json{{"name", "some other room"}}))}) | withRoomState({makeEvent(withStateKey("") | withEventType("m.room.name") | withEventContent(json{{"name", "some other room"}}))}) | ||||
| ); | ); | ||||
| auto room3 = makeRoom( | auto room3 = makeRoom( | ||||
| withRoomId("!some:example.org") | withRoomId("!some:example.org") | ||||
| | withRoomState({ | |||||
| makeMemberEvent(withStateKey("@foo:tusooa.xyz") | withEventKV(json::json_pointer("/content/displayname"), "User aaa")), | |||||
| makeMemberEvent(withStateKey("@bar:tusooa.xyz") | withEventKV(json::json_pointer("/content/displayname"), "User bbb")), | |||||
| }) | |||||
| ); | ); | ||||
| room3.heroIds = immer::flex_vector<std::string>{"@foo:tusooa.xyz", "@bar:tusooa.xyz"}; | |||||
| withRoom(room1)(model.client); | withRoom(room1)(model.client); | ||||
| withRoom(room2)(model.client); | withRoom(room2)(model.client); | ||||
| withRoom(room3)(model.client); | withRoom(room3)(model.client); | ||||
| std::unique_ptr<MatrixSdk> sdk{makeTestSdk(model)}; | std::unique_ptr<MatrixSdk> sdk{makeTestSdk(model)}; | ||||
| auto roomList = toUniquePtr(sdk->roomList()); | auto roomList = toUniquePtr(sdk->roomList()); | ||||
| roomList->setfilter("some"); | roomList->setfilter("some"); | ||||
| QCOMPARE(roomList->count(), 2); | QCOMPARE(roomList->count(), 2); | ||||
| QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room2.roomId)); | QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room2.roomId)); | ||||
| QCOMPARE(roomList->roomIdAt(1), QString::fromStdString(room1.roomId)); | QCOMPARE(roomList->roomIdAt(1), QString::fromStdString(room1.roomId)); | ||||
| roomList->setfilter("!some:example.org"); | roomList->setfilter("!some:example.org"); | ||||
| QCOMPARE(roomList->count(), 1); | |||||
| QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room3.roomId)); | |||||
| roomList->setfilter("foo"); | |||||
| QCOMPARE(roomList->count(), 1); | |||||
| QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room3.roomId)); | |||||
| roomList->setfilter("aaa"); | |||||
| QCOMPARE(roomList->count(), 1); | QCOMPARE(roomList->count(), 1); | ||||
| QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room3.roomId)); | QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room3.roomId)); | ||||
| } | } | ||||
| QTEST_MAIN(MatrixRoomListTest) | QTEST_MAIN(MatrixRoomListTest) | ||||
| #include "matrix-room-list-test.moc" | #include "matrix-room-list-test.moc" | ||||