on xenial help sign in
less c&p
5329f14Albert Astals Cid
tests/qmltests/Components/tst_PhysicalKeysMapper.qml+9−23
@@ -70,35 +70,21 @@ TestCase {
70 screenshotSpy.clear();
70 screenshotSpy.clear();
71 }
71 }
72
72
73− function test_powerKeyLongPressed() {
73+ function test_powerKeyLongPressed_data() {
74− physicalKeysMapper.powerKeyLongPressTime = 500;
74+ return [
75−
75+ { tag: "screenOn", status: Powerd.On },
76− physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: false });
76+ { tag: "screenOff", status: Powerd.Off },
77−
77+ ];
78− for (var i = 0; i < 3; ++i) {
79− wait(10);
80− physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: true});
81− }
82−
83− // powerKeyLongPressed should not have been emitted yet.
84− compare(powerSpy.count, 0);
85−
86− for (var i = 0; i < 10; ++i) {
87− wait(50);
88− physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: true});
89− }
90−
91− compare(powerSpy.count, 1);
92 }
78 }
93
79
94− function test_powerKeyLongPressed_screen_off() {
80+ function test_powerKeyLongPressed(data) {
95− // The screen is off
96− Powerd.status = Powerd.Off;
81+ Powerd.status = data.status;
97 physicalKeysMapper.powerKeyLongPressTime = 500;
82 physicalKeysMapper.powerKeyLongPressTime = 500;
98
83
99 physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: false });
84 physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: false });
100
85
86+ // After the first key press the screen is always on
101− // After the first key press it'll be on and the rest of keypresses are auto repeat
87+ // and the rest of keypresses are auto repeat
102 Powerd.status = Powerd.On;
88 Powerd.status = Powerd.On;
103
89
104 for (var i = 0; i < 3; ++i) {
90 for (var i = 0; i < 3; ++i) {