on xenial help sign in
Add test
429f3c5Albert Astals Cid
tests/qmltests/Components/tst_PhysicalKeysMapper.qml+28
@@ -17,6 +17,7 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import QtTest 1.0
18import QtTest 1.0
19import "../../../qml/Components"
19import "../../../qml/Components"
20+import Powerd 0.1
20
21
21TestCase {
22TestCase {
22 name: "PhysicalKeysMapper"
23 name: "PhysicalKeysMapper"
@@ -56,6 +57,7 @@ TestCase {
56 }
57 }
57
58
58 function init() {
59 function init() {
60+ Powerd.status = Powerd.On;
59 loader.active = true;
61 loader.active = true;
60 tryCompare(loader.status == Loader.Ready);
62 tryCompare(loader.status == Loader.Ready);
61 }
63 }
@@ -89,6 +91,32 @@ TestCase {
89 compare(powerSpy.count, 1);
91 compare(powerSpy.count, 1);
90 }
92 }
91
93
94+ function test_powerKeyLongPressed_screen_off() {
95+ // The screen is off
96+ Powerd.status = Powerd.Off;
97+ physicalKeysMapper.powerKeyLongPressTime = 500;
98+
99+ physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: false });
100+
101+ // After the first key press it'll be on and the rest of keypresses are auto repeat
102+ Powerd.status = Powerd.On;
103+
104+ for (var i = 0; i < 3; ++i) {
105+ wait(10);
106+ physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: true});
107+ }
108+
109+ // powerKeyLongPressed should not have been emitted yet.
110+ compare(powerSpy.count, 0);
111+
112+ for (var i = 0; i < 10; ++i) {
113+ wait(50);
114+ physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: true});
115+ }
116+
117+ compare(powerSpy.count, 1);
118+ }
119+
92 function test_screenshotPrtScr() {
120 function test_screenshotPrtScr() {
93 physicalKeysMapper.onKeyPressed({ key: Qt.Key_Print })
121 physicalKeysMapper.onKeyPressed({ key: Qt.Key_Print })
94 tryCompare(screenshotSpy, "count", 1) // verify the screenshotTriggered signal has been called, exactly once
122 tryCompare(screenshotSpy, "count", 1) // verify the screenshotTriggered signal has been called, exactly once