@@ -1,9 +1,6 @@
2 * Copyright (C) 2014 Canonical, Ltd.
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
4 * 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
5 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
6 * the Free Software Foundation; version 3.
@@ -20,9 +17,9 @@
20import QtQuick 2.0
17import QtQuick 2.0
21import QtTest 1.0
18import QtTest 1.0
22import "../../../qml/Components"
19import "../../../qml/Components"
23−import Unity.Test 0.1 as UT
22+ name: "PhysicalKeysMapper"
27 property int onBothVolumeKeysPressedCount: 0
24 property int onBothVolumeKeysPressedCount: 0
28 property int onPowerKeyLongPressCount: 0
25 property int onPowerKeyLongPressCount: 0
@@ -40,61 +37,56 @@ Item {
40 onVolumeUpPressed: onVolumeUpPressedCount += 1
37 onVolumeUpPressed: onVolumeUpPressedCount += 1
44− name: "PhysicalKeyMapper"
47− function cleanup() {
40+ function cleanup() {
48− physicalKeysMapper.onKeyReleased(Qt.Key_PowerDown);
41+ physicalKeysMapper.onKeyReleased(Qt.Key_PowerDown);
49− physicalKeysMapper.onKeyReleased(Qt.Key_PowerOff);
42+ physicalKeysMapper.onKeyReleased(Qt.Key_PowerOff);
50− physicalKeysMapper.onKeyReleased(Qt.Key_VolumeDown);
43+ physicalKeysMapper.onKeyReleased(Qt.Key_VolumeDown);
51− physicalKeysMapper.onKeyReleased(Qt.Key_VolumeUp);
44+ physicalKeysMapper.onKeyReleased(Qt.Key_VolumeUp);
53− onBothVolumeKeysPressedCount = 0;
46+ onBothVolumeKeysPressedCount = 0;
54− onPowerKeyLongPressCount = 0;
47+ onPowerKeyLongPressCount = 0;
55− onScreenshotPressedCount = 0;
48+ onScreenshotPressedCount = 0;
56− onVolumeDownPressedCount = 0;
49+ onVolumeDownPressedCount = 0;
57− onVolumeUpPressedCount = 0;
50+ onVolumeUpPressedCount = 0;
60− function test_BothVolumeKeysSimultaneously() {
53+ function test_BothVolumeKeysSimultaneously() {
61− physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
54+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
62− physicalKeysMapper.onKeyPressed(Qt.Key_VolumeUp);
55+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeUp);
64− compare(onBothVolumeKeysPressedCount, 1);
57+ compare(onBothVolumeKeysPressedCount, 1);
66− // Simulate holding the keys down
59+ // Simulate holding the keys down
67− wait(3000);
60+ wait(3000);
68− compare(onBothVolumeKeysPressedCount, 1);
61+ compare(onBothVolumeKeysPressedCount, 1);
71− function test_LongPressPowerButton() {
64+ function test_LongPressPowerButton() {
72− physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
65+ physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
73− wait(3000);
66+ wait(3000);
75− compare(onPowerKeyLongPressCount, 1);
68+ compare(onPowerKeyLongPressCount, 1);
78− function test_ScreenshotButtons() {
71+ function test_ScreenshotButtons() {
79− physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
72+ physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
80− physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
73+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
82− compare(onScreenshotPressedCount, 1);
75+ compare(onScreenshotPressedCount, 1);
83− compare(onVolumeDownPressedCount, 0);
76+ compare(onVolumeDownPressedCount, 0);
85− wait(3000);
78+ wait(3000);
86− compare(onScreenshotPressedCount, 1);
79+ compare(onScreenshotPressedCount, 1);
87− compare(onVolumeDownPressedCount, 0);
80+ compare(onVolumeDownPressedCount, 0);
90− function test_VolumeDownButton() {
83+ function test_VolumeDownButton() {
91− physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
84+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
92− compare(onVolumeDownPressedCount, 1);
85+ compare(onVolumeDownPressedCount, 1);
95− function test_VolumeUpButton() {
88+ function test_VolumeUpButton() {
96− physicalKeysMapper.onKeyPressed(Qt.Key_VolumeUp);
89+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeUp);
97− compare(onVolumeUpPressedCount, 1);
90+ compare(onVolumeUpPressedCount, 1);