summaryrefslogtreecommitdiffstats
path: root/tests/querytest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r--tests/querytest.cpp136
1 files changed, 68 insertions, 68 deletions
diff --git a/tests/querytest.cpp b/tests/querytest.cpp
index f9344cd..62db15b 100644
--- a/tests/querytest.cpp
+++ b/tests/querytest.cpp
@@ -20,8 +20,8 @@ class QueryTest : public QObject
20private Q_SLOTS: 20private Q_SLOTS:
21 void initTestCase() 21 void initTestCase()
22 { 22 {
23 Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); 23 Sink::Log::setDebugOutputLevel(Sink::Log::Trace);
24 auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); 24 auto factory = Sink::ResourceFactory::load("org.kde.dummy");
25 QVERIFY(factory); 25 QVERIFY(factory);
26 DummyResource::removeFromDisk("org.kde.dummy.instance1"); 26 DummyResource::removeFromDisk("org.kde.dummy.instance1");
27 ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); 27 ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy");
@@ -29,11 +29,11 @@ private Q_SLOTS:
29 29
30 void cleanup() 30 void cleanup()
31 { 31 {
32 Akonadi2::Store::shutdown(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); 32 Sink::Store::shutdown(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished();
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 = Sink::ResourceFactory::load("org.kde.dummy");
35 QVERIFY(factory); 35 QVERIFY(factory);
36 Akonadi2::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); 36 Sink::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished();
37 } 37 }
38 38
39 void init() 39 void init()
@@ -46,13 +46,13 @@ private Q_SLOTS:
46 void testNoResources() 46 void testNoResources()
47 { 47 {
48 //Test 48 //Test
49 Akonadi2::Query query; 49 Sink::Query query;
50 query.resources << "foobar"; 50 query.resources << "foobar";
51 query.liveQuery = true; 51 query.liveQuery = true;
52 52
53 //We fetch before the data is available and rely on the live query mechanism to deliver the actual data 53 //We fetch before the data is available and rely on the live query mechanism to deliver the actual data
54 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); 54 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query);
55 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 55 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
56 QCOMPARE(model->rowCount(), 0); 56 QCOMPARE(model->rowCount(), 0);
57 } 57 }
58 58
@@ -61,17 +61,17 @@ private Q_SLOTS:
61 { 61 {
62 //Setup 62 //Setup
63 { 63 {
64 Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); 64 Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1");
65 Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished(); 65 Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished();
66 } 66 }
67 67
68 //Test 68 //Test
69 Akonadi2::Query query; 69 Sink::Query query;
70 query.resources << "org.kde.dummy.instance1"; 70 query.resources << "org.kde.dummy.instance1";
71 query.liveQuery = true; 71 query.liveQuery = true;
72 72
73 //We fetch before the data is available and rely on the live query mechanism to deliver the actual data 73 //We fetch before the data is available and rely on the live query mechanism to deliver the actual data
74 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); 74 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query);
75 model->fetchMore(QModelIndex()); 75 model->fetchMore(QModelIndex());
76 QTRY_COMPARE(model->rowCount(), 1); 76 QTRY_COMPARE(model->rowCount(), 1);
77 } 77 }
@@ -80,23 +80,23 @@ private Q_SLOTS:
80 { 80 {
81 //Setup 81 //Setup
82 { 82 {
83 Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); 83 Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1");
84 Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished(); 84 Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished();
85 } 85 }
86 86
87 //Test 87 //Test
88 Akonadi2::Query query; 88 Sink::Query query;
89 query.resources << "org.kde.dummy.instance1"; 89 query.resources << "org.kde.dummy.instance1";
90 query.liveQuery = false; 90 query.liveQuery = false;
91 91
92 //Ensure all local data is processed 92 //Ensure all local data is processed
93 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 93 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
94 94
95 //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data 95 //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data
96 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); 96 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query);
97 97
98 model->fetchMore(QModelIndex()); 98 model->fetchMore(QModelIndex());
99 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 99 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
100 QCOMPARE(model->rowCount(), 1); 100 QCOMPARE(model->rowCount(), 1);
101 } 101 }
102 102
@@ -105,31 +105,31 @@ private Q_SLOTS:
105 QByteArray id; 105 QByteArray id;
106 //Setup 106 //Setup
107 { 107 {
108 Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); 108 Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1");
109 Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished(); 109 Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished();
110 Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished(); 110 Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished();
111 111
112 Akonadi2::Query query; 112 Sink::Query query;
113 query.resources << "org.kde.dummy.instance1"; 113 query.resources << "org.kde.dummy.instance1";
114 114
115 //Ensure all local data is processed 115 //Ensure all local data is processed
116 Akonadi2::Store::synchronize(query).exec().waitForFinished(); 116 Sink::Store::synchronize(query).exec().waitForFinished();
117 117
118 //We fetch before the data is available and rely on the live query mechanism to deliver the actual data 118 //We fetch before the data is available and rely on the live query mechanism to deliver the actual data
119 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); 119 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query);
120 model->fetchMore(QModelIndex()); 120 model->fetchMore(QModelIndex());
121 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 121 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
122 QVERIFY(model->rowCount() >= 1); 122 QVERIFY(model->rowCount() >= 1);
123 id = model->index(0, 0).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Mail::Ptr>()->identifier(); 123 id = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>()->identifier();
124 } 124 }
125 125
126 //Test 126 //Test
127 Akonadi2::Query query; 127 Sink::Query query;
128 query.resources << "org.kde.dummy.instance1"; 128 query.resources << "org.kde.dummy.instance1";
129 query.ids << id; 129 query.ids << id;
130 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); 130 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query);
131 model->fetchMore(QModelIndex()); 131 model->fetchMore(QModelIndex());
132 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 132 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
133 QCOMPARE(model->rowCount(), 1); 133 QCOMPARE(model->rowCount(), 1);
134 } 134 }
135 135
@@ -137,20 +137,20 @@ private Q_SLOTS:
137 { 137 {
138 //Setup 138 //Setup
139 { 139 {
140 Akonadi2::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); 140 Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1");
141 Akonadi2::Store::create<Akonadi2::ApplicationDomain::Folder>(folder).exec().waitForFinished(); 141 Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished();
142 } 142 }
143 143
144 //Test 144 //Test
145 Akonadi2::Query query; 145 Sink::Query query;
146 query.resources << "org.kde.dummy.instance1"; 146 query.resources << "org.kde.dummy.instance1";
147 query.liveQuery = true; 147 query.liveQuery = true;
148 148
149 //We fetch before the data is available and rely on the live query mechanism to deliver the actual data 149 //We fetch before the data is available and rely on the live query mechanism to deliver the actual data
150 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); 150 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query);
151 model->fetchMore(QModelIndex()); 151 model->fetchMore(QModelIndex());
152 QTRY_COMPARE(model->rowCount(), 1); 152 QTRY_COMPARE(model->rowCount(), 1);
153 auto folderEntity = model->index(0, 0).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); 153 auto folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>();
154 QVERIFY(!folderEntity->identifier().isEmpty()); 154 QVERIFY(!folderEntity->identifier().isEmpty());
155 } 155 }
156 156
@@ -158,42 +158,42 @@ private Q_SLOTS:
158 { 158 {
159 //Setup 159 //Setup
160 { 160 {
161 Akonadi2::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); 161 Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1");
162 Akonadi2::Store::create<Akonadi2::ApplicationDomain::Folder>(folder).exec().waitForFinished(); 162 Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished();
163 163
164 Akonadi2::Query query; 164 Sink::Query query;
165 query.resources << "org.kde.dummy.instance1"; 165 query.resources << "org.kde.dummy.instance1";
166 166
167 //Ensure all local data is processed 167 //Ensure all local data is processed
168 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 168 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
169 169
170 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); 170 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query);
171 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 171 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
172 QCOMPARE(model->rowCount(), 1); 172 QCOMPARE(model->rowCount(), 1);
173 173
174 auto folderEntity = model->index(0, 0).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); 174 auto folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>();
175 QVERIFY(!folderEntity->identifier().isEmpty()); 175 QVERIFY(!folderEntity->identifier().isEmpty());
176 176
177 Akonadi2::ApplicationDomain::Folder subfolder("org.kde.dummy.instance1"); 177 Sink::ApplicationDomain::Folder subfolder("org.kde.dummy.instance1");
178 subfolder.setProperty("parent", folderEntity->identifier()); 178 subfolder.setProperty("parent", folderEntity->identifier());
179 Akonadi2::Store::create<Akonadi2::ApplicationDomain::Folder>(subfolder).exec().waitForFinished(); 179 Sink::Store::create<Sink::ApplicationDomain::Folder>(subfolder).exec().waitForFinished();
180 } 180 }
181 181
182 //Test 182 //Test
183 Akonadi2::Query query; 183 Sink::Query query;
184 query.resources << "org.kde.dummy.instance1"; 184 query.resources << "org.kde.dummy.instance1";
185 query.parentProperty = "parent"; 185 query.parentProperty = "parent";
186 186
187 //Ensure all local data is processed 187 //Ensure all local data is processed
188 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 188 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
189 189
190 //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data 190 //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data
191 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); 191 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query);
192 model->fetchMore(QModelIndex()); 192 model->fetchMore(QModelIndex());
193 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 193 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
194 QCOMPARE(model->rowCount(), 1); 194 QCOMPARE(model->rowCount(), 1);
195 model->fetchMore(model->index(0, 0)); 195 model->fetchMore(model->index(0, 0));
196 QTRY_VERIFY(model->data(model->index(0, 0), Akonadi2::Store::ChildrenFetchedRole).toBool()); 196 QTRY_VERIFY(model->data(model->index(0, 0), Sink::Store::ChildrenFetchedRole).toBool());
197 QCOMPARE(model->rowCount(model->index(0, 0)), 1); 197 QCOMPARE(model->rowCount(model->index(0, 0)), 1);
198 } 198 }
199 199
@@ -201,65 +201,65 @@ private Q_SLOTS:
201 { 201 {
202 //Setup 202 //Setup
203 { 203 {
204 Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); 204 Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1");
205 mail.setProperty("uid", "test1"); 205 mail.setProperty("uid", "test1");
206 mail.setProperty("sender", "doe@example.org"); 206 mail.setProperty("sender", "doe@example.org");
207 Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished(); 207 Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished();
208 } 208 }
209 209
210 //Test 210 //Test
211 Akonadi2::Query query; 211 Sink::Query query;
212 query.resources << "org.kde.dummy.instance1"; 212 query.resources << "org.kde.dummy.instance1";
213 query.liveQuery = false; 213 query.liveQuery = false;
214 query.propertyFilter.insert("uid", "test1"); 214 query.propertyFilter.insert("uid", "test1");
215 215
216 //Ensure all local data is processed 216 //Ensure all local data is processed
217 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 217 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
218 218
219 //We fetch before the data is available and rely on the live query mechanism to deliver the actual data 219 //We fetch before the data is available and rely on the live query mechanism to deliver the actual data
220 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); 220 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query);
221 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 221 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
222 QCOMPARE(model->rowCount(), 1); 222 QCOMPARE(model->rowCount(), 1);
223 } 223 }
224 224
225 void testMailByFolder() 225 void testMailByFolder()
226 { 226 {
227 //Setup 227 //Setup
228 Akonadi2::ApplicationDomain::Folder::Ptr folderEntity; 228 Sink::ApplicationDomain::Folder::Ptr folderEntity;
229 { 229 {
230 Akonadi2::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); 230 Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1");
231 Akonadi2::Store::create<Akonadi2::ApplicationDomain::Folder>(folder).exec().waitForFinished(); 231 Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished();
232 232
233 Akonadi2::Query query; 233 Sink::Query query;
234 query.resources << "org.kde.dummy.instance1"; 234 query.resources << "org.kde.dummy.instance1";
235 235
236 //Ensure all local data is processed 236 //Ensure all local data is processed
237 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 237 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
238 238
239 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); 239 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query);
240 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 240 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
241 QCOMPARE(model->rowCount(), 1); 241 QCOMPARE(model->rowCount(), 1);
242 242
243 folderEntity = model->index(0, 0).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); 243 folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>();
244 QVERIFY(!folderEntity->identifier().isEmpty()); 244 QVERIFY(!folderEntity->identifier().isEmpty());
245 245
246 Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); 246 Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1");
247 mail.setProperty("uid", "test1"); 247 mail.setProperty("uid", "test1");
248 mail.setProperty("folder", folderEntity->identifier()); 248 mail.setProperty("folder", folderEntity->identifier());
249 Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished(); 249 Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished();
250 } 250 }
251 251
252 //Test 252 //Test
253 Akonadi2::Query query; 253 Sink::Query query;
254 query.resources << "org.kde.dummy.instance1"; 254 query.resources << "org.kde.dummy.instance1";
255 query.propertyFilter.insert("folder", folderEntity->identifier()); 255 query.propertyFilter.insert("folder", folderEntity->identifier());
256 256
257 //Ensure all local data is processed 257 //Ensure all local data is processed
258 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 258 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
259 259
260 //We fetch before the data is available and rely on the live query mechanism to deliver the actual data 260 //We fetch before the data is available and rely on the live query mechanism to deliver the actual data
261 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); 261 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query);
262 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 262 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
263 QCOMPARE(model->rowCount(), 1); 263 QCOMPARE(model->rowCount(), 1);
264 } 264 }
265}; 265};