diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-06 19:02:20 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-06 19:02:20 +0100 |
commit | cb657315068a57a05300d0f25dba3b27db9f57cb (patch) | |
tree | 75b45e421df0be6b2307c74663d1dc1de30d2b1b | |
parent | 303a3cf5ba48dd9857a1fb9600cedd604c71de8d (diff) | |
download | sink-cb657315068a57a05300d0f25dba3b27db9f57cb.tar.gz sink-cb657315068a57a05300d0f25dba3b27db9f57cb.zip |
Use Akonadi2::Store::ChildrenFetchedRole
-rw-r--r-- | tests/dummyresourcetest.cpp | 4 | ||||
-rw-r--r-- | tests/querytest.cpp | 22 |
2 files changed, 16 insertions, 10 deletions
diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index b8711a2..0e1f382 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp | |||
@@ -239,7 +239,7 @@ private Q_SLOTS: | |||
239 | //Test remove | 239 | //Test remove |
240 | { | 240 | { |
241 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); | 241 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); |
242 | //TODO ensure the initial query is done | 242 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
243 | QTRY_COMPARE(model->rowCount(QModelIndex()), 0); | 243 | QTRY_COMPARE(model->rowCount(QModelIndex()), 0); |
244 | } | 244 | } |
245 | } | 245 | } |
@@ -255,7 +255,7 @@ private Q_SLOTS: | |||
255 | query.propertyFilter.insert("uid", "testuid"); | 255 | query.propertyFilter.insert("uid", "testuid"); |
256 | 256 | ||
257 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); | 257 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); |
258 | //TODO ensure the initial query is done | 258 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
259 | 259 | ||
260 | Akonadi2::ApplicationDomain::Event event("org.kde.dummy.instance1"); | 260 | Akonadi2::ApplicationDomain::Event event("org.kde.dummy.instance1"); |
261 | event.setProperty("uid", "testuid"); | 261 | event.setProperty("uid", "testuid"); |
diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 516af35..f0f0766 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp | |||
@@ -33,6 +33,7 @@ private Q_SLOTS: | |||
33 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | 33 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); |
34 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); | 34 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); |
35 | QVERIFY(factory); | 35 | QVERIFY(factory); |
36 | Akonadi2::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | ||
36 | } | 37 | } |
37 | 38 | ||
38 | void init() | 39 | void init() |
@@ -78,15 +79,15 @@ private Q_SLOTS: | |||
78 | query.processAll = true; | 79 | query.processAll = true; |
79 | query.liveQuery = false; | 80 | query.liveQuery = false; |
80 | 81 | ||
81 | //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data | ||
82 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | ||
83 | |||
84 | //Ensure all local data is processed | 82 | //Ensure all local data is processed |
85 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 83 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
86 | 84 | ||
85 | //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data | ||
86 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | ||
87 | |||
87 | model->fetchMore(QModelIndex()); | 88 | model->fetchMore(QModelIndex()); |
88 | QVERIFY(model->rowCount() < 2); | 89 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
89 | QTRY_COMPARE(model->rowCount(), 1); | 90 | QCOMPARE(model->rowCount(), 1); |
90 | } | 91 | } |
91 | 92 | ||
92 | void testFolder() | 93 | void testFolder() |
@@ -128,7 +129,8 @@ private Q_SLOTS: | |||
128 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 129 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
129 | 130 | ||
130 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 131 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); |
131 | QTRY_COMPARE(model->rowCount(), 1); | 132 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
133 | QCOMPARE(model->rowCount(), 1); | ||
132 | 134 | ||
133 | auto folderEntity = model->index(0, 0).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); | 135 | auto folderEntity = model->index(0, 0).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); |
134 | QVERIFY(!folderEntity->identifier().isEmpty()); | 136 | QVERIFY(!folderEntity->identifier().isEmpty()); |
@@ -151,9 +153,13 @@ private Q_SLOTS: | |||
151 | //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data | 153 | //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data |
152 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 154 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); |
153 | model->fetchMore(QModelIndex()); | 155 | model->fetchMore(QModelIndex()); |
154 | QTRY_COMPARE(model->rowCount(), 1); | 156 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
157 | QCOMPARE(model->rowCount(), 1); | ||
155 | model->fetchMore(model->index(0, 0)); | 158 | model->fetchMore(model->index(0, 0)); |
156 | QTRY_COMPARE(model->rowCount(model->index(0, 0)), 1); | 159 | QTRY_VERIFY(model->data(model->index(0, 0), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
160 | QCOMPARE(model->rowCount(model->index(0, 0)), 1); | ||
161 | } | ||
162 | |||
157 | void testMailByUid() | 163 | void testMailByUid() |
158 | { | 164 | { |
159 | //Setup | 165 | //Setup |