Merge lp:~aacid/unity8/dashviews_integration into lp:unity8

Proposed by Albert Astals Cid
Status: Merged
Approved by: Michał Sawicz
Approved revision: 960
Merged at revision: 979
Proposed branch: lp:~aacid/unity8/dashviews_integration
Merge into: lp:unity8
Prerequisite: lp:~aacid/unity8/makeTryVJHJOGwork
Diff against target: 612 lines (+374/-26)
14 files modified
plugins/Dash/CardCreator.js (+8/-6)
qml/Components/ResponsiveVerticalJournal.qml (+74/-0)
qml/Dash/CardCarousel.qml (+0/-2)
qml/Dash/CardFilterGrid.qml (+1/-4)
qml/Dash/CardVerticalJournal.qml (+89/-0)
qml/Dash/DashRenderer.qml (+0/-7)
qml/Dash/GenericScopeView.qml (+10/-1)
tests/plugins/Dash/cardcreator/1.res (+1/-1)
tests/plugins/Dash/cardcreator/2.res (+2/-1)
tests/plugins/Dash/cardcreator/3.res (+1/-1)
tests/plugins/Dash/cardcreator/4.res (+2/-1)
tests/plugins/Dash/cardcreator/5.res (+2/-2)
tests/qmltests/CMakeLists.txt (+1/-0)
tests/qmltests/Components/tst_ResponsiveVerticalJournal.qml (+183/-0)
To merge this branch: bzr merge lp:~aacid/unity8/dashviews_integration
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Michał Sawicz Approve
Review via email: mp+222192@code.launchpad.net

Commit message

Add VerticalJournal integration to Dash/scopes/QML

Description of the change

* Are there any related MPs required for this MP to build/function as expected?
No

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes, used unity-scope-tool on a scope modified to use VerticalJournal

* Did you make sure that your branch does not contain spurious tags?
Yes

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

* If you changed the UI, has there been a design review?
N/A

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: 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
Michał Sawicz (saviq) wrote :

TryVerticalJournal doesn't resize the journal, would be nice to see how it behaves.

Also see inline.

review: Needs Fixing
Revision history for this message
Michał Sawicz (saviq) wrote :

I took a scope (lp:~vtuson/+junk/rsslocal) and made it use vertical-journal (http://paste.ubuntu.com/7658904/), ran with the scope tool (./builddir/tools/unity-scope-tool /tmp/rsslocal/src/ELPAIS-scope.ini) and after expanding + overshooting and scrolling back, the view breaks...

We might be overloading the delegate margins maybe?

review: Needs Fixing
951. By Albert Astals Cid

Small fixes:

 Make the comment be doc
 Make tryResponsiveVerticalJournal actually change width with window width changes

952. By Albert Astals Cid

Make this a real

953. By Albert Astals Cid

Typo + year fix

954. By Albert Astals Cid

Unwrap lines, make _data functions simpler

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

> TryVerticalJournal doesn't resize the journal, would be nice to see how it behaves.
Done

> Please apply http://paste.ubuntu.com/7658540/ to make it into a doc.
Done

> Shouldn't this be real?
Done

> Should this be "responsive"?
It's what we have in the responsiveGridView too, i agree it can be a bit confusing, can change it in both if you want

> Wonder if clip: true would be good enough here? Clipping should be smart enough to know when not to clip?
I think clip is not smart at all, that's why is disabled by default, turning it on will cause a speed decrease even if you only paint inside your own area

> Commented out?
No, it's the formula Karni added to help understand the code below, can remove it if it makes you get confused

> 2014
Done

> s/it's/its/
Done

> Is the comment still valid?
I'd say no

> Why wrapped? Same above?
Karni is probably using a narrow terminal :D Unwrapped

> Any reason why not 'return [...];'?
Karni did that and i did not pay much attention ;/ I've changed it now to return []

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)
955. By Albert Astals Cid

Merge lp:unity8

956. By Albert Astals Cid

Make the rowHeight be the headerHeight if we have it

Shuffle a bit the margins in headerHeight/fixedHeaderHeight

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

Saviq: I think i fixed all the issues you mentioned. Can you check & re-review?

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: Approve (continuous-integration)
957. By Albert Astals Cid

Merge upstream

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

I applied http://paste.ubuntu.com/7673731/ to test, and in tryDash I noticed that height of CardVJ animates on delegate creation and "forgets" which category was expanded.

review: Needs Fixing
958. By Albert Astals Cid

Seems doxygen needs 4 spaces in front to be told not to join lines

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

Only animate height when told to

960. By Albert Astals Cid

Account for special behaviour of VJ expandable attribute not being set on load but after

Revision history for this message
Michał Sawicz (saviq) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes.

 * Did CI run pass? If not, please explain why.
No, Qt 5.3 is causing failures. It's being worked on.

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

Missed one space

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Dash/CardCreator.js'
2--- plugins/Dash/CardCreator.js 2014-05-19 15:53:16 +0000
3+++ plugins/Dash/CardCreator.js 2014-06-20 10:32:22 +0000
4@@ -108,7 +108,7 @@
5 visible: showHeader && status == Loader.Ready; \n\
6 sourceComponent: ShaderEffect { \n\
7 id: overlay; \n\
8- height: fixedHeaderHeight != -1 ? fixedHeaderHeight : headerHeight; \n\
9+ height: fixedHeaderHeight != -1 ? fixedHeaderHeight + units.gu(1) * 2 : headerHeight; \n\
10 opacity: 0.6; \n\
11 property var source: ShaderEffectSource { \n\
12 id: shaderSource; \n\
13@@ -145,6 +145,7 @@
14 objectName: "outerRow"; \n\
15 property real margins: units.gu(1); \n\
16 spacing: margins; \n\
17+ height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
18 anchors { %1 } \n\
19 anchors.right: parent.right; \n\
20 anchors.margins: margins;\n\
21@@ -163,6 +164,7 @@
22 objectName: "outerRow"; \n\
23 property real margins: units.gu(1); \n\
24 spacing: margins; \n\
25+ height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight; \n\
26 anchors { %1 } \n\
27 anchors.right: parent.right; \n\
28 anchors.margins: margins;\n\
29@@ -315,7 +317,7 @@
30 anchors = 'left: parent.left';
31 if (hasMascot || hasTitle) {
32 widthCode = 'height * artShape.aspect'
33- heightCode = 'headerHeight';
34+ heightCode = 'headerHeight + 2 * units.gu(1)';
35 } else {
36 // This side of the else is a bit silly, who wants an horizontal layout without mascot and title?
37 // So we define a "random" height of the image height + 2 gu for the margins
38@@ -366,13 +368,13 @@
39 }
40
41 if (hasHeaderRow) {
42- code += 'readonly property int headerHeight: row.height + row.margins * 2;\n'
43+ code += 'readonly property int headerHeight: row.height;\n'
44 } else if (hasMascot) {
45- code += 'readonly property int headerHeight: mascotImage.height + units.gu(1) * 2;\n'
46+ code += 'readonly property int headerHeight: mascotImage.height;\n'
47 } else if (hasSubtitle) {
48- code += 'readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin * 2 + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
49+ code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
50 } else if (hasTitle) {
51- code += 'readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin * 2;\n'
52+ code += 'readonly property int headerHeight: titleLabel.height;\n'
53 } else {
54 code += 'readonly property int headerHeight: 0;\n'
55 }
56
57=== added file 'qml/Components/ResponsiveVerticalJournal.qml'
58--- qml/Components/ResponsiveVerticalJournal.qml 1970-01-01 00:00:00 +0000
59+++ qml/Components/ResponsiveVerticalJournal.qml 2014-06-20 10:32:22 +0000
60@@ -0,0 +1,74 @@
61+/*
62+ * Copyright (C) 2013-2014 Canonical, Ltd.
63+ *
64+ * This program is free software; you can redistribute it and/or modify
65+ * it under the terms of the GNU General Public License as published by
66+ * the Free Software Foundation; version 3.
67+ *
68+ * This program is distributed in the hope that it will be useful,
69+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
70+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
71+ * GNU General Public License for more details.
72+ *
73+ * You should have received a copy of the GNU General Public License
74+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
75+ */
76+
77+import QtQuick 2.0
78+import Ubuntu.Components 0.1
79+import "../Components"
80+import Dash 0.1
81+
82+/*!
83+ \brief A responsive wrapper around VerticalJournal.
84+
85+ Based on defined column width, delegates are laid out in columns following
86+ a top-left most position rule.
87+
88+ Example:
89+ +-----+ +-----+ +-----+
90+ | | | 2 | | |
91+ | | | | | |
92+ | 1 | +-----+ | 3 |
93+ | | +-----+ | |
94+ | | | | +-----+
95+ +-----+ | 4 | +-----+
96+ +-----+ | | | 5 |
97+ | 6 | +-----+ | |
98+ | | +-----+
99+ +-----+
100+*/
101+Item {
102+ property real minimumColumnSpacing: units.gu(1)
103+
104+ property alias columnWidth: verticalJournalView.columnWidth
105+ property alias rowSpacing: verticalJournalView.rowSpacing
106+ property alias model: verticalJournalView.model
107+ property alias delegate: verticalJournalView.delegate
108+ property alias displayMarginBeginning: verticalJournalView.displayMarginBeginning
109+ property alias displayMarginEnd: verticalJournalView.displayMarginEnd
110+ implicitHeight: verticalJournalView.implicitHeight
111+
112+ VerticalJournal {
113+ id: verticalJournalView
114+ objectName: "responsiveVerticalJournalView"
115+ anchors {
116+ fill: parent
117+ leftMargin: columnSpacing / 2
118+ rightMargin: columnSpacing / 2
119+ topMargin: rowSpacing / 2
120+ bottomMargin: rowSpacing / 2
121+ }
122+ clip: parent.height != implicitHeight
123+
124+ function px2gu(pixels) {
125+ return Math.floor(pixels / units.gu(1))
126+ }
127+
128+ columnSpacing: {
129+ // parent.width = columns * columnWidth + (columns-1) * spacing + spacing(margins)
130+ var expectedColumns = Math.max(1, Math.floor(parent.width / (columnWidth + minimumColumnSpacing)));
131+ Math.floor((parent.width - expectedColumns * columnWidth) / expectedColumns);
132+ }
133+ }
134+}
135
136=== modified file 'qml/Dash/CardCarousel.qml'
137--- qml/Dash/CardCarousel.qml 2014-05-27 07:46:14 +0000
138+++ qml/Dash/CardCarousel.qml 2014-06-20 10:32:22 +0000
139@@ -27,9 +27,7 @@
140 property alias selectedItemScaleFactor: carousel.selectedItemScaleFactor
141 property alias tileAspectRatio: carousel.tileAspectRatio
142
143- currentItem: carousel.currentItem
144 height: carousel.implicitHeight + units.gu(6)
145- verticalSpacing: units.gu(3)
146
147 Carousel {
148 id: carousel
149
150=== modified file 'qml/Dash/CardFilterGrid.qml'
151--- qml/Dash/CardFilterGrid.qml 2014-05-23 13:52:36 +0000
152+++ qml/Dash/CardFilterGrid.qml 2014-06-20 10:32:22 +0000
153@@ -22,11 +22,8 @@
154
155 expandable: filterGrid.expandable
156 collapsedHeight: filterGrid.collapsedHeight
157- margins: filterGrid.margins
158 uncollapsedHeight: filterGrid.uncollapsedHeight
159 originY: filterGrid.originY
160- verticalSpacing: units.gu(1)
161- currentItem: filterGrid.currentItem
162 height: filterGrid.height
163 filtered: filterGrid.filtered
164
165@@ -40,7 +37,7 @@
166 minimumHorizontalSpacing: units.gu(1)
167 delegateWidth: cardTool.cardWidth
168 delegateHeight: cardTool.cardHeight
169- verticalSpacing: genericFilterGrid.verticalSpacing
170+ verticalSpacing: units.gu(1)
171 model: genericFilterGrid.model
172 collapsedRowCount: Math.min(2, cardTool && cardTool.template && cardTool.template["collapsed-rows"] || 2)
173 displayMarginBeginning: genericFilterGrid.displayMarginBeginning
174
175=== added file 'qml/Dash/CardVerticalJournal.qml'
176--- qml/Dash/CardVerticalJournal.qml 1970-01-01 00:00:00 +0000
177+++ qml/Dash/CardVerticalJournal.qml 2014-06-20 10:32:22 +0000
178@@ -0,0 +1,89 @@
179+/*
180+ * Copyright (C) 2014 Canonical, Ltd.
181+ *
182+ * This program is free software; you can redistribute it and/or modify
183+ * it under the terms of the GNU General Public License as published by
184+ * the Free Software Foundation; version 3.
185+ *
186+ * This program is distributed in the hope that it will be useful,
187+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
188+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
189+ * GNU General Public License for more details.
190+ *
191+ * You should have received a copy of the GNU General Public License
192+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
193+ */
194+
195+import QtQuick 2.0
196+import Ubuntu.Components 0.1
197+import "../Components"
198+
199+DashRenderer {
200+ id: root
201+
202+ readonly property double collapseLimit: units.gu(35)
203+
204+ uncollapsedHeight: cardVerticalJournal.implicitHeight
205+ collapsedHeight: Math.min(collapseLimit, cardVerticalJournal.implicitHeight)
206+ expandable: uncollapsedHeight > collapseLimit
207+
208+ // This minHeight is used as bootstrapper for the height. Vertical Journal
209+ // is special by the fact that it doesn't know how to calculate its implicit height unless we give it
210+ // enough height that it can start creating its children so we make sure it has enough height for that
211+ // in case the model is non empty
212+ readonly property double minHeight: root.model.count > 1 ? cardVerticalJournal.rowSpacing + 1 : 0
213+ height: filtered ? Math.max(collapsedHeight, minHeight) : uncollapsedHeight
214+
215+ Behavior on height {
216+ id: heightBehaviour
217+ enabled: false
218+ animation: UbuntuNumberAnimation {
219+ onRunningChanged: {
220+ if (!running) {
221+ heightBehaviour.enabled = false
222+ }
223+ }
224+ }
225+ }
226+
227+ function setFilter(filter, animate) {
228+ heightBehaviour.enabled = animate;
229+ filtered = filter;
230+ }
231+
232+ ResponsiveVerticalJournal {
233+ id: cardVerticalJournal
234+
235+ model: root.model
236+
237+ anchors.fill: parent
238+ rowSpacing: minimumColumnSpacing
239+ columnWidth: cardTool.cardWidth
240+
241+ displayMarginBeginning: root.displayMarginBeginning
242+ displayMarginEnd: root.displayMarginEnd
243+
244+ delegate: Loader {
245+ id: loader
246+ sourceComponent: cardTool.cardComponent
247+ width: cardTool.cardWidth
248+ anchors.horizontalCenter: parent.horizontalCenter
249+ onLoaded: {
250+ item.objectName = "delegate" + index;
251+ item.width = Qt.binding(function() { return cardTool.cardWidth; });
252+ item.height = Qt.binding(function() { return cardTool.cardHeight; });
253+ item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
254+ item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; });
255+ item.cardData = Qt.binding(function() { return model; });
256+ item.template = Qt.binding(function() { return cardTool.template; });
257+ item.components = Qt.binding(function() { return cardTool.components; });
258+ item.headerAlignment = Qt.binding(function() { return cardTool.headerAlignment; });
259+ }
260+ Connections {
261+ target: loader.item
262+ onClicked: root.clicked(index, result)
263+ onPressAndHold: root.pressAndHold(index)
264+ }
265+ }
266+ }
267+}
268
269=== modified file 'qml/Dash/DashRenderer.qml'
270--- qml/Dash/DashRenderer.qml 2014-05-23 13:52:36 +0000
271+++ qml/Dash/DashRenderer.qml 2014-06-20 10:32:22 +0000
272@@ -25,8 +25,6 @@
273
274 property int collapsedHeight: height
275
276- property int margins: 0
277-
278 property int uncollapsedHeight: height
279
280 property int displayMarginBeginning: 0
281@@ -35,11 +33,6 @@
282
283 property real originY: 0
284
285- property real verticalSpacing: 0
286-
287- // The current item of the renderer
288- property var currentItem
289-
290 // The model to renderer
291 property var model
292
293
294=== modified file 'qml/Dash/GenericScopeView.qml'
295--- qml/Dash/GenericScopeView.qml 2014-06-11 09:42:10 +0000
296+++ qml/Dash/GenericScopeView.qml 2014-06-20 10:32:22 +0000
297@@ -1,5 +1,5 @@
298 /*
299- * Copyright (C) 2013 Canonical, Ltd.
300+ * Copyright (C) 2013-2014 Canonical, Ltd.
301 *
302 * This program is free software; you can redistribute it and/or modify
303 * it under the terms of the GNU General Public License as published by
304@@ -147,6 +147,7 @@
305 source: {
306 switch (cardTool.categoryLayout) {
307 case "carousel": return "CardCarousel.qml";
308+ case "vertical-journal": return "CardVerticalJournal.qml";
309 case "running-apps": return "Apps/RunningApplicationsGrid.qml";
310 case "grid":
311 default: return "CardFilterGrid.qml";
312@@ -202,6 +203,14 @@
313 previewListView.currentIndex = index;
314 previewListView.open = true
315 }
316+ onExpandableChanged: {
317+ // This can happen with the VJ that doesn't know how height it will be on creation
318+ // so doesn't set expandable until a bit too late for onLoaded
319+ if (rendererLoader.item.expandable) {
320+ var shouldFilter = baseItem.category != categoryView.expandedCategoryId;
321+ rendererLoader.item.setFilter(shouldFilter, false /*animate*/);
322+ }
323+ }
324 }
325 Connections {
326 target: categoryView
327
328=== modified file 'tests/plugins/Dash/cardcreator/1.res'
329--- tests/plugins/Dash/cardcreator/1.res 2014-05-19 15:53:16 +0000
330+++ tests/plugins/Dash/cardcreator/1.res 2014-06-20 10:32:22 +0000
331@@ -56,7 +56,7 @@
332 }
333 }
334 }
335-readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin * 2;
336+readonly property int headerHeight: titleLabel.height;
337 Label {
338 id: titleLabel;
339 objectName: "titleLabel";
340
341=== modified file 'tests/plugins/Dash/cardcreator/2.res'
342--- tests/plugins/Dash/cardcreator/2.res 2014-05-19 15:53:16 +0000
343+++ tests/plugins/Dash/cardcreator/2.res 2014-06-20 10:32:22 +0000
344@@ -46,12 +46,13 @@
345 }
346 }
347 readonly property size artShapeSize: Qt.size(-1, -1);
348-readonly property int headerHeight: row.height + row.margins * 2;
349+readonly property int headerHeight: row.height;
350 Row {
351 id: row;
352 objectName: "outerRow";
353 property real margins: units.gu(1);
354 spacing: margins;
355+ height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
356 anchors { top: parent.top;
357 topMargin: units.gu(1);
358 left: parent.left;
359
360=== modified file 'tests/plugins/Dash/cardcreator/3.res'
361--- tests/plugins/Dash/cardcreator/3.res 2014-05-19 15:53:16 +0000
362+++ tests/plugins/Dash/cardcreator/3.res 2014-06-20 10:32:22 +0000
363@@ -56,7 +56,7 @@
364 }
365 }
366 }
367-readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin * 2 + subtitleLabel.height + subtitleLabel.anchors.topMargin;
368+readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;
369 Label {
370 id: titleLabel;
371 objectName: "titleLabel";
372
373=== modified file 'tests/plugins/Dash/cardcreator/4.res'
374--- tests/plugins/Dash/cardcreator/4.res 2014-05-19 15:53:16 +0000
375+++ tests/plugins/Dash/cardcreator/4.res 2014-06-20 10:32:22 +0000
376@@ -13,12 +13,13 @@
377 property bool showHeader: true;
378 implicitWidth: childrenRect.width;
379 readonly property size artShapeSize: Qt.size(-1, -1);
380-readonly property int headerHeight: row.height + row.margins * 2;
381+readonly property int headerHeight: row.height;
382 Row {
383 id: row;
384 objectName: "outerRow";
385 property real margins: units.gu(1);
386 spacing: margins;
387+ height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
388 anchors { top: parent.top;
389 topMargin: units.gu(1);
390 left: parent.left;
391
392=== modified file 'tests/plugins/Dash/cardcreator/5.res'
393--- tests/plugins/Dash/cardcreator/5.res 2014-05-19 15:53:16 +0000
394+++ tests/plugins/Dash/cardcreator/5.res 2014-06-20 10:32:22 +0000
395@@ -68,7 +68,7 @@
396 visible: showHeader && status == Loader.Ready;
397 sourceComponent: ShaderEffect {
398 id: overlay;
399- height: fixedHeaderHeight != -1 ? fixedHeaderHeight : headerHeight;
400+ height: fixedHeaderHeight != -1 ? fixedHeaderHeight + units.gu(1) * 2 : headerHeight;
401 opacity: 0.6;
402 property var source: ShaderEffectSource {
403 id: shaderSource;
404@@ -96,7 +96,7 @@
405 }";
406 }
407 }
408-readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin * 2 + subtitleLabel.height + subtitleLabel.anchors.topMargin;
409+readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;
410 Label {
411 id: titleLabel;
412 objectName: "titleLabel";
413
414=== modified file 'tests/qmltests/CMakeLists.txt'
415--- tests/qmltests/CMakeLists.txt 2014-06-11 15:36:51 +0000
416+++ tests/qmltests/CMakeLists.txt 2014-06-20 10:32:22 +0000
417@@ -29,6 +29,7 @@
418 add_qml_test(Components Rating)
419 add_qml_test(Components ResponsiveFlowView)
420 add_qml_test(Components ResponsiveGridView)
421+add_qml_test(Components ResponsiveVerticalJournal IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
422 add_qml_test(Components SeeMore)
423 add_qml_test(Components Showable)
424 add_qml_test(Components PageHeaderLabel)
425
426=== added file 'tests/qmltests/Components/tst_ResponsiveVerticalJournal.qml'
427--- tests/qmltests/Components/tst_ResponsiveVerticalJournal.qml 1970-01-01 00:00:00 +0000
428+++ tests/qmltests/Components/tst_ResponsiveVerticalJournal.qml 2014-06-20 10:32:22 +0000
429@@ -0,0 +1,183 @@
430+/*
431+ * Copyright 2013-2014 Canonical Ltd.
432+ *
433+ * This program is free software; you can redistribute it and/or modify
434+ * it under the terms of the GNU General Public License as published by
435+ * the Free Software Foundation; version 3.
436+ *
437+ * This program is distributed in the hope that it will be useful,
438+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
439+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
440+ * GNU General Public License for more details.
441+ *
442+ * You should have received a copy of the GNU General Public License
443+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
444+ */
445+
446+import QtQuick 2.0
447+import QtTest 1.0
448+import ".."
449+import "../../../qml/Components"
450+import Ubuntu.Components.ListItems 0.1 as ListItem
451+import Ubuntu.Components 0.1
452+import Utils 0.1
453+import Unity.Test 0.1 as UT
454+
455+Item {
456+ width: units.gu(80) + controls.width
457+ height: units.gu(80)
458+
459+ Column {
460+ id: controls
461+ width: units.gu(40)
462+ height: parent.height
463+ anchors.top: parent.top
464+ anchors.right: parent.right
465+ ListItem.ValueSelector {
466+ id: cardSizeSelector
467+ text: "card-size"
468+ // small, medium, large card sizes
469+ values: [units.gu(12), units.gu(18.5), units.gu(38)]
470+ selectedIndex: 0
471+ }
472+ ListItem.ValueSelector {
473+ id: minColumnSpacingSelector
474+ text: "minColumnSpacing"
475+ values: [0, units.gu(2), units.gu(8), units.gu(25)]
476+ selectedIndex: 0
477+ }
478+ ListItem.ValueSelector {
479+ id: rowSpacingSelector
480+ text: "rowSpacing"
481+ values: [units.gu(1), units.gu(2), units.gu(4), units.gu(8)]
482+ selectedIndex: 1
483+ }
484+ }
485+
486+ ListModel {
487+ id: fakeModel
488+ ListElement { name: "A" }
489+ ListElement { name: "B" }
490+ ListElement { name: "C" }
491+ ListElement { name: "D" }
492+ ListElement { name: "E" }
493+ ListElement { name: "F" }
494+ ListElement { name: "G" }
495+ ListElement { name: "H" }
496+ ListElement { name: "I" }
497+ ListElement { name: "J" }
498+ ListElement { name: "K" }
499+ ListElement { name: "L" }
500+ ListElement { name: "M" }
501+ ListElement { name: "N" }
502+ ListElement { name: "O" }
503+ ListElement { name: "P" }
504+ ListElement { name: "Q" }
505+ ListElement { name: "R" }
506+ ListElement { name: "S" }
507+ ListElement { name: "T" }
508+ ListElement { name: "U" }
509+ }
510+
511+ SortFilterProxyModel {
512+ id: wrappedFakeModel
513+ model: fakeModel
514+ }
515+
516+ Rectangle {
517+ id: journalRect
518+ height: parent.height
519+ color: "grey"
520+ anchors.top: parent.top
521+ anchors.left: parent.left
522+ anchors.right: controls.left
523+
524+ ResponsiveVerticalJournal {
525+ id: journal
526+ anchors.fill: parent
527+ model: wrappedFakeModel
528+ minimumColumnSpacing: minColumnSpacingSelector.values[minColumnSpacingSelector.selectedIndex]
529+ rowSpacing: rowSpacingSelector.values[rowSpacingSelector.selectedIndex]
530+ columnWidth: cardSizeSelector.values[cardSizeSelector.selectedIndex]
531+
532+ delegate: Rectangle {
533+ id: delegateItem
534+ // So that it can be identified by test code
535+ property bool isJournalDelegate: true
536+ objectName: "delegate" + index
537+ color: "grey"
538+ border.color: "red"
539+ border.width: 1
540+
541+ // width derived from Card's template['card-size']
542+ width: cardSizeSelector.values[cardSizeSelector.selectedIndex]
543+ height: Math.max(units.gu(8), Math.floor(Math.random() * 300))
544+
545+ Rectangle {
546+ color: "green"
547+ anchors.centerIn: parent
548+ width: units.gu(6)
549+ height: units.gu(6)
550+ Text {
551+ anchors.centerIn: parent
552+ text: name
553+ }
554+ }
555+
556+ Text { x:0; y:0; text:"(" + parent.x + ", " + parent.y + ")"}
557+ }
558+ }
559+ }
560+
561+ UT.UnityTestCase {
562+ name: "ResponsiveVerticalJournal"
563+ when: windowShown
564+
565+ function test_minimumColumnSpacing_data() {
566+ return [{minColumnSpacingIndex: 0, expectedColumns: 2},
567+ {minColumnSpacingIndex: 1, expectedColumns: 2},
568+ {minColumnSpacingIndex: 2, expectedColumns: 1}]
569+ }
570+
571+ // Test how minimumColumnSpacing affects column count.
572+ function test_minimumColumnSpacing(data) {
573+ cardSizeSelector.selectedIndex = 2 // large card
574+
575+ minColumnSpacingSelector.selectedIndex = data.minColumnSpacingIndex
576+
577+ tryCompareFunction(countJournalDelegatesOnFirstRow, data.expectedColumns)
578+ }
579+
580+ function test_maximumNumberOfColumns_data() {
581+ return [{cardSizeIndex: 0, expectedColumns: 6},
582+ {cardSizeIndex: 1, expectedColumns: 4},
583+ {cardSizeIndex: 2, expectedColumns: 2}]
584+ }
585+
586+ // Test how maximumNumberOfColumns and columnWidth affect column count.
587+ function test_maximumNumberOfColumns(data) {
588+ minColumnSpacingSelector.selectedIndex = 0 // no spacing
589+
590+ cardSizeSelector.selectedIndex = data.cardSizeIndex // columnWidth
591+
592+ tryCompareFunction(countJournalDelegatesOnFirstRow, data.expectedColumns)
593+ }
594+
595+ function countJournalDelegatesOnFirstRow() {
596+ return __countJournalDelegatesOnFirstRow(journal.visibleChildren, 0)
597+ }
598+
599+ function __countJournalDelegatesOnFirstRow(objList, total) {
600+ for (var i = 0; i < objList.length; ++i) {
601+ var child = objList[i];
602+ if (child.isJournalDelegate !== undefined && child.y === 0) {
603+ ++total;
604+ } else {
605+ total = __countJournalDelegatesOnFirstRow(
606+ child.visibleChildren, total)
607+ }
608+ }
609+ return total
610+ }
611+ }
612+}

Subscribers

People subscribed via source and target branches