From 2b1542d7fee7e9ef14592e88c8a974ed4ea2eacf Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 30 Jul 2015 17:53:46 +0200 Subject: 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. --- tests/resourcecommunicationtest.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') 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: result.waitForFinished(); QVERIFY(!result.errorCode()); } + + void testCommandLoop() + { + const QByteArray resourceIdentifier("test"); + Listener listener(resourceIdentifier); + Akonadi2::ResourceAccess resourceAccess(resourceIdentifier); + resourceAccess.open(); + + const int count = 500; + int complete = 0; + int errors = 0; + for (int i = 0; i < count; i++) { + auto result = resourceAccess.sendCommand(Akonadi2::Commands::PingCommand) + .then([&complete]() { + complete++; + }, + [&errors, &complete](int error, const QString &msg) { + qWarning() << msg; + errors++; + complete++; + }).exec(); + } + QTRY_COMPARE(complete, count); + QVERIFY(!errors); + } }; QTEST_MAIN(ResourceCommunicationTest) -- cgit v1.2.3