summaryrefslogtreecommitdiffstats
path: root/tests/maildirresourcetest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-01-20 19:07:07 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-01-20 19:07:07 +0100
commitbdb01c2c068df326f5a8328ed1492ab1bea388c5 (patch)
tree25c2ee1b29bc481b6914c244ed9ca194b1415d16 /tests/maildirresourcetest.cpp
parent17e7ee40c9185c0505883853345fd6024c675b1a (diff)
downloadsink-bdb01c2c068df326f5a8328ed1492ab1bea388c5.tar.gz
sink-bdb01c2c068df326f5a8328ed1492ab1bea388c5.zip
Renamed Akonadi2 to Sink
(except for documentation).
Diffstat (limited to 'tests/maildirresourcetest.cpp')
-rw-r--r--tests/maildirresourcetest.cpp138
1 files changed, 69 insertions, 69 deletions
diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp
index ec4f6a4..6ad6ca6 100644
--- a/tests/maildirresourcetest.cpp
+++ b/tests/maildirresourcetest.cpp
@@ -57,18 +57,18 @@ private Q_SLOTS:
57 { 57 {
58 targetPath = tempDir.path() + "/maildir1/"; 58 targetPath = tempDir.path() + "/maildir1/";
59 59
60 Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); 60 Sink::Log::setDebugOutputLevel(Sink::Log::Trace);
61 MaildirResource::removeFromDisk("org.kde.maildir.instance1"); 61 MaildirResource::removeFromDisk("org.kde.maildir.instance1");
62 Akonadi2::ApplicationDomain::AkonadiResource resource; 62 Sink::ApplicationDomain::SinkResource resource;
63 resource.setProperty("identifier", "org.kde.maildir.instance1"); 63 resource.setProperty("identifier", "org.kde.maildir.instance1");
64 resource.setProperty("type", "org.kde.maildir"); 64 resource.setProperty("type", "org.kde.maildir");
65 resource.setProperty("path", targetPath); 65 resource.setProperty("path", targetPath);
66 Akonadi2::Store::create(resource).exec().waitForFinished(); 66 Sink::Store::create(resource).exec().waitForFinished();
67 } 67 }
68 68
69 void cleanup() 69 void cleanup()
70 { 70 {
71 Akonadi2::Store::shutdown(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished(); 71 Sink::Store::shutdown(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished();
72 MaildirResource::removeFromDisk("org.kde.maildir.instance1"); 72 MaildirResource::removeFromDisk("org.kde.maildir.instance1");
73 QDir dir(targetPath); 73 QDir dir(targetPath);
74 dir.removeRecursively(); 74 dir.removeRecursively();
@@ -80,46 +80,46 @@ private Q_SLOTS:
80 qDebug() << "-----------------------------------------"; 80 qDebug() << "-----------------------------------------";
81 qDebug(); 81 qDebug();
82 copyRecursively(TESTDATAPATH "/maildir1", targetPath); 82 copyRecursively(TESTDATAPATH "/maildir1", targetPath);
83 Akonadi2::Store::start(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished(); 83 Sink::Store::start(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished();
84 } 84 }
85 85
86 void testListFolders() 86 void testListFolders()
87 { 87 {
88 Akonadi2::Query query; 88 Sink::Query query;
89 query.resources << "org.kde.maildir.instance1"; 89 query.resources << "org.kde.maildir.instance1";
90 90
91 //Ensure all local data is processed 91 //Ensure all local data is processed
92 Akonadi2::Store::synchronize(query).exec().waitForFinished(); 92 Sink::Store::synchronize(query).exec().waitForFinished();
93 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 93 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
94 94
95 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); 95 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query);
96 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 96 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
97 QCOMPARE(model->rowCount(QModelIndex()), 2); 97 QCOMPARE(model->rowCount(QModelIndex()), 2);
98 } 98 }
99 99
100 void testListFolderTree() 100 void testListFolderTree()
101 { 101 {
102 Akonadi2::Query query; 102 Sink::Query query;
103 query.resources << "org.kde.maildir.instance1"; 103 query.resources << "org.kde.maildir.instance1";
104 query.parentProperty = "parent"; 104 query.parentProperty = "parent";
105 105
106 //Ensure all local data is processed 106 //Ensure all local data is processed
107 Akonadi2::Store::synchronize(query).exec().waitForFinished(); 107 Sink::Store::synchronize(query).exec().waitForFinished();
108 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 108 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
109 109
110 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); 110 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query);
111 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 111 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
112 QCOMPARE(model->rowCount(QModelIndex()), 1); 112 QCOMPARE(model->rowCount(QModelIndex()), 1);
113 auto parentIndex = model->index(0, 0, QModelIndex()); 113 auto parentIndex = model->index(0, 0, QModelIndex());
114 model->fetchMore(parentIndex); 114 model->fetchMore(parentIndex);
115 QTRY_VERIFY(model->data(parentIndex, Akonadi2::Store::ChildrenFetchedRole).toBool()); 115 QTRY_VERIFY(model->data(parentIndex, Sink::Store::ChildrenFetchedRole).toBool());
116 QCOMPARE(model->rowCount(parentIndex), 1); 116 QCOMPARE(model->rowCount(parentIndex), 1);
117 } 117 }
118 118
119 void testListMailsOfFolder() 119 void testListMailsOfFolder()
120 { 120 {
121 using namespace Akonadi2; 121 using namespace Sink;
122 using namespace Akonadi2::ApplicationDomain; 122 using namespace Sink::ApplicationDomain;
123 //Ensure all local data is processed 123 //Ensure all local data is processed
124 auto query = Query::ResourceFilter("org.kde.maildir.instance1"); 124 auto query = Query::ResourceFilter("org.kde.maildir.instance1");
125 Store::synchronize(query).exec().waitForFinished(); 125 Store::synchronize(query).exec().waitForFinished();
@@ -143,18 +143,18 @@ private Q_SLOTS:
143 143
144 void testMailContent() 144 void testMailContent()
145 { 145 {
146 Akonadi2::Query query; 146 Sink::Query query;
147 query.resources << "org.kde.maildir.instance1"; 147 query.resources << "org.kde.maildir.instance1";
148 query.requestedProperties << "folder" << "subject" << "mimeMessage" << "date"; 148 query.requestedProperties << "folder" << "subject" << "mimeMessage" << "date";
149 149
150 //Ensure all local data is processed 150 //Ensure all local data is processed
151 Akonadi2::Store::synchronize(query).exec().waitForFinished(); 151 Sink::Store::synchronize(query).exec().waitForFinished();
152 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 152 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
153 153
154 auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); 154 auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query);
155 QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 155 QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
156 QVERIFY(mailModel->rowCount(QModelIndex()) >= 1); 156 QVERIFY(mailModel->rowCount(QModelIndex()) >= 1);
157 auto mail = mailModel->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Mail::Ptr>(); 157 auto mail = mailModel->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>();
158 QVERIFY(!mail->getProperty("subject").toString().isEmpty()); 158 QVERIFY(!mail->getProperty("subject").toString().isEmpty());
159 QVERIFY(!mail->getProperty("mimeMessage").toString().isEmpty()); 159 QVERIFY(!mail->getProperty("mimeMessage").toString().isEmpty());
160 QVERIFY(mail->getProperty("date").toDateTime().isValid()); 160 QVERIFY(mail->getProperty("date").toDateTime().isValid());
@@ -163,85 +163,85 @@ private Q_SLOTS:
163 163
164 void testSyncFolderMove() 164 void testSyncFolderMove()
165 { 165 {
166 Akonadi2::Query query; 166 Sink::Query query;
167 query.resources << "org.kde.maildir.instance1"; 167 query.resources << "org.kde.maildir.instance1";
168 query.requestedProperties << "name"; 168 query.requestedProperties << "name";
169 169
170 //Ensure all local data is processed 170 //Ensure all local data is processed
171 Akonadi2::Store::synchronize(query).exec().waitForFinished(); 171 Sink::Store::synchronize(query).exec().waitForFinished();
172 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 172 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
173 173
174 auto targetPath = tempDir.path() + "/maildir1/"; 174 auto targetPath = tempDir.path() + "/maildir1/";
175 QDir dir(targetPath); 175 QDir dir(targetPath);
176 QVERIFY(dir.rename("inbox", "newbox")); 176 QVERIFY(dir.rename("inbox", "newbox"));
177 177
178 //Ensure all local data is processed 178 //Ensure all local data is processed
179 Akonadi2::Store::synchronize(query).exec().waitForFinished(); 179 Sink::Store::synchronize(query).exec().waitForFinished();
180 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 180 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
181 181
182 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); 182 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query);
183 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 183 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
184 QCOMPARE(model->rowCount(QModelIndex()), 2); 184 QCOMPARE(model->rowCount(QModelIndex()), 2);
185 QCOMPARE(model->match(model->index(0, 0, QModelIndex()), Qt::DisplayRole, QStringLiteral("newbox"), 1).size(), 1); 185 QCOMPARE(model->match(model->index(0, 0, QModelIndex()), Qt::DisplayRole, QStringLiteral("newbox"), 1).size(), 1);
186 } 186 }
187 187
188 void testReSyncMail() 188 void testReSyncMail()
189 { 189 {
190 Akonadi2::Query query; 190 Sink::Query query;
191 query.resources << "org.kde.maildir.instance1"; 191 query.resources << "org.kde.maildir.instance1";
192 query.requestedProperties << "folder" << "subject"; 192 query.requestedProperties << "folder" << "subject";
193 193
194 //Ensure all local data is processed 194 //Ensure all local data is processed
195 Akonadi2::Store::synchronize(query).exec().waitForFinished(); 195 Sink::Store::synchronize(query).exec().waitForFinished();
196 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 196 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
197 197
198 //Ensure all local data is processed 198 //Ensure all local data is processed
199 Akonadi2::Store::synchronize(query).exec().waitForFinished(); 199 Sink::Store::synchronize(query).exec().waitForFinished();
200 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 200 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
201 201
202 auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); 202 auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query);
203 QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 203 QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
204 QCOMPARE(mailModel->rowCount(QModelIndex()), 2); 204 QCOMPARE(mailModel->rowCount(QModelIndex()), 2);
205 } 205 }
206 206
207 void testSyncMailRemoval() 207 void testSyncMailRemoval()
208 { 208 {
209 Akonadi2::Query query; 209 Sink::Query query;
210 query.resources << "org.kde.maildir.instance1"; 210 query.resources << "org.kde.maildir.instance1";
211 query.requestedProperties << "folder" << "subject"; 211 query.requestedProperties << "folder" << "subject";
212 212
213 //Ensure all local data is processed 213 //Ensure all local data is processed
214 Akonadi2::Store::synchronize(query).exec().waitForFinished(); 214 Sink::Store::synchronize(query).exec().waitForFinished();
215 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 215 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
216 216
217 auto targetPath = tempDir.path() + "/maildir1/cur/1365777830.R28.localhost.localdomain:2,S"; 217 auto targetPath = tempDir.path() + "/maildir1/cur/1365777830.R28.localhost.localdomain:2,S";
218 QFile file(targetPath); 218 QFile file(targetPath);
219 QVERIFY(file.remove()); 219 QVERIFY(file.remove());
220 220
221 //Ensure all local data is processed 221 //Ensure all local data is processed
222 Akonadi2::Store::synchronize(query).exec().waitForFinished(); 222 Sink::Store::synchronize(query).exec().waitForFinished();
223 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 223 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
224 224
225 auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); 225 auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query);
226 QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 226 QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
227 QCOMPARE(mailModel->rowCount(QModelIndex()), 1); 227 QCOMPARE(mailModel->rowCount(QModelIndex()), 1);
228 } 228 }
229 229
230 void testCreateFolder() 230 void testCreateFolder()
231 { 231 {
232 Akonadi2::Query query; 232 Sink::Query query;
233 query.resources << "org.kde.maildir.instance1"; 233 query.resources << "org.kde.maildir.instance1";
234 234
235 //Ensure all local data is processed 235 //Ensure all local data is processed
236 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 236 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
237 237
238 Akonadi2::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); 238 Sink::ApplicationDomain::Folder folder("org.kde.maildir.instance1");
239 folder.setProperty("name", "testCreateFolder"); 239 folder.setProperty("name", "testCreateFolder");
240 240
241 Akonadi2::Store::create(folder).exec().waitForFinished(); 241 Sink::Store::create(folder).exec().waitForFinished();
242 242
243 //Ensure all local data is processed 243 //Ensure all local data is processed
244 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 244 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
245 245
246 auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; 246 auto targetPath = tempDir.path() + "/maildir1/testCreateFolder";
247 QFileInfo file(targetPath); 247 QFileInfo file(targetPath);
@@ -251,45 +251,45 @@ private Q_SLOTS:
251 251
252 void testRemoveFolder() 252 void testRemoveFolder()
253 { 253 {
254 Akonadi2::Query query; 254 Sink::Query query;
255 query.resources << "org.kde.maildir.instance1"; 255 query.resources << "org.kde.maildir.instance1";
256 256
257 auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; 257 auto targetPath = tempDir.path() + "/maildir1/testCreateFolder";
258 258
259 Akonadi2::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); 259 Sink::ApplicationDomain::Folder folder("org.kde.maildir.instance1");
260 folder.setProperty("name", "testCreateFolder"); 260 folder.setProperty("name", "testCreateFolder");
261 Akonadi2::Store::create(folder).exec().waitForFinished(); 261 Sink::Store::create(folder).exec().waitForFinished();
262 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 262 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
263 QTRY_VERIFY(QFileInfo(targetPath).exists()); 263 QTRY_VERIFY(QFileInfo(targetPath).exists());
264 264
265 Akonadi2::Query folderQuery; 265 Sink::Query folderQuery;
266 folderQuery.resources << "org.kde.maildir.instance1"; 266 folderQuery.resources << "org.kde.maildir.instance1";
267 folderQuery.propertyFilter.insert("name", "testCreateFolder"); 267 folderQuery.propertyFilter.insert("name", "testCreateFolder");
268 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(folderQuery); 268 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(folderQuery);
269 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 269 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
270 QCOMPARE(model->rowCount(QModelIndex()), 1); 270 QCOMPARE(model->rowCount(QModelIndex()), 1);
271 auto createdFolder = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); 271 auto createdFolder = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>();
272 272
273 Akonadi2::Store::remove(*createdFolder).exec().waitForFinished(); 273 Sink::Store::remove(*createdFolder).exec().waitForFinished();
274 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 274 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
275 QTRY_VERIFY(!QFileInfo(targetPath).exists()); 275 QTRY_VERIFY(!QFileInfo(targetPath).exists());
276 } 276 }
277 277
278 void testCreateMail() 278 void testCreateMail()
279 { 279 {
280 Akonadi2::Query query; 280 Sink::Query query;
281 query.resources << "org.kde.maildir.instance1"; 281 query.resources << "org.kde.maildir.instance1";
282 282
283 //Ensure all local data is processed 283 //Ensure all local data is processed
284 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 284 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
285 285
286 Akonadi2::ApplicationDomain::Mail mail("org.kde.maildir.instance1"); 286 Sink::ApplicationDomain::Mail mail("org.kde.maildir.instance1");
287 mail.setProperty("name", "testCreateMail"); 287 mail.setProperty("name", "testCreateMail");
288 288
289 Akonadi2::Store::create(mail).exec().waitForFinished(); 289 Sink::Store::create(mail).exec().waitForFinished();
290 290
291 //Ensure all local data is processed 291 //Ensure all local data is processed
292 Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 292 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished();
293 293
294 auto targetPath = tempDir.path() + "/maildir1/new"; 294 auto targetPath = tempDir.path() + "/maildir1/new";
295 QDir dir(targetPath); 295 QDir dir(targetPath);
@@ -299,8 +299,8 @@ private Q_SLOTS:
299 299
300 void testRemoveMail() 300 void testRemoveMail()
301 { 301 {
302 using namespace Akonadi2; 302 using namespace Sink;
303 using namespace Akonadi2::ApplicationDomain; 303 using namespace Sink::ApplicationDomain;
304 304
305 auto query = Query::ResourceFilter("org.kde.maildir.instance1"); 305 auto query = Query::ResourceFilter("org.kde.maildir.instance1");
306 Store::synchronize(query).exec().waitForFinished(); 306 Store::synchronize(query).exec().waitForFinished();
@@ -333,8 +333,8 @@ private Q_SLOTS:
333 333
334 void testMarkMailAsRead() 334 void testMarkMailAsRead()
335 { 335 {
336 using namespace Akonadi2; 336 using namespace Sink;
337 using namespace Akonadi2::ApplicationDomain; 337 using namespace Sink::ApplicationDomain;
338 338
339 auto query = Query::ResourceFilter("org.kde.maildir.instance1"); 339 auto query = Query::ResourceFilter("org.kde.maildir.instance1");
340 Store::synchronize(query).exec().waitForFinished(); 340 Store::synchronize(query).exec().waitForFinished();