diff options
Diffstat (limited to 'tests/maildirresourcetest.cpp')
-rw-r--r-- | tests/maildirresourcetest.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
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 @@ | |||
1 | #include <QtTest> | ||
2 | |||
3 | #include <QString> | ||
4 | |||
5 | #include "maildirresource/maildirresource.h" | ||
6 | #include "clientapi.h" | ||
7 | #include "commands.h" | ||
8 | #include "entitybuffer.h" | ||
9 | #include "resourceconfig.h" | ||
10 | #include "modelresult.h" | ||
11 | #include "pipeline.h" | ||
12 | #include "log.h" | ||
13 | |||
14 | /** | ||
15 | * Test of complete system using the maildir resource. | ||
16 | * | ||
17 | * This test requires the maildir resource installed. | ||
18 | */ | ||
19 | class MaildirResourceTest : public QObject | ||
20 | { | ||
21 | Q_OBJECT | ||
22 | private Q_SLOTS: | ||
23 | void initTestCase() | ||
24 | { | ||
25 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); | ||
26 | auto factory = Akonadi2::ResourceFactory::load("org.kde.maildir"); | ||
27 | QVERIFY(factory); | ||
28 | MaildirResource::removeFromDisk("org.kde.maildir.instance1"); | ||
29 | Akonadi2::ApplicationDomain::AkonadiResource resource; | ||
30 | resource.setProperty("identifier", "org.kde.maildir.instance1"); | ||
31 | resource.setProperty("type", "org.kde.maildir"); | ||
32 | resource.setProperty("path", "/work/build/local-mail"); | ||
33 | Akonadi2::Store::create(resource).exec().waitForFinished(); | ||
34 | } | ||
35 | |||
36 | void cleanup() | ||
37 | { | ||
38 | Akonadi2::Store::shutdown(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished(); | ||
39 | MaildirResource::removeFromDisk("org.kde.maildir.instance1"); | ||
40 | } | ||
41 | |||
42 | void init() | ||
43 | { | ||
44 | qDebug(); | ||
45 | qDebug() << "-----------------------------------------"; | ||
46 | qDebug(); | ||
47 | } | ||
48 | |||
49 | void testListFolders() | ||
50 | { | ||
51 | Akonadi2::Query query; | ||
52 | query.resources << "org.kde.maildir.instance1"; | ||
53 | query.syncOnDemand = true; | ||
54 | query.processAll = true; | ||
55 | |||
56 | //Ensure all local data is processed | ||
57 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
58 | |||
59 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | ||
60 | QTRY_VERIFY(model->rowCount(QModelIndex()) > 1); | ||
61 | } | ||
62 | |||
63 | }; | ||
64 | |||
65 | QTEST_MAIN(MaildirResourceTest) | ||
66 | #include "maildirresourcetest.moc" | ||