diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/dummyresourcetest.cpp | 24 | ||||
-rw-r--r-- | tests/querytest.cpp | 24 | ||||
-rw-r--r-- | tests/testimplementations.h | 4 |
3 files changed, 49 insertions, 3 deletions
diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index d027266..3b90e6c 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp | |||
@@ -64,6 +64,9 @@ private Q_SLOTS: | |||
64 | query.syncOnDemand = false; | 64 | query.syncOnDemand = false; |
65 | query.processAll = true; | 65 | query.processAll = true; |
66 | 66 | ||
67 | //Ensure all local data is processed | ||
68 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
69 | |||
67 | query.propertyFilter.insert("uid", "testuid"); | 70 | query.propertyFilter.insert("uid", "testuid"); |
68 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); | 71 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); |
69 | result.exec(); | 72 | result.exec(); |
@@ -88,6 +91,9 @@ private Q_SLOTS: | |||
88 | query.syncOnDemand = false; | 91 | query.syncOnDemand = false; |
89 | query.processAll = true; | 92 | query.processAll = true; |
90 | 93 | ||
94 | //Ensure all local data is processed | ||
95 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
96 | |||
91 | query.propertyFilter.insert("uid", "testuid"); | 97 | query.propertyFilter.insert("uid", "testuid"); |
92 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); | 98 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); |
93 | result.exec(); | 99 | result.exec(); |
@@ -114,6 +120,9 @@ private Q_SLOTS: | |||
114 | query.syncOnDemand = false; | 120 | query.syncOnDemand = false; |
115 | query.processAll = true; | 121 | query.processAll = true; |
116 | 122 | ||
123 | //Ensure all local data is processed | ||
124 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
125 | |||
117 | query.propertyFilter.insert("summary", "summaryValue2"); | 126 | query.propertyFilter.insert("summary", "summaryValue2"); |
118 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); | 127 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); |
119 | result.exec(); | 128 | result.exec(); |
@@ -145,6 +154,9 @@ private Q_SLOTS: | |||
145 | query.syncOnDemand = true; | 154 | query.syncOnDemand = true; |
146 | query.processAll = true; | 155 | query.processAll = true; |
147 | 156 | ||
157 | //Ensure all local data is processed | ||
158 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
159 | |||
148 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); | 160 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); |
149 | result.exec(); | 161 | result.exec(); |
150 | QVERIFY(!result.isEmpty()); | 162 | QVERIFY(!result.isEmpty()); |
@@ -160,6 +172,9 @@ private Q_SLOTS: | |||
160 | query.syncOnDemand = true; | 172 | query.syncOnDemand = true; |
161 | query.processAll = true; | 173 | query.processAll = true; |
162 | 174 | ||
175 | //Ensure all local data is processed | ||
176 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
177 | |||
163 | async::SyncListResult<Akonadi2::ApplicationDomain::Mail::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Mail>(query)); | 178 | async::SyncListResult<Akonadi2::ApplicationDomain::Mail::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Mail>(query)); |
164 | result.exec(); | 179 | result.exec(); |
165 | QVERIFY(!result.isEmpty()); | 180 | QVERIFY(!result.isEmpty()); |
@@ -182,6 +197,9 @@ private Q_SLOTS: | |||
182 | query.processAll = true; | 197 | query.processAll = true; |
183 | query.propertyFilter.insert("uid", "testuid"); | 198 | query.propertyFilter.insert("uid", "testuid"); |
184 | 199 | ||
200 | //Ensure all local data is processed | ||
201 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
202 | |||
185 | //Test create | 203 | //Test create |
186 | Akonadi2::ApplicationDomain::Event event2; | 204 | Akonadi2::ApplicationDomain::Event event2; |
187 | { | 205 | { |
@@ -198,6 +216,9 @@ private Q_SLOTS: | |||
198 | event2.setProperty("summary", "summaryValue2"); | 216 | event2.setProperty("summary", "summaryValue2"); |
199 | Akonadi2::Store::modify<Akonadi2::ApplicationDomain::Event>(event2).exec().waitForFinished(); | 217 | Akonadi2::Store::modify<Akonadi2::ApplicationDomain::Event>(event2).exec().waitForFinished(); |
200 | 218 | ||
219 | //Ensure all local data is processed | ||
220 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
221 | |||
201 | //Test modify | 222 | //Test modify |
202 | { | 223 | { |
203 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); | 224 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); |
@@ -210,6 +231,9 @@ private Q_SLOTS: | |||
210 | 231 | ||
211 | Akonadi2::Store::remove<Akonadi2::ApplicationDomain::Event>(event2).exec().waitForFinished(); | 232 | Akonadi2::Store::remove<Akonadi2::ApplicationDomain::Event>(event2).exec().waitForFinished(); |
212 | 233 | ||
234 | //Ensure all local data is processed | ||
235 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
236 | |||
213 | //Test remove | 237 | //Test remove |
214 | { | 238 | { |
215 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); | 239 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); |
diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 9f4b3bb..47d977b 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp | |||
@@ -57,11 +57,33 @@ private Q_SLOTS: | |||
57 | query.syncOnDemand = false; | 57 | query.syncOnDemand = false; |
58 | query.processAll = true; | 58 | query.processAll = true; |
59 | 59 | ||
60 | auto model = new ModelResult<Akonadi2::ApplicationDomain::Mail>(query, QList<QByteArray>() << "summary" << "uid"); | 60 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); |
61 | model->fetchMore(QModelIndex()); | 61 | model->fetchMore(QModelIndex()); |
62 | QTRY_COMPARE(model->rowCount(), 1); | 62 | QTRY_COMPARE(model->rowCount(), 1); |
63 | } | 63 | } |
64 | 64 | ||
65 | void testSingleWithDelay() | ||
66 | { | ||
67 | //Setup | ||
68 | { | ||
69 | Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | ||
70 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | ||
71 | } | ||
72 | |||
73 | //Test | ||
74 | Akonadi2::Query query; | ||
75 | query.resources << "org.kde.dummy.instance1"; | ||
76 | query.syncOnDemand = false; | ||
77 | query.processAll = true; | ||
78 | query.liveQuery = true; | ||
79 | |||
80 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | ||
81 | QTest::qWait(200); | ||
82 | model->fetchMore(QModelIndex()); | ||
83 | QVERIFY(model->rowCount() < 2); | ||
84 | QTRY_COMPARE(model->rowCount(), 1); | ||
85 | } | ||
86 | |||
65 | // void testTree() | 87 | // void testTree() |
66 | // { | 88 | // { |
67 | // //Setup | 89 | // //Setup |
diff --git a/tests/testimplementations.h b/tests/testimplementations.h index eee78b0..1436c68 100644 --- a/tests/testimplementations.h +++ b/tests/testimplementations.h | |||
@@ -85,8 +85,8 @@ public Q_SLOTS: | |||
85 | class TestResourceFacade : public Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event> | 85 | class TestResourceFacade : public Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event> |
86 | { | 86 | { |
87 | public: | 87 | public: |
88 | TestResourceFacade(const QByteArray &instanceIdentifier, const QSharedPointer<EntityStorage<Akonadi2::ApplicationDomain::Event> > storage, const QSharedPointer<Akonadi2::ResourceAccessInterface> resourceAccess) | 88 | TestResourceFacade(const QByteArray &instanceIdentifier, const QSharedPointer<Akonadi2::ResourceAccessInterface> resourceAccess) |
89 | : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event>(instanceIdentifier, QSharedPointer<TestEventAdaptorFactory>::create(), storage, resourceAccess) | 89 | : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event>(instanceIdentifier, QSharedPointer<TestEventAdaptorFactory>::create(), resourceAccess) |
90 | { | 90 | { |
91 | 91 | ||
92 | } | 92 | } |