From be9f675ada44b04d3f74c68dc46cc7f7325ece0c Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 8 Feb 2016 19:30:35 +0100 Subject: Test responsiveness of command processing. --- tests/dummyresourcebenchmark.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests/dummyresourcebenchmark.cpp') diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp index e511613..6c37c09 100644 --- a/tests/dummyresourcebenchmark.cpp +++ b/tests/dummyresourcebenchmark.cpp @@ -10,6 +10,7 @@ #include "pipeline.h" #include "log.h" #include "resourceconfig.h" +#include "notification_generated.h" #include "hawd/dataset.h" #include "hawd/formatter.h" @@ -71,6 +72,41 @@ private Q_SLOTS: }); } + //Ensure we can process a command in less than 0.1s + void testCommandResponsiveness() + { + //Test responsiveness including starting the process. + Sink::Store::shutdown("org.kde.dummy.instance1").exec().waitForFinished(); + DummyResource::removeFromDisk("org.kde.dummy.instance1"); + + QTime time; + time.start(); + + Sink::ApplicationDomain::Event event("org.kde.dummy.instance1"); + event.setProperty("uid", "testuid"); + QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); + event.setProperty("summary", "summaryValue"); + + auto notifier = QSharedPointer::create("org.kde.dummy.instance1"); + bool gotNotification = false; + int duration = 0; + notifier->registerHandler([&gotNotification, &duration, &time](const Sink::Notification ¬ification) { + if (notification.type == Sink::Commands::NotificationType::NotificationType_RevisionUpdate) { + gotNotification = true; + duration = time.elapsed(); + } + }); + + Sink::Store::create(event).exec(); + + //Wait for notification + QTRY_VERIFY(gotNotification); + + QVERIFY2(duration < 100, QString::fromLatin1("Processing a create command took more than 100ms: %1").arg(duration).toLatin1()); + Sink::Store::shutdown("org.kde.dummy.instance1").exec().waitForFinished(); + qDebug() << "Single command took [ms]: " << duration; + } + void testWriteToFacade() { DummyResource::removeFromDisk("org.kde.dummy.instance1"); -- cgit v1.2.3