aboutsummaryrefslogtreecommitdiff
path: root/examples/qmc-example.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-12-12 13:20:46 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-12-12 13:20:46 +0900
commitc46663aece5e001543b07d3ed901e64c38be4172 (patch)
tree95e8eb7ad2e99225b45ab271b1347125cc5a7a55 /examples/qmc-example.cpp
parent095444aff98ac56663bb205837a57e746d950f3b (diff)
downloadlibquotient-c46663aece5e001543b07d3ed901e64c38be4172.tar.gz
libquotient-c46663aece5e001543b07d3ed901e64c38be4172.zip
qmc-example: Use lazy-loading; check full-loading upon setDisplayed
Diffstat (limited to 'examples/qmc-example.cpp')
-rw-r--r--examples/qmc-example.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/examples/qmc-example.cpp b/examples/qmc-example.cpp
index 9c86d4a9..bdb9ef3f 100644
--- a/examples/qmc-example.cpp
+++ b/examples/qmc-example.cpp
@@ -26,6 +26,7 @@ class QMCTest : public QObject
void setup(const QString& testRoomName);
void onNewRoom(Room* r);
void startTests();
+ void loadMembers();
void sendMessage();
void addAndRemoveTag();
void sendAndRedact();
@@ -80,6 +81,7 @@ void QMCTest::setup(const QString& testRoomName)
cout << "Access token: " << c->accessToken().toStdString() << endl;
// Setting up sync loop
+ c->setLazyLoading(true);
c->sync();
connect(c.data(), &Connection::syncDone, c.data(), [this,testRoomName] {
cout << "Sync complete, "
@@ -142,12 +144,41 @@ void QMCTest::onNewRoom(Room* r)
void QMCTest::startTests()
{
cout << "Starting tests" << endl;
+ loadMembers();
sendMessage();
addAndRemoveTag();
sendAndRedact();
markDirectChat();
}
+void QMCTest::loadMembers()
+{
+ running.push_back("Loading members");
+ // The dedicated qmc-test room is too small to test
+ // lazy-loading-then-full-loading; use #test:matrix.org instead.
+ // TODO: #264
+ auto* r = c->room(QStringLiteral("!vfFxDRtZSSdspfTSEr:matrix.org"));
+ if (!r)
+ {
+ cout << "#test:matrix.org is not found in the test user's rooms" << endl;
+ QMC_CHECK("Loading members", false);
+ return;
+ }
+ // It's not exactly correct because an arbitrary server might not support
+ // lazy loading; but in the absence of capabilities framework we assume
+ // it does.
+ if (r->memberNames().size() < r->joinedCount())
+ {
+ cout << "Lazy loading doesn't seem to be enabled" << endl;
+ QMC_CHECK("Loading members", false);
+ return;
+ }
+ r->setDisplayed();
+ connect(r, &Room::allMembersLoaded, [this] {
+ QMC_CHECK("Loading members", true);
+ });
+}
+
void QMCTest::sendMessage()
{
running.push_back("Message sending");