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

Subscribers

People subscribed via source and target branches