10
10
from __future__ import absolute_import
12
from testtools.matchers import Equals, GreaterThan, LessThan
12
from testtools.matchers import Equals
13
13
from autopilot.matchers import Eventually
15
15
from notes_app.tests import NotesAppTestCase
41
41
def test_slide_to_delete_right(self):
42
42
note = self.main_window.get_notes()[0]
44
# Verify that sliding the note right removes the note
45
x, y, w, h = note.globalRect
47
self.pointing_device.drag(int(x + 0.1 * w), ty, int(x + 0.9 * w), ty)
48
confirm = self.main_window.get_note_delete_confirmation_button(note)
49
xmax = note.globalRect[0] + note.globalRect[2] / 4
50
self.assertThat(lambda: confirm.globalRect[0],
51
Eventually(LessThan(xmax)))
52
self.pointing_device.click_object(confirm)
43
listitem = self.main_window.get_note_listitem(note)
44
listitem.swipe_to_delete('right')
45
listitem.confirm_removal()
55
47
lambda: len(self.main_window.get_notes()), Eventually(Equals(0)))
57
49
def test_slide_to_delete_left(self):
58
50
note = self.main_window.get_notes()[0]
60
# Verify that sliding the note left removes the note
61
x, y, w, h = note.globalRect
63
self.pointing_device.drag(int(x + 0.9 * w), ty, int(x + 0.1 * w), ty)
64
confirm = self.main_window.get_note_delete_confirmation_button(note)
65
xmin = note.globalRect[0] + note.globalRect[2] / 2
66
self.assertThat(lambda: confirm.globalRect[0],
67
Eventually(GreaterThan(xmin)))
68
self.pointing_device.click_object(confirm)
51
listitem = self.main_window.get_note_listitem(note)
52
listitem.swipe_to_delete('left')
53
listitem.confirm_removal()
71
55
lambda: len(self.main_window.get_notes()), Eventually(Equals(0)))
81
65
note_x + note_w / 2 + 10, note_y + note_h / 2)
82
66
self.pointing_device.release()
84
self.app.select_single("Empty").swipingState.wait_for("")
68
self.main_window.get_note_listitem(note).swipingState.wait_for("")
86
70
lambda: len(self.main_window.get_notes()), Eventually(Equals(1)))
97
81
self.pointing_device.move(note_x + note_w / 2, note_y + note_h / 2)
98
82
self.pointing_device.release()
100
self.app.select_single("Empty").swipingState.wait_for("")
84
self.main_window.get_note_listitem(note).swipingState.wait_for("")
102
86
lambda: len(self.main_window.get_notes()), Eventually(Equals(1)))