on xenial help sign in
Remove GUI from test
d2abe97Josh Arenson
tests/qmltests/Components/tst_PhysicalKeysMapper.qml+53−61
@@ -1,9 +1,6 @@
1/*
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
3 *
4− * Authors:
5− * Josh Arenson <joshua.arenson@canonical.com>
6− *
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
24
20
25−Item {
21+TestCase {
22+ name: "PhysicalKeysMapper"
26
23
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
41 }
38 }
42
39
43− UT.UnityTestCase {
44− name: "PhysicalKeyMapper"
45− when: windowShown
46−
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);
52−
45+
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;
58− }
51+ }
59−
52+
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);
63−
56+
64− compare(onBothVolumeKeysPressedCount, 1);
57+ compare(onBothVolumeKeysPressedCount, 1);
65−
58+
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);
69− }
62+ }
70−
63+
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);
74−
67+
75− compare(onPowerKeyLongPressCount, 1);
68+ compare(onPowerKeyLongPressCount, 1);
76− }
69+ }
77−
70+
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);
81−
74+
82− compare(onScreenshotPressedCount, 1);
75+ compare(onScreenshotPressedCount, 1);
83− compare(onVolumeDownPressedCount, 0);
76+ compare(onVolumeDownPressedCount, 0);
84−
77+
85− wait(3000);
78+ wait(3000);
86− compare(onScreenshotPressedCount, 1);
79+ compare(onScreenshotPressedCount, 1);
87− compare(onVolumeDownPressedCount, 0);
80+ compare(onVolumeDownPressedCount, 0);
88− }
81+ }
89−
82+
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);
93− }
86+ }
94−
87+
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);
98− }
99 }
91 }
100}
92}