Merge lp:~unity-team/unity/phablet.test_responsiveflowview into lp:unity/phablet

Proposed by Andrea Cimitan
Status: Merged
Approved by: Andrea Cimitan
Approved revision: no longer in the source branch.
Merged at revision: 563
Proposed branch: lp:~unity-team/unity/phablet.test_responsiveflowview
Merge into: lp:unity/phablet
Prerequisite: lp:~unity-team/unity/phablet.tests_coding-style
Diff against target: 219 lines (+194/-0)
3 files modified
Components/ResponsiveFlowView.qml (+2/-0)
tests/qmluitests/Components/CMakeLists.txt (+1/-0)
tests/qmluitests/Components/tst_ResponsiveFlowView.qml (+191/-0)
To merge this branch: bzr merge lp:~unity-team/unity/phablet.test_responsiveflowview
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Albert Astals Cid (community) Approve
Review via email: mp+157901@code.launchpad.net

This proposal supersedes a proposal from 2013-04-09.

Commit message

Add tests for ResponsiveFlowView

Description of the change

Adds tests for ResponsiveFlowView, adapting from ResponsiveGridView

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

Change ResponsiveGridView -> Change ResponsiveFlowView

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

Looks good to me, let's wait for CI before merging

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Makes sense

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

FAILED: Autolanding.
No commit message was specified in the merge proposal. Hit 'Add commit message' on the merge proposal web page or follow the link below. You can approve the merge proposal yourself to rerun.
https://code.launchpad.net/~unity-team/unity/phablet.test_responsiveflowview/+merge/157901/+edit-commit-message

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
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
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/ResponsiveFlowView.qml'
2--- Components/ResponsiveFlowView.qml 2013-04-09 12:30:58 +0000
3+++ Components/ResponsiveFlowView.qml 2013-04-09 15:54:23 +0000
4@@ -30,6 +30,8 @@
5 property alias firstModel: repeater1.model
6 property alias secondModel: repeater2.model
7 property alias delegate: repeater1.delegate
8+ readonly property int cellWidth: referenceDelegateWidth + horizontalSpacing
9+ readonly property int cellHeight: referenceDelegateWidth + verticalSpacing
10
11 height: flow.height + flow.anchors.topMargin
12
13
14=== modified file 'tests/qmluitests/Components/CMakeLists.txt'
15--- tests/qmluitests/Components/CMakeLists.txt 2013-04-08 17:08:40 +0000
16+++ tests/qmluitests/Components/CMakeLists.txt 2013-04-09 15:54:23 +0000
17@@ -1,5 +1,6 @@
18 add_qml_test(DraggingArea)
19 add_qml_test(FilterGrid IMPORT_PATH ${CMAKE_BINARY_DIR}/plugins)
20+add_qml_test(ResponsiveFlowView)
21 add_qml_test(ResponsiveGridView)
22 add_qml_test(Revealer)
23 add_qml_test(Showable)
24
25=== added file 'tests/qmluitests/Components/tst_ResponsiveFlowView.qml'
26--- tests/qmluitests/Components/tst_ResponsiveFlowView.qml 1970-01-01 00:00:00 +0000
27+++ tests/qmluitests/Components/tst_ResponsiveFlowView.qml 2013-04-09 15:54:23 +0000
28@@ -0,0 +1,191 @@
29+/*
30+ * Copyright 2013 Canonical Ltd.
31+ *
32+ * This program is free software; you can redistribute it and/or modify
33+ * it under the terms of the GNU General Public License as published by
34+ * the Free Software Foundation; version 3.
35+ *
36+ * This program is distributed in the hope that it will be useful,
37+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
38+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39+ * GNU General Public License for more details.
40+ *
41+ * You should have received a copy of the GNU General Public License
42+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
43+ */
44+
45+import QtQuick 2.0
46+import QtTest 1.0
47+import ".."
48+import "../../../Components"
49+import Ubuntu.Components.ListItems 0.1 as ListItem
50+import Ubuntu.Components 0.1
51+
52+Item {
53+ width: flowRect.width + controls.width
54+ height: units.gu(80)
55+
56+ Column {
57+ id: controls
58+ width: units.gu(40)
59+ height: parent.height
60+ anchors.top: parent.top
61+ anchors.right: parent.right
62+ ListItem.ValueSelector {
63+ id: maxColumnsSelector
64+ text: "maximumNumberOfColumns"
65+ values: [2,4,8,13,1000]
66+ selectedIndex: 1
67+ }
68+ ListItem.ValueSelector {
69+ id: minHSpacingSelector
70+ text: "minHorizontalSpacing"
71+ values: [0,units.gu(2),units.gu(8),units.gu(25)]
72+ selectedIndex: 0
73+ }
74+ }
75+
76+ ListModel {
77+ id: fakeModel
78+ ListElement { name: "A" }
79+ ListElement { name: "B" }
80+ ListElement { name: "C" }
81+ ListElement { name: "D" }
82+ ListElement { name: "E" }
83+ ListElement { name: "F" }
84+ ListElement { name: "G" }
85+ ListElement { name: "H" }
86+ ListElement { name: "I" }
87+ ListElement { name: "J" }
88+ ListElement { name: "K" }
89+ ListElement { name: "L" }
90+ ListElement { name: "M" }
91+ ListElement { name: "N" }
92+ ListElement { name: "O" }
93+ ListElement { name: "P" }
94+ ListElement { name: "Q" }
95+ ListElement { name: "R" }
96+ ListElement { name: "S" }
97+ ListElement { name: "T" }
98+ ListElement { name: "U" }
99+ }
100+
101+ Rectangle {
102+ id: flowRect
103+ width: units.gu(80)
104+ height: parent.height
105+ color: "grey"
106+ anchors.top: parent.top
107+ anchors.left: parent.left
108+
109+ ResponsiveFlowView {
110+ id: flow
111+ anchors.fill: parent
112+ firstModel: fakeModel
113+ secondModel: fakeModel
114+ minimumHorizontalSpacing:
115+ minHSpacingSelector.values[minHSpacingSelector.selectedIndex]
116+ verticalSpacing: units.gu(2)
117+ maximumNumberOfColumns:
118+ maxColumnsSelector.values[maxColumnsSelector.selectedIndex]
119+ referenceDelegateWidth: units.gu(6)
120+
121+ delegate: Rectangle {
122+ // So that it can be identified by test code
123+ property bool isFlowDelegate: true
124+ color: "grey"
125+ border.color: "red"
126+ border.width: 1
127+
128+ // IMPORTANT: always use flow's cellWidth and cellHeight here to get
129+ // ResponsiveFlowView's intended result
130+ width: flow.cellWidth
131+ height: flow.cellHeight
132+
133+ Rectangle {
134+ color: "green"
135+ anchors.centerIn: parent
136+ width: units.gu(6)
137+ height: units.gu(6)
138+ Text {
139+ anchors.centerIn: parent
140+ text: name
141+ }
142+ }
143+
144+ Text { x:0; y:0; text:"(" + parent.x + ", " + parent.y + ")"}
145+ }
146+ }
147+ }
148+
149+ UnityTestCase {
150+ name: "ResponsiveFlowView"
151+ when: windowShown
152+
153+ function test_maximumNumberOfColumns_data() {
154+ var data = new Array()
155+
156+ data.push({selectedIndex: 0, maxColumnCount:2, columnCount: 2})
157+ data.push({selectedIndex: 1, maxColumnCount:4, columnCount: 4})
158+ data.push({selectedIndex: 2, maxColumnCount:8, columnCount: 8})
159+ data.push({selectedIndex: 4, maxColumnCount:1000, columnCount: 13})
160+
161+ return data
162+ }
163+
164+ /* Change ResponsiveFlowView's maximumNumberOfColumns property and check
165+ that the resulting number of columns matches expectations */
166+ function test_maximumNumberOfColumns(data) {
167+ minHSpacingSelector.selectedIndex = 0
168+
169+ // sanity checks
170+ compare(maxColumnsSelector.values[data.selectedIndex], data.maxColumnCount)
171+ compare(minHSpacingSelector.values[0], 0)
172+
173+ maxColumnsSelector.selectedIndex = data.selectedIndex
174+ tryCompareFunction(countFlowDelegatesOnFirstRow, data.columnCount);
175+ compare(flow.columns, data.columnCount)
176+ }
177+
178+ function test_minimumHorizontalSpacing_data() {
179+ var data = new Array()
180+
181+ data.push({selectedIndex: 0, minHSpacing:0, columnCount: 13})
182+ data.push({selectedIndex: 1, minHSpacing:units.gu(2), columnCount: 9})
183+ data.push({selectedIndex: 2, minHSpacing:units.gu(8), columnCount: 5})
184+ data.push({selectedIndex: 3, minHSpacing:units.gu(25), columnCount: 2})
185+
186+ return data
187+ }
188+
189+ /* Change ResponsiveFlowView's minimumHorizontalSpacing property and check
190+ that the resulting number of columns matches expectations */
191+ function test_minimumHorizontalSpacing(data) {
192+ maxColumnsSelector.selectedIndex = 4
193+
194+ // sanity checks
195+ compare(maxColumnsSelector.values[4], 1000)
196+ compare(minHSpacingSelector.values[data.selectedIndex], data.minHSpacing)
197+
198+ minHSpacingSelector.selectedIndex = data.selectedIndex
199+ tryCompareFunction(countFlowDelegatesOnFirstRow, data.columnCount);
200+ compare(flow.columns, data.columnCount)
201+ }
202+
203+ function countFlowDelegatesOnFirstRow() {
204+ return __countFlowDelegatesOnFirstRow(flow.visibleChildren, 0)
205+ }
206+
207+ function __countFlowDelegatesOnFirstRow(objList, total) {
208+ for (var i = 0; i < objList.length; ++i) {
209+ var child = objList[i];
210+ if (child.isFlowDelegate !== undefined && child.y === 0) {
211+ ++total;
212+ } else {
213+ total = __countFlowDelegatesOnFirstRow(child.visibleChildren, total)
214+ }
215+ }
216+ return total
217+ }
218+ }
219+}

Subscribers

People subscribed via source and target branches

to all changes: