Merge lp:~canonical-platform-qa/ubuntu-ui-toolkit/fix1401517-overwrite_swipe_borders into lp:ubuntu-ui-toolkit/staging

Proposed by Leo Arias
Status: Merged
Approved by: Zsombor Egri
Approved revision: 1381
Merged at revision: 1478
Proposed branch: lp:~canonical-platform-qa/ubuntu-ui-toolkit/fix1401517-overwrite_swipe_borders
Merge into: lp:ubuntu-ui-toolkit/staging
Prerequisite: lp:~canonical-platform-qa/ubuntu-ui-toolkit/grid_units
Diff against target: 123 lines (+62/-11)
2 files modified
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py (+18/-10)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py (+44/-1)
To merge this branch: bzr merge lp:~canonical-platform-qa/ubuntu-ui-toolkit/fix1401517-overwrite_swipe_borders
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Zsombor Egri Approve
Brendan Donegan (community) Approve
Leo Arias (community) Approve
Albert Astals Cid (community) Abstain
Review via email: mp+248986@code.launchpad.net

This proposal supersedes a proposal from 2014-12-17.

Commit message

Make it possible to overwrite the bottom margin for the flickable autopilot helper.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote : Posted in a previous version of this proposal

37 elif direction == 'above':
38 - start_y = top
39 - stop_y = bottom
40 + start_y = top + 5
41 + stop_y = bottom - 5

to be consistent, you should use
start_y = top + self.margin_to_swipe_from_top

Revision history for this message
Tim Peeters (tpeeters) wrote : Posted in a previous version of this proposal

+ # Swiping from below can open the toolbar or trigger the bottom edge
9 + # gesture. Use this margin to start a swipe that will not be that close to
10 + # the bottom edge.
11 + margin_to_swipe_from_bottom = 25

Where did you get the 25 pixels from? Shouldn't we use grid units here?

We have this in the UITK Panel.qml:

    /*!
      The size (height for top or bottom-aligned panels, width for left or right-aligned
      panels) of the mouse area used to detect edge swipes to open the panel, when
      the panel is not opened. Default value: units.gu(2).
     */
    property real triggerSize: units.gu(2)

So apps that use the Panel with default settings will need a margin of 2 grid units. Of course apps can override this with their own value (or not use the Panel at all and implement their own bottom-edge).

Revision history for this message
Leo Arias (elopio) wrote :

@albert, I more or less understand what you did with the drags and the rate.
What I don't understand is why you add the rate to the top and subtract it from the bottom. I removed that part, so can you please take a look and confirm I'm not breaking anything from your change?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Leo, the idea +/- rate was already there, i kept it as "buffer" zone since we're doing a integer division and then multiplying back byu the rate we may get a big enough number and i did not want to end up past top/bottom but i guess that it's not really possible.

Revision history for this message
Albert Astals Cid (aacid) wrote :

I'll leave it to the SDK guys

review: Abstain
Revision history for this message
Leo Arias (elopio) wrote :

The prerequisite has a test failing in mako. Work in progress while we find the issue.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Federico Gimenez (fgimenez) wrote :

The failing tests have been fixed and the prerequisite has already landed, back to Needs review

Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

LGTM +1

Revision history for this message
Leo Arias (elopio) wrote :

We already have functional tests that do the swiping for real, so I think it's ok for this case to use a mock. One of those swiping tests failed in the latest execution, which makes me uneasy. Can someone retrigger the jenkins job? I don't have the vpn configured in my laptop, I will do it as soon as I get some quiet time.

1381. By Federico Gimenez

Merged with staging

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 :

+1. There seems to be an qmlscene crash making some tests fail, but on this run all the tests affected are passing.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

My previous comment didn't come out as an Approve. Approving again

review: Approve
Revision history for this message
Zsombor Egri (zsombi) wrote :

Looks good to go. Thank you!

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
=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py'
--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py 2015-02-03 08:34:58 +0000
+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py 2015-04-15 13:48:54 +0000
@@ -19,6 +19,7 @@
19import autopilot.exceptions19import autopilot.exceptions
20from autopilot import logging as autopilot_logging20from autopilot import logging as autopilot_logging
2121
22from ubuntuuitoolkit import units
22from ubuntuuitoolkit._custom_proxy_objects import _common23from ubuntuuitoolkit._custom_proxy_objects import _common
2324
2425
@@ -98,6 +99,14 @@
9899
99class QQuickFlickable(Scrollable):100class QQuickFlickable(Scrollable):
100101
102 # Swiping from below can open the toolbar or trigger the bottom edge
103 # gesture. Use this margin to start a swipe that will not be that close to
104 # the bottom edge.
105 margin_to_swipe_from_bottom = units.gu(2)
106 # Swiping from above can open the indicators or resize the window. Use this
107 # margin to start a swipe that will not be that close to the top edge.
108 margin_to_swipe_from_top = units.gu(1)
109
101 @autopilot_logging.log_action(logger.info)110 @autopilot_logging.log_action(logger.info)
102 def swipe_child_into_view(self, child):111 def swipe_child_into_view(self, child):
103 """Make the child visible.112 """Make the child visible.
@@ -145,24 +154,23 @@
145 containers = self._get_containers()154 containers = self._get_containers()
146 start_x = stop_x = self.globalRect.x + (self.globalRect.width // 2)155 start_x = stop_x = self.globalRect.x + (self.globalRect.width // 2)
147156
157 top = _get_visible_container_top(containers)
158 bottom = _get_visible_container_bottom(containers)
159
148 # Make the drag range be a multiple of the drag "rate" value.160 # Make the drag range be a multiple of the drag "rate" value.
149 # Workarounds https://bugs.launchpad.net/mir/+bug/1399690161 # Workarounds https://bugs.launchpad.net/mir/+bug/1399690
150 rate = self._slow_drag_rate()162 rate = self._slow_drag_rate()
151163
152 # Start and stop just a little under the top and a little over the164 # The swipes are not done from right at the top and bottom because
153 # bottom.165 # they could trigger edge gestures or resize windows.
154 top = _get_visible_container_top(containers) + rate
155 bottom = _get_visible_container_bottom(containers) - rate
156
157 if direction == 'below':166 if direction == 'below':
158 # Take into account that swiping from below can open the toolbar or167 start_y = bottom - self.margin_to_swipe_from_bottom
159 # trigger the bottom edge gesture.
160 # XXX Do this only if we are close to the bottom edge.
161 start_y = bottom - 20
162 stop_y = start_y + (top - start_y) // rate * rate168 stop_y = start_y + (top - start_y) // rate * rate
169
163 elif direction == 'above':170 elif direction == 'above':
164 start_y = top171 start_y = top + self.margin_to_swipe_from_top
165 stop_y = start_y + (bottom - start_y) // rate * rate172 stop_y = start_y + (bottom - start_y) // rate * rate
173
166 else:174 else:
167 raise _common.ToolkitException(175 raise _common.ToolkitException(
168 'Invalid direction {}.'.format(direction))176 'Invalid direction {}.'.format(direction))
169177
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py'
--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py 2015-03-03 13:20:06 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py 2015-04-15 13:48:54 +0000
@@ -21,7 +21,11 @@
2121
22import testtools22import testtools
23import ubuntuuitoolkit23import ubuntuuitoolkit
24from ubuntuuitoolkit import tests24from ubuntuuitoolkit import (
25 tests,
26 units,
27)
28from ubuntuuitoolkit._custom_proxy_objects import _flickable
2529
2630
27class FlickableTestCase(testtools.TestCase):31class FlickableTestCase(testtools.TestCase):
@@ -218,6 +222,45 @@
218 self.flickable.swipe_to_show_more_below()222 self.flickable.swipe_to_show_more_below()
219 self.assertFalse(self.flickable.atYBeginning)223 self.assertFalse(self.flickable.atYBeginning)
220224
225 def test_swipe_to_show_more_below_with_bottom_margin(self):
226 """Calling swipe to show more below will use the margin in the drag."""
227 qquickflickable = self.main_view.select_single(
228 ubuntuuitoolkit.QQuickFlickable, objectName='flickable')
229 qquickflickable.margin_to_swipe_from_bottom = units.gu(6)
230 containers = qquickflickable._get_containers()
231 bottom = _flickable._get_visible_container_bottom(containers)
232
233 with mock.patch.object(
234 qquickflickable.pointing_device, 'drag') as mock_drag:
235 try:
236 qquickflickable.swipe_to_show_more_below()
237 except ubuntuuitoolkit.ToolkitException:
238 # An exception will be raised because the drag was faked.
239 pass
240
241 mock_drag.assert_called_with(
242 mock.ANY, bottom - units.gu(6), mock.ANY, mock.ANY, rate=mock.ANY)
243
244 def test_swipe_to_show_more_above_with_top_margin(self):
245 """Calling swipe to show more above will use the margin in the drag."""
246 qquickflickable = self.main_view.select_single(
247 ubuntuuitoolkit.QQuickFlickable, objectName='flickable')
248 qquickflickable.margin_to_swipe_from_top = units.gu(6)
249 containers = qquickflickable._get_containers()
250 top = _flickable._get_visible_container_top(containers)
251
252 qquickflickable.swipe_to_bottom()
253 with mock.patch.object(
254 qquickflickable.pointing_device, 'drag') as mock_drag:
255 try:
256 qquickflickable.swipe_to_show_more_above()
257 except ubuntuuitoolkit.ToolkitException:
258 # An exception will be raised because the drag was faked.
259 pass
260
261 mock_drag.assert_called_with(
262 mock.ANY, top + units.gu(6), mock.ANY, mock.ANY, rate=mock.ANY)
263
221 def test_failed_drag_must_raise_exception(self):264 def test_failed_drag_must_raise_exception(self):
222 dummy_coordinates = (0, 0, 10, 10)265 dummy_coordinates = (0, 0, 10, 10)
223 # Patch the pointing device so it does nothing and the swipe fails.266 # Patch the pointing device so it does nothing and the swipe fails.

Subscribers

People subscribed via source and target branches