summaryrefslogtreecommitdiffstats
path: root/tests/querytest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-12-17 19:16:55 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-12-17 19:16:55 +0100
commitef6150aa4c7c05ba4879dcf9274506ccd1b38f15 (patch)
treef1dfe73cd0f3a8e857ec450ccffc861a74a6653f /tests/querytest.cpp
parentb4168a61fbf56afea00f06d308eddbe1a562c1bf (diff)
downloadsink-ef6150aa4c7c05ba4879dcf9274506ccd1b38f15.tar.gz
sink-ef6150aa4c7c05ba4879dcf9274506ccd1b38f15.zip
Make queries by id work
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r--tests/querytest.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/querytest.cpp b/tests/querytest.cpp
index 1ba37f4..e09f7a4 100644
--- a/tests/querytest.cpp
+++ b/tests/querytest.cpp
@@ -106,6 +106,39 @@ private Q_SLOTS:
106 QCOMPARE(model->rowCount(), 1); 106 QCOMPARE(model->rowCount(), 1);
107 } 107 }
108 108
109 void testById()
110 {
111 QByteArray id;
112 //Setup
113 {
114 Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1");
115 Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished();
116 Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished();
117
118 Akonadi2::Query query;
119 query.resources << "org.kde.dummy.instance1";
120
121 //Ensure all local data is processed
122 Akonadi2::Store::synchronize(query).exec().waitForFinished();
123
124 //We fetch before the data is available and rely on the live query mechanism to deliver the actual data
125 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query);
126 model->fetchMore(QModelIndex());
127 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool());
128 QVERIFY(model->rowCount() >= 1);
129 id = model->index(0, 0).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Mail::Ptr>()->identifier();
130 }
131
132 //Test
133 Akonadi2::Query query;
134 query.resources << "org.kde.dummy.instance1";
135 query.ids << id;
136 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query);
137 model->fetchMore(QModelIndex());
138 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool());
139 QCOMPARE(model->rowCount(), 1);
140 }
141
109 void testFolder() 142 void testFolder()
110 { 143 {
111 //Setup 144 //Setup