Merge lp:~mzanetti/unity/phablet-test-filtergrids into lp:unity/phablet

Proposed by Michael Zanetti
Status: Merged
Approved by: Albert Astals Cid
Approved revision: no longer in the source branch.
Merged at revision: 609
Proposed branch: lp:~mzanetti/unity/phablet-test-filtergrids
Merge into: lp:unity/phablet
Diff against target: 364 lines (+208/-5)
15 files modified
Components/ResponsiveGridView.qml (+1/-0)
Dash/Apps/ApplicationsFilterGrid.qml (+4/-1)
Dash/DashApps.qml (+7/-1)
Dash/DashHome.qml (+8/-1)
Dash/Music/MusicFilterGrid.qml (+6/-0)
Dash/People/PeopleFilterGrid.qml (+1/-0)
Dash/Video/VideosFilterGrid.qml (+1/-0)
tests/autopilot/qml_phone_shell/emulators/main_window.py (+1/-1)
tests/autopilot/qml_phone_shell/tests/__init__.py (+1/-1)
tests/qmltests/CMakeLists.txt (+1/-0)
tests/qmltests/Dash/tst_FilterGrids.qml (+147/-0)
tests/qmltests/plugins/CMakeLists.txt (+1/-0)
tests/qmltests/plugins/Dee/CMakeLists.txt (+4/-0)
tests/qmltests/plugins/Dee/DeeVariantText.qml (+22/-0)
tests/qmltests/plugins/Dee/qmldir (+3/-0)
To merge this branch: bzr merge lp:~mzanetti/unity/phablet-test-filtergrids
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Andrea Cimitan (community) Approve
Unity Team Pending
Review via email: mp+158941@code.launchpad.net

Commit message

added tests for the various filtergrid subclasses

Description of the change

added tests for the various filtergrid subclasses

To do this, I had to align the API's a bit which I think in the long-run is what we should try to achieve anyways

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
Daniel d'Andrada (dandrader) wrote :

Some lines are very long. It makes it hard to have two code windows side-by-side. By the way, do we have a coding style guide? I would vote for a maximum of around 90 chars.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

217 + name: "VideosFilterGrid"

The test case should have a more general name

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> Some lines are very long. It makes it hard to have two code windows side-by-
> side. By the way, do we have a coding style guide? I would vote for a maximum
> of around 90 chars.

In my opinion if you use a editor that can display only 90 characters it should have an option to do the word wraps for you (At least all the editors I know can do that). In my case, where I work on a 15" screen with mostly fullscreen windows, wrapping everything at 90 characters would cause the left hand side to look clumsy while leaving the right hand side empty.

Its easier for a editor to automatically add word wraps where you need them than to remove them where they are not needed.

QtCreator has this feature in Menu -> Options -> Text Editor -> Display

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> 217 + name: "VideosFilterGrid"
>
> The test case should have a more general name

Fixed. thanks

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

I'm with Michael in the line length issue, my editor setup is able to show 190 columns, why should i be deprived from half on my useful screen? If you want just 90 columns because you prefer having 2 editors side by side there's lots of ways to wrap at that width

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: Needs Fixing (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) 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) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> I'm with Michael in the line length issue, my editor setup is able to show 190
> columns, why should i be deprived from half on my useful screen? If you want
> just 90 columns because you prefer having 2 editors side by side there's lots
> of ways to wrap at that width

Automatically wrapped lines are horrible to read.

Revision history for this message
Andrea Cimitan (cimi) wrote :

> I'm with Michael in the line length issue, my editor setup is able to show 190
> columns, why should i be deprived from half on my useful screen? If you want
> just 90 columns because you prefer having 2 editors side by side there's lots
> of ways to wrap at that width
or you can buy a second monitor :-)

Revision history for this message
Andrea Cimitan (cimi) wrote :

Code seems fine to me, however considering the complexity of the test (we're not testing a single component but mixing them), I'd wait for other reviews...

Only picky thing is removing id: shell from the test qml since it's not used

review: Approve
Revision history for this message
Michael Zanetti (mzanetti) wrote :

> Only picky thing is removing id: shell from the test qml since it's not used

It's used inside the used components... removing it from the test causes a warning to be printed. Actually when you removed some of those lately you introduced a lot of warnings... I did the review and approved... so my fault too.

Revision history for this message
Andrea Cimitan (cimi) wrote :

> > Only picky thing is removing id: shell from the test qml since it's not used
>
> It's used inside the used components... removing it from the test causes a
> warning to be printed. Actually when you removed some of those lately you
> introduced a lot of warnings... I did the review and approved... so my fault
> too.

ops, thanks for clarifying!

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Looks good

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/ResponsiveGridView.qml'
2--- Components/ResponsiveGridView.qml 2013-03-20 09:37:41 +0000
3+++ Components/ResponsiveGridView.qml 2013-04-18 11:37:25 +0000
4@@ -37,6 +37,7 @@
5
6 GridView {
7 id: gridView
8+ objectName: "responsiveGridViewGrid"
9 anchors {
10 fill: parent
11 leftMargin: margin/2
12
13=== modified file 'Dash/Apps/ApplicationsFilterGrid.qml'
14--- Dash/Apps/ApplicationsFilterGrid.qml 2013-04-02 15:29:04 +0000
15+++ Dash/Apps/ApplicationsFilterGrid.qml 2013-04-18 11:37:25 +0000
16@@ -29,7 +29,10 @@
17 delegateHeight: units.gu(9.5)
18 verticalSpacing: units.gu(2)
19
20+ signal clicked(int index, variant data)
21+
22 delegate: Tile {
23+ objectName: "delegate" + index
24 Application {
25 id: application
26 desktopFile: model.column_6 ? stripProtocol(model.column_6) : model.desktopFile // FIXME: this is temporary
27@@ -48,6 +51,6 @@
28 imageWidth: units.gu(8)
29 imageHeight: units.gu(7.5)
30 source: icon.indexOf("/") == -1 ? "image://gicon/" + icon : icon
31- onClicked: shell.activateApplication(application.desktopFile)
32+ onClicked: filterGrid.clicked(index, application.desktopFile);
33 }
34 }
35
36=== modified file 'Dash/DashApps.qml'
37--- Dash/DashApps.qml 2013-04-05 11:42:20 +0000
38+++ Dash/DashApps.qml 2013-04-18 11:37:25 +0000
39@@ -85,7 +85,13 @@
40 a bug where it can position the delegate content to overlap the section header
41 of the ListView - a workaround is to use sourceComponent of Loader instead */
42 Component { id: runningApplicationsGrid; RunningApplicationsGrid {} }
43- Component { id: applicationsFilterGrid; ApplicationsFilterGrid {} }
44+ Component {
45+ id: applicationsFilterGrid;
46+ ApplicationsFilterGrid {
47+ onClicked: shell.activateApplication(data)
48+ }
49+ }
50+
51 property var componentModels: {
52 "RunningApplicationsGrid": runningApplicationsGrid,
53 "ApplicationsFilterGrid": applicationsFilterGrid,
54
55=== modified file 'Dash/DashHome.qml'
56--- Dash/DashHome.qml 2013-03-18 15:21:23 +0000
57+++ Dash/DashHome.qml 2013-04-18 11:37:25 +0000
58@@ -114,7 +114,14 @@
59 When using Loader to load external QML file in the list deelgate, the ListView has
60 a bug where it can position the delegate content to overlap the section header
61 of the ListView - a workaround is to use sourceComponent of Loader instead */
62- Component { id: applicationsFilterGrid; ApplicationsFilterGrid { objectName: "dashHomeApplicationsGrid" } }
63+ Component {
64+ id: applicationsFilterGrid
65+ ApplicationsFilterGrid {
66+ objectName: "dashHomeApplicationsGrid"
67+ onClicked: shell.activateApplication(data);
68+ }
69+ }
70+
71 Component { id: peopleCarousel; PeopleCarousel {} }
72 Component { id: peopleGrid; PeopleFilterGrid {} }
73 Component { id: musicGrid; MusicFilterGrid {} }
74
75=== modified file 'Dash/Music/MusicFilterGrid.qml'
76--- Dash/Music/MusicFilterGrid.qml 2013-02-15 23:08:44 +0000
77+++ Dash/Music/MusicFilterGrid.qml 2013-04-18 11:37:25 +0000
78@@ -30,7 +30,10 @@
79 readonly property int iconWidth: (width / columns) * 0.8
80 readonly property int iconHeight: iconWidth
81
82+ signal clicked(int index)
83+
84 delegate: AlbumTile {
85+ objectName: "delegate" + index
86 width: filterGrid.cellWidth
87 height: filterGrid.cellHeight
88 iconWidth: filterGrid.iconWidth
89@@ -38,5 +41,8 @@
90 artist: model.column_4
91 album: model.column_5
92 source: model.column_1
93+ onClicked: {
94+ filterGrid.clicked(index);
95+ }
96 }
97 }
98
99=== modified file 'Dash/People/PeopleFilterGrid.qml'
100--- Dash/People/PeopleFilterGrid.qml 2013-02-15 12:48:00 +0000
101+++ Dash/People/PeopleFilterGrid.qml 2013-04-18 11:37:25 +0000
102@@ -35,6 +35,7 @@
103 signal clicked(int index, variant data)
104
105 delegate: ListItems.Base {
106+ objectName: "delegate" + index
107 width: filterGrid.cellWidth
108 showDivider: index < Math.floor((filterGrid.model.count-1) / filterGrid.columnCount) * filterGrid.columnCount
109
110
111=== modified file 'Dash/Video/VideosFilterGrid.qml'
112--- Dash/Video/VideosFilterGrid.qml 2013-02-15 23:08:44 +0000
113+++ Dash/Video/VideosFilterGrid.qml 2013-04-18 11:37:25 +0000
114@@ -33,6 +33,7 @@
115 signal clicked(int index)
116
117 delegate: Tile {
118+ objectName: "delegate" + index
119 width: filtergrid.cellWidth
120 height: filtergrid.cellHeight
121 text: model.column_4
122
123=== modified file 'tests/autopilot/qml_phone_shell/emulators/main_window.py'
124--- tests/autopilot/qml_phone_shell/emulators/main_window.py 2013-03-13 19:37:27 +0000
125+++ tests/autopilot/qml_phone_shell/emulators/main_window.py 2013-04-18 11:37:25 +0000
126@@ -40,7 +40,7 @@
127 return self.app.select_single("Dash")
128
129 def get_dash_home_applications_grid(self):
130- return self.app.select_single("FilterGrid", objectName="dashHomeApplicationsGrid")
131+ return self.app.select_single("ApplicationsFilterGrid", objectName="dashHomeApplicationsGrid")
132
133 def get_bottombar(self):
134 return self.app.select_single("Bottombar")
135
136=== modified file 'tests/autopilot/qml_phone_shell/tests/__init__.py'
137--- tests/autopilot/qml_phone_shell/tests/__init__.py 2013-03-13 15:59:48 +0000
138+++ tests/autopilot/qml_phone_shell/tests/__init__.py 2013-04-18 11:37:25 +0000
139@@ -35,7 +35,7 @@
140
141 def launch_test_local(self, geometry):
142 self.app = self.launch_test_application(
143- "../../qml-phone-shell", "-geometry", geometry, "-frameless")
144+ "../../builddir/qml-phone-shell", "-geometry", geometry, "-frameless")
145
146 def launch_test_installed(self, geometry):
147 if self.running_on_device():
148
149=== modified file 'tests/qmltests/CMakeLists.txt'
150--- tests/qmltests/CMakeLists.txt 2013-04-17 10:14:28 +0000
151+++ tests/qmltests/CMakeLists.txt 2013-04-18 11:37:25 +0000
152@@ -37,6 +37,7 @@
153 add_qml_test(Components PageHeader)
154 add_qml_test(Dash DashPreview)
155 add_qml_test(Dash PeoplePreview)
156+add_qml_test(Dash FilterGrids IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
157 add_qml_test(Greeter Greeter)
158 add_qml_test(Hud Hud IMPORT_PATHS ${CMAKE_CURRENT_BINARY_DIR}/plugins)
159 add_qml_test(Launcher Launcher)
160
161=== added file 'tests/qmltests/Dash/tst_FilterGrids.qml'
162--- tests/qmltests/Dash/tst_FilterGrids.qml 1970-01-01 00:00:00 +0000
163+++ tests/qmltests/Dash/tst_FilterGrids.qml 2013-04-18 11:37:25 +0000
164@@ -0,0 +1,147 @@
165+/*
166+ * Copyright 2013 Canonical Ltd.
167+ *
168+ * This program is free software; you can redistribute it and/or modify
169+ * it under the terms of the GNU General Public License as published by
170+ * the Free Software Foundation; version 3.
171+ *
172+ * This program is distributed in the hope that it will be useful,
173+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
174+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
175+ * GNU General Public License for more details.
176+ *
177+ * You should have received a copy of the GNU General Public License
178+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
179+ */
180+
181+import QtQuick 2.0
182+import QtTest 1.0
183+import "../../../Dash/Video"
184+import Ubuntu.Components.ListItems 0.1 as ListItem
185+import Ubuntu.Components 0.1
186+import "../"
187+
188+Rectangle {
189+ id: shell
190+ width: gridRect.width + controls.width
191+ height: units.gu(50)
192+ color: "white"
193+
194+ Column {
195+ id: controls
196+ width: units.gu(30)
197+ height: parent.height
198+ anchors.top: parent.top
199+ anchors.right: parent.right
200+ spacing: units.gu(1)
201+ Label {
202+ id: spyLabel
203+ color: "blue"
204+ text: "Clicked item: [none]"
205+ anchors {left: parent.left; right: parent.right; margins: units.gu(1) }
206+ }
207+ Repeater {
208+ model: testCase.test_clicked_signal_data()
209+ Button {
210+ anchors {left: parent.left; right: parent.right; margins: units.gu(1) }
211+ text: testCase.test_clicked_signal_data()[index].tag
212+ onClicked: gridLoader.source = "../../../Dash/" + testCase.test_clicked_signal_data()[index].component
213+ }
214+ }
215+ }
216+
217+ ListModel {
218+ id: fakeModel
219+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item0"; column_5: ""; column_6: "dummy.desktop" }
220+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item1"; column_5: ""; column_6: "dummy.desktop" }
221+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item2"; column_5: ""; column_6: "dummy.desktop" }
222+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item3"; column_5: ""; column_6: "dummy.desktop" }
223+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item4"; column_5: ""; column_6: "dummy.desktop" }
224+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item5"; column_5: ""; column_6: "dummy.desktop" }
225+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item6"; column_5: ""; column_6: "dummy.desktop" }
226+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item7"; column_5: ""; column_6: "dummy.desktop" }
227+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item8"; column_5: ""; column_6: "dummy.desktop" }
228+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item9"; column_5: ""; column_6: "dummy.desktop" }
229+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item10"; column_5: ""; column_6: "dummy.desktop" }
230+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item11"; column_5: ""; column_6: "dummy.desktop" }
231+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item12"; column_5: ""; column_6: "dummy.desktop" }
232+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item13"; column_5: ""; column_6: "dummy.desktop" }
233+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item14"; column_5: ""; column_6: "dummy.desktop" }
234+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item15"; column_5: ""; column_6: "dummy.desktop" }
235+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item16"; column_5: ""; column_6: "dummy.desktop" }
236+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item17"; column_5: ""; column_6: "dummy.desktop" }
237+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item18"; column_5: ""; column_6: "dummy.desktop" }
238+ ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item19"; column_5: ""; column_6: "dummy.desktop" }
239+ }
240+
241+ Rectangle {
242+ id: gridRect
243+ width: units.gu(50)
244+ height: parent.height
245+ color: "grey"
246+ anchors.top: parent.top
247+ anchors.left: parent.left
248+
249+ Loader {
250+ id: gridLoader
251+ anchors.fill: parent
252+
253+ onProgressChanged: {
254+ if (progress == 1) {
255+ item.model = fakeModel
256+ }
257+ }
258+ }
259+
260+ Connections {
261+ target: gridLoader.item
262+ onClicked: spyLabel.text = "Clicked index: " + index
263+ }
264+ }
265+
266+ UnityTestCase {
267+ id: testCase
268+ name: "FilterGrids"
269+ when: windowShown
270+
271+ function test_clicked_signal_data() {
272+ return [
273+ {tag: "VideosFilterGrid", component: "Video/VideosFilterGrid.qml"},
274+ {tag: "PeopleFilterGrid", component: "People/PeopleFilterGrid.qml"},
275+ {tag: "MusicFilterGrid", component: "Music/MusicFilterGrid.qml"},
276+ {tag: "ApplicationsFilterGrid", component: "Apps/ApplicationsFilterGrid.qml"}
277+ ]
278+ }
279+
280+ function test_clicked_signal(data) {
281+ gridLoader.source = "";
282+ gridLoader.source = "../../../Dash/" + data.component;
283+
284+ // Wait until the FilterGrid is loaded by the loader
285+ tryCompare(gridLoader, "status", Loader.Ready, "Loader couldn't load " + data.component);
286+
287+ // Wait until the GridView inside the model has the according amout of items set
288+ var gridView = findChild(gridLoader, "responsiveGridViewGrid");
289+ var itemCount = gridLoader.item.filter ? gridLoader.item.collapsedRowCount * gridLoader.item.columns : fakeModel.count;
290+ tryCompare(gridView, "count", itemCount)
291+
292+ // Wait until the expandinganimation is finished
293+ tryCompare(gridLoader.item.__expansionAnimation, "running", false)
294+
295+ // Click item 1
296+ var tile1 = findChild(gridLoader.item, "delegate1");
297+ clickedSpy.clear()
298+ mouseClick(tile1, tile1.width/2, tile1.height/2);
299+
300+ // Check emission of clicked() signal with the according index as argument
301+ compare(clickedSpy.signalArguments[0][0], 1, "Clicked index is not the same as the one actually clicked")
302+ }
303+ }
304+
305+ SignalSpy {
306+ id: clickedSpy
307+ signalName: "clicked"
308+ target: gridLoader.item
309+ }
310+}
311+
312
313=== modified file 'tests/qmltests/plugins/CMakeLists.txt'
314--- tests/qmltests/plugins/CMakeLists.txt 2013-04-16 14:22:23 +0000
315+++ tests/qmltests/plugins/CMakeLists.txt 2013-04-18 11:37:25 +0000
316@@ -1,2 +1,3 @@
317 add_subdirectory(HudClient)
318 add_subdirectory(Ubuntu)
319+add_subdirectory(Dee)
320
321=== added directory 'tests/qmltests/plugins/Dee'
322=== added file 'tests/qmltests/plugins/Dee/CMakeLists.txt'
323--- tests/qmltests/plugins/Dee/CMakeLists.txt 1970-01-01 00:00:00 +0000
324+++ tests/qmltests/plugins/Dee/CMakeLists.txt 2013-04-18 11:37:25 +0000
325@@ -0,0 +1,4 @@
326+# copy qmldir file into build directory for shadow builds
327+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/qmldir"
328+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
329+ )
330
331=== added file 'tests/qmltests/plugins/Dee/DeeVariantText.qml'
332--- tests/qmltests/plugins/Dee/DeeVariantText.qml 1970-01-01 00:00:00 +0000
333+++ tests/qmltests/plugins/Dee/DeeVariantText.qml 2013-04-18 11:37:25 +0000
334@@ -0,0 +1,22 @@
335+/*
336+ * Copyright (C) 2013 Canonical, Ltd.
337+ *
338+ * This program is free software; you can redistribute it and/or modify
339+ * it under the terms of the GNU General Public License as published by
340+ * the Free Software Foundation; version 3.
341+ *
342+ * This program is distributed in the hope that it will be useful,
343+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
344+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
345+ * GNU General Public License for more details.
346+ *
347+ * You should have received a copy of the GNU General Public License
348+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
349+ */
350+
351+import QtQuick 2.0
352+
353+Item {
354+ property variant value
355+ property string text
356+}
357
358=== added file 'tests/qmltests/plugins/Dee/qmldir'
359--- tests/qmltests/plugins/Dee/qmldir 1970-01-01 00:00:00 +0000
360+++ tests/qmltests/plugins/Dee/qmldir 2013-04-18 11:37:25 +0000
361@@ -0,0 +1,3 @@
362+module Dee
363+
364+DeeVariantText 3.0 DeeVariantText.qml

Subscribers

People subscribed via source and target branches