Merge lp:~renatofilho/ubuntu-ui-toolkit/fix-1236464 into lp:ubuntu-ui-toolkit

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Cris Dywan
Approved revision: 811
Merged at revision: 810
Proposed branch: lp:~renatofilho/ubuntu-ui-toolkit/fix-1236464
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 282 lines (+186/-0)
5 files modified
CHANGES (+2/-0)
components.api (+2/-0)
modules/Ubuntu/Components/ListItems/Empty.qml (+22/-0)
tests/autopilot/ubuntuuitoolkit/emulators.py (+68/-0)
tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py (+92/-0)
To merge this branch: bzr merge lp:~renatofilho/ubuntu-ui-toolkit/fix-1236464
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Olivier Tilloy (community) Approve
Leo Arias (community) autopilot code review Approve
Ubuntu SDK team Pending
Review via email: mp+190496@code.launchpad.net

Commit message

Implemented emulator for swipe to remove.

To post a comment you must log in.
Revision history for this message
Leo Arias (elopio) wrote :

<elopio> renato_: I think it would be enough to test one of the objects that inherit from SwipeToDeleteTestCase, and then to test that all the emulators you added inherit from SwipeToDeleteTestCase.
<elopio> and that second test would be a little dumb, so I would just leave either the empty or the standard item on your test.
<elopio> renato_: every time you do select_single, and continue on the next line, you have a pep8 error there because of the extra space.
<elopio> so jenkins is going to reject your branch for that.
<elopio> renato_: you are missing some tests to cover all the possible flows:
<elopio> test_delete_item -> with default direction value
<elopio> test_delete_item_swiping_to_the_left
<elopio> test_delete_non_removable_item
<elopio> test_confirm_removal_when_item_was_not_swiped
<elopio> renato_: and I don't like this: 109␉+ self.implicitHeight.wait_for(0)
<elopio> if the dialog doesn't have a visible property that works, or an opened property or something like that, I think we should fix it to be
<elopio> self.visible.wait_for(False)
<elopio> I say "we" as in somebody who know how to do it, not me :)

Thank you for working on this!

review: Needs Fixing (code review)
794. By Renato Araujo Oliveira Filho

Added more tests cases.
Fixed swipe to left.

795. By Renato Araujo Oliveira Filho

Reduce the qml example used for swipe to delete emulator test.

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

Looks really good. Thanks again.

review: Approve (autopilot code review)
796. By Renato Araujo Oliveira Filho

Creeated setUp function to simplify the code.

797. By Renato Araujo Oliveira Filho

Used single quotes when possible.

798. By Renato Araujo Oliveira Filho

Moved setUp to the top of the class declaration.

799. By Renato Araujo Oliveira Filho

Removed white spaces.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
800. By Renato Araujo Oliveira Filho

Updated API changes related files.

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)
801. By Renato Araujo Oliveira Filho

Updated components.api.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

pep8 reports 22 errors.
pyflakes reports 2 errors.

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

126 + if (direction == 'right'):
127 + self.pointing_device.drag(tx, ty, w, ty)
128 + else:
129 + self.pointing_device.drag(w, ty, x, ty)

The else clause should be an "elif (direction == 'left')", and you should add an additional else clause that raises some sort of exception if the value of direction is neither 'left' nor 'right'.

Revision history for this message
Olivier Tilloy (osomon) wrote :

116 + def _get_confirm_buttton(self):

Typo: there’s one t too many.

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

148 +class Empty(UbuntuUIToolkitEmulatorBase, SupportsSwipeToDelete):
149 + pass
150 +
151 +class Base(UbuntuUIToolkitEmulatorBase, SupportsSwipeToDelete):
152 + pass
153 +
154 +class ItemSelector(UbuntuUIToolkitEmulatorBase, SupportsSwipeToDelete):
155 + pass
[…]

In QML, Base and ItemSelector inherit Empty, wouldn’t it be possible to make the emulator classes follow the same inheritance pattern? The same would apply for all emulators, e.g. MultiValue inherit from Base, and so on…

Revision history for this message
Olivier Tilloy (osomon) wrote :

241 + def test_delete_item(self):
242 + self._item.swipe_to_delete('right')
243 + self._item.confirm_removal()
244 + self.assertEqual(self._item.implicitHeight, 0)

For completeness, this test should be duplicated to test the confirmation when swiped to the left.

review: Needs Fixing
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

> 148 +class Empty(UbuntuUIToolkitEmulatorBase, SupportsSwipeToDelete):
> 149 + pass
> 150 +
> 151 +class Base(UbuntuUIToolkitEmulatorBase, SupportsSwipeToDelete):
> 152 + pass
> 153 +
> 154 +class ItemSelector(UbuntuUIToolkitEmulatorBase,
> SupportsSwipeToDelete):
> 155 + pass
> […]
>
> In QML, Base and ItemSelector inherit Empty, wouldn’t it be possible to make
> the emulator classes follow the same inheritance pattern? The same would apply
> for all emulators, e.g. MultiValue inherit from Base, and so on…

This is the way the quality guys told me to go, For some reason autopilot will get confused by using what you proposal.

802. By Renato Araujo Oliveira Filho

Fixed pep8 syntax.

803. By Renato Araujo Oliveira Filho

Fixed typo buttton

804. By Renato Araujo Oliveira Filho

Raise error when trying to swipe a item to invalid direction.

Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

> pep8 reports 22 errors.
> pyflakes reports 2 errors.

Fixed on rev: 802

Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

> 116 + def _get_confirm_buttton(self):
>
> Typo: there’s one t too many.

Fixed on rev: 803

Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

> 126 + if (direction == 'right'):
> 127 + self.pointing_device.drag(tx, ty, w, ty)
> 128 + else:
> 129 + self.pointing_device.drag(w, ty, x, ty)
>
> The else clause should be an "elif (direction == 'left')", and you should add
> an additional else clause that raises some sort of exception if the value of
> direction is neither 'left' nor 'right'.
Fixed rev: 804

Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

> 241 + def test_delete_item(self):
> 242 + self._item.swipe_to_delete('right')
> 243 + self._item.confirm_removal()
> 244 + self.assertEqual(self._item.implicitHeight, 0)
>
> For completeness, this test should be duplicated to test the confirmation when
> swiped to the left.
Fixed on rev 804

Revision history for this message
Olivier Tilloy (osomon) wrote :

> > pep8 reports 22 errors.
> > pyflakes reports 2 errors.
>
> Fixed on rev: 802

I’m now seeing 3 pyflakes errors.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
805. By Renato Araujo Oliveira Filho

Fixed pyflakes errors.

Revision history for this message
Olivier Tilloy (osomon) wrote :

> > In QML, Base and ItemSelector inherit Empty, wouldn’t it be possible to make
> > the emulator classes follow the same inheritance pattern? The same would
> apply
> > for all emulators, e.g. MultiValue inherit from Base, and so on…
>
> This is the way the quality guys told me to go, For some reason autopilot will
> get confused by using what you proposal.

I find this awkward, and I don’t really understand why this would confuse autopilot. We’re talking about simple inheritance here. Can you please give it a shot?

806. By Renato Araujo Oliveira Filho

Use Empty as base class for swipe to delete emulator.

Revision history for this message
Olivier Tilloy (osomon) wrote :

SingleValue, MultiValue and Subtitled should inherit from Base, not from Empty.

review: Needs Fixing
807. By Renato Araujo Oliveira Filho

Fixed class inheritance

Revision history for this message
Olivier Tilloy (osomon) wrote :

The inheritance checks need to be updated in test_supported_class() too.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
808. By Renato Araujo Oliveira Filho

Fixed test_supported_class to check the correct class.

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
Olivier Tilloy (osomon) wrote :

Looks good to me now.

review: Approve
809. By Renato Araujo Oliveira Filho

Merged mainline.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
810. By Renato Araujo Oliveira Filho

Merged mainline.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:810
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1063/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/23
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/23/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-ci/11
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/11
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/11/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/18
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/23
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/23/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/23
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/23/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2654/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2705/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/347
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/346

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1063/rebuild

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
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:810
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1067/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/30
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/30/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-ci/15
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/15
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/15/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/24
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/30
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/30/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/30
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/30/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2659/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2710/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/357
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/356

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1067/rebuild

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

FAILED: Continuous integration, rev:810
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1070/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/37
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/37/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-ci/18
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/18
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/18/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/31
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/37
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/37/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/37
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/37/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2666/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2717/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/371
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/372

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1070/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

20:57:51.268 ERROR testresult:35 - FAIL: ubuntuuitoolkit.tests.test_emulators.SwipeToDeleteTestCase.test_swipe_item_to_left
AssertionError: After 10.0 seconds test on Standard.waitingConfirmationForRemoval failed: True != dbus.Boolean(False, variant_level=1)

811. By Renato Araujo Oliveira Filho

Attempt to fix the swipe to delete autopilot on device.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:811
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1080/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/63
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/63
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-ci/28
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/28
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/28/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/55
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/63
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/63/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/63
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/63/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2692
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2743
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/429
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/421

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1080/rebuild

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

FAILED: Continuous integration, rev:811
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1089/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/85
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/84/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-ci/37
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/37
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/37/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/79
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/85
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/85/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/84
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/84/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2712/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2763
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/476
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/462

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1089/rebuild

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

PASSED: Continuous integration, rev:811
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1093/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/89
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/88
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-ci/41
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/41
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/41/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/83
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/89
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/89/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/88
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/88/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2716
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2767
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/483
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/466

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1093/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CHANGES'
2--- CHANGES 2013-10-18 02:41:30 +0000
3+++ CHANGES 2013-10-24 12:01:09 +0000
4@@ -65,6 +65,8 @@
5 * ADDED IN Panel: function open()
6 * ADDED IN Panel: function close()
7 * DEPRECATED IN Panel: writable property opened. Will be made read-only.
8+* ADDED IN: Empty: property bool waitingConfirmationForRemoval
9+* ADDED IN: Empty: function cancelItemRemoval()
10 * CHANGED in CrossFadeImage: readonly property size sourceSize TO property size sourceSize
11
12 Compatibility Breaks
13
14=== modified file 'components.api'
15--- components.api 2013-10-18 14:41:53 +0000
16+++ components.api 2013-10-24 12:01:09 +0000
17@@ -410,6 +410,7 @@
18 property bool removable
19 property bool confirmRemoval
20 readonly property string swipingState
21+ readonly property bool waitingConfirmationForRemoval
22 signal itemRemoved
23 property int __height
24 property bool showDivider
25@@ -418,6 +419,7 @@
26 property list<Item> backgroundIndicator
27 property ThinDivider divider
28 property real __contentsMargins
29+ function cancelItemRemoval()
30 modules/Ubuntu/Components/ListItems/Header.qml
31 Item
32 property string text
33
34=== modified file 'modules/Ubuntu/Components/ListItems/Empty.qml'
35--- modules/Ubuntu/Components/ListItems/Empty.qml 2013-10-04 19:07:26 +0000
36+++ modules/Ubuntu/Components/ListItems/Empty.qml 2013-10-24 12:01:09 +0000
37@@ -109,6 +109,12 @@
38 */
39 readonly property alias swipingState: backgroundIndicator.state
40
41+ /*!
42+ \preliminary
43+ \qmlproperty bool waitingConfirmationForRemoval
44+ Defines if the item is waiting for the user interaction during the swipe to delete
45+ */
46+ readonly property alias waitingConfirmationForRemoval: confirmRemovalDialog.waitingForConfirmation
47
48 /*!
49 \preliminary
50@@ -162,6 +168,15 @@
51 */
52 property real __contentsMargins: units.gu(2)
53
54+ /*!
55+ \preliminary
56+ Cancel item romoval
57+ */
58+ function cancelItemRemoval()
59+ {
60+ priv.resetDrag()
61+ }
62+
63 width: parent ? parent.width : units.gu(31)
64 implicitHeight: priv.removed ? 0 : __height + bottomDividerLine.height
65 __mouseArea.drag.axis: Drag.XAxis
66@@ -218,6 +233,7 @@
67 Resets the item dragging state
68 */
69 function resetDrag() {
70+ confirmRemovalDialog.waitingForConfirmation = false
71 body.x = 0
72 pressedPosition = -1
73 __mouseArea.drag.target = null
74@@ -304,6 +320,7 @@
75 }
76 ScriptAction {
77 script: {
78+ confirmRemovalDialog.waitingForConfirmation = true
79 priv.commitDrag()
80 }
81 }
82@@ -333,9 +350,13 @@
83
84 Item {
85 id: confirmRemovalDialog
86+ objectName: "confirmRemovalDialog"
87+
88+ property bool waitingForConfirmation: false
89
90 visible: false
91 width: units.gu(15)
92+ x: body.x - width - units.gu(2)
93 anchors {
94 top: parent.top
95 bottom: parent.bottom
96@@ -374,6 +395,7 @@
97 }
98
99 MouseArea {
100+ visible: confirmRemovalDialog.waitingForConfirmation
101 anchors.fill: parent
102 onClicked: removeItemAnimation.start()
103 }
104
105=== modified file 'tests/autopilot/ubuntuuitoolkit/emulators.py'
106--- tests/autopilot/ubuntuuitoolkit/emulators.py 2013-10-18 09:37:13 +0000
107+++ tests/autopilot/ubuntuuitoolkit/emulators.py 2013-10-24 12:01:09 +0000
108@@ -340,3 +340,71 @@
109 if self.checked:
110 self.pointing_device.click_object(self)
111 self.checked.wait_for(False)
112+
113+
114+class Empty(UbuntuUIToolkitEmulatorBase):
115+ """Base class to emulate swipe to delete"""
116+
117+ def _get_confirm_button(self):
118+ return self.select_single(
119+ 'QQuickItem', objectName='confirmRemovalDialog')
120+
121+ def swipe_to_delete(self, direction='right'):
122+ """ Swipe the item in a specific direction """
123+ if (self.removable):
124+ x, y, w, h = self.globalRect
125+ tx = x + (w / 8)
126+ ty = y + (h / 2)
127+
128+ if (direction == 'right'):
129+ self.pointing_device.drag(tx, ty, w, ty)
130+ elif (direction == 'left'):
131+ self.pointing_device.drag(w - (w*0.1), ty, x, ty)
132+ else:
133+ raise ToolkitEmulatorException(
134+ 'Invalid direction "{0}" used on swipe to delete function'
135+ .format(direction))
136+
137+ self.waitingConfirmationForRemoval.wait_for(True)
138+ else:
139+ raise ToolkitEmulatorException(
140+ 'The item "{0}" is not removable'.format(self.objectName))
141+
142+ def confirm_removal(self):
143+ """ Comfirm item removal if this was already swiped """
144+ if (self.waitingConfirmationForRemoval):
145+ deleteButton = self._get_confirm_button()
146+ self.pointing_device.click_object(deleteButton)
147+ self.implicitHeight.wait_for(0)
148+ else:
149+ raise ToolkitEmulatorException(
150+ 'The item "{0}" is not waiting for removal confirmation'.
151+ format(self.objectName))
152+
153+
154+class Base(Empty):
155+ pass
156+
157+
158+class Standard(Empty):
159+ pass
160+
161+
162+class ItemSelector(Empty):
163+ pass
164+
165+
166+class SingleControl(Empty):
167+ pass
168+
169+
170+class MultiValue(Base):
171+ pass
172+
173+
174+class SingleValue(Base):
175+ pass
176+
177+
178+class Subtitled(Base):
179+ pass
180
181=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py'
182--- tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2013-10-18 14:41:53 +0000
183+++ tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2013-10-24 12:01:09 +0000
184@@ -458,6 +458,98 @@
185 self.assertFalse(mock_click.called)
186
187
188+class SwipeToDeleteTestCase(tests.QMLStringAppTestCase):
189+
190+ test_qml = ("""
191+import QtQuick 2.0
192+import Ubuntu.Components 0.1
193+import Ubuntu.Components.ListItems 0.1
194+
195+
196+MainView {
197+ width: units.gu(48)
198+ height: units.gu(300)
199+
200+ Column {
201+ width: parent.width
202+
203+ Standard {
204+ objectName: "listitem_standard"
205+ confirmRemoval: true
206+ removable: true
207+ width: parent.width
208+ text: 'Slide to remove'
209+ }
210+ Empty {
211+ objectName: "listitem_empty"
212+ width: parent.width
213+ }
214+ }
215+}
216+""")
217+
218+ def setUp(self):
219+ super(SwipeToDeleteTestCase, self).setUp()
220+ self._item = self.main_view.select_single(
221+ emulators.Standard, objectName='listitem_standard')
222+
223+ def test_supported_class(self):
224+ self.assertTrue(issubclass(
225+ emulators.Base, emulators.Empty))
226+ self.assertTrue(issubclass(
227+ emulators.ItemSelector, emulators.Empty))
228+ self.assertTrue(issubclass(
229+ emulators.Standard, emulators.Empty))
230+ self.assertTrue(issubclass(
231+ emulators.SingleControl, emulators.Empty))
232+ self.assertTrue(issubclass(
233+ emulators.MultiValue, emulators.Base))
234+ self.assertTrue(issubclass(
235+ emulators.SingleValue, emulators.Base))
236+ self.assertTrue(issubclass(
237+ emulators.Subtitled, emulators.Base))
238+
239+ def test_standard_emulator(self):
240+ self.assertIsInstance(self._item, emulators.Standard)
241+
242+ def test_swipe_item(self):
243+ self._item.swipe_to_delete()
244+ self.assertTrue(self._item.waitingConfirmationForRemoval)
245+
246+ def test_swipe_item_to_right(self):
247+ self._item.swipe_to_delete('right')
248+ self.assertTrue(self._item.waitingConfirmationForRemoval)
249+
250+ def test_swipe_item_to_left(self):
251+ self._item.swipe_to_delete('left')
252+ self.assertTrue(self._item.waitingConfirmationForRemoval)
253+
254+ def test_swipe_item_to_wrong_direction(self):
255+ self.assertRaises(
256+ emulators.ToolkitEmulatorException,
257+ self._item.swipe_to_delete, 'up')
258+
259+ def test_delete_item_moving_right(self):
260+ self._item.swipe_to_delete('right')
261+ self._item.confirm_removal()
262+ self.assertEqual(self._item.implicitHeight, 0)
263+
264+ def test_delete_item_moving_left(self):
265+ self._item.swipe_to_delete('left')
266+ self._item.confirm_removal()
267+ self.assertEqual(self._item.implicitHeight, 0)
268+
269+ def test_delete_non_removable_item(self):
270+ self._item = self.main_view.select_single(
271+ emulators.Empty, objectName='listitem_empty')
272+ self.assertRaises(
273+ emulators.ToolkitEmulatorException, self._item.swipe_to_delete)
274+
275+ def test_confirm_removal_when_item_was_not_swiped(self):
276+ self.assertRaises(
277+ emulators.ToolkitEmulatorException, self._item.confirm_removal)
278+
279+
280 class PageStackTestCase(tests.QMLStringAppTestCase):
281
282 test_qml = ("""

Subscribers

People subscribed via source and target branches

to status/vote changes: