Merge lp:~uriboni/camera-app/reset-zoom-ui into lp:camera-app

Proposed by Ugo Riboni
Status: Superseded
Proposed branch: lp:~uriboni/camera-app/reset-zoom-ui
Merge into: lp:camera-app
Diff against target: 212 lines (+81/-29)
4 files modified
ViewFinderOverlay.qml (+8/-1)
tests/autopilot/camera_app/emulators/main_window.py (+20/-1)
tests/autopilot/camera_app/tests/test_capture.py (+6/-27)
tests/autopilot/camera_app/tests/test_zoom.py (+47/-0)
To merge this branch: bzr merge lp:~uriboni/camera-app/reset-zoom-ui
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Florian Boucault (community) Needs Information
Review via email: mp+277869@code.launchpad.net

This proposal has been superseded by a proposal from 2015-11-25.

Commit message

Correctly reset the zoom UI when the actual zoom level of the camera resets due to switching cameras or recording modes

Description of the change

Correctly reset the zoom UI when the actual zoom level of the camera resets due to switching cameras or recording modes

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

We have a binding one way.

         Binding { target: camera; property: "currentZoom"; value: zoomControl.value }

We ideally would want one the other way no? This could probably be achieved without binding loop issues with something like:

Connections {
   target: camera
   onCurrentZoomChanged: zoomControl.value = camera.currentZoom
}

review: Needs Information
lp:~uriboni/camera-app/reset-zoom-ui updated
601. By Ugo Riboni

Implement the two-way binding in a more general way

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

> We have a binding one way.
>
> Binding { target: camera; property: "currentZoom"; value:
> zoomControl.value }
>
> We ideally would want one the other way no? This could probably be achieved
> without binding loop issues with something like:
>
> Connections {
> target: camera
> onCurrentZoomChanged: zoomControl.value = camera.currentZoom
> }

This actually causes lots of binding loop warnings when zooming, as the value changes:

ViewFinderOverlay.qml:743:13: QML Binding: Binding loop detected for property "value"

I don't think they are a problem, but it still not nice to have them. Should I revert to my previous implementation ?

lp:~uriboni/camera-app/reset-zoom-ui updated
602. By Ugo Riboni

Revert previous commit as it was causing binding loop warnings when zooming

603. By Ugo Riboni

Reset the zoom UI to the actual level when coming back from suspend

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ViewFinderOverlay.qml'
2--- ViewFinderOverlay.qml 2015-10-22 12:21:14 +0000
3+++ ViewFinderOverlay.qml 2015-11-24 17:48:24 +0000
4@@ -571,18 +571,25 @@
5 function completeSwitch() {
6 viewFinderSwitcherAnimation.restart();
7 camera.switchInProgress = false;
8+ zoomControl.value = camera.currentZoom;
9 }
10
11 function changeRecordMode() {
12 if (camera.captureMode == Camera.CaptureVideo) camera.videoRecorder.stop()
13 camera.captureMode = (camera.captureMode == Camera.CaptureVideo) ? Camera.CaptureStillImage : Camera.CaptureVideo
14+ zoomControl.value = camera.currentZoom
15+ }
16+
17+ Connections {
18+ target: Qt.application
19+ onActiveChanged: if (active) zoomControl.value = camera.currentZoom
20 }
21
22 Timer {
23 id: shootingTimer
24 repeat: true
25 triggeredOnStart: true
26-
27+
28 property int remainingSecs: 0
29
30 onTriggered: {
31
32=== modified file 'tests/autopilot/camera_app/emulators/main_window.py'
33--- tests/autopilot/camera_app/emulators/main_window.py 2015-11-20 15:01:02 +0000
34+++ tests/autopilot/camera_app/emulators/main_window.py 2015-11-24 17:48:24 +0000
35@@ -7,7 +7,7 @@
36
37 from camera_app.emulators.panel import Panel
38 from autopilot.matchers import Eventually
39-from testtools.matchers import Equals
40+from testtools.matchers import Equals, NotEquals
41
42
43 class MainWindow(object):
44@@ -163,3 +163,22 @@
45 tx, ty, (tx + view_switcher.width // 2), ty, rate=1)
46 viewfinder = self.get_viewfinder()
47 testCase.assertThat(viewfinder.inView, Eventually(Equals(True)))
48+
49+ def switch_cameras(self):
50+ # Swap cameras and wait for camera to settle
51+ shoot_button = self.get_exposure_button()
52+ swap_camera_button = self.get_swap_camera_button()
53+ self.app.pointing_device.move_to_object(swap_camera_button)
54+ self.app.pointing_device.click()
55+ shoot_button.enabled.wait_for(True)
56+
57+ def switch_recording_mode(self):
58+ record_control = self.get_record_control()
59+
60+ # Wait for the camera overlay to be loaded
61+ record_control.enabled.wait_for(True)
62+ record_control.width.wait_for(NotEquals(0))
63+ record_control.height.wait_for(NotEquals(0))
64+
65+ self.app.pointing_device.move_to_object(record_control)
66+ self.app.pointing_device.click()
67
68=== modified file 'tests/autopilot/camera_app/tests/test_capture.py'
69--- tests/autopilot/camera_app/tests/test_capture.py 2015-10-05 13:14:12 +0000
70+++ tests/autopilot/camera_app/tests/test_capture.py 2015-11-24 17:48:24 +0000
71@@ -90,13 +90,11 @@
72
73 """
74 # Get all the elements
75- record_control = self.main_window.get_record_control()
76 stop_watch = self.main_window.get_stop_watch()
77 exposure_button = self.main_window.get_exposure_button()
78
79 # Click the record button to toggle photo/video mode
80- self.pointing_device.move_to_object(record_control)
81- self.pointing_device.click()
82+ self.main_window.switch_recording_mode()
83
84 # Before recording the stop watch should read zero recording time
85 # and not be visible anyway.
86@@ -137,8 +135,7 @@
87 # Now stop the video and go back to picture mode and check if
88 # everything resets itself to previous states
89 self.pointing_device.click()
90- self.pointing_device.move_to_object(record_control)
91- self.pointing_device.click()
92+ self.main_window.switch_recording_mode()
93
94 self.assertThat(stop_watch.opacity, Eventually(Equals(0.0)))
95
96@@ -268,7 +265,7 @@
97 """Test recording videos at a set resolution and switching cameras"""
98 def test_video_resolution_setting_switching_cameras(self):
99 # switch to video recording and empty video folder
100- self.switch_to_video_recording()
101+ self.main_window.switch_recording_mode()
102 self.delete_all_videos()
103
104 # select the first resolution for the current camera
105@@ -277,14 +274,14 @@
106 self.set_video_resolution(initial_resolution)
107
108 # switch cameras and select the last resolution for the current camera
109- self.switch_cameras()
110+ self.main_window.switch_cameras()
111 resolutions = self.get_available_video_resolutions()
112 expected_resolution = resolutions[-1]
113 self.assertThat(expected_resolution, NotEquals(initial_resolution))
114 self.set_video_resolution(expected_resolution)
115
116 # switch back to the initial camera and record a video
117- self.switch_cameras()
118+ self.main_window.switch_cameras()
119 self.record_video(2)
120 video_file = self.get_first_video()
121 height = self.read_video_height(video_file)
122@@ -292,17 +289,9 @@
123 expected_resolution)
124 self.assertThat(height, Equals(expected_height))
125
126- def switch_cameras(self):
127- # Swap cameras and wait for camera to settle
128- shoot_button = self.main_window.get_exposure_button()
129- swap_camera_button = self.main_window.get_swap_camera_button()
130- self.pointing_device.move_to_object(swap_camera_button)
131- self.pointing_device.click()
132- self.assertThat(shoot_button.enabled, Eventually(Equals(True)))
133-
134 """Test recording videos at various resolutions"""
135 def test_video_resolution_setting(self):
136- self.switch_to_video_recording()
137+ self.main_window.switch_recording_mode()
138 resolutions = self.get_available_video_resolutions()
139
140 for resolution_label in resolutions:
141@@ -316,16 +305,6 @@
142 self.assertThat(height, Equals(expected_height))
143 self.dismiss_first_photo_hint()
144
145- def switch_to_video_recording(self):
146- record_control = self.main_window.get_record_control()
147- # Wait for the camera overlay to be loaded
148- self.assertThat(record_control.enabled, Eventually(Equals(True)))
149- self.assertThat(record_control.width, Eventually(NotEquals(0)))
150- self.assertThat(record_control.height, Eventually(NotEquals(0)))
151-
152- self.pointing_device.move_to_object(record_control)
153- self.pointing_device.click()
154-
155 def get_available_video_resolutions(self):
156 # open bottom edge
157 bottom_edge = self.main_window.get_bottom_edge()
158
159=== modified file 'tests/autopilot/camera_app/tests/test_zoom.py'
160--- tests/autopilot/camera_app/tests/test_zoom.py 2015-04-29 15:56:44 +0000
161+++ tests/autopilot/camera_app/tests/test_zoom.py 2015-11-24 17:48:24 +0000
162@@ -68,3 +68,50 @@
163
164 self.pointing_device.drag(tx, ty, (tx - zoom_control.width), ty)
165 self.assertThat(zoom_control.value, Eventually(Equals(1.0)))
166+
167+ """Tests zoom is reset to minimum on camera switch"""
168+ def test_zoom_reset_on_camera_change(self):
169+ zoom_control = self.main_window.get_zoom_control()
170+ zoom_slider = self.main_window.get_zoom_slider()
171+
172+ self.activate_zoom()
173+ x, y, w, h = zoom_slider.globalRect
174+ tx = x + (w // 2)
175+ ty = y + (h // 2)
176+ self.pointing_device.drag(tx, ty, (tx + zoom_control.width), ty)
177+ self.assertThat(
178+ zoom_control.value, Eventually(Equals(zoom_control.maximumValue)))
179+
180+ self.main_window.switch_cameras()
181+ self.assertThat(
182+ zoom_control.value, Eventually(Equals(zoom_control.minimumValue)))
183+
184+ self.activate_zoom()
185+ self.pointing_device.drag(tx, ty, (tx + zoom_control.width), ty)
186+ self.assertThat(
187+ zoom_control.value, Eventually(Equals(zoom_control.maximumValue)))
188+
189+ self.main_window.switch_cameras()
190+ self.assertThat(
191+ zoom_control.value, Eventually(Equals(zoom_control.minimumValue)))
192+
193+ """Tests zoom is reset to minimum on recording mode switch"""
194+ def test_zoom_reset_on_recording_mode_change(self):
195+ zoom_control = self.main_window.get_zoom_control()
196+ zoom_slider = self.main_window.get_zoom_slider()
197+
198+ self.activate_zoom()
199+ x, y, w, h = zoom_slider.globalRect
200+ tx = x + (w // 2)
201+ ty = y + (h // 2)
202+ self.pointing_device.drag(tx, ty, (tx + zoom_control.width), ty)
203+ self.assertThat(
204+ zoom_control.value, Eventually(Equals(zoom_control.maximumValue)))
205+
206+ self.main_window.switch_recording_mode()
207+ self.assertThat(
208+ zoom_control.value, Eventually(Equals(zoom_control.minimumValue)))
209+
210+ # Ideally we should test the same thing when switching back to photo
211+ # mode, however due to http://pad.lv/1191088 zooming when recording
212+ # video is disabled, so adding that test is pointless until fixed.

Subscribers

People subscribed via source and target branches