~lukas-kde/unity8/betterSessionManagement

« back to all changes in this revision

Viewing changes to tests/plugins/Utils/WindowInputMonitorTest.cpp

  • Committer: Lukáš Tinkl
  • Date: 2017-03-24 11:57:27 UTC
  • mfrom: (2800.1.91 unity8)
  • Revision ID: lukas.tinkl@canonical.com-20170324115727-34c7tvv3qnxvxzdj
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    qint64 elapsed() const override { return m_valid ? msecsSinceEpoch - m_msecsSinceReference : qrand(); }
33
33
 
34
34
private:
35
 
    qint64 m_msecsSinceReference;
 
35
    qint64 m_msecsSinceReference{0};
36
36
    bool m_valid{false};
37
37
};
38
38
qint64 FakeElapsedTimer::msecsSinceEpoch = 0;
89
89
    void tapWhileTouching();
90
90
    void multipleHomeKeys();
91
91
 
 
92
    void keyComboInvolvingHome();
 
93
 
92
94
    void repeatedSuperPress();
93
95
 
94
96
private:
197
199
    QCOMPARE(activatedSpy.count(), expectedActivatedCount);
198
200
}
199
201
 
 
202
void WindowInputMonitorTest::keyComboInvolvingHome()
 
203
{
 
204
    WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(this), new FakeElapsedTimer);
 
205
    QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::homeKeyActivated);
 
206
    QVERIFY(activatedSpy.isValid());
 
207
 
 
208
    passTime(1000);
 
209
    {
 
210
        QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_Super_L, Qt::NoModifier);
 
211
        homeKeyWatcher.update(&keyEvent);
 
212
    }
 
213
    {
 
214
        QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier);
 
215
        homeKeyWatcher.update(&keyEvent);
 
216
    }
 
217
    {
 
218
        QKeyEvent keyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::NoModifier);
 
219
        homeKeyWatcher.update(&keyEvent);
 
220
    }
 
221
    {
 
222
        QKeyEvent keyEvent(QEvent::KeyRelease, Qt::Key_Super_L, Qt::NoModifier);
 
223
        homeKeyWatcher.update(&keyEvent);
 
224
    }
 
225
    passTime(1000);
 
226
 
 
227
    QCOMPARE(activatedSpy.count(), 0);
 
228
}
 
229
 
200
230
void WindowInputMonitorTest::tapWhileTouching()
201
231
{
202
232
    WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(this), new FakeElapsedTimer);