diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-08 19:30:35 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-08 19:30:35 +0100 |
commit | be9f675ada44b04d3f74c68dc46cc7f7325ece0c (patch) | |
tree | 0fd2a737ad106cb97888d1b4d586efd270bb3b67 /tests/dummyresourcebenchmark.cpp | |
parent | 6f43bb64e180083aff726a5be2c5122e97e54819 (diff) | |
download | sink-be9f675ada44b04d3f74c68dc46cc7f7325ece0c.tar.gz sink-be9f675ada44b04d3f74c68dc46cc7f7325ece0c.zip |
Test responsiveness of command processing.
Diffstat (limited to 'tests/dummyresourcebenchmark.cpp')
-rw-r--r-- | tests/dummyresourcebenchmark.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
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 @@ | |||
10 | #include "pipeline.h" | 10 | #include "pipeline.h" |
11 | #include "log.h" | 11 | #include "log.h" |
12 | #include "resourceconfig.h" | 12 | #include "resourceconfig.h" |
13 | #include "notification_generated.h" | ||
13 | 14 | ||
14 | #include "hawd/dataset.h" | 15 | #include "hawd/dataset.h" |
15 | #include "hawd/formatter.h" | 16 | #include "hawd/formatter.h" |
@@ -71,6 +72,41 @@ private Q_SLOTS: | |||
71 | }); | 72 | }); |
72 | } | 73 | } |
73 | 74 | ||
75 | //Ensure we can process a command in less than 0.1s | ||
76 | void testCommandResponsiveness() | ||
77 | { | ||
78 | //Test responsiveness including starting the process. | ||
79 | Sink::Store::shutdown("org.kde.dummy.instance1").exec().waitForFinished(); | ||
80 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | ||
81 | |||
82 | QTime time; | ||
83 | time.start(); | ||
84 | |||
85 | Sink::ApplicationDomain::Event event("org.kde.dummy.instance1"); | ||
86 | event.setProperty("uid", "testuid"); | ||
87 | QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); | ||
88 | event.setProperty("summary", "summaryValue"); | ||
89 | |||
90 | auto notifier = QSharedPointer<Sink::Notifier>::create("org.kde.dummy.instance1"); | ||
91 | bool gotNotification = false; | ||
92 | int duration = 0; | ||
93 | notifier->registerHandler([&gotNotification, &duration, &time](const Sink::Notification ¬ification) { | ||
94 | if (notification.type == Sink::Commands::NotificationType::NotificationType_RevisionUpdate) { | ||
95 | gotNotification = true; | ||
96 | duration = time.elapsed(); | ||
97 | } | ||
98 | }); | ||
99 | |||
100 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec(); | ||
101 | |||
102 | //Wait for notification | ||
103 | QTRY_VERIFY(gotNotification); | ||
104 | |||
105 | QVERIFY2(duration < 100, QString::fromLatin1("Processing a create command took more than 100ms: %1").arg(duration).toLatin1()); | ||
106 | Sink::Store::shutdown("org.kde.dummy.instance1").exec().waitForFinished(); | ||
107 | qDebug() << "Single command took [ms]: " << duration; | ||
108 | } | ||
109 | |||
74 | void testWriteToFacade() | 110 | void testWriteToFacade() |
75 | { | 111 | { |
76 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | 112 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); |