diff options
-rw-r--r-- | examples/maildirresource/libmaildir/maildir.cpp | 13 | ||||
-rw-r--r-- | examples/maildirresource/maildirresource.cpp | 12 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/data/maildir1/cur/1365777829.R28.localhost.localdomain:2,S | 72 | ||||
-rw-r--r-- | tests/data/maildir1/inbox/cur/1365777829.R28.localhost.localdomain:2,S | 72 | ||||
-rw-r--r-- | tests/maildirresourcetest.cpp | 89 |
6 files changed, 246 insertions, 14 deletions
diff --git a/examples/maildirresource/libmaildir/maildir.cpp b/examples/maildirresource/libmaildir/maildir.cpp index 37bf6ea..67a2d2d 100644 --- a/examples/maildirresource/libmaildir/maildir.cpp +++ b/examples/maildirresource/libmaildir/maildir.cpp | |||
@@ -402,11 +402,14 @@ Maildir Maildir::parent() const | |||
402 | return Maildir(); | 402 | return Maildir(); |
403 | QDir dir(d->path); | 403 | QDir dir(d->path); |
404 | dir.cdUp(); | 404 | dir.cdUp(); |
405 | if (!dir.dirName().startsWith(QLatin1Char('.')) || !dir.dirName().endsWith(QLatin1String(".directory"))) | 405 | //FIXME Figure out how this is acutally supposed to work |
406 | return Maildir(); | 406 | //There seem to be a bunch of conflicting standards, and nesting folders is apparently not what we're supposed to be doing, |
407 | const QString parentName = dir.dirName().mid(1, dir.dirName().size() - 11); | 407 | //but it works for the time being. |
408 | dir.cdUp(); | 408 | // if (!dir.dirName().startsWith(QLatin1Char('.')) || !dir.dirName().endsWith(QLatin1String(".directory"))) |
409 | dir.cd(parentName); | 409 | // return Maildir(); |
410 | // const QString parentName = dir.dirName().mid(1, dir.dirName().size() - 11); | ||
411 | // dir.cdUp(); | ||
412 | // dir.cd(parentName); | ||
410 | return Maildir (dir.path()); | 413 | return Maildir (dir.path()); |
411 | } | 414 | } |
412 | 415 | ||
diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index f9cc2a4..a19756a 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp | |||
@@ -48,7 +48,7 @@ MaildirResource::MaildirResource(const QByteArray &instanceIdentifier, const QSh | |||
48 | { | 48 | { |
49 | addType(ENTITY_TYPE_MAIL, QSharedPointer<MaildirMailAdaptorFactory>::create(), | 49 | addType(ENTITY_TYPE_MAIL, QSharedPointer<MaildirMailAdaptorFactory>::create(), |
50 | QVector<Akonadi2::Preprocessor*>() << new DefaultIndexUpdater<Akonadi2::ApplicationDomain::Mail>); | 50 | QVector<Akonadi2::Preprocessor*>() << new DefaultIndexUpdater<Akonadi2::ApplicationDomain::Mail>); |
51 | addType(ENTITY_TYPE_MAIL, QSharedPointer<MaildirMailAdaptorFactory>::create(), | 51 | addType(ENTITY_TYPE_FOLDER, QSharedPointer<MaildirFolderAdaptorFactory>::create(), |
52 | QVector<Akonadi2::Preprocessor*>() << new DefaultIndexUpdater<Akonadi2::ApplicationDomain::Folder>); | 52 | QVector<Akonadi2::Preprocessor*>() << new DefaultIndexUpdater<Akonadi2::ApplicationDomain::Folder>); |
53 | auto config = ResourceConfig::getConfiguration(instanceIdentifier); | 53 | auto config = ResourceConfig::getConfiguration(instanceIdentifier); |
54 | mMaildirPath = config.value("path").toString(); | 54 | mMaildirPath = config.value("path").toString(); |
@@ -101,7 +101,6 @@ void MaildirResource::synchronizeFolders(Akonadi2::Storage::Transaction &transac | |||
101 | 101 | ||
102 | Akonadi2::Storage store(Akonadi2::storageLocation(), mResourceInstanceIdentifier + ".synchronization", Akonadi2::Storage::ReadWrite); | 102 | Akonadi2::Storage store(Akonadi2::storageLocation(), mResourceInstanceIdentifier + ".synchronization", Akonadi2::Storage::ReadWrite); |
103 | auto synchronizationTransaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | 103 | auto synchronizationTransaction = store.createTransaction(Akonadi2::Storage::ReadWrite); |
104 | Index ridMapping("rid.mapping", synchronizationTransaction); | ||
105 | for (const auto folder : folderList) { | 104 | for (const auto folder : folderList) { |
106 | const auto remoteId = folder.toUtf8(); | 105 | const auto remoteId = folder.toUtf8(); |
107 | auto akonadiId = resolveRemoteId(bufferType.toUtf8(), remoteId, synchronizationTransaction); | 106 | auto akonadiId = resolveRemoteId(bufferType.toUtf8(), remoteId, synchronizationTransaction); |
@@ -116,7 +115,7 @@ void MaildirResource::synchronizeFolders(Akonadi2::Storage::Transaction &transac | |||
116 | if (!found) { //A new entity | 115 | if (!found) { //A new entity |
117 | m_fbb.Clear(); | 116 | m_fbb.Clear(); |
118 | 117 | ||
119 | KPIM::Maildir md(folder); | 118 | KPIM::Maildir md(folder, folder == mMaildirPath); |
120 | 119 | ||
121 | flatbuffers::FlatBufferBuilder entityFbb; | 120 | flatbuffers::FlatBufferBuilder entityFbb; |
122 | auto name = m_fbb.CreateString(md.name().toStdString()); | 121 | auto name = m_fbb.CreateString(md.name().toStdString()); |
@@ -124,7 +123,7 @@ void MaildirResource::synchronizeFolders(Akonadi2::Storage::Transaction &transac | |||
124 | flatbuffers::Offset<flatbuffers::String> parent; | 123 | flatbuffers::Offset<flatbuffers::String> parent; |
125 | 124 | ||
126 | if (!md.isRoot()) { | 125 | if (!md.isRoot()) { |
127 | auto akonadiId = resolveRemoteId(ENTITY_TYPE_FOLDER, md.parent().path(), transaction); | 126 | auto akonadiId = resolveRemoteId(ENTITY_TYPE_FOLDER, md.parent().path(), synchronizationTransaction); |
128 | parent = m_fbb.CreateString(akonadiId.toStdString()); | 127 | parent = m_fbb.CreateString(akonadiId.toStdString()); |
129 | } | 128 | } |
130 | 129 | ||
@@ -169,13 +168,12 @@ void MaildirResource::synchronizeMails(Akonadi2::Storage::Transaction &transacti | |||
169 | 168 | ||
170 | auto listingPath = maildir.pathToCurrent(); | 169 | auto listingPath = maildir.pathToCurrent(); |
171 | auto entryIterator = QSharedPointer<QDirIterator>::create(listingPath, QDir::Files); | 170 | auto entryIterator = QSharedPointer<QDirIterator>::create(listingPath, QDir::Files); |
172 | Trace() << "Looking into " << maildir.pathToNew(); | 171 | Trace() << "Looking into " << listingPath; |
173 | 172 | ||
174 | QFileInfo entryInfo; | 173 | QFileInfo entryInfo; |
175 | 174 | ||
176 | Akonadi2::Storage store(Akonadi2::storageLocation(), mResourceInstanceIdentifier + ".synchronization", Akonadi2::Storage::ReadWrite); | 175 | Akonadi2::Storage store(Akonadi2::storageLocation(), mResourceInstanceIdentifier + ".synchronization", Akonadi2::Storage::ReadWrite); |
177 | auto synchronizationTransaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | 176 | auto synchronizationTransaction = store.createTransaction(Akonadi2::Storage::ReadWrite); |
178 | Index ridMapping("rid.mapping", synchronizationTransaction); | ||
179 | 177 | ||
180 | while (entryIterator->hasNext()) { | 178 | while (entryIterator->hasNext()) { |
181 | QString filePath = entryIterator->next(); | 179 | QString filePath = entryIterator->next(); |
@@ -207,7 +205,7 @@ void MaildirResource::synchronizeMails(Akonadi2::Storage::Transaction &transacti | |||
207 | auto sender = m_fbb.CreateString(msg->from(true)->asUnicodeString().toStdString()); | 205 | auto sender = m_fbb.CreateString(msg->from(true)->asUnicodeString().toStdString()); |
208 | auto senderName = m_fbb.CreateString(msg->from(true)->asUnicodeString().toStdString()); | 206 | auto senderName = m_fbb.CreateString(msg->from(true)->asUnicodeString().toStdString()); |
209 | auto date = m_fbb.CreateString(msg->date(true)->dateTime().toString().toStdString()); | 207 | auto date = m_fbb.CreateString(msg->date(true)->dateTime().toString().toStdString()); |
210 | auto folder = m_fbb.CreateString(resolveRemoteId(ENTITY_TYPE_FOLDER, path, transaction).toStdString()); | 208 | auto folder = m_fbb.CreateString(resolveRemoteId(ENTITY_TYPE_FOLDER, path, synchronizationTransaction).toStdString()); |
211 | auto mimeMessage = m_fbb.CreateString(filepath.toStdString()); | 209 | auto mimeMessage = m_fbb.CreateString(filepath.toStdString()); |
212 | 210 | ||
213 | auto builder = Akonadi2::ApplicationDomain::Buffer::MailBuilder(m_fbb); | 211 | auto builder = Akonadi2::ApplicationDomain::Buffer::MailBuilder(m_fbb); |
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b909681..4b10b56 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt | |||
@@ -8,6 +8,8 @@ include_directories( | |||
8 | ${CMAKE_CURRENT_SOURCE_DIR}/../examples/ | 8 | ${CMAKE_CURRENT_SOURCE_DIR}/../examples/ |
9 | ) | 9 | ) |
10 | 10 | ||
11 | add_definitions(-DTESTDATAPATH="${CMAKE_CURRENT_SOURCE_DIR}/data") | ||
12 | |||
11 | macro(manual_tests) | 13 | macro(manual_tests) |
12 | foreach(_testname ${ARGN}) | 14 | foreach(_testname ${ARGN}) |
13 | add_executable(${_testname} ${_testname}.cpp testimplementations.cpp) | 15 | add_executable(${_testname} ${_testname}.cpp testimplementations.cpp) |
diff --git a/tests/data/maildir1/cur/1365777829.R28.localhost.localdomain:2,S b/tests/data/maildir1/cur/1365777829.R28.localhost.localdomain:2,S new file mode 100644 index 0000000..91231b5 --- /dev/null +++ b/tests/data/maildir1/cur/1365777829.R28.localhost.localdomain:2,S | |||
@@ -0,0 +1,72 @@ | |||
1 | Return-Path: <nepomuk-bounces@kde.org> | ||
2 | Received: 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 | ||
5 | X-Sieve: CMU Sieve 2.4 | ||
6 | X-Spam-score: 0.0 | ||
7 | X-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 | ||
9 | X-Spam-source: IP='46.4.96.248', Host='postbox.kde.org', Country='unk', FromHeader='org', | ||
10 | MailFrom='org' | ||
11 | X-Spam-charsets: plain='us-ascii' | ||
12 | X-Resolved-to: chrigi_1@fastmail.fm | ||
13 | X-Delivered-to: chrigi_1@fastmail.fm | ||
14 | X-Mail-from: nepomuk-bounces@kde.org | ||
15 | Received: from mx4.nyi.mail.srv.osa ([10.202.2.203]) | ||
16 | by compute4.internal (LMTPProxy); Mon, 11 Mar 2013 14:28:42 -0400 | ||
17 | Received: 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) | ||
20 | Received: 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) | ||
23 | DKIM-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= | ||
31 | X-Original-To: nepomuk@kde.org | ||
32 | X-Remote-Delivered-To: nepomuk@localhost.kde.org | ||
33 | Received: 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) | ||
36 | Received: 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 | ||
39 | Date: Mon, 11 Mar 2013 18:28:27 +0000 (UTC) | ||
40 | From: KDE CI System <null@kde.org> | ||
41 | To: nepomuk@kde.org | ||
42 | Message-ID: <1977027405.27.1363026507008.JavaMail.jenkins@build> | ||
43 | In-Reply-To: <880663748.26.1363026023717.JavaMail.jenkins@build> | ||
44 | References: <880663748.26.1363026023717.JavaMail.jenkins@build> | ||
45 | MIME-Version: 1.0 | ||
46 | X-Jenkins-Job: nepomuk-core_stable | ||
47 | X-Jenkins-Result: UNSTABLE | ||
48 | X-Scanned-By: MIMEDefang 2.71 on 46.4.96.248 | ||
49 | Subject: [Nepomuk] Jenkins build is still unstable: nepomuk-core_stable #158 | ||
50 | X-BeenThere: nepomuk@kde.org | ||
51 | X-Mailman-Version: 2.1.14 | ||
52 | Precedence: list | ||
53 | List-Id: The Semantic KDE <nepomuk.kde.org> | ||
54 | List-Unsubscribe: <https://mail.kde.org/mailman/options/nepomuk>, | ||
55 | <mailto:nepomuk-request@kde.org?subject=unsubscribe> | ||
56 | List-Archive: <http://mail.kde.org/pipermail/nepomuk> | ||
57 | List-Post: <mailto:nepomuk@kde.org> | ||
58 | List-Help: <mailto:nepomuk-request@kde.org?subject=help> | ||
59 | List-Subscribe: <https://mail.kde.org/mailman/listinfo/nepomuk>, | ||
60 | <mailto:nepomuk-request@kde.org?subject=subscribe> | ||
61 | Content-Type: text/plain; charset="us-ascii" | ||
62 | Content-Transfer-Encoding: 7bit | ||
63 | Errors-To: nepomuk-bounces@kde.org | ||
64 | Sender: nepomuk-bounces@kde.org | ||
65 | X-Truedomain: NotChecked | ||
66 | |||
67 | See <http://build.kde.org/job/nepomuk-core_stable/changes> | ||
68 | |||
69 | _______________________________________________ | ||
70 | Nepomuk mailing list | ||
71 | Nepomuk@kde.org | ||
72 | https://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 new file mode 100644 index 0000000..91231b5 --- /dev/null +++ b/tests/data/maildir1/inbox/cur/1365777829.R28.localhost.localdomain:2,S | |||
@@ -0,0 +1,72 @@ | |||
1 | Return-Path: <nepomuk-bounces@kde.org> | ||
2 | Received: 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 | ||
5 | X-Sieve: CMU Sieve 2.4 | ||
6 | X-Spam-score: 0.0 | ||
7 | X-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 | ||
9 | X-Spam-source: IP='46.4.96.248', Host='postbox.kde.org', Country='unk', FromHeader='org', | ||
10 | MailFrom='org' | ||
11 | X-Spam-charsets: plain='us-ascii' | ||
12 | X-Resolved-to: chrigi_1@fastmail.fm | ||
13 | X-Delivered-to: chrigi_1@fastmail.fm | ||
14 | X-Mail-from: nepomuk-bounces@kde.org | ||
15 | Received: from mx4.nyi.mail.srv.osa ([10.202.2.203]) | ||
16 | by compute4.internal (LMTPProxy); Mon, 11 Mar 2013 14:28:42 -0400 | ||
17 | Received: 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) | ||
20 | Received: 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) | ||
23 | DKIM-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= | ||
31 | X-Original-To: nepomuk@kde.org | ||
32 | X-Remote-Delivered-To: nepomuk@localhost.kde.org | ||
33 | Received: 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) | ||
36 | Received: 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 | ||
39 | Date: Mon, 11 Mar 2013 18:28:27 +0000 (UTC) | ||
40 | From: KDE CI System <null@kde.org> | ||
41 | To: nepomuk@kde.org | ||
42 | Message-ID: <1977027405.27.1363026507008.JavaMail.jenkins@build> | ||
43 | In-Reply-To: <880663748.26.1363026023717.JavaMail.jenkins@build> | ||
44 | References: <880663748.26.1363026023717.JavaMail.jenkins@build> | ||
45 | MIME-Version: 1.0 | ||
46 | X-Jenkins-Job: nepomuk-core_stable | ||
47 | X-Jenkins-Result: UNSTABLE | ||
48 | X-Scanned-By: MIMEDefang 2.71 on 46.4.96.248 | ||
49 | Subject: [Nepomuk] Jenkins build is still unstable: nepomuk-core_stable #158 | ||
50 | X-BeenThere: nepomuk@kde.org | ||
51 | X-Mailman-Version: 2.1.14 | ||
52 | Precedence: list | ||
53 | List-Id: The Semantic KDE <nepomuk.kde.org> | ||
54 | List-Unsubscribe: <https://mail.kde.org/mailman/options/nepomuk>, | ||
55 | <mailto:nepomuk-request@kde.org?subject=unsubscribe> | ||
56 | List-Archive: <http://mail.kde.org/pipermail/nepomuk> | ||
57 | List-Post: <mailto:nepomuk@kde.org> | ||
58 | List-Help: <mailto:nepomuk-request@kde.org?subject=help> | ||
59 | List-Subscribe: <https://mail.kde.org/mailman/listinfo/nepomuk>, | ||
60 | <mailto:nepomuk-request@kde.org?subject=subscribe> | ||
61 | Content-Type: text/plain; charset="us-ascii" | ||
62 | Content-Transfer-Encoding: 7bit | ||
63 | Errors-To: nepomuk-bounces@kde.org | ||
64 | Sender: nepomuk-bounces@kde.org | ||
65 | X-Truedomain: NotChecked | ||
66 | |||
67 | See <http://build.kde.org/job/nepomuk-core_stable/changes> | ||
68 | |||
69 | _______________________________________________ | ||
70 | Nepomuk mailing list | ||
71 | Nepomuk@kde.org | ||
72 | https://mail.kde.org/mailman/listinfo/nepomuk | ||
diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp index c65cdf0..bef94ba 100644 --- a/tests/maildirresourcetest.cpp +++ b/tests/maildirresourcetest.cpp | |||
@@ -11,6 +11,32 @@ | |||
11 | #include "pipeline.h" | 11 | #include "pipeline.h" |
12 | #include "log.h" | 12 | #include "log.h" |
13 | 13 | ||
14 | static bool copyRecursively(const QString &srcFilePath, | ||
15 | const QString &tgtFilePath) | ||
16 | { | ||
17 | QFileInfo srcFileInfo(srcFilePath); | ||
18 | if (srcFileInfo.isDir()) { | ||
19 | QDir targetDir(tgtFilePath); | ||
20 | targetDir.cdUp(); | ||
21 | if (!targetDir.mkdir(QFileInfo(tgtFilePath).fileName())) | ||
22 | return false; | ||
23 | QDir sourceDir(srcFilePath); | ||
24 | QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System); | ||
25 | foreach (const QString &fileName, fileNames) { | ||
26 | const QString newSrcFilePath | ||
27 | = srcFilePath + QLatin1Char('/') + fileName; | ||
28 | const QString newTgtFilePath | ||
29 | = tgtFilePath + QLatin1Char('/') + fileName; | ||
30 | if (!copyRecursively(newSrcFilePath, newTgtFilePath)) | ||
31 | return false; | ||
32 | } | ||
33 | } else { | ||
34 | if (!QFile::copy(srcFilePath, tgtFilePath)) | ||
35 | return false; | ||
36 | } | ||
37 | return true; | ||
38 | } | ||
39 | |||
14 | /** | 40 | /** |
15 | * Test of complete system using the maildir resource. | 41 | * Test of complete system using the maildir resource. |
16 | * | 42 | * |
@@ -22,6 +48,12 @@ class MaildirResourceTest : public QObject | |||
22 | private Q_SLOTS: | 48 | private Q_SLOTS: |
23 | void initTestCase() | 49 | void initTestCase() |
24 | { | 50 | { |
51 | auto targetPath = QDir::tempPath() + QDir::separator() + "maildirresourcetest" + QDir::separator() + "maildir1"; | ||
52 | QDir dir(targetPath); | ||
53 | dir.removeRecursively(); | ||
54 | |||
55 | copyRecursively(TESTDATAPATH "/maildir1", targetPath); | ||
56 | |||
25 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); | 57 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); |
26 | auto factory = Akonadi2::ResourceFactory::load("org.kde.maildir"); | 58 | auto factory = Akonadi2::ResourceFactory::load("org.kde.maildir"); |
27 | QVERIFY(factory); | 59 | QVERIFY(factory); |
@@ -29,7 +61,7 @@ private Q_SLOTS: | |||
29 | Akonadi2::ApplicationDomain::AkonadiResource resource; | 61 | Akonadi2::ApplicationDomain::AkonadiResource resource; |
30 | resource.setProperty("identifier", "org.kde.maildir.instance1"); | 62 | resource.setProperty("identifier", "org.kde.maildir.instance1"); |
31 | resource.setProperty("type", "org.kde.maildir"); | 63 | resource.setProperty("type", "org.kde.maildir"); |
32 | resource.setProperty("path", "/work/build/local-mail"); | 64 | resource.setProperty("path", targetPath); |
33 | Akonadi2::Store::create(resource).exec().waitForFinished(); | 65 | Akonadi2::Store::create(resource).exec().waitForFinished(); |
34 | } | 66 | } |
35 | 67 | ||
@@ -57,7 +89,60 @@ private Q_SLOTS: | |||
57 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 89 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
58 | 90 | ||
59 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 91 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); |
60 | QTRY_VERIFY(model->rowCount(QModelIndex()) > 1); | 92 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
93 | QVERIFY(model->rowCount(QModelIndex()) > 1); | ||
94 | } | ||
95 | |||
96 | void testListFolderTree() | ||
97 | { | ||
98 | Akonadi2::Query query; | ||
99 | query.resources << "org.kde.maildir.instance1"; | ||
100 | query.syncOnDemand = true; | ||
101 | query.processAll = true; | ||
102 | query.parentProperty = "parent"; | ||
103 | |||
104 | //Ensure all local data is processed | ||
105 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
106 | |||
107 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | ||
108 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | ||
109 | QCOMPARE(model->rowCount(QModelIndex()), 1); | ||
110 | auto parentIndex = model->index(0, 0, QModelIndex()); | ||
111 | model->fetchMore(parentIndex); | ||
112 | QTRY_VERIFY(model->data(parentIndex, Akonadi2::Store::ChildrenFetchedRole).toBool()); | ||
113 | QCOMPARE(model->rowCount(parentIndex), 1); | ||
114 | } | ||
115 | |||
116 | void testListMailsOfFolder() | ||
117 | { | ||
118 | { | ||
119 | Akonadi2::Query query; | ||
120 | query.resources << "org.kde.maildir.instance1"; | ||
121 | query.syncOnDemand = true; | ||
122 | query.processAll = true; | ||
123 | |||
124 | //Ensure all local data is processed | ||
125 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
126 | } | ||
127 | QByteArray folderIdentifier; | ||
128 | { | ||
129 | Akonadi2::Query query; | ||
130 | query.resources << "org.kde.maildir.instance1"; | ||
131 | query.requestedProperties << "folder" << "name"; | ||
132 | |||
133 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | ||
134 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | ||
135 | QVERIFY(model->rowCount(QModelIndex()) > 1); | ||
136 | folderIdentifier = model->index(1, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>()->identifier(); | ||
137 | } | ||
138 | |||
139 | Akonadi2::Query query; | ||
140 | query.resources << "org.kde.maildir.instance1"; | ||
141 | query.requestedProperties << "folder" << "summary"; | ||
142 | query.propertyFilter.insert("folder", folderIdentifier); | ||
143 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | ||
144 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | ||
145 | QVERIFY(mailModel->rowCount(QModelIndex()) >= 1); | ||
61 | } | 146 | } |
62 | 147 | ||
63 | }; | 148 | }; |