From 1710fab0965d32b883dfcc327c36d3fd38a91357 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 15 Dec 2015 17:05:20 +0100 Subject: A read-only maildir resource. Respectively a first prototype thereof. --- tests/CMakeLists.txt | 7 ++++- tests/maildirresourcetest.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 tests/maildirresourcetest.cpp (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 11fe415..b909681 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -47,8 +47,13 @@ auto_tests ( pipelinetest querytest ) - target_link_libraries(dummyresourcetest akonadi2_resource_dummy) target_link_libraries(dummyresourcebenchmark akonadi2_resource_dummy) target_link_libraries(querytest akonadi2_resource_dummy) +if (BUILD_MAILDIR) + auto_tests ( + maildirresourcetest + ) + target_link_libraries(maildirresourcetest akonadi2_resource_maildir) +endif() diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp new file mode 100644 index 0000000..c65cdf0 --- /dev/null +++ b/tests/maildirresourcetest.cpp @@ -0,0 +1,66 @@ +#include + +#include + +#include "maildirresource/maildirresource.h" +#include "clientapi.h" +#include "commands.h" +#include "entitybuffer.h" +#include "resourceconfig.h" +#include "modelresult.h" +#include "pipeline.h" +#include "log.h" + +/** + * Test of complete system using the maildir resource. + * + * This test requires the maildir resource installed. + */ +class MaildirResourceTest : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void initTestCase() + { + Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); + auto factory = Akonadi2::ResourceFactory::load("org.kde.maildir"); + QVERIFY(factory); + MaildirResource::removeFromDisk("org.kde.maildir.instance1"); + Akonadi2::ApplicationDomain::AkonadiResource resource; + resource.setProperty("identifier", "org.kde.maildir.instance1"); + resource.setProperty("type", "org.kde.maildir"); + resource.setProperty("path", "/work/build/local-mail"); + Akonadi2::Store::create(resource).exec().waitForFinished(); + } + + void cleanup() + { + Akonadi2::Store::shutdown(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished(); + MaildirResource::removeFromDisk("org.kde.maildir.instance1"); + } + + void init() + { + qDebug(); + qDebug() << "-----------------------------------------"; + qDebug(); + } + + void testListFolders() + { + 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(); + + auto model = Akonadi2::Store::loadModel(query); + QTRY_VERIFY(model->rowCount(QModelIndex()) > 1); + } + +}; + +QTEST_MAIN(MaildirResourceTest) +#include "maildirresourcetest.moc" -- cgit v1.2.3