Merge lp:~kissiel/checkbox/story-1242 into lp:checkbox

Proposed by Maciej Kisielewski
Status: Merged
Approved by: Zygmunt Krynicki
Approved revision: 3617
Merged at revision: 3619
Proposed branch: lp:~kissiel/checkbox/story-1242
Merge into: lp:checkbox
Diff against target: 170 lines (+158/-0)
2 files modified
providers/2015.com.canonical.certification:qml-tests/data/sensors-01.qml (+150/-0)
providers/2015.com.canonical.certification:qml-tests/units/qml-tests.pxu (+8/-0)
To merge this branch: bzr merge lp:~kissiel/checkbox/story-1242
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Review via email: mp+253219@code.launchpad.net

Description of the change

This MR adds sensors-01 test that is a minigame helping verify whether accelerometer is working.

Version proposed here is not using any fancy math to translate world coordinates - it's relative to Earth's gravity instead.

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Just one minor comment in the .pxu file

review: Needs Fixing
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Everything looks nice, interesting test, +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'providers/2015.com.canonical.certification:qml-tests/data/sensors-01.qml'
--- providers/2015.com.canonical.certification:qml-tests/data/sensors-01.qml 1970-01-01 00:00:00 +0000
+++ providers/2015.com.canonical.certification:qml-tests/data/sensors-01.qml 2015-03-17 15:39:13 +0000
@@ -0,0 +1,150 @@
1/*
2 * This file is part of Checkbox.
3 *
4 * Copyright 2015 Canonical Ltd.
5 * Written by:
6 * Maciej Kisielewski <maciej.kisielewski@canonical.com>
7 *
8 * Checkbox is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 3,
10 * as published by the Free Software Foundation.
11 *
12 * Checkbox is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
19 */
20import QtQuick 2.0
21import Ubuntu.Components 1.1
22import QtSensors 5.2
23import QtQuick.Layouts 1.1
24import QtQuick.Window 2.2
25
26
27Item {
28 id: root
29 signal testDone(var test)
30 property var testingShell
31
32 width: units.gu(100)
33 height: units.gu(75)
34
35 readonly property var ballSize: units.gu(5)
36 property var posX: mainPage.width/2 - ballSize/2
37 property var posY: mainPage.height/8 - ballSize/2
38
39 property var testPassed
40
41 anchors.fill: parent
42
43 Page {
44 id: mainPage
45
46 ColumnLayout {
47 spacing: units.gu(1)
48 anchors {
49 margins: units.gu(2)
50 fill: parent
51 }
52
53 Label {
54 id: instruction
55 text: i18n.tr("Tilt the device to place the red ball in the green box")
56 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
57 Layout.fillWidth: true
58 verticalAlignment: Text.AlignVCenter
59 horizontalAlignment: Text.AlignHCenter
60 Layout.preferredWidth: units.gu(10)
61
62 }
63
64 Label {
65 id: outcomeLabel
66 visible: false
67 text: testPassed ? i18n.tr("PASSED") : i18n.tr("FAILED")
68 color: testPassed ? UbuntuColors.green : UbuntuColors.red
69 Layout.fillWidth: true
70 Layout.preferredWidth: units.gu(10)
71 verticalAlignment: Text.AlignVCenter
72 horizontalAlignment: Text.AlignHCenter
73 font.pixelSize: units.gu(7)
74 function showResult(passed) {
75 ticker.stop();
76 failButton.visible = false;
77 instruction.visible = false;
78 outcomeLabel.visible = true;
79 testPassed = passed;
80 summaryTimer.start();
81 }
82 }
83
84 Button {
85 id: failButton
86 text: i18n.tr("I'm unable to move the dot")
87 anchors.bottom: parent.bottom
88 Layout.fillWidth: true
89 onClicked: outcomeLabel.showResult(false)
90 }
91 }
92
93 Rectangle {
94 id: goal
95 property var goalSizeX: units.gu(15)
96 property var goalSizeY: units.gu(10)
97 x: mainPage.width / 2 - goalSizeX / 2
98 y: (mainPage.height / 8) * 5 - goalSizeY / 2
99 color: "green"
100 height: goalSizeY
101 width: goalSizeX
102 }
103
104 Rectangle {
105 id: ball
106 x: posX
107 y: posY
108 color: "red"
109 width: ballSize
110 height: ballSize
111 radius: width*0.5
112 }
113
114 Timer {
115 id: ticker
116 interval: 20
117 running: true
118 onTriggered: {
119 posX-=accelerometer.reading.x;
120 posY+=accelerometer.reading.y;
121
122 if(posX < 0) posX = 0;
123 if(posX + ballSize > mainPage.width) posX = mainPage.width - ballSize;
124 if(posY < 0) posY = 0;
125 if(posY + ballSize > mainPage.height) posY = mainPage.height - ballSize;
126
127 if(posX >= goal.x && posX+ballSize < goal.x+goal.goalSizeX &&
128 posY >= goal.y && posY+ballSize < goal.y+goal.goalSizeY) {
129 outcomeLabel.showResult(true);
130 }
131 }
132 repeat: true
133 }
134
135 Timer {
136 id: summaryTimer
137 interval: 1000
138 onTriggered: {
139 testDone({'outcome': testPassed ? "pass" : "fail"})
140 }
141 }
142 }
143
144 Accelerometer {
145 id: accelerometer
146 active: true
147 }
148}
149
150
0151
=== modified file 'providers/2015.com.canonical.certification:qml-tests/units/qml-tests.pxu'
--- providers/2015.com.canonical.certification:qml-tests/units/qml-tests.pxu 2015-03-13 14:21:45 +0000
+++ providers/2015.com.canonical.certification:qml-tests/units/qml-tests.pxu 2015-03-17 15:39:13 +0000
@@ -18,3 +18,11 @@
18_description: Camera test 06 - Record a video then play it back18_description: Camera test 06 - Record a video then play it back
19qml_file: camera-06.qml19qml_file: camera-06.qml
20estimated_duration: 2020estimated_duration: 20
21
22id: sensors-01
23plugin: qml
24_sumamry: Sensors test 01 - Ensure accelerometer is functioning
25_description:
26 This test is a mini-game where accelerometer is used to guide a big dot to a goal marked on the screen.
27qml_file: sensors-01.qml
28estimated_duration: 20

Subscribers

People subscribed via source and target branches