Merge lp:~chris.gagnon/gallery-app/autopilot-fix-flakyness-and-make-work-on-desktop into lp:gallery-app
- autopilot-fix-flakyness-and-make-work-on-desktop
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 964 |
Proposed branch: | lp:~chris.gagnon/gallery-app/autopilot-fix-flakyness-and-make-work-on-desktop |
Merge into: | lp:gallery-app |
Prerequisite: | lp:~chris.gagnon/gallery-app/autopilot-test-cleanup |
Diff against target: |
994 lines (+241/-184) 21 files modified
debian/control (+4/-3) debian/gallery-app-autopilot.lintian-overrides (+1/-1) tests/autopilot/CMakeLists.txt (+1/-1) tests/autopilot/gallery_app/emulators/album_editor.py (+1/-1) tests/autopilot/gallery_app/emulators/album_view.py (+56/-1) tests/autopilot/gallery_app/emulators/albums_view.py (+1/-1) tests/autopilot/gallery_app/emulators/events_view.py (+50/-18) tests/autopilot/gallery_app/emulators/gallery_utils.py (+23/-1) tests/autopilot/gallery_app/emulators/media_selector.py (+1/-1) tests/autopilot/gallery_app/emulators/media_viewer.py (+5/-3) tests/autopilot/gallery_app/emulators/photo_viewer.py (+29/-1) tests/autopilot/gallery_app/emulators/photos_view.py (+1/-1) tests/autopilot/gallery_app/emulators/picker_screen.py (+0/-3) tests/autopilot/gallery_app/tests/__init__.py (+6/-5) tests/autopilot/gallery_app/tests/test_album_editor.py (+0/-2) tests/autopilot/gallery_app/tests/test_album_view.py (+4/-23) tests/autopilot/gallery_app/tests/test_albums_view.py (+7/-5) tests/autopilot/gallery_app/tests/test_events_view.py (+18/-39) tests/autopilot/gallery_app/tests/test_photo_viewer.py (+33/-66) tests/autopilot/gallery_app/tests/test_photos_view.py (+0/-2) tests/autopilot/gallery_app/tests/test_picker_mode.py (+0/-6) |
To merge this branch: | bzr merge lp:~chris.gagnon/gallery-app/autopilot-fix-flakyness-and-make-work-on-desktop |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Barry Warsaw (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Leo Arias (community) | Approve | ||
Chris Gagnon | Pending | ||
Review via email:
|
This proposal supersedes a proposal from 2014-04-30.
Commit message
fix tests on desktop,
fix flaky test,
pep8 fixes,
refactor test to make failures easier to diagnose.
[barry]
py3 port
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Leo Arias (elopio) wrote : Posted in a previous version of this proposal | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Leo Arias (elopio) : Posted in a previous version of this proposal | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Barry Warsaw (barry) wrote : Posted in a previous version of this proposal | # |
This looks great, but why not apply this patch too. Then you'll get the Python 3 port at the same time!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Leo Arias (elopio) : Posted in a previous version of this proposal | # |
- 961. By Chris Gagnon
-
fix flakyness, pep8 fixes and make work on desktop
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:960
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:961
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Leo Arias (elopio) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:960
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Timo Jyrinki (timo-jyrinki) wrote : | # |
Image testing hit the flaky add_photo test again at image #13:
http://
So as this branch should help with that, please get it merged :)
Preview Diff
1 | === modified file 'debian/control' |
2 | --- debian/control 2014-04-14 20:21:26 +0000 |
3 | +++ debian/control 2014-05-02 17:33:12 +0000 |
4 | @@ -15,8 +15,8 @@ |
5 | qt5-default, |
6 | qtbase5-dev, |
7 | qtdeclarative5-dev, |
8 | - python, |
9 | -Standards-Version: 3.9.4 |
10 | + python3-all, |
11 | +Standards-Version: 3.9.5 |
12 | # If you don't have commit rights to lp:gallery-app but need to upload |
13 | # packaging changes, just go ahead. The developers will notice and sync |
14 | # up the code again. |
15 | @@ -49,7 +49,8 @@ |
16 | libqt5test5, |
17 | ubuntu-ui-toolkit-autopilot, |
18 | unity8-autopilot, |
19 | - python-pkg-resources, |
20 | + python3-pkg-resources, |
21 | + python3-autopilot, |
22 | Description: Autopilot tests for the photo gallery for Ubuntu |
23 | gallery-app is a photo gallery for the Ubuntu platform. This package contains |
24 | autopilot tests for it. |
25 | |
26 | === modified file 'debian/gallery-app-autopilot.lintian-overrides' |
27 | --- debian/gallery-app-autopilot.lintian-overrides 2013-03-27 16:16:52 +0000 |
28 | +++ debian/gallery-app-autopilot.lintian-overrides 2014-05-02 17:33:12 +0000 |
29 | @@ -1,1 +1,1 @@ |
30 | -gallery-app-autopilot: image-file-in-usr-lib usr/lib/python2.7/dist-packages/gallery_app/data/sample.jpg |
31 | +gallery-app-autopilot: image-file-in-usr-lib usr/lib/python*/dist-packages/gallery_app/data/sample.jpg |
32 | |
33 | === modified file 'tests/autopilot/CMakeLists.txt' |
34 | --- tests/autopilot/CMakeLists.txt 2013-10-06 23:42:20 +0000 |
35 | +++ tests/autopilot/CMakeLists.txt 2014-05-02 17:33:12 +0000 |
36 | @@ -1,6 +1,6 @@ |
37 | set(AUTOPILOT_DIR gallery_app) |
38 | |
39 | -execute_process(COMMAND python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" |
40 | +execute_process(COMMAND python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())" |
41 | OUTPUT_VARIABLE PYTHON_PACKAGE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) |
42 | |
43 | if(INSTALL_TESTS) |
44 | |
45 | === modified file 'tests/autopilot/gallery_app/emulators/album_editor.py' |
46 | --- tests/autopilot/gallery_app/emulators/album_editor.py 2014-05-02 17:33:11 +0000 |
47 | +++ tests/autopilot/gallery_app/emulators/album_editor.py 2014-05-02 17:33:12 +0000 |
48 | @@ -15,7 +15,7 @@ |
49 | cover_image = self.album_cover_image() |
50 | # click left of the cover |
51 | x, y, w, h = cover_image.globalRect |
52 | - self.pointing_device.move(x - 10, y + (h/2)) |
53 | + self.pointing_device.move(x - 10, y + (h // 2)) |
54 | # workaround lp:1247698 (get rid of toolbar) |
55 | self.pointing_device.click() |
56 | self.pointing_device.click() |
57 | |
58 | === modified file 'tests/autopilot/gallery_app/emulators/album_view.py' |
59 | --- tests/autopilot/gallery_app/emulators/album_view.py 2014-05-02 17:33:11 +0000 |
60 | +++ tests/autopilot/gallery_app/emulators/album_view.py 2014-05-02 17:33:12 +0000 |
61 | @@ -5,13 +5,19 @@ |
62 | # under the terms of the GNU General Public License version 3, as published |
63 | # by the Free Software Foundation. |
64 | |
65 | -from gallery_utils import GalleryUtils |
66 | +from testtools.matchers import GreaterThan, LessThan |
67 | + |
68 | +from gallery_app.emulators.gallery_utils import( |
69 | + GalleryUtils, |
70 | + GalleryAppException, |
71 | +) |
72 | |
73 | |
74 | class AlbumView(GalleryUtils): |
75 | """An emulator class that makes it easy to interact with the gallery app""" |
76 | |
77 | def __init__(self, app): |
78 | + super(AlbumView, self).__init__(self) |
79 | self.app = app |
80 | |
81 | def get_animated_album_view(self): |
82 | @@ -66,3 +72,52 @@ |
83 | animated_viewer = self.get_animated_album_view() |
84 | animated_viewer.isOpen.wait_for(False) |
85 | animated_viewer.animationRunning.wait_for(False) |
86 | + |
87 | + def ensure_media_selector_is_fully_closed(self): |
88 | + """Ensure media selector is fully closed""" |
89 | + loader = self.media_selector_loader() |
90 | + loader.status.wait_for(0) |
91 | + |
92 | + def _swipe_setup(self, page_number, direction): |
93 | + self.album = self.get_album_view() |
94 | + self.spread = self.get_spread_view() |
95 | + self.album.animationRunning.wait_for(False) |
96 | + |
97 | + x, y, w, h = self.spread.globalRect |
98 | + mid_y = y + h // 2 |
99 | + mid_x = x + w // 2 |
100 | + |
101 | + if 'left' == direction: |
102 | + matcher = LessThan |
103 | + self.pointing_device.drag( |
104 | + mid_x, mid_y, # Start |
105 | + x + w, mid_y # Finish |
106 | + ) |
107 | + |
108 | + elif 'right' == direction: |
109 | + matcher = GreaterThan |
110 | + self.pointing_device.drag( |
111 | + mid_x, mid_y, # Start |
112 | + x, mid_y # Finish |
113 | + ) |
114 | + else: |
115 | + raise GalleryAppException( |
116 | + 'Direction can be "right" or "left" ' |
117 | + 'you choose "{}"'.format(direction)) |
118 | + |
119 | + self.album.animationRunning.wait_for(False) |
120 | + self.spread.viewingPage.wait_for(matcher(page_number)) |
121 | + |
122 | + def swipe_page_left(self, page_number): |
123 | + '''Swipe page to the left |
124 | + |
125 | + :param page_number: The starting page number you are swiping from |
126 | + ''' |
127 | + self._swipe_setup(page_number, 'left') |
128 | + |
129 | + def swipe_page_right(self, page_number): |
130 | + '''Swipe page to the right |
131 | + |
132 | + :param page_number: The starting page number you are swiping from |
133 | + ''' |
134 | + self._swipe_setup(page_number, 'right') |
135 | |
136 | === modified file 'tests/autopilot/gallery_app/emulators/albums_view.py' |
137 | --- tests/autopilot/gallery_app/emulators/albums_view.py 2013-08-09 10:20:19 +0000 |
138 | +++ tests/autopilot/gallery_app/emulators/albums_view.py 2014-05-02 17:33:12 +0000 |
139 | @@ -5,7 +5,7 @@ |
140 | # under the terms of the GNU General Public License version 3, as published |
141 | # by the Free Software Foundation. |
142 | |
143 | -from gallery_utils import GalleryUtils |
144 | +from gallery_app.emulators.gallery_utils import GalleryUtils |
145 | |
146 | |
147 | class AlbumsView(GalleryUtils): |
148 | |
149 | === modified file 'tests/autopilot/gallery_app/emulators/events_view.py' |
150 | --- tests/autopilot/gallery_app/emulators/events_view.py 2014-05-02 17:33:11 +0000 |
151 | +++ tests/autopilot/gallery_app/emulators/events_view.py 2014-05-02 17:33:12 +0000 |
152 | @@ -5,37 +5,69 @@ |
153 | # under the terms of the GNU General Public License version 3, as published |
154 | # by the Free Software Foundation. |
155 | |
156 | -from gallery_utils import GalleryUtils |
157 | +from gallery_app.emulators.gallery_utils import( |
158 | + GalleryAppException, |
159 | + GalleryUtils |
160 | +) |
161 | |
162 | |
163 | class EventsView(GalleryUtils): |
164 | |
165 | def __init__(self, app): |
166 | + super(EventsView, self).__init__(self) |
167 | self.app = app |
168 | |
169 | - def get_first_event(self): |
170 | - """Returns the first event in the event view""" |
171 | - return self.app.select_single("OrganicMediaList", |
172 | - objectName="organicEventItem0") |
173 | + def get_event(self, event_number=0): |
174 | + """Return an event in the event view based on index number |
175 | + |
176 | + :param event_number: the index number of the organicEventItem to get |
177 | + """ |
178 | + return self.app.select_single( |
179 | + 'OrganicMediaList', |
180 | + objectName='organicEventItem{}'.format(int(event_number)) |
181 | + ) |
182 | |
183 | def number_of_events(self): |
184 | - """Returns the number of events in the model behind the event view""" |
185 | - return self.app.select_single("EventsOverview")._eventCount |
186 | + """Return the number of events in the model behind the event view""" |
187 | + return self.app.select_single('EventsOverview')._eventCount |
188 | |
189 | def number_of_photos_in_events(self): |
190 | - """Returns the number of events""" |
191 | - photo_delegates = self.app.select_many("QQuickItem", |
192 | - objectName="eventPhoto") |
193 | + """Return the number of photos in events""" |
194 | + |
195 | + overview = self.app.select_single('EventsOverview') |
196 | + photo_delegates = overview.select_many( |
197 | + "QQuickItem", |
198 | + objectName="eventPhoto" |
199 | + ) |
200 | return len(photo_delegates) |
201 | |
202 | def number_of_photos_in_event(self, event): |
203 | - """Returns the number of photo delgated in an event""" |
204 | - photo_delegates = event.select_many("QQuickItem", |
205 | - objectName="eventPhoto") |
206 | + """Return the number of photo delgated in an event""" |
207 | + photo_delegates = event.select_many(objectName='eventPhoto') |
208 | return len(photo_delegates) |
209 | |
210 | - def get_first_image_in_event_view(self): |
211 | - """Returns the first photo of the gallery.""" |
212 | - event = self.get_first_event() |
213 | - return event.select_many("OrganicItemInteraction", |
214 | - objectName='eventsViewPhoto')[1] |
215 | + def _get_image_in_event_view(self, image_name, event_index_num=0): |
216 | + """Return the photo of the gallery based on image name. |
217 | + |
218 | + :param image_name: the name of the photo in the event to return""" |
219 | + event = self.get_event(event_index_num) |
220 | + photos = event.select_many( |
221 | + 'QQuickItem', |
222 | + objectName='eventPhoto' |
223 | + ) |
224 | + for photo in photos: |
225 | + images = photo.select_many('QQuickImage') |
226 | + for image in images: |
227 | + if str(image.source).endswith(image_name): |
228 | + return image |
229 | + raise GalleryAppException( |
230 | + 'Photo with image name {} could not be found'.format(image_name)) |
231 | + |
232 | + def click_photo(self, photo_name, event_index_num=0): |
233 | + """Click photo with name and event |
234 | + |
235 | + :param photo_name: name of file to click |
236 | + :param event_index_num: index of event to click |
237 | + """ |
238 | + photo = self._get_image_in_event_view(photo_name, event_index_num) |
239 | + self.pointing_device.click_object(photo) |
240 | |
241 | === modified file 'tests/autopilot/gallery_app/emulators/gallery_utils.py' |
242 | --- tests/autopilot/gallery_app/emulators/gallery_utils.py 2014-05-02 17:33:11 +0000 |
243 | +++ tests/autopilot/gallery_app/emulators/gallery_utils.py 2014-05-02 17:33:12 +0000 |
244 | @@ -4,10 +4,15 @@ |
245 | # This program is free software: you can redistribute it and/or modify it |
246 | # under the terms of the GNU General Public License version 3, as published |
247 | # by the Free Software Foundation. |
248 | +import ubuntuuitoolkit.emulators |
249 | |
250 | from time import sleep |
251 | |
252 | |
253 | +class GalleryAppException(Exception): |
254 | + pass |
255 | + |
256 | + |
257 | class GalleryUtils(object): |
258 | """An emulator class that makes it easy to interact with |
259 | general components of the gallery app.""" |
260 | @@ -16,6 +21,7 @@ |
261 | |
262 | def __init__(self, app): |
263 | self.app = app |
264 | + self.pointing_device = ubuntuuitoolkit.emulators.get_pointing_device() |
265 | |
266 | def select_many_retry(self, object_type, **kwargs): |
267 | """Returns the item that is searched for with app.select_many |
268 | @@ -26,7 +32,7 @@ |
269 | while len(items) < 1 and tries > 0: |
270 | sleep(self.retry_delay) |
271 | items = self.app.select_many(object_type, **kwargs) |
272 | - tries = tries - 1 |
273 | + tries -= 1 |
274 | return items |
275 | |
276 | def get_qml_view(self): |
277 | @@ -103,3 +109,19 @@ |
278 | objectName="albumCoverMenuItem", |
279 | text=text |
280 | ) |
281 | + |
282 | + def _ensure_delete_dialog_visible(self): |
283 | + delete_dialog = self.get_delete_dialog() |
284 | + delete_dialog.opacity.wait_for(1) |
285 | + |
286 | + def _click_dialog_button(self, button): |
287 | + self._ensure_delete_dialog_visible() |
288 | + self.pointing_device.click_object(button) |
289 | + |
290 | + def click_delete_dialog_cancel_button(self): |
291 | + button = self.get_delete_dialog_cancel_button() |
292 | + self._click_dialog_button(button) |
293 | + |
294 | + def click_delete_dialog_delete_button(self): |
295 | + button = self.get_delete_dialog_delete_button() |
296 | + self._click_dialog_button(button) |
297 | |
298 | === modified file 'tests/autopilot/gallery_app/emulators/media_selector.py' |
299 | --- tests/autopilot/gallery_app/emulators/media_selector.py 2014-05-02 17:33:11 +0000 |
300 | +++ tests/autopilot/gallery_app/emulators/media_selector.py 2014-05-02 17:33:12 +0000 |
301 | @@ -5,7 +5,7 @@ |
302 | # under the terms of the GNU General Public License version 3, as published |
303 | # by the Free Software Foundation. |
304 | |
305 | -from gallery_utils import GalleryUtils |
306 | +from gallery_app.emulators.gallery_utils import GalleryUtils |
307 | |
308 | |
309 | class MediaSelector(GalleryUtils): |
310 | |
311 | === modified file 'tests/autopilot/gallery_app/emulators/media_viewer.py' |
312 | --- tests/autopilot/gallery_app/emulators/media_viewer.py 2014-05-02 17:33:11 +0000 |
313 | +++ tests/autopilot/gallery_app/emulators/media_viewer.py 2014-05-02 17:33:12 +0000 |
314 | @@ -11,11 +11,13 @@ |
315 | class MediaViewer(toolkit_emulators.UbuntuUIToolkitEmulatorBase): |
316 | """A class that makes it easy to interact with the media viewer""" |
317 | |
318 | - def __init__(self, *args): |
319 | - super(MediaViewer, self).__init__(*args) |
320 | - |
321 | def get_edit_spinner(self): |
322 | return self.select_single( |
323 | "ActivityIndicator", |
324 | objectName="busySpinner" |
325 | ) |
326 | + |
327 | + def ensure_spinner_not_running(self): |
328 | + """Wait for spinner to stop running""" |
329 | + spinner = self.get_edit_spinner() |
330 | + spinner.running.wait_for(False) |
331 | |
332 | === modified file 'tests/autopilot/gallery_app/emulators/photo_viewer.py' |
333 | --- tests/autopilot/gallery_app/emulators/photo_viewer.py 2014-02-04 17:37:28 +0000 |
334 | +++ tests/autopilot/gallery_app/emulators/photo_viewer.py 2014-05-02 17:33:12 +0000 |
335 | @@ -5,12 +5,13 @@ |
336 | # under the terms of the GNU General Public License version 3, as published |
337 | # by the Free Software Foundation. |
338 | |
339 | -from gallery_utils import GalleryUtils |
340 | +from gallery_app.emulators.gallery_utils import GalleryUtils |
341 | |
342 | |
343 | class PhotoViewer(GalleryUtils): |
344 | |
345 | def __init__(self, app): |
346 | + super(PhotoViewer, self).__init__(self) |
347 | self.app = app |
348 | |
349 | def get_delete_dialog(self): |
350 | @@ -116,3 +117,30 @@ |
351 | """Returns the edit preview.""" |
352 | return self.app.wait_select_single("EditPreview", |
353 | objectName="editPreview") |
354 | + |
355 | + def _click_item(self, item): |
356 | + self.pointing_device.click_object(item) |
357 | + |
358 | + def click_rotate_item(self): |
359 | + rotate_item = self.get_rotate_menu_item() |
360 | + self._click_item(rotate_item) |
361 | + |
362 | + def click_crop_item(self): |
363 | + crop_item = self.get_crop_menu_item() |
364 | + self._click_item(crop_item) |
365 | + |
366 | + def click_undo_item(self): |
367 | + undo_item = self.get_undo_menu_item() |
368 | + self._click_item(undo_item) |
369 | + |
370 | + def click_redo_item(self): |
371 | + redo_item = self.get_redo_menu_item() |
372 | + self._click_item(redo_item) |
373 | + |
374 | + def click_revert_item(self): |
375 | + revert_item = self.get_revert_menu_item() |
376 | + self._click_item(revert_item) |
377 | + |
378 | + def click_enhance_item(self): |
379 | + enhance_item = self.get_auto_enhance_menu_item() |
380 | + self._click_item(enhance_item) |
381 | |
382 | === modified file 'tests/autopilot/gallery_app/emulators/photos_view.py' |
383 | --- tests/autopilot/gallery_app/emulators/photos_view.py 2014-05-02 17:33:11 +0000 |
384 | +++ tests/autopilot/gallery_app/emulators/photos_view.py 2014-05-02 17:33:12 +0000 |
385 | @@ -5,7 +5,7 @@ |
386 | # under the terms of the GNU General Public License version 3, as published |
387 | # by the Free Software Foundation. |
388 | |
389 | -from gallery_utils import GalleryUtils |
390 | +from gallery_app.emulators.gallery_utils import GalleryUtils |
391 | |
392 | |
393 | class PhotosView(GalleryUtils): |
394 | |
395 | === modified file 'tests/autopilot/gallery_app/emulators/picker_screen.py' |
396 | --- tests/autopilot/gallery_app/emulators/picker_screen.py 2014-05-02 17:33:11 +0000 |
397 | +++ tests/autopilot/gallery_app/emulators/picker_screen.py 2014-04-09 08:19:24 +0000 |
398 | @@ -31,7 +31,6 @@ |
399 | def first_media_in_grid_view(self): |
400 | grid_view = self.grid_view() |
401 | return grid_view.select_many("OrganicItemInteraction")[0] |
402 | -<<<<<<< TREE |
403 | |
404 | def _get_named_photo_element(self, photo_name): |
405 | """ |
406 | @@ -46,5 +45,3 @@ |
407 | """Select the named photo from the picker view.""" |
408 | photo_element = self._get_named_photo_element(photo_name) |
409 | self.pointing_device.click_object(photo_element) |
410 | -======= |
411 | ->>>>>>> MERGE-SOURCE |
412 | |
413 | === modified file 'tests/autopilot/gallery_app/tests/__init__.py' |
414 | --- tests/autopilot/gallery_app/tests/__init__.py 2014-03-31 08:38:45 +0000 |
415 | +++ tests/autopilot/gallery_app/tests/__init__.py 2014-05-02 17:33:12 +0000 |
416 | @@ -7,8 +7,8 @@ |
417 | |
418 | """gallery autopilot tests.""" |
419 | |
420 | +import os |
421 | import logging |
422 | -import os.path |
423 | import shutil |
424 | import signal |
425 | |
426 | @@ -24,7 +24,6 @@ |
427 | from gallery_app.emulators.gallery_utils import GalleryUtils |
428 | |
429 | from time import sleep |
430 | -from os import remove |
431 | |
432 | logger = logging.getLogger(__name__) |
433 | |
434 | @@ -69,6 +68,8 @@ |
435 | # in /usr |
436 | if os.path.realpath(__file__).startswith("/usr/"): |
437 | return EnvironmentTypes.installed |
438 | + if model() == 'Desktop': |
439 | + return EnvironmentTypes.installed |
440 | else: |
441 | if os.path.exists(self.local_location): |
442 | return EnvironmentTypes.local |
443 | @@ -144,7 +145,7 @@ |
444 | config = os.path.expanduser( |
445 | os.path.join("~", ".config", "gallery-app.conf")) |
446 | if os.path.exists(config): |
447 | - remove(config) |
448 | + os.remove(config) |
449 | |
450 | def setUp(self): |
451 | self.pointing_device = toolkit_emulators.get_pointing_device() |
452 | @@ -164,8 +165,8 @@ |
453 | self.assertThat(self.gallery_utils.get_qml_view().visible, |
454 | Eventually(Equals(True))) |
455 | """FIXME somehow on the server gallery sometimes is not fully started |
456 | - for switching to the albums view. Therefore this hack of a second""" |
457 | - sleep(1) |
458 | + for switching to the albums view. Therefore this hack of sleeping""" |
459 | + sleep(2) |
460 | |
461 | def launch_gallery_app(self, env_type): |
462 | if env_type == EnvironmentTypes.installed: |
463 | |
464 | === modified file 'tests/autopilot/gallery_app/tests/test_album_editor.py' |
465 | --- tests/autopilot/gallery_app/tests/test_album_editor.py 2014-05-02 17:33:11 +0000 |
466 | +++ tests/autopilot/gallery_app/tests/test_album_editor.py 2014-05-02 17:33:12 +0000 |
467 | @@ -8,8 +8,6 @@ |
468 | |
469 | """Tests the album editor of the gallery app""" |
470 | |
471 | -from __future__ import absolute_import |
472 | - |
473 | from testtools.matchers import Equals |
474 | from autopilot.matchers import Eventually |
475 | |
476 | |
477 | === modified file 'tests/autopilot/gallery_app/tests/test_album_view.py' |
478 | --- tests/autopilot/gallery_app/tests/test_album_view.py 2014-05-02 17:33:11 +0000 |
479 | +++ tests/autopilot/gallery_app/tests/test_album_view.py 2014-05-02 17:33:12 +0000 |
480 | @@ -8,8 +8,6 @@ |
481 | |
482 | """Tests the album view of the gallery app""" |
483 | |
484 | -from __future__ import absolute_import |
485 | - |
486 | from testtools.matchers import Equals, GreaterThan, LessThan |
487 | from autopilot.matchers import Eventually |
488 | |
489 | @@ -42,10 +40,6 @@ |
490 | super(TestAlbumView, self).setUp() |
491 | self.switch_to_albums_tab() |
492 | |
493 | - def ensure_media_selector_is_fully_closed(self): |
494 | - loader = self.album_view.media_selector_loader() |
495 | - self.assertThat(loader.status, Eventually(Equals(0))) |
496 | - |
497 | def test_album_view_open_photo(self): |
498 | self.main_view.close_toolbar() |
499 | self.open_first_album() |
500 | @@ -66,32 +60,20 @@ |
501 | self.open_album_at(0) |
502 | self.main_view.close_toolbar() |
503 | |
504 | - album = self.album_view.get_album_view() |
505 | spread = self.album_view.get_spread_view() |
506 | |
507 | - self.assertThat(album.animationRunning, Eventually(Equals(False))) |
508 | - self.assertThat(spread.viewingPage, Eventually(Equals(1))) |
509 | - self.main_view.close_toolbar() |
510 | - |
511 | - x, y, w, h = spread.globalRect |
512 | - mid_y = y + h / 2 |
513 | - mid_x = x + w / 2 |
514 | - |
515 | # check that we can page to the cover and back (we check for lesser |
516 | # than 1 because it can either be 0 if we are on a one page spread |
517 | # or -1 if we are on a two page spread, for example on desktop) |
518 | - self.pointing_device.drag(mid_x - mid_x / 2, mid_y, x + w - 10, mid_y) |
519 | - self.album_view.get_animated_album_view() |
520 | + self.album_view.swipe_page_left(1) |
521 | self.assertThat(spread.viewingPage, Eventually(LessThan(1))) |
522 | - self.pointing_device.drag(mid_x + mid_x / 2, mid_y, x + 10, mid_y) |
523 | - self.album_view.get_animated_album_view() |
524 | + self.album_view.swipe_page_right(0) |
525 | self.assertThat(spread.viewingPage, Eventually(Equals(1))) |
526 | |
527 | # drag to next page and check we have flipped away from page 1 |
528 | # can't check precisely for page 2 because depending on form factor |
529 | # and orientation we might be displaying two pages at the same time |
530 | - self.pointing_device.drag(mid_x + mid_x / 2, mid_y, x + 10, mid_y) |
531 | - self.assertThat(album.animationRunning, Eventually(Equals(False))) |
532 | + self.album_view.swipe_page_right(1) |
533 | self.assertThat(spread.viewingPage, Eventually(GreaterThan(1))) |
534 | |
535 | def test_add_photo(self): |
536 | @@ -105,7 +87,7 @@ |
537 | self.media_selector.ensure_fully_open() |
538 | |
539 | self.main_view.get_toolbar().click_custom_button("cancelButton") |
540 | - self.ensure_media_selector_is_fully_closed() |
541 | + self.album_view.ensure_media_selector_is_fully_closed() |
542 | |
543 | num_photos = self.album_view.number_of_photos() |
544 | self.assertThat(num_photos, Equals(num_photos_start)) |
545 | @@ -122,7 +104,6 @@ |
546 | lambda: self.album_view.number_of_photos(), |
547 | Eventually(Equals(num_photos_start + 1))) |
548 | |
549 | - @skip("UnicodeEncodeError: 'ascii' codec can't encode character u'xa2'") |
550 | def test_add_photo_to_new_album(self): |
551 | self.main_view.open_toolbar().click_button("addButton") |
552 | self.ui_update() |
553 | |
554 | === modified file 'tests/autopilot/gallery_app/tests/test_albums_view.py' |
555 | --- tests/autopilot/gallery_app/tests/test_albums_view.py 2014-05-02 17:33:11 +0000 |
556 | +++ tests/autopilot/gallery_app/tests/test_albums_view.py 2014-05-02 17:33:12 +0000 |
557 | @@ -8,8 +8,6 @@ |
558 | |
559 | """Tests the albums view of the gallery app.""" |
560 | |
561 | -from __future__ import absolute_import |
562 | - |
563 | from testtools.matchers import Equals |
564 | from autopilot.matchers import Eventually |
565 | from autopilot.platform import model |
566 | @@ -59,14 +57,18 @@ |
567 | ) |
568 | |
569 | def test_add_album_and_cancel(self): |
570 | - """Add one album, cancel it and checks if the number of albums does not change""" |
571 | + """Add one album, cancel it and checks if the number of albums does |
572 | + not change |
573 | + """ |
574 | albums = self.albums_view.number_of_albums_in_albums_view() |
575 | self.main_view.open_toolbar().click_button("addButton") |
576 | editor = self.app.select_single(album_editor.AlbumEditorAnimated) |
577 | editor.ensure_fully_open() |
578 | self.main_view.get_toolbar().click_custom_button("cancelButton") |
579 | - self.assertThat(lambda: self.albums_view.number_of_albums_in_albums_view(), |
580 | - Eventually(Equals(albums))) |
581 | + self.assertThat( |
582 | + lambda: self.albums_view.number_of_albums_in_albums_view(), |
583 | + Eventually(Equals(albums)) |
584 | + ) |
585 | |
586 | # Check if Camera Button is not visible at Desktop mode |
587 | def test_camera_button_visible(self): |
588 | |
589 | === modified file 'tests/autopilot/gallery_app/tests/test_events_view.py' |
590 | --- tests/autopilot/gallery_app/tests/test_events_view.py 2014-05-02 17:33:11 +0000 |
591 | +++ tests/autopilot/gallery_app/tests/test_events_view.py 2014-05-02 17:33:12 +0000 |
592 | @@ -8,8 +8,6 @@ |
593 | |
594 | """Tests for the Gallery App""" |
595 | |
596 | -from __future__ import absolute_import |
597 | - |
598 | from testtools.matchers import Equals, NotEquals, Is, GreaterThan |
599 | from autopilot.matchers import Eventually |
600 | from autopilot.platform import model |
601 | @@ -63,15 +61,6 @@ |
602 | def enable_select_mode(self): |
603 | self.main_view.open_toolbar().click_button("selectButton") |
604 | |
605 | - def click_first_photo(self): |
606 | - first_photo = self.events_view.get_first_image_in_event_view() |
607 | - self.click_item(first_photo) |
608 | - |
609 | - def assert_delete_dialog_visible(self): |
610 | - delete_dialog = self.gallery_utils.get_delete_dialog() |
611 | - |
612 | - self.assertThat(delete_dialog.opacity, Eventually(Equals(1))) |
613 | - |
614 | def test_select_button_cancel(self): |
615 | """Clicking the cancel button after clicking the select button must |
616 | hide the toolbar automatically.""" |
617 | @@ -87,60 +76,50 @@ |
618 | self.assertThat(toolbar.opened, Eventually(Equals(False))) |
619 | self.assertFalse(events_view.inSelectionMode) |
620 | |
621 | - first_photo = self.events_view.get_first_image_in_event_view() |
622 | - self.tap_item(first_photo) |
623 | - self.assertTrue(events_view.inSelectionMode) |
624 | - |
625 | def test_delete_a_photo(self): |
626 | """Selecting a photo must make the delete button clickable.""" |
627 | - number_of_photos = self.events_view.number_of_photos_in_events() |
628 | + self.assertThat(lambda: exists(self.sample_file), |
629 | + Eventually(Equals(True))) |
630 | + |
631 | self.enable_select_mode() |
632 | - self.click_first_photo() |
633 | + self.events_view.click_photo(self.sample_file) |
634 | self.main_view.open_toolbar().click_button("deleteButton") |
635 | - self.assert_delete_dialog_visible() |
636 | + self.assertThat(self.gallery_utils.delete_dialog_shown, |
637 | + Eventually(Is(True))) |
638 | |
639 | - cancel_item = self.gallery_utils.get_delete_dialog_cancel_button() |
640 | - self.click_item(cancel_item) |
641 | + self.gallery_utils.click_delete_dialog_cancel_button() |
642 | + self.assertThat(self.gallery_utils.delete_dialog_shown, |
643 | + Eventually(Is(False))) |
644 | |
645 | self.assertThat(lambda: exists(self.sample_file), |
646 | Eventually(Equals(True))) |
647 | |
648 | - new_number_of_photos = self.events_view.number_of_photos_in_events() |
649 | - self.assertThat(new_number_of_photos, Equals(number_of_photos)) |
650 | - |
651 | - self.assertThat(self.gallery_utils.delete_dialog_shown, |
652 | - Eventually(Is(False))) |
653 | - |
654 | self.main_view.open_toolbar().click_button("deleteButton") |
655 | - self.assert_delete_dialog_visible() |
656 | + self.assertThat(self.gallery_utils.delete_dialog_shown, |
657 | + Eventually(Is(True))) |
658 | |
659 | - delete_item = self.gallery_utils.get_delete_dialog_delete_button() |
660 | - self.click_item(delete_item) |
661 | + self.gallery_utils.click_delete_dialog_delete_button() |
662 | self.assertThat(self.gallery_utils.delete_dialog_shown, |
663 | Eventually(Is(False))) |
664 | |
665 | self.assertThat(lambda: exists(self.sample_file), |
666 | Eventually(Equals(False))) |
667 | |
668 | - self.ui_update() |
669 | - new_number_of_photos = self.events_view.number_of_photos_in_events() |
670 | - self.assertThat(new_number_of_photos, Equals(number_of_photos - 1)) |
671 | - |
672 | def test_adding_a_video(self): |
673 | if model() == "Desktop": |
674 | - first_before = self.events_view.get_first_event() |
675 | + before = self.events_view.get_event(0) |
676 | video_file = "video.mp4" |
677 | shutil.copyfile(self.sample_dir+"/option01/"+video_file, |
678 | self.sample_destination_dir+"/"+video_file) |
679 | video_file = "video.mkv" |
680 | shutil.copyfile(self.sample_dir+"/option01/"+video_file, |
681 | self.sample_destination_dir+"/"+video_file) |
682 | - first = self.events_view.get_first_event() |
683 | - self.assertThat(lambda: str(first), |
684 | - Eventually(NotEquals(str(first_before)))) |
685 | + after = self.events_view.get_event(0) |
686 | + self.assertThat(lambda: str(after), |
687 | + Eventually(NotEquals(str(before)))) |
688 | self.assertThat( |
689 | - lambda: self.events_view.number_of_photos_in_event(first), |
690 | - Eventually(Equals(2))) |
691 | + lambda: self.events_view.number_of_photos_in_events(), |
692 | + Eventually(Equals(3))) |
693 | |
694 | # Check if Camera Button is not visible at Desktop mode |
695 | def test_camera_button_visible(self): |
696 | |
697 | === modified file 'tests/autopilot/gallery_app/tests/test_photo_viewer.py' |
698 | --- tests/autopilot/gallery_app/tests/test_photo_viewer.py 2014-05-02 17:33:11 +0000 |
699 | +++ tests/autopilot/gallery_app/tests/test_photo_viewer.py 2014-05-02 17:33:12 +0000 |
700 | @@ -8,8 +8,6 @@ |
701 | |
702 | """Tests the Photo editor of the gallery app.""" |
703 | |
704 | -from __future__ import absolute_import |
705 | - |
706 | from testtools.matchers import Equals, NotEquals, GreaterThan, Is |
707 | from autopilot.matchers import Eventually |
708 | |
709 | @@ -18,7 +16,6 @@ |
710 | from gallery_app.emulators.events_view import EventsView |
711 | from gallery_app.tests import GalleryTestCase |
712 | |
713 | -from os.path import exists |
714 | import os |
715 | from time import sleep |
716 | import unittest |
717 | @@ -45,15 +42,16 @@ |
718 | self.main_view.open_toolbar() |
719 | |
720 | def open_first_photo(self): |
721 | - self.assertThat(lambda: self.events_view.number_of_photos_in_events(), |
722 | - Eventually(GreaterThan(0))) |
723 | - single_photo = self.events_view.get_first_image_in_event_view() |
724 | + self.assertThat( |
725 | + lambda: self.events_view.number_of_photos_in_events(), |
726 | + Eventually(GreaterThan(0)) |
727 | + ) |
728 | |
729 | # workaround lp:1247698 |
730 | # toolbar needs to be gone to click on an image. |
731 | self.main_view.close_toolbar() |
732 | |
733 | - self.click_item(single_photo) |
734 | + self.events_view.click_photo(self.sample_file) |
735 | |
736 | photo_viewer_loader = self.photo_viewer.get_main_photo_viewer_loader() |
737 | self.assertThat(photo_viewer_loader.loaded, Eventually(Equals(True))) |
738 | @@ -64,9 +62,6 @@ |
739 | |
740 | class TestPhotoViewer(TestPhotoViewerBase): |
741 | |
742 | - def setUp(self): |
743 | - super(TestPhotoViewer, self).setUp() |
744 | - |
745 | @unittest.skip("Temporarily disable as it fails in some cases, " |
746 | "supposedly due to problems with the infrastructure") |
747 | def test_save_state(self): |
748 | @@ -132,11 +127,11 @@ |
749 | self.click_item(cancel_item) |
750 | self.ensure_closed_delete_dialog() |
751 | |
752 | - self.assertThat(lambda: exists(self.sample_file), |
753 | + self.assertThat(lambda: os.path.exists(self.sample_file), |
754 | Eventually(Equals(True))) |
755 | |
756 | self.delete_one_picture() |
757 | - self.assertThat(lambda: exists(self.sample_file), |
758 | + self.assertThat(lambda: os.path.exists(self.sample_file), |
759 | Eventually(Equals(False))) |
760 | |
761 | # Delete all other pictures and make sure the photo viewer closes |
762 | @@ -183,8 +178,8 @@ |
763 | |
764 | # Slide left should move to the next image |
765 | x, y, w, h = list.globalRect |
766 | - mid_y = y + h / 2 |
767 | - mid_x = x + w / 2 |
768 | + mid_y = y + h // 2 |
769 | + mid_x = x + w // 2 |
770 | self.pointing_device.drag(mid_x, mid_y, x + 10, mid_y) |
771 | |
772 | self.assertThat(list.moving, Eventually(Equals(False))) |
773 | @@ -208,6 +203,7 @@ |
774 | def setUp(self): |
775 | super(TestPhotoEditor, self).setUp() |
776 | self.click_edit_button() |
777 | + self.media_view = self.app.select_single(MediaViewer) |
778 | |
779 | def click_edit_button(self): |
780 | self.main_view.open_toolbar().click_button("editButton") |
781 | @@ -215,35 +211,6 @@ |
782 | self.assertThat(edit_dialog.visible, (Eventually(Equals(True)))) |
783 | self.assertThat(edit_dialog.opacity, (Eventually(Equals(1)))) |
784 | |
785 | - def click_rotate_item(self): |
786 | - rotate_item = self.photo_viewer.get_rotate_menu_item() |
787 | - self.click_item(rotate_item) |
788 | - |
789 | - def click_crop_item(self): |
790 | - crop_item = self.photo_viewer.get_crop_menu_item() |
791 | - self.click_item(crop_item) |
792 | - |
793 | - def click_undo_item(self): |
794 | - undo_item = self.photo_viewer.get_undo_menu_item() |
795 | - self.click_item(undo_item) |
796 | - |
797 | - def click_redo_item(self): |
798 | - redo_item = self.photo_viewer.get_redo_menu_item() |
799 | - self.click_item(redo_item) |
800 | - |
801 | - def click_revert_item(self): |
802 | - revert_item = self.photo_viewer.get_revert_menu_item() |
803 | - self.click_item(revert_item) |
804 | - |
805 | - def click_enhance_item(self): |
806 | - enhance_item = self.photo_viewer.get_auto_enhance_menu_item() |
807 | - self.click_item(enhance_item) |
808 | - |
809 | - def ensure_spinner_not_running(self): |
810 | - media_view = self.app.select_single(MediaViewer) |
811 | - spinner = media_view.get_edit_spinner() |
812 | - self.assertThat(spinner.running, Eventually(Equals(False))) |
813 | - |
814 | def test_photo_editor_crop(self): |
815 | """Cropping a photo must crop it.""" |
816 | old_file_size = os.path.getsize(self.sample_file) |
817 | @@ -252,17 +219,17 @@ |
818 | item_width = crop_box.width |
819 | item_height = crop_box.height |
820 | |
821 | - self.click_crop_item() |
822 | + self.photo_viewer.click_crop_item() |
823 | |
824 | self.assertThat(crop_box.state, Eventually(Equals("shown"))) |
825 | self.assertThat(crop_box.opacity, Eventually(Equals(1))) |
826 | |
827 | crop_corner = self.photo_viewer.get_top_left_crop_corner() |
828 | x, y, h, w = crop_corner.globalRect |
829 | - x = x + w / 2 |
830 | - y = y + h / 2 |
831 | + x = x + w // 2 |
832 | + y = y + h // 2 |
833 | self.pointing_device.drag(x, y, |
834 | - x + item_width / 2, y + item_height / 2) |
835 | + x + item_width // 2, y + item_height // 2) |
836 | |
837 | # wait for animation being finished |
838 | crop_overlay = self.photo_viewer.get_crop_overlay() |
839 | @@ -271,7 +238,7 @@ |
840 | |
841 | crop_button = self.photo_viewer.get_crop_overlays_crop_icon() |
842 | self.click_item(crop_button) |
843 | - self.ensure_spinner_not_running() |
844 | + self.media_view.ensure_spinner_not_running() |
845 | |
846 | # wait for new photo being set/reloaded, so saving thumbnailing etc. |
847 | # is done |
848 | @@ -293,8 +260,8 @@ |
849 | return opened_photo.paintedWidth > opened_photo.paintedHeight |
850 | self.assertThat(is_landscape(), Equals(True)) |
851 | |
852 | - self.click_rotate_item() |
853 | - self.ensure_spinner_not_running() |
854 | + self.photo_viewer.click_rotate_item() |
855 | + self.media_view.ensure_spinner_not_running() |
856 | |
857 | self.assertThat(opened_photo.paintedHeight, |
858 | Eventually(Equals(item_height))) |
859 | @@ -303,8 +270,8 @@ |
860 | |
861 | self.main_view.open_toolbar() |
862 | self.click_edit_button() |
863 | - self.click_undo_item() |
864 | - self.ensure_spinner_not_running() |
865 | + self.photo_viewer.click_undo_item() |
866 | + self.media_view.ensure_spinner_not_running() |
867 | |
868 | self.assertThat(opened_photo.paintedHeight, |
869 | Eventually(NotEquals(item_height))) |
870 | @@ -313,8 +280,8 @@ |
871 | |
872 | self.main_view.open_toolbar() |
873 | self.click_edit_button() |
874 | - self.click_redo_item() |
875 | - self.ensure_spinner_not_running() |
876 | + self.photo_viewer.click_redo_item() |
877 | + self.media_view.ensure_spinner_not_running() |
878 | |
879 | self.assertThat(opened_photo.paintedHeight, |
880 | Eventually(Equals(item_height))) |
881 | @@ -323,10 +290,10 @@ |
882 | |
883 | self.main_view.open_toolbar() |
884 | self.click_edit_button() |
885 | - self.click_rotate_item() |
886 | + self.photo_viewer.click_rotate_item() |
887 | self.main_view.open_toolbar() |
888 | self.click_edit_button() |
889 | - self.click_revert_item() |
890 | + self.photo_viewer.click_revert_item() |
891 | |
892 | self.assertThat(opened_photo.paintedHeight, |
893 | Eventually(NotEquals(item_height))) |
894 | @@ -348,8 +315,8 @@ |
895 | self.assertThat(redo_item.enabled, Eventually(Equals(False))) |
896 | self.assertThat(revert_item.enabled, Eventually(Equals(False))) |
897 | |
898 | - self.click_rotate_item() |
899 | - self.ensure_spinner_not_running() |
900 | + self.photo_viewer.click_rotate_item() |
901 | + self.media_view.ensure_spinner_not_running() |
902 | |
903 | self.click_edit_button() |
904 | undo_item = self.photo_viewer.get_undo_menu_item() |
905 | @@ -360,8 +327,8 @@ |
906 | self.assertThat(redo_item.enabled, Eventually(Equals(False))) |
907 | self.assertThat(revert_item.enabled, Eventually(Equals(True))) |
908 | |
909 | - self.click_undo_item() |
910 | - self.ensure_spinner_not_running() |
911 | + self.photo_viewer.click_undo_item() |
912 | + self.media_view.ensure_spinner_not_running() |
913 | |
914 | self.click_edit_button() |
915 | undo_item = self.photo_viewer.get_undo_menu_item() |
916 | @@ -372,8 +339,8 @@ |
917 | self.assertThat(redo_item.enabled, Eventually(Equals(True))) |
918 | self.assertThat(revert_item.enabled, Eventually(Equals(False))) |
919 | |
920 | - self.click_redo_item() |
921 | - self.ensure_spinner_not_running() |
922 | + self.photo_viewer.click_redo_item() |
923 | + self.media_view.ensure_spinner_not_running() |
924 | |
925 | self.click_edit_button() |
926 | undo_item = self.photo_viewer.get_undo_menu_item() |
927 | @@ -384,8 +351,8 @@ |
928 | self.assertThat(redo_item.enabled, Eventually(Equals(False))) |
929 | self.assertThat(revert_item.enabled, Eventually(Equals(True))) |
930 | |
931 | - self.click_revert_item() |
932 | - self.ensure_spinner_not_running() |
933 | + self.photo_viewer.click_revert_item() |
934 | + self.media_view.ensure_spinner_not_running() |
935 | |
936 | self.click_edit_button() |
937 | undo_item = self.photo_viewer.get_undo_menu_item() |
938 | @@ -396,8 +363,8 @@ |
939 | self.assertThat(redo_item.enabled, Eventually(Equals(False))) |
940 | self.assertThat(revert_item.enabled, Eventually(Equals(False))) |
941 | |
942 | - self.click_enhance_item() |
943 | - self.ensure_spinner_not_running() |
944 | + self.photo_viewer.click_enhance_item() |
945 | + self.media_view.ensure_spinner_not_running() |
946 | |
947 | self.click_edit_button() |
948 | |
949 | |
950 | === modified file 'tests/autopilot/gallery_app/tests/test_photos_view.py' |
951 | --- tests/autopilot/gallery_app/tests/test_photos_view.py 2014-05-02 17:33:11 +0000 |
952 | +++ tests/autopilot/gallery_app/tests/test_photos_view.py 2014-05-02 17:33:12 +0000 |
953 | @@ -8,8 +8,6 @@ |
954 | |
955 | """Tests the Photos view of the gallery app.""" |
956 | |
957 | -from __future__ import absolute_import |
958 | - |
959 | from testtools.matchers import Equals, Is |
960 | from testtools import skipUnless |
961 | from autopilot.matchers import Eventually |
962 | |
963 | === modified file 'tests/autopilot/gallery_app/tests/test_picker_mode.py' |
964 | --- tests/autopilot/gallery_app/tests/test_picker_mode.py 2014-05-02 17:33:11 +0000 |
965 | +++ tests/autopilot/gallery_app/tests/test_picker_mode.py 2014-05-02 17:33:12 +0000 |
966 | @@ -8,8 +8,6 @@ |
967 | |
968 | """Tests the Photos view of the gallery app.""" |
969 | |
970 | -from __future__ import absolute_import |
971 | - |
972 | from testtools.matchers import Equals |
973 | from autopilot.matchers import Eventually |
974 | |
975 | @@ -66,7 +64,6 @@ |
976 | Eventually(Equals(False)) |
977 | ) |
978 | |
979 | -<<<<<<< TREE |
980 | def test_pick_named_photo(self): |
981 | """Select a named photo and press Pick button.""" |
982 | self.picker_view.switch_to_tab('photosTab') |
983 | @@ -81,11 +78,8 @@ |
984 | self.assertTrue(pick_button.enabled) |
985 | self.click_item(pick_button) |
986 | |
987 | - @unittest.skip("Temporarily disable as it fails in some cases, supposedly due to problems with the infrastructure") |
988 | -======= |
989 | @unittest.skip("Temporarily disable as it fails in some cases, " |
990 | "supposedly due to problems with the infrastructure") |
991 | ->>>>>>> MERGE-SOURCE |
992 | def test_selection_synchronisation(self): |
993 | """Checks if the selection is the same for both views""" |
994 | first_events_media = self.picker_view.first_media_in_events_view() |
22 + self.pointing_ device = ubuntuuitoolkit .emulators. get_pointing_ device( )
GalleryUtils already has a pointing_device attribute. You should just call the super __init__()
I would actually prefer not to inherit from something like GalleryUtils, but from an autopilot introspection object, but that probably should be in a later refactor.
35 + def _swipe_setup(self):
Here I don't like that you are adding attributes to the object on a method that's not __init__.
I think it could be clearer something like this:
def swipe_page_ left(self, page_number): _swipe_ page(page_ number, 'left')
self.
def _swipe_page(self, page_number, direction): album_view( ) spread_ view() animationRunnin g.wait_ for(False)
album = self.get_
spread = self.get_
album.
spread_center_x = spread.globalRect.x + spread.globalRect.w // 2
spread_center_y = spread.globalRect.y + spread.globalRect.h // 2
start_x = spread.globalRect.x
start_y = stop_y = spread_center_y
if direction == 'left':
expected_ page_matcher = LessThan
expected_ page_matcher = GreatherThan
stop_x = spread_center_x
elif direction == 'right':
stop_x = spread.globalRect.x
else:
raise Something.
self. pointing_ device. drag(
start_x, start_y, stop_x, stop_y)
album. animationRunnin g.wait_ for(False) viewingPage. wait_for( expected_ page_matcher( page_number) )
spread.
88 +class EventsViewExcep tion(Exception) :
I would prefer if this inherits from a general GalleryAppExcep tion. Then you could ignore all the GalleryAppExcep tions in some cases.
119 def number_ of_photos_ in_events( self):
[...]
123 + """Return the number of events"""
I think that docstring is wrong.
514 + def media_view(self):
If you do this as a property, then every time you call it the select_single will be executed. Is there a reason for not doing this on the __init__ like:
self.media_view = self.app. select_ single( MediaViewer)
?
In general, this is a big step forward, so +1. I still don't like some things, but they don't come from before your branch.
Like this:
203 + def click_delete_ dialog_ cancel_ button( self):
I don't like it being part of a utils module. There's probably a helper for dialogs on the toolkit, and we should return the dialog object from the method that opens it.
Anyway, thanks a lot for this. It's now a lot more understandable.