@@ -25,14 +25,15 @@ class FakeElapsedTimer : public AbstractElapsedTimer {
26 static qint64 msecsSinceEpoch;
26 static qint64 msecsSinceEpoch;
28− FakeElapsedTimer() { start(); }
28+ FakeElapsedTimer() {}
30− void start() override { m_msecsSinceReference = msecsSinceEpoch; }
30+ void start() override { m_msecsSinceReference = msecsSinceEpoch; m_valid = true; }
31 qint64 msecsSinceReference() const override { return m_msecsSinceReference; }
31 qint64 msecsSinceReference() const override { return m_msecsSinceReference; }
32− qint64 elapsed() const override { return msecsSinceEpoch - m_msecsSinceReference; }
32+ qint64 elapsed() const override { return m_valid ? msecsSinceEpoch - m_msecsSinceReference : qrand(); }
35 qint64 m_msecsSinceReference;
35 qint64 m_msecsSinceReference;
37qint64 FakeElapsedTimer::msecsSinceEpoch = 0;
38qint64 FakeElapsedTimer::msecsSinceEpoch = 0;
@@ -48,7 +49,7 @@ public:
48 int interval() const override;
49 int interval() const override;
49 void setInterval(int msecs) override;
50 void setInterval(int msecs) override;
50 void start() override;
51 void start() override;
51− void stop() override;
52+ void stop() override;
52 bool isRunning() const override;
53 bool isRunning() const override;
53 bool isSingleShot() const override;
54 bool isSingleShot() const override;
54 void setSingleShot(bool value) override;
55 void setSingleShot(bool value) override;
@@ -103,11 +104,10 @@ void WindowInputMonitorTest::init()
104void WindowInputMonitorTest::cleanup()
105void WindowInputMonitorTest::cleanup()
106− delete m_fakeTimerFactory;
107+ delete m_fakeTimerFactory;
107 m_fakeTimerFactory = nullptr;
108 m_fakeTimerFactory = nullptr;
111void WindowInputMonitorTest::passTime(qint64 timeSpanMs)
111void WindowInputMonitorTest::passTime(qint64 timeSpanMs)
113 qint64 finalTime = FakeElapsedTimer::msecsSinceEpoch + timeSpanMs;
113 qint64 finalTime = FakeElapsedTimer::msecsSinceEpoch + timeSpanMs;
@@ -138,7 +138,7 @@ void WindowInputMonitorTest::touchTapTouch()
138 QFETCH(int, silenceAfterTap);
138 QFETCH(int, silenceAfterTap);
139 QFETCH(int, expectedActivatedCount);
139 QFETCH(int, expectedActivatedCount);
140 QFETCH(Qt::Key, key);
140 QFETCH(Qt::Key, key);
141− WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
141+ WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(this), new FakeElapsedTimer);
142 QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::homeKeyActivated);
142 QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::homeKeyActivated);
143 QVERIFY(activatedSpy.isValid());
143 QVERIFY(activatedSpy.isValid());
@@ -199,7 +199,7 @@ void WindowInputMonitorTest::touchTapTouch()
200void WindowInputMonitorTest::tapWhileTouching()
200void WindowInputMonitorTest::tapWhileTouching()
202− WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
202+ WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(this), new FakeElapsedTimer);
203 QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::homeKeyActivated);
203 QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::homeKeyActivated);
204 QVERIFY(activatedSpy.isValid());
204 QVERIFY(activatedSpy.isValid());
@@ -234,7 +234,7 @@ void WindowInputMonitorTest::tapWhileTouching()
235void WindowInputMonitorTest::multipleHomeKeys()
235void WindowInputMonitorTest::multipleHomeKeys()
237− WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
237+ WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(this), new FakeElapsedTimer);
238 QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::homeKeyActivated);
238 QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::homeKeyActivated);
239 QVERIFY(activatedSpy.isValid());
239 QVERIFY(activatedSpy.isValid());
@@ -266,7 +266,7 @@ void WindowInputMonitorTest::multipleHomeKeys()
266// regression test for lp:1607427
266// regression test for lp:1607427
267void WindowInputMonitorTest::repeatedSuperPress()
267void WindowInputMonitorTest::repeatedSuperPress()
269− WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
269+ WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(this), new FakeElapsedTimer);
270 QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::homeKeyActivated);
270 QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::homeKeyActivated);
271 QVERIFY(activatedSpy.isValid());
271 QVERIFY(activatedSpy.isValid());
@@ -284,6 +284,21 @@ void WindowInputMonitorTest::repeatedSuperPress()
284 passTime(1000);
284 passTime(1000);
285 QCOMPARE(activatedSpy.count(), 1);
285 QCOMPARE(activatedSpy.count(), 1);
287+ // a touch event in between
289+ QTouchEvent touchEvent(QEvent::TouchBegin);
290+ homeKeyWatcher.update(&touchEvent);
293+ QTouchEvent touchEvent(QEvent::TouchUpdate);
294+ homeKeyWatcher.update(&touchEvent);
297+ QTouchEvent touchEvent(QEvent::TouchEnd);
298+ homeKeyWatcher.update(&touchEvent);
287 // 2nd try
302 // 2nd try
288 activatedSpy.clear();
303 activatedSpy.clear();