Merge lp:~fboucault/qtubuntu-camera/hdr_scene_mode into lp:qtubuntu-camera
- hdr_scene_mode
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Jim Hodapp |
Approved revision: | 104 |
Merged at revision: | 96 |
Proposed branch: | lp:~fboucault/qtubuntu-camera/hdr_scene_mode |
Merge into: | lp:qtubuntu-camera |
Diff against target: |
585 lines (+413/-4) 12 files modified
src/aalcameraexposurecontrol.cpp (+141/-0) src/aalcameraexposurecontrol.h (+52/-0) src/aalcameraservice.cpp (+7/-0) src/aalcameraservice.h (+3/-0) src/src.pro (+2/-0) unittests/aalcameraexposurecontrol/aalcameraexposurecontrol.pro (+20/-0) unittests/aalcameraexposurecontrol/aalcameraservice.cpp (+76/-0) unittests/aalcameraexposurecontrol/tst_aalcameraexposurecontrol.cpp (+96/-0) unittests/mocks/aal/camera_compatibility_layer.cpp (+10/-2) unittests/mocks/aal/camera_compatibility_layer_capabilities.h (+4/-1) unittests/mocks/aal/media_recorder_layer.cpp (+1/-1) unittests/unittests.pro (+1/-0) |
To merge this branch: | bzr merge lp:~fboucault/qtubuntu-camera/hdr_scene_mode |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jim Hodapp (community) | code | Approve | |
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+225993@code.launchpad.net |
Commit message
Expose scene modes through a custom QCameraExposure
Description of the change
Florian Boucault (fboucault) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:94
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:95
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:96
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:97
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Florian Boucault (fboucault) wrote : | # |
Good to go apart from that we need to define a better enum value for HDR than QCameraExposure
Build will be green when relevant libhybris patch lands.
Florian Boucault (fboucault) wrote : | # |
Patch in libhybris is at: https:/
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:98
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:99
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:100
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Jim Hodapp (jhodapp) wrote : | # |
The main code looks great, I'd like to see some tests for the logic of setting the exposure mode and making sure the appropriate signals are emitted when expected.
Jim Hodapp (jhodapp) wrote : | # |
By tests, I mean unit tests
- 102. By Florian Boucault
-
Empty commit
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:102
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 103. By Florian Boucault
-
Fix unit test.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:103
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 104. By Florian Boucault
-
Properly fixed unit tests.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:104
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Jim Hodapp (jhodapp) wrote : | # |
Looks great, thanks
Preview Diff
1 | === added file 'src/aalcameraexposurecontrol.cpp' |
2 | --- src/aalcameraexposurecontrol.cpp 1970-01-01 00:00:00 +0000 |
3 | +++ src/aalcameraexposurecontrol.cpp 2014-07-15 12:39:22 +0000 |
4 | @@ -0,0 +1,141 @@ |
5 | +/* |
6 | + * Copyright (C) 2014 Canonical, Ltd. |
7 | + * |
8 | + * This program is free software; you can redistribute it and/or modify |
9 | + * it under the terms of the GNU Lesser General Public License as published by |
10 | + * the Free Software Foundation; version 3. |
11 | + * |
12 | + * This program is distributed in the hope that it will be useful, |
13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | + * GNU Lesser General Public License for more details. |
16 | + * |
17 | + * You should have received a copy of the GNU Lesser General Public License |
18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | + */ |
20 | + |
21 | +#include "aalcameraexposurecontrol.h" |
22 | +#include "aalcameracontrol.h" |
23 | +#include "aalcameraservice.h" |
24 | + |
25 | +#include <hybris/camera/camera_compatibility_layer.h> |
26 | +#include <hybris/camera/camera_compatibility_layer_capabilities.h> |
27 | + |
28 | +// Definition of this enum value is duplicated in camera-app |
29 | +static const QCameraExposure::ExposureMode ExposureHdr = static_cast<QCameraExposure::ExposureMode>(QCameraExposure::ExposureModeVendor + 1); |
30 | + |
31 | +AalCameraExposureControl::AalCameraExposureControl(AalCameraService *service, QObject *parent) |
32 | + : QCameraExposureControl(parent), |
33 | + m_service(service), |
34 | + m_requestedExposureMode(QCameraExposure::ExposureAuto), |
35 | + m_actualExposureMode(QCameraExposure::ExposureAuto) |
36 | +{ |
37 | + m_androidToQtExposureModes[SCENE_MODE_AUTO] = QCameraExposure::ExposureAuto; |
38 | + m_androidToQtExposureModes[SCENE_MODE_ACTION] = QCameraExposure::ExposureSports; |
39 | + m_androidToQtExposureModes[SCENE_MODE_NIGHT] = QCameraExposure::ExposureNight; |
40 | + m_androidToQtExposureModes[SCENE_MODE_PARTY] = QCameraExposure::ExposureAuto; // FIXME: no correspondance |
41 | + m_androidToQtExposureModes[SCENE_MODE_SUNSET] = QCameraExposure::ExposureAuto; // FIXME: no correspondance |
42 | + m_androidToQtExposureModes[SCENE_MODE_HDR] = ExposureHdr; |
43 | +} |
44 | + |
45 | +void AalCameraExposureControl::init(CameraControl *control, CameraControlListener *listener) |
46 | +{ |
47 | + Q_UNUSED(listener); |
48 | + |
49 | + m_requestedExposureMode = QCameraExposure::ExposureAuto; |
50 | + m_actualExposureMode = QCameraExposure::ExposureAuto; |
51 | + |
52 | + m_supportedExposureModes.clear(); |
53 | + android_camera_enumerate_supported_scene_modes(control, &AalCameraExposureControl::supportedSceneModesCallback, this); |
54 | + |
55 | + Q_EMIT requestedValueChanged(QCameraExposureControl::ExposureMode); |
56 | + Q_EMIT actualValueChanged(QCameraExposureControl::ExposureMode); |
57 | + Q_EMIT parameterRangeChanged(QCameraExposureControl::ExposureMode); |
58 | +} |
59 | + |
60 | +void AalCameraExposureControl::supportedSceneModesCallback(void *context, SceneMode sceneMode) |
61 | +{ |
62 | + AalCameraExposureControl *self = (AalCameraExposureControl*)context; |
63 | + self->m_supportedExposureModes << QVariant::fromValue(self->m_androidToQtExposureModes[sceneMode]); |
64 | +} |
65 | + |
66 | +bool AalCameraExposureControl::setValue(ExposureParameter parameter, const QVariant& value) |
67 | +{ |
68 | + if (!value.isValid()) { |
69 | + return false; |
70 | + } |
71 | + |
72 | + if (parameter == QCameraExposureControl::ExposureMode) { |
73 | + m_requestedExposureMode = value.value<QCameraExposure::ExposureMode>(); |
74 | + Q_EMIT requestedValueChanged(QCameraExposureControl::ExposureMode); |
75 | + |
76 | + if (m_supportedExposureModes.contains(value)) { |
77 | + SceneMode sceneMode = m_androidToQtExposureModes.key(m_requestedExposureMode); |
78 | + android_camera_set_scene_mode(m_service->androidControl(), sceneMode); |
79 | + m_actualExposureMode = m_requestedExposureMode; |
80 | + Q_EMIT actualValueChanged(QCameraExposureControl::ExposureMode); |
81 | + return true; |
82 | + } |
83 | + } |
84 | + |
85 | + return false; |
86 | +} |
87 | + |
88 | +QVariant AalCameraExposureControl::requestedValue(ExposureParameter parameter) const |
89 | +{ |
90 | + if (parameter == QCameraExposureControl::ExposureMode) { |
91 | + return QVariant::fromValue(m_requestedExposureMode); |
92 | + } |
93 | + |
94 | + return QVariant(); |
95 | +} |
96 | + |
97 | +QVariant AalCameraExposureControl::actualValue(ExposureParameter parameter) const |
98 | +{ |
99 | + if (parameter == QCameraExposureControl::ExposureMode) { |
100 | + return QVariant::fromValue(m_actualExposureMode); |
101 | + } |
102 | + |
103 | + return QVariant(); |
104 | +} |
105 | + |
106 | +bool AalCameraExposureControl::isParameterSupported(ExposureParameter parameter) const |
107 | +{ |
108 | + switch (parameter) { |
109 | + case QCameraExposureControl::ISO: |
110 | + return false; |
111 | + case QCameraExposureControl::Aperture: |
112 | + return false; |
113 | + case QCameraExposureControl::ShutterSpeed: |
114 | + return false; |
115 | + case QCameraExposureControl::ExposureCompensation: |
116 | + return false; |
117 | + case QCameraExposureControl::FlashPower: |
118 | + return false; |
119 | + case QCameraExposureControl::FlashCompensation: |
120 | + return false; |
121 | + case QCameraExposureControl::TorchPower: |
122 | + return false; |
123 | + case QCameraExposureControl::SpotMeteringPoint: |
124 | + return false; |
125 | + case QCameraExposureControl::ExposureMode: |
126 | + return true; |
127 | + case QCameraExposureControl::MeteringMode: |
128 | + return false; |
129 | + default: |
130 | + return false; |
131 | + } |
132 | +} |
133 | + |
134 | +QVariantList AalCameraExposureControl::supportedParameterRange(ExposureParameter parameter, bool *continuous) const |
135 | +{ |
136 | + if (continuous != NULL) { |
137 | + *continuous = false; |
138 | + } |
139 | + |
140 | + if (parameter == QCameraExposureControl::ExposureMode) { |
141 | + return m_supportedExposureModes; |
142 | + } |
143 | + |
144 | + return QVariantList(); |
145 | +} |
146 | |
147 | === added file 'src/aalcameraexposurecontrol.h' |
148 | --- src/aalcameraexposurecontrol.h 1970-01-01 00:00:00 +0000 |
149 | +++ src/aalcameraexposurecontrol.h 2014-07-15 12:39:22 +0000 |
150 | @@ -0,0 +1,52 @@ |
151 | +/* |
152 | + * Copyright (C) 2014 Canonical, Ltd. |
153 | + * |
154 | + * This program is free software; you can redistribute it and/or modify |
155 | + * it under the terms of the GNU Lesser General Public License as published by |
156 | + * the Free Software Foundation; version 3. |
157 | + * |
158 | + * This program is distributed in the hope that it will be useful, |
159 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
160 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
161 | + * GNU Lesser General Public License for more details. |
162 | + * |
163 | + * You should have received a copy of the GNU Lesser General Public License |
164 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
165 | + */ |
166 | + |
167 | +#ifndef AALCAMERAEXPOSURECONTROL_H |
168 | +#define AALCAMERAEXPOSURECONTROL_H |
169 | + |
170 | +#include <QtCore/QMap> |
171 | +#include <QCameraExposureControl> |
172 | + |
173 | +#include <hybris/camera/camera_compatibility_layer_capabilities.h> |
174 | + |
175 | +class AalCameraService; |
176 | +class CameraControl; |
177 | +class CameraControlListener; |
178 | + |
179 | +class AalCameraExposureControl : public QCameraExposureControl |
180 | +{ |
181 | + Q_OBJECT |
182 | +public: |
183 | + explicit AalCameraExposureControl(AalCameraService *service, QObject *parent = 0); |
184 | + |
185 | + void init(CameraControl *control, CameraControlListener *listener); |
186 | + bool setValue(ExposureParameter parameter, const QVariant& value); |
187 | + QVariant requestedValue(ExposureParameter parameter) const; |
188 | + QVariant actualValue(ExposureParameter parameter) const; |
189 | + bool isParameterSupported(ExposureParameter parameter) const; |
190 | + QVariantList supportedParameterRange(ExposureParameter parameter, bool *continuous) const; |
191 | + |
192 | + static void supportedSceneModesCallback(void *context, SceneMode sceneMode); |
193 | + |
194 | +private: |
195 | + QMap<SceneMode, QCameraExposure::ExposureMode> m_androidToQtExposureModes; |
196 | + AalCameraService *m_service; |
197 | + QVariantList m_supportedExposureModes; |
198 | + QCameraExposure::ExposureMode m_requestedExposureMode; |
199 | + QCameraExposure::ExposureMode m_actualExposureMode; |
200 | +}; |
201 | + |
202 | +#endif // AALCAMERAEXPOSURECONTROL_H |
203 | |
204 | === modified file 'src/aalcameraservice.cpp' |
205 | --- src/aalcameraservice.cpp 2013-08-01 10:41:04 +0000 |
206 | +++ src/aalcameraservice.cpp 2014-07-15 12:39:22 +0000 |
207 | @@ -27,6 +27,7 @@ |
208 | #include "aalvideoencodersettingscontrol.h" |
209 | #include "aalvideorenderercontrol.h" |
210 | #include "aalviewfindersettingscontrol.h" |
211 | +#include "aalcameraexposurecontrol.h" |
212 | #include <storagemanager.h> |
213 | |
214 | #include <hybris/camera/camera_compatibility_layer.h> |
215 | @@ -56,6 +57,7 @@ |
216 | m_videoEncoderControl = new AalVideoEncoderSettingsControl(this); |
217 | m_videoOutput = new AalVideoRendererControl(this); |
218 | m_viewfinderControl = new AalViewfinderSettingsControl(this); |
219 | + m_exposureControl = new AalCameraExposureControl(this); |
220 | } |
221 | |
222 | AalCameraService::~AalCameraService() |
223 | @@ -74,6 +76,7 @@ |
224 | delete m_videoEncoderControl; |
225 | delete m_videoOutput; |
226 | delete m_viewfinderControl; |
227 | + delete m_exposureControl; |
228 | if (m_oldAndroidControl) |
229 | android_camera_delete(m_oldAndroidControl); |
230 | if (m_androidControl) |
231 | @@ -119,6 +122,9 @@ |
232 | if (qstrcmp(name, QCameraViewfinderSettingsControl_iid) == 0) |
233 | return m_viewfinderControl; |
234 | |
235 | + if (qstrcmp(name, QCameraExposureControl_iid) == 0) |
236 | + return m_exposureControl; |
237 | + |
238 | return 0; |
239 | } |
240 | |
241 | @@ -285,4 +291,5 @@ |
242 | m_viewfinderControl->setAspectRatio(m_videoEncoderControl->getAspectRatio()); |
243 | m_viewfinderControl->init(camControl, listener); |
244 | m_videoOutput->init(camControl, listener); |
245 | + m_exposureControl->init(camControl, listener); |
246 | } |
247 | |
248 | === modified file 'src/aalcameraservice.h' |
249 | --- src/aalcameraservice.h 2013-08-01 10:41:04 +0000 |
250 | +++ src/aalcameraservice.h 2014-07-15 12:39:22 +0000 |
251 | @@ -31,6 +31,7 @@ |
252 | class AalVideoEncoderSettingsControl; |
253 | class AalVideoRendererControl; |
254 | class AalViewfinderSettingsControl; |
255 | +class AalCameraExposureControl; |
256 | class QCameraControl; |
257 | |
258 | struct CameraControl; |
259 | @@ -60,6 +61,7 @@ |
260 | AalVideoEncoderSettingsControl *videoEncoderControl() const { return m_videoEncoderControl; } |
261 | AalVideoRendererControl *videoOutputControl() const { return m_videoOutput; } |
262 | AalViewfinderSettingsControl *viewfinderControl() const { return m_viewfinderControl; } |
263 | + AalCameraExposureControl *exposureControl() const { return m_exposureControl; } |
264 | |
265 | CameraControl *androidControl(); |
266 | |
267 | @@ -99,6 +101,7 @@ |
268 | AalVideoEncoderSettingsControl *m_videoEncoderControl; |
269 | AalVideoRendererControl *m_videoOutput; |
270 | AalViewfinderSettingsControl *m_viewfinderControl; |
271 | + AalCameraExposureControl *m_exposureControl; |
272 | |
273 | CameraControl *m_androidControl; |
274 | CameraControlListener *m_androidListener; |
275 | |
276 | === modified file 'src/src.pro' |
277 | --- src/src.pro 2014-01-16 14:20:08 +0000 |
278 | +++ src/src.pro 2014-07-15 12:39:22 +0000 |
279 | @@ -33,6 +33,7 @@ |
280 | aalvideoencodersettingscontrol.h \ |
281 | aalvideorenderercontrol.h \ |
282 | aalviewfindersettingscontrol.h \ |
283 | + aalcameraexposurecontrol.h \ |
284 | storagemanager.h |
285 | |
286 | SOURCES += \ |
287 | @@ -50,4 +51,5 @@ |
288 | aalvideoencodersettingscontrol.cpp \ |
289 | aalvideorenderercontrol.cpp \ |
290 | aalviewfindersettingscontrol.cpp \ |
291 | + aalcameraexposurecontrol.cpp \ |
292 | storagemanager.cpp |
293 | |
294 | === added directory 'unittests/aalcameraexposurecontrol' |
295 | === added file 'unittests/aalcameraexposurecontrol/aalcameraexposurecontrol.pro' |
296 | --- unittests/aalcameraexposurecontrol/aalcameraexposurecontrol.pro 1970-01-01 00:00:00 +0000 |
297 | +++ unittests/aalcameraexposurecontrol/aalcameraexposurecontrol.pro 2014-07-15 12:39:22 +0000 |
298 | @@ -0,0 +1,20 @@ |
299 | +include(../../coverage.pri) |
300 | + |
301 | +TARGET = tst_aalcameraexposurecontrol |
302 | + |
303 | +QT += testlib multimedia opengl |
304 | + |
305 | +LIBS += -L../mocks/aal -laal |
306 | +INCLUDEPATH += ../../src |
307 | +INCLUDEPATH += ../mocks/aal |
308 | + |
309 | +HEADERS += ../../src/aalcameraexposurecontrol.h \ |
310 | + ../../src/aalcameraservice.h |
311 | + |
312 | +SOURCES += tst_aalcameraexposurecontrol.cpp \ |
313 | + ../../src/aalcameraexposurecontrol.cpp \ |
314 | + aalcameraservice.cpp |
315 | + |
316 | +check.depends = $${TARGET} |
317 | +check.commands = ./$${TARGET} |
318 | +QMAKE_EXTRA_TARGETS += check |
319 | |
320 | === added file 'unittests/aalcameraexposurecontrol/aalcameraservice.cpp' |
321 | --- unittests/aalcameraexposurecontrol/aalcameraservice.cpp 1970-01-01 00:00:00 +0000 |
322 | +++ unittests/aalcameraexposurecontrol/aalcameraservice.cpp 2014-07-15 12:39:22 +0000 |
323 | @@ -0,0 +1,76 @@ |
324 | +/* |
325 | + * Copyright (C) 2013 Canonical, Ltd. |
326 | + * |
327 | + * This program is free software; you can redistribute it and/or modify |
328 | + * it under the terms of the GNU Lesser General Public License as published by |
329 | + * the Free Software Foundation; version 3. |
330 | + * |
331 | + * This program is distributed in the hope that it will be useful, |
332 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
333 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
334 | + * GNU Lesser General Public License for more details. |
335 | + * |
336 | + * You should have received a copy of the GNU Lesser General Public License |
337 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
338 | + */ |
339 | + |
340 | +#include "aalcameraservice.h" |
341 | +#include "aalcameraexposurecontrol.h" |
342 | +#include "camera_control.h" |
343 | +#include "camera_compatibility_layer.h" |
344 | + |
345 | +AalCameraService *AalCameraService::m_service = 0; |
346 | + |
347 | +AalCameraService::AalCameraService(QObject *parent) : |
348 | + QMediaService(parent), |
349 | + m_androidControl(0), |
350 | + m_androidListener(0) |
351 | +{ |
352 | + m_exposureControl = new AalCameraExposureControl(this); |
353 | +} |
354 | + |
355 | +AalCameraService::~AalCameraService() |
356 | +{ |
357 | + delete m_exposureControl; |
358 | +} |
359 | + |
360 | +QMediaControl *AalCameraService::requestControl(const char *name) |
361 | +{ |
362 | + Q_UNUSED(name); |
363 | + return 0; |
364 | +} |
365 | + |
366 | +void AalCameraService::releaseControl(QMediaControl *control) |
367 | +{ |
368 | + Q_UNUSED(control); |
369 | +} |
370 | + |
371 | +CameraControl *AalCameraService::androidControl() |
372 | +{ |
373 | + return m_androidControl; |
374 | +} |
375 | + |
376 | +bool AalCameraService::connectCamera() |
377 | +{ |
378 | + m_androidListener = new CameraControlListener; |
379 | + m_androidControl = android_camera_connect_to(BACK_FACING_CAMERA_TYPE, m_androidListener); |
380 | + |
381 | + initControls(m_androidControl, m_androidListener); |
382 | + |
383 | + return true; |
384 | +} |
385 | + |
386 | +void AalCameraService::disconnectCamera() |
387 | +{ |
388 | + delete m_androidListener; |
389 | + android_camera_disconnect(m_androidControl); |
390 | +} |
391 | + |
392 | +void AalCameraService::initControls(CameraControl *camControl, CameraControlListener *listener) |
393 | +{ |
394 | + m_exposureControl->init(camControl, listener); |
395 | +} |
396 | + |
397 | +void AalCameraService::updateCaptureReady() |
398 | +{ |
399 | +} |
400 | |
401 | === added file 'unittests/aalcameraexposurecontrol/tst_aalcameraexposurecontrol.cpp' |
402 | --- unittests/aalcameraexposurecontrol/tst_aalcameraexposurecontrol.cpp 1970-01-01 00:00:00 +0000 |
403 | +++ unittests/aalcameraexposurecontrol/tst_aalcameraexposurecontrol.cpp 2014-07-15 12:39:22 +0000 |
404 | @@ -0,0 +1,96 @@ |
405 | +/* |
406 | + * Copyright (C) 2013 Canonical, Ltd. |
407 | + * |
408 | + * This program is free software; you can redistribute it and/or modify |
409 | + * it under the terms of the GNU Lesser General Public License as published by |
410 | + * the Free Software Foundation; version 3. |
411 | + * |
412 | + * This program is distributed in the hope that it will be useful, |
413 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
414 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
415 | + * GNU Lesser General Public License for more details. |
416 | + * |
417 | + * You should have received a copy of the GNU Lesser General Public License |
418 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
419 | + */ |
420 | + |
421 | +#include <QtTest/QtTest> |
422 | +#include <QSignalSpy> |
423 | + |
424 | +#include "aalcameraservice.h" |
425 | + |
426 | +#define private public |
427 | +#include "aalcameraexposurecontrol.h" |
428 | + |
429 | +class tst_AalCameraExposureControl : public QObject |
430 | +{ |
431 | + Q_OBJECT |
432 | +private slots: |
433 | + void initTestCase(); |
434 | + void cleanupTestCase(); |
435 | + |
436 | + void setUnsupportedParameter(); |
437 | + void setExposureMode(); |
438 | + |
439 | +private: |
440 | + AalCameraExposureControl *m_exposureControl; |
441 | + AalCameraService *m_service; |
442 | +}; |
443 | + |
444 | +void tst_AalCameraExposureControl::initTestCase() |
445 | +{ |
446 | + m_service = new AalCameraService(); |
447 | + m_exposureControl = m_service->exposureControl(); |
448 | + m_service->connectCamera(); |
449 | +} |
450 | + |
451 | +void tst_AalCameraExposureControl::cleanupTestCase() |
452 | +{ |
453 | + delete m_service; |
454 | +} |
455 | + |
456 | +void tst_AalCameraExposureControl::setUnsupportedParameter() |
457 | +{ |
458 | + QCameraExposureControl::ExposureParameter parameter = QCameraExposureControl::ISO; |
459 | + |
460 | + QSignalSpy spyActual(m_exposureControl, SIGNAL(actualValueChanged(int))); |
461 | + QSignalSpy spyRequested(m_exposureControl, SIGNAL(requestedValueChanged(int))); |
462 | + |
463 | + bool supported = m_exposureControl->isParameterSupported(parameter); |
464 | + bool valid = m_exposureControl->setValue(parameter, QVariant::fromValue(200)); |
465 | + QVariant requestedValue = m_exposureControl->requestedValue(parameter); |
466 | + QVariant actualValue = m_exposureControl->actualValue(parameter); |
467 | + |
468 | + QVERIFY(!supported); |
469 | + QVERIFY(!valid); |
470 | + QCOMPARE(requestedValue, QVariant()); |
471 | + QCOMPARE(actualValue, QVariant()); |
472 | + |
473 | + QCOMPARE(spyActual.count(), 0); |
474 | + QCOMPARE(spyRequested.count(), 0); |
475 | +} |
476 | + |
477 | +void tst_AalCameraExposureControl::setExposureMode() |
478 | +{ |
479 | + QCameraExposureControl::ExposureParameter parameter = QCameraExposureControl::ExposureMode; |
480 | + |
481 | + QSignalSpy spyActual(m_exposureControl, SIGNAL(actualValueChanged(int))); |
482 | + QSignalSpy spyRequested(m_exposureControl, SIGNAL(requestedValueChanged(int))); |
483 | + |
484 | + bool supported = m_exposureControl->isParameterSupported(parameter); |
485 | + bool valid = m_exposureControl->setValue(parameter, QVariant::fromValue(QCameraExposure::ExposureSports)); |
486 | + QVariant requestedValue = m_exposureControl->requestedValue(parameter); |
487 | + QVariant actualValue = m_exposureControl->actualValue(parameter); |
488 | + |
489 | + QVERIFY(supported); |
490 | + QVERIFY(valid); |
491 | + QCOMPARE(requestedValue, QVariant::fromValue(QCameraExposure::ExposureSports)); |
492 | + QCOMPARE(actualValue, QVariant::fromValue(QCameraExposure::ExposureSports)); |
493 | + |
494 | + QCOMPARE(spyActual.count(), 1); |
495 | + QCOMPARE(spyRequested.count(), 1); |
496 | +} |
497 | + |
498 | +QTEST_MAIN(tst_AalCameraExposureControl) |
499 | + |
500 | +#include "tst_aalcameraexposurecontrol.moc" |
501 | |
502 | === modified file 'unittests/mocks/aal/camera_compatibility_layer.cpp' |
503 | --- unittests/mocks/aal/camera_compatibility_layer.cpp 2013-06-07 08:54:10 +0000 |
504 | +++ unittests/mocks/aal/camera_compatibility_layer.cpp 2014-07-15 12:39:22 +0000 |
505 | @@ -16,8 +16,8 @@ |
506 | * Authored by: Thomas Voss <thomas.voss@canonical.com> |
507 | */ |
508 | |
509 | -#include <hybris/camera/camera_compatibility_layer.h> |
510 | -#include <hybris/camera/camera_compatibility_layer_capabilities.h> |
511 | +#include "camera_compatibility_layer.h" |
512 | +#include "camera_compatibility_layer_capabilities.h" |
513 | |
514 | #include "camera_control.h" |
515 | |
516 | @@ -95,6 +95,14 @@ |
517 | crashTest(control); |
518 | } |
519 | |
520 | +void android_camera_enumerate_supported_scene_modes(CameraControl* control, scene_mode_callback cb, void* ctx) |
521 | +{ |
522 | + Q_UNUSED(cb); |
523 | + Q_UNUSED(ctx); |
524 | + crashTest(control); |
525 | + cb(ctx, SCENE_MODE_ACTION); |
526 | +} |
527 | + |
528 | void android_camera_set_scene_mode(CameraControl* control, SceneMode mode) |
529 | { |
530 | Q_UNUSED(mode); |
531 | |
532 | === modified file 'unittests/mocks/aal/camera_compatibility_layer_capabilities.h' |
533 | --- unittests/mocks/aal/camera_compatibility_layer_capabilities.h 2013-02-11 15:56:21 +0000 |
534 | +++ unittests/mocks/aal/camera_compatibility_layer_capabilities.h 2014-07-15 12:39:22 +0000 |
535 | @@ -48,7 +48,8 @@ |
536 | SCENE_MODE_ACTION, |
537 | SCENE_MODE_NIGHT, |
538 | SCENE_MODE_PARTY, |
539 | - SCENE_MODE_SUNSET |
540 | + SCENE_MODE_SUNSET, |
541 | + SCENE_MODE_HDR |
542 | } SceneMode; |
543 | |
544 | typedef enum |
545 | @@ -95,6 +96,7 @@ |
546 | } FocusRegion; |
547 | |
548 | typedef void (*size_callback)(void* ctx, int width, int height); |
549 | +typedef void (*scene_mode_callback)(void* ctx, SceneMode mode); |
550 | |
551 | // Dumps the camera parameters to stdout. |
552 | void android_camera_dump_parameters(CameraControl* control); |
553 | @@ -115,6 +117,7 @@ |
554 | void android_camera_get_effect_mode(CameraControl* control, EffectMode* mode); |
555 | void android_camera_get_flash_mode(CameraControl* control, FlashMode* mode); |
556 | void android_camera_get_white_balance_mode(CameraControl* control, WhiteBalanceMode* mode); |
557 | +void android_camera_enumerate_supported_scene_modes(CameraControl* control, scene_mode_callback cb, void* ctx); |
558 | void android_camera_get_scene_mode(CameraControl* control, SceneMode* mode); |
559 | void android_camera_get_auto_focus_mode(CameraControl* control, AutoFocusMode* mode); |
560 | void android_camera_get_preview_format(CameraControl* control, CameraPixelFormat* format); |
561 | |
562 | === modified file 'unittests/mocks/aal/media_recorder_layer.cpp' |
563 | --- unittests/mocks/aal/media_recorder_layer.cpp 2014-06-19 20:54:56 +0000 |
564 | +++ unittests/mocks/aal/media_recorder_layer.cpp 2014-07-15 12:39:22 +0000 |
565 | @@ -15,7 +15,7 @@ |
566 | * |
567 | */ |
568 | |
569 | -#include <hybris/media/media_recorder_layer.h> |
570 | +#include "media_recorder_layer.h" |
571 | #include "camera_control.h" |
572 | |
573 | #include <qglobal.h> |
574 | |
575 | === modified file 'unittests/unittests.pro' |
576 | --- unittests/unittests.pro 2013-05-24 11:25:15 +0000 |
577 | +++ unittests/unittests.pro 2014-07-15 12:39:22 +0000 |
578 | @@ -3,6 +3,7 @@ |
579 | SUBDIRS += \ |
580 | mocks \ |
581 | aalcameracontrol \ |
582 | + aalcameraexposurecontrol \ |
583 | aalcameraflashcontrol \ |
584 | aalcamerafocuscontrol \ |
585 | aalcamerazoomcontrol \ |
MR not ready for review.