Merge lp:~om26er/camera-app/ap_tests_improvements into lp:camera-app

Proposed by Omer Akram
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
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.

To post a comment you must log in.
133. By Omer Akram

simplify

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
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

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
136. By Omer Akram

separate out the Nexus 7 skip test changes

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Omer Akram (om26er) wrote :

I have now removed the Nexus 7 specific changes, I'll do that in another branch.

Revision history for this message
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.pointing_device.position())
347 +
348 + focus_ring_center = self.get_center(focus_ring)
349 +

Same issue here

356 + drag_end_coords = [focus_ring_center[0] / 2, focus_ring_center[1] / 2]
357 + self.pointing_device.drag(
358 + focus_ring_center[0], focus_ring_center[1], drag_end_coords[0], drag_end_coords[1])
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

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: Approve (continuous-integration)
Revision history for this message
Ugo Riboni (uriboni) wrote :

Looks good to me and all tests pass on jenkins, approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/autopilot/camera_app/tests/__init__.py'
--- tests/autopilot/camera_app/tests/__init__.py 2013-05-14 20:27:38 +0000
+++ tests/autopilot/camera_app/tests/__init__.py 2013-05-29 11:56:26 +0000
@@ -18,18 +18,19 @@
1818
19from camera_app.emulators.main_window import MainWindow19from camera_app.emulators.main_window import MainWindow
2020
21
21class CameraAppTestCase(AutopilotTestCase):22class CameraAppTestCase(AutopilotTestCase):
2223
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
25 for camera-app tests.
2426
27 """
25 if model() == 'Desktop':28 if model() == 'Desktop':
26 scenarios = [29 scenarios = [
27 ('with mouse', dict(input_device_class=Mouse))30 ('with mouse', dict(input_device_class=Mouse))]
28 ]
29 else:31 else:
30 scenarios = [32 scenarios = [
31 ('with touch', dict(input_device_class=Touch))33 ('with touch', dict(input_device_class=Touch))]
32 ]
3334
34 local_location = "../../camera-app"35 local_location = "../../camera-app"
3536
@@ -56,7 +57,10 @@
56 "--desktop_file_hint=/usr/share/applications/camera-app.desktop",57 "--desktop_file_hint=/usr/share/applications/camera-app.desktop",
57 app_type='qt')58 app_type='qt')
5859
60 def get_center(self, object_proxy):
61 x, y, w, h = object_proxy.globalRect
62 return [x + (w / 2), y + (h / 2)]
63
59 @property64 @property
60 def main_window(self):65 def main_window(self):
61 return MainWindow(self.app)66 return MainWindow(self.app)
62
6367
=== modified file 'tests/autopilot/camera_app/tests/test_capture.py'
--- tests/autopilot/camera_app/tests/test_capture.py 2013-05-07 19:07:05 +0000
+++ tests/autopilot/camera_app/tests/test_capture.py 2013-05-29 11:56:26 +0000
@@ -20,6 +20,7 @@
20import os20import os
21from os import path21from os import path
2222
23
23class TestCapture(CameraAppTestCase):24class TestCapture(CameraAppTestCase):
24 """Tests the main camera features"""25 """Tests the main camera features"""
2526
@@ -27,7 +28,8 @@
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."""
28 def setUp(self):29 def setUp(self):
29 super(TestCapture, self).setUp()30 super(TestCapture, self).setUp()
30 self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))31 self.assertThat(
32 self.main_window.get_qml_view().visible, Eventually(Equals(True)))
3133
32 def tearDown(self):34 def tearDown(self):
33 super(TestCapture, self).tearDown()35 super(TestCapture, self).tearDown()
@@ -39,21 +41,23 @@
39 pictures_dir = path.expanduser("~/Pictures")41 pictures_dir = path.expanduser("~/Pictures")
4042
41 # Remove all pictures from ~/Pictures that match our pattern43 # Remove all pictures from ~/Pictures that match our pattern
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))]
43 for f in files:45 for f in files:
44 os.remove(path.join(pictures_dir, f))46 os.remove(path.join(pictures_dir, f))
4547
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
49 # (the exposure button gets enabled when ready)
47 self.assertThat(exposure_button.enabled, Eventually(Equals(True)))50 self.assertThat(exposure_button.enabled, Eventually(Equals(True)))
4851
49 # Now take the picture! (Give it a little time to animate)52 # Now take the picture! (Give it a little time to animate)
50 self.pointing_device.move_to_object(exposure_button)53 self.pointing_device.move_to_object(exposure_button)
51 self.pointing_device.click()54 self.pointing_device.click()
5255
53 # Check that only one picture with the right name pattern is actually there56 # Check that only one picture with the right name pattern
57 # is actually there
54 one_picture_on_disk = False58 one_picture_on_disk = False
55 for i in range(0, 10):59 for i in range(0, 10):
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))]
57 if len(files) == 1:61 if len(files) == 1:
58 one_picture_on_disk = True62 one_picture_on_disk = True
59 break63 break
@@ -78,7 +82,7 @@
7882
79 # Click the record button to toggle photo/video mode83 # Click the record button to toggle photo/video mode
80 self.pointing_device.move_to_object(record_control)84 self.pointing_device.move_to_object(record_control)
81 self.pointing_device.click();85 self.pointing_device.click()
8286
83 # Has the flash changed to be a torch ?87 # Has the flash changed to be a torch ?
84 self.assertThat(flash_button.flashState, Eventually(Equals("off")))88 self.assertThat(flash_button.flashState, Eventually(Equals("off")))
@@ -91,24 +95,27 @@
9195
92 # Click the exposure button to start recording96 # Click the exposure button to start recording
93 self.pointing_device.move_to_object(exposure_button)97 self.pointing_device.move_to_object(exposure_button)
94 self.pointing_device.click();98 self.pointing_device.click()
9599
96 # Record video for 2 seconds and check if the stop watch actually runs and100 # Record video for 2 seconds and check if the stop watch actually
97 # is visible.101 # runs and is visible.
98 # Since the timer is not precise we don't check the actual time, just that it102 # Since the timer is not precise we don't check the actual time,
99 # is not counting zero anymore.103 # just that it is not counting zero anymore.
100 self.assertThat(stop_watch.opacity, Eventually(Equals(1.0)))104 self.assertThat(stop_watch.opacity, Eventually(Equals(1.0)))
101 self.assertThat(stop_watch.elapsed, Eventually(NotEquals("00:00")))105 self.assertThat(stop_watch.elapsed, Eventually(NotEquals("00:00")))
102106
103 # Now stop the video and check if everything resets itself to previous states107 # Now stop the video and check if everything resets itself to
108 # previous states.
104 self.pointing_device.click()109 self.pointing_device.click()
105110
106 self.assertThat(stop_watch.opacity, Eventually(Equals(0.0)))111 self.assertThat(stop_watch.opacity, Eventually(Equals(0.0)))
107112
108 # Now start recording a second video and check if everything still works113 # Now start recording a second video and check if everything
109 self.pointing_device.click();114 # still works
115 self.pointing_device.click()
110116
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
118 # and set to 00:00?
112 self.assertThat(flash_button.flashState, Eventually(Equals("off")))119 self.assertThat(flash_button.flashState, Eventually(Equals("off")))
113 self.assertThat(flash_button.torchMode, Eventually(Equals(True)))120 self.assertThat(flash_button.torchMode, Eventually(Equals(True)))
114 self.assertThat(stop_watch.opacity, Eventually(Equals(1.0)))121 self.assertThat(stop_watch.opacity, Eventually(Equals(1.0)))
@@ -117,16 +124,20 @@
117 # Record video for 2 seconds and check if the stop watch actually works124 # Record video for 2 seconds and check if the stop watch actually works
118 self.assertThat(stop_watch.elapsed, Eventually(NotEquals("00:00")))125 self.assertThat(stop_watch.elapsed, Eventually(NotEquals("00:00")))
119126
120 # Now stop the video and go back to picture mode and check if everything resets itself to previous states127 # Now stop the video and go back to picture mode and check if
121 self.pointing_device.click();128 # everything resets itself to previous states
129 self.pointing_device.click()
122 self.pointing_device.move_to_object(record_control)130 self.pointing_device.move_to_object(record_control)
123 self.pointing_device.click();131 self.pointing_device.click()
124132
125 self.assertThat(stop_watch.opacity, Eventually(Equals(0.0)))133 self.assertThat(stop_watch.opacity, Eventually(Equals(0.0)))
126 self.assertThat(flash_button.flashState, Eventually(Equals(flashlight_old_state)))134 self.assertThat(
127 self.assertThat(flash_button.torchMode, Eventually(Equals(torchmode_old_state)))135 flash_button.flashState, Eventually(Equals(flashlight_old_state)))
136 self.assertThat(
137 flash_button.torchMode, Eventually(Equals(torchmode_old_state)))
128138
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
140 after shooting"""
130 def test_shoot_button_disable(self):141 def test_shoot_button_disable(self):
131 exposure_button = self.main_window.get_exposure_button()142 exposure_button = self.main_window.get_exposure_button()
132143
133144
=== modified file 'tests/autopilot/camera_app/tests/test_flash.py'
--- tests/autopilot/camera_app/tests/test_flash.py 2013-04-26 13:22:45 +0000
+++ tests/autopilot/camera_app/tests/test_flash.py 2013-05-29 11:56:26 +0000
@@ -16,6 +16,7 @@
1616
17import time17import time
1818
19
19class TestCameraFlash(CameraAppTestCase):20class TestCameraFlash(CameraAppTestCase):
20 """Tests the flash"""21 """Tests the flash"""
2122
@@ -23,7 +24,8 @@
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."""
24 def setUp(self):25 def setUp(self):
25 super(TestCameraFlash, self).setUp()26 super(TestCameraFlash, self).setUp()
26 self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))27 self.assertThat(
28 self.main_window.get_qml_view().visible, Eventually(Equals(True)))
2729
28 def tearDown(self):30 def tearDown(self):
29 super(TestCameraFlash, self).tearDown()31 super(TestCameraFlash, self).tearDown()
@@ -77,8 +79,8 @@
77 flash_button = self.main_window.get_flash_button()79 flash_button = self.main_window.get_flash_button()
78 record_button = self.main_window.get_record_control()80 record_button = self.main_window.get_record_control()
7981
80 # Change flash mode, then switch to camera, then back to flash and verify82 # Change flash mode, then switch to camera, then back to flash
81 # that previous state is preserved83 # and verify that previous state is preserved
82 self.pointing_device.move_to_object(flash_button)84 self.pointing_device.move_to_object(flash_button)
83 self.pointing_device.click()85 self.pointing_device.click()
84 self.pointing_device.click()86 self.pointing_device.click()
@@ -90,10 +92,12 @@
90 self.assertThat(flash_button.torchMode, Equals(True))92 self.assertThat(flash_button.torchMode, Equals(True))
9193
92 self.pointing_device.click()94 self.pointing_device.click()
93 self.assertThat(flash_button.flashState, Eventually(Equals(old_flash_state)))95 self.assertThat(
96 flash_button.flashState, Eventually(Equals(old_flash_state)))
94 self.assertThat(flash_button.torchMode, Equals(False))97 self.assertThat(flash_button.torchMode, Equals(False))
9598
96 # Now test the same thing in the opposite way, seeing if torch state is preserved99 # Now test the same thing in the opposite way, seeing if torch state
100 # is preserved
97 self.pointing_device.click()101 self.pointing_device.click()
98 self.assertThat(flash_button.flashState, Eventually(Equals("off")))102 self.assertThat(flash_button.flashState, Eventually(Equals("off")))
99 self.assertThat(flash_button.torchMode, Equals(True))103 self.assertThat(flash_button.torchMode, Equals(True))
@@ -104,9 +108,11 @@
104108
105 self.pointing_device.move_to_object(record_button)109 self.pointing_device.move_to_object(record_button)
106 self.pointing_device.click()110 self.pointing_device.click()
107 self.assertThat(flash_button.flashState, Eventually(Equals(old_flash_state)))111 self.assertThat(
112 flash_button.flashState, Eventually(Equals(old_flash_state)))
108 self.assertThat(flash_button.torchMode, Equals(False))113 self.assertThat(flash_button.torchMode, Equals(False))
109114
110 self.pointing_device.click()115 self.pointing_device.click()
111 self.assertThat(flash_button.flashState, Eventually(Equals(old_torch_state)))116 self.assertThat(
117 flash_button.flashState, Eventually(Equals(old_torch_state)))
112 self.assertThat(flash_button.torchMode, Equals(True))118 self.assertThat(flash_button.torchMode, Equals(True))
113119
=== modified file 'tests/autopilot/camera_app/tests/test_focus.py'
--- tests/autopilot/camera_app/tests/test_focus.py 2013-04-26 13:22:45 +0000
+++ tests/autopilot/camera_app/tests/test_focus.py 2013-05-29 11:56:26 +0000
@@ -17,6 +17,7 @@
17import unittest17import unittest
18import time18import time
1919
20
20class TestFocus(CameraAppTestCase):21class TestFocus(CameraAppTestCase):
21 """Tests the focus"""22 """Tests the focus"""
2223
@@ -24,7 +25,8 @@
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."""
25 def setUp(self):26 def setUp(self):
26 super(TestFocus, self).setUp()27 super(TestFocus, self).setUp()
27 self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))28 self.assertThat(
29 self.main_window.get_qml_view().visible, Eventually(Equals(True)))
2830
29 def tearDown(self):31 def tearDown(self):
30 super(TestFocus, self).tearDown()32 super(TestFocus, self).tearDown()
@@ -41,13 +43,13 @@
41 # The focus ring should be invisible in the beginning43 # The focus ring should be invisible in the beginning
42 self.assertEquals(focus_ring.opacity, 0.0)44 self.assertEquals(focus_ring.opacity, 0.0)
4345
44 # Click in the center of the viewfinder area46 self.pointing_device.move_to_object(feed)
45 click_coords = [feed.globalRect[2] / 2 + feed.globalRect[0], feed.globalRect[3] / 2 + feed.globalRect[1]]
46 self.pointing_device.move(click_coords[0], click_coords[1])
47 self.pointing_device.click()47 self.pointing_device.click()
48 click_coords = list(self.pointing_device.position())
4849
49 # The focus ring sould be visible and centered to the mouse click coords now50 # The focus ring sould be visible and centered to the mouse click
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
52 focus_ring_center = self.get_center(focus_ring)
51 self.assertThat(focus_ring.opacity, Eventually(Equals(1.0)))53 self.assertThat(focus_ring.opacity, Eventually(Equals(1.0)))
52 self.assertEquals(focus_ring_center, click_coords)54 self.assertEquals(focus_ring_center, click_coords)
5355
@@ -60,20 +62,22 @@
60 self.assertThat(exposure_button.enabled, Eventually(Equals(True)))62 self.assertThat(exposure_button.enabled, Eventually(Equals(True)))
6163
62 # Click in the center of the viewfinder area64 # Click in the center of the viewfinder area
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]]
64 self.pointing_device.move(click_coords[0], click_coords[1])66 self.pointing_device.move(click_coords[0], click_coords[1])
65 self.pointing_device.click()67 self.pointing_device.click()
6668
67 # The focus ring sould be visible and centered to the mouse click coords now69 # The focus ring sould be visible and centered to the mouse
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
71 focus_ring_center = self.get_center(focus_ring)
69 self.assertThat(focus_ring.opacity, Eventually(Equals(1.0)))72 self.assertThat(focus_ring.opacity, Eventually(Equals(1.0)))
70 self.assertEquals(focus_ring_center, click_coords)73 self.assertEquals(focus_ring_center, click_coords)
7174
72 # After some seconds the focus ring should fade out75 # After some seconds the focus ring should fade out
73 self.assertThat(focus_ring.opacity, Eventually(Equals(0.0)))76 self.assertThat(focus_ring.opacity, Eventually(Equals(0.0)))
7477
75 """Tests clicking outside of the viewfinder image area, where it should not focus"""
76 def test_focus_invalid(self):78 def test_focus_invalid(self):
79 """Tests clicking outside of the viewfinder image area, where it should
80 not focus."""
77 camera_window = self.main_window.get_camera()81 camera_window = self.main_window.get_camera()
78 toolbar = self.main_window.get_toolbar()82 toolbar = self.main_window.get_toolbar()
79 zoom = self.main_window.get_zoom_control()83 zoom = self.main_window.get_zoom_control()
@@ -85,16 +89,21 @@
85 # The focus ring should be invisible in the beginning89 # The focus ring should be invisible in the beginning
86 self.assertEquals(focus_ring.opacity, 0.0)90 self.assertEquals(focus_ring.opacity, 0.0)
8791
88 # Click at the bottom of the window below the toolbar. It should never focus there.92 x, y, h, w = toolbar.globalRect
89 click_coords = [toolbar.globalRect[2] / 2 + toolbar.globalRect[0], toolbar.globalRect[1] + toolbar.globalRect[3] + 2]93 tx = x + (h / 2)
90 self.pointing_device.move(click_coords[0], click_coords[1])94 ty = y + (w + 2)
95 # Click at the bottom of the window below the toolbar. It should never
96 # focus there.
97 self.pointing_device.move(tx, ty)
91 self.pointing_device.click()98 self.pointing_device.click()
92 self.assertEquals(focus_ring.opacity, 0.0)99 self.assertEquals(focus_ring.opacity, 0.0)
93100
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
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
103 #ring.
96 if zoom.y > feed.height: # Feed is aligned to the top of the window104 if zoom.y > feed.height: # Feed is aligned to the top of the window
97 click_coords = [zoom.globalRect[2] / 2 + zoom.globalRect[0], zoom.globalRect[1] - 2]105 x, y, h, w = zoom.globalRect
106 click_coords = [x + (h / 2), y - 2]
98 self.pointing_device.move(click_coords[0], click_coords[1])107 self.pointing_device.move(click_coords[0], click_coords[1])
99 self.pointing_device.click()108 self.pointing_device.click()
100 self.assertEquals(focus_ring.opacity, 0.0)109 self.assertEquals(focus_ring.opacity, 0.0)
@@ -106,7 +115,8 @@
106115
107 # Maybe we will have the gap when we switch the camera, test it again116 # Maybe we will have the gap when we switch the camera, test it again
108 if zoom.y > feed.height:117 if zoom.y > feed.height:
109 click_coords = [zoom.globalRect[2] / 2 + zoom.globalRect[0], zoom.globalRect[1] - 2]118 x, y, h, w = zoom.globalRect
119 click_coords = [x + (h / 2), y - 2]
110 self.pointing_device.move(click_coords[0], click_coords[1])120 self.pointing_device.move(click_coords[0], click_coords[1])
111 self.pointing_device.click()121 self.pointing_device.click()
112 self.assertEquals(focus_ring.opacity, 0.0)122 self.assertEquals(focus_ring.opacity, 0.0)
@@ -123,36 +133,38 @@
123 self.assertEquals(focus_ring.opacity, 0.0)133 self.assertEquals(focus_ring.opacity, 0.0)
124134
125 # Focus to the center of the viewfinder feed135 # Focus to the center of the viewfinder feed
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)
127 self.pointing_device.move(center_click_coords[0], center_click_coords[1])
128 self.pointing_device.click()137 self.pointing_device.click()
138 center_click_coords = list(self.pointing_device.position())
129139
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)
131 self.assertThat(focus_ring.opacity, Eventually(Equals(1.0)))141 self.assertThat(focus_ring.opacity, Eventually(Equals(1.0)))
132 self.assertEquals(focus_ring_center, center_click_coords)142 self.assertEquals(focus_ring_center, center_click_coords)
133143
134 # Now drag it halfway across the feed, verify that it has moved there144 # Now drag it halfway across the feed, verify that it has moved there
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]
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]
147 self.pointing_device.drag(tx, ty, tx / 2, ty / 2)
137148
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)
139 self.assertThat(focus_ring_center[1], GreaterThan(drag_end_coords[1] - 2))150 self.assertThat(focus_ring_center[1], GreaterThan(ty / 2 - 2))
140151
141 # Switch cameras, wait for camera to settle, and try again152 # Switch cameras, wait for camera to settle, and try again
142 self.pointing_device.move_to_object(switch_cameras)153 self.pointing_device.move_to_object(switch_cameras)
143 self.pointing_device.click()154 self.pointing_device.click()
144 self.assertThat(exposure_button.enabled, Eventually(Equals(True)))155 self.assertThat(exposure_button.enabled, Eventually(Equals(True)))
145156
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)
147 self.pointing_device.move(center_click_coords[0], center_click_coords[1])
148 self.pointing_device.click()158 self.pointing_device.click()
159 center_click_coords = list(self.pointing_device.position())
149160
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)
151 self.assertThat(focus_ring.opacity, Eventually(Equals(1.0)))162 self.assertThat(focus_ring.opacity, Eventually(Equals(1.0)))
152 self.assertEquals(focus_ring_center, center_click_coords)163 self.assertEquals(focus_ring_center, center_click_coords)
153164
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]
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]
167 self.pointing_device.drag(tx, ty, tx / 2, ty / 2)
156168
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)
158 self.assertThat(focus_ring_center[1], GreaterThan(drag_end_coords[1] - 2))170 self.assertThat(focus_ring_center[1], GreaterThan(ty / 2 - 2))
159171
=== modified file 'tests/autopilot/camera_app/tests/test_zoom.py'
--- tests/autopilot/camera_app/tests/test_zoom.py 2013-05-14 19:55:38 +0000
+++ tests/autopilot/camera_app/tests/test_zoom.py 2013-05-29 11:56:26 +0000
@@ -17,6 +17,7 @@
17import time17import time
18import unittest18import unittest
1919
20
20class TestCameraZoom(CameraAppTestCase):21class TestCameraZoom(CameraAppTestCase):
21 """Tests the main camera features"""22 """Tests the main camera features"""
2223
@@ -24,7 +25,8 @@
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."""
25 def setUp(self):26 def setUp(self):
26 super(TestCameraZoom, self).setUp()27 super(TestCameraZoom, self).setUp()
27 self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))28 self.assertThat(
29 self.main_window.get_qml_view().visible, Eventually(Equals(True)))
2830
29 def tearDown(self):31 def tearDown(self):
30 super(TestCameraZoom, self).tearDown()32 super(TestCameraZoom, self).tearDown()
@@ -32,30 +34,32 @@
32 """Tests the zoom slider"""34 """Tests the zoom slider"""
33 def test_slider(self):35 def test_slider(self):
34 zoom_control = self.main_window.get_zoom_control()36 zoom_control = self.main_window.get_zoom_control()
35
36 zoom_button = self.main_window.get_zoom_slider_button()37 zoom_button = self.main_window.get_zoom_slider_button()
3738
38 zoom_button_center_x = zoom_button.globalRect[0] + zoom_button.globalRect[2] / 239 x, y, h, w = zoom_button.globalRect
39 zoom_button_center_y = zoom_button.globalRect[1] + zoom_button.globalRect[3] / 240
4041 tx = x + (h / 2)
41 if self.main_window.get_orientation() == "portrait":42 ty = y + (w / 2)
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
43 else:44 if self.main_window.get_orientation() == "portrait":
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)
4546 else:
46 self.assertThat(zoom_control.value, Eventually(Equals(zoom_control.maximumValue)))47 self.pointing_device.drag(tx, ty, tx, (ty - zoom_control.width))
4748
48 zoom_button_center_x = zoom_button.globalRect[0] + zoom_button.globalRect[2] / 249 self.assertThat(
49 zoom_button_center_y = zoom_button.globalRect[1] + zoom_button.globalRect[3] / 250 zoom_control.value, Eventually(Equals(zoom_control.maximumValue)))
5051
51 if self.main_window.get_orientation() == "portrait":52 tx = x + (h / 2)
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)
53 else:54
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":
56 self.pointing_device.drag(tx, ty, (tx - zoom_control.width), ty)
57 else:
58 self.pointing_device.drag(tx, ty, tx, (ty + zoom_control.width))
5559
56 self.assertThat(zoom_control.value, Eventually(Equals(1.0)))60 self.assertThat(zoom_control.value, Eventually(Equals(1.0)))
5761
58 @unittest.skip("Disabled this failing test due to bug 1179592") 62 @unittest.skip("Disabled this failing test due to bug 1179592")
59 def test_plus_minus(self):63 def test_plus_minus(self):
60 """Tests the plus and minus buttons"""64 """Tests the plus and minus buttons"""
61 zoom_control = self.main_window.get_zoom_control()65 zoom_control = self.main_window.get_zoom_control()
@@ -79,32 +83,39 @@
7983
80 self.pointing_device.move_to_object(minus)84 self.pointing_device.move_to_object(minus)
81 self.pointing_device.click()85 self.pointing_device.click()
82 self.assertThat(zoom_control.value, Eventually(LessThan(value_before_minus)))86 self.assertThat(
87 zoom_control.value, Eventually(LessThan(value_before_minus)))
8388
84 # Test that keeping the plus button pressed eventually reaches max zoom89 # Test that keeping the plus button pressed eventually reaches max zoom
85 self.pointing_device.move_to_object(plus)90 self.pointing_device.move_to_object(plus)
86 self.pointing_device.press()91 self.pointing_device.press()
87 self.assertThat(zoom_control.value, Eventually(Equals(zoom_control.maximumValue)))92 self.assertThat(
93 zoom_control.value, Eventually(Equals(zoom_control.maximumValue)))
88 self.pointing_device.release()94 self.pointing_device.release()
8995
90 # Test that plus when at maximum zoom does nothing96 # Test that plus when at maximum zoom does nothing
91 self.assertThat(zoom_control.value, Eventually(Equals(zoom_control.maximumValue)))97 self.assertThat(
98 zoom_control.value, Eventually(Equals(zoom_control.maximumValue)))
92 self.pointing_device.move_to_object(plus)99 self.pointing_device.move_to_object(plus)
93 self.pointing_device.click()100 self.pointing_device.click()
94 self.assertThat(zoom_control.value, Eventually(Equals(zoom_control.maximumValue)))101 self.assertThat(
102 zoom_control.value, Eventually(Equals(zoom_control.maximumValue)))
95103
96 # Test that minus moves to some non-maximum value104 # Test that minus moves to some non-maximum value
97 # and that plus goes back up105 # and that plus goes back up
98 self.assertThat(zoom_control.value, Eventually(Equals(zoom_control.maximumValue)))106 self.assertThat(
107 zoom_control.value, Eventually(Equals(zoom_control.maximumValue)))
99 self.pointing_device.move_to_object(minus)108 self.pointing_device.move_to_object(minus)
100 self.pointing_device.click()109 self.pointing_device.click()
101 self.assertThat(zoom_control.value, Eventually(NotEquals(zoom_control.maximumValue)))110 self.assertThat(
111 zoom_control.value, Eventually(NotEquals(zoom_control.maximumValue)))
102112
103 value_before_plus = zoom_control.value113 value_before_plus = zoom_control.value
104114
105 self.pointing_device.move_to_object(plus)115 self.pointing_device.move_to_object(plus)
106 self.pointing_device.click()116 self.pointing_device.click()
107 self.assertThat(zoom_control.value, Eventually(GreaterThan(value_before_plus)))117 self.assertThat(
118 zoom_control.value, Eventually(GreaterThan(value_before_plus)))
108119
109 # Test that keeping the minus button pressed eventually reaches min zoom120 # Test that keeping the minus button pressed eventually reaches min zoom
110 self.pointing_device.move_to_object(minus)121 self.pointing_device.move_to_object(minus)

Subscribers

People subscribed via source and target branches