25 #include "unittest_cxesettingsimp.h" |
25 #include "unittest_cxesettingsimp.h" |
26 #include "cxecenrepkeys.h" |
26 #include "cxecenrepkeys.h" |
27 |
27 |
28 const char* FAIL_TEST_SETTING = "Fail test"; |
28 const char* FAIL_TEST_SETTING = "Fail test"; |
29 const char* EMPTY_STRING = ""; |
29 const char* EMPTY_STRING = ""; |
30 const int CAMERA_MODE_STILL = 0; |
|
31 const int CAMERA_MODE_VIDEO = 1; |
|
32 //Default EV compensation value for auto still and auto video scene mode |
30 //Default EV compensation value for auto still and auto video scene mode |
33 const int SCENE_AUTO_EV_VALUE = 0; |
31 const int SCENE_AUTO_EV_VALUE = 0; |
34 const int SIGNAL_TIMEOUT = 3000; //milliseconds |
32 const int SIGNAL_TIMEOUT = 3000; //milliseconds |
35 |
33 |
36 UnitTestCxeSettingsImp::UnitTestCxeSettingsImp() : |
34 UnitTestCxeSettingsImp::UnitTestCxeSettingsImp() |
37 mSettingsImp(NULL), mSettingsStore(NULL) |
35 : mSettingsStore(NULL), |
|
36 mSettingsImp(NULL) |
38 { |
37 { |
39 qRegisterMetaType<CxeScene>("CxeScene"); |
38 qRegisterMetaType<CxeScene>("CxeScene"); |
40 qRegisterMetaType<CxeError::Id>("CxeError::Id"); |
39 qRegisterMetaType<CxeError::Id>("CxeError::Id"); |
41 qRegisterMetaType<Cxe::CameraMode>("Cxe::CameraMode"); |
40 qRegisterMetaType<Cxe::CameraMode>("Cxe::CameraMode"); |
42 } |
41 } |
128 * defined in cxesettings.h as template |
127 * defined in cxesettings.h as template |
129 */ |
128 */ |
130 void UnitTestCxeSettingsImp::testGet() |
129 void UnitTestCxeSettingsImp::testGet() |
131 { |
130 { |
132 CX_DEBUG_ENTER_FUNCTION(); |
131 CX_DEBUG_ENTER_FUNCTION(); |
133 CxeError::Id err = CxeError::None; |
|
134 |
132 |
135 // The idea of this test case is to test as much of different type of settings |
133 // The idea of this test case is to test as much of different type of settings |
136 // as possible |
134 // as possible |
137 |
135 |
138 // Testing reading brightness setting value |
136 // Testing reading brightness setting value |
144 } |
142 } |
145 catch (CxeException exception) { |
143 catch (CxeException exception) { |
146 QString message = "Exception thrown, error id = "; |
144 QString message = "Exception thrown, error id = "; |
147 message.append(exception.error()); |
145 message.append(exception.error()); |
148 QFAIL(message.toAscii()); |
146 QFAIL(message.toAscii()); |
149 return; |
|
150 } |
147 } |
151 |
148 |
152 mSettingsStore->get(CxeSettingIds::BRIGHTNESS, testValue); |
149 mSettingsStore->get(CxeSettingIds::BRIGHTNESS, testValue); |
153 QCOMPARE(brightnessValue, testValue.toInt()); |
150 QCOMPARE(brightnessValue, testValue.toInt()); |
154 |
151 |
159 } |
156 } |
160 catch (CxeException exception) { |
157 catch (CxeException exception) { |
161 QString message = "Exception thrown, error id = "; |
158 QString message = "Exception thrown, error id = "; |
162 message.append(exception.error()); |
159 message.append(exception.error()); |
163 QFAIL(message.toAscii()); |
160 QFAIL(message.toAscii()); |
164 return; |
|
165 } |
161 } |
166 |
162 |
167 QVariant colorTone2; |
163 QVariant colorTone2; |
168 mSettingsStore->get(CxeSettingIds::COLOR_TONE, colorTone2); |
164 mSettingsStore->get(CxeSettingIds::COLOR_TONE, colorTone2); |
169 QVERIFY(colorTone2 == colorTone); |
165 QVERIFY(colorTone2 == colorTone); |
175 } |
171 } |
176 catch (CxeException exception) { |
172 catch (CxeException exception) { |
177 QString message = "Exception thrown, error id = "; |
173 QString message = "Exception thrown, error id = "; |
178 message.append(exception.error()); |
174 message.append(exception.error()); |
179 QFAIL(message.toAscii()); |
175 QFAIL(message.toAscii()); |
180 return; |
|
181 } |
176 } |
182 |
177 |
183 mSettingsStore->get(CxeSettingIds::CONTRAST, testValue); |
178 mSettingsStore->get(CxeSettingIds::CONTRAST, testValue); |
184 QCOMPARE(testValue.toInt(), contrastValue); |
179 QCOMPARE(testValue.toInt(), contrastValue); |
185 |
180 |
190 } |
185 } |
191 catch (CxeException exception) { |
186 catch (CxeException exception) { |
192 QString message = "Exception thrown, error id = "; |
187 QString message = "Exception thrown, error id = "; |
193 message.append(exception.error()); |
188 message.append(exception.error()); |
194 QFAIL(message.toAscii()); |
189 QFAIL(message.toAscii()); |
195 return; |
|
196 } |
190 } |
197 |
191 |
198 mSettingsStore->get(CxeSettingIds::FNAME_FOLDER_SUFFIX, testValue); |
192 mSettingsStore->get(CxeSettingIds::FNAME_FOLDER_SUFFIX, testValue); |
199 QCOMPARE(testValue.toString(), fnameValue); |
193 QCOMPARE(testValue.toString(), fnameValue); |
200 |
194 |
209 } |
203 } |
210 catch (CxeException exception) { |
204 catch (CxeException exception) { |
211 QString message = "Exception thrown, error id = "; |
205 QString message = "Exception thrown, error id = "; |
212 message.append(exception.error()); |
206 message.append(exception.error()); |
213 QFAIL(message.toAscii()); |
207 QFAIL(message.toAscii()); |
214 return; |
|
215 } |
208 } |
216 |
209 |
217 QCOMPARE(sceneData[CxeSettingIds::EV_COMPENSATION_VALUE].toInt(), SCENE_AUTO_EV_VALUE); |
210 QCOMPARE(sceneData[CxeSettingIds::EV_COMPENSATION_VALUE].toInt(), SCENE_AUTO_EV_VALUE); |
218 |
211 |
219 // Now let's try same with video scene |
212 // Now let's try same with video scene |
224 } |
217 } |
225 catch (CxeException exception) { |
218 catch (CxeException exception) { |
226 QString message = "Exception thrown, error id = "; |
219 QString message = "Exception thrown, error id = "; |
227 message.append(exception.error()); |
220 message.append(exception.error()); |
228 QFAIL(message.toAscii()); |
221 QFAIL(message.toAscii()); |
229 return; |
|
230 } |
222 } |
231 |
223 |
232 QCOMPARE(sceneData[CxeSettingIds::EV_COMPENSATION_VALUE].toInt(), SCENE_AUTO_EV_VALUE); |
224 QCOMPARE(sceneData[CxeSettingIds::EV_COMPENSATION_VALUE].toInt(), SCENE_AUTO_EV_VALUE); |
233 |
225 |
234 CX_DEBUG_EXIT_FUNCTION(); |
226 CX_DEBUG_EXIT_FUNCTION(); |
330 } |
322 } |
331 catch (CxeException exception) { |
323 catch (CxeException exception) { |
332 QString message = "Exception thrown, error id = "; |
324 QString message = "Exception thrown, error id = "; |
333 message.append(exception.error()); |
325 message.append(exception.error()); |
334 QFAIL(message.toAscii()); |
326 QFAIL(message.toAscii()); |
335 return; |
|
336 } |
327 } |
337 mSettingsStore->get(CxeSettingIds::COLOR_TONE, value); |
328 mSettingsStore->get(CxeSettingIds::COLOR_TONE, value); |
338 QCOMPARE(value.toInt(), (int)Cxe::ColortoneBlackAndWhite); |
329 QCOMPARE(value.toInt(), (int)Cxe::ColortoneBlackAndWhite); |
339 |
330 |
340 // Testing set<QString>() version |
331 // Testing set<QString>() version |
344 } |
335 } |
345 catch (CxeException exception) { |
336 catch (CxeException exception) { |
346 QString message = "Exception thrown, error id = "; |
337 QString message = "Exception thrown, error id = "; |
347 message.append(exception.error()); |
338 message.append(exception.error()); |
348 QFAIL(message.toAscii()); |
339 QFAIL(message.toAscii()); |
349 return; |
|
350 } |
340 } |
351 mSettingsStore->get(CxeSettingIds::FNAME_FOLDER_SUFFIX, value); |
341 mSettingsStore->get(CxeSettingIds::FNAME_FOLDER_SUFFIX, value); |
352 QCOMPARE(value.toString(), stringValue); |
342 QCOMPARE(value.toString(), stringValue); |
353 |
343 |
354 // Testing set<bool>() version |
344 // Testing set<bool>() version |
358 } |
348 } |
359 catch (CxeException exception) { |
349 catch (CxeException exception) { |
360 QString message = "Exception thrown, error id = "; |
350 QString message = "Exception thrown, error id = "; |
361 message.append(exception.error()); |
351 message.append(exception.error()); |
362 QFAIL(message.toAscii()); |
352 QFAIL(message.toAscii()); |
363 return; |
|
364 } |
353 } |
365 mSettingsStore->get(CxeSettingIds::STILL_SHOWCAPTURED, value); |
354 mSettingsStore->get(CxeSettingIds::STILL_SHOWCAPTURED, value); |
366 QCOMPARE(value.toBool(), boolValue); |
355 QCOMPARE(value.toBool(), boolValue); |
367 |
356 |
368 // Testing set<qreal>() version |
357 // Testing set<qreal>() version |
372 } |
361 } |
373 catch (CxeException exception) { |
362 catch (CxeException exception) { |
374 QString message = "Exception thrown, error id = "; |
363 QString message = "Exception thrown, error id = "; |
375 message.append(exception.error()); |
364 message.append(exception.error()); |
376 QFAIL(message.toAscii()); |
365 QFAIL(message.toAscii()); |
377 return; |
|
378 } |
366 } |
379 mSettingsStore->get(CxeSettingIds::EV_COMPENSATION_VALUE, value); |
367 mSettingsStore->get(CxeSettingIds::EV_COMPENSATION_VALUE, value); |
380 QCOMPARE(value.toReal(), qrealValue); |
368 QCOMPARE(value.toReal(), qrealValue); |
381 |
369 |
382 // Testing set<QVariantMap>() version |
370 // Testing set<QVariantMap>() version |