@@ -0,0 +1,103 @@
2+ * Copyright (C) 2014 Canonical, Ltd.
5+ * Josh Arenson <joshua.arenson@canonical.com>
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation; version 3.
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
22+import "../../../qml/Components"
23+import Unity.Test 0.1 as UT
27+ property int onBothVolumeKeysPressedCount: 0
28+ property int onPowerPressedCount: 0
29+ property int onScreenshotPressedCount: 0
30+ property int onVolumeDownPressedCount: 0
31+ property int onVolumeUpPressedCount: 0
34+ id: physicalKeysFilter
36+ onBothVolumeKeysPressed: onBothVolumeKeysPressedCount += 1
37+ onPowerPressed: onPowerPressedCount += 1
38+ onScreenshotPressed: onScreenshotPressedCount += 1
39+ onVolumeDownPressed: onVolumeDownPressedCount += 1
40+ onVolumeUpPressed: onVolumeUpPressedCount += 1
44+ name: "PhysicalKeyFilter"
48+ physicalKeysFilter.onKeyReleased(Qt.Key_PowerDown);
49+ physicalKeysFilter.onKeyReleased(Qt.Key_PowerOff);
50+ physicalKeysFilter.onKeyReleased(Qt.Key_VolumeDown);
51+ physicalKeysFilter.onKeyReleased(Qt.Key_VolumeUp);
53+ onBothVolumeKeysPressedCount = 0;
54+ onPowerPressedCount = 0;
55+ onScreenshotPressedCount = 0;
56+ onVolumeDownPressedCount = 0;
57+ onVolumeUpPressedCount = 0;
60+ function test_both_volume_keys_simultaneously() {
61+ physicalKeysFilter.onKeyPressed(Qt.Key_VolumeDown);
62+ physicalKeysFilter.onKeyPressed(Qt.Key_VolumeUp);
64+ compare(onBothVolumeKeysPressedCount, 1);
66+ // Simulate holding the keys down
68+ compare(onBothVolumeKeysPressedCount, 1);
71+ function test_power_button() {
72+ physicalKeysFilter.onKeyPressed(Qt.Key_PowerDown);
73+ compare(onPowerPressedCount, 1);
76+ compare(onPowerPressedCount, 1);
79+ function test_screenshot_buttons() {
80+ physicalKeysFilter.onKeyPressed(Qt.Key_PowerDown);
81+ physicalKeysFilter.onKeyPressed(Qt.Key_VolumeDown);
83+ compare(onPowerPressedCount, 1);
84+ compare(onScreenshotPressedCount, 1);
85+ compare(onVolumeDownPressedCount, 0);
88+ compare(onPowerPressedCount, 1);
89+ compare(onScreenshotPressedCount, 1);
90+ compare(onVolumeDownPressedCount, 0);
93+ function test_volume_down_button() {
94+ physicalKeysFilter.onKeyPressed(Qt.Key_VolumeDown);
95+ compare(onVolumeDownPressedCount, 1);
98+ function test_volume_up_button() {
99+ physicalKeysFilter.onKeyPressed(Qt.Key_VolumeUp);
100+ compare(onVolumeUpPressedCount, 1);