summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-05-31 17:24:40 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-05-31 17:24:40 +0200
commit4d89be0c8ed4a9b33d44f9782e93709be8fc8042 (patch)
treec2f06bc4ad8e6eaf53435536ec6ce448fdf80339
parented0faba01b26579e726f5a2d3cf5efb14140322c (diff)
downloadsink-4d89be0c8ed4a9b33d44f9782e93709be8fc8042.tar.gz
sink-4d89be0c8ed4a9b33d44f9782e93709be8fc8042.zip
Got rid of the maildirresourcetest
-rw-r--r--tests/CMakeLists.txt11
-rw-r--r--tests/data/maildir1/cur/1365777830.R28.localhost.localdomain:2,S72
-rw-r--r--tests/data/maildir1/inbox/cur/1365777829.R28.localhost.localdomain:2,S72
-rw-r--r--tests/data/maildir1/inbox/new/1365777840.R28.localhost.localdomain:272
-rw-r--r--tests/maildirresourcetest.cpp251
-rw-r--r--tests/mailsynctest.cpp24
-rw-r--r--tests/mailsynctest.h1
7 files changed, 23 insertions, 480 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index c9ad41f..0d45f3a 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -54,14 +54,3 @@ target_link_libraries(dummyresourcewritebenchmark sink_resource_dummy)
54target_link_libraries(querytest sink_resource_dummy) 54target_link_libraries(querytest sink_resource_dummy)
55target_link_libraries(modelinteractivitytest sink_resource_dummy) 55target_link_libraries(modelinteractivitytest sink_resource_dummy)
56target_link_libraries(inspectiontest sink_resource_dummy) 56target_link_libraries(inspectiontest sink_resource_dummy)
57
58if (BUILD_MAILDIR)
59 auto_tests (
60 maildirresourcetest
61 )
62 manual_tests (
63 maildirsyncbenchmark
64 )
65 target_link_libraries(maildirresourcetest sink_resource_maildir)
66 target_link_libraries(maildirsyncbenchmark sink_resource_maildir)
67endif()
diff --git a/tests/data/maildir1/cur/1365777830.R28.localhost.localdomain:2,S b/tests/data/maildir1/cur/1365777830.R28.localhost.localdomain:2,S
deleted file mode 100644
index 91231b5..0000000
--- a/tests/data/maildir1/cur/1365777830.R28.localhost.localdomain:2,S
+++ /dev/null
@@ -1,72 +0,0 @@
1Return-Path: <nepomuk-bounces@kde.org>
2Received: from compute4.internal (compute4.nyi.mail.srv.osa [10.202.2.44])
3 by slots3a1p1 (Cyrus git2.5+0-git-fastmail-8998) with LMTPA;
4 Mon, 11 Mar 2013 14:28:42 -0400
5X-Sieve: CMU Sieve 2.4
6X-Spam-score: 0.0
7X-Spam-hits: BAYES_00 -1.9, RCVD_IN_DNSWL_MED -2.3, RP_MATCHES_RCVD -0.704,
8 LANGUAGES unknown, BAYES_USED global, SA_VERSION 3.3.1
9X-Spam-source: IP='46.4.96.248', Host='postbox.kde.org', Country='unk', FromHeader='org',
10 MailFrom='org'
11X-Spam-charsets: plain='us-ascii'
12X-Resolved-to: chrigi_1@fastmail.fm
13X-Delivered-to: chrigi_1@fastmail.fm
14X-Mail-from: nepomuk-bounces@kde.org
15Received: from mx4.nyi.mail.srv.osa ([10.202.2.203])
16 by compute4.internal (LMTPProxy); Mon, 11 Mar 2013 14:28:42 -0400
17Received: from postbox.kde.org (postbox.kde.org [46.4.96.248])
18 by mx4.messagingengine.com (Postfix) with ESMTP id 1C9D2440F88
19 for <chrigi_1@fastmail.fm>; Mon, 11 Mar 2013 14:28:42 -0400 (EDT)
20Received: from postbox.kde.org (localhost [IPv6:::1])
21 by postbox.kde.org (Postfix) with ESMTP id 00FFEB3732B;
22 Mon, 11 Mar 2013 18:28:40 +0000 (UTC)
23DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=kde.org; s=default;
24 t=1363026520; bh=cOdvyBAJJ8ho64q0H7rxkl+cB2y6TiyVOX0fO3yZ64U=;
25 h=Date:From:To:Message-ID:In-Reply-To:References:MIME-Version:
26 Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:
27 List-Subscribe:Content-Type:Content-Transfer-Encoding:Sender; b=dv
28 dJAFu+6JCuNun5WIuP4ysfKpLh0DeuhEEfy2cQavUGMICJ27k7tI73x6gN37V5Q/evJ
29 NDFna3/IhNBsAQeLiXs28HKxzcVhbnq5jdFR6fbyo6k1fOKt5vTT1GTDZ+3zIGPD1CU
30 ioDBGxPb/Ds6gee90tjadOj6o+Oc+2ZSq94=
31X-Original-To: nepomuk@kde.org
32X-Remote-Delivered-To: nepomuk@localhost.kde.org
33Received: from build.kde.org (build.kde.org [IPv6:2a01:4f8:160:9363::5])
34 by postbox.kde.org (Postfix) with ESMTP id 4491CB3732B
35 for <nepomuk@kde.org>; Mon, 11 Mar 2013 18:28:27 +0000 (UTC)
36Received: from localhost ([127.0.0.1]) by build.kde.org with esmtp (Exim 4.72)
37 (envelope-from <null@kde.org>) id 1UF7SV-0000gs-11
38 for nepomuk@kde.org; Mon, 11 Mar 2013 18:28:27 +0000
39Date: Mon, 11 Mar 2013 18:28:27 +0000 (UTC)
40From: KDE CI System <null@kde.org>
41To: nepomuk@kde.org
42Message-ID: <1977027405.27.1363026507008.JavaMail.jenkins@build>
43In-Reply-To: <880663748.26.1363026023717.JavaMail.jenkins@build>
44References: <880663748.26.1363026023717.JavaMail.jenkins@build>
45MIME-Version: 1.0
46X-Jenkins-Job: nepomuk-core_stable
47X-Jenkins-Result: UNSTABLE
48X-Scanned-By: MIMEDefang 2.71 on 46.4.96.248
49Subject: [Nepomuk] Jenkins build is still unstable: nepomuk-core_stable #158
50X-BeenThere: nepomuk@kde.org
51X-Mailman-Version: 2.1.14
52Precedence: list
53List-Id: The Semantic KDE <nepomuk.kde.org>
54List-Unsubscribe: <https://mail.kde.org/mailman/options/nepomuk>,
55 <mailto:nepomuk-request@kde.org?subject=unsubscribe>
56List-Archive: <http://mail.kde.org/pipermail/nepomuk>
57List-Post: <mailto:nepomuk@kde.org>
58List-Help: <mailto:nepomuk-request@kde.org?subject=help>
59List-Subscribe: <https://mail.kde.org/mailman/listinfo/nepomuk>,
60 <mailto:nepomuk-request@kde.org?subject=subscribe>
61Content-Type: text/plain; charset="us-ascii"
62Content-Transfer-Encoding: 7bit
63Errors-To: nepomuk-bounces@kde.org
64Sender: nepomuk-bounces@kde.org
65X-Truedomain: NotChecked
66
67See <http://build.kde.org/job/nepomuk-core_stable/changes>
68
69_______________________________________________
70Nepomuk mailing list
71Nepomuk@kde.org
72https://mail.kde.org/mailman/listinfo/nepomuk
diff --git a/tests/data/maildir1/inbox/cur/1365777829.R28.localhost.localdomain:2,S b/tests/data/maildir1/inbox/cur/1365777829.R28.localhost.localdomain:2,S
deleted file mode 100644
index 91231b5..0000000
--- a/tests/data/maildir1/inbox/cur/1365777829.R28.localhost.localdomain:2,S
+++ /dev/null
@@ -1,72 +0,0 @@
1Return-Path: <nepomuk-bounces@kde.org>
2Received: from compute4.internal (compute4.nyi.mail.srv.osa [10.202.2.44])
3 by slots3a1p1 (Cyrus git2.5+0-git-fastmail-8998) with LMTPA;
4 Mon, 11 Mar 2013 14:28:42 -0400
5X-Sieve: CMU Sieve 2.4
6X-Spam-score: 0.0
7X-Spam-hits: BAYES_00 -1.9, RCVD_IN_DNSWL_MED -2.3, RP_MATCHES_RCVD -0.704,
8 LANGUAGES unknown, BAYES_USED global, SA_VERSION 3.3.1
9X-Spam-source: IP='46.4.96.248', Host='postbox.kde.org', Country='unk', FromHeader='org',
10 MailFrom='org'
11X-Spam-charsets: plain='us-ascii'
12X-Resolved-to: chrigi_1@fastmail.fm
13X-Delivered-to: chrigi_1@fastmail.fm
14X-Mail-from: nepomuk-bounces@kde.org
15Received: from mx4.nyi.mail.srv.osa ([10.202.2.203])
16 by compute4.internal (LMTPProxy); Mon, 11 Mar 2013 14:28:42 -0400
17Received: from postbox.kde.org (postbox.kde.org [46.4.96.248])
18 by mx4.messagingengine.com (Postfix) with ESMTP id 1C9D2440F88
19 for <chrigi_1@fastmail.fm>; Mon, 11 Mar 2013 14:28:42 -0400 (EDT)
20Received: from postbox.kde.org (localhost [IPv6:::1])
21 by postbox.kde.org (Postfix) with ESMTP id 00FFEB3732B;
22 Mon, 11 Mar 2013 18:28:40 +0000 (UTC)
23DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=kde.org; s=default;
24 t=1363026520; bh=cOdvyBAJJ8ho64q0H7rxkl+cB2y6TiyVOX0fO3yZ64U=;
25 h=Date:From:To:Message-ID:In-Reply-To:References:MIME-Version:
26 Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:
27 List-Subscribe:Content-Type:Content-Transfer-Encoding:Sender; b=dv
28 dJAFu+6JCuNun5WIuP4ysfKpLh0DeuhEEfy2cQavUGMICJ27k7tI73x6gN37V5Q/evJ
29 NDFna3/IhNBsAQeLiXs28HKxzcVhbnq5jdFR6fbyo6k1fOKt5vTT1GTDZ+3zIGPD1CU
30 ioDBGxPb/Ds6gee90tjadOj6o+Oc+2ZSq94=
31X-Original-To: nepomuk@kde.org
32X-Remote-Delivered-To: nepomuk@localhost.kde.org
33Received: from build.kde.org (build.kde.org [IPv6:2a01:4f8:160:9363::5])
34 by postbox.kde.org (Postfix) with ESMTP id 4491CB3732B
35 for <nepomuk@kde.org>; Mon, 11 Mar 2013 18:28:27 +0000 (UTC)
36Received: from localhost ([127.0.0.1]) by build.kde.org with esmtp (Exim 4.72)
37 (envelope-from <null@kde.org>) id 1UF7SV-0000gs-11
38 for nepomuk@kde.org; Mon, 11 Mar 2013 18:28:27 +0000
39Date: Mon, 11 Mar 2013 18:28:27 +0000 (UTC)
40From: KDE CI System <null@kde.org>
41To: nepomuk@kde.org
42Message-ID: <1977027405.27.1363026507008.JavaMail.jenkins@build>
43In-Reply-To: <880663748.26.1363026023717.JavaMail.jenkins@build>
44References: <880663748.26.1363026023717.JavaMail.jenkins@build>
45MIME-Version: 1.0
46X-Jenkins-Job: nepomuk-core_stable
47X-Jenkins-Result: UNSTABLE
48X-Scanned-By: MIMEDefang 2.71 on 46.4.96.248
49Subject: [Nepomuk] Jenkins build is still unstable: nepomuk-core_stable #158
50X-BeenThere: nepomuk@kde.org
51X-Mailman-Version: 2.1.14
52Precedence: list
53List-Id: The Semantic KDE <nepomuk.kde.org>
54List-Unsubscribe: <https://mail.kde.org/mailman/options/nepomuk>,
55 <mailto:nepomuk-request@kde.org?subject=unsubscribe>
56List-Archive: <http://mail.kde.org/pipermail/nepomuk>
57List-Post: <mailto:nepomuk@kde.org>
58List-Help: <mailto:nepomuk-request@kde.org?subject=help>
59List-Subscribe: <https://mail.kde.org/mailman/listinfo/nepomuk>,
60 <mailto:nepomuk-request@kde.org?subject=subscribe>
61Content-Type: text/plain; charset="us-ascii"
62Content-Transfer-Encoding: 7bit
63Errors-To: nepomuk-bounces@kde.org
64Sender: nepomuk-bounces@kde.org
65X-Truedomain: NotChecked
66
67See <http://build.kde.org/job/nepomuk-core_stable/changes>
68
69_______________________________________________
70Nepomuk mailing list
71Nepomuk@kde.org
72https://mail.kde.org/mailman/listinfo/nepomuk
diff --git a/tests/data/maildir1/inbox/new/1365777840.R28.localhost.localdomain:2 b/tests/data/maildir1/inbox/new/1365777840.R28.localhost.localdomain:2
deleted file mode 100644
index 91231b5..0000000
--- a/tests/data/maildir1/inbox/new/1365777840.R28.localhost.localdomain:2
+++ /dev/null
@@ -1,72 +0,0 @@
1Return-Path: <nepomuk-bounces@kde.org>
2Received: from compute4.internal (compute4.nyi.mail.srv.osa [10.202.2.44])
3 by slots3a1p1 (Cyrus git2.5+0-git-fastmail-8998) with LMTPA;
4 Mon, 11 Mar 2013 14:28:42 -0400
5X-Sieve: CMU Sieve 2.4
6X-Spam-score: 0.0
7X-Spam-hits: BAYES_00 -1.9, RCVD_IN_DNSWL_MED -2.3, RP_MATCHES_RCVD -0.704,
8 LANGUAGES unknown, BAYES_USED global, SA_VERSION 3.3.1
9X-Spam-source: IP='46.4.96.248', Host='postbox.kde.org', Country='unk', FromHeader='org',
10 MailFrom='org'
11X-Spam-charsets: plain='us-ascii'
12X-Resolved-to: chrigi_1@fastmail.fm
13X-Delivered-to: chrigi_1@fastmail.fm
14X-Mail-from: nepomuk-bounces@kde.org
15Received: from mx4.nyi.mail.srv.osa ([10.202.2.203])
16 by compute4.internal (LMTPProxy); Mon, 11 Mar 2013 14:28:42 -0400
17Received: from postbox.kde.org (postbox.kde.org [46.4.96.248])
18 by mx4.messagingengine.com (Postfix) with ESMTP id 1C9D2440F88
19 for <chrigi_1@fastmail.fm>; Mon, 11 Mar 2013 14:28:42 -0400 (EDT)
20Received: from postbox.kde.org (localhost [IPv6:::1])
21 by postbox.kde.org (Postfix) with ESMTP id 00FFEB3732B;
22 Mon, 11 Mar 2013 18:28:40 +0000 (UTC)
23DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=kde.org; s=default;
24 t=1363026520; bh=cOdvyBAJJ8ho64q0H7rxkl+cB2y6TiyVOX0fO3yZ64U=;
25 h=Date:From:To:Message-ID:In-Reply-To:References:MIME-Version:
26 Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:
27 List-Subscribe:Content-Type:Content-Transfer-Encoding:Sender; b=dv
28 dJAFu+6JCuNun5WIuP4ysfKpLh0DeuhEEfy2cQavUGMICJ27k7tI73x6gN37V5Q/evJ
29 NDFna3/IhNBsAQeLiXs28HKxzcVhbnq5jdFR6fbyo6k1fOKt5vTT1GTDZ+3zIGPD1CU
30 ioDBGxPb/Ds6gee90tjadOj6o+Oc+2ZSq94=
31X-Original-To: nepomuk@kde.org
32X-Remote-Delivered-To: nepomuk@localhost.kde.org
33Received: from build.kde.org (build.kde.org [IPv6:2a01:4f8:160:9363::5])
34 by postbox.kde.org (Postfix) with ESMTP id 4491CB3732B
35 for <nepomuk@kde.org>; Mon, 11 Mar 2013 18:28:27 +0000 (UTC)
36Received: from localhost ([127.0.0.1]) by build.kde.org with esmtp (Exim 4.72)
37 (envelope-from <null@kde.org>) id 1UF7SV-0000gs-11
38 for nepomuk@kde.org; Mon, 11 Mar 2013 18:28:27 +0000
39Date: Mon, 11 Mar 2013 18:28:27 +0000 (UTC)
40From: KDE CI System <null@kde.org>
41To: nepomuk@kde.org
42Message-ID: <1977027405.27.1363026507008.JavaMail.jenkins@build>
43In-Reply-To: <880663748.26.1363026023717.JavaMail.jenkins@build>
44References: <880663748.26.1363026023717.JavaMail.jenkins@build>
45MIME-Version: 1.0
46X-Jenkins-Job: nepomuk-core_stable
47X-Jenkins-Result: UNSTABLE
48X-Scanned-By: MIMEDefang 2.71 on 46.4.96.248
49Subject: [Nepomuk] Jenkins build is still unstable: nepomuk-core_stable #158
50X-BeenThere: nepomuk@kde.org
51X-Mailman-Version: 2.1.14
52Precedence: list
53List-Id: The Semantic KDE <nepomuk.kde.org>
54List-Unsubscribe: <https://mail.kde.org/mailman/options/nepomuk>,
55 <mailto:nepomuk-request@kde.org?subject=unsubscribe>
56List-Archive: <http://mail.kde.org/pipermail/nepomuk>
57List-Post: <mailto:nepomuk@kde.org>
58List-Help: <mailto:nepomuk-request@kde.org?subject=help>
59List-Subscribe: <https://mail.kde.org/mailman/listinfo/nepomuk>,
60 <mailto:nepomuk-request@kde.org?subject=subscribe>
61Content-Type: text/plain; charset="us-ascii"
62Content-Transfer-Encoding: 7bit
63Errors-To: nepomuk-bounces@kde.org
64Sender: nepomuk-bounces@kde.org
65X-Truedomain: NotChecked
66
67See <http://build.kde.org/job/nepomuk-core_stable/changes>
68
69_______________________________________________
70Nepomuk mailing list
71Nepomuk@kde.org
72https://mail.kde.org/mailman/listinfo/nepomuk
diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp
deleted file mode 100644
index 0a32000..0000000
--- a/tests/maildirresourcetest.cpp
+++ /dev/null
@@ -1,251 +0,0 @@
1#include <QtTest>
2
3#include <QString>
4#include <KMime/Message>
5
6#include "maildirresource/maildirresource.h"
7#include "store.h"
8#include "resourcecontrol.h"
9#include "commands.h"
10#include "entitybuffer.h"
11#include "resourceconfig.h"
12#include "modelresult.h"
13#include "pipeline.h"
14#include "log.h"
15#include "test.h"
16
17#define ASYNCCOMPARE(actual, expected) \
18do {\
19 if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\
20 return KAsync::error<void>(1, "Comparison failed.");\
21} while (0)
22
23#define ASYNCVERIFY(statement) \
24do {\
25 if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\
26 return KAsync::error<void>(1, "Verify failed.");\
27} while (0)
28
29using namespace Sink;
30
31static bool copyRecursively(const QString &srcFilePath, const QString &tgtFilePath)
32{
33 QFileInfo srcFileInfo(srcFilePath);
34 if (srcFileInfo.isDir()) {
35 QDir targetDir(tgtFilePath);
36 targetDir.cdUp();
37 if (!targetDir.mkdir(QFileInfo(srcFilePath).fileName())) {
38 qWarning() << "Failed to create directory " << tgtFilePath;
39 return false;
40 }
41 QDir sourceDir(srcFilePath);
42 QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
43 foreach (const QString &fileName, fileNames) {
44 const QString newSrcFilePath = srcFilePath + QLatin1Char('/') + fileName;
45 const QString newTgtFilePath = tgtFilePath + QLatin1Char('/') + fileName;
46 if (!copyRecursively(newSrcFilePath, newTgtFilePath))
47 return false;
48 }
49 } else {
50 if (!QFile::copy(srcFilePath, tgtFilePath)) {
51 qWarning() << "Failed to copy file " << tgtFilePath;
52 return false;
53 }
54 }
55 return true;
56}
57
58/**
59 * Test of complete system using the maildir resource.
60 *
61 * This test requires the maildir resource installed.
62 */
63class MaildirResourceTest : public QObject
64{
65 Q_OBJECT
66
67 QTemporaryDir tempDir;
68 QString targetPath;
69private slots:
70 void initTestCase()
71 {
72 targetPath = tempDir.path() + "/maildir1/";
73
74 Sink::Test::initTest();
75 Sink::Log::setDebugOutputLevel(Sink::Log::Trace);
76 MaildirResource::removeFromDisk("org.kde.maildir.instance1");
77 Sink::ApplicationDomain::SinkResource resource;
78 resource.setProperty("identifier", "org.kde.maildir.instance1");
79 resource.setProperty("type", "org.kde.maildir");
80 resource.setProperty("path", targetPath);
81 Sink::Store::create(resource).exec().waitForFinished();
82 }
83
84 void cleanup()
85 {
86 Sink::ResourceControl::shutdown(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished();
87 MaildirResource::removeFromDisk("org.kde.maildir.instance1");
88 QDir dir(targetPath);
89 dir.removeRecursively();
90 }
91
92 void init()
93 {
94 qDebug();
95 qDebug() << "-----------------------------------------";
96 qDebug();
97 copyRecursively(TESTDATAPATH "/maildir1", targetPath);
98 Sink::ResourceControl::start(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished();
99 }
100
101 void testListFolders()
102 {
103 Sink::Query query;
104 query.resources << "org.kde.maildir.instance1";
105
106 // Ensure all local data is processed
107 Sink::Store::synchronize(query).exec().waitForFinished();
108 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
109
110 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query);
111 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
112 QCOMPARE(model->rowCount(QModelIndex()), 3);
113 }
114
115 void testListFolderTree()
116 {
117 Sink::Query query;
118 query.resources << "org.kde.maildir.instance1";
119 query.parentProperty = "parent";
120
121 // Ensure all local data is processed
122 Sink::Store::synchronize(query).exec().waitForFinished();
123 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
124
125 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query);
126 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
127 QCOMPARE(model->rowCount(QModelIndex()), 1);
128 auto parentIndex = model->index(0, 0, QModelIndex());
129 model->fetchMore(parentIndex);
130 QTRY_VERIFY(model->data(parentIndex, Sink::Store::ChildrenFetchedRole).toBool());
131 QCOMPARE(model->rowCount(parentIndex), 2);
132 }
133
134 void testListMailsOfFolder()
135 {
136 using namespace Sink;
137 using namespace Sink::ApplicationDomain;
138 // Ensure all local data is processed
139 auto query = Query::ResourceFilter("org.kde.maildir.instance1");
140 Store::synchronize(query).exec().waitForFinished();
141 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
142 auto result = Store::fetchOne<Folder>(Query::ResourceFilter("org.kde.maildir.instance1") + Query::RequestedProperties(QByteArrayList() << "name"))
143 .then<QList<Mail::Ptr>, Folder>([](const Folder &folder) {
144 Trace() << "Found a folder" << folder.identifier();
145 return Store::fetchAll<Mail>(Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder"
146 << "subject"));
147 })
148 .then<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { QVERIFY(mails.size() >= 1); })
149 .exec();
150 result.waitForFinished();
151 QVERIFY(!result.errorCode());
152 }
153
154 void testMailContent()
155 {
156 Sink::Query query;
157 query.resources << "org.kde.maildir.instance1";
158 query.requestedProperties << "folder"
159 << "subject"
160 << "mimeMessage"
161 << "date";
162
163 // Ensure all local data is processed
164 Sink::Store::synchronize(query).exec().waitForFinished();
165 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
166
167 auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query);
168 QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
169 QVERIFY(mailModel->rowCount(QModelIndex()) >= 1);
170 auto mail = mailModel->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>();
171 QVERIFY(!mail->getProperty("subject").toString().isEmpty());
172 QVERIFY(!mail->getProperty("mimeMessage").toString().isEmpty());
173 QVERIFY(mail->getProperty("date").toDateTime().isValid());
174
175 QFileInfo info(mail->getProperty("mimeMessage").toString());
176 QVERIFY(info.exists());
177 }
178
179
180 void testSyncFolderMove()
181 {
182 Sink::Query query;
183 query.resources << "org.kde.maildir.instance1";
184 query.requestedProperties << "name";
185
186 // Ensure all local data is processed
187 Sink::Store::synchronize(query).exec().waitForFinished();
188 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
189
190 auto targetPath = tempDir.path() + "/maildir1/";
191 QDir dir(targetPath);
192 QVERIFY(dir.rename("inbox", "newbox"));
193
194 // Ensure all local data is processed
195 Sink::Store::synchronize(query).exec().waitForFinished();
196 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
197
198 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query);
199 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
200 QCOMPARE(model->rowCount(QModelIndex()), 4);
201 QCOMPARE(model->match(model->index(0, 0, QModelIndex()), Qt::DisplayRole, QStringLiteral("newbox"), 1).size(), 1);
202 }
203
204 void testReSyncMail()
205 {
206 Sink::Query query;
207 query.resources << "org.kde.maildir.instance1";
208 query.requestedProperties << "folder"
209 << "subject";
210
211 // Ensure all local data is processed
212 Sink::Store::synchronize(query).exec().waitForFinished();
213 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
214
215 // Ensure all local data is processed
216 Sink::Store::synchronize(query).exec().waitForFinished();
217 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
218
219 auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query);
220 QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
221 QCOMPARE(mailModel->rowCount(QModelIndex()), 3);
222 }
223
224 void testSyncMailRemoval()
225 {
226 Sink::Query query;
227 query.resources << "org.kde.maildir.instance1";
228 query.requestedProperties << "folder"
229 << "subject";
230
231 // Ensure all local data is processed
232 Sink::Store::synchronize(query).exec().waitForFinished();
233 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
234
235 auto targetPath = tempDir.path() + "/maildir1/cur/1365777830.R28.localhost.localdomain:2,S";
236 QFile file(targetPath);
237 QVERIFY(file.remove());
238
239 // Ensure all local data is processed
240 Sink::Store::synchronize(query).exec().waitForFinished();
241 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
242
243 auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query);
244 QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
245 QCOMPARE(mailModel->rowCount(QModelIndex()), 2);
246 }
247
248};
249
250QTEST_MAIN(MaildirResourceTest)
251#include "maildirresourcetest.moc"
diff --git a/tests/mailsynctest.cpp b/tests/mailsynctest.cpp
index 2fc8568..4f0b9bb 100644
--- a/tests/mailsynctest.cpp
+++ b/tests/mailsynctest.cpp
@@ -249,7 +249,7 @@ void MailSyncTest::testListMails()
249{ 249{
250 Sink::Query query; 250 Sink::Query query;
251 query.resources << mResourceInstanceIdentifier; 251 query.resources << mResourceInstanceIdentifier;
252 query.request<Mail::Subject>().request<Mail::MimeMessage>(); 252 query.request<Mail::Subject>().request<Mail::MimeMessage>().request<Mail::Folder>().request<Mail::Date>();
253 253
254 // Ensure all local data is processed 254 // Ensure all local data is processed
255 VERIFYEXEC(Store::synchronize(query)); 255 VERIFYEXEC(Store::synchronize(query));
@@ -265,6 +265,27 @@ void MailSyncTest::testListMails()
265 m.setContent(data); 265 m.setContent(data);
266 m.parse(); 266 m.parse();
267 QCOMPARE(mails.first()->getSubject(), m.subject(true)->asUnicodeString()); 267 QCOMPARE(mails.first()->getSubject(), m.subject(true)->asUnicodeString());
268 QVERIFY(!mails.first()->getFolder().isEmpty());
269 QVERIFY(mails.first()->getDate().isValid());
270 });
271 VERIFYEXEC(job);
272}
273
274void MailSyncTest::testResyncMails()
275{
276 Sink::Query query;
277 query.resources << mResourceInstanceIdentifier;
278
279 // Ensure all local data is processed
280 VERIFYEXEC(Store::synchronize(query));
281 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
282
283 // Ensure all local data is processed
284 VERIFYEXEC(Store::synchronize(query));
285 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
286
287 auto job = Store::fetchAll<Mail>(query).then<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) {
288 QCOMPARE(mails.size(), 1);
268 }); 289 });
269 VERIFYEXEC(job); 290 VERIFYEXEC(job);
270} 291}
@@ -294,7 +315,6 @@ void MailSyncTest::testFetchNewRemovedMessages()
294 VERIFYEXEC(job); 315 VERIFYEXEC(job);
295 } 316 }
296 317
297
298 removeMessage(QStringList() << "test", messageIdentifier); 318 removeMessage(QStringList() << "test", messageIdentifier);
299 319
300 Store::synchronize(query).exec().waitForFinished(); 320 Store::synchronize(query).exec().waitForFinished();
diff --git a/tests/mailsynctest.h b/tests/mailsynctest.h
index b0fda7c..ec40f33 100644
--- a/tests/mailsynctest.h
+++ b/tests/mailsynctest.h
@@ -82,6 +82,7 @@ private slots:
82 void testListRemovedSubFolder(); 82 void testListRemovedSubFolder();
83 83
84 void testListMails(); 84 void testListMails();
85 void testResyncMails();
85 void testFetchNewRemovedMessages(); 86 void testFetchNewRemovedMessages();
86 87
87 void testFailingSync(); 88 void testFailingSync();