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
1=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py'
2--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py 2015-02-03 08:34:58 +0000
3+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_flickable.py 2015-04-15 13:48:54 +0000
4@@ -19,6 +19,7 @@
5 import autopilot.exceptions
6 from autopilot import logging as autopilot_logging
7
8+from ubuntuuitoolkit import units
9 from ubuntuuitoolkit._custom_proxy_objects import _common
10
11
12@@ -98,6 +99,14 @@
13
14 class QQuickFlickable(Scrollable):
15
16+ # Swiping from below can open the toolbar or trigger the bottom edge
17+ # gesture. Use this margin to start a swipe that will not be that close to
18+ # the bottom edge.
19+ margin_to_swipe_from_bottom = units.gu(2)
20+ # Swiping from above can open the indicators or resize the window. Use this
21+ # margin to start a swipe that will not be that close to the top edge.
22+ margin_to_swipe_from_top = units.gu(1)
23+
24 @autopilot_logging.log_action(logger.info)
25 def swipe_child_into_view(self, child):
26 """Make the child visible.
27@@ -145,24 +154,23 @@
28 containers = self._get_containers()
29 start_x = stop_x = self.globalRect.x + (self.globalRect.width // 2)
30
31+ top = _get_visible_container_top(containers)
32+ bottom = _get_visible_container_bottom(containers)
33+
34 # Make the drag range be a multiple of the drag "rate" value.
35 # Workarounds https://bugs.launchpad.net/mir/+bug/1399690
36 rate = self._slow_drag_rate()
37
38- # Start and stop just a little under the top and a little over the
39- # bottom.
40- top = _get_visible_container_top(containers) + rate
41- bottom = _get_visible_container_bottom(containers) - rate
42-
43+ # The swipes are not done from right at the top and bottom because
44+ # they could trigger edge gestures or resize windows.
45 if direction == 'below':
46- # Take into account that swiping from below can open the toolbar or
47- # trigger the bottom edge gesture.
48- # XXX Do this only if we are close to the bottom edge.
49- start_y = bottom - 20
50+ start_y = bottom - self.margin_to_swipe_from_bottom
51 stop_y = start_y + (top - start_y) // rate * rate
52+
53 elif direction == 'above':
54- start_y = top
55+ start_y = top + self.margin_to_swipe_from_top
56 stop_y = start_y + (bottom - start_y) // rate * rate
57+
58 else:
59 raise _common.ToolkitException(
60 'Invalid direction {}.'.format(direction))
61
62=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py'
63--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py 2015-03-03 13:20:06 +0000
64+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py 2015-04-15 13:48:54 +0000
65@@ -21,7 +21,11 @@
66
67 import testtools
68 import ubuntuuitoolkit
69-from ubuntuuitoolkit import tests
70+from ubuntuuitoolkit import (
71+ tests,
72+ units,
73+)
74+from ubuntuuitoolkit._custom_proxy_objects import _flickable
75
76
77 class FlickableTestCase(testtools.TestCase):
78@@ -218,6 +222,45 @@
79 self.flickable.swipe_to_show_more_below()
80 self.assertFalse(self.flickable.atYBeginning)
81
82+ def test_swipe_to_show_more_below_with_bottom_margin(self):
83+ """Calling swipe to show more below will use the margin in the drag."""
84+ qquickflickable = self.main_view.select_single(
85+ ubuntuuitoolkit.QQuickFlickable, objectName='flickable')
86+ qquickflickable.margin_to_swipe_from_bottom = units.gu(6)
87+ containers = qquickflickable._get_containers()
88+ bottom = _flickable._get_visible_container_bottom(containers)
89+
90+ with mock.patch.object(
91+ qquickflickable.pointing_device, 'drag') as mock_drag:
92+ try:
93+ qquickflickable.swipe_to_show_more_below()
94+ except ubuntuuitoolkit.ToolkitException:
95+ # An exception will be raised because the drag was faked.
96+ pass
97+
98+ mock_drag.assert_called_with(
99+ mock.ANY, bottom - units.gu(6), mock.ANY, mock.ANY, rate=mock.ANY)
100+
101+ def test_swipe_to_show_more_above_with_top_margin(self):
102+ """Calling swipe to show more above will use the margin in the drag."""
103+ qquickflickable = self.main_view.select_single(
104+ ubuntuuitoolkit.QQuickFlickable, objectName='flickable')
105+ qquickflickable.margin_to_swipe_from_top = units.gu(6)
106+ containers = qquickflickable._get_containers()
107+ top = _flickable._get_visible_container_top(containers)
108+
109+ qquickflickable.swipe_to_bottom()
110+ with mock.patch.object(
111+ qquickflickable.pointing_device, 'drag') as mock_drag:
112+ try:
113+ qquickflickable.swipe_to_show_more_above()
114+ except ubuntuuitoolkit.ToolkitException:
115+ # An exception will be raised because the drag was faked.
116+ pass
117+
118+ mock_drag.assert_called_with(
119+ mock.ANY, top + units.gu(6), mock.ANY, mock.ANY, rate=mock.ANY)
120+
121 def test_failed_drag_must_raise_exception(self):
122 dummy_coordinates = (0, 0, 10, 10)
123 # Patch the pointing device so it does nothing and the swipe fails.

Subscribers

People subscribed via source and target branches