summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/dummyresourcetest.cpp1
-rw-r--r--tests/resourcecommunicationtest.cpp29
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp
index 20c725f..b8711a2 100644
--- a/tests/dummyresourcetest.cpp
+++ b/tests/dummyresourcetest.cpp
@@ -35,6 +35,7 @@ private Q_SLOTS:
35 DummyResource::removeFromDisk("org.kde.dummy.instance1"); 35 DummyResource::removeFromDisk("org.kde.dummy.instance1");
36 auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); 36 auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy");
37 QVERIFY(factory); 37 QVERIFY(factory);
38 Akonadi2::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished();
38 } 39 }
39 40
40 void init() 41 void init()
diff --git a/tests/resourcecommunicationtest.cpp b/tests/resourcecommunicationtest.cpp
index fa2b5a1..18e9223 100644
--- a/tests/resourcecommunicationtest.cpp
+++ b/tests/resourcecommunicationtest.cpp
@@ -63,6 +63,35 @@ private Q_SLOTS:
63 QTRY_COMPARE(complete, count); 63 QTRY_COMPARE(complete, count);
64 QVERIFY(!errors); 64 QVERIFY(!errors);
65 } 65 }
66
67 void testResourceAccessReuse()
68 {
69 qDebug();
70 const QByteArray resourceIdentifier("test");
71 Listener listener(resourceIdentifier);
72 Akonadi2::ResourceAccess resourceAccess(resourceIdentifier);
73 resourceAccess.open();
74
75 const int count = 10;
76 int complete = 0;
77 int errors = 0;
78 for (int i = 0; i < count; i++) {
79 resourceAccess.sendCommand(Akonadi2::Commands::PingCommand)
80 .then<void>([&complete]() {
81 complete++;
82 },
83 [&errors, &complete](int error, const QString &msg) {
84 qWarning() << msg;
85 errors++;
86 complete++;
87 }).then<void>([&resourceAccess]() {
88 resourceAccess.close();
89 resourceAccess.open();
90 }).exec().waitForFinished();
91 }
92 QTRY_COMPARE(complete, count);
93 QVERIFY(!errors);
94 }
66}; 95};
67 96
68QTEST_MAIN(ResourceCommunicationTest) 97QTEST_MAIN(ResourceCommunicationTest)