Merge lp:~om26er/camera-app/ap_tests_improvements into lp:camera-app
- ap_tests_improvements
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Ugo Riboni |
Approved revision: | 137 |
Merged at revision: | 132 |
Proposed branch: | lp:~om26er/camera-app/ap_tests_improvements |
Merge into: | lp:camera-app |
Diff against target: |
505 lines (+136/-92) 5 files modified
tests/autopilot/camera_app/tests/__init__.py (+10/-6) tests/autopilot/camera_app/tests/test_capture.py (+32/-21) tests/autopilot/camera_app/tests/test_flash.py (+13/-7) tests/autopilot/camera_app/tests/test_focus.py (+43/-31) tests/autopilot/camera_app/tests/test_zoom.py (+38/-27) |
To merge this branch: | bzr merge lp:~om26er/camera-app/ap_tests_improvements |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ugo Riboni (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Ubuntu Phablet Team | Pending | ||
Review via email: mp+165733@code.launchpad.net |
Commit message
make the camera-app tests pep8 compliant, improves tests for readability and re-usability of code, skip few tests on the Nexus 7 as camera does not work on it yet.
Description of the change
make the camera-app tests pep8 compliant, improves tests for readability and re-usability of code.
- 133. By Omer Akram
-
simplify
PS Jenkins bot (ps-jenkins) wrote : | # |
- 134. By Omer Akram
-
skip a bunch of tests on the nexus 7 as camera does not work there
- 135. By Omer Akram
-
fix test on phone
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:135
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 136. By Omer Akram
-
separate out the Nexus 7 skip test changes
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:136
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Omer Akram (om26er) wrote : | # |
I have now removed the Nexus 7 specific changes, I'll do that in another branch.
Ugo Riboni (uriboni) wrote : | # |
291 + """Tests clicking outside of the viewfinder image area, where it should
292 + not focus
293 +
294 + """
Why all the extra space ?
346 + center_click_coords = list(self.
347 +
348 + focus_ring_center = self.get_
349 +
Same issue here
356 + drag_end_coords = [focus_
357 + self.pointing_
358 + focus_ring_
359
Since you're improving readability by adding intermediate variable in other places, you might want to do this here for the parameters to drag() too.
- 137. By Omer Akram
-
fix per suggestions
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:137
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:137
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ugo Riboni (uriboni) wrote : | # |
Looks good to me and all tests pass on jenkins, approved.
Preview Diff
1 | === modified file 'tests/autopilot/camera_app/tests/__init__.py' | |||
2 | --- tests/autopilot/camera_app/tests/__init__.py 2013-05-14 20:27:38 +0000 | |||
3 | +++ tests/autopilot/camera_app/tests/__init__.py 2013-05-29 11:56:26 +0000 | |||
4 | @@ -18,18 +18,19 @@ | |||
5 | 18 | 18 | ||
6 | 19 | from camera_app.emulators.main_window import MainWindow | 19 | from camera_app.emulators.main_window import MainWindow |
7 | 20 | 20 | ||
8 | 21 | |||
9 | 21 | class CameraAppTestCase(AutopilotTestCase): | 22 | class CameraAppTestCase(AutopilotTestCase): |
10 | 22 | 23 | ||
12 | 23 | """A common test case class that provides several useful methods for camera-app tests.""" | 24 | """A common test case class that provides several useful methods |
13 | 25 | for camera-app tests. | ||
14 | 24 | 26 | ||
15 | 27 | """ | ||
16 | 25 | if model() == 'Desktop': | 28 | if model() == 'Desktop': |
17 | 26 | scenarios = [ | 29 | scenarios = [ |
20 | 27 | ('with mouse', dict(input_device_class=Mouse)) | 30 | ('with mouse', dict(input_device_class=Mouse))] |
19 | 28 | ] | ||
21 | 29 | else: | 31 | else: |
22 | 30 | scenarios = [ | 32 | scenarios = [ |
25 | 31 | ('with touch', dict(input_device_class=Touch)) | 33 | ('with touch', dict(input_device_class=Touch))] |
24 | 32 | ] | ||
26 | 33 | 34 | ||
27 | 34 | local_location = "../../camera-app" | 35 | local_location = "../../camera-app" |
28 | 35 | 36 | ||
29 | @@ -56,7 +57,10 @@ | |||
30 | 56 | "--desktop_file_hint=/usr/share/applications/camera-app.desktop", | 57 | "--desktop_file_hint=/usr/share/applications/camera-app.desktop", |
31 | 57 | app_type='qt') | 58 | app_type='qt') |
32 | 58 | 59 | ||
33 | 60 | def get_center(self, object_proxy): | ||
34 | 61 | x, y, w, h = object_proxy.globalRect | ||
35 | 62 | return [x + (w / 2), y + (h / 2)] | ||
36 | 63 | |||
37 | 59 | @property | 64 | @property |
38 | 60 | def main_window(self): | 65 | def main_window(self): |
39 | 61 | return MainWindow(self.app) | 66 | return MainWindow(self.app) |
40 | 62 | |||
41 | 63 | 67 | ||
42 | === modified file 'tests/autopilot/camera_app/tests/test_capture.py' | |||
43 | --- tests/autopilot/camera_app/tests/test_capture.py 2013-05-07 19:07:05 +0000 | |||
44 | +++ tests/autopilot/camera_app/tests/test_capture.py 2013-05-29 11:56:26 +0000 | |||
45 | @@ -20,6 +20,7 @@ | |||
46 | 20 | import os | 20 | import os |
47 | 21 | from os import path | 21 | from os import path |
48 | 22 | 22 | ||
49 | 23 | |||
50 | 23 | class TestCapture(CameraAppTestCase): | 24 | class TestCapture(CameraAppTestCase): |
51 | 24 | """Tests the main camera features""" | 25 | """Tests the main camera features""" |
52 | 25 | 26 | ||
53 | @@ -27,7 +28,8 @@ | |||
54 | 27 | In the testfarm, the application may take some time to show up.""" | 28 | In the testfarm, the application may take some time to show up.""" |
55 | 28 | def setUp(self): | 29 | def setUp(self): |
56 | 29 | super(TestCapture, self).setUp() | 30 | super(TestCapture, self).setUp() |
58 | 30 | self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True))) | 31 | self.assertThat( |
59 | 32 | self.main_window.get_qml_view().visible, Eventually(Equals(True))) | ||
60 | 31 | 33 | ||
61 | 32 | def tearDown(self): | 34 | def tearDown(self): |
62 | 33 | super(TestCapture, self).tearDown() | 35 | super(TestCapture, self).tearDown() |
63 | @@ -39,21 +41,23 @@ | |||
64 | 39 | pictures_dir = path.expanduser("~/Pictures") | 41 | pictures_dir = path.expanduser("~/Pictures") |
65 | 40 | 42 | ||
66 | 41 | # Remove all pictures from ~/Pictures that match our pattern | 43 | # Remove all pictures from ~/Pictures that match our pattern |
68 | 42 | files = [ f for f in os.listdir(pictures_dir) if f[0:5] == "image" and path.isfile(path.join(pictures_dir,f))] | 44 | files = [f for f in os.listdir(pictures_dir) if f[0:5] == "image" and path.isfile(path.join(pictures_dir, f))] |
69 | 43 | for f in files: | 45 | for f in files: |
70 | 44 | os.remove(path.join(pictures_dir, f)) | 46 | os.remove(path.join(pictures_dir, f)) |
71 | 45 | 47 | ||
73 | 46 | # Wait for the camera to have finished focusing (the exposure button gets enabled when ready) | 48 | # Wait for the camera to have finished focusing |
74 | 49 | # (the exposure button gets enabled when ready) | ||
75 | 47 | self.assertThat(exposure_button.enabled, Eventually(Equals(True))) | 50 | self.assertThat(exposure_button.enabled, Eventually(Equals(True))) |
76 | 48 | 51 | ||
77 | 49 | # Now take the picture! (Give it a little time to animate) | 52 | # Now take the picture! (Give it a little time to animate) |
78 | 50 | self.pointing_device.move_to_object(exposure_button) | 53 | self.pointing_device.move_to_object(exposure_button) |
79 | 51 | self.pointing_device.click() | 54 | self.pointing_device.click() |
80 | 52 | 55 | ||
82 | 53 | # Check that only one picture with the right name pattern is actually there | 56 | # Check that only one picture with the right name pattern |
83 | 57 | # is actually there | ||
84 | 54 | one_picture_on_disk = False | 58 | one_picture_on_disk = False |
85 | 55 | for i in range(0, 10): | 59 | for i in range(0, 10): |
87 | 56 | files = [ f for f in os.listdir(pictures_dir) if f[0:5] == "image" and path.isfile(path.join(pictures_dir,f))] | 60 | files = [f for f in os.listdir(pictures_dir) if f[0:5] == "image" and path.isfile(path.join(pictures_dir, f))] |
88 | 57 | if len(files) == 1: | 61 | if len(files) == 1: |
89 | 58 | one_picture_on_disk = True | 62 | one_picture_on_disk = True |
90 | 59 | break | 63 | break |
91 | @@ -78,7 +82,7 @@ | |||
92 | 78 | 82 | ||
93 | 79 | # Click the record button to toggle photo/video mode | 83 | # Click the record button to toggle photo/video mode |
94 | 80 | self.pointing_device.move_to_object(record_control) | 84 | self.pointing_device.move_to_object(record_control) |
96 | 81 | self.pointing_device.click(); | 85 | self.pointing_device.click() |
97 | 82 | 86 | ||
98 | 83 | # Has the flash changed to be a torch ? | 87 | # Has the flash changed to be a torch ? |
99 | 84 | self.assertThat(flash_button.flashState, Eventually(Equals("off"))) | 88 | self.assertThat(flash_button.flashState, Eventually(Equals("off"))) |
100 | @@ -91,24 +95,27 @@ | |||
101 | 91 | 95 | ||
102 | 92 | # Click the exposure button to start recording | 96 | # Click the exposure button to start recording |
103 | 93 | self.pointing_device.move_to_object(exposure_button) | 97 | self.pointing_device.move_to_object(exposure_button) |
105 | 94 | self.pointing_device.click(); | 98 | self.pointing_device.click() |
106 | 95 | 99 | ||
111 | 96 | # Record video for 2 seconds and check if the stop watch actually runs and | 100 | # Record video for 2 seconds and check if the stop watch actually |
112 | 97 | # is visible. | 101 | # runs and is visible. |
113 | 98 | # Since the timer is not precise we don't check the actual time, just that it | 102 | # Since the timer is not precise we don't check the actual time, |
114 | 99 | # is not counting zero anymore. | 103 | # just that it is not counting zero anymore. |
115 | 100 | self.assertThat(stop_watch.opacity, Eventually(Equals(1.0))) | 104 | self.assertThat(stop_watch.opacity, Eventually(Equals(1.0))) |
116 | 101 | self.assertThat(stop_watch.elapsed, Eventually(NotEquals("00:00"))) | 105 | self.assertThat(stop_watch.elapsed, Eventually(NotEquals("00:00"))) |
117 | 102 | 106 | ||
119 | 103 | # Now stop the video and check if everything resets itself to previous states | 107 | # Now stop the video and check if everything resets itself to |
120 | 108 | # previous states. | ||
121 | 104 | self.pointing_device.click() | 109 | self.pointing_device.click() |
122 | 105 | 110 | ||
123 | 106 | self.assertThat(stop_watch.opacity, Eventually(Equals(0.0))) | 111 | self.assertThat(stop_watch.opacity, Eventually(Equals(0.0))) |
124 | 107 | 112 | ||
127 | 108 | # Now start recording a second video and check if everything still works | 113 | # Now start recording a second video and check if everything |
128 | 109 | self.pointing_device.click(); | 114 | # still works |
129 | 115 | self.pointing_device.click() | ||
130 | 110 | 116 | ||
132 | 111 | # Has the flash changed to be a torch, is the stop watch visible and set to 00:00? | 117 | # Has the flash changed to be a torch, is the stop watch visible |
133 | 118 | # and set to 00:00? | ||
134 | 112 | self.assertThat(flash_button.flashState, Eventually(Equals("off"))) | 119 | self.assertThat(flash_button.flashState, Eventually(Equals("off"))) |
135 | 113 | self.assertThat(flash_button.torchMode, Eventually(Equals(True))) | 120 | self.assertThat(flash_button.torchMode, Eventually(Equals(True))) |
136 | 114 | self.assertThat(stop_watch.opacity, Eventually(Equals(1.0))) | 121 | self.assertThat(stop_watch.opacity, Eventually(Equals(1.0))) |
137 | @@ -117,16 +124,20 @@ | |||
138 | 117 | # Record video for 2 seconds and check if the stop watch actually works | 124 | # Record video for 2 seconds and check if the stop watch actually works |
139 | 118 | self.assertThat(stop_watch.elapsed, Eventually(NotEquals("00:00"))) | 125 | self.assertThat(stop_watch.elapsed, Eventually(NotEquals("00:00"))) |
140 | 119 | 126 | ||
143 | 120 | # Now stop the video and go back to picture mode and check if everything resets itself to previous states | 127 | # Now stop the video and go back to picture mode and check if |
144 | 121 | self.pointing_device.click(); | 128 | # everything resets itself to previous states |
145 | 129 | self.pointing_device.click() | ||
146 | 122 | self.pointing_device.move_to_object(record_control) | 130 | self.pointing_device.move_to_object(record_control) |
148 | 123 | self.pointing_device.click(); | 131 | self.pointing_device.click() |
149 | 124 | 132 | ||
150 | 125 | self.assertThat(stop_watch.opacity, Eventually(Equals(0.0))) | 133 | self.assertThat(stop_watch.opacity, Eventually(Equals(0.0))) |
153 | 126 | self.assertThat(flash_button.flashState, Eventually(Equals(flashlight_old_state))) | 134 | self.assertThat( |
154 | 127 | self.assertThat(flash_button.torchMode, Eventually(Equals(torchmode_old_state))) | 135 | flash_button.flashState, Eventually(Equals(flashlight_old_state))) |
155 | 136 | self.assertThat( | ||
156 | 137 | flash_button.torchMode, Eventually(Equals(torchmode_old_state))) | ||
157 | 128 | 138 | ||
159 | 129 | """Test that the shoot button gets disabled for a while then re-enabled after shooting""" | 139 | """Test that the shoot button gets disabled for a while then re-enabled |
160 | 140 | after shooting""" | ||
161 | 130 | def test_shoot_button_disable(self): | 141 | def test_shoot_button_disable(self): |
162 | 131 | exposure_button = self.main_window.get_exposure_button() | 142 | exposure_button = self.main_window.get_exposure_button() |
163 | 132 | 143 | ||
164 | 133 | 144 | ||
165 | === modified file 'tests/autopilot/camera_app/tests/test_flash.py' | |||
166 | --- tests/autopilot/camera_app/tests/test_flash.py 2013-04-26 13:22:45 +0000 | |||
167 | +++ tests/autopilot/camera_app/tests/test_flash.py 2013-05-29 11:56:26 +0000 | |||
168 | @@ -16,6 +16,7 @@ | |||
169 | 16 | 16 | ||
170 | 17 | import time | 17 | import time |
171 | 18 | 18 | ||
172 | 19 | |||
173 | 19 | class TestCameraFlash(CameraAppTestCase): | 20 | class TestCameraFlash(CameraAppTestCase): |
174 | 20 | """Tests the flash""" | 21 | """Tests the flash""" |
175 | 21 | 22 | ||
176 | @@ -23,7 +24,8 @@ | |||
177 | 23 | In the testfarm, the application may take some time to show up.""" | 24 | In the testfarm, the application may take some time to show up.""" |
178 | 24 | def setUp(self): | 25 | def setUp(self): |
179 | 25 | super(TestCameraFlash, self).setUp() | 26 | super(TestCameraFlash, self).setUp() |
181 | 26 | self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True))) | 27 | self.assertThat( |
182 | 28 | self.main_window.get_qml_view().visible, Eventually(Equals(True))) | ||
183 | 27 | 29 | ||
184 | 28 | def tearDown(self): | 30 | def tearDown(self): |
185 | 29 | super(TestCameraFlash, self).tearDown() | 31 | super(TestCameraFlash, self).tearDown() |
186 | @@ -77,8 +79,8 @@ | |||
187 | 77 | flash_button = self.main_window.get_flash_button() | 79 | flash_button = self.main_window.get_flash_button() |
188 | 78 | record_button = self.main_window.get_record_control() | 80 | record_button = self.main_window.get_record_control() |
189 | 79 | 81 | ||
192 | 80 | # Change flash mode, then switch to camera, then back to flash and verify | 82 | # Change flash mode, then switch to camera, then back to flash |
193 | 81 | # that previous state is preserved | 83 | # and verify that previous state is preserved |
194 | 82 | self.pointing_device.move_to_object(flash_button) | 84 | self.pointing_device.move_to_object(flash_button) |
195 | 83 | self.pointing_device.click() | 85 | self.pointing_device.click() |
196 | 84 | self.pointing_device.click() | 86 | self.pointing_device.click() |
197 | @@ -90,10 +92,12 @@ | |||
198 | 90 | self.assertThat(flash_button.torchMode, Equals(True)) | 92 | self.assertThat(flash_button.torchMode, Equals(True)) |
199 | 91 | 93 | ||
200 | 92 | self.pointing_device.click() | 94 | self.pointing_device.click() |
202 | 93 | self.assertThat(flash_button.flashState, Eventually(Equals(old_flash_state))) | 95 | self.assertThat( |
203 | 96 | flash_button.flashState, Eventually(Equals(old_flash_state))) | ||
204 | 94 | self.assertThat(flash_button.torchMode, Equals(False)) | 97 | self.assertThat(flash_button.torchMode, Equals(False)) |
205 | 95 | 98 | ||
207 | 96 | # Now test the same thing in the opposite way, seeing if torch state is preserved | 99 | # Now test the same thing in the opposite way, seeing if torch state |
208 | 100 | # is preserved | ||
209 | 97 | self.pointing_device.click() | 101 | self.pointing_device.click() |
210 | 98 | self.assertThat(flash_button.flashState, Eventually(Equals("off"))) | 102 | self.assertThat(flash_button.flashState, Eventually(Equals("off"))) |
211 | 99 | self.assertThat(flash_button.torchMode, Equals(True)) | 103 | self.assertThat(flash_button.torchMode, Equals(True)) |
212 | @@ -104,9 +108,11 @@ | |||
213 | 104 | 108 | ||
214 | 105 | self.pointing_device.move_to_object(record_button) | 109 | self.pointing_device.move_to_object(record_button) |
215 | 106 | self.pointing_device.click() | 110 | self.pointing_device.click() |
217 | 107 | self.assertThat(flash_button.flashState, Eventually(Equals(old_flash_state))) | 111 | self.assertThat( |
218 | 112 | flash_button.flashState, Eventually(Equals(old_flash_state))) | ||
219 | 108 | self.assertThat(flash_button.torchMode, Equals(False)) | 113 | self.assertThat(flash_button.torchMode, Equals(False)) |
220 | 109 | 114 | ||
221 | 110 | self.pointing_device.click() | 115 | self.pointing_device.click() |
223 | 111 | self.assertThat(flash_button.flashState, Eventually(Equals(old_torch_state))) | 116 | self.assertThat( |
224 | 117 | flash_button.flashState, Eventually(Equals(old_torch_state))) | ||
225 | 112 | self.assertThat(flash_button.torchMode, Equals(True)) | 118 | self.assertThat(flash_button.torchMode, Equals(True)) |
226 | 113 | 119 | ||
227 | === modified file 'tests/autopilot/camera_app/tests/test_focus.py' | |||
228 | --- tests/autopilot/camera_app/tests/test_focus.py 2013-04-26 13:22:45 +0000 | |||
229 | +++ tests/autopilot/camera_app/tests/test_focus.py 2013-05-29 11:56:26 +0000 | |||
230 | @@ -17,6 +17,7 @@ | |||
231 | 17 | import unittest | 17 | import unittest |
232 | 18 | import time | 18 | import time |
233 | 19 | 19 | ||
234 | 20 | |||
235 | 20 | class TestFocus(CameraAppTestCase): | 21 | class TestFocus(CameraAppTestCase): |
236 | 21 | """Tests the focus""" | 22 | """Tests the focus""" |
237 | 22 | 23 | ||
238 | @@ -24,7 +25,8 @@ | |||
239 | 24 | In the testfarm, the application may take some time to show up.""" | 25 | In the testfarm, the application may take some time to show up.""" |
240 | 25 | def setUp(self): | 26 | def setUp(self): |
241 | 26 | super(TestFocus, self).setUp() | 27 | super(TestFocus, self).setUp() |
243 | 27 | self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True))) | 28 | self.assertThat( |
244 | 29 | self.main_window.get_qml_view().visible, Eventually(Equals(True))) | ||
245 | 28 | 30 | ||
246 | 29 | def tearDown(self): | 31 | def tearDown(self): |
247 | 30 | super(TestFocus, self).tearDown() | 32 | super(TestFocus, self).tearDown() |
248 | @@ -41,13 +43,13 @@ | |||
249 | 41 | # The focus ring should be invisible in the beginning | 43 | # The focus ring should be invisible in the beginning |
250 | 42 | self.assertEquals(focus_ring.opacity, 0.0) | 44 | self.assertEquals(focus_ring.opacity, 0.0) |
251 | 43 | 45 | ||
255 | 44 | # Click in the center of the viewfinder area | 46 | self.pointing_device.move_to_object(feed) |
253 | 45 | click_coords = [feed.globalRect[2] / 2 + feed.globalRect[0], feed.globalRect[3] / 2 + feed.globalRect[1]] | ||
254 | 46 | self.pointing_device.move(click_coords[0], click_coords[1]) | ||
256 | 47 | self.pointing_device.click() | 47 | self.pointing_device.click() |
257 | 48 | click_coords = list(self.pointing_device.position()) | ||
258 | 48 | 49 | ||
261 | 49 | # The focus ring sould be visible and centered to the mouse click coords now | 50 | # The focus ring sould be visible and centered to the mouse click |
262 | 50 | focus_ring_center = [focus_ring.globalRect[2] / 2 + focus_ring.globalRect[0], focus_ring.globalRect[3] / 2 + focus_ring.globalRect[1]] | 51 | # coords now |
263 | 52 | focus_ring_center = self.get_center(focus_ring) | ||
264 | 51 | self.assertThat(focus_ring.opacity, Eventually(Equals(1.0))) | 53 | self.assertThat(focus_ring.opacity, Eventually(Equals(1.0))) |
265 | 52 | self.assertEquals(focus_ring_center, click_coords) | 54 | self.assertEquals(focus_ring_center, click_coords) |
266 | 53 | 55 | ||
267 | @@ -60,20 +62,22 @@ | |||
268 | 60 | self.assertThat(exposure_button.enabled, Eventually(Equals(True))) | 62 | self.assertThat(exposure_button.enabled, Eventually(Equals(True))) |
269 | 61 | 63 | ||
270 | 62 | # Click in the center of the viewfinder area | 64 | # Click in the center of the viewfinder area |
272 | 63 | click_coords = [feed.globalRect[2] / 2 + feed.globalRect[0], feed.globalRect[3] / 2 + feed.globalRect[1]] | 65 | click_coords =[feed.globalRect[2] / 2 + feed.globalRect[0], feed.globalRect[3] / 2 + feed.globalRect[1]] |
273 | 64 | self.pointing_device.move(click_coords[0], click_coords[1]) | 66 | self.pointing_device.move(click_coords[0], click_coords[1]) |
274 | 65 | self.pointing_device.click() | 67 | self.pointing_device.click() |
275 | 66 | 68 | ||
278 | 67 | # The focus ring sould be visible and centered to the mouse click coords now | 69 | # The focus ring sould be visible and centered to the mouse |
279 | 68 | focus_ring_center = [focus_ring.globalRect[2] / 2 + focus_ring.globalRect[0], focus_ring.globalRect[3] / 2 + focus_ring.globalRect[1]] | 70 | # click coords now |
280 | 71 | focus_ring_center = self.get_center(focus_ring) | ||
281 | 69 | self.assertThat(focus_ring.opacity, Eventually(Equals(1.0))) | 72 | self.assertThat(focus_ring.opacity, Eventually(Equals(1.0))) |
282 | 70 | self.assertEquals(focus_ring_center, click_coords) | 73 | self.assertEquals(focus_ring_center, click_coords) |
283 | 71 | 74 | ||
284 | 72 | # After some seconds the focus ring should fade out | 75 | # After some seconds the focus ring should fade out |
285 | 73 | self.assertThat(focus_ring.opacity, Eventually(Equals(0.0))) | 76 | self.assertThat(focus_ring.opacity, Eventually(Equals(0.0))) |
286 | 74 | 77 | ||
287 | 75 | """Tests clicking outside of the viewfinder image area, where it should not focus""" | ||
288 | 76 | def test_focus_invalid(self): | 78 | def test_focus_invalid(self): |
289 | 79 | """Tests clicking outside of the viewfinder image area, where it should | ||
290 | 80 | not focus.""" | ||
291 | 77 | camera_window = self.main_window.get_camera() | 81 | camera_window = self.main_window.get_camera() |
292 | 78 | toolbar = self.main_window.get_toolbar() | 82 | toolbar = self.main_window.get_toolbar() |
293 | 79 | zoom = self.main_window.get_zoom_control() | 83 | zoom = self.main_window.get_zoom_control() |
294 | @@ -85,16 +89,21 @@ | |||
295 | 85 | # The focus ring should be invisible in the beginning | 89 | # The focus ring should be invisible in the beginning |
296 | 86 | self.assertEquals(focus_ring.opacity, 0.0) | 90 | self.assertEquals(focus_ring.opacity, 0.0) |
297 | 87 | 91 | ||
301 | 88 | # Click at the bottom of the window below the toolbar. It should never focus there. | 92 | x, y, h, w = toolbar.globalRect |
302 | 89 | click_coords = [toolbar.globalRect[2] / 2 + toolbar.globalRect[0], toolbar.globalRect[1] + toolbar.globalRect[3] + 2] | 93 | tx = x + (h / 2) |
303 | 90 | self.pointing_device.move(click_coords[0], click_coords[1]) | 94 | ty = y + (w + 2) |
304 | 95 | # Click at the bottom of the window below the toolbar. It should never | ||
305 | 96 | # focus there. | ||
306 | 97 | self.pointing_device.move(tx, ty) | ||
307 | 91 | self.pointing_device.click() | 98 | self.pointing_device.click() |
308 | 92 | self.assertEquals(focus_ring.opacity, 0.0) | 99 | self.assertEquals(focus_ring.opacity, 0.0) |
309 | 93 | 100 | ||
312 | 94 | # Check if there's a gap between the viewfinder feed and the zoom control. | 101 | # Check if there's a gap between the viewfinder feed and the zoom |
313 | 95 | # If there is, test that focusing there won't show the focus ring. | 102 | # control. If there is, test that focusing there won't show the focus |
314 | 103 | #ring. | ||
315 | 96 | if zoom.y > feed.height: # Feed is aligned to the top of the window | 104 | if zoom.y > feed.height: # Feed is aligned to the top of the window |
317 | 97 | click_coords = [zoom.globalRect[2] / 2 + zoom.globalRect[0], zoom.globalRect[1] - 2] | 105 | x, y, h, w = zoom.globalRect |
318 | 106 | click_coords = [x + (h / 2), y - 2] | ||
319 | 98 | self.pointing_device.move(click_coords[0], click_coords[1]) | 107 | self.pointing_device.move(click_coords[0], click_coords[1]) |
320 | 99 | self.pointing_device.click() | 108 | self.pointing_device.click() |
321 | 100 | self.assertEquals(focus_ring.opacity, 0.0) | 109 | self.assertEquals(focus_ring.opacity, 0.0) |
322 | @@ -106,7 +115,8 @@ | |||
323 | 106 | 115 | ||
324 | 107 | # Maybe we will have the gap when we switch the camera, test it again | 116 | # Maybe we will have the gap when we switch the camera, test it again |
325 | 108 | if zoom.y > feed.height: | 117 | if zoom.y > feed.height: |
327 | 109 | click_coords = [zoom.globalRect[2] / 2 + zoom.globalRect[0], zoom.globalRect[1] - 2] | 118 | x, y, h, w = zoom.globalRect |
328 | 119 | click_coords = [x + (h / 2), y - 2] | ||
329 | 110 | self.pointing_device.move(click_coords[0], click_coords[1]) | 120 | self.pointing_device.move(click_coords[0], click_coords[1]) |
330 | 111 | self.pointing_device.click() | 121 | self.pointing_device.click() |
331 | 112 | self.assertEquals(focus_ring.opacity, 0.0) | 122 | self.assertEquals(focus_ring.opacity, 0.0) |
332 | @@ -123,36 +133,38 @@ | |||
333 | 123 | self.assertEquals(focus_ring.opacity, 0.0) | 133 | self.assertEquals(focus_ring.opacity, 0.0) |
334 | 124 | 134 | ||
335 | 125 | # Focus to the center of the viewfinder feed | 135 | # Focus to the center of the viewfinder feed |
338 | 126 | center_click_coords = [feed.globalRect[2] / 2 + feed.globalRect[0], feed.globalRect[3] / 2 + feed.globalRect[1]] | 136 | self.pointing_device.move_to_object(feed) |
337 | 127 | self.pointing_device.move(center_click_coords[0], center_click_coords[1]) | ||
339 | 128 | self.pointing_device.click() | 137 | self.pointing_device.click() |
340 | 138 | center_click_coords = list(self.pointing_device.position()) | ||
341 | 129 | 139 | ||
343 | 130 | focus_ring_center = [focus_ring.globalRect[2] / 2 + focus_ring.globalRect[0], focus_ring.globalRect[3] / 2 + focus_ring.globalRect[1]] | 140 | focus_ring_center = self.get_center(focus_ring) |
344 | 131 | self.assertThat(focus_ring.opacity, Eventually(Equals(1.0))) | 141 | self.assertThat(focus_ring.opacity, Eventually(Equals(1.0))) |
345 | 132 | self.assertEquals(focus_ring_center, center_click_coords) | 142 | self.assertEquals(focus_ring_center, center_click_coords) |
346 | 133 | 143 | ||
347 | 134 | # Now drag it halfway across the feed, verify that it has moved there | 144 | # Now drag it halfway across the feed, verify that it has moved there |
350 | 135 | drag_end_coords = [focus_ring_center[0] + feed.globalRect[2] / 4, focus_ring_center[1] + feed.globalRect[3] / 4] | 145 | tx = focus_ring_center[0] |
351 | 136 | self.pointing_device.drag(focus_ring_center[0], focus_ring_center[1], drag_end_coords[0], drag_end_coords[1]) | 146 | ty = focus_ring_center[1] |
352 | 147 | self.pointing_device.drag(tx, ty, tx / 2, ty / 2) | ||
353 | 137 | 148 | ||
356 | 138 | focus_ring_center = [focus_ring.globalRect[2] / 2 + focus_ring.globalRect[0], focus_ring.globalRect[3] / 2 + focus_ring.globalRect[1]] | 149 | focus_ring_center = self.get_center(focus_ring) |
357 | 139 | self.assertThat(focus_ring_center[1], GreaterThan(drag_end_coords[1] - 2)) | 150 | self.assertThat(focus_ring_center[1], GreaterThan(ty / 2 - 2)) |
358 | 140 | 151 | ||
359 | 141 | # Switch cameras, wait for camera to settle, and try again | 152 | # Switch cameras, wait for camera to settle, and try again |
360 | 142 | self.pointing_device.move_to_object(switch_cameras) | 153 | self.pointing_device.move_to_object(switch_cameras) |
361 | 143 | self.pointing_device.click() | 154 | self.pointing_device.click() |
362 | 144 | self.assertThat(exposure_button.enabled, Eventually(Equals(True))) | 155 | self.assertThat(exposure_button.enabled, Eventually(Equals(True))) |
363 | 145 | 156 | ||
366 | 146 | center_click_coords = [feed.globalRect[2] / 2 + feed.globalRect[0], feed.globalRect[3] / 2 + feed.globalRect[1]] | 157 | self.pointing_device.move_to_object(feed) |
365 | 147 | self.pointing_device.move(center_click_coords[0], center_click_coords[1]) | ||
367 | 148 | self.pointing_device.click() | 158 | self.pointing_device.click() |
368 | 159 | center_click_coords = list(self.pointing_device.position()) | ||
369 | 149 | 160 | ||
371 | 150 | focus_ring_center = [focus_ring.globalRect[2] / 2 + focus_ring.globalRect[0], focus_ring.globalRect[3] / 2 + focus_ring.globalRect[1]] | 161 | focus_ring_center = self.get_center(focus_ring) |
372 | 151 | self.assertThat(focus_ring.opacity, Eventually(Equals(1.0))) | 162 | self.assertThat(focus_ring.opacity, Eventually(Equals(1.0))) |
373 | 152 | self.assertEquals(focus_ring_center, center_click_coords) | 163 | self.assertEquals(focus_ring_center, center_click_coords) |
374 | 153 | 164 | ||
377 | 154 | drag_end_coords = [focus_ring_center[0] + feed.globalRect[2] / 4, focus_ring_center[1] + feed.globalRect[3] / 4] | 165 | tx = focus_ring_center[0] |
378 | 155 | self.pointing_device.drag(focus_ring_center[0], focus_ring_center[1], drag_end_coords[0], drag_end_coords[1]) | 166 | ty = focus_ring_center[1] |
379 | 167 | self.pointing_device.drag(tx, ty, tx / 2, ty / 2) | ||
380 | 156 | 168 | ||
383 | 157 | focus_ring_center = [focus_ring.globalRect[2] / 2 + focus_ring.globalRect[0], focus_ring.globalRect[3] / 2 + focus_ring.globalRect[1]] | 169 | focus_ring_center = self.get_center(focus_ring) |
384 | 158 | self.assertThat(focus_ring_center[1], GreaterThan(drag_end_coords[1] - 2)) | 170 | self.assertThat(focus_ring_center[1], GreaterThan(ty / 2 - 2)) |
385 | 159 | 171 | ||
386 | === modified file 'tests/autopilot/camera_app/tests/test_zoom.py' | |||
387 | --- tests/autopilot/camera_app/tests/test_zoom.py 2013-05-14 19:55:38 +0000 | |||
388 | +++ tests/autopilot/camera_app/tests/test_zoom.py 2013-05-29 11:56:26 +0000 | |||
389 | @@ -17,6 +17,7 @@ | |||
390 | 17 | import time | 17 | import time |
391 | 18 | import unittest | 18 | import unittest |
392 | 19 | 19 | ||
393 | 20 | |||
394 | 20 | class TestCameraZoom(CameraAppTestCase): | 21 | class TestCameraZoom(CameraAppTestCase): |
395 | 21 | """Tests the main camera features""" | 22 | """Tests the main camera features""" |
396 | 22 | 23 | ||
397 | @@ -24,7 +25,8 @@ | |||
398 | 24 | In the testfarm, the application may take some time to show up.""" | 25 | In the testfarm, the application may take some time to show up.""" |
399 | 25 | def setUp(self): | 26 | def setUp(self): |
400 | 26 | super(TestCameraZoom, self).setUp() | 27 | super(TestCameraZoom, self).setUp() |
402 | 27 | self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True))) | 28 | self.assertThat( |
403 | 29 | self.main_window.get_qml_view().visible, Eventually(Equals(True))) | ||
404 | 28 | 30 | ||
405 | 29 | def tearDown(self): | 31 | def tearDown(self): |
406 | 30 | super(TestCameraZoom, self).tearDown() | 32 | super(TestCameraZoom, self).tearDown() |
407 | @@ -32,30 +34,32 @@ | |||
408 | 32 | """Tests the zoom slider""" | 34 | """Tests the zoom slider""" |
409 | 33 | def test_slider(self): | 35 | def test_slider(self): |
410 | 34 | zoom_control = self.main_window.get_zoom_control() | 36 | zoom_control = self.main_window.get_zoom_control() |
411 | 35 | |||
412 | 36 | zoom_button = self.main_window.get_zoom_slider_button() | 37 | zoom_button = self.main_window.get_zoom_slider_button() |
413 | 37 | 38 | ||
431 | 38 | zoom_button_center_x = zoom_button.globalRect[0] + zoom_button.globalRect[2] / 2 | 39 | x, y, h, w = zoom_button.globalRect |
432 | 39 | zoom_button_center_y = zoom_button.globalRect[1] + zoom_button.globalRect[3] / 2 | 40 | |
433 | 40 | 41 | tx = x + (h / 2) | |
434 | 41 | if self.main_window.get_orientation() == "portrait": | 42 | ty = y + (w / 2) |
435 | 42 | self.pointing_device.drag(zoom_button_center_x, zoom_button_center_y, zoom_button_center_x + zoom_control.width, zoom_button_center_y) | 43 | |
436 | 43 | else: | 44 | if self.main_window.get_orientation() == "portrait": |
437 | 44 | self.pointing_device.drag(zoom_button_center_x, zoom_button_center_y, zoom_button_center_x, zoom_button_center_y - zoom_control.width) | 45 | self.pointing_device.drag(tx, ty, (tx + zoom_control.width), ty) |
438 | 45 | 46 | else: | |
439 | 46 | self.assertThat(zoom_control.value, Eventually(Equals(zoom_control.maximumValue))) | 47 | self.pointing_device.drag(tx, ty, tx, (ty - zoom_control.width)) |
440 | 47 | 48 | ||
441 | 48 | zoom_button_center_x = zoom_button.globalRect[0] + zoom_button.globalRect[2] / 2 | 49 | self.assertThat( |
442 | 49 | zoom_button_center_y = zoom_button.globalRect[1] + zoom_button.globalRect[3] / 2 | 50 | zoom_control.value, Eventually(Equals(zoom_control.maximumValue))) |
443 | 50 | 51 | ||
444 | 51 | if self.main_window.get_orientation() == "portrait": | 52 | tx = x + (h / 2) |
445 | 52 | self.pointing_device.drag(zoom_button_center_x, zoom_button_center_y, zoom_button_center_x - zoom_control.width, zoom_button_center_y) | 53 | ty = y + (w / 2) |
446 | 53 | else: | 54 | |
447 | 54 | self.pointing_device.drag(zoom_button_center_x, zoom_button_center_y, zoom_button_center_x, zoom_button_center_y + zoom_control.width) | 55 | if self.main_window.get_orientation() == "portrait": |
448 | 56 | self.pointing_device.drag(tx, ty, (tx - zoom_control.width), ty) | ||
449 | 57 | else: | ||
450 | 58 | self.pointing_device.drag(tx, ty, tx, (ty + zoom_control.width)) | ||
451 | 55 | 59 | ||
452 | 56 | self.assertThat(zoom_control.value, Eventually(Equals(1.0))) | 60 | self.assertThat(zoom_control.value, Eventually(Equals(1.0))) |
453 | 57 | 61 | ||
455 | 58 | @unittest.skip("Disabled this failing test due to bug 1179592") | 62 | @unittest.skip("Disabled this failing test due to bug 1179592") |
456 | 59 | def test_plus_minus(self): | 63 | def test_plus_minus(self): |
457 | 60 | """Tests the plus and minus buttons""" | 64 | """Tests the plus and minus buttons""" |
458 | 61 | zoom_control = self.main_window.get_zoom_control() | 65 | zoom_control = self.main_window.get_zoom_control() |
459 | @@ -79,32 +83,39 @@ | |||
460 | 79 | 83 | ||
461 | 80 | self.pointing_device.move_to_object(minus) | 84 | self.pointing_device.move_to_object(minus) |
462 | 81 | self.pointing_device.click() | 85 | self.pointing_device.click() |
464 | 82 | self.assertThat(zoom_control.value, Eventually(LessThan(value_before_minus))) | 86 | self.assertThat( |
465 | 87 | zoom_control.value, Eventually(LessThan(value_before_minus))) | ||
466 | 83 | 88 | ||
467 | 84 | # Test that keeping the plus button pressed eventually reaches max zoom | 89 | # Test that keeping the plus button pressed eventually reaches max zoom |
468 | 85 | self.pointing_device.move_to_object(plus) | 90 | self.pointing_device.move_to_object(plus) |
469 | 86 | self.pointing_device.press() | 91 | self.pointing_device.press() |
471 | 87 | self.assertThat(zoom_control.value, Eventually(Equals(zoom_control.maximumValue))) | 92 | self.assertThat( |
472 | 93 | zoom_control.value, Eventually(Equals(zoom_control.maximumValue))) | ||
473 | 88 | self.pointing_device.release() | 94 | self.pointing_device.release() |
474 | 89 | 95 | ||
475 | 90 | # Test that plus when at maximum zoom does nothing | 96 | # Test that plus when at maximum zoom does nothing |
477 | 91 | self.assertThat(zoom_control.value, Eventually(Equals(zoom_control.maximumValue))) | 97 | self.assertThat( |
478 | 98 | zoom_control.value, Eventually(Equals(zoom_control.maximumValue))) | ||
479 | 92 | self.pointing_device.move_to_object(plus) | 99 | self.pointing_device.move_to_object(plus) |
480 | 93 | self.pointing_device.click() | 100 | self.pointing_device.click() |
482 | 94 | self.assertThat(zoom_control.value, Eventually(Equals(zoom_control.maximumValue))) | 101 | self.assertThat( |
483 | 102 | zoom_control.value, Eventually(Equals(zoom_control.maximumValue))) | ||
484 | 95 | 103 | ||
485 | 96 | # Test that minus moves to some non-maximum value | 104 | # Test that minus moves to some non-maximum value |
486 | 97 | # and that plus goes back up | 105 | # and that plus goes back up |
488 | 98 | self.assertThat(zoom_control.value, Eventually(Equals(zoom_control.maximumValue))) | 106 | self.assertThat( |
489 | 107 | zoom_control.value, Eventually(Equals(zoom_control.maximumValue))) | ||
490 | 99 | self.pointing_device.move_to_object(minus) | 108 | self.pointing_device.move_to_object(minus) |
491 | 100 | self.pointing_device.click() | 109 | self.pointing_device.click() |
493 | 101 | self.assertThat(zoom_control.value, Eventually(NotEquals(zoom_control.maximumValue))) | 110 | self.assertThat( |
494 | 111 | zoom_control.value, Eventually(NotEquals(zoom_control.maximumValue))) | ||
495 | 102 | 112 | ||
496 | 103 | value_before_plus = zoom_control.value | 113 | value_before_plus = zoom_control.value |
497 | 104 | 114 | ||
498 | 105 | self.pointing_device.move_to_object(plus) | 115 | self.pointing_device.move_to_object(plus) |
499 | 106 | self.pointing_device.click() | 116 | self.pointing_device.click() |
501 | 107 | self.assertThat(zoom_control.value, Eventually(GreaterThan(value_before_plus))) | 117 | self.assertThat( |
502 | 118 | zoom_control.value, Eventually(GreaterThan(value_before_plus))) | ||
503 | 108 | 119 | ||
504 | 109 | # Test that keeping the minus button pressed eventually reaches min zoom | 120 | # Test that keeping the minus button pressed eventually reaches min zoom |
505 | 110 | self.pointing_device.move_to_object(minus) | 121 | self.pointing_device.move_to_object(minus) |
PASSED: Continuous integration, rev:133 jenkins. qa.ubuntu. com/job/ camera- app-ci/ 42/ jenkins. qa.ubuntu. com/job/ camera- app-raring- amd64-ci/ 32 jenkins. qa.ubuntu. com/job/ camera- app-raring- armhf-ci/ 55 jenkins. qa.ubuntu. com/job/ camera- app-raring- armhf-ci/ 55/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ camera- app-raring- i386-ci/ 55 jenkins. qa.ubuntu. com/job/ generic- mediumtests- runner/ 1690
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ camera- app-ci/ 42/rebuild
http://