Merge lp:~phablet-team/camera-app/refactor-and-fix-editor-tests into lp:camera-app

Proposed by Ugo Riboni
Status: Merged
Approved by: Florian Boucault
Approved revision: 537
Merged at revision: 534
Proposed branch: lp:~phablet-team/camera-app/refactor-and-fix-editor-tests
Merge into: lp:camera-app
Diff against target: 479 lines (+171/-117)
7 files modified
tests/autopilot/camera_app/data/__init__.py (+6/-0)
tests/autopilot/camera_app/emulators/main_window.py (+4/-2)
tests/autopilot/camera_app/emulators/panel.py (+4/-3)
tests/autopilot/camera_app/tests/__init__.py (+30/-0)
tests/autopilot/camera_app/tests/test_capture.py (+5/-2)
tests/autopilot/camera_app/tests/test_gallery_view.py (+63/-73)
tests/autopilot/camera_app/tests/test_photo_editor.py (+59/-37)
To merge this branch: bzr merge lp:~phablet-team/camera-app/refactor-and-fix-editor-tests
Reviewer Review Type Date Requested Status
Florian Boucault (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+250931@code.launchpad.net

Commit message

Refactor camera editor tests, make them work even if UI extras are not installed, and add a test for the edit button being disabled when on a video

Description of the change

Refactor camera editor tests, make them work even if UI extras are not installed, and add a test for the edit button being disabled when on a video

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
527. By Ugo Riboni

Fix very random bug on dragging the panel by maximizing the speed of drag

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)
528. By Ugo Riboni

Prevent failure when removing config file if it does not exist

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
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)
529. By Ugo Riboni

Merge lp:~canonical-platform-qa/camera-app/close-panel-helper-fix to group more fixes in one review

530. By Ugo Riboni

Explicit rate parameter in calls to drag

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)
531. By Ugo Riboni

When possible prefer adding sample media in advance of launching the app than taking actual pictures or videos

532. By Ugo Riboni

Make sure we don't fail if for any reason there are subdirectories while we try to clean the media directory

533. By Ugo Riboni

Merge changes from trunk

534. By Ugo Riboni

Fix missing parameter on call

535. By Ugo Riboni

Minimize swipe speed when switching to gallery view and back as it seems to be necessary to fix the problem in combination with previous changes

536. By Ugo Riboni

Ensure environment is clean of other media when running tests

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
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
537. By Ugo Riboni

Ensure editor tests have photo or video present before starting the test, or they will not be picked up

Revision history for this message
Florian Boucault (fboucault) wrote :

All tests green on krillin RTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'tests/autopilot/camera_app/data'
=== added file 'tests/autopilot/camera_app/data/__init__.py'
--- tests/autopilot/camera_app/data/__init__.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/camera_app/data/__init__.py 2015-03-11 09:25:45 +0000
@@ -0,0 +1,6 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2015 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
07
=== added file 'tests/autopilot/camera_app/data/sample.jpg'
1Binary files tests/autopilot/camera_app/data/sample.jpg 1970-01-01 00:00:00 +0000 and tests/autopilot/camera_app/data/sample.jpg 2015-03-11 09:25:45 +0000 differ8Binary files tests/autopilot/camera_app/data/sample.jpg 1970-01-01 00:00:00 +0000 and tests/autopilot/camera_app/data/sample.jpg 2015-03-11 09:25:45 +0000 differ
=== added file 'tests/autopilot/camera_app/data/sample.mp4'
2Binary files tests/autopilot/camera_app/data/sample.mp4 1970-01-01 00:00:00 +0000 and tests/autopilot/camera_app/data/sample.mp4 2015-03-11 09:25:45 +0000 differ9Binary files tests/autopilot/camera_app/data/sample.mp4 1970-01-01 00:00:00 +0000 and tests/autopilot/camera_app/data/sample.mp4 2015-03-11 09:25:45 +0000 differ
=== modified file 'tests/autopilot/camera_app/emulators/main_window.py'
--- tests/autopilot/camera_app/emulators/main_window.py 2015-01-27 17:36:59 +0000
+++ tests/autopilot/camera_app/emulators/main_window.py 2015-03-11 09:25:45 +0000
@@ -5,6 +5,8 @@
5# under the terms of the GNU General Public License version 3, as published5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.6# by the Free Software Foundation.
77
8import sys
9
8from camera_app.emulators.panel import Panel10from camera_app.emulators.panel import Panel
9from autopilot.matchers import Eventually11from autopilot.matchers import Eventually
10from testtools.matchers import Equals12from testtools.matchers import Equals
@@ -141,7 +143,7 @@
141 tx = x + (w // 2)143 tx = x + (w // 2)
142 ty = y + (h // 2)144 ty = y + (h // 2)
143145
144 testCase.pointing_device.drag(tx, ty, (tx - main_view.width // 2), ty)146 testCase.pointing_device.drag(tx, ty, x, ty, rate=1)
145 viewfinder = self.get_viewfinder()147 viewfinder = self.get_viewfinder()
146 testCase.assertThat(viewfinder.inView, Eventually(Equals(False)))148 testCase.assertThat(viewfinder.inView, Eventually(Equals(False)))
147149
@@ -152,6 +154,6 @@
152 tx = x + (w // 2)154 tx = x + (w // 2)
153 ty = y + (h // 2)155 ty = y + (h // 2)
154156
155 testCase.pointing_device.drag(tx, ty, (tx + main_view.width // 2), ty)157 testCase.pointing_device.drag(tx, ty, (tx + main_view.width // 2), ty, rate=1)
156 viewfinder = self.get_viewfinder()158 viewfinder = self.get_viewfinder()
157 testCase.assertThat(viewfinder.inView, Eventually(Equals(True)))159 testCase.assertThat(viewfinder.inView, Eventually(Equals(True)))
158160
=== modified file 'tests/autopilot/camera_app/emulators/panel.py'
--- tests/autopilot/camera_app/emulators/panel.py 2014-12-10 17:47:57 +0000
+++ tests/autopilot/camera_app/emulators/panel.py 2015-03-11 09:25:45 +0000
@@ -6,6 +6,7 @@
6# by the Free Software Foundation.6# by the Free Software Foundation.
77
8import logging8import logging
9import sys
910
10from autopilot import logging as autopilot_logging11from autopilot import logging as autopilot_logging
11from camera_app.emulators.baseemulator import CameraCustomProxyObjectBase12from camera_app.emulators.baseemulator import CameraCustomProxyObjectBase
@@ -38,7 +39,7 @@
38 start_y = y + self.height - 139 start_y = y + self.height - 1
39 stop_y = y40 stop_y = y
4041
41 self.pointing_device.drag(line_x, start_y, line_x, stop_y)42 self.pointing_device.drag(line_x, start_y, line_x, stop_y, rate=sys.maxsize)
4243
43 @autopilot_logging.log_action(logger.info)44 @autopilot_logging.log_action(logger.info)
44 def close(self):45 def close(self):
@@ -51,8 +52,8 @@
5152
52 def _drag_to_close(self):53 def _drag_to_close(self):
53 x, y, _, _ = self.globalRect54 x, y, _, _ = self.globalRect
54 line_x = x55 line_x = x + self.width - 1
55 start_y = y56 start_y = y
56 stop_y = y + self.height - 157 stop_y = y + self.height - 1
5758
58 self.pointing_device.drag(line_x, start_y, line_x, stop_y)59 self.pointing_device.drag(line_x, start_y, line_x, stop_y, rate=sys.maxsize)
5960
=== modified file 'tests/autopilot/camera_app/tests/__init__.py'
--- tests/autopilot/camera_app/tests/__init__.py 2014-11-17 14:27:25 +0000
+++ tests/autopilot/camera_app/tests/__init__.py 2015-03-11 09:25:45 +0000
@@ -9,10 +9,15 @@
99
10import os10import os
11import time11import time
12import shutil
13from time import sleep
14from pkg_resources import resource_filename
1215
13from autopilot.input import Mouse, Touch, Pointer16from autopilot.input import Mouse, Touch, Pointer
14from autopilot.platform import model17from autopilot.platform import model
15from autopilot.testcase import AutopilotTestCase18from autopilot.testcase import AutopilotTestCase
19from autopilot.matchers import Eventually
20from testtools.matchers import Equals
1621
17from camera_app.emulators.main_window import MainWindow22from camera_app.emulators.main_window import MainWindow
18from camera_app.emulators.baseemulator import CameraCustomProxyObjectBase23from camera_app.emulators.baseemulator import CameraCustomProxyObjectBase
@@ -32,6 +37,10 @@
32 local_location = "../../camera-app"37 local_location = "../../camera-app"
33 deb_location = '/usr/bin/camera-app'38 deb_location = '/usr/bin/camera-app'
3439
40 pictures_dir = os.path.expanduser("~/Pictures/com.ubuntu.camera")
41 videos_dir = os.path.expanduser("~/Videos/com.ubuntu.camera")
42 sample_dir = resource_filename('camera_app', 'data')
43
35 def setUp(self):44 def setUp(self):
36 self.pointing_device = Pointer(self.input_device_class.create())45 self.pointing_device = Pointer(self.input_device_class.create())
37 super(CameraAppTestCase, self).setUp()46 super(CameraAppTestCase, self).setUp()
@@ -79,3 +88,24 @@
79 @property88 @property
80 def main_window(self):89 def main_window(self):
81 return MainWindow(self.app)90 return MainWindow(self.app)
91
92 def delete_all_media(self):
93 picture_files = os.listdir(self.pictures_dir)
94 for f in picture_files:
95 f = os.path.join(self.pictures_dir, f)
96 if os.path.isfile(f):
97 os.remove(f)
98
99 video_files = os.listdir(self.videos_dir)
100 for f in video_files:
101 f = os.path.join(self.videos_dir, f)
102 if os.path.isfile(f):
103 os.remove(f)
104
105 def add_sample_photo(self):
106 shutil.copyfile(os.path.join(self.sample_dir, "sample.jpg"),
107 os.path.join(self.pictures_dir, "sample.jpg"))
108
109 def add_sample_video(self):
110 shutil.copyfile(os.path.join(self.sample_dir, "sample.mp4"),
111 os.path.join(self.videos_dir, "sample.mp4"))
82112
=== modified file 'tests/autopilot/camera_app/tests/test_capture.py'
--- tests/autopilot/camera_app/tests/test_capture.py 2015-01-20 12:33:39 +0000
+++ tests/autopilot/camera_app/tests/test_capture.py 2015-03-11 09:25:45 +0000
@@ -28,7 +28,8 @@
28 def setUp(self):28 def setUp(self):
29 # Remove configuration file where knowledge of the photo roll hint's necessity is stored29 # Remove configuration file where knowledge of the photo roll hint's necessity is stored
30 config_file = os.path.expanduser("~/.config/com.ubuntu.camera/com.ubuntu.camera.conf")30 config_file = os.path.expanduser("~/.config/com.ubuntu.camera/com.ubuntu.camera.conf")
31 os.remove(config_file)31 if os.path.exists(config_file):
32 os.remove(config_file)
3233
33 super(TestCapture, self).setUp()34 super(TestCapture, self).setUp()
3435
@@ -199,7 +200,9 @@
199 def delete_all_photos(self):200 def delete_all_photos(self):
200 picture_files = os.listdir(self.pictures_dir)201 picture_files = os.listdir(self.pictures_dir)
201 for f in picture_files:202 for f in picture_files:
202 os.remove(os.path.join(self.pictures_dir, f))203 f = os.path.join(self.pictures_dir, f)
204 if os.path.isfile(f):
205 os.remove(os.path.join(self.pictures_dir, f))
203206
204 def get_first_picture(self, timeout=10):207 def get_first_picture(self, timeout=10):
205 pictures = []208 pictures = []
206209
=== modified file 'tests/autopilot/camera_app/tests/test_gallery_view.py'
--- tests/autopilot/camera_app/tests/test_gallery_view.py 2015-02-18 14:23:02 +0000
+++ tests/autopilot/camera_app/tests/test_gallery_view.py 2015-03-11 09:25:45 +0000
@@ -16,24 +16,8 @@
16import os16import os
17from time import sleep17from time import sleep
1818
1919class TestCameraGalleryViewMixin(object):
20class TestCameraGalleryView(CameraAppTestCase):
21 """Tests the main camera features"""
22
23 """ This is needed to wait for the application to start.
24 In the testfarm, the application may take some time to show up."""
25 def setUp(self):
26 super(TestCameraGalleryView, self).setUp()
27 self.assertThat(
28 self.main_window.get_qml_view().visible, Eventually(Equals(True)))
29 self.pictures_dir = os.path.expanduser("~/Pictures/com.ubuntu.camera")
30 self.videos_dir = os.path.expanduser("~/Videos/com.ubuntu.camera")
31
32 def tearDown(self):
33 super(TestCameraGalleryView, self).tearDown()
34
35 def move_from_slideshow_to_photogrid(self):20 def move_from_slideshow_to_photogrid(self):
36 # make sure we move from slideshow to photogrid view
37 gallery = self.main_window.get_gallery()21 gallery = self.main_window.get_gallery()
3822
39 slideshow_view = gallery.wait_select_single("SlideshowView")23 slideshow_view = gallery.wait_select_single("SlideshowView")
@@ -52,39 +36,6 @@
52 self.assertThat(slideshow_view.visible, Eventually(Equals(False)))36 self.assertThat(slideshow_view.visible, Eventually(Equals(False)))
53 self.assertThat(photogrid_view.visible, Eventually(Equals(True)))37 self.assertThat(photogrid_view.visible, Eventually(Equals(True)))
5438
55 def delete_all_media(self):
56 picture_files = os.listdir(self.pictures_dir)
57 for f in picture_files:
58 f = os.path.join(self.pictures_dir, f)
59 if os.path.isfile(f):
60 os.remove(f)
61
62 video_files = os.listdir(self.videos_dir)
63 for f in video_files:
64 f = os.path.join(self.videos_dir, f)
65 if os.path.isfile(f):
66 os.remove(f)
67
68 def add_sample_photo(self):
69 self.main_window.swipe_to_viewfinder(self)
70 exposure_button = self.main_window.get_exposure_button()
71 self.assertThat(exposure_button.enabled, Eventually(Equals(True)))
72 self.pointing_device.move_to_object(exposure_button)
73 self.pointing_device.click()
74
75 def add_sample_video(self):
76 self.main_window.swipe_to_viewfinder(self)
77 video_button = self.main_window.get_record_control()
78 self.pointing_device.move_to_object(video_button)
79 self.pointing_device.click()
80
81 exposure_button = self.main_window.get_exposure_button()
82 self.assertThat(exposure_button.enabled, Eventually(Equals(True)))
83 self.pointing_device.move_to_object(exposure_button)
84 self.pointing_device.click()
85 sleep(3)
86 self.pointing_device.click()
87
88 def select_first_photo(self):39 def select_first_photo(self):
89 # select the first photo40 # select the first photo
90 gallery = self.main_window.get_gallery()41 gallery = self.main_window.get_gallery()
@@ -96,6 +47,18 @@
96 sleep(1)47 sleep(1)
97 self.pointing_device.release()48 self.pointing_device.release()
9849
50class TestCameraGalleryView(CameraAppTestCase, TestCameraGalleryViewMixin):
51 """Tests the camera gallery view without media already present"""
52
53 def setUp(self):
54 self.delete_all_media()
55 super(TestCameraGalleryView, self).setUp()
56 self.assertThat(
57 self.main_window.get_qml_view().visible, Eventually(Equals(True)))
58
59 def tearDown(self):
60 super(TestCameraGalleryView, self).tearDown()
61
99 """Tests swiping to the gallery and pressing the back button"""62 """Tests swiping to the gallery and pressing the back button"""
100 def test_swipe_to_gallery(self):63 def test_swipe_to_gallery(self):
101 viewfinder = self.main_window.get_viewfinder()64 viewfinder = self.main_window.get_viewfinder()
@@ -120,7 +83,6 @@
12083
121 """Tests swiping to the gallery/photo roll with no media in it"""84 """Tests swiping to the gallery/photo roll with no media in it"""
122 def test_swipe_to_empty_gallery(self):85 def test_swipe_to_empty_gallery(self):
123 self.delete_all_media()
124 viewfinder = self.main_window.get_viewfinder()86 viewfinder = self.main_window.get_viewfinder()
125 gallery = self.main_window.get_gallery()87 gallery = self.main_window.get_gallery()
12688
@@ -133,14 +95,31 @@
13395
134 self.assertThat(hint.visible, Eventually(Equals(True)))96 self.assertThat(hint.visible, Eventually(Equals(True)))
13597
136 self.add_sample_photo()98 # Take a picture and verify that the no media hint disappears
99 self.main_window.swipe_to_viewfinder(self)
100 exposure_button = self.main_window.get_exposure_button()
101 self.assertThat(exposure_button.enabled, Eventually(Equals(True)))
102 self.pointing_device.move_to_object(exposure_button)
103 self.pointing_device.click()
137104
138 self.assertThat(hint.visible, Eventually(Equals(False)))105 self.assertThat(hint.visible, Eventually(Equals(False)))
139106
107class TestCameraGalleryViewWithVideo(TestCameraGalleryViewMixin, CameraAppTestCase):
108 """Tests the camera gallery view with video already present"""
109
110 def setUp(self):
111 self.delete_all_media()
112 self.add_sample_video()
113
114 super(TestCameraGalleryViewWithVideo, self).setUp()
115 self.assertThat(
116 self.main_window.get_qml_view().visible, Eventually(Equals(True)))
117
118 def tearDown(self):
119 super(TestCameraGalleryViewWithVideo, self).tearDown()
120
140 """Tests the thumnails for video load correctly in slideshow view"""121 """Tests the thumnails for video load correctly in slideshow view"""
141 def test_video_thumbnails(self):122 def test_video_thumbnails(self):
142 self.add_sample_video()
143 self.delete_all_media()
144 viewfinder = self.main_window.get_viewfinder()123 viewfinder = self.main_window.get_viewfinder()
145 gallery = self.main_window.get_gallery()124 gallery = self.main_window.get_gallery()
146125
@@ -152,29 +131,22 @@
152 spinner = gallery.wait_select_single("ActivityIndicator")131 spinner = gallery.wait_select_single("ActivityIndicator")
153 self.assertThat(spinner.running, Eventually(Equals(False)))132 self.assertThat(spinner.running, Eventually(Equals(False)))
154133
155 """Tests entering/leaving multiselection mode in the photogrid view"""134class TestCameraGalleryViewWithPhoto(TestCameraGalleryViewMixin, CameraAppTestCase):
156 def test_multiselection_mode(self):135 """Tests the camera gallery view with photo already present"""
136
137 def setUp(self):
138 self.delete_all_media()
157 self.add_sample_photo()139 self.add_sample_photo()
158 self.main_window.swipe_to_gallery(self)140
159 self.move_from_slideshow_to_photogrid()141 super(TestCameraGalleryViewWithPhoto, self).setUp()
160 self.select_first_photo()142 self.assertThat(
161143 self.main_window.get_qml_view().visible, Eventually(Equals(True)))
162 # exit the multiselection mode144
163 gallery = self.main_window.get_gallery()145 def tearDown(self):
164 back_button = gallery.wait_select_single(objectName="backButton")146 super(TestCameraGalleryViewWithPhoto, self).tearDown()
165 self.pointing_device.move_to_object(back_button)
166 self.pointing_device.click()
167
168 slideshow_view = gallery.wait_select_single("SlideshowView")
169 photogrid_view = gallery.wait_select_single("PhotogridView")
170
171 self.assertThat(slideshow_view.visible, Eventually(Equals(False)))
172 self.assertThat(photogrid_view.visible, Eventually(Equals(True)))
173147
174 """Test deleting photo from multiselection"""148 """Test deleting photo from multiselection"""
175 def test_delete_photo_from_multiselection(self):149 def test_delete_photo_from_multiselection(self):
176 self.delete_all_media()
177 self.add_sample_photo()
178 self.main_window.swipe_to_gallery(self)150 self.main_window.swipe_to_gallery(self)
179 self.move_from_slideshow_to_photogrid()151 self.move_from_slideshow_to_photogrid()
180 self.select_first_photo()152 self.select_first_photo()
@@ -197,3 +169,21 @@
197169
198 hint = self.main_window.get_no_media_hint()170 hint = self.main_window.get_no_media_hint()
199 self.assertThat(hint.visible, Eventually(Equals(True)))171 self.assertThat(hint.visible, Eventually(Equals(True)))
172
173 """Tests entering/leaving multiselection mode in the photogrid view"""
174 def test_multiselection_mode(self):
175 self.main_window.swipe_to_gallery(self)
176 self.move_from_slideshow_to_photogrid()
177 self.select_first_photo()
178
179 # exit the multiselection mode
180 gallery = self.main_window.get_gallery()
181 back_button = gallery.wait_select_single(objectName="backButton")
182 self.pointing_device.move_to_object(back_button)
183 self.pointing_device.click()
184
185 slideshow_view = gallery.wait_select_single("SlideshowView")
186 photogrid_view = gallery.wait_select_single("PhotogridView")
187
188 self.assertThat(slideshow_view.visible, Eventually(Equals(False)))
189 self.assertThat(photogrid_view.visible, Eventually(Equals(True)))
200190
=== modified file 'tests/autopilot/camera_app/tests/test_photo_editor.py'
--- tests/autopilot/camera_app/tests/test_photo_editor.py 2014-12-16 13:26:28 +0000
+++ tests/autopilot/camera_app/tests/test_photo_editor.py 2015-03-11 09:25:45 +0000
@@ -18,49 +18,23 @@
18from time import sleep18from time import sleep
1919
2020
21class TestCameraPhotoEditor(CameraAppTestCase):21class TestCameraPhotoEditorWithPhoto(CameraAppTestCase):
22 """Tests the main camera features"""22 """Tests photo editor when a photo is present"""
2323
24 """ This is needed to wait for the application to start.
25 In the testfarm, the application may take some time to show up."""
26 def setUp(self):24 def setUp(self):
27 super(TestCameraPhotoEditor, self).setUp()25 self.delete_all_media()
26 self.add_sample_photo()
27
28 super(TestCameraPhotoEditorWithPhoto, self).setUp()
28 self.assertThat(29 self.assertThat(
29 self.main_window.get_qml_view().visible, Eventually(Equals(True)))30 self.main_window.get_qml_view().visible, Eventually(Equals(True)))
30 self.pictures_dir = os.path.expanduser("~/Pictures/com.ubuntu.camera")
31 self.videos_dir = os.path.expanduser("~/Videos/com.ubuntu.camera")
3231
33 def tearDown(self):32 def tearDown(self):
34 super(TestCameraPhotoEditor, self).tearDown()33 super(TestCameraPhotoEditorWithPhoto, self).tearDown()
3534
36 def delete_all_media(self):35 """Tests editor opening and closing correctly for pictures"""
37 picture_files = os.listdir(self.pictures_dir)
38 for f in picture_files:
39 os.remove(os.path.join(self.pictures_dir, f))
40
41 video_files = os.listdir(self.videos_dir)
42 for f in video_files:
43 os.remove(os.path.join(self.videos_dir, f))
44
45 def add_sample_photo(self):
46 # add a fake photo to pictures_dir
47 photo_path = os.path.join(self.pictures_dir, "fake_photo.jpg")
48 with open(photo_path, 'a'):
49 os.utime(photo_path, None)
50
51 def select_first_photo(self):
52 # select the first photo
53 gallery = self.main_window.get_gallery()
54 photo = gallery.wait_select_single(objectName="mediaItem0")
55 self.pointing_device.move_to_object(photo)
56
57 # do a long press to enter Multiselection mode
58 self.pointing_device.press()
59 sleep(1)
60 self.pointing_device.release()
61
62 """Tests swiping to the gallery and pressing the back button"""
63 def test_editor_appears(self):36 def test_editor_appears(self):
37
64 viewfinder = self.main_window.get_viewfinder()38 viewfinder = self.main_window.get_viewfinder()
65 gallery = self.main_window.get_gallery()39 gallery = self.main_window.get_gallery()
6640
@@ -73,7 +47,15 @@
73 self.pointing_device.move_to_object(opt)47 self.pointing_device.move_to_object(opt)
74 self.pointing_device.click()48 self.pointing_device.click()
7549
76 edit = gallery.wait_select_single(objectName="actionButtonEdit")50 # If the editor button is not there when in the gallery view, then
51 # we are not on a system that has the UI extras package installed or has
52 # an older version than the one we need. Skip the test in this case.
53 try:
54 edit = gallery.wait_select_single(objectName="actionButtonEdit")
55 except:
56 return
57
58 self.assertThat(edit.enabled, Eventually(Equals(True)))
77 self.pointing_device.move_to_object(edit)59 self.pointing_device.move_to_object(edit)
78 self.pointing_device.click()60 self.pointing_device.click()
7961
@@ -98,3 +80,43 @@
98 except StateNotFoundError:80 except StateNotFoundError:
99 disappeared = True81 disappeared = True
100 self.assertThat(disappeared, Equals(True))82 self.assertThat(disappeared, Equals(True))
83
84class TestCameraPhotoEditorWithVideo(CameraAppTestCase):
85 """Tests photo editor when a video is present"""
86
87 def setUp(self):
88 self.delete_all_media()
89 self.add_sample_video()
90
91 super(TestCameraPhotoEditorWithVideo, self).setUp()
92 self.assertThat(
93 self.main_window.get_qml_view().visible, Eventually(Equals(True)))
94
95 def tearDown(self):
96 super(TestCameraPhotoEditorWithVideo, self).tearDown()
97
98 """Tests editor not being available for videos"""
99 def test_editor_not_on_videos(self):
100 self.add_sample_video()
101
102 viewfinder = self.main_window.get_viewfinder()
103 gallery = self.main_window.get_gallery()
104
105 self.main_window.swipe_to_gallery(self)
106
107 self.assertThat(gallery.inView, Eventually(Equals(True)))
108
109 # open actions drawer
110 opt = gallery.wait_select_single(objectName="additionalActionsButton")
111 self.pointing_device.move_to_object(opt)
112 self.pointing_device.click()
113
114 # If the editor button is not there when in the gallery view, then
115 # we are not on a system that has the UI extras package installed or has
116 # an older version than the one we need. Skip the test in this case.
117 try:
118 edit = gallery.wait_select_single(objectName="actionButtonEdit")
119 except:
120 return
121
122 self.assertThat(edit.enabled, Equals(False))

Subscribers

People subscribed via source and target branches