Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_idle.cpp
Show All 36 Lines | |||||
37 | { | 37 | { | ||
38 | Q_OBJECT | 38 | Q_OBJECT | ||
39 | private Q_SLOTS: | 39 | private Q_SLOTS: | ||
40 | void init(); | 40 | void init(); | ||
41 | void cleanup(); | 41 | void cleanup(); | ||
42 | 42 | | |||
43 | void testTimeout(); | 43 | void testTimeout(); | ||
44 | void testSimulateUserActivity(); | 44 | void testSimulateUserActivity(); | ||
45 | void testServerSimulateUserActivity(); | ||||
45 | void testIdleInhibit(); | 46 | void testIdleInhibit(); | ||
46 | void testIdleInhibitBlocksTimeout(); | 47 | void testIdleInhibitBlocksTimeout(); | ||
47 | 48 | | |||
48 | private: | 49 | private: | ||
49 | Display *m_display = nullptr; | 50 | Display *m_display = nullptr; | ||
50 | SeatInterface *m_seatInterface = nullptr; | 51 | SeatInterface *m_seatInterface = nullptr; | ||
51 | IdleInterface *m_idleInterface = nullptr; | 52 | IdleInterface *m_idleInterface = nullptr; | ||
52 | ConnectionThread *m_connection = nullptr; | 53 | ConnectionThread *m_connection = nullptr; | ||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Line(s) | 165 | { | |||
183 | timeout->simulateUserActivity(); | 184 | timeout->simulateUserActivity(); | ||
184 | QVERIFY(resumedFormIdleSpy.wait()); | 185 | QVERIFY(resumedFormIdleSpy.wait()); | ||
185 | 186 | | |||
186 | timeout.reset(); | 187 | timeout.reset(); | ||
187 | m_connection->flush(); | 188 | m_connection->flush(); | ||
188 | m_display->dispatchEvents(); | 189 | m_display->dispatchEvents(); | ||
189 | } | 190 | } | ||
190 | 191 | | |||
192 | void IdleTest::testServerSimulateUserActivity() | ||||
193 | { | ||||
194 | // this test verifies that simulate user activity doesn't fire the timer | ||||
195 | QScopedPointer<IdleTimeout> timeout(m_idle->getTimeout(6000, m_seat)); | ||||
196 | QVERIFY(timeout->isValid()); | ||||
197 | QSignalSpy idleSpy(timeout.data(), &IdleTimeout::idle); | ||||
198 | QVERIFY(idleSpy.isValid()); | ||||
199 | QSignalSpy resumedFormIdleSpy(timeout.data(), &IdleTimeout::resumeFromIdle); | ||||
200 | QVERIFY(resumedFormIdleSpy.isValid()); | ||||
201 | m_connection->flush(); | ||||
202 | | ||||
203 | QTest::qWait(4000); | ||||
204 | m_idleInterface->simulateUserActivity(); | ||||
205 | // waiting default five sec should fail | ||||
206 | QVERIFY(!idleSpy.wait()); | ||||
207 | // another 2 sec should fire | ||||
208 | QVERIFY(idleSpy.wait(2000)); | ||||
209 | | ||||
210 | // now simulating user activity should emit a resumedFromIdle | ||||
211 | QVERIFY(resumedFormIdleSpy.isEmpty()); | ||||
212 | m_idleInterface->simulateUserActivity(); | ||||
213 | QVERIFY(resumedFormIdleSpy.wait()); | ||||
214 | | ||||
215 | timeout.reset(); | ||||
216 | m_connection->flush(); | ||||
217 | m_display->dispatchEvents(); | ||||
218 | } | ||||
219 | | ||||
191 | void IdleTest::testIdleInhibit() | 220 | void IdleTest::testIdleInhibit() | ||
192 | { | 221 | { | ||
193 | QCOMPARE(m_idleInterface->isInhibited(), false); | 222 | QCOMPARE(m_idleInterface->isInhibited(), false); | ||
194 | QSignalSpy idleInhibitedSpy(m_idleInterface, &IdleInterface::inhibitedChanged); | 223 | QSignalSpy idleInhibitedSpy(m_idleInterface, &IdleInterface::inhibitedChanged); | ||
195 | QVERIFY(idleInhibitedSpy.isValid()); | 224 | QVERIFY(idleInhibitedSpy.isValid()); | ||
196 | m_idleInterface->inhibit(); | 225 | m_idleInterface->inhibit(); | ||
197 | QCOMPARE(m_idleInterface->isInhibited(), true); | 226 | QCOMPARE(m_idleInterface->isInhibited(), true); | ||
198 | QCOMPARE(idleInhibitedSpy.count(), 1); | 227 | QCOMPARE(idleInhibitedSpy.count(), 1); | ||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |