summaryrefslogtreecommitdiffstats
path: root/tests/resourcecommunicationtest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-07-30 17:53:46 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-07-30 17:54:56 +0200
commit2b1542d7fee7e9ef14592e88c8a974ed4ea2eacf (patch)
treebbdf1a27c5d275f1b2214c62d303fd0b9a39b5c9 /tests/resourcecommunicationtest.cpp
parent93b208cc95114e39f5d3379e66646c94e70b6a02 (diff)
downloadsink-2b1542d7fee7e9ef14592e88c8a974ed4ea2eacf.tar.gz
sink-2b1542d7fee7e9ef14592e88c8a974ed4ea2eacf.zip
Tested command loop with Ping command.
Ping is a command that by definition doesn't affect the resource, and thus can be used at all times to check if the resource is still alive.
Diffstat (limited to 'tests/resourcecommunicationtest.cpp')
-rw-r--r--tests/resourcecommunicationtest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/resourcecommunicationtest.cpp b/tests/resourcecommunicationtest.cpp
index f1cef50..1ab516a 100644
--- a/tests/resourcecommunicationtest.cpp
+++ b/tests/resourcecommunicationtest.cpp
@@ -35,6 +35,31 @@ private Q_SLOTS:
35 result.waitForFinished(); 35 result.waitForFinished();
36 QVERIFY(!result.errorCode()); 36 QVERIFY(!result.errorCode());
37 } 37 }
38
39 void testCommandLoop()
40 {
41 const QByteArray resourceIdentifier("test");
42 Listener listener(resourceIdentifier);
43 Akonadi2::ResourceAccess resourceAccess(resourceIdentifier);
44 resourceAccess.open();
45
46 const int count = 500;
47 int complete = 0;
48 int errors = 0;
49 for (int i = 0; i < count; i++) {
50 auto result = resourceAccess.sendCommand(Akonadi2::Commands::PingCommand)
51 .then<void>([&complete]() {
52 complete++;
53 },
54 [&errors, &complete](int error, const QString &msg) {
55 qWarning() << msg;
56 errors++;
57 complete++;
58 }).exec();
59 }
60 QTRY_COMPARE(complete, count);
61 QVERIFY(!errors);
62 }
38}; 63};
39 64
40QTEST_MAIN(ResourceCommunicationTest) 65QTEST_MAIN(ResourceCommunicationTest)