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

Proposed by Leo Arias
Status: Merged
Approved by: Cris Dywan
Approved revision: 1306
Merged at revision: 1306
Proposed branch: lp:~canonical-platform-qa/ubuntu-ui-toolkit/fix1384703-flickable_infinite_loop
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 100 lines (+25/-9)
2 files modified
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py (+6/-6)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py (+19/-3)
To merge this branch: bzr merge lp:~canonical-platform-qa/ubuntu-ui-toolkit/fix1384703-flickable_infinite_loop
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Cris Dywan Approve
Chris Gagnon (community) Approve
Review via email: mp+239366@code.launchpad.net

This proposal supersedes a proposal from 2014-10-23.

Commit message

Fixed the infinite loop when running flickable tests.

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

Reordered the comment.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Gagnon (chris.gagnon) wrote :

lgtm

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

Two crashes on this run made it fail. The test added works.

Revision history for this message
Cris Dywan (kalikiana) wrote :

Good to see this addressed, as I actually got a branch failing due to this now.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py'
2--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py 2014-10-01 16:29:23 +0000
3+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py 2014-10-23 13:45:32 +0000
4@@ -77,15 +77,20 @@
5 def _slow_drag(self, start_x, stop_x, start_y, stop_y):
6 # If we drag too fast, we end up scrolling more than what we
7 # should, sometimes missing the element we are looking for.
8+ original_content_y = self.contentY
9+
10 # I found that when the flickDeceleration is 1500, the rate should be
11 # 5 and that when it's 100, the rate should be 1. With those two points
12- # we can get that the following equation.
13+ # we can get the following equation.
14 # XXX The deceleration might not be linear with respect to the rate,
15 # but this works for the two types of scrollables we have for now.
16 # --elopio - 2014-05-08
17 rate = (self.flickDeceleration + 250) / 350
18 self.pointing_device.drag(start_x, start_y, stop_x, stop_y, rate=rate)
19
20+ if self.contentY == original_content_y:
21+ raise _common.ToolkitException('Could not swipe in the flickable.')
22+
23
24 class QQuickFlickable(Scrollable):
25
26@@ -105,7 +110,6 @@
27
28 @autopilot_logging.log_action(logger.info)
29 def _swipe_non_visible_child_into_view(self, child, containers):
30- original_content_y = self.contentY
31 while not self._is_child_visible(child, containers):
32 # Check the direction of the swipe based on the position of the
33 # child relative to the immediate flickable container.
34@@ -114,10 +118,6 @@
35 else:
36 self.swipe_to_show_more_below(containers)
37
38- if self.contentY == original_content_y:
39- raise _common.ToolkitException(
40- "Couldn't swipe in the flickable.")
41-
42 @autopilot_logging.log_action(logger.info)
43 def swipe_to_show_more_above(self, containers=None):
44 if self.atYBeginning:
45
46=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py'
47--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py 2014-10-01 16:51:32 +0000
48+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py 2014-10-23 13:45:32 +0000
49@@ -14,10 +14,14 @@
50 # You should have received a copy of the GNU Lesser General Public License
51 # along with this program. If not, see <http://www.gnu.org/licenses/>.
52
53+try:
54+ from unittest import mock
55+except ImportError:
56+ import mock
57+
58 import testtools
59 import ubuntuuitoolkit
60 from ubuntuuitoolkit import tests
61-from ubuntuuitoolkit._custom_proxy_objects import _common
62
63
64 class FlickableTestCase(testtools.TestCase):
65@@ -27,7 +31,7 @@
66 dummy_id = (0, 0)
67 dummy_flicking = (0, 'dummy')
68 state_with_flicking = {'id': dummy_id, 'flicking': dummy_flicking}
69- element = _common.UbuntuUIToolkitCustomProxyObjectBase(
70+ element = ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase(
71 state_with_flicking, '/dummy'.encode(), 'dummy')
72
73 with element.no_automatic_refreshing():
74@@ -37,7 +41,7 @@
75 """is_flickable returns False if flickable property doesn't exist."""
76 dummy_id = (0, 0)
77 state_without_flicking = {'id': dummy_id}
78- element = _common.UbuntuUIToolkitCustomProxyObjectBase(
79+ element = ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase(
80 state_without_flicking, '/dummy'.encode(), 'dummy')
81
82 with element.no_automatic_refreshing():
83@@ -213,6 +217,18 @@
84 self.flickable.swipe_to_show_more_below()
85 self.assertFalse(self.flickable.atYBeginning)
86
87+ def test_failed_drag_must_raise_exception(self):
88+ dummy_coordinates = (0, 0, 10, 10)
89+ # Patch the pointing device so it does nothing and the swipe fails.
90+ with mock.patch.object(self.flickable, 'pointing_device'):
91+ error = self.assertRaises(
92+ ubuntuuitoolkit.ToolkitException,
93+ self.flickable._slow_drag,
94+ *dummy_coordinates
95+ )
96+
97+ self.assertEqual('Could not swipe in the flickable.', str(error))
98+
99
100 class UnityFlickableTestCase(tests.QMLStringAppTestCase):
101

Subscribers

People subscribed via source and target branches