Merge lp:~canonical-platform-qa/ubuntu-ui-toolkit/fix1384703-flickable_infinite_loop into lp:ubuntu-ui-toolkit

Proposed by Leo Arias
Status: Superseded
Proposed branch: lp:~canonical-platform-qa/ubuntu-ui-toolkit/fix1384703-flickable_infinite_loop
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 807 lines (+473/-103) (has conflicts)
10 files modified
debian/changelog (+13/-0)
modules/Ubuntu/Components/Themes/Ambiance/PageHeadStyle.qml (+6/-0)
modules/Ubuntu/Test/UbuntuTestCase.qml (+71/-72)
po/cs.po (+135/-0)
po/ubuntu-ui-toolkit.pot (+11/-3)
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py (+11/-9)
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/listitems.py (+42/-0)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py (+53/-3)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_listitems.ExpandableTestCase.qml (+66/-0)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_listitems.py (+65/-16)
Text conflict in debian/changelog
Text conflict in po/cs.po
To merge this branch: bzr merge lp:~canonical-platform-qa/ubuntu-ui-toolkit/fix1384703-flickable_infinite_loop
Reviewer Review Type Date Requested Status
Ubuntu SDK team Pending
Review via email: mp+239365@code.launchpad.net

This proposal has been superseded by a proposal from 2014-10-23.

To post a comment you must log in.
1306. By Leo Arias

Reordered the comment.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2014-10-16 13:01:01 +0000
3+++ debian/changelog 2014-10-23 13:41:08 +0000
4@@ -1,3 +1,4 @@
5+<<<<<<< TREE
6 ubuntu-ui-toolkit (1.1.1298+14.10.20141016.1-0ubuntu1) 14.09; urgency=medium
7
8 [ Jussi Pakkanen]
9@@ -93,6 +94,18 @@
10
11 -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Tue, 14 Oct 2014 14:40:58 +0000
12
13+=======
14+ubuntu-ui-toolkit (1.1.1279.1+14.10.20141014-0ubuntu1) 14.09; urgency=low
15+
16+ [ Ubuntu daily release ]
17+ * New rebuild forced
18+
19+ [ Tim Peeters ]
20+ * Fix margins in header contents.
21+
22+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Tue, 14 Oct 2014 14:40:58 +0000
23+
24+>>>>>>> MERGE-SOURCE
25 ubuntu-ui-toolkit (1.1.1279+14.10.20141007-0ubuntu1) 14.09; urgency=medium
26
27 [ Michael Sheldon ]
28
29=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/PageHeadStyle.qml'
30--- modules/Ubuntu/Components/Themes/Ambiance/PageHeadStyle.qml 2014-10-16 11:43:24 +0000
31+++ modules/Ubuntu/Components/Themes/Ambiance/PageHeadStyle.qml 2014-10-23 13:41:08 +0000
32@@ -41,6 +41,11 @@
33 readonly property bool animating: headerStyle.state == "OUT"
34 || leftAnchor.anchors.leftMargin < 0
35
36+ // for Unity8
37+ // FIXME: Remove this property when we introduce a header preset that does not
38+ // have a separator.
39+ property alias __separator_visible: separator.visible
40+
41 BorderImage {
42 id: separator
43 anchors {
44@@ -123,6 +128,7 @@
45 right: parent.right
46 }
47 source: headerStyle.separatorBottomSource
48+ visible: separator.visible
49 }
50
51 states: [
52
53=== modified file 'modules/Ubuntu/Test/UbuntuTestCase.qml'
54--- modules/Ubuntu/Test/UbuntuTestCase.qml 2014-10-07 14:52:27 +0000
55+++ modules/Ubuntu/Test/UbuntuTestCase.qml 2014-10-23 13:41:08 +0000
56@@ -1,5 +1,5 @@
57 /*
58- * Copyright 2012 Canonical Ltd.
59+ * Copyright 2012, 2014 Canonical Ltd.
60 *
61 * This program is free software; you can redistribute it and/or modify
62 * it under the terms of the GNU Lesser General Public License as published by
63@@ -29,45 +29,45 @@
64 This class extends the default QML TestCase class which is available in QtTest 1.0.
65 */
66 TestCase {
67- TestUtil {
68- id:util
69- }
70+ TestUtil {
71+ id:util
72+ }
73
74- /*!
75- Find a child from the item based on the objectName.
76- */
77- function findChild(obj,objectName) {
78- var childs = new Array(0);
79- childs.push(obj)
80- while (childs.length > 0) {
81- if (childs[0].objectName == objectName) {
82- return childs[0]
83- }
84- for (var i in childs[0].children) {
85- childs.push(childs[0].children[i])
86- }
87- childs.splice(0, 1);
88- }
89- return null;
90- }
91+ /*!
92+ Find a child from the item based on the objectName.
93+ */
94+ function findChild(obj,objectName) {
95+ var childs = new Array(0);
96+ childs.push(obj)
97+ while (childs.length > 0) {
98+ if (childs[0].objectName == objectName) {
99+ return childs[0]
100+ }
101+ for (var i in childs[0].children) {
102+ childs.push(childs[0].children[i])
103+ }
104+ childs.splice(0, 1);
105+ }
106+ return null;
107+ }
108
109 /*!
110 Find a non-visual child such as QtObject based on objectName.
111 */
112- function findInvisibleChild(obj,objectName) {
113- var childs = new Array(0);
114- childs.push(obj)
115- while (childs.length > 0) {
116- if (childs[0].objectName == objectName) {
117- return childs[0]
118- }
119- for (var i in childs[0].data) {
120- childs.push(childs[0].data[i])
121- }
122- childs.splice(0, 1);
123- }
124- return null;
125- }
126+ function findInvisibleChild(obj,objectName) {
127+ var childs = new Array(0);
128+ childs.push(obj)
129+ while (childs.length > 0) {
130+ if (childs[0].objectName == objectName) {
131+ return childs[0]
132+ }
133+ for (var i in childs[0].data) {
134+ childs.push(childs[0].data[i])
135+ }
136+ childs.splice(0, 1);
137+ }
138+ return null;
139+ }
140
141 /*!
142 Finds a visible child of an \a item having a given \a property with a given
143@@ -194,44 +194,43 @@
144 }
145
146 /*!
147- Keeps executing a given parameter-less function until it returns the given
148- expected result or the timemout is reached (in which case a test failure
149- is generated)
150- */
151+ Keeps executing a given parameter-less function until it returns the given
152+ expected result or the timemout is reached (in which case a test failure
153+ is generated)
154+ */
155
156- function tryCompareFunction(func, expectedResult, timeout) {
157- var timeSpent = 0
158- var success = false
159- var actualResult
160- if (timeout == undefined) {
161+ function tryCompareFunction(func, expectedResult, timeout) {
162+ var timeSpent = 0
163+ var success = false
164+ var actualResult
165+ if (timeout == undefined) {
166 timeout = 5000;
167 }
168- while (timeSpent < timeout && !success) {
169- actualResult = func()
170- success = qtest_compareInternal(actualResult, expectedResult)
171- if (success === false) {
172- wait(50)
173- timeSpent += 50
174- }
175- }
176-
177- var act = qtest_results.stringify(actualResult)
178- var exp = qtest_results.stringify(expectedResult)
179- if (!qtest_results.compare(success,
180- "function returned unexpected result",
181- act, exp,
182- util.callerFile(), util.callerLine())) {
183- throw new Error("QtQuickTest::fail")
184- }
185- }
186-
187- /*!
188- Convenience function to allow typing a full string instead of single characters
189- */
190- function typeString(string) {
191- for (var i = 0; i < string.length; i++) {
192- keyClick(string[i]);
193- }
194- }
195+ while (timeSpent < timeout && !success) {
196+ actualResult = func()
197+ success = qtest_compareInternal(actualResult, expectedResult)
198+ if (success === false) {
199+ wait(50)
200+ timeSpent += 50
201+ }
202+ }
203+
204+ var act = qtest_results.stringify(actualResult)
205+ var exp = qtest_results.stringify(expectedResult)
206+ if (!qtest_results.compare(success,
207+ "function returned unexpected result",
208+ act, exp,
209+ util.callerFile(), util.callerLine())) {
210+ throw new Error("QtQuickTest::fail")
211+ }
212+ }
213+
214+ /*!
215+ Convenience function to allow typing a full string instead of single characters
216+ */
217+ function typeString(string) {
218+ for (var i = 0; i < string.length; i++) {
219+ keyClick(string[i]);
220+ }
221+ }
222 }
223-
224
225=== modified file 'po/cs.po'
226--- po/cs.po 2014-10-23 07:24:16 +0000
227+++ po/cs.po 2014-10-23 13:41:08 +0000
228@@ -1,3 +1,4 @@
229+<<<<<<< TREE
230 # Czech translation for ubuntu-ui-toolkit
231 # Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014
232 # This file is distributed under the same license as the ubuntu-ui-toolkit package.
233@@ -130,3 +131,137 @@
234 #: Ubuntu/Components/Themes/Ambiance/PullToRefreshStyle.qml:28
235 msgid "Pull to refresh..."
236 msgstr ""
237+=======
238+# Czech translation for ubuntu-ui-toolkit
239+# Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014
240+# This file is distributed under the same license as the ubuntu-ui-toolkit package.
241+# FIRST AUTHOR <EMAIL@ADDRESS>, 2014.
242+#
243+msgid ""
244+msgstr ""
245+"Project-Id-Version: ubuntu-ui-toolkit\n"
246+"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
247+"POT-Creation-Date: 2014-09-01 19:02+0200\n"
248+"PO-Revision-Date: 2014-10-12 19:03+0000\n"
249+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
250+"Language-Team: Czech <cs@li.org>\n"
251+"MIME-Version: 1.0\n"
252+"Content-Type: text/plain; charset=UTF-8\n"
253+"Content-Transfer-Encoding: 8bit\n"
254+"X-Launchpad-Export-Date: 2014-10-13 06:11+0000\n"
255+"X-Generator: Launchpad (build 17196)\n"
256+
257+#: Ubuntu/Components/plugin/statesaverbackend_p.cpp:154
258+#, qt-format
259+msgid ""
260+"property \"%1\" of object %2 has type %3 and cannot be set to value \"%4\" "
261+"of type %5"
262+msgstr ""
263+
264+#: Ubuntu/Components/plugin/statesaverbackend_p.cpp:163
265+#, qt-format
266+msgid "property \"%1\" does not exist or is not writable for object %2"
267+msgstr ""
268+
269+#: Ubuntu/Components/plugin/ucalarm.cpp:42
270+#: Ubuntu/Components/plugin/ucalarm.cpp:136
271+msgid "Alarm"
272+msgstr ""
273+
274+#: Ubuntu/Components/plugin/ucalarm.cpp:684
275+#: Ubuntu/Components/plugin/ucalarm.cpp:716
276+msgid "Alarm has a pending operation."
277+msgstr ""
278+
279+#: Ubuntu/Components/plugin/ucarguments.cpp:188
280+msgid "Usage: "
281+msgstr ""
282+
283+#: Ubuntu/Components/plugin/ucarguments.cpp:209
284+msgid "Options:"
285+msgstr ""
286+
287+#: Ubuntu/Components/plugin/ucarguments.cpp:498
288+#, qt-format
289+msgid "%1 is expecting an additional argument: %2"
290+msgstr ""
291+
292+#: Ubuntu/Components/plugin/ucarguments.cpp:503
293+#, qt-format
294+msgid "%1 is expecting a value for argument: %2"
295+msgstr ""
296+
297+#: Ubuntu/Components/plugin/ucarguments.cpp:520
298+#, qt-format
299+msgid "%1 is expecting additional arguments: %2"
300+msgstr ""
301+
302+#: Ubuntu/Components/plugin/ucmousefilters.cpp:1064
303+msgid "Ignoring AfterItem priority for InverseMouse filters."
304+msgstr ""
305+
306+#: Ubuntu/Components/plugin/ucstatesaver.cpp:46
307+msgid "Warning: attachee must have an ID. State will not be saved."
308+msgstr ""
309+
310+#: Ubuntu/Components/plugin/ucstatesaver.cpp:56
311+#, qt-format
312+msgid ""
313+"Warning: attachee's UUID is already registered, state won't be saved: %1"
314+msgstr ""
315+
316+#: Ubuntu/Components/plugin/ucstatesaver.cpp:102
317+#, qt-format
318+msgid ""
319+"All the parents must have an id.\n"
320+"State saving disabled for %1, class %2"
321+msgstr ""
322+
323+#: Ubuntu/Components/plugin/uctheme.cpp:233
324+msgid "Theme not found: "
325+msgstr ""
326+
327+#: Ubuntu/Components/Popups/ComposerSheet.qml:80
328+msgid "Cancel"
329+msgstr ""
330+
331+#: Ubuntu/Components/Popups/ComposerSheet.qml:90
332+msgid "Confirm"
333+msgstr ""
334+
335+#: Ubuntu/Components/Popups/DefaultSheet.qml:89
336+msgid "Close"
337+msgstr ""
338+
339+#: Ubuntu/Components/Popups/DefaultSheet.qml:99
340+msgid "Done"
341+msgstr ""
342+
343+#: Ubuntu/Components/TextInputPopover.qml:27
344+msgid "Select All"
345+msgstr ""
346+
347+#: Ubuntu/Components/TextInputPopover.qml:33
348+msgid "Cut"
349+msgstr ""
350+
351+#: Ubuntu/Components/TextInputPopover.qml:42
352+msgid "Copy"
353+msgstr ""
354+
355+#: Ubuntu/Components/TextInputPopover.qml:49
356+msgid "Paste"
357+msgstr ""
358+
359+#: Ubuntu/Components/Themes/Ambiance/ProgressBarStyle.qml:57
360+msgid "In Progress"
361+msgstr ""
362+
363+#: Ubuntu/Components/Themes/Ambiance/PullToRefreshStyle.qml:28
364+msgid "Release to refresh..."
365+msgstr ""
366+
367+#: Ubuntu/Components/Themes/Ambiance/PullToRefreshStyle.qml:28
368+msgid "Pull to refresh..."
369+msgstr ""
370+>>>>>>> MERGE-SOURCE
371
372=== modified file 'po/ubuntu-ui-toolkit.pot'
373--- po/ubuntu-ui-toolkit.pot 2014-09-01 17:02:40 +0000
374+++ po/ubuntu-ui-toolkit.pot 2014-10-23 13:41:08 +0000
375@@ -8,7 +8,7 @@
376 msgstr ""
377 "Project-Id-Version: ubuntu-ui-toolkit\n"
378 "Report-Msgid-Bugs-To: \n"
379-"POT-Creation-Date: 2014-09-01 19:02+0200\n"
380+"POT-Creation-Date: 2014-10-20 10:20-0400\n"
381 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
382 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
383 "Language-Team: LANGUAGE <LL@li.org>\n"
384@@ -17,14 +17,18 @@
385 "Content-Type: text/plain; charset=CHARSET\n"
386 "Content-Transfer-Encoding: 8bit\n"
387
388-#: Ubuntu/Components/plugin/statesaverbackend_p.cpp:154
389+#: Ubuntu/Components/ListItems/Empty.qml:413
390+msgid "Delete"
391+msgstr ""
392+
393+#: Ubuntu/Components/plugin/statesaverbackend_p.cpp:176
394 #, qt-format
395 msgid ""
396 "property \"%1\" of object %2 has type %3 and cannot be set to value \"%4\" "
397 "of type %5"
398 msgstr ""
399
400-#: Ubuntu/Components/plugin/statesaverbackend_p.cpp:163
401+#: Ubuntu/Components/plugin/statesaverbackend_p.cpp:185
402 #, qt-format
403 msgid "property \"%1\" does not exist or is not writable for object %2"
404 msgstr ""
405@@ -130,3 +134,7 @@
406 #: Ubuntu/Components/Themes/Ambiance/PullToRefreshStyle.qml:28
407 msgid "Pull to refresh..."
408 msgstr ""
409+
410+#: Ubuntu/Components/ToolbarItems.qml:142
411+msgid "Back"
412+msgstr ""
413
414=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py'
415--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py 2014-08-03 03:06:54 +0000
416+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py 2014-10-23 13:41:08 +0000
417@@ -77,15 +77,20 @@
418 def _slow_drag(self, start_x, stop_x, start_y, stop_y):
419 # If we drag too fast, we end up scrolling more than what we
420 # should, sometimes missing the element we are looking for.
421+ original_content_y = self.contentY
422+
423 # I found that when the flickDeceleration is 1500, the rate should be
424 # 5 and that when it's 100, the rate should be 1. With those two points
425- # we can get that the following equation.
426+ # we can get the following equation.
427 # XXX The deceleration might not be linear with respect to the rate,
428 # but this works for the two types of scrollables we have for now.
429 # --elopio - 2014-05-08
430 rate = (self.flickDeceleration + 250) / 350
431 self.pointing_device.drag(start_x, start_y, stop_x, stop_y, rate=rate)
432
433+ if self.contentY == original_content_y:
434+ raise _common.ToolkitException('Could not swipe in the flickable.')
435+
436
437 class QQuickFlickable(Scrollable):
438
439@@ -105,7 +110,6 @@
440
441 @autopilot_logging.log_action(logger.info)
442 def _swipe_non_visible_child_into_view(self, child, containers):
443- original_content_y = self.contentY
444 while not self._is_child_visible(child, containers):
445 # Check the direction of the swipe based on the position of the
446 # child relative to the immediate flickable container.
447@@ -114,12 +118,8 @@
448 else:
449 self.swipe_to_show_more_below(containers)
450
451- if self.contentY == original_content_y:
452- raise _common.ToolkitException(
453- "Couldn't swipe in the flickable.")
454-
455 @autopilot_logging.log_action(logger.info)
456- def swipe_to_show_more_above(self, containers):
457+ def swipe_to_show_more_above(self, containers=None):
458 if self.atYBeginning:
459 raise _common.ToolkitException(
460 "Can't swipe more, we are already at the top of the "
461@@ -128,7 +128,7 @@
462 self._swipe_to_show_more('above', containers)
463
464 @autopilot_logging.log_action(logger.info)
465- def swipe_to_show_more_below(self, containers):
466+ def swipe_to_show_more_below(self, containers=None):
467 if self.atYEnd:
468 raise _common.ToolkitException(
469 "Can't swipe more, we are already at the bottom of the "
470@@ -136,7 +136,9 @@
471 else:
472 self._swipe_to_show_more('below', containers)
473
474- def _swipe_to_show_more(self, direction, containers):
475+ def _swipe_to_show_more(self, direction, containers=None):
476+ if containers is None:
477+ containers = self._get_containers()
478 start_x = stop_x = self.globalRect.x + (self.globalRect.width // 2)
479 # Start and stop just a little under the top and a little over the
480 # bottom.
481
482=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/listitems.py'
483--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/listitems.py 2014-06-16 21:26:30 +0000
484+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/listitems.py 2014-10-23 13:41:08 +0000
485@@ -108,6 +108,48 @@
486 pass
487
488
489+class Expandable(Empty):
490+
491+ @autopilot_logging.log_action(logger.info)
492+ def expand(self):
493+ """Expand an expandable list item.
494+
495+ If the item is already expanded, no action will be executed.
496+ If you want to check if the item is expanded, you can use the
497+ ``expanded`` property.
498+
499+ """
500+ if not self.expanded:
501+ self._click_always_visible_section()
502+ self.expanded.wait_for(True)
503+ self.height.wait_for(self.expandedHeight)
504+ else:
505+ logger.debug('The item is already expanded.')
506+
507+ @autopilot_logging.log_action(logger.debug)
508+ def _click_always_visible_section(self):
509+ self.pointing_device.move(
510+ self.globalRect.x + self.globalRect.width // 2,
511+ self.globalRect.y + self.collapsedHeight // 2)
512+ self.pointing_device.click()
513+
514+ @autopilot_logging.log_action(logger.info)
515+ def collapse(self):
516+ """Collapse an expandable list item.
517+
518+ If the item is already collapsed, no action will be executed.
519+ If you want to check if the item is expanded, you can use the
520+ ``expanded`` property.
521+
522+ """
523+ if self.expanded:
524+ self._click_always_visible_section()
525+ self.expanded.wait_for(False)
526+ self.height.wait_for(self.collapsedHeight)
527+ else:
528+ logger.debug('The item is already collapsed.')
529+
530+
531 class Standard(Empty):
532 pass
533
534
535=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py'
536--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py 2014-09-04 09:16:49 +0000
537+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py 2014-10-23 13:41:08 +0000
538@@ -14,10 +14,14 @@
539 # You should have received a copy of the GNU Lesser General Public License
540 # along with this program. If not, see <http://www.gnu.org/licenses/>.
541
542+try:
543+ from unittest import mock
544+except ImportError:
545+ import mock
546+
547 import testtools
548 import ubuntuuitoolkit
549 from ubuntuuitoolkit import tests
550-from ubuntuuitoolkit._custom_proxy_objects import _common
551
552
553 class FlickableTestCase(testtools.TestCase):
554@@ -27,7 +31,7 @@
555 dummy_id = (0, 0)
556 dummy_flicking = (0, 'dummy')
557 state_with_flicking = {'id': dummy_id, 'flicking': dummy_flicking}
558- element = _common.UbuntuUIToolkitCustomProxyObjectBase(
559+ element = ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase(
560 state_with_flicking, '/dummy'.encode(), 'dummy')
561
562 with element.no_automatic_refreshing():
563@@ -37,7 +41,7 @@
564 """is_flickable returns False if flickable property doesn't exist."""
565 dummy_id = (0, 0)
566 state_without_flicking = {'id': dummy_id}
567- element = _common.UbuntuUIToolkitCustomProxyObjectBase(
568+ element = ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase(
569 state_without_flicking, '/dummy'.encode(), 'dummy')
570
571 with element.no_automatic_refreshing():
572@@ -179,6 +183,52 @@
573 self.flickable.swipe_to_bottom()
574 self.assertTrue(self.flickable.atYEnd)
575
576+ def test_swipe_to_show_more_above_with_containers(self):
577+ """Swipe to show more above must receive containers as parameter."""
578+ self.flickable.swipe_to_bottom()
579+ self.assertTrue(self.flickable.atYEnd)
580+
581+ containers = self.flickable._get_containers()
582+ self.flickable.swipe_to_show_more_above(containers)
583+ self.assertFalse(self.flickable.atYEnd)
584+
585+ def test_swipe_to_show_more_above_without_arguments(self):
586+ """Calling swipe to show more above must get containers by default."""
587+ self.flickable.swipe_to_bottom()
588+ self.assertTrue(self.flickable.atYEnd)
589+
590+ self.flickable.swipe_to_show_more_above()
591+ self.assertFalse(self.flickable.atYEnd)
592+
593+ def test_swipe_to_show_more_below_with_containers(self):
594+ """Swipe to show more below must receive containers as parameter."""
595+ self.flickable.swipe_to_top()
596+ self.assertTrue(self.flickable.atYBeginning)
597+
598+ containers = self.flickable._get_containers()
599+ self.flickable.swipe_to_show_more_below(containers)
600+ self.assertFalse(self.flickable.atYBeginning)
601+
602+ def test_swipe_to_show_more_below_without_arguments(self):
603+ """Calling swipe to show more below must get containers by default."""
604+ self.flickable.swipe_to_top()
605+ self.assertTrue(self.flickable.atYBeginning)
606+
607+ self.flickable.swipe_to_show_more_below()
608+ self.assertFalse(self.flickable.atYBeginning)
609+
610+ def test_failed_drag_must_raise_exception(self):
611+ dummy_coordinates = (0, 0, 10, 10)
612+ # Patch the pointing device so it does nothing and the swipe fails.
613+ with mock.patch.object(self.flickable, 'pointing_device'):
614+ error = self.assertRaises(
615+ ubuntuuitoolkit.ToolkitException,
616+ self.flickable._slow_drag,
617+ *dummy_coordinates
618+ )
619+
620+ self.assertEqual('Could not swipe in the flickable.', str(error))
621+
622
623 class UnityFlickableTestCase(tests.QMLStringAppTestCase):
624
625
626=== added file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_listitems.ExpandableTestCase.qml'
627--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_listitems.ExpandableTestCase.qml 1970-01-01 00:00:00 +0000
628+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_listitems.ExpandableTestCase.qml 2014-10-23 13:41:08 +0000
629@@ -0,0 +1,66 @@
630+/*
631+ * Copyright 2014 Canonical Ltd.
632+ *
633+ * This program is free software; you can redistribute it and/or modify
634+ * it under the terms of the GNU Lesser General Public License as published by
635+ * the Free Software Foundation; version 3.
636+ *
637+ * This program is distributed in the hope that it will be useful,
638+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
639+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
640+ * GNU Lesser General Public License for more details.
641+ *
642+ * You should have received a copy of the GNU Lesser General Public License
643+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
644+ */
645+
646+import QtQuick 2.0
647+import Ubuntu.Components 1.1
648+import Ubuntu.Components.ListItems 0.1
649+
650+
651+MainView {
652+ width: units.gu(48)
653+ height: units.gu(60)
654+
655+
656+ Column {
657+ anchors.fill: parent
658+
659+ Repeater {
660+ model: 2
661+ Expandable {
662+ id: expandingItem
663+ objectName: "expandable" + index
664+ expandedHeight: contentCol.height + units.gu(1)
665+
666+ onClicked: {
667+ expanded = !expanded;
668+ }
669+
670+ Column {
671+ id: contentCol
672+ anchors { left: parent.left; right: parent.right }
673+ Item {
674+ anchors { left: parent.left; right: parent.right}
675+ height: expandingItem.collapsedHeight
676+ Label {
677+ anchors {
678+ left: parent.left
679+ right: parent.right
680+ verticalCenter: parent.verticalCenter
681+ }
682+ text: "Item " + index
683+ }
684+ }
685+
686+ UbuntuShape {
687+ objectName: "shape" + index
688+ anchors { left: parent.left; right: parent.right }
689+ height: units.gu(6)
690+ }
691+ }
692+ }
693+ }
694+ }
695+}
696
697=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_listitems.py'
698--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_listitems.py 2014-06-12 22:56:48 +0000
699+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_listitems.py 2014-10-23 13:41:08 +0000
700@@ -14,15 +14,43 @@
701 # You should have received a copy of the GNU Lesser General Public License
702 # along with this program. If not, see <http://www.gnu.org/licenses/>.
703
704+try:
705+ from unittest import mock
706+except ImportError:
707+ import mock
708+
709 import logging
710+import os
711
712 import fixtures
713+import testtools
714 from testtools.matchers import Contains
715
716 import ubuntuuitoolkit
717 from ubuntuuitoolkit import listitems, tests
718
719
720+class ListItemsTestCase(testtools.TestCase):
721+
722+ def test_supported_class(self):
723+ self.assertTrue(issubclass(
724+ listitems.Base, listitems.Empty))
725+ self.assertTrue(issubclass(
726+ listitems.Expandable, listitems.Empty))
727+ self.assertTrue(issubclass(
728+ listitems.ItemSelector, listitems.Empty))
729+ self.assertTrue(issubclass(
730+ listitems.Standard, listitems.Empty))
731+ self.assertTrue(issubclass(
732+ listitems.SingleControl, listitems.Empty))
733+ self.assertTrue(issubclass(
734+ listitems.MultiValue, listitems.Base))
735+ self.assertTrue(issubclass(
736+ listitems.SingleValue, listitems.Base))
737+ self.assertTrue(issubclass(
738+ listitems.Subtitled, listitems.Base))
739+
740+
741 class SwipeToDeleteTestCase(tests.QMLStringAppTestCase):
742
743 test_qml = ("""
744@@ -97,22 +125,6 @@
745 listitems.Standard, objectName='listitem_standard')
746 self.assertTrue(self._item.exists())
747
748- def test_supported_class(self):
749- self.assertTrue(issubclass(
750- listitems.Base, listitems.Empty))
751- self.assertTrue(issubclass(
752- listitems.ItemSelector, listitems.Empty))
753- self.assertTrue(issubclass(
754- listitems.Standard, listitems.Empty))
755- self.assertTrue(issubclass(
756- listitems.SingleControl, listitems.Empty))
757- self.assertTrue(issubclass(
758- listitems.MultiValue, listitems.Base))
759- self.assertTrue(issubclass(
760- listitems.SingleValue, listitems.Base))
761- self.assertTrue(issubclass(
762- listitems.Subtitled, listitems.Base))
763-
764 def test_standard_custom_proxy_object(self):
765 self.assertIsInstance(self._item, listitems.Standard)
766
767@@ -185,3 +197,40 @@
768 objectName='listitem_destroyed_on_remove_without_confirm')
769 item.swipe_to_delete()
770 self.assertFalse(item.exists())
771+
772+
773+class ExpandableTestCase(tests.QMLFileAppTestCase):
774+
775+ path = os.path.abspath(__file__)
776+ dir_path = os.path.dirname(path)
777+ test_qml_file_path = os.path.join(
778+ dir_path, 'test_listitems.ExpandableTestCase.qml')
779+
780+ def setUp(self):
781+ super(ExpandableTestCase, self).setUp()
782+ self.test_expandable = self.main_view.select_single(
783+ listitems.Expandable, objectName='expandable0')
784+
785+ def test_expand_item(self):
786+ self.test_expandable.expand()
787+ self.assertTrue(self.test_expandable.expanded)
788+
789+ def test_expand_already_expanded_item_must_do_nothing(self):
790+ self.test_expandable.expand()
791+
792+ # Replace the pointer with None, so we make sure it's not being called.
793+ with mock.patch.object(self.test_expandable, 'pointing_device', None):
794+ self.test_expandable.expand()
795+
796+ def test_collapse_item(self):
797+ self.test_expandable.expand()
798+
799+ self.test_expandable.collapse()
800+ self.assertFalse(self.test_expandable.expanded)
801+
802+ def test_collapse_already_collapsed_item_must_do_nothing(self):
803+ self.test_expandable.collapse()
804+
805+ # Replace the pointer with None, so we make sure it's not being called.
806+ with mock.patch.object(self.test_expandable, 'pointing_device', None):
807+ self.test_expandable.collapse()

Subscribers

People subscribed via source and target branches

to status/vote changes: