From 56e38fd874546b54ba34b07c71f65532059c5e7b Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 16 Dec 2015 13:14:49 +0100 Subject: Get the maildir resource to work. The subfolder implementation is not according to any standard it seems, but at least it works for now. --- tests/CMakeLists.txt | 2 + .../cur/1365777829.R28.localhost.localdomain:2,S | 72 +++++++++++++++++ .../cur/1365777829.R28.localhost.localdomain:2,S | 72 +++++++++++++++++ tests/maildirresourcetest.cpp | 89 +++++++++++++++++++++- 4 files changed, 233 insertions(+), 2 deletions(-) create mode 100644 tests/data/maildir1/cur/1365777829.R28.localhost.localdomain:2,S create mode 100644 tests/data/maildir1/inbox/cur/1365777829.R28.localhost.localdomain:2,S (limited to 'tests') 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( ${CMAKE_CURRENT_SOURCE_DIR}/../examples/ ) +add_definitions(-DTESTDATAPATH="${CMAKE_CURRENT_SOURCE_DIR}/data") + macro(manual_tests) foreach(_testname ${ARGN}) 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 @@ +Return-Path: +Received: from compute4.internal (compute4.nyi.mail.srv.osa [10.202.2.44]) + by slots3a1p1 (Cyrus git2.5+0-git-fastmail-8998) with LMTPA; + Mon, 11 Mar 2013 14:28:42 -0400 +X-Sieve: CMU Sieve 2.4 +X-Spam-score: 0.0 +X-Spam-hits: BAYES_00 -1.9, RCVD_IN_DNSWL_MED -2.3, RP_MATCHES_RCVD -0.704, + LANGUAGES unknown, BAYES_USED global, SA_VERSION 3.3.1 +X-Spam-source: IP='46.4.96.248', Host='postbox.kde.org', Country='unk', FromHeader='org', + MailFrom='org' +X-Spam-charsets: plain='us-ascii' +X-Resolved-to: chrigi_1@fastmail.fm +X-Delivered-to: chrigi_1@fastmail.fm +X-Mail-from: nepomuk-bounces@kde.org +Received: from mx4.nyi.mail.srv.osa ([10.202.2.203]) + by compute4.internal (LMTPProxy); Mon, 11 Mar 2013 14:28:42 -0400 +Received: from postbox.kde.org (postbox.kde.org [46.4.96.248]) + by mx4.messagingengine.com (Postfix) with ESMTP id 1C9D2440F88 + for ; Mon, 11 Mar 2013 14:28:42 -0400 (EDT) +Received: from postbox.kde.org (localhost [IPv6:::1]) + by postbox.kde.org (Postfix) with ESMTP id 00FFEB3732B; + Mon, 11 Mar 2013 18:28:40 +0000 (UTC) +DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=kde.org; s=default; + t=1363026520; bh=cOdvyBAJJ8ho64q0H7rxkl+cB2y6TiyVOX0fO3yZ64U=; + h=Date:From:To:Message-ID:In-Reply-To:References:MIME-Version: + Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: + List-Subscribe:Content-Type:Content-Transfer-Encoding:Sender; b=dv + dJAFu+6JCuNun5WIuP4ysfKpLh0DeuhEEfy2cQavUGMICJ27k7tI73x6gN37V5Q/evJ + NDFna3/IhNBsAQeLiXs28HKxzcVhbnq5jdFR6fbyo6k1fOKt5vTT1GTDZ+3zIGPD1CU + ioDBGxPb/Ds6gee90tjadOj6o+Oc+2ZSq94= +X-Original-To: nepomuk@kde.org +X-Remote-Delivered-To: nepomuk@localhost.kde.org +Received: from build.kde.org (build.kde.org [IPv6:2a01:4f8:160:9363::5]) + by postbox.kde.org (Postfix) with ESMTP id 4491CB3732B + for ; Mon, 11 Mar 2013 18:28:27 +0000 (UTC) +Received: from localhost ([127.0.0.1]) by build.kde.org with esmtp (Exim 4.72) + (envelope-from ) id 1UF7SV-0000gs-11 + for nepomuk@kde.org; Mon, 11 Mar 2013 18:28:27 +0000 +Date: Mon, 11 Mar 2013 18:28:27 +0000 (UTC) +From: KDE CI System +To: nepomuk@kde.org +Message-ID: <1977027405.27.1363026507008.JavaMail.jenkins@build> +In-Reply-To: <880663748.26.1363026023717.JavaMail.jenkins@build> +References: <880663748.26.1363026023717.JavaMail.jenkins@build> +MIME-Version: 1.0 +X-Jenkins-Job: nepomuk-core_stable +X-Jenkins-Result: UNSTABLE +X-Scanned-By: MIMEDefang 2.71 on 46.4.96.248 +Subject: [Nepomuk] Jenkins build is still unstable: nepomuk-core_stable #158 +X-BeenThere: nepomuk@kde.org +X-Mailman-Version: 2.1.14 +Precedence: list +List-Id: The Semantic KDE +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: 7bit +Errors-To: nepomuk-bounces@kde.org +Sender: nepomuk-bounces@kde.org +X-Truedomain: NotChecked + +See + +_______________________________________________ +Nepomuk mailing list +Nepomuk@kde.org +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 @@ +Return-Path: +Received: from compute4.internal (compute4.nyi.mail.srv.osa [10.202.2.44]) + by slots3a1p1 (Cyrus git2.5+0-git-fastmail-8998) with LMTPA; + Mon, 11 Mar 2013 14:28:42 -0400 +X-Sieve: CMU Sieve 2.4 +X-Spam-score: 0.0 +X-Spam-hits: BAYES_00 -1.9, RCVD_IN_DNSWL_MED -2.3, RP_MATCHES_RCVD -0.704, + LANGUAGES unknown, BAYES_USED global, SA_VERSION 3.3.1 +X-Spam-source: IP='46.4.96.248', Host='postbox.kde.org', Country='unk', FromHeader='org', + MailFrom='org' +X-Spam-charsets: plain='us-ascii' +X-Resolved-to: chrigi_1@fastmail.fm +X-Delivered-to: chrigi_1@fastmail.fm +X-Mail-from: nepomuk-bounces@kde.org +Received: from mx4.nyi.mail.srv.osa ([10.202.2.203]) + by compute4.internal (LMTPProxy); Mon, 11 Mar 2013 14:28:42 -0400 +Received: from postbox.kde.org (postbox.kde.org [46.4.96.248]) + by mx4.messagingengine.com (Postfix) with ESMTP id 1C9D2440F88 + for ; Mon, 11 Mar 2013 14:28:42 -0400 (EDT) +Received: from postbox.kde.org (localhost [IPv6:::1]) + by postbox.kde.org (Postfix) with ESMTP id 00FFEB3732B; + Mon, 11 Mar 2013 18:28:40 +0000 (UTC) +DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=kde.org; s=default; + t=1363026520; bh=cOdvyBAJJ8ho64q0H7rxkl+cB2y6TiyVOX0fO3yZ64U=; + h=Date:From:To:Message-ID:In-Reply-To:References:MIME-Version: + Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: + List-Subscribe:Content-Type:Content-Transfer-Encoding:Sender; b=dv + dJAFu+6JCuNun5WIuP4ysfKpLh0DeuhEEfy2cQavUGMICJ27k7tI73x6gN37V5Q/evJ + NDFna3/IhNBsAQeLiXs28HKxzcVhbnq5jdFR6fbyo6k1fOKt5vTT1GTDZ+3zIGPD1CU + ioDBGxPb/Ds6gee90tjadOj6o+Oc+2ZSq94= +X-Original-To: nepomuk@kde.org +X-Remote-Delivered-To: nepomuk@localhost.kde.org +Received: from build.kde.org (build.kde.org [IPv6:2a01:4f8:160:9363::5]) + by postbox.kde.org (Postfix) with ESMTP id 4491CB3732B + for ; Mon, 11 Mar 2013 18:28:27 +0000 (UTC) +Received: from localhost ([127.0.0.1]) by build.kde.org with esmtp (Exim 4.72) + (envelope-from ) id 1UF7SV-0000gs-11 + for nepomuk@kde.org; Mon, 11 Mar 2013 18:28:27 +0000 +Date: Mon, 11 Mar 2013 18:28:27 +0000 (UTC) +From: KDE CI System +To: nepomuk@kde.org +Message-ID: <1977027405.27.1363026507008.JavaMail.jenkins@build> +In-Reply-To: <880663748.26.1363026023717.JavaMail.jenkins@build> +References: <880663748.26.1363026023717.JavaMail.jenkins@build> +MIME-Version: 1.0 +X-Jenkins-Job: nepomuk-core_stable +X-Jenkins-Result: UNSTABLE +X-Scanned-By: MIMEDefang 2.71 on 46.4.96.248 +Subject: [Nepomuk] Jenkins build is still unstable: nepomuk-core_stable #158 +X-BeenThere: nepomuk@kde.org +X-Mailman-Version: 2.1.14 +Precedence: list +List-Id: The Semantic KDE +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: 7bit +Errors-To: nepomuk-bounces@kde.org +Sender: nepomuk-bounces@kde.org +X-Truedomain: NotChecked + +See + +_______________________________________________ +Nepomuk mailing list +Nepomuk@kde.org +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 @@ #include "pipeline.h" #include "log.h" +static bool copyRecursively(const QString &srcFilePath, + const QString &tgtFilePath) +{ + QFileInfo srcFileInfo(srcFilePath); + if (srcFileInfo.isDir()) { + QDir targetDir(tgtFilePath); + targetDir.cdUp(); + if (!targetDir.mkdir(QFileInfo(tgtFilePath).fileName())) + return false; + QDir sourceDir(srcFilePath); + QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System); + foreach (const QString &fileName, fileNames) { + const QString newSrcFilePath + = srcFilePath + QLatin1Char('/') + fileName; + const QString newTgtFilePath + = tgtFilePath + QLatin1Char('/') + fileName; + if (!copyRecursively(newSrcFilePath, newTgtFilePath)) + return false; + } + } else { + if (!QFile::copy(srcFilePath, tgtFilePath)) + return false; + } + return true; +} + /** * Test of complete system using the maildir resource. * @@ -22,6 +48,12 @@ class MaildirResourceTest : public QObject private Q_SLOTS: void initTestCase() { + auto targetPath = QDir::tempPath() + QDir::separator() + "maildirresourcetest" + QDir::separator() + "maildir1"; + QDir dir(targetPath); + dir.removeRecursively(); + + copyRecursively(TESTDATAPATH "/maildir1", targetPath); + Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); auto factory = Akonadi2::ResourceFactory::load("org.kde.maildir"); QVERIFY(factory); @@ -29,7 +61,7 @@ private Q_SLOTS: Akonadi2::ApplicationDomain::AkonadiResource resource; resource.setProperty("identifier", "org.kde.maildir.instance1"); resource.setProperty("type", "org.kde.maildir"); - resource.setProperty("path", "/work/build/local-mail"); + resource.setProperty("path", targetPath); Akonadi2::Store::create(resource).exec().waitForFinished(); } @@ -57,7 +89,60 @@ private Q_SLOTS: Akonadi2::Store::synchronize(query).exec().waitForFinished(); auto model = Akonadi2::Store::loadModel(query); - QTRY_VERIFY(model->rowCount(QModelIndex()) > 1); + QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); + QVERIFY(model->rowCount(QModelIndex()) > 1); + } + + void testListFolderTree() + { + Akonadi2::Query query; + query.resources << "org.kde.maildir.instance1"; + query.syncOnDemand = true; + query.processAll = true; + query.parentProperty = "parent"; + + //Ensure all local data is processed + Akonadi2::Store::synchronize(query).exec().waitForFinished(); + + auto model = Akonadi2::Store::loadModel(query); + QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); + QCOMPARE(model->rowCount(QModelIndex()), 1); + auto parentIndex = model->index(0, 0, QModelIndex()); + model->fetchMore(parentIndex); + QTRY_VERIFY(model->data(parentIndex, Akonadi2::Store::ChildrenFetchedRole).toBool()); + QCOMPARE(model->rowCount(parentIndex), 1); + } + + void testListMailsOfFolder() + { + { + Akonadi2::Query query; + query.resources << "org.kde.maildir.instance1"; + query.syncOnDemand = true; + query.processAll = true; + + //Ensure all local data is processed + Akonadi2::Store::synchronize(query).exec().waitForFinished(); + } + QByteArray folderIdentifier; + { + Akonadi2::Query query; + query.resources << "org.kde.maildir.instance1"; + query.requestedProperties << "folder" << "name"; + + auto model = Akonadi2::Store::loadModel(query); + QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); + QVERIFY(model->rowCount(QModelIndex()) > 1); + folderIdentifier = model->index(1, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value()->identifier(); + } + + Akonadi2::Query query; + query.resources << "org.kde.maildir.instance1"; + query.requestedProperties << "folder" << "summary"; + query.propertyFilter.insert("folder", folderIdentifier); + auto mailModel = Akonadi2::Store::loadModel(query); + QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); + QVERIFY(mailModel->rowCount(QModelIndex()) >= 1); } }; -- cgit v1.2.3