diff options
Diffstat (limited to 'tests/inspectiontest.cpp')
-rw-r--r-- | tests/inspectiontest.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/inspectiontest.cpp b/tests/inspectiontest.cpp new file mode 100644 index 0000000..29cce6c --- /dev/null +++ b/tests/inspectiontest.cpp | |||
@@ -0,0 +1,65 @@ | |||
1 | #include <QtTest> | ||
2 | |||
3 | #include <QString> | ||
4 | |||
5 | #include "dummyresource/resourcefactory.h" | ||
6 | #include "clientapi.h" | ||
7 | #include "resourceconfig.h" | ||
8 | #include "log.h" | ||
9 | |||
10 | /** | ||
11 | * Test of inspection system using the dummy resource. | ||
12 | * | ||
13 | * This test requires the dummy resource installed. | ||
14 | */ | ||
15 | class InspectionTest : public QObject | ||
16 | { | ||
17 | Q_OBJECT | ||
18 | private Q_SLOTS: | ||
19 | void initTestCase() | ||
20 | { | ||
21 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); | ||
22 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); | ||
23 | QVERIFY(factory); | ||
24 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | ||
25 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); | ||
26 | } | ||
27 | |||
28 | void cleanup() | ||
29 | { | ||
30 | Akonadi2::Store::shutdown(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | ||
31 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | ||
32 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); | ||
33 | QVERIFY(factory); | ||
34 | Akonadi2::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | ||
35 | } | ||
36 | |||
37 | void testInspection_data() | ||
38 | { | ||
39 | QTest::addColumn<bool>("success"); | ||
40 | QTest::newRow("success") << true; | ||
41 | QTest::newRow("fail") << false; | ||
42 | } | ||
43 | |||
44 | void testInspection() | ||
45 | { | ||
46 | QFETCH(bool, success); | ||
47 | using namespace Akonadi2; | ||
48 | using namespace Akonadi2::ApplicationDomain; | ||
49 | |||
50 | Mail mail(QByteArray("org.kde.dummy.instance1"), QByteArray("identifier"), 0, QSharedPointer<MemoryBufferAdaptor::MemoryBufferAdaptor>::create()); | ||
51 | |||
52 | //testInspection is a magic property that the dummyresource supports | ||
53 | auto inspectionCommand = Resources::Inspection::PropertyInspection(mail, "testInspection", success); | ||
54 | auto result = Resources::inspect<Mail>(inspectionCommand).exec(); | ||
55 | result.waitForFinished(); | ||
56 | if (success) { | ||
57 | QVERIFY(!result.errorCode()); | ||
58 | } else { | ||
59 | QVERIFY(result.errorCode()); | ||
60 | } | ||
61 | } | ||
62 | }; | ||
63 | |||
64 | QTEST_MAIN(InspectionTest) | ||
65 | #include "inspectiontest.moc" | ||