Merge lp:~mzanetti/ubuntu-ui-toolkit/ubuntulistview into lp:ubuntu-ui-toolkit
- ubuntulistview
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Zsombor Egri |
Approved revision: | 954 |
Merged at revision: | 956 |
Proposed branch: | lp:~mzanetti/ubuntu-ui-toolkit/ubuntulistview |
Merge into: | lp:ubuntu-ui-toolkit |
Prerequisite: | lp:~mzanetti/ubuntu-ui-toolkit/expandable-and-column |
Diff against target: |
544 lines (+439/-7) 7 files modified
components.api (+3/-0) examples/ubuntu-ui-toolkit-gallery/ListItems.qml (+51/-0) modules/Ubuntu/Components/ListItems/Expandable.qml (+30/-7) modules/Ubuntu/Components/UbuntuListView.qml (+121/-0) modules/Ubuntu/Components/qmldir (+1/-0) modules/Ubuntu/Test/UbuntuTestCase.qml (+35/-0) tests/unit_x11/tst_components/tst_ubuntulistview.qml (+198/-0) |
To merge this branch: | bzr merge lp:~mzanetti/ubuntu-ui-toolkit/ubuntulistview |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Zsombor Egri | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+206161@code.launchpad.net |
Commit message
Introduce the almighty UbuntuListView. So far not /that/ mighty tho. Can only deal with Expandables.
Description of the change
- 941. By Michael Zanetti
-
merge prerequisite branch
- 942. By Michael Zanetti
-
add UbuntuListView to the gallery
PS Jenkins bot (ps-jenkins) wrote : | # |
Zsombor Egri (zsombi) wrote : | # |
"can only deal with Expandables" - I guess it can also deal with other elements in between, right?
Zsombor Egri (zsombi) wrote : | # |
I see you still have the item-based property/function. We agreed that this is not good as when scrolled out of the cacheBuffer, ListView will re-create the item when scrolled back and will no longer be the same instance as the previous one...
Or are you still working on that?
Michael Zanetti (mzanetti) wrote : | # |
yep... didn't get to it yet... Had to do unity8 stuff for MWC. Will get to this now.
Michael Zanetti (mzanetti) wrote : | # |
> "can only deal with Expandables" - I guess it can also deal with other
> elements in between, right?
Yes, it can. However, in terms of "mightyness" it adds only the Expandables compared with the standard ListView.
- 943. By Michael Zanetti
-
change UbuntuListView to work with expandedIndex instead of expandedItem
- 944. By Michael Zanetti
-
merge trunk
- 945. By Michael Zanetti
-
fix docs
- 946. By Michael Zanetti
-
merge prerequisite
- 947. By Michael Zanetti
-
remove preliminary from docstring
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:943
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 948. By Michael Zanetti
-
readd tests for UbuntuListView
Michael Zanetti (mzanetti) wrote : | # |
Ok. Changed the UbuntuListView to operate on an expandedIndex instead of an expandedItem. Definitely makes more sense this way.
This also touches the ExpandableItem a bit to add support for a parent Column and a parent ListView to it.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:947
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:948
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 949. By Michael Zanetti
-
merge prerequistite branch
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:949
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Zsombor Egri (zsombi) wrote : | # |
96 + Gives information whether this item is inside an item based container supporting Expandable items, such as ExpandablesColumn
97 + */
98 + readonly property bool isInExpandableC
"expandedItem" does no longer exist for the UbuntuListView... Same everywhere.
Zsombor Egri (zsombi) wrote : | # |
> 96 + Gives information whether this item is inside an item based
> container supporting Expandable items, such as ExpandablesColumn
> 97 + */
> 98 + readonly property bool isInExpandableC
> undefined && view.hasOwnProp
> view.hasOwnProp
>
> "expandedItem" does no longer exist for the UbuntuListView... Same everywhere.
Aaaah, forget about this :)
- 950. By Michael Zanetti
-
added a test for moving expanded item out of the view and bringing it back in.
fix issue with originY not being taken into account which was breaking logic in some circumstances
- 951. By Michael Zanetti
-
change UbuntuTestCase:
:tryCompareFunc tion to provide an optional timeout parameter
Zsombor Egri (zsombi) wrote : | # |
Excellent stuff! Thanks again!
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:950
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 952. By Michael Zanetti
-
fix year in test header
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:951
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:952
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 953. By Michael Zanetti
-
fix className reference in gallery
- 954. By Michael Zanetti
-
merge prerequisite
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:954
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Zsombor Egri (zsombi) wrote : | # |
CI@home is all green.
Preview Diff
1 | === modified file 'components.api' |
2 | --- components.api 2014-02-26 09:47:24 +0000 |
3 | +++ components.api 2014-02-26 09:47:24 +0000 |
4 | @@ -567,6 +567,9 @@ |
5 | property Item pageStack |
6 | property bool opened |
7 | property bool locked |
8 | +modules/Ubuntu/Components/UbuntuListView.qml |
9 | +ListView |
10 | + property int expandedIndex |
11 | modules/Ubuntu/Components/UbuntuNumberAnimation.qml |
12 | NumberAnimation |
13 | modules/Ubuntu/Components/UbuntuShape.qml |
14 | |
15 | === modified file 'examples/ubuntu-ui-toolkit-gallery/ListItems.qml' |
16 | --- examples/ubuntu-ui-toolkit-gallery/ListItems.qml 2014-02-26 09:47:24 +0000 |
17 | +++ examples/ubuntu-ui-toolkit-gallery/ListItems.qml 2014-02-26 09:47:24 +0000 |
18 | @@ -224,6 +224,57 @@ |
19 | } |
20 | |
21 | TemplateSection { |
22 | + title: i18n.tr("UbuntuListView") |
23 | + className: "UbuntuListView" |
24 | + |
25 | + ListModel { |
26 | + id: fruitModel |
27 | + ListElement { name: "Orange"; details: "The orange (specifically, the sweet orange) is the fruit of the citrus species Citrus × ​sinensis in the family Rutaceae. The fruit of the Citrus sinensis is called sweet orange to distinguish it from that of the Citrus aurantium, the bitter orange. The orange is a hybrid, possibly between pomelo (Citrus maxima) and mandarin (Citrus reticulata), cultivated since ancient times.\n-\nWikipedia"} |
28 | + ListElement { name: "Apple"; details: "Fruit" } |
29 | + ListElement { name: "Tomato"; details: "The tomato is the edible, often red fruit of the plant Solanum lycopersicum, commonly known as a tomato plant. Both the species and its use as a food originated in Mexico, and spread throughout the world following the Spanish colonization of the Americas. Its many varieties are now widely grown, sometimes in greenhouses in cooler climates. The tomato is consumed in diverse ways, including raw, as an ingredient in many dishes, sauces, salads, and drinks. While it is botanically a fruit, it is considered a vegetable for culinary purposes (as well as under U.S. customs regulations, see Nix v. Hedden), which has caused some confusion. The fruit is rich in lycopene, which may have beneficial health effects. The tomato belongs to the nightshade family (Solanaceae). The plants typically grow to 1–3 meters (3–10 ft) in height and have a weak stem that often sprawls over the ground and vines over other plants. It is a perennial in its native habitat, although often grown outdoors in temperate climates as an annual. An average common tomato weighs approximately 100 grams (4 oz).\n-\nWikipedia" } |
30 | + ListElement { name: "Carrot"; details: "Vegetable" } |
31 | + ListElement { name: "Potato"; details: "Vegetable" } |
32 | + } |
33 | + |
34 | + Toolkit.UbuntuListView { |
35 | + id: ubuntuListView |
36 | + anchors { left: parent.left; right: parent.right } |
37 | + height: units.gu(24) |
38 | + model: fruitModel |
39 | + clip: true |
40 | + |
41 | + delegate: ListItem.Expandable { |
42 | + id: expandingItem |
43 | + |
44 | + expandedHeight: contentColumn.height + units.gu(1) |
45 | + |
46 | + onClicked: { |
47 | + ubuntuListView.expandedIndex = index; |
48 | + } |
49 | + |
50 | + Column { |
51 | + id: contentColumn |
52 | + anchors { left: parent.left; right: parent.right } |
53 | + Item { |
54 | + anchors { left: parent.left; right: parent.right} |
55 | + height: expandingItem.collapsedHeight |
56 | + Toolkit.Label { |
57 | + anchors { left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter} |
58 | + text: model.name |
59 | + } |
60 | + } |
61 | + |
62 | + Toolkit.Label { |
63 | + anchors { left: parent.left; right: parent.right } |
64 | + text: model.details |
65 | + wrapMode: Text.WordWrap |
66 | + } |
67 | + } |
68 | + } |
69 | + } |
70 | + } |
71 | + |
72 | + TemplateSection { |
73 | title: i18n.tr("ExpandablesColumn") |
74 | className: "ExpandablesColumn" |
75 | |
76 | |
77 | === modified file 'modules/Ubuntu/Components/ListItems/Expandable.qml' |
78 | --- modules/Ubuntu/Components/ListItems/Expandable.qml 2014-02-26 09:47:24 +0000 |
79 | +++ modules/Ubuntu/Components/ListItems/Expandable.qml 2014-02-26 09:47:24 +0000 |
80 | @@ -25,7 +25,7 @@ |
81 | components such as buttons. It subclasses \l Empty and thus brings all that |
82 | functionality, but additionally provides means to expand and collapse the item. |
83 | |
84 | - When used together with an UbuntuListView or \l ExpandablesColumn it |
85 | + When used together with an \l UbuntuListView or \l ExpandablesColumn it |
86 | can coordinate with other items in the list to make sure it is scrolled while |
87 | expanding to be fully visible in the view. Additionally it is made sure that |
88 | only one Expandable item is expanded at a time and it is collapsed when the |
89 | @@ -110,19 +110,25 @@ |
90 | property Item view: root.ListView.view ? root.ListView.view : (root.parent.parent.parent.hasOwnProperty("expandItem") ? root.parent.parent.parent : null) |
91 | |
92 | /*! \internal |
93 | - Gives information whether this item is inside a ExpandablesListView or ExpandablesColumn |
94 | - */ |
95 | - readonly property bool isInExpandableList: view && view !== undefined && view.hasOwnProperty("expandItem") && view.hasOwnProperty("collapse") |
96 | + Gives information whether this item is inside an item based container supporting Expandable items, such as ExpandablesColumn |
97 | + */ |
98 | + readonly property bool isInExpandableColumn: view && view !== undefined && view.hasOwnProperty("expandItem") && view.hasOwnProperty("collapse") |
99 | + |
100 | + /*! \internal |
101 | + Gives information whether this item is inside an index based container supporting Expandable items, such as UbuntuListView |
102 | + */ |
103 | + readonly property bool isInExpandableListView: view && view !== undefined && view.hasOwnProperty("expandedIndex") |
104 | |
105 | /*! \internal |
106 | Gives information if there is another item expanded in the containing ExpandablesListView or ExpandablesColumn |
107 | */ |
108 | - readonly property bool otherExpanded: isInExpandableList && view.expandedItem !== null && view.expandedItem !== undefined && view.expandedItem !== root |
109 | + readonly property bool otherExpanded: (isInExpandableColumn && view.expandedItem !== null && view.expandedItem !== undefined && view.expandedItem !== root) |
110 | + || (isInExpandableListView && view.expandedIndex !== -1 && view.expandedIndex !== index) |
111 | |
112 | /*! \internal |
113 | Gives information about the maximum expanded height, in case that is limited by the containing ExpandablesListView or ExpandablesColumn |
114 | */ |
115 | - readonly property real maxExpandedHeight: isInExpandableList ? Math.min(view.height - collapsedHeight, expandedHeight) : expandedHeight |
116 | + readonly property real maxExpandedHeight: (isInExpandableColumn || isInExpandableListView) ? Math.min(view.height - collapsedHeight, expandedHeight) : expandedHeight |
117 | } |
118 | |
119 | states: [ |
120 | @@ -140,13 +146,30 @@ |
121 | } |
122 | ] |
123 | |
124 | + Component.onCompleted: { |
125 | + if (priv.isInExpandableListView && priv.view.expandedIndex == index) { |
126 | + root.expanded = true; |
127 | + } |
128 | + } |
129 | + |
130 | + Connections { |
131 | + target: priv.isInExpandableListView ? priv.view : null |
132 | + onExpandedIndexChanged: { |
133 | + if (priv.view.expandedIndex == index) { |
134 | + root.expanded = true; |
135 | + } else if (root.expanded = true) { |
136 | + root.expanded = false; |
137 | + } |
138 | + } |
139 | + } |
140 | + |
141 | /*! \internal */ |
142 | onExpandedChanged: { |
143 | if (!expanded) { |
144 | contentFlickable.contentY = 0; |
145 | } |
146 | |
147 | - if (priv.isInExpandableList) { |
148 | + if (priv.isInExpandableColumn) { |
149 | if (expanded) { |
150 | priv.view.expandItem(root); |
151 | } else { |
152 | |
153 | === added file 'modules/Ubuntu/Components/UbuntuListView.qml' |
154 | --- modules/Ubuntu/Components/UbuntuListView.qml 1970-01-01 00:00:00 +0000 |
155 | +++ modules/Ubuntu/Components/UbuntuListView.qml 2014-02-26 09:47:24 +0000 |
156 | @@ -0,0 +1,121 @@ |
157 | +/* |
158 | + * Copyright 2014 Canonical Ltd. |
159 | + * |
160 | + * This program is free software; you can redistribute it and/or modify |
161 | + * it under the terms of the GNU Lesser General Public License as published by |
162 | + * the Free Software Foundation; version 3. |
163 | + * |
164 | + * This program is distributed in the hope that it will be useful, |
165 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
166 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
167 | + * GNU Lesser General Public License for more details. |
168 | + * |
169 | + * You should have received a copy of the GNU Lesser General Public License |
170 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
171 | + */ |
172 | + |
173 | +import QtQuick 2.0 |
174 | +import Ubuntu.Components 0.1 as Toolkit |
175 | + |
176 | +/*! |
177 | + \qmltype UbuntuListView |
178 | + \inqmlmodule Ubuntu.Components 0.1 |
179 | + \ingroup ubuntu |
180 | + \brief A ListView with special features tailored for a look and feel fitting the |
181 | + Ubuntu Touch platform. |
182 | + The UbuntuListView works just like a regular ListView, but it adds special features |
183 | + such as expanding/collapsing items (when used together with the Expandable item). |
184 | + It provides features like automatically positioning the expanding item when it |
185 | + expands and collapsing it again when the user taps outside of it. |
186 | + |
187 | + Examples: |
188 | + \qml |
189 | + import Ubuntu.Components 0.1 |
190 | + import Ubuntu.Components.ListItems 0.1 as ListItem |
191 | + |
192 | + Item { |
193 | + ListModel { |
194 | + id: listModel |
195 | + } |
196 | + |
197 | + UbuntuListView { |
198 | + id: ubuntuListView |
199 | + anchors { left: parent.left; right: parent.right } |
200 | + height: units.gu(24) |
201 | + model: listModel |
202 | + |
203 | + delegate: ListItem.Expandable { |
204 | + id: expandingItem |
205 | + |
206 | + expandedHeight: units.gu(30) |
207 | + |
208 | + onClicked: { |
209 | + ubuntuListView.expandedIndex = index; |
210 | + } |
211 | + } |
212 | + } |
213 | + } |
214 | + \endqml |
215 | + |
216 | + \b{This component is under heavy development.} |
217 | +*/ |
218 | + |
219 | +ListView { |
220 | + id: root |
221 | + |
222 | + /*! |
223 | + The index of the currently expanded item. -1 if no item is expanded. |
224 | + */ |
225 | + property int expandedIndex: -1 |
226 | + |
227 | + QtObject { |
228 | + id: priv |
229 | + |
230 | + function positionViewAtIndexAnimated(expandedIndex) { |
231 | + animation.from = root.contentY; |
232 | + root.currentIndex = expandedIndex; |
233 | + if (expandedIndex == root.count - 1) { |
234 | + root.positionViewAtIndex(expandedIndex, ListView.End); |
235 | + } else { |
236 | + root.positionViewAtIndex(expandedIndex + 1, ListView.End); |
237 | + } |
238 | + |
239 | + var effectiveExpandedHeight = Math.min(root.currentItem.expandedHeight, root.height - root.currentItem.collapsedHeight); |
240 | + if (root.contentY - root.originY == 0) { |
241 | + if (((root.currentIndex + 1) * root.currentItem.collapsedHeight) + effectiveExpandedHeight > root.height) { |
242 | + animation.to = ((root.currentIndex + 1) * root.currentItem.collapsedHeight + effectiveExpandedHeight) - root.height + root.originY |
243 | + } else { |
244 | + animation.to = root.originY |
245 | + } |
246 | + } else { |
247 | + animation.to = root.contentY + (effectiveExpandedHeight - root.currentItem.collapsedHeight); |
248 | + } |
249 | + animation.start(); |
250 | + } |
251 | + } |
252 | + |
253 | + /*! |
254 | + \preliminary |
255 | + Expand the item at the given index. |
256 | + */ |
257 | + onExpandedIndexChanged: { |
258 | + if (expandedIndex < 0) { |
259 | + return; |
260 | + } |
261 | + priv.positionViewAtIndexAnimated(expandedIndex, ListView.End) |
262 | + } |
263 | + |
264 | + UbuntuNumberAnimation { |
265 | + id: animation |
266 | + target: root |
267 | + property: "contentY" |
268 | + } |
269 | + |
270 | + MouseArea { |
271 | + parent: contentItem |
272 | + anchors.fill: parent |
273 | + z: 2 |
274 | + enabled: root.expandedIndex != -1 |
275 | + onClicked: root.expandedIndex = -1; |
276 | + } |
277 | +} |
278 | |
279 | === modified file 'modules/Ubuntu/Components/qmldir' |
280 | --- modules/Ubuntu/Components/qmldir 2014-01-21 18:27:23 +0000 |
281 | +++ modules/Ubuntu/Components/qmldir 2014-02-26 09:47:24 +0000 |
282 | @@ -43,6 +43,7 @@ |
283 | StyledItem 0.1 StyledItem.qml |
284 | ColorUtils 0.1 colorUtils.js |
285 | DateUtils 0.1 dateUtils.js |
286 | +UbuntuListView 0.1 UbuntuListView.qml |
287 | |
288 | internal TextCursor TextCursor.qml |
289 | internal TextInputPopover TextInputPopover.qml |
290 | |
291 | === modified file 'modules/Ubuntu/Test/UbuntuTestCase.qml' |
292 | --- modules/Ubuntu/Test/UbuntuTestCase.qml 2014-02-19 10:49:07 +0000 |
293 | +++ modules/Ubuntu/Test/UbuntuTestCase.qml 2014-02-26 09:47:24 +0000 |
294 | @@ -29,6 +29,9 @@ |
295 | This class extends the default QML TestCase class which is available in QtTest 1.0. |
296 | */ |
297 | TestCase { |
298 | + TestUtil { |
299 | + id:util |
300 | + } |
301 | |
302 | /*! |
303 | Find a child from the item based on the objectName. |
304 | @@ -83,5 +86,37 @@ |
305 | mouseMove(item,x + ix,y + iy,stepdelay); |
306 | } |
307 | } |
308 | + |
309 | + /*! |
310 | + Keeps executing a given parameter-less function until it returns the given |
311 | + expected result or the timemout is reached (in which case a test failure |
312 | + is generated) |
313 | + */ |
314 | + |
315 | + function tryCompareFunction(func, expectedResult, timeout) { |
316 | + var timeSpent = 0 |
317 | + var success = false |
318 | + var actualResult |
319 | + if (timeout == undefined) { |
320 | + timeout = 5000; |
321 | + } |
322 | + while (timeSpent < timeout && !success) { |
323 | + actualResult = func() |
324 | + success = qtest_compareInternal(actualResult, expectedResult) |
325 | + if (success === false) { |
326 | + wait(50) |
327 | + timeSpent += 50 |
328 | + } |
329 | + } |
330 | + |
331 | + var act = qtest_results.stringify(actualResult) |
332 | + var exp = qtest_results.stringify(expectedResult) |
333 | + if (!qtest_results.compare(success, |
334 | + "function returned unexpected result", |
335 | + act, exp, |
336 | + util.callerFile(), util.callerLine())) { |
337 | + throw new Error("QtQuickTest::fail") |
338 | + } |
339 | + } |
340 | } |
341 | |
342 | |
343 | === added file 'tests/unit_x11/tst_components/tst_ubuntulistview.qml' |
344 | --- tests/unit_x11/tst_components/tst_ubuntulistview.qml 1970-01-01 00:00:00 +0000 |
345 | +++ tests/unit_x11/tst_components/tst_ubuntulistview.qml 2014-02-26 09:47:24 +0000 |
346 | @@ -0,0 +1,198 @@ |
347 | +/* |
348 | + * Copyright 2014 Canonical Ltd. |
349 | + * |
350 | + * This program is free software; you can redistribute it and/or modify |
351 | + * it under the terms of the GNU Lesser General Public License as published by |
352 | + * the Free Software Foundation; version 3. |
353 | + * |
354 | + * This program is distributed in the hope that it will be useful, |
355 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
356 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
357 | + * GNU Lesser General Public License for more details. |
358 | + * |
359 | + * You should have received a copy of the GNU Lesser General Public License |
360 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
361 | + */ |
362 | + |
363 | +import QtQuick 2.0 |
364 | +import QtTest 1.0 |
365 | +import Ubuntu.Test 0.1 |
366 | +import Ubuntu.Components 0.1 |
367 | +import Ubuntu.Components.ListItems 0.1 |
368 | + |
369 | +Item { |
370 | + width: units.gu(40) |
371 | + height: units.gu(60) |
372 | + |
373 | + ListModel { |
374 | + id: dummyModel |
375 | + Component.onCompleted: { |
376 | + for (var i = 0; i < 20; ++i) { |
377 | + dummyModel.append({idx: i}); |
378 | + } |
379 | + } |
380 | + } |
381 | + |
382 | + UbuntuListView { |
383 | + id: ubuntuListView |
384 | + anchors { left: parent.left; top: parent.top; right: parent.right } |
385 | + height: units.gu(20) |
386 | + clip: true |
387 | + model: dummyModel |
388 | + |
389 | + delegate: Expandable { |
390 | + id: expandable |
391 | + objectName: "expandable" + index |
392 | + expandedHeight: contentColumn.height |
393 | + |
394 | + onClicked: ubuntuListView.expandedIndex = index |
395 | + |
396 | + Column { |
397 | + id: contentColumn |
398 | + anchors { left: parent.left; right: parent.right; top: parent.top } |
399 | + Rectangle { |
400 | + anchors { left: parent.left; right: parent.right} |
401 | + id: collapsedRect |
402 | + color: index % 2 == 0 ? "khaki" : "blue" |
403 | + height: expandable.collapsedHeight |
404 | + } |
405 | + Rectangle { |
406 | + anchors { left: parent.left; right: parent.right } |
407 | + height: units.gu(40) |
408 | + color: "orange" |
409 | + } |
410 | + } |
411 | + } |
412 | + } |
413 | + |
414 | + UbuntuTestCase { |
415 | + name: "UbuntuListView" |
416 | + when: windowShown |
417 | + |
418 | + function initTestCase() { |
419 | + tryCompare(dummyModel, "count", 20); |
420 | + } |
421 | + |
422 | + function init() { |
423 | + waitForRendering(ubuntuListView); |
424 | + } |
425 | + |
426 | + function expandItem(item) { |
427 | + var index = ubuntuListView.indexAt(item.x, item.y); |
428 | + ubuntuListView.expandedIndex = index; |
429 | + var targetHeight = Math.min(item.expandedHeight, ubuntuListView.height - item.collapsedHeight); |
430 | + tryCompare(item, "height", targetHeight); |
431 | + } |
432 | + |
433 | + function collapse() { |
434 | + if (ubuntuListView.expandedIndex == -1) { |
435 | + return; |
436 | + } |
437 | + |
438 | + var expandedItem = findChild(ubuntuListView, "expandable" + ubuntuListView.expandedIndex); |
439 | + ubuntuListView.expandedIndex = -1; |
440 | + tryCompare(expandedItem, "height", expandedItem.collapsedHeight); |
441 | + } |
442 | + |
443 | + function test_expandedItem() { |
444 | + var item = findChild(ubuntuListView, "expandable1"); |
445 | + expandItem(item); |
446 | + |
447 | + // expandedItem needs to point to the expanded item |
448 | + compare(ubuntuListView.expandedIndex, 1); |
449 | + // item must be expanded now |
450 | + compare(item.expanded, true); |
451 | + |
452 | + collapse(); |
453 | + |
454 | + // expandedItem must be unset after collapsing |
455 | + compare(ubuntuListView.expandedIndex, -1); |
456 | + } |
457 | + |
458 | + function test_noScrollingNeeded() { |
459 | + var item = findChild(ubuntuListView, "expandable1"); |
460 | + fuzzyCompare(ubuntuListView.mapFromItem(item).y, item.collapsedHeight, .5); |
461 | + |
462 | + expandItem(item); |
463 | + waitForRendering(ubuntuListView); |
464 | + |
465 | + fuzzyCompare(ubuntuListView.mapFromItem(item).y, item.collapsedHeight, .5); |
466 | + } |
467 | + |
468 | + function test_scrollToTop() { |
469 | + ubuntuListView.height = units.gu(30); |
470 | + ubuntuListView.positionViewAtIndex(0, ListView.Beginning) |
471 | + |
472 | + var item = findChild(ubuntuListView, "expandable1"); |
473 | + fuzzyCompare(ubuntuListView.mapFromItem(item).y, item.collapsedHeight, 1); |
474 | + |
475 | + expandItem(item); |
476 | + |
477 | + fuzzyCompare(ubuntuListView.mapFromItem(item).y, 0, .5); |
478 | + } |
479 | + |
480 | + function test_scrollIntoView() { |
481 | + var item = findChild(ubuntuListView, "expandable9"); |
482 | + expandItem(item); |
483 | + waitForRendering(ubuntuListView); |
484 | + |
485 | + // The item must be scrolled upwards, leaving space for one other item at the bottom |
486 | + fuzzyCompare(ubuntuListView.mapFromItem(item).y, ubuntuListView.height - item.collapsedHeight - item.expandedHeight, 1); |
487 | + } |
488 | + |
489 | + function test_collapseByClickingOutside() { |
490 | + // expand item 0 |
491 | + var item = findChild(ubuntuListView, "expandable0"); |
492 | + expandItem(item); |
493 | + |
494 | + // click on item 1 |
495 | + var item1 = findChild(ubuntuListView, "expandable1"); |
496 | + mouseClick(item1, item1.width / 2, item1.height / 2); |
497 | + |
498 | + // make sure item1 is collapsed |
499 | + tryCompare(item, "expanded", false); |
500 | + } |
501 | + |
502 | + function test_dimOthers() { |
503 | + var item = findChild(ubuntuListView, "expandable1"); |
504 | + expandItem(item); |
505 | + |
506 | + for (var i = 0; i < ubuntuListView.contentItem.children.length; ++i) { |
507 | + var childItem = ubuntuListView.contentItem.children[i]; |
508 | + if (childItem.hasOwnProperty("expanded")) { |
509 | + compare(childItem.opacity, childItem.expanded ? 1 : .5) |
510 | + } |
511 | + |
512 | + } |
513 | + } |
514 | + |
515 | + function test_destroyAndRecreateExpanded() { |
516 | + var item = findChild(ubuntuListView, "expandable1"); |
517 | + expandItem(item); |
518 | + |
519 | + // scroll the list to the bottom |
520 | + ubuntuListView.currentIndex = 0; |
521 | + ubuntuListView.positionViewAtIndex(ubuntuListView.count -1, ListView.End); |
522 | + |
523 | + // make sure the item is eventually destroyed |
524 | + tryCompareFunction(function() { return findChild(ubuntuListView, "expandable1") == null;}, true) |
525 | + |
526 | + // scroll the list back up |
527 | + ubuntuListView.positionViewAtIndex(0, ListView.Beginning) |
528 | + |
529 | + // wait until the item is recreated. |
530 | + tryCompareFunction(function() { return findChild(ubuntuListView, "expandable1") != null; }, true); |
531 | + item = findChild(ubuntuListView, "expandable1"); |
532 | + compare(item.expanded, true); |
533 | + |
534 | + } |
535 | + |
536 | + function cleanup() { |
537 | + // Restore listview height |
538 | + ubuntuListView.height = units.gu(60); |
539 | + collapse(); |
540 | + // scroll the ListView back to top |
541 | + ubuntuListView.positionViewAtIndex(0, ListView.Beginning); |
542 | + } |
543 | + } |
544 | +} |
FAILED: Continuous integration, rev:942 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- ci/1728/ jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty/ 3201 jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty- touch/2882/ console jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- trusty- amd64-ci/ 676 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- trusty- armhf-ci/ 676 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- trusty- armhf-ci/ 676/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ autopilot- testrunner- otto-trusty/ 2814 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- amd64/3203 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- amd64/3203/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- armhf/2884 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- armhf/2884/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- runner- mako/5289/ console s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 3915
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- ui-toolkit- ci/1728/ rebuild
http://