37
38
def media_selector(self):
38
39
return MediaSelector(self.app)
42
def photo_viewer(self):
43
return PhotoViewer(self.app)
42
47
super(TestAlbumView, self).setUp()
43
48
self.switch_to_albums_tab()
45
def ensure_media_selector_is_fully_open(self):
46
media_selector = self.media_selector.get_media_selector()
47
self.assertThat(media_selector.opacity, Eventually(Equals(1.0)))
49
def ensure_media_selector_is_fully_closed(self):
50
loader = self.album_view.media_selector_loader()
51
self.assertThat(loader.status, Eventually(Equals(0)))
53
50
def test_album_view_open_photo(self):
54
self.main_view.close_toolbar()
55
51
self.open_first_album()
56
self.main_view.close_toolbar()
57
52
photo = self.album_view.get_first_photo()
58
# workaround lp:1247698
59
self.main_view.close_toolbar()
60
53
self.click_item(photo)
61
photo_view = self.album_view.get_album_photo_view()
55
photo_view = self.main_view.wait_select_single("PopupPhotoViewer")
62
56
self.assertThat(photo_view.visible, Eventually(Equals(True)))
63
self.assertThat(photo_view.isPoppedUp, Eventually(Equals(True)))
65
58
def test_album_view_flipping(self):
66
self.main_view.close_toolbar()
68
59
# For some reason here the album at position 0 in the autopilot list is
69
60
# actually the second album, they seem to be returned in reverse order.
71
self.main_view.close_toolbar()
73
album = self.album_view.get_album_view()
74
63
spread = self.album_view.get_spread_view()
76
self.assertThat(album.animationRunning, Eventually(Equals(False)))
77
self.assertThat(spread.viewingPage, Eventually(Equals(1)))
78
self.main_view.close_toolbar()
80
x, y, w, h = spread.globalRect
84
65
# check that we can page to the cover and back (we check for lesser
85
66
# than 1 because it can either be 0 if we are on a one page spread
86
67
# or -1 if we are on a two page spread, for example on desktop)
87
self.pointing_device.drag(mid_x - mid_x / 2, mid_y, x + w - 10, mid_y)
88
animview = self.album_view.get_animated_album_view()
68
self.album_view.swipe_page_left(1)
89
69
self.assertThat(spread.viewingPage, Eventually(LessThan(1)))
90
self.pointing_device.drag(mid_x + mid_x / 2, mid_y, x + 10, mid_y)
91
animview = self.album_view.get_animated_album_view()
70
self.album_view.swipe_page_right(0)
92
71
self.assertThat(spread.viewingPage, Eventually(Equals(1)))
94
73
# drag to next page and check we have flipped away from page 1
95
74
# can't check precisely for page 2 because depending on form factor
96
75
# and orientation we might be displaying two pages at the same time
97
self.pointing_device.drag(mid_x + mid_x / 2, mid_y, x + 10, mid_y)
98
self.assertThat(album.animationRunning, Eventually(Equals(False)))
76
self.album_view.swipe_page_right(1)
99
77
self.assertThat(spread.viewingPage, Eventually(GreaterThan(1)))
101
79
def test_add_photo(self):
102
self.main_view.close_toolbar()
103
80
self.open_first_album()
104
81
num_photos_start = self.album_view.number_of_photos()
105
82
self.assertThat(num_photos_start, Equals(1))
84
# should click away of any photo to toggle header
85
photo = self.album_view.get_first_photo()
86
x, y, w, h = photo.globalRect
87
self.pointing_device.move(x + 40, y + h + 40)
88
self.pointing_device.click()
107
90
# open media selector but cancel
108
self.main_view.open_toolbar().click_button("addButton")
109
self.ensure_media_selector_is_fully_open()
91
self.main_view.get_header().click_action_button("addButton")
92
self.media_selector.ensure_fully_open()
111
self.main_view.get_toolbar().click_custom_button("cancelButton")
112
self.ensure_media_selector_is_fully_closed()
94
self.main_view.get_header().click_custom_back_button()
114
97
num_photos = self.album_view.number_of_photos()
115
98
self.assertThat(num_photos, Equals(num_photos_start))
117
100
# open media selector and add a photo
118
self.main_view.open_toolbar().click_button("addButton")
119
self.ensure_media_selector_is_fully_open()
101
self.main_view.get_header().click_action_button("addButton")
102
self.media_selector.ensure_fully_open()
121
104
photo = self.media_selector.get_second_photo()
122
self.click_item(photo)
123
self.main_view.get_toolbar().click_custom_button("addButton")
105
checkbox = photo.select_single(objectName="selectionCheckbox")
106
self.click_item(checkbox)
107
self.main_view.get_header().click_action_button("addButton")
126
110
lambda: self.album_view.number_of_photos(),
127
111
Eventually(Equals(num_photos_start + 1)))
129
@skip("UnicodeEncodeError: 'ascii' codec can't encode character u'xa2'")
113
def test_remove_photo_from_album(self):
114
self.open_first_album()
115
num_photos_start = self.album_view.number_of_photos()
116
self.assertThat(num_photos_start, Equals(1))
118
path = self.album_view.click_first_photo()
120
self.assertThat(lambda: os.path.exists(path),
121
Eventually(Equals(True)))
123
photo_view = self.album_view.get_album_photo_view()
124
self.assertThat(photo_view.visible, Eventually(Equals(True)))
126
self.main_view.get_header().click_action_button("deleteButton")
127
self.album_view.click_remove_from_album_remove_button()
129
self.assertThat(lambda: self.album_view.number_of_photos(),
130
Eventually(Equals(num_photos_start - 1)))
132
self.assertThat(lambda: os.path.exists(path),
133
Eventually(Equals(True)))
135
def test_remove_photo_from_album_and_delete(self):
136
self.open_first_album()
137
num_photos_start = self.album_view.number_of_photos()
138
self.assertThat(num_photos_start, Equals(1))
140
path = self.album_view.click_first_photo()
142
self.assertThat(lambda: os.path.exists(path),
143
Eventually(Equals(True)))
145
photo_view = self.album_view.get_album_photo_view()
146
self.assertThat(photo_view.visible, Eventually(Equals(True)))
148
self.main_view.get_header().click_action_button("deleteButton")
149
self.album_view.click_remove_from_album_delete_button()
151
self.assertThat(lambda: self.album_view.number_of_photos(),
152
Eventually(Equals(num_photos_start - 1)))
154
self.assertThat(lambda: os.path.exists(path),
155
Eventually(Equals(False)))
157
def test_cancel_remove_photo_from_album(self):
158
self.open_first_album()
159
num_photos_start = self.album_view.number_of_photos()
160
self.assertThat(num_photos_start, Equals(1))
162
path = self.album_view.click_first_photo()
164
self.assertThat(lambda: os.path.exists(path),
165
Eventually(Equals(True)))
167
photo_view = self.album_view.get_album_photo_view()
168
self.assertThat(photo_view.visible, Eventually(Equals(True)))
170
self.main_view.get_header().click_action_button("deleteButton")
171
self.album_view.click_remove_from_album_cancel_button()
173
self.main_view.get_header().click_custom_back_button()
175
self.assertThat(lambda: self.album_view.number_of_photos(),
176
Eventually(Equals(num_photos_start)))
178
self.assertThat(lambda: os.path.exists(path),
179
Eventually(Equals(True)))
130
181
def test_add_photo_to_new_album(self):
131
self.main_view.open_toolbar().click_button("addButton")
182
self.main_view.get_header().click_action_button("addButton")
134
editor = self.app.select_single(album_editor.AlbumEditorAnimated)
185
editor = self.app.select_single(album_editor.AlbumEditor)
135
186
editor.ensure_fully_open()
136
self.main_view.close_toolbar()
139
self.open_first_album()
140
self.main_view.close_toolbar()
141
189
num_photos_start = self.album_view.number_of_photos()
142
190
self.assertThat(num_photos_start, Equals(0))
144
192
plus = self.album_view.get_plus_icon_empty_album()
145
# workaround lp:1247698
146
self.main_view.close_toolbar()
147
193
self.click_item(plus)
148
self.ensure_media_selector_is_fully_open()
194
self.media_selector.ensure_fully_open()
150
196
photo = self.media_selector.get_second_photo()
151
self.click_item(photo)
152
self.main_view.get_toolbar().click_custom_button("addButton")
197
checkbox = photo.select_single(objectName="selectionCheckbox")
198
self.click_item(checkbox)
199
self.main_view.get_header().click_action_button("addButton")
201
self.open_first_album()
155
203
lambda: self.album_view.number_of_photos(),
156
204
Eventually(Equals(num_photos_start + 1)))