summaryrefslogtreecommitdiffstats
path: root/tests/dummyresourcebenchmark.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dummyresourcebenchmark.cpp')
-rw-r--r--tests/dummyresourcebenchmark.cpp47
1 files changed, 42 insertions, 5 deletions
diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp
index e511613..9afc775 100644
--- a/tests/dummyresourcebenchmark.cpp
+++ b/tests/dummyresourcebenchmark.cpp
@@ -4,12 +4,15 @@
4 4
5#include "dummyresource/resourcefactory.h" 5#include "dummyresource/resourcefactory.h"
6#include "dummyresource/domainadaptor.h" 6#include "dummyresource/domainadaptor.h"
7#include "clientapi.h" 7#include "store.h"
8#include "notifier.h"
9#include "resourcecontrol.h"
8#include "commands.h" 10#include "commands.h"
9#include "entitybuffer.h" 11#include "entitybuffer.h"
10#include "pipeline.h" 12#include "pipeline.h"
11#include "log.h" 13#include "log.h"
12#include "resourceconfig.h" 14#include "resourceconfig.h"
15#include "notification_generated.h"
13 16
14#include "hawd/dataset.h" 17#include "hawd/dataset.h"
15#include "hawd/formatter.h" 18#include "hawd/formatter.h"
@@ -71,9 +74,43 @@ private Q_SLOTS:
71 }); 74 });
72 } 75 }
73 76
77 //Ensure we can process a command in less than 0.1s
78 void testCommandResponsiveness()
79 {
80 //Test responsiveness including starting the process.
81 Sink::Store::removeDataFromDisk("org.kde.dummy.instance1").exec().waitForFinished();
82
83 QTime time;
84 time.start();
85
86 Sink::ApplicationDomain::Event event("org.kde.dummy.instance1");
87 event.setProperty("uid", "testuid");
88 QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid"));
89 event.setProperty("summary", "summaryValue");
90
91 auto notifier = QSharedPointer<Sink::Notifier>::create("org.kde.dummy.instance1");
92 bool gotNotification = false;
93 int duration = 0;
94 notifier->registerHandler([&gotNotification, &duration, &time](const Sink::Notification &notification) {
95 if (notification.type == Sink::Commands::NotificationType::NotificationType_RevisionUpdate) {
96 gotNotification = true;
97 duration = time.elapsed();
98 }
99 });
100
101 Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec();
102
103 //Wait for notification
104 QTRY_VERIFY(gotNotification);
105
106 QVERIFY2(duration < 100, QString::fromLatin1("Processing a create command took more than 100ms: %1").arg(duration).toLatin1());
107 Sink::ResourceControl::shutdown("org.kde.dummy.instance1").exec().waitForFinished();
108 qDebug() << "Single command took [ms]: " << duration;
109 }
110
74 void testWriteToFacade() 111 void testWriteToFacade()
75 { 112 {
76 DummyResource::removeFromDisk("org.kde.dummy.instance1"); 113 Sink::Store::removeDataFromDisk("org.kde.dummy.instance1").exec().waitForFinished();
77 114
78 QTime time; 115 QTime time;
79 time.start(); 116 time.start();
@@ -92,7 +129,7 @@ private Q_SLOTS:
92 { 129 {
93 Sink::Query query; 130 Sink::Query query;
94 query.resources << "org.kde.dummy.instance1"; 131 query.resources << "org.kde.dummy.instance1";
95 Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); 132 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
96 } 133 }
97 auto allProcessedTime = time.elapsed(); 134 auto allProcessedTime = time.elapsed();
98 135
@@ -138,7 +175,7 @@ private Q_SLOTS:
138 175
139 void testWriteInProcess() 176 void testWriteInProcess()
140 { 177 {
141 DummyResource::removeFromDisk("org.kde.dummy.instance1"); 178 Sink::Store::removeDataFromDisk("org.kde.dummy.instance1").exec().waitForFinished();
142 QTime time; 179 QTime time;
143 time.start(); 180 time.start();
144 181
@@ -226,7 +263,7 @@ private Q_SLOTS:
226 //This allows to run individual parts without doing a cleanup, but still cleaning up normally 263 //This allows to run individual parts without doing a cleanup, but still cleaning up normally
227 void testCleanupForCompleteTest() 264 void testCleanupForCompleteTest()
228 { 265 {
229 DummyResource::removeFromDisk("org.kde.dummy.instance1"); 266 Sink::Store::removeDataFromDisk("org.kde.dummy.instance1").exec().waitForFinished();
230 } 267 }
231 268
232private: 269private: