Merge lp:~paulliu/unity/phablet-test-dashpeoplefiltergrid into lp:unity/phablet

Proposed by Ying-Chun Liu
Status: Merged
Approved by: Albert Astals Cid
Approved revision: no longer in the source branch.
Merged at revision: 651
Proposed branch: lp:~paulliu/unity/phablet-test-dashpeoplefiltergrid
Merge into: lp:unity/phablet
Diff against target: 202 lines (+164/-0)
4 files modified
Components/FilterGrid.qml (+3/-0)
Components/ResponsiveGridView.qml (+3/-0)
tests/qmltests/CMakeLists.txt (+1/-0)
tests/qmltests/Dash/People/tst_PeopleFilterGrid.qml (+157/-0)
To merge this branch: bzr merge lp:~paulliu/unity/phablet-test-dashpeoplefiltergrid
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Albert Astals Cid (community) Approve
Review via email: mp+161936@code.launchpad.net

Commit message

Add test for PeopleFilterGrid.

Description of the change

Add test for PeopleFilterGrid.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

The test is unstable, running

while [ true ]; do make testPeopleFilterGrid; if [ $? -ne 0 ]; then break; fi; done

in my builddir makes it fail with

********* Start testing of qmltestrunner *********
Config: Using QTest library 5.0.1, Qt 5.0.1
PASS : qmltestrunner::DashPeopleFilterGrid::initTestCase()
PASS : qmltestrunner::DashPeopleFilterGrid::test_clickCell(row 0)
FAIL! : qmltestrunner::DashPeopleFilterGrid::test_clickCell(row 1) Compared values are not the same
   Actual (): 0
   Expected (): 1
   Loc: [/home/tsdgeos_work/phablet/lalala/tests/qmltests/Dash/People/tst_PeopleFilterGrid.qml(140)]
FAIL! : qmltestrunner::DashPeopleFilterGrid::test_clickCell(row 2) Compared values are not the same
   Actual (): 0
   Expected (): 1
   Loc: [/home/tsdgeos_work/phablet/lalala/tests/qmltests/Dash/People/tst_PeopleFilterGrid.qml(140)]
FAIL! : qmltestrunner::DashPeopleFilterGrid::test_clickCell(row 3) Compared values are not the same
   Actual (): 0
   Expected (): 1
   Loc: [/home/tsdgeos_work/phablet/lalala/tests/qmltests/Dash/People/tst_PeopleFilterGrid.qml(140)]
FAIL! : qmltestrunner::DashPeopleFilterGrid::test_clickCell(row 4) Compared values are not the same
   Actual (): 0
   Expected (): 1
   Loc: [/home/tsdgeos_work/phablet/lalala/tests/qmltests/Dash/People/tst_PeopleFilterGrid.qml(140)]
PASS : qmltestrunner::DashPeopleFilterGrid::cleanupTestCase()
Totals: 3 passed, 4 failed, 0 skipped
********* Finished testing of qmltestrunner *********

Usually happens in less than a minute of running the while loop

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote :

Works :-)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Components/FilterGrid.qml'
2--- Components/FilterGrid.qml 2013-04-22 09:47:20 +0000
3+++ Components/FilterGrid.qml 2013-05-02 00:15:31 +0000
4@@ -51,6 +51,9 @@
5 property alias delegate: iconTileGrid.delegate
6 property alias cellWidth: iconTileGrid.cellWidth
7 property alias cellHeight: iconTileGrid.cellHeight
8+ readonly property alias flicking: iconTileGrid.flicking
9+ readonly property alias moving: iconTileGrid.moving
10+ readonly property alias pressDelay: iconTileGrid.pressDelay
11
12 // for testing purposes
13 property alias __expansionAnimation: heightAnimation
14
15=== modified file 'Components/ResponsiveGridView.qml'
16--- Components/ResponsiveGridView.qml 2013-04-15 14:31:47 +0000
17+++ Components/ResponsiveGridView.qml 2013-05-02 00:15:31 +0000
18@@ -34,6 +34,9 @@
19 readonly property int cellHeight: gridView.cellHeight
20 readonly property int totalContentHeight: Math.ceil(gridView.model.count / columns) * cellHeight + verticalSpacing
21 property alias interactive: gridView.interactive
22+ readonly property alias flicking: gridView.flicking
23+ readonly property alias moving: gridView.moving
24+ readonly property alias pressDelay: gridView.pressDelay
25
26 GridView {
27 id: gridView
28
29=== modified file 'tests/qmltests/CMakeLists.txt'
30--- tests/qmltests/CMakeLists.txt 2013-04-29 22:36:25 +0000
31+++ tests/qmltests/CMakeLists.txt 2013-05-02 00:15:31 +0000
32@@ -48,6 +48,7 @@
33 add_qml_test(Dash FilterGrids IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins ${CMAKE_CURRENT_SOURCE_DIR}/plugins
34 ${CMAKE_BINARY_DIR}/tests/mocks)
35 add_qml_test(Dash/Apps RunningApplicationsGrid IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
36+add_qml_test(Dash/People PeopleFilterGrid IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${CMAKE_CURRENT_SOURCE_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
37 add_qml_test(Greeter Greeter)
38 add_qml_test(Hud Hud)
39 add_qml_test(Launcher Launcher)
40
41=== added directory 'tests/qmltests/Dash/People'
42=== added file 'tests/qmltests/Dash/People/tst_PeopleFilterGrid.qml'
43--- tests/qmltests/Dash/People/tst_PeopleFilterGrid.qml 1970-01-01 00:00:00 +0000
44+++ tests/qmltests/Dash/People/tst_PeopleFilterGrid.qml 2013-05-02 00:15:31 +0000
45@@ -0,0 +1,157 @@
46+/*
47+ * Copyright 2013 Canonical Ltd.
48+ *
49+ * This program is free software; you can redistribute it and/or modify
50+ * it under the terms of the GNU General Public License as published by
51+ * the Free Software Foundation; version 3.
52+ *
53+ * This program is distributed in the hope that it will be useful,
54+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
55+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56+ * GNU General Public License for more details.
57+ *
58+ * You should have received a copy of the GNU General Public License
59+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
60+ */
61+
62+import QtQuick 2.0
63+import QtTest 1.0
64+import ".."
65+import "../.."
66+import "../../../../Dash/People"
67+import Ubuntu.Components 0.1
68+import Unity.Test 0.1 as UT
69+
70+Item {
71+ id: root
72+ width: units.gu(120)
73+ height: units.gu(40)
74+
75+ PeopleFilterGrid {
76+ id: peopleFilterGrid
77+ anchors.fill: parent
78+ model: mockModel
79+ }
80+
81+ SignalSpy {
82+ id: signalSpy
83+ target: peopleFilterGrid
84+ signalName: "clicked"
85+ }
86+
87+ ListModel {
88+ id: mockModel
89+
90+ ListElement {
91+ column_0: 'user://001'
92+ column_1: "gtk-apply"
93+ column_2: ""
94+ column_3: ""
95+ column_4: "User 1"
96+ column_5: "Text 1"
97+ }
98+
99+ ListElement {
100+ column_0: 'user://002'
101+ column_1: "gtk-apply"
102+ column_2: ""
103+ column_3: ""
104+ column_4: "User 2"
105+ column_5: "Text 2"
106+ }
107+
108+ ListElement {
109+ column_0: 'user://003'
110+ column_1: "gtk-apply"
111+ column_2: ""
112+ column_3: ""
113+ column_4: "User 3"
114+ column_5: "Text 3"
115+ }
116+
117+ ListElement {
118+ column_0: 'user://004'
119+ column_1: "gtk-apply"
120+ column_2: ""
121+ column_3: ""
122+ column_4: "User 4"
123+ column_5: "Text 4"
124+ }
125+
126+ ListElement {
127+ column_0: 'user://005'
128+ column_1: "gtk-apply"
129+ column_2: ""
130+ column_3: ""
131+ column_4: "User 5"
132+ column_5: "Text 5"
133+ }
134+
135+ }
136+
137+ UT.UnityTestCase {
138+ id: testCase
139+ name: "DashPeopleFilterGrid"
140+ when: windowShown
141+
142+ function init() {
143+ }
144+
145+ function test_clickCell_data() {
146+ return [
147+ {
148+ x: peopleFilterGrid.minimumHorizontalSpacing+peopleFilterGrid.cellWidth/2,
149+ y: peopleFilterGrid.verticalSpacing+peopleFilterGrid.cellHeight/2,
150+ index: 0,
151+ uri: "user://001"
152+ },
153+ {
154+ x: 2*peopleFilterGrid.minimumHorizontalSpacing+peopleFilterGrid.cellWidth+peopleFilterGrid.cellWidth/2,
155+ y: peopleFilterGrid.verticalSpacing+peopleFilterGrid.cellHeight/2,
156+ index: 1,
157+ uri: "user://002"
158+ },
159+ {
160+ x: 3*peopleFilterGrid.minimumHorizontalSpacing+2*peopleFilterGrid.cellWidth+peopleFilterGrid.cellWidth/2,
161+ y: peopleFilterGrid.verticalSpacing+peopleFilterGrid.cellHeight/2,
162+ index: 2,
163+ uri: "user://003"
164+ },
165+ {
166+ x: peopleFilterGrid.minimumHorizontalSpacing+peopleFilterGrid.cellWidth/2,
167+ y: 2*peopleFilterGrid.verticalSpacing+peopleFilterGrid.cellHeight+peopleFilterGrid.cellHeight/2,
168+ index: 3,
169+ uri: "user://004"
170+ },
171+ {
172+ x: 2*peopleFilterGrid.minimumHorizontalSpacing+peopleFilterGrid.cellWidth+peopleFilterGrid.cellWidth/2,
173+ y: 2*peopleFilterGrid.verticalSpacing+peopleFilterGrid.cellHeight+peopleFilterGrid.cellHeight/2,
174+ index: 4,
175+ uri: "user://005"
176+ },
177+ ]
178+ }
179+
180+ function test_columns() {
181+ tryCompare(peopleFilterGrid.__expansionAnimation, "running", false)
182+ compare(peopleFilterGrid.columns,3)
183+ }
184+
185+ function test_clickCell(data) {
186+ tryCompare(peopleFilterGrid.__expansionAnimation, "running", false)
187+ tryCompare(peopleFilterGrid, "flicking", false)
188+ tryCompare(peopleFilterGrid, "moving", false)
189+ signalSpy.clear()
190+ wait(peopleFilterGrid.pressDelay > 0 ? peopleFilterGrid.pressDelay : 5)
191+ mouseClick(peopleFilterGrid, data.x, data.y)
192+ tryCompare(peopleFilterGrid.__expansionAnimation, "running", false)
193+ tryCompare(peopleFilterGrid, "flicking", false)
194+ tryCompare(peopleFilterGrid, "moving", false)
195+ compare(signalSpy.count, 1)
196+ compare(signalSpy.signalArguments.length, 1, "signalArguments.length != 1")
197+ compare(signalSpy.signalArguments[0][0], data.index)
198+ compare(signalSpy.signalArguments[0][1]["uri"], data.uri)
199+ }
200+
201+ }
202+}

Subscribers

People subscribed via source and target branches