Merge lp:~zsombi/ubuntu-ui-toolkit/datepicker-fix1287009 into lp:ubuntu-ui-toolkit
- datepicker-fix1287009
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Cris Dywan |
Approved revision: | 971 |
Merged at revision: | 968 |
Proposed branch: | lp:~zsombi/ubuntu-ui-toolkit/datepicker-fix1287009 |
Merge into: | lp:ubuntu-ui-toolkit |
Diff against target: |
952 lines (+227/-150) 12 files modified
components.api (+3/-0) modules/Ubuntu/Components/Pickers/DatePicker.qml (+16/-0) modules/Ubuntu/Components/Pickers/Picker.qml (+66/-0) modules/Ubuntu/Components/Pickers/PickerDelegate.qml (+1/-1) modules/Ubuntu/Components/Pickers/PickerModelBase.qml (+8/-1) modules/Ubuntu/Components/Pickers/PickerRow.qml (+46/-3) modules/Ubuntu/Components/Pickers/SecondsModel.qml (+2/-2) modules/Ubuntu/Components/Themes/Ambiance/PickerDelegateStyle.qml (+1/-1) modules/Ubuntu/Components/plugin/quickutils.cpp (+3/-0) tests/resources/pickers/DatePickerTest.qml (+5/-0) tests/resources/pickers/PickerTest.qml (+6/-0) tests/unit_x11/tst_components/tst_datepicker.qml (+70/-142) |
To merge this branch: | bzr merge lp:~zsombi/ubuntu-ui-toolkit/datepicker-fix1287009 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cris Dywan | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Timo Jyrinki | Approve | ||
Review via email: mp+209641@code.launchpad.net |
Commit message
DatePicker flaky test fix.
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
Timo Jyrinki (timo-jyrinki) wrote : | # |
Fixes the issue in the landing PPA: https:/
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:971
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://
Cris Dywan (kalikiana) wrote : | # |
I'm liking waitPickerMoving and your use of the loader status. So much cleaner and keeps the tests readable.
Preview Diff
1 | === modified file 'components.api' |
2 | --- components.api 2014-03-04 13:01:20 +0000 |
3 | +++ components.api 2014-03-06 14:36:38 +0000 |
4 | @@ -271,6 +271,7 @@ |
5 | readonly property int minutes |
6 | readonly property int seconds |
7 | property var locale |
8 | + readonly property bool moving |
9 | modules/Ubuntu/Components/Pickers/Dialer.qml |
10 | StyledItem |
11 | property real minimumValue |
12 | @@ -296,6 +297,8 @@ |
13 | property Component delegate |
14 | property int selectedIndex |
15 | property bool live |
16 | + readonly property bool moving |
17 | + function positionViewAtIndex(index) |
18 | property int __clickedIndex |
19 | modules/Ubuntu/Components/Pickers/PickerDelegate.qml |
20 | AbstractButton |
21 | |
22 | === modified file 'modules/Ubuntu/Components/Pickers/DatePicker.qml' |
23 | --- modules/Ubuntu/Components/Pickers/DatePicker.qml 2014-01-10 15:33:02 +0000 |
24 | +++ modules/Ubuntu/Components/Pickers/DatePicker.qml 2014-03-06 14:36:38 +0000 |
25 | @@ -292,6 +292,14 @@ |
26 | */ |
27 | property var locale: Qt.locale() |
28 | |
29 | + /*! |
30 | + \qmlproperty bool moving |
31 | + \readonly |
32 | + The property holds whether the component's pickers are moving. |
33 | + \sa Picker::moving |
34 | + */ |
35 | + readonly property alias moving: positioner.moving |
36 | + |
37 | implicitWidth: units.gu(36) |
38 | implicitHeight: units.gu(20) |
39 | |
40 | @@ -453,6 +461,13 @@ |
41 | */ |
42 | id: tumblerModel |
43 | |
44 | + /* |
45 | + Signal triggered when the model is about to remove a picker. We cannot rely on |
46 | + rowAboutToBeRemoved, as by the time the signal is called the list element is |
47 | + already removed from the model. |
48 | + */ |
49 | + signal pickerRemoved(int index) |
50 | + |
51 | // the function checks whether a pickerModel was added or not |
52 | // returns the index of the model object the pickerModel was found |
53 | // or -1 on error. |
54 | @@ -480,6 +495,7 @@ |
55 | function removePicker(name) { |
56 | var idx = pickerModelIndex(name); |
57 | if (idx >= 0) { |
58 | + pickerRemoved(idx); |
59 | remove(idx); |
60 | } |
61 | } |
62 | |
63 | === modified file 'modules/Ubuntu/Components/Pickers/Picker.qml' |
64 | --- modules/Ubuntu/Components/Pickers/Picker.qml 2013-12-10 19:28:19 +0000 |
65 | +++ modules/Ubuntu/Components/Pickers/Picker.qml 2014-03-06 14:36:38 +0000 |
66 | @@ -121,6 +121,40 @@ |
67 | */ |
68 | property bool live: false |
69 | |
70 | + /*! |
71 | + The property holds whether the picker's view is moving due to the user |
72 | + interaction either by dragging, flicking or due to the manual change of |
73 | + the selectedIndex property. |
74 | + */ |
75 | + readonly property bool moving: (loader.item ? loader.item.moving : false) || movingPoll.indexChanging |
76 | + |
77 | + /*! |
78 | + The function positions the picker's view to the given index without animating |
79 | + the view. The component must be ready when calling the function, e.g. to make |
80 | + sure the Picker shows up at the given index, do the following: |
81 | + \qml |
82 | + Picker { |
83 | + model: 120 |
84 | + delegate: PickerDelegate { |
85 | + Label { |
86 | + anchors.fill: parent |
87 | + verticalCenter: Text.AlignVCenter |
88 | + text: modelData |
89 | + } |
90 | + } |
91 | + Component.onCompleted: positionViewAtIndex(10) |
92 | + } |
93 | + \endqml |
94 | + */ |
95 | + function positionViewAtIndex(index) { |
96 | + if (!loader.item || !internals.completed) { |
97 | + return; |
98 | + } |
99 | + loader.item.positionViewAtIndex(index, loader.isListView ? ListView.SnapPosition : PathView.SnapPosition); |
100 | + // update selectedIndex |
101 | + selectedIndex = loader.item.currentIndex; |
102 | + } |
103 | + |
104 | implicitWidth: units.gu(8) |
105 | implicitHeight: units.gu(20) |
106 | |
107 | @@ -137,6 +171,34 @@ |
108 | when: __styleInstance.hasOwnProperty("view") && loader.item |
109 | } |
110 | |
111 | + /* |
112 | + ListView/PathView do not change moding property when the current index is |
113 | + changed manually. Therefore we use an idle timer to poll the contentY to |
114 | + detect whether the views are still moving. |
115 | + PathView's currentIndex changes while the component is moving, however this |
116 | + is not true for ListView. |
117 | + */ |
118 | + Timer { |
119 | + id: movingPoll |
120 | + interval: 50 |
121 | + running: false |
122 | + property bool indexChanging: false |
123 | + property real prevContentY |
124 | + onTriggered: { |
125 | + if (prevContentY === loader.item.contentY) { |
126 | + indexChanging = false; |
127 | + } else { |
128 | + kick(); |
129 | + } |
130 | + } |
131 | + function kick() { |
132 | + if (!loader.item) return; |
133 | + indexChanging = true; |
134 | + prevContentY = loader.item.contentY; |
135 | + running = true; |
136 | + } |
137 | + } |
138 | + |
139 | // tumbler |
140 | Loader { |
141 | id: loader |
142 | @@ -171,12 +233,14 @@ |
143 | } |
144 | } |
145 | onCurrentIndexChanged: { |
146 | + movingPoll.kick(); |
147 | if (!loader.completed) return; |
148 | if (picker.live || (modelWatcher.modelSize() <= 0) |
149 | || (picker.__clickedIndex >= 0 && (picker.__clickedIndex === loader.item.currentIndex)) |
150 | || modelWatcher.cropping) { |
151 | picker.selectedIndex = loader.item.currentIndex; |
152 | modelWatcher.cropping = false; |
153 | + picker.__clickedIndex = -1; |
154 | } |
155 | } |
156 | onModelChanged: { |
157 | @@ -216,6 +280,8 @@ |
158 | property Item pickerItem: picker |
159 | // property holding view completion |
160 | property bool viewCompleted: false |
161 | + // declared to ease moving detection |
162 | + property real contentY: offset |
163 | anchors { |
164 | top: parent ? parent.top : undefined |
165 | bottom: parent ? parent.bottom : undefined |
166 | |
167 | === modified file 'modules/Ubuntu/Components/Pickers/PickerDelegate.qml' |
168 | --- modules/Ubuntu/Components/Pickers/PickerDelegate.qml 2013-12-10 16:52:07 +0000 |
169 | +++ modules/Ubuntu/Components/Pickers/PickerDelegate.qml 2014-03-06 14:36:38 +0000 |
170 | @@ -51,7 +51,7 @@ |
171 | |
172 | QtObject { |
173 | id: internal |
174 | - property bool inListView: QuickUtils.className(pickerDelegate.parent) !== "QQuickPathView" |
175 | + property bool inListView: pickerDelegate.parent && (QuickUtils.className(pickerDelegate.parent) !== "QQuickPathView") |
176 | property Item itemList: !inListView ? pickerDelegate.PathView.view : pickerDelegate.ListView.view |
177 | property Picker picker: itemList ? itemList.pickerItem : null |
178 | } |
179 | |
180 | === modified file 'modules/Ubuntu/Components/Pickers/PickerModelBase.qml' |
181 | --- modules/Ubuntu/Components/Pickers/PickerModelBase.qml 2013-12-10 16:52:07 +0000 |
182 | +++ modules/Ubuntu/Components/Pickers/PickerModelBase.qml 2014-03-06 14:36:38 +0000 |
183 | @@ -141,7 +141,14 @@ |
184 | if (!pickerCompleted || !pickerItem || resetting) { |
185 | return; |
186 | } |
187 | - pickerItem.selectedIndex = indexOf(); |
188 | + // use animated index update only if the change had happened because of the delegate update |
189 | + if (pickerItem.__clickedIndex >= 0) { |
190 | + pickerItem.selectedIndex = indexOf(); |
191 | + } else { |
192 | + // in case the date property was changed due to binding/update, |
193 | + // position tumbler without animating |
194 | + pickerItem.positionViewAtIndex(indexOf()); |
195 | + } |
196 | } |
197 | |
198 | } |
199 | |
200 | === modified file 'modules/Ubuntu/Components/Pickers/PickerRow.qml' |
201 | --- modules/Ubuntu/Components/Pickers/PickerRow.qml 2013-12-17 07:53:21 +0000 |
202 | +++ modules/Ubuntu/Components/Pickers/PickerRow.qml 2014-03-06 14:36:38 +0000 |
203 | @@ -35,10 +35,51 @@ |
204 | */ |
205 | property real margins: units.gu(1.5) |
206 | |
207 | + /* |
208 | + Reports whether either of the pickers is moving |
209 | + */ |
210 | + property bool moving |
211 | + |
212 | + // the following functions/properties should be kept private in case the |
213 | + // component is ever decided to be published |
214 | + |
215 | + function pickerMoving(isMoving) { |
216 | + if (isMoving === undefined) { |
217 | + isMoving = this.moving; |
218 | + } |
219 | + |
220 | + if (isMoving) { |
221 | + row.moving = true; |
222 | + } else { |
223 | + for (var i = 0; i < row.model.count; i++) { |
224 | + var pickerItem = model.get(i).pickerModel.pickerItem; |
225 | + if (!pickerItem) return; |
226 | + if (pickerItem.moving) { |
227 | + row.moving = true; |
228 | + return; |
229 | + } |
230 | + } |
231 | + row.moving = false; |
232 | + } |
233 | + } |
234 | + |
235 | + function disconnectPicker(index) { |
236 | + var pickerItem = model.get(index).pickerModel.pickerItem; |
237 | + if (pickerItem) { |
238 | + pickerItem.onMovingChanged.disconnect(pickerMoving); |
239 | + } |
240 | + } |
241 | + |
242 | + Connections { |
243 | + target: row.model |
244 | + onPickerRemoved: disconnectPicker(index) |
245 | + } |
246 | + |
247 | objectName: "PickerRow_Positioner"; |
248 | |
249 | Repeater { |
250 | id: rowRepeater |
251 | + onModelChanged: row.pickerMoving(true) |
252 | Picker { |
253 | id: unitPicker |
254 | objectName: "PickerRow_" + pickerName |
255 | @@ -47,7 +88,7 @@ |
256 | circular: pickerModel.circular |
257 | live: false |
258 | width: pickerModel.pickerWidth |
259 | - height: parent.height |
260 | + height: parent ? parent.height : 0 |
261 | |
262 | style: Rectangle { |
263 | anchors.fill: parent |
264 | @@ -56,7 +97,7 @@ |
265 | delegate: PickerDelegate { |
266 | Label { |
267 | objectName: "PickerRow_PickerLabel" |
268 | - text: pickerModel.text(modelData) |
269 | + text: pickerModel ? pickerModel.text(modelData) : "" |
270 | anchors.fill: parent |
271 | verticalAlignment: Text.AlignVCenter |
272 | horizontalAlignment: Text.AlignHCenter |
273 | @@ -82,12 +123,14 @@ |
274 | pickerModel.reset(); |
275 | pickerModel.resetLimits(textSizer, margins); |
276 | pickerModel.resetCompleted(); |
277 | - selectedIndex = pickerModel.indexOf(); |
278 | + positionViewAtIndex(pickerModel.indexOf()); |
279 | } |
280 | |
281 | Component.onCompleted: { |
282 | // update model with the item instance |
283 | pickerModel.pickerItem = unitPicker; |
284 | + unitPicker.onMovingChanged.connect(pickerMoving.bind(unitPicker)); |
285 | + row.pickerMoving(unitPicker.moving); |
286 | } |
287 | } |
288 | } |
289 | |
290 | === modified file 'modules/Ubuntu/Components/Pickers/SecondsModel.qml' |
291 | --- modules/Ubuntu/Components/Pickers/SecondsModel.qml 2013-12-13 11:22:51 +0000 |
292 | +++ modules/Ubuntu/Components/Pickers/SecondsModel.qml 2014-03-06 14:36:38 +0000 |
293 | @@ -26,8 +26,8 @@ |
294 | |
295 | clear(); |
296 | from = minimum.getSeconds(); |
297 | - var distance = (!maximum.isValid() || (minimum.daysTo(maximum) > 1) || (minimum.secondsTo(maximum) >= 60)) ? 59 : minimum.secondsTo(maximum); |
298 | - for (var i = 0; i <= distance; i++) { |
299 | + var distance = (!maximum.isValid() || (minimum.secondsTo(maximum) >= 60)) ? 60 : minimum.secondsTo(maximum); |
300 | + for (var i = 0; i < distance; i++) { |
301 | append({"seconds": (from + i) % 60}); |
302 | } |
303 | |
304 | |
305 | === modified file 'modules/Ubuntu/Components/Themes/Ambiance/PickerDelegateStyle.qml' |
306 | --- modules/Ubuntu/Components/Themes/Ambiance/PickerDelegateStyle.qml 2013-12-09 06:39:07 +0000 |
307 | +++ modules/Ubuntu/Components/Themes/Ambiance/PickerDelegateStyle.qml 2014-03-06 14:36:38 +0000 |
308 | @@ -22,7 +22,7 @@ |
309 | property real maxFade: 0.95 |
310 | property bool fadingEnabled: true |
311 | |
312 | - property bool inListView: QuickUtils.className(styledItem.parent) !== "QQuickPathView" |
313 | + property bool inListView: styledItem.parent && (QuickUtils.className(styledItem.parent) !== "QQuickPathView") |
314 | property Item itemList: inListView ? styledItem.ListView.view : styledItem.PathView.view |
315 | property Item picker: styledItem.picker |
316 | property Item highlightItem: itemList.highlightItem |
317 | |
318 | === modified file 'modules/Ubuntu/Components/plugin/quickutils.cpp' |
319 | --- modules/Ubuntu/Components/plugin/quickutils.cpp 2014-03-01 12:52:25 +0000 |
320 | +++ modules/Ubuntu/Components/plugin/quickutils.cpp 2014-03-06 14:36:38 +0000 |
321 | @@ -112,6 +112,9 @@ |
322 | */ |
323 | QString QuickUtils::className(QObject *item) |
324 | { |
325 | + if (!item) { |
326 | + return QString(); |
327 | + } |
328 | QString result = item->metaObject()->className(); |
329 | return result.left(result.indexOf("_QML")); |
330 | } |
331 | |
332 | === modified file 'tests/resources/pickers/DatePickerTest.qml' |
333 | --- tests/resources/pickers/DatePickerTest.qml 2013-12-19 11:08:50 +0000 |
334 | +++ tests/resources/pickers/DatePickerTest.qml 2014-03-06 14:36:38 +0000 |
335 | @@ -32,6 +32,7 @@ |
336 | date: new Date() |
337 | |
338 | onDateChanged: print("CHANGED DATE=" + Qt.formatDateTime(date, "yyyy/MM/dd, hh:mm:ss")) |
339 | + onMovingChanged: print("MOVING?", moving) |
340 | } |
341 | Slider { |
342 | value: 0.0//units.gu(36) |
343 | @@ -47,21 +48,25 @@ |
344 | spacing: units.gu(1) |
345 | Button { |
346 | text: "HU" |
347 | + width: units.gu(5) |
348 | height: units.gu(2) |
349 | onClicked: picker.locale = Qt.locale("hu_HU") |
350 | } |
351 | Button { |
352 | text: "DE" |
353 | + width: units.gu(5) |
354 | height: units.gu(2) |
355 | onClicked: picker.locale = Qt.locale("de_DE") |
356 | } |
357 | Button { |
358 | text: "EN(US)" |
359 | + width: units.gu(9) |
360 | height: units.gu(2) |
361 | onClicked: picker.locale = Qt.locale("en_US") |
362 | } |
363 | Button { |
364 | text: "FI" |
365 | + width: units.gu(5) |
366 | height: units.gu(2) |
367 | onClicked: { |
368 | picker.locale = Qt.locale("fi_FI") |
369 | |
370 | === modified file 'tests/resources/pickers/PickerTest.qml' |
371 | --- tests/resources/pickers/PickerTest.qml 2013-12-09 06:39:07 +0000 |
372 | +++ tests/resources/pickers/PickerTest.qml 2014-03-06 14:36:38 +0000 |
373 | @@ -42,6 +42,7 @@ |
374 | height: units.gu(40) |
375 | model: pickerModel |
376 | delegate: PickerDelegate { |
377 | + property string text: modelData ? modelData : "" |
378 | Label { |
379 | anchors.fill: parent |
380 | horizontalAlignment: Text.AlignHCenter |
381 | @@ -50,6 +51,7 @@ |
382 | } |
383 | } |
384 | onSelectedIndexChanged: print("circular index="+selectedIndex) |
385 | + onMovingChanged: print("MOVING?", moving) |
386 | } |
387 | |
388 | Picker { |
389 | @@ -59,6 +61,7 @@ |
390 | model: pickerModel |
391 | circular: false |
392 | delegate: PickerDelegate { |
393 | + property string text: modelData ? modelData : "" |
394 | Label { |
395 | anchors.fill: parent |
396 | horizontalAlignment: Text.AlignHCenter |
397 | @@ -67,6 +70,7 @@ |
398 | } |
399 | } |
400 | onSelectedIndexChanged: print("linear index="+selectedIndex) |
401 | + onMovingChanged: print("MOVING?", moving) |
402 | } |
403 | |
404 | Picker { |
405 | @@ -82,6 +86,7 @@ |
406 | } |
407 | } |
408 | onSelectedIndexChanged: print("circular index="+selectedIndex) |
409 | + onMovingChanged: print("MOVING?", moving) |
410 | } |
411 | |
412 | Picker { |
413 | @@ -98,6 +103,7 @@ |
414 | } |
415 | } |
416 | onSelectedIndexChanged: print("linear index="+selectedIndex) |
417 | + onMovingChanged: print("MOVING?", moving) |
418 | } |
419 | } |
420 | |
421 | |
422 | === modified file 'tests/unit_x11/tst_components/tst_datepicker.qml' |
423 | --- tests/unit_x11/tst_components/tst_datepicker.qml 2014-01-07 14:41:57 +0000 |
424 | +++ tests/unit_x11/tst_components/tst_datepicker.qml 2014-03-06 14:36:38 +0000 |
425 | @@ -25,58 +25,44 @@ |
426 | width: units.gu(40) |
427 | height: units.gu(71) |
428 | |
429 | - DatePicker { |
430 | - id: picker |
431 | + Component { |
432 | + id: testComponent |
433 | + DatePicker { |
434 | + width: testSuite.width |
435 | + } |
436 | + } |
437 | + Loader { |
438 | + id: pickerLoader |
439 | + asynchronous: false |
440 | width: parent.width |
441 | } |
442 | |
443 | - SignalSpy { |
444 | - id: modeChange |
445 | - target: picker |
446 | - signalName: "modeChanged" |
447 | - } |
448 | - |
449 | - SignalSpy { |
450 | - id: dateChange |
451 | - target: picker |
452 | - signalName: "dateChanged" |
453 | - } |
454 | - |
455 | - SignalSpy { |
456 | - id: yearChange |
457 | - target: picker |
458 | - signalName: "yearChanged" |
459 | - } |
460 | - |
461 | - SignalSpy { |
462 | - id: monthChange |
463 | - target: picker |
464 | - signalName: "monthChanged" |
465 | - } |
466 | - |
467 | - SignalSpy { |
468 | - id: dayChange |
469 | - target: picker |
470 | - signalName: "dayChanged" |
471 | - } |
472 | - |
473 | - SignalSpy { |
474 | - id: weekChange |
475 | - target: picker |
476 | - signalName: "weekChanged" |
477 | - } |
478 | - |
479 | UbuntuTestCase { |
480 | name: "DatePickerAPI" |
481 | when: windowShown |
482 | |
483 | + readonly property DatePicker picker: pickerLoader.item |
484 | + |
485 | + function init() { |
486 | + pickerLoader.sourceComponent = testComponent; |
487 | + tryCompareFunction(function(){return pickerLoader.status}, Loader.Ready); |
488 | + waitPickerMoving(); |
489 | + } |
490 | + function cleanup() { |
491 | + pickerLoader.sourceComponent = undefined; |
492 | + } |
493 | + function waitPickerMoving() { |
494 | + waitForRendering(picker); |
495 | + tryCompareFunction(function(){return picker.moving}, false); |
496 | + } |
497 | + |
498 | function getPickerLabel(picker, name) { |
499 | var pickerItem = findChild(picker, name); |
500 | var pickerCurrent = findChild(pickerItem, "Picker_ViewLoader"); |
501 | return findChild(pickerCurrent.item.currentItem, "PickerRow_PickerLabel"); |
502 | } |
503 | function getPickerModel(picker, name) { |
504 | - var pickerItem = findChild(picker, name); |
505 | + var pickerItem = findInvisibleChild(picker, name); |
506 | return pickerItem ? pickerItem.model : undefined; |
507 | } |
508 | function setHMS(date, h, m, s) { |
509 | @@ -114,213 +100,149 @@ |
510 | var newMode = "Years|Months"; |
511 | var pickerCount = 2 + 1; // +1 is the Repeater |
512 | picker.mode = newMode; |
513 | - wait(500); |
514 | + waitPickerMoving(); |
515 | var positioner = findChild(picker, "PickerRow_Positioner"); |
516 | compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
517 | - |
518 | - picker.mode = "Years|Months|Days"; |
519 | - pickerCount = 3 + 1; // +1 is the Repeater |
520 | - compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
521 | } |
522 | |
523 | function test_1_changeModeMD() { |
524 | var newMode = "Days|Months"; |
525 | var pickerCount = 2 + 1; // +1 is the Repeater |
526 | picker.mode = newMode; |
527 | - wait(500); |
528 | + waitPickerMoving(); |
529 | var positioner = findChild(picker, "PickerRow_Positioner"); |
530 | compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
531 | - |
532 | - picker.mode = "Years|Months|Days"; |
533 | - pickerCount = 3 + 1; // +1 is the Repeater |
534 | - compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
535 | } |
536 | |
537 | function test_1_changeModeYD() { |
538 | var newMode = "Years|Days"; |
539 | var pickerCount = 2 + 1; // +1 is the Repeater |
540 | picker.mode = newMode; |
541 | - wait(500); |
542 | + // no rendering is expected, no need to wait |
543 | var positioner = findChild(picker, "PickerRow_Positioner"); |
544 | expectFailContinue("", "Invalid mode"); |
545 | compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
546 | - |
547 | - picker.mode = "Years|Months|Days"; |
548 | - pickerCount = 3 + 1; // +1 is the Repeater |
549 | - compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
550 | } |
551 | |
552 | function test_1_changeModeY() { |
553 | var newMode = "Years"; |
554 | var pickerCount = 1 + 1; // +1 is the Repeater |
555 | picker.mode = newMode; |
556 | - wait(500); |
557 | + waitPickerMoving(); |
558 | var positioner = findChild(picker, "PickerRow_Positioner"); |
559 | compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
560 | - |
561 | - picker.mode = "Years|Months|Days"; |
562 | - pickerCount = 3 + 1; // +1 is the Repeater |
563 | - compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
564 | } |
565 | |
566 | function test_1_changeModeM() { |
567 | var newMode = "Months"; |
568 | var pickerCount = 1 + 1; // +1 is the Repeater |
569 | picker.mode = newMode; |
570 | - wait(500); |
571 | + waitPickerMoving(); |
572 | var positioner = findChild(picker, "PickerRow_Positioner"); |
573 | compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
574 | - |
575 | - picker.mode = "Years|Months|Days"; |
576 | - pickerCount = 3 + 1; // +1 is the Repeater |
577 | - compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
578 | } |
579 | |
580 | function test_1_changeModeD() { |
581 | var newMode = "Days"; |
582 | var pickerCount = 1 + 1; // +1 is the Repeater |
583 | picker.mode = newMode; |
584 | - wait(500); |
585 | + waitPickerMoving(); |
586 | var positioner = findChild(picker, "PickerRow_Positioner"); |
587 | compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
588 | - |
589 | - picker.mode = "Years|Months|Days"; |
590 | - pickerCount = 3 + 1; // +1 is the Repeater |
591 | - compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
592 | } |
593 | |
594 | function test_1_changeModeHMS() { |
595 | var newMode = "Hours|Minutes|Seconds"; |
596 | var pickerCount = 3 + 1; // +1 is the Repeater |
597 | picker.mode = newMode; |
598 | - wait(500); |
599 | + waitPickerMoving(); |
600 | var positioner = findChild(picker, "PickerRow_Positioner"); |
601 | compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
602 | - |
603 | - picker.mode = "Years|Months|Days"; |
604 | - pickerCount = 3 + 1; // +1 is the Repeater |
605 | - compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
606 | } |
607 | |
608 | function test_1_changeModeHM() { |
609 | var newMode = "Hours|Minutes"; |
610 | var pickerCount = 2 + 1; // +1 is the Repeater |
611 | picker.mode = newMode; |
612 | - wait(500); |
613 | + waitPickerMoving(); |
614 | var positioner = findChild(picker, "PickerRow_Positioner"); |
615 | compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
616 | - |
617 | - picker.mode = "Years|Months|Days"; |
618 | - pickerCount = 3 + 1; // +1 is the Repeater |
619 | - compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
620 | } |
621 | |
622 | function test_1_changeModeMS() { |
623 | var newMode = "Minutes|Seconds"; |
624 | var pickerCount = 2 + 1; // +1 is the Repeater |
625 | picker.mode = newMode; |
626 | - wait(500); |
627 | + waitPickerMoving(); |
628 | var positioner = findChild(picker, "PickerRow_Positioner"); |
629 | compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
630 | - |
631 | - picker.mode = "Years|Months|Days"; |
632 | - pickerCount = 3 + 1; // +1 is the Repeater |
633 | - compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
634 | } |
635 | |
636 | function test_1_changeModeHS() { |
637 | var newMode = "Hours|Seconds"; |
638 | var pickerCount = 2 + 1; // +1 is the Repeater |
639 | picker.mode = newMode; |
640 | - wait(500); |
641 | + waitPickerMoving(); |
642 | var positioner = findChild(picker, "PickerRow_Positioner"); |
643 | expectFailContinue("", "cannot set mode to Hours|Minutes"); |
644 | compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
645 | - |
646 | - picker.mode = "Years|Months|Days"; |
647 | - pickerCount = 3 + 1; // +1 is the Repeater |
648 | - compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
649 | } |
650 | |
651 | function test_1_changeModeH() { |
652 | var newMode = "Hours"; |
653 | var pickerCount = 1 + 1; // +1 is the Repeater |
654 | picker.mode = newMode; |
655 | - wait(500); |
656 | + waitPickerMoving(); |
657 | var positioner = findChild(picker, "PickerRow_Positioner"); |
658 | compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
659 | - |
660 | - picker.mode = "Years|Months|Days"; |
661 | - pickerCount = 3 + 1; // +1 is the Repeater |
662 | - compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
663 | } |
664 | |
665 | function test_1_changeModeMinute() { |
666 | var newMode = "Minutes"; |
667 | var pickerCount = 1 + 1; // +1 is the Repeater |
668 | picker.mode = newMode; |
669 | - wait(500); |
670 | + waitPickerMoving(); |
671 | var positioner = findChild(picker, "PickerRow_Positioner"); |
672 | compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
673 | - |
674 | - picker.mode = "Years|Months|Days"; |
675 | - pickerCount = 3 + 1; // +1 is the Repeater |
676 | - compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
677 | } |
678 | |
679 | function test_1_changeModeS() { |
680 | var newMode = "Seconds"; |
681 | var pickerCount = 1 + 1; // +1 is the Repeater |
682 | picker.mode = newMode; |
683 | - wait(500); |
684 | + waitPickerMoving(); |
685 | var positioner = findChild(picker, "PickerRow_Positioner"); |
686 | compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
687 | - |
688 | - picker.mode = "Years|Months|Days"; |
689 | - pickerCount = 3 + 1; // +1 is the Repeater |
690 | - compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
691 | } |
692 | |
693 | function test_1_changeModeYMDHMS() { |
694 | var newMode = "Years|Months|Days|Hours|Minutes|Seconds"; |
695 | var pickerCount = 6 + 1; // +1 is the Repeater |
696 | picker.mode = newMode; |
697 | - wait(500); |
698 | + waitPickerMoving(); |
699 | var positioner = findChild(picker, "PickerRow_Positioner"); |
700 | expectFailContinue("", "cannot combine date and time pickers"); |
701 | compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
702 | - |
703 | - picker.mode = "Years|Months|Days"; |
704 | - pickerCount = 3 + 1; // +1 is the Repeater |
705 | - compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
706 | } |
707 | |
708 | function test_1_changeModeYH() { |
709 | var newMode = "Years|Hours"; |
710 | var pickerCount = 2 + 1; // +1 is the Repeater |
711 | picker.mode = newMode; |
712 | - wait(500); |
713 | + waitPickerMoving(); |
714 | var positioner = findChild(picker, "PickerRow_Positioner"); |
715 | expectFailContinue("", "cannot combine date and time pickers"); |
716 | compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
717 | - |
718 | - picker.mode = "Years|Months|Days"; |
719 | - pickerCount = 3 + 1; // +1 is the Repeater |
720 | - compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
721 | } |
722 | |
723 | function test_1_changeModeUnhandled() { |
724 | var newMode = "Years|Whatever"; |
725 | var pickerCount = 2 + 1; // +1 is the Repeater |
726 | picker.mode = newMode; |
727 | - wait(500); |
728 | + // no rendering is expected, no need to wait |
729 | var positioner = findChild(picker, "PickerRow_Positioner"); |
730 | expectFailContinue("", "unhandled mode flag should not pass"); |
731 | compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
732 | - |
733 | - picker.mode = "Years|Months|Days"; |
734 | - pickerCount = 3 + 1; // +1 is the Repeater |
735 | - compare(positioner.children.length, pickerCount, "invalid amount of pickers"); |
736 | } |
737 | |
738 | function test_1_changeLocale() { |
739 | @@ -328,16 +250,14 @@ |
740 | var locale = Qt.locale("hu_HU"); |
741 | picker.minimum = new Date(2012, 11, 1); |
742 | picker.date = new Date(2012, 11, 1); |
743 | - wait(500) |
744 | picker.locale = Qt.locale("hu_HU"); |
745 | - wait(500) |
746 | + waitPickerMoving(); |
747 | var label = getPickerLabel(picker, "PickerRow_MonthPicker"); |
748 | compare(label.text, locale.monthName(picker.date.getMonth(), Locale.LongFormat), "locale for month wrong"); |
749 | |
750 | label = getPickerLabel(picker, "PickerRow_DayPicker"); |
751 | var dayModel = getPickerModel(picker, "PickerRow_DayPicker"); |
752 | compare(label.text, dayModel.text(picker.date.getDate() - 1, testSuite.width), "locale for day name wrong"); |
753 | - picker.locale = prevLocale; |
754 | } |
755 | |
756 | function test_1_changeMinimumBeforeDate() { |
757 | @@ -346,7 +266,8 @@ |
758 | date.setFullYear(date.getFullYear() - 1); |
759 | date.setDate(1); |
760 | picker.minimum = date; |
761 | - wait(500); |
762 | + // no rendering is expected, so no need to wait |
763 | + |
764 | var year = getPickerLabel(picker, "PickerRow_YearPicker"); |
765 | compare(year.text, originalDate.getFullYear().toString(), "year differs"); |
766 | var month = getPickerLabel(picker, "PickerRow_MonthPicker"); |
767 | @@ -362,7 +283,7 @@ |
768 | date.setFullYear(date.getFullYear() + 1); |
769 | date.setDate(1); |
770 | picker.maximum = date; |
771 | - wait(500); |
772 | + waitPickerMoving(); |
773 | var year = getPickerLabel(picker, "PickerRow_YearPicker"); |
774 | compare(year.text, originalDate.getFullYear().toString(), "year differs"); |
775 | var month = getPickerLabel(picker, "PickerRow_MonthPicker"); |
776 | @@ -375,26 +296,27 @@ |
777 | // make infinite |
778 | function test_1_changeMinimumInvalid() { |
779 | picker.minimum = Date.prototype.getInvalidDate.call(); |
780 | + // no rendering is expected |
781 | compare(picker.minimum, picker.date, "invalid minimum hasn't been adjusted to date"); |
782 | } |
783 | |
784 | // make infinite |
785 | function test_1_changeMaximumInvalid() { |
786 | picker.maximum = Date.prototype.getInvalidDate.call(); |
787 | - |
788 | + waitPickerMoving(); |
789 | // check if the year picker model is autoExtending |
790 | var yearModel = getPickerModel(picker, "PickerRow_YearPicker"); |
791 | compare(yearModel.autoExtend, true, "the year picker is not auto-extending one"); |
792 | } |
793 | |
794 | function test_1_changeDate() { |
795 | - var date = picker.date; |
796 | - date.setFullYear(date.getFullYear() + 2); |
797 | + var date = new Date(); |
798 | + date.setFullYear(picker.date.getFullYear() + 2); |
799 | date.setMonth(5); |
800 | date.setDate(21); |
801 | picker.date = date; |
802 | picker.mode = "Years|Months|Days"; |
803 | - wait(500); |
804 | + waitPickerMoving(); |
805 | |
806 | var yearLabel = getPickerLabel(picker, "PickerRow_YearPicker"); |
807 | var monthLabel = getPickerLabel(picker, "PickerRow_MonthPicker"); |
808 | @@ -410,15 +332,15 @@ |
809 | picker.minimum = new Date(2013, 9, 1); |
810 | picker.date = new Date(2013, 09, 31); |
811 | picker.locale = Qt.locale("hu_HU") |
812 | - wait(500); |
813 | + waitPickerMoving(); |
814 | |
815 | // click on the month picker to set the next month |
816 | var monthPicker = findChild(picker, "PickerRow_MonthPicker"); |
817 | var monthCurrent = findChild(monthPicker, "Picker_ViewLoader"); |
818 | var my = monthPicker.y + (monthPicker.height / 2) + monthCurrent.item.currentItem.height; |
819 | var mx = monthPicker.x + monthPicker.width / 2; |
820 | - mouseClick(testSuite, mx, my); |
821 | - wait(500); |
822 | + mouseClick(picker, mx, my); |
823 | + waitPickerMoving(); |
824 | |
825 | var yearLabel = getPickerLabel(picker, "PickerRow_YearPicker"); |
826 | var monthLabel = getPickerLabel(picker, "PickerRow_MonthPicker"); |
827 | @@ -433,8 +355,8 @@ |
828 | |
829 | // set it back |
830 | my = monthPicker.y + (monthPicker.height / 2) - monthCurrent.item.currentItem.height; |
831 | - mouseClick(testSuite, mx, my); |
832 | - wait(500); |
833 | + mouseClick(picker, mx, my); |
834 | + waitPickerMoving(); |
835 | |
836 | compare(yearLabel.text, "2013", "different year value"); |
837 | // October |
838 | @@ -451,8 +373,9 @@ |
839 | var maxDate = new Date(2013, 11, 31); |
840 | picker.minimum = minDate; |
841 | picker.maximum = maxDate; |
842 | - wait(500); |
843 | + waitPickerMoving(); |
844 | picker.date = date; |
845 | + waitPickerMoving(); |
846 | |
847 | var yearPicker = findChild(picker, "PickerRow_YearPicker"); |
848 | compare(yearPicker.enabled, false, "year picker should be disabled"); |
849 | @@ -465,6 +388,7 @@ |
850 | picker.minimum = minDate; |
851 | picker.maximum = maxDate; |
852 | picker.date = date; |
853 | + waitPickerMoving(); |
854 | |
855 | var yearPicker = findChild(picker, "PickerRow_YearPicker"); |
856 | compare(yearPicker.enabled, false, "year picker should be disabled"); |
857 | @@ -491,10 +415,11 @@ |
858 | |
859 | function test_3_changeHours() { |
860 | picker.mode = "Hours|Minutes|Seconds"; |
861 | + waitPickerMoving(); |
862 | var date = new Date(picker.date); |
863 | date.setHours((date.getHours() + 10) % 24); |
864 | picker.date = date; |
865 | - wait(500); |
866 | + waitPickerMoving(); |
867 | |
868 | var hoursLabel = getPickerLabel(picker, "PickerRow_HoursPicker"); |
869 | verify(hoursLabel, "hour label undefined"); |
870 | @@ -512,7 +437,7 @@ |
871 | var date = new Date(picker.date); |
872 | date.setMinutes((date.getMinutes() + 40) % 60); |
873 | picker.date = date; |
874 | - wait(500); |
875 | + waitPickerMoving(); |
876 | |
877 | var hoursLabel = getPickerLabel(picker, "PickerRow_HoursPicker"); |
878 | verify(hoursLabel, "hour label undefined"); |
879 | @@ -530,7 +455,7 @@ |
880 | var date = new Date(picker.date); |
881 | date.setSeconds((date.getSeconds() + 50) % 60); |
882 | picker.date = date; |
883 | - wait(500); |
884 | + waitPickerMoving(); |
885 | |
886 | var hoursLabel = getPickerLabel(picker, "PickerRow_HoursPicker"); |
887 | verify(hoursLabel, "hour label undefined"); |
888 | @@ -550,7 +475,7 @@ |
889 | date.setFullYear(date.getFullYear() - 1); |
890 | date.setDate(1); |
891 | picker.minimum = date; |
892 | - wait(500); |
893 | + waitPickerMoving(); |
894 | |
895 | var hoursLabel = getPickerLabel(picker, "PickerRow_HoursPicker"); |
896 | verify(hoursLabel, "hour label undefined"); |
897 | @@ -570,7 +495,7 @@ |
898 | date.setFullYear(date.getFullYear() + 1); |
899 | date.setDate(1); |
900 | picker.maximum = date; |
901 | - wait(500); |
902 | + waitPickerMoving(); |
903 | var hoursLabel = getPickerLabel(picker, "PickerRow_HoursPicker"); |
904 | verify(hoursLabel, "hour label undefined"); |
905 | compare(hoursLabel.text, ("00" + originalDate.getHours()).slice(-2), "hours differ"); |
906 | @@ -583,12 +508,13 @@ |
907 | } |
908 | |
909 | function test_4_disabledHour() { |
910 | + picker.mode = "Hours|Minutes|Seconds"; |
911 | var date = setHMS(new Date(), 12, 10, 45); |
912 | var minDate = setHMS(new Date(), 12, 0, 0); |
913 | var maxDate = setHMS(new Date(), 12, 59, 59); |
914 | picker.minimum = minDate; |
915 | picker.maximum = maxDate; |
916 | - wait(500); |
917 | + waitPickerMoving(); |
918 | picker.date = date; |
919 | |
920 | var hoursPicker = findChild(picker, "PickerRow_HoursPicker"); |
921 | @@ -596,13 +522,14 @@ |
922 | } |
923 | |
924 | function test_4_disabledHoursAndMinutes() { |
925 | + picker.mode = "Hours|Minutes|Seconds"; |
926 | var date = setHMS(new Date(), 12, 10, 45); |
927 | var minDate = setHMS(new Date(), 12, 10, 0); |
928 | var maxDate = setHMS(new Date(), 12, 10, 59); |
929 | picker.minimum = minDate; |
930 | picker.maximum = maxDate; |
931 | picker.date = date; |
932 | - wait(500); |
933 | + waitPickerMoving(); |
934 | |
935 | var hoursPicker = findChild(picker, "PickerRow_HoursPicker"); |
936 | compare(hoursPicker.enabled, false, "hours picker should be disabled"); |
937 | @@ -611,13 +538,14 @@ |
938 | } |
939 | |
940 | function test_4_linearSecondsPicker() { |
941 | + picker.mode = "Hours|Minutes|Seconds"; |
942 | var date = setHMS(new Date(), 12, 10, 45); |
943 | var minDate = setHMS(new Date(), 12, 10, 1); |
944 | var maxDate = setHMS(new Date(), 12, 10, 59); |
945 | picker.minimum = minDate; |
946 | picker.maximum = maxDate; |
947 | picker.date = date; |
948 | - wait(500); |
949 | + waitPickerMoving(); |
950 | |
951 | var hoursPicker = findChild(picker, "PickerRow_HoursPicker"); |
952 | compare(hoursPicker.enabled, false, "hours picker should be disabled"); |
PASSED: Continuous integration, rev:970 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- ci/1840/ jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty/ 3708 jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty- touch/3299 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- trusty- amd64-ci/ 788 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- trusty- armhf-ci/ 788 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- trusty- armhf-ci/ 788/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ autopilot- testrunner- otto-trusty/ 3258 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- amd64/3713 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- amd64/3713/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- armhf/3301 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- armhf/3301/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- runner- mako/5669 s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 4520
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: s-jenkins. ubuntu- ci:8080/ job/ubuntu- ui-toolkit- ci/1840/ rebuild
http://