on xenial help sign in
Add test
commit429f3c549063afb3492b8152be3cb9b302a98ef7 authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 28 Aug 2015, 09:44 (11 years ago) parent364ac1a
1 file changed+28
tests/qmltests/Components/tst_PhysicalKeysMapper.qml+28
tests/qmltests/Components/tst_PhysicalKeysMapper.qml+28
@@ -17,6 +17,7 @@
1717import QtQuick 2.0
1818import QtTest 1.0
1919import "../../../qml/Components"
20+import Powerd 0.1
2021
2122TestCase {
2223 name: "PhysicalKeysMapper"
@@ -56,6 +57,7 @@ TestCase {
5657 }
5758
5859 function init() {
60+ Powerd.status = Powerd.On;
5961 loader.active = true;
6062 tryCompare(loader.status == Loader.Ready);
6163 }
@@ -89,6 +91,32 @@ TestCase {
8991 compare(powerSpy.count, 1);
9092 }
9193
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+
92120 function test_screenshotPrtScr() {
93121 physicalKeysMapper.onKeyPressed({ key: Qt.Key_Print })
94122 tryCompare(screenshotSpy, "count", 1) // verify the screenshotTriggered signal has been called, exactly once