From b1e5525be34850ef4d11cccbf23e118c93e93506 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 19 Dec 2015 19:39:53 +0100 Subject: Generalized the sync algorithms and applied them to mail. Not necessarily the smartest algorithms, but at least they work and are generally applicable. --- tests/maildirresourcetest.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'tests') diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp index e6b6849..a4856ce 100644 --- a/tests/maildirresourcetest.cpp +++ b/tests/maildirresourcetest.cpp @@ -149,6 +149,26 @@ private Q_SLOTS: QVERIFY(mailModel->rowCount(QModelIndex()) >= 1); } + void testMailContent() + { + Akonadi2::Query query; + query.resources << "org.kde.maildir.instance1"; + query.requestedProperties << "folder" << "subject" << "mimeMessage"; + query.syncOnDemand = true; + query.processAll = true; + + //Ensure all local data is processed + Akonadi2::Store::synchronize(query).exec().waitForFinished(); + + auto mailModel = Akonadi2::Store::loadModel(query); + QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); + QVERIFY(mailModel->rowCount(QModelIndex()) >= 1); + auto mail = mailModel->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value(); + QVERIFY(!mail->getProperty("subject").toString().isEmpty()); + QVERIFY(!mail->getProperty("mimeMessage").toString().isEmpty()); + } + + void testSyncFolderMove() { Akonadi2::Query query; @@ -173,6 +193,29 @@ private Q_SLOTS: QCOMPARE(model->match(model->index(0, 0, QModelIndex()), Qt::DisplayRole, QStringLiteral("newbox"), 1).size(), 1); } + void testSyncMailMove() + { + Akonadi2::Query query; + query.resources << "org.kde.maildir.instance1"; + query.syncOnDemand = true; + query.processAll = true; + query.requestedProperties << "folder" << "summary"; + + //Ensure all local data is processed + Akonadi2::Store::synchronize(query).exec().waitForFinished(); + + auto targetPath = tempDir.path() + QDir::separator() + "maildir1/cur/1365777830.R28.localhost.localdomain:2,S"; + QFile file(targetPath); + QVERIFY(file.remove()); + + //Ensure all local data is processed + Akonadi2::Store::synchronize(query).exec().waitForFinished(); + + auto mailModel = Akonadi2::Store::loadModel(query); + QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); + QCOMPARE(mailModel->rowCount(QModelIndex()), 1); + } + }; QTEST_MAIN(MaildirResourceTest) -- cgit v1.2.3