@@ -22,17 +22,16 @@ TestCase {
22 name: "PhysicalKeysMapper"
22 name: "PhysicalKeysMapper"
24 property int onPowerKeyLongPressCount: 0
24 property int onPowerKeyLongPressCount: 0
25− property int onScreenshotPressedCount: 0
25+ property int initialLongPressTimerValue
26− property int onVolumeDownPressedCount: 0
27− property int onVolumeUpPressedCount: 0
29 PhysicalKeysMapper {
27 PhysicalKeysMapper {
30 id: physicalKeysMapper
28 id: physicalKeysMapper
32 onPowerKeyLongPress: onPowerKeyLongPressCount += 1
30 onPowerKeyLongPress: onPowerKeyLongPressCount += 1
33− onScreenshotPressed: onScreenshotPressedCount += 1
31+ }
34− onVolumeDownPressed: onVolumeDownPressedCount += 1
32+
35− onVolumeUpPressed: onVolumeUpPressedCount += 1
33+ function initTestCase() {
34+ initialLongPressTimerValue = physicalKeysMapper.powerKeyLongPressTimeMs
38 function cleanup() {
37 function cleanup() {
@@ -42,37 +41,45 @@ TestCase {
42 physicalKeysMapper.onKeyReleased(Qt.Key_VolumeUp);
41 physicalKeysMapper.onKeyReleased(Qt.Key_VolumeUp);
44 onPowerKeyLongPressCount = 0;
43 onPowerKeyLongPressCount = 0;
45− onScreenshotPressedCount = 0;
44+
46− onVolumeDownPressedCount = 0;
45+ physicalKeysMapper.powerKeyLongPressTimeMs = initialLongPressTimerValue
47− onVolumeUpPressedCount = 0;
50 function test_LongPressPowerButton() {
48 function test_LongPressPowerButton() {
49+ // Delays chosen are lowest reliable values
50+ physicalKeysMapper.powerKeyLongPressTimeMs = 2
51 physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
51 physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
52− wait(3000);
52+ wait(15);
54 compare(onPowerKeyLongPressCount, 1);
54 compare(onPowerKeyLongPressCount, 1);
57 function test_ScreenshotButtons() {
57 function test_ScreenshotButtons() {
58+ /* Behavior when Power is pressed 1st */
58 physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
59 physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
59 physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
60 physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
61+ compare(physicalKeysMapper.screenshotPressed, true);
62+ compare(physicalKeysMapper.volumeDownPressed, false);
61− compare(onScreenshotPressedCount, 1);
64+ physicalKeysMapper.onKeyReleased(Qt.Key_PowerDown);
62− compare(onVolumeDownPressedCount, 0);
65+ physicalKeysMapper.onKeyReleased(Qt.Key_VolumeDown);
64− wait(3000);
67+ /* Behavior when VolumeDown is pressed 1st */
65− compare(onScreenshotPressedCount, 1);
68+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
66− compare(onVolumeDownPressedCount, 0);
69+ compare(physicalKeysMapper.volumeDownPressed, true);
70+ physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
71+ compare(physicalKeysMapper.screenshotPressed, true);
69 function test_VolumeDownButton() {
74 function test_VolumeDownButton() {
75+ compare(physicalKeysMapper.volumeDownPressed, false);
70 physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
76 physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
71− compare(onVolumeDownPressedCount, 1);
77+ compare(physicalKeysMapper.volumeDownPressed, true);
74 function test_VolumeUpButton() {
80 function test_VolumeUpButton() {
81+ compare(physicalKeysMapper.volumeUpPressed, false);
75 physicalKeysMapper.onKeyPressed(Qt.Key_VolumeUp);
82 physicalKeysMapper.onKeyPressed(Qt.Key_VolumeUp);
76− compare(onVolumeUpPressedCount, 1);
83+ compare(physicalKeysMapper.volumeUpPressed, true);