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

Subscribers

People subscribed via source and target branches