on xenial help sign in
Remove GUI from test
commitd2abe973bd25b222d3ba3a36333cd6138a2cfab6 authorJosh Arenson <joshua.arenson@canonical.com> dateThu 11 Dec 2014, 12:58 (12 years ago) parentffaf38b
1 file changed+53−61
tests/qmltests/Components/tst_PhysicalKeysMapper.qml+53−61
tests/qmltests/Components/tst_PhysicalKeysMapper.qml+53−61
@@ -1,9 +1,6 @@
11/*
22 * Copyright (C) 2014 Canonical, Ltd.
33 *
4− * Authors:
5− * Josh Arenson <joshua.arenson@canonical.com>
6− *
74 * This program is free software; you can redistribute it and/or modify
85 * it under the terms of the GNU General Public License as published by
96 * the Free Software Foundation; version 3.
@@ -20,9 +17,9 @@
2017import QtQuick 2.0
2118import QtTest 1.0
2219import "../../../qml/Components"
23−import Unity.Test 0.1 as UT
2420
25−Item {
21+TestCase {
22+ name: "PhysicalKeysMapper"
2623
2724 property int onBothVolumeKeysPressedCount: 0
2825 property int onPowerKeyLongPressCount: 0
@@ -40,61 +37,56 @@ Item {
4037 onVolumeUpPressed: onVolumeUpPressedCount += 1
4138 }
4239
43− UT.UnityTestCase {
44− name: "PhysicalKeyMapper"
45− when: windowShown
46−
47− function cleanup() {
48− physicalKeysMapper.onKeyReleased(Qt.Key_PowerDown);
49− physicalKeysMapper.onKeyReleased(Qt.Key_PowerOff);
50− physicalKeysMapper.onKeyReleased(Qt.Key_VolumeDown);
51− physicalKeysMapper.onKeyReleased(Qt.Key_VolumeUp);
52−
53− onBothVolumeKeysPressedCount = 0;
54− onPowerKeyLongPressCount = 0;
55− onScreenshotPressedCount = 0;
56− onVolumeDownPressedCount = 0;
57− onVolumeUpPressedCount = 0;
58− }
59−
60− function test_BothVolumeKeysSimultaneously() {
61− physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
62− physicalKeysMapper.onKeyPressed(Qt.Key_VolumeUp);
63−
64− compare(onBothVolumeKeysPressedCount, 1);
65−
66− // Simulate holding the keys down
67− wait(3000);
68− compare(onBothVolumeKeysPressedCount, 1);
69− }
70−
71− function test_LongPressPowerButton() {
72− physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
73− wait(3000);
74−
75− compare(onPowerKeyLongPressCount, 1);
76− }
77−
78− function test_ScreenshotButtons() {
79− physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
80− physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
81−
82− compare(onScreenshotPressedCount, 1);
83− compare(onVolumeDownPressedCount, 0);
84−
85− wait(3000);
86− compare(onScreenshotPressedCount, 1);
87− compare(onVolumeDownPressedCount, 0);
88− }
89−
90− function test_VolumeDownButton() {
91− physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
92− compare(onVolumeDownPressedCount, 1);
93− }
94−
95− function test_VolumeUpButton() {
96− physicalKeysMapper.onKeyPressed(Qt.Key_VolumeUp);
97− compare(onVolumeUpPressedCount, 1);
98− }
40+ function cleanup() {
41+ physicalKeysMapper.onKeyReleased(Qt.Key_PowerDown);
42+ physicalKeysMapper.onKeyReleased(Qt.Key_PowerOff);
43+ physicalKeysMapper.onKeyReleased(Qt.Key_VolumeDown);
44+ physicalKeysMapper.onKeyReleased(Qt.Key_VolumeUp);
45+
46+ onBothVolumeKeysPressedCount = 0;
47+ onPowerKeyLongPressCount = 0;
48+ onScreenshotPressedCount = 0;
49+ onVolumeDownPressedCount = 0;
50+ onVolumeUpPressedCount = 0;
51+ }
52+
53+ function test_BothVolumeKeysSimultaneously() {
54+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
55+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeUp);
56+
57+ compare(onBothVolumeKeysPressedCount, 1);
58+
59+ // Simulate holding the keys down
60+ wait(3000);
61+ compare(onBothVolumeKeysPressedCount, 1);
62+ }
63+
64+ function test_LongPressPowerButton() {
65+ physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
66+ wait(3000);
67+
68+ compare(onPowerKeyLongPressCount, 1);
69+ }
70+
71+ function test_ScreenshotButtons() {
72+ physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
73+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
74+
75+ compare(onScreenshotPressedCount, 1);
76+ compare(onVolumeDownPressedCount, 0);
77+
78+ wait(3000);
79+ compare(onScreenshotPressedCount, 1);
80+ compare(onVolumeDownPressedCount, 0);
81+ }
82+
83+ function test_VolumeDownButton() {
84+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
85+ compare(onVolumeDownPressedCount, 1);
86+ }
87+
88+ function test_VolumeUpButton() {
89+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeUp);
90+ compare(onVolumeUpPressedCount, 1);
9991 }
10092}