Merge lp:~osomon/notes-app/swipe-to-delete-emulator into lp:notes-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Ugo Riboni
Approved revision: 222
Merged at revision: 227
Proposed branch: lp:~osomon/notes-app/swipe-to-delete-emulator
Merge into: lp:notes-app
Diff against target: 89 lines (+11/-32)
2 files modified
tests/autopilot/notes_app/emulators/notesapp.py (+2/-7)
tests/autopilot/notes_app/tests/test_delete.py (+9/-25)
To merge this branch: bzr merge lp:~osomon/notes-app/swipe-to-delete-emulator
Reviewer Review Type Date Requested Status
Ugo Riboni (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+194566@code.launchpad.net

Commit message

Use the standard UITK emulator for swipe-to-delete gesture and confirmation.

Description of the change

Note: this requires https://code.launchpad.net/~elopio/ubuntu-ui-toolkit/fix-swipe_to_delete/+merge/194544 to be merged in the UITK as a prerequisite.

To post a comment you must log in.
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: Approve (continuous-integration)
Revision history for this message
Ugo Riboni (uriboni) wrote :

pass tests locally and code makes sense

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/notes_app/emulators/notesapp.py'
2--- tests/autopilot/notes_app/emulators/notesapp.py 2013-11-07 17:34:00 +0000
3+++ tests/autopilot/notes_app/emulators/notesapp.py 2013-11-08 18:40:53 +0000
4@@ -30,13 +30,8 @@
5 parts.sort(key=lambda part: part.y)
6 return parts
7
8- def get_note_delete_confirmation_button(self, note_item):
9- # XXX: this is highly unreliable, if the UITK implementation changes,
10- # this will break. Likewise, if NoteItems were to have more than one
11- # Row item at some point, it would break.
12- # This is a temporary solution until
13- # https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1236464 is fixed.
14- return note_item.select_single("QQuickRow")
15+ def get_note_listitem(self, note_item):
16+ return note_item.select_single(uitk.Empty)
17
18 def get_keyboard_rectangle(self):
19 return self.select_single("KeyboardRectangle")
20
21=== modified file 'tests/autopilot/notes_app/tests/test_delete.py'
22--- tests/autopilot/notes_app/tests/test_delete.py 2013-11-04 11:12:49 +0000
23+++ tests/autopilot/notes_app/tests/test_delete.py 2013-11-08 18:40:53 +0000
24@@ -9,7 +9,7 @@
25
26 from __future__ import absolute_import
27
28-from testtools.matchers import Equals, GreaterThan, LessThan
29+from testtools.matchers import Equals
30 from autopilot.matchers import Eventually
31
32 from notes_app.tests import NotesAppTestCase
33@@ -40,33 +40,17 @@
34
35 def test_slide_to_delete_right(self):
36 note = self.main_window.get_notes()[0]
37-
38- # Verify that sliding the note right removes the note
39- x, y, w, h = note.globalRect
40- ty = int(y + h / 2)
41- self.pointing_device.drag(int(x + 0.1 * w), ty, int(x + 0.9 * w), ty)
42- confirm = self.main_window.get_note_delete_confirmation_button(note)
43- xmax = note.globalRect[0] + note.globalRect[2] / 4
44- self.assertThat(lambda: confirm.globalRect[0],
45- Eventually(LessThan(xmax)))
46- self.pointing_device.click_object(confirm)
47-
48+ listitem = self.main_window.get_note_listitem(note)
49+ listitem.swipe_to_delete('right')
50+ listitem.confirm_removal()
51 self.assertThat(
52 lambda: len(self.main_window.get_notes()), Eventually(Equals(0)))
53
54 def test_slide_to_delete_left(self):
55 note = self.main_window.get_notes()[0]
56-
57- # Verify that sliding the note left removes the note
58- x, y, w, h = note.globalRect
59- ty = int(y + h / 2)
60- self.pointing_device.drag(int(x + 0.9 * w), ty, int(x + 0.1 * w), ty)
61- confirm = self.main_window.get_note_delete_confirmation_button(note)
62- xmin = note.globalRect[0] + note.globalRect[2] / 2
63- self.assertThat(lambda: confirm.globalRect[0],
64- Eventually(GreaterThan(xmin)))
65- self.pointing_device.click_object(confirm)
66-
67+ listitem = self.main_window.get_note_listitem(note)
68+ listitem.swipe_to_delete('left')
69+ listitem.confirm_removal()
70 self.assertThat(
71 lambda: len(self.main_window.get_notes()), Eventually(Equals(0)))
72
73@@ -81,7 +65,7 @@
74 note_x + note_w / 2 + 10, note_y + note_h / 2)
75 self.pointing_device.release()
76
77- self.app.select_single("Empty").swipingState.wait_for("")
78+ self.main_window.get_note_listitem(note).swipingState.wait_for("")
79 self.assertThat(
80 lambda: len(self.main_window.get_notes()), Eventually(Equals(1)))
81
82@@ -97,6 +81,6 @@
83 self.pointing_device.move(note_x + note_w / 2, note_y + note_h / 2)
84 self.pointing_device.release()
85
86- self.app.select_single("Empty").swipingState.wait_for("")
87+ self.main_window.get_note_listitem(note).swipingState.wait_for("")
88 self.assertThat(
89 lambda: len(self.main_window.get_notes()), Eventually(Equals(1)))

Subscribers

People subscribed via source and target branches