diff options
Diffstat (limited to 'tests/inspectiontest.cpp')
-rw-r--r-- | tests/inspectiontest.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/inspectiontest.cpp b/tests/inspectiontest.cpp new file mode 100644 index 0000000..e332844 --- /dev/null +++ b/tests/inspectiontest.cpp | |||
@@ -0,0 +1,64 @@ | |||
1 | #include <QtTest> | ||
2 | |||
3 | #include <QString> | ||
4 | |||
5 | #include "dummyresource/resourcefactory.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 inspection system using the dummy resource. | ||
16 | * | ||
17 | * This test requires the dummy resource installed. | ||
18 | */ | ||
19 | class InspectionTest : 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.dummy"); | ||
27 | QVERIFY(factory); | ||
28 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | ||
29 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); | ||
30 | } | ||
31 | |||
32 | void cleanup() | ||
33 | { | ||
34 | Akonadi2::Store::shutdown(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | ||
35 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | ||
36 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); | ||
37 | QVERIFY(factory); | ||
38 | Akonadi2::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | ||
39 | } | ||
40 | |||
41 | void init() | ||
42 | { | ||
43 | qDebug(); | ||
44 | qDebug() << "-----------------------------------------"; | ||
45 | qDebug(); | ||
46 | } | ||
47 | |||
48 | void testMarkMailAsRead() | ||
49 | { | ||
50 | using namespace Akonadi2; | ||
51 | using namespace Akonadi2::ApplicationDomain; | ||
52 | |||
53 | Mail mail(QByteArray("org.kde.dummy.instance1"), QByteArray("identifier"), 0, QSharedPointer<MemoryBufferAdaptor::MemoryBufferAdaptor>::create()); | ||
54 | |||
55 | auto inspectionCommand = Resources::Inspection::PropertyInspection(mail, "unread", true); | ||
56 | auto result = Resources::inspect<Mail>(inspectionCommand).exec(); | ||
57 | result.waitForFinished(); | ||
58 | QVERIFY(!result.errorCode()); | ||
59 | Akonadi2::Store::flushMessageQueue(QByteArrayList() << QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | ||
60 | } | ||
61 | }; | ||
62 | |||
63 | QTEST_MAIN(InspectionTest) | ||
64 | #include "inspectiontest.moc" | ||