Merge lp:~elopio/ubuntu-ui-toolkit/pullToRefresh-test2 into lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/pullToRefresh

Proposed by Leo Arias
Status: Merged
Merged at revision: 948
Proposed branch: lp:~elopio/ubuntu-ui-toolkit/pullToRefresh-test2
Merge into: lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/pullToRefresh
Diff against target: 78 lines (+32/-5)
2 files modified
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py (+20/-1)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_pull_to_refresh.py (+12/-4)
To merge this branch: bzr merge lp:~elopio/ubuntu-ui-toolkit/pullToRefresh-test2
Reviewer Review Type Date Requested Status
Zsombor Egri Approve
Review via email: mp+220677@code.launchpad.net

Commit message

Added a test for the cancel pull to refresh.

To post a comment you must log in.
Revision history for this message
Zsombor Egri (zsombi) wrote :

thx buddy

review: Approve

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-05-21 12:13:27 +0000
3+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py 2014-05-22 15:47:53 +0000
4@@ -183,7 +183,7 @@
5 @autopilot_logging.log_action(logger.info)
6 def _swipe_to_middle(self):
7 start_x = stop_x = self.globalRect.x + (self.globalRect.width // 2)
8- # Start and stop just a little under the top.
9+ # Start just a little under the top.
10 containers = self._get_containers()
11 top = _get_visible_container_top(containers) + 5
12 bottom = _get_visible_container_bottom(containers)
13@@ -194,6 +194,25 @@
14 self.dragging.wait_for(False)
15 self.moving.wait_for(False)
16
17+ @autopilot_logging.log_action(logger.info)
18+ def _cancel_pull_to_refresh(self):
19+ """Swipe down the list and then swipe it up to cancel the refresh."""
20+ # This method is kept private because it's not for the test writers to
21+ # call. It's to test pull to refresh. --elopio - 2014-05-22
22+ self._swipe_to_top()
23+ start_x = stop_x = self.globalRect.x + (self.globalRect.width // 2)
24+ # Start just a little under the top.
25+ containers = self._get_containers()
26+ top = _get_visible_container_top(containers) + 5
27+ bottom = _get_visible_container_bottom(containers)
28+
29+ start_y = top
30+ stop_y = bottom // 2
31+ self.pointing_device.move(start_x, start_y)
32+ self.pointing_device.press()
33+ self.pointing_device.move(stop_x, stop_y)
34+ self.pointing_device.move(start_x, start_y)
35+ self.pointing_device.release()
36
37 class PullToRefresh(_common.UbuntuUIToolkitCustomProxyObjectBase):
38 """Autopilot helper for the PullToRefresh component."""
39
40=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_pull_to_refresh.py'
41--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_pull_to_refresh.py 2014-05-21 12:15:29 +0000
42+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_pull_to_refresh.py 2014-05-22 15:47:53 +0000
43@@ -15,6 +15,7 @@
44 # along with this program. If not, see <http://www.gnu.org/licenses/>.
45
46 import os
47+import time
48
49 import ubuntuuitoolkit
50 from ubuntuuitoolkit import tests
51@@ -31,6 +32,9 @@
52 self.label = self.main_view.select_single(
53 'Label', objectName='refreshedLabel')
54 self.assertEqual(self.label.text, 'Not refreshed.')
55+ self.flickable_with_pull_to_refresh = self.main_view.select_single(
56+ ubuntuuitoolkit.QQuickFlickable,
57+ objectName='flickableWithPullToRefresh')
58
59 def test_pull_to_refresh_on_a_flickable_without_it_must_raise_error(self):
60 flickable = self.main_view.select_single(
61@@ -42,9 +46,13 @@
62 str(error), 'The flickable has no pull to refresh functionality.')
63
64 def test_pull_to_refresh_must_refresh_model(self):
65- flickable = self.main_view.select_single(
66- ubuntuuitoolkit.QQuickFlickable,
67- objectName='flickableWithPullToRefresh')
68- flickable.pull_to_refresh()
69+ self.flickable_with_pull_to_refresh.pull_to_refresh()
70
71 self.assertEqual(self.label.text, 'Refreshed.')
72+
73+ def test_cancel_pull_to_refresh_must_not_refresh_model(self):
74+ self.flickable_with_pull_to_refresh._cancel_pull_to_refresh()
75+ # Sleep for some time to make sure that the list is not being
76+ # refreshed.
77+ time.sleep(3)
78+ self.assertEqual(self.label.text, 'Not refreshed.')

Subscribers

People subscribed via source and target branches

to all changes: