1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #include <QTest> |
|
18 #include <ecam.h> |
|
19 #include <ecamadvsettingsuids.hrh> |
|
20 #include <ecamadvsettings.h> |
|
21 #include <ECamOrientationCustomInterface2.h> |
|
22 |
|
23 #include "cxenamespace.h" |
|
24 #include "cxesettingsmappersymbian.h" |
|
25 #include "cxequalitydetails.h" |
|
26 #include "unittest_cxesettingsmappersymbian.h" |
|
27 |
|
28 |
|
29 // Enums |
|
30 |
|
31 |
|
32 UnitTestCxeSettingsMapperSymbian::UnitTestCxeSettingsMapperSymbian() |
|
33 { |
|
34 } |
|
35 |
|
36 UnitTestCxeSettingsMapperSymbian::~UnitTestCxeSettingsMapperSymbian() |
|
37 { |
|
38 } |
|
39 |
|
40 // Run before each individual test case |
|
41 void UnitTestCxeSettingsMapperSymbian::init() |
|
42 { |
|
43 } |
|
44 |
|
45 // Run after each individual test case |
|
46 void UnitTestCxeSettingsMapperSymbian::cleanup() |
|
47 { |
|
48 } |
|
49 |
|
50 void UnitTestCxeSettingsMapperSymbian::testMap2CameraAutofocus() |
|
51 { |
|
52 CCamera::CCameraAdvancedSettings::TFocusRange result; |
|
53 CxeAutoFocusControl::Mode initialData = CxeAutoFocusControl::Auto; |
|
54 |
|
55 // case 0: check with autofocus auto value |
|
56 result = CxeSettingsMapperSymbian::Map2CameraAutofocus(initialData); |
|
57 QVERIFY(result == CCamera::CCameraAdvancedSettings::EFocusRangeAuto); |
|
58 |
|
59 // case 1: try with valid ui autofocus value |
|
60 initialData = CxeAutoFocusControl::Hyperfocal; |
|
61 result = CxeSettingsMapperSymbian::Map2CameraAutofocus(initialData); |
|
62 QVERIFY(result == CCamera::CCameraAdvancedSettings::EFocusRangeHyperfocal); |
|
63 |
|
64 } |
|
65 |
|
66 void UnitTestCxeSettingsMapperSymbian::testMap2CameraEffect() |
|
67 { |
|
68 CCamera::CCameraImageProcessing::TEffect result; |
|
69 Cxe::Colortone initialData = static_cast<Cxe::Colortone>(99999); |
|
70 |
|
71 // case 0: check with unknown value |
|
72 result = CxeSettingsMapperSymbian::Map2CameraEffect(initialData); |
|
73 QVERIFY(result == CCamera::CCameraImageProcessing::EEffectNone); |
|
74 |
|
75 // case 1: try with valid ui color tone value |
|
76 initialData = Cxe::ColortoneSepia; |
|
77 result = CxeSettingsMapperSymbian::Map2CameraEffect(initialData); |
|
78 QVERIFY(result == CCamera::CCameraImageProcessing::EEffectSepia); |
|
79 |
|
80 // case 2: try with direct value which is invalid |
|
81 result = CxeSettingsMapperSymbian::Map2CameraEffect( |
|
82 static_cast<Cxe::Colortone>(-1)); |
|
83 QVERIFY(result == CCamera::CCameraImageProcessing::EEffectNone); |
|
84 |
|
85 } |
|
86 |
|
87 void UnitTestCxeSettingsMapperSymbian::testMap2CameraExposureMode() |
|
88 { |
|
89 CCamera::TExposure result; |
|
90 Cxe::ExposureMode initialData = static_cast<Cxe::ExposureMode>(-1); |
|
91 |
|
92 // case 0: check with unknown value |
|
93 result = CxeSettingsMapperSymbian::Map2CameraExposureMode(initialData); |
|
94 QVERIFY(result == CCamera::EExposureAuto); |
|
95 |
|
96 // case 1: try with valid ui exposure value |
|
97 initialData = Cxe::ExposureNight; |
|
98 result = CxeSettingsMapperSymbian::Map2CameraExposureMode(initialData); |
|
99 QVERIFY(result == CCamera::EExposureNight); |
|
100 |
|
101 // case 2: try with direct value which is invalid |
|
102 result = CxeSettingsMapperSymbian::Map2CameraExposureMode( |
|
103 static_cast<Cxe::ExposureMode>(99999)); |
|
104 QVERIFY(result == CCamera::EExposureAuto); |
|
105 } |
|
106 |
|
107 void UnitTestCxeSettingsMapperSymbian::testMap2CameraFlash() |
|
108 { |
|
109 CCamera::TFlash result; |
|
110 Cxe::FlashMode initialData = static_cast<Cxe::FlashMode>(-1); |
|
111 |
|
112 // case 0: check with unknown value |
|
113 result = CxeSettingsMapperSymbian::Map2CameraFlash(initialData); |
|
114 QVERIFY(result == CCamera::EFlashAuto); |
|
115 |
|
116 // case 1: try with valid ui flash value |
|
117 initialData = Cxe::FlashOn; |
|
118 result = CxeSettingsMapperSymbian::Map2CameraFlash(initialData); |
|
119 QVERIFY(result == CCamera::EFlashForced); |
|
120 |
|
121 // case 2: try with direct value which is invalid |
|
122 result = CxeSettingsMapperSymbian::Map2CameraFlash( |
|
123 static_cast<Cxe::FlashMode>(99999)); |
|
124 QVERIFY(result == CCamera::EFlashAuto); |
|
125 } |
|
126 |
|
127 |
|
128 void UnitTestCxeSettingsMapperSymbian::testMap2CameraOrientation() |
|
129 { |
|
130 MCameraOrientation::TOrientation result; |
|
131 Cxe::DeviceOrientation initialData = Cxe::Orientation0; |
|
132 |
|
133 // case 0: check with unknown value |
|
134 result = CxeSettingsMapperSymbian::Map2CameraOrientation(initialData); |
|
135 QVERIFY(result == MCameraOrientation::EOrientation0); |
|
136 |
|
137 // case 1: try with valid ui camera orientation value |
|
138 initialData = Cxe::Orientation90; |
|
139 result = CxeSettingsMapperSymbian::Map2CameraOrientation(initialData); |
|
140 QVERIFY(result == MCameraOrientation::EOrientation90); |
|
141 } |
|
142 |
|
143 void UnitTestCxeSettingsMapperSymbian::testMap2CameraWb() |
|
144 { |
|
145 CCamera::TWhiteBalance result; |
|
146 Cxe::Whitebalance initialData = static_cast<Cxe::Whitebalance>(-1); |
|
147 |
|
148 // case 0: check with unknown value |
|
149 result = CxeSettingsMapperSymbian::Map2CameraWb(initialData); |
|
150 QVERIFY(result == CCamera::EWBAuto); |
|
151 |
|
152 // case 1: try with valid ui whitebalance value |
|
153 initialData = Cxe::WhitebalanceSunny; |
|
154 result = CxeSettingsMapperSymbian::Map2CameraWb(initialData); |
|
155 QVERIFY(result == CCamera::EWBDaylight); |
|
156 |
|
157 // case 2: try with direct value which is invalid |
|
158 result = CxeSettingsMapperSymbian::Map2CameraWb( |
|
159 static_cast<Cxe::Whitebalance>(99999)); |
|
160 QVERIFY(result == CCamera::EWBAuto); |
|
161 } |
|
162 |
|
163 void UnitTestCxeSettingsMapperSymbian::testMap2UseCaseHintVideoParameters() |
|
164 { |
|
165 CxeVideoDetails details; |
|
166 MCameraUseCaseHint::TVideoCodec codec = MCameraUseCaseHint::ECodecUnknown; |
|
167 MCameraUseCaseHint::TVideoProfile profile = MCameraUseCaseHint::EProfileUnknown; |
|
168 |
|
169 details.mVideoCodecMimeType = "video/H263-2000"; |
|
170 CxeSettingsMapperSymbian::Map2UseCaseHintVideoParameters(details, codec, profile); |
|
171 QCOMPARE(codec, MCameraUseCaseHint::ECodecH263); |
|
172 QCOMPARE(profile, MCameraUseCaseHint::EProfileH263P0L10); |
|
173 |
|
174 details.mVideoCodecMimeType = "video/mp4v-es; profile-level-id=2"; |
|
175 CxeSettingsMapperSymbian::Map2UseCaseHintVideoParameters(details, codec, profile); |
|
176 QCOMPARE(codec, MCameraUseCaseHint::ECodecMpeg4); |
|
177 QCOMPARE(profile, MCameraUseCaseHint::EProfileMPEG4SpL2); |
|
178 |
|
179 details.mVideoCodecMimeType = "video/mp4v-es; profile-level-id=3"; |
|
180 CxeSettingsMapperSymbian::Map2UseCaseHintVideoParameters(details, codec, profile); |
|
181 QCOMPARE(codec, MCameraUseCaseHint::ECodecMpeg4); |
|
182 QCOMPARE(profile, MCameraUseCaseHint::EProfileMPEG4SpL3); |
|
183 |
|
184 details.mVideoCodecMimeType = "video/mp4v-es; profile-level-id=4"; |
|
185 CxeSettingsMapperSymbian::Map2UseCaseHintVideoParameters(details, codec, profile); |
|
186 QCOMPARE(codec, MCameraUseCaseHint::ECodecMpeg4); |
|
187 QCOMPARE(profile, MCameraUseCaseHint::EProfileMPEG4SpL4a); |
|
188 |
|
189 details.mVideoCodecMimeType = "video/mp4v-es; profile-level-id=foobar"; |
|
190 CxeSettingsMapperSymbian::Map2UseCaseHintVideoParameters(details, codec, profile); |
|
191 QCOMPARE(codec, MCameraUseCaseHint::ECodecMpeg4); |
|
192 QCOMPARE(profile, MCameraUseCaseHint::EProfileUnknown); |
|
193 |
|
194 details.mVideoCodecMimeType = "video/H264; profile-level-id=42801E"; |
|
195 CxeSettingsMapperSymbian::Map2UseCaseHintVideoParameters(details, codec, profile); |
|
196 QCOMPARE(codec, MCameraUseCaseHint::ECodecH264); |
|
197 QCOMPARE(profile, MCameraUseCaseHint::EProfileH264BpL3); |
|
198 |
|
199 details.mVideoCodecMimeType = "video/H264; profile-level-id=42801F"; |
|
200 CxeSettingsMapperSymbian::Map2UseCaseHintVideoParameters(details, codec, profile); |
|
201 QCOMPARE(codec, MCameraUseCaseHint::ECodecH264); |
|
202 QCOMPARE(profile, MCameraUseCaseHint::EProfileH264BpL3_1); |
|
203 |
|
204 details.mVideoCodecMimeType = "video/H264; profile-level-id=foobar"; |
|
205 CxeSettingsMapperSymbian::Map2UseCaseHintVideoParameters(details, codec, profile); |
|
206 QCOMPARE(codec, MCameraUseCaseHint::ECodecH264); |
|
207 QCOMPARE(profile, MCameraUseCaseHint::EProfileUnknown); |
|
208 |
|
209 details.mVideoCodecMimeType = "invalid"; |
|
210 CxeSettingsMapperSymbian::Map2UseCaseHintVideoParameters(details, codec, profile); |
|
211 QCOMPARE(codec, MCameraUseCaseHint::ECodecUnknown); |
|
212 QCOMPARE(profile, MCameraUseCaseHint::EProfileUnknown); |
|
213 } |
|
214 |
|
215 // main() function non-GUI testing |
|
216 QTEST_APPLESS_MAIN(UnitTestCxeSettingsMapperSymbian); |
|