author | hgs |
Fri, 06 Aug 2010 10:03:37 +0300 | |
changeset 46 | c826656d6714 |
parent 41 | 67457b2ffb33 |
child 52 | 7e18d488ac5f |
permissions | -rw-r--r-- |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
41 | 2 |
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
#include <QTest> |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
#include <QDebug> |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
#include <QSignalSpy> |
46 | 20 |
#include <QMetaType> |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
|
46 | 22 |
#include "cxutils.h" |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
#include "cxetestutils.h" |
46 | 24 |
#include "cxefakesettingsstore.h" |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
#include "unittest_cxesettingsimp.h" |
46 | 26 |
#include "cxecenrepkeys.h" |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
const char* FAIL_TEST_SETTING = "Fail test"; |
46 | 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 |
|
33 |
const int SCENE_AUTO_EV_VALUE = 0; |
|
34 |
const int SIGNAL_TIMEOUT = 3000; //milliseconds |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
36 |
UnitTestCxeSettingsImp::UnitTestCxeSettingsImp() : |
46 | 37 |
mSettingsImp(NULL), mSettingsStore(NULL) |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
38 |
{ |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
qRegisterMetaType<CxeScene>("CxeScene"); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
qRegisterMetaType<CxeError::Id>("CxeError::Id"); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
qRegisterMetaType<Cxe::CameraMode>("Cxe::CameraMode"); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
44 |
UnitTestCxeSettingsImp::~UnitTestCxeSettingsImp() |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
{ |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
47 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
void UnitTestCxeSettingsImp::init() |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
{ |
46 | 50 |
mSettingsStore = new CxeFakeSettingsStore(); |
51 |
mSettingsImp = new CxeSettingsImp(mSettingsStore); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
54 |
void UnitTestCxeSettingsImp::cleanup() |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
55 |
{ |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
delete mSettingsImp; |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
mSettingsImp = NULL; |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
59 |
|
46 | 60 |
/* |
61 |
* Testing loadSettings() with Cxe::ImageMode argument |
|
62 |
*/ |
|
63 |
void UnitTestCxeSettingsImp::testLoadImageSettings() |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
64 |
{ |
46 | 65 |
CX_DEBUG_ENTER_FUNCTION(); |
66 |
QSignalSpy spy(mSettingsImp, SIGNAL(settingValueChanged(QString,QVariant))); |
|
67 |
mSettingsImp->loadSettings(Cxe::ImageMode); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
68 |
|
46 | 69 |
//signal should be emitted when loading settings |
70 |
QVERIFY(spy.count() > 0); |
|
71 |
||
72 |
//now let's take a look inside a signal content |
|
73 |
QList<QVariant> arguments = spy.takeFirst(); |
|
74 |
QVERIFY(arguments.at(0).toString().toAscii() == CxeSettingIds::IMAGE_SCENE); |
|
75 |
CX_DEBUG_EXIT_FUNCTION(); |
|
76 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
|
46 | 78 |
/* |
79 |
* Testing loadSettings() with Cxe::VideoMode argument |
|
80 |
*/ |
|
81 |
void UnitTestCxeSettingsImp::testLoadVideoSettings() |
|
82 |
{ |
|
83 |
CX_DEBUG_ENTER_FUNCTION(); |
|
84 |
QSignalSpy spy(mSettingsImp, SIGNAL(settingValueChanged(QString,QVariant))); |
|
85 |
mSettingsImp->loadSettings(Cxe::VideoMode); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
86 |
|
46 | 87 |
//signal should be emitted when loading settings |
88 |
QVERIFY(spy.count() > 0); |
|
89 |
||
90 |
//now let's take a look inside a signal content |
|
91 |
QList<QVariant> arguments = spy.takeFirst(); |
|
92 |
QVERIFY(arguments.at(0).toString().toAscii() == CxeSettingIds::VIDEO_SCENE); |
|
93 |
||
94 |
CX_DEBUG_EXIT_FUNCTION(); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
95 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
96 |
|
46 | 97 |
/* |
98 |
* Advanced test case for loadSettings() |
|
99 |
*/ |
|
100 |
void UnitTestCxeSettingsImp::testLoadImageAndVideoSettings() |
|
101 |
{ |
|
102 |
CX_DEBUG_ENTER_FUNCTION(); |
|
103 |
QSignalSpy spy(mSettingsImp, SIGNAL(settingValueChanged(QString,QVariant))); |
|
104 |
mSettingsImp->loadSettings(Cxe::VideoMode); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
105 |
|
46 | 106 |
//signal should be emitted when loading settings |
107 |
QVERIFY(spy.count() > 0); |
|
108 |
||
109 |
//now let's take a look inside a signal content |
|
110 |
QList<QVariant> arguments = spy.takeFirst(); |
|
111 |
QVERIFY(arguments.at(0).toString().toAscii() == CxeSettingIds::VIDEO_SCENE); |
|
112 |
spy.clear(); |
|
113 |
||
114 |
mSettingsImp->loadSettings(Cxe::ImageMode); |
|
115 |
||
116 |
//signal should be emitted when loading settings |
|
117 |
QVERIFY(spy.count() > 0); |
|
118 |
||
119 |
//now let's take a look inside a signal content |
|
120 |
arguments = spy.takeFirst(); |
|
121 |
QVERIFY(arguments.at(0).toString().toAscii() == CxeSettingIds::IMAGE_SCENE); |
|
122 |
||
123 |
CX_DEBUG_EXIT_FUNCTION(); |
|
124 |
} |
|
125 |
||
126 |
/* |
|
127 |
* Testing inline get(const QString &key) |
|
128 |
* defined in cxesettings.h as template |
|
129 |
*/ |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
130 |
void UnitTestCxeSettingsImp::testGet() |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
131 |
{ |
46 | 132 |
CX_DEBUG_ENTER_FUNCTION(); |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
133 |
CxeError::Id err = CxeError::None; |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
134 |
|
46 | 135 |
// The idea of this test case is to test as much of different type of settings |
136 |
// as possible |
|
137 |
||
138 |
// Testing reading brightness setting value |
|
139 |
int brightnessValue; |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
140 |
QVariant testValue; |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
141 |
|
46 | 142 |
try { |
143 |
brightnessValue = mSettingsImp->CxeSettings::get<int>(CxeSettingIds::BRIGHTNESS); |
|
144 |
} |
|
145 |
catch (CxeException exception) { |
|
146 |
QString message = "Exception thrown, error id = "; |
|
147 |
message.append(exception.error()); |
|
148 |
QFAIL(message.toAscii()); |
|
149 |
return; |
|
150 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
151 |
|
46 | 152 |
mSettingsStore->get(CxeSettingIds::BRIGHTNESS, testValue); |
153 |
QCOMPARE(brightnessValue, testValue.toInt()); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
154 |
|
46 | 155 |
// Testing reading color tone setting value |
156 |
Cxe::Colortone colorTone; |
|
157 |
try { |
|
158 |
colorTone = mSettingsImp->CxeSettings::get<Cxe::Colortone>(CxeSettingIds::COLOR_TONE); |
|
159 |
} |
|
160 |
catch (CxeException exception) { |
|
161 |
QString message = "Exception thrown, error id = "; |
|
162 |
message.append(exception.error()); |
|
163 |
QFAIL(message.toAscii()); |
|
164 |
return; |
|
165 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
166 |
|
46 | 167 |
QVariant colorTone2; |
168 |
mSettingsStore->get(CxeSettingIds::COLOR_TONE, colorTone2); |
|
169 |
QVERIFY(colorTone2 == colorTone); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
170 |
|
46 | 171 |
// Testing reading contrast setting value |
172 |
int contrastValue; |
|
173 |
try { |
|
174 |
contrastValue = mSettingsImp->CxeSettings::get<int>(CxeSettingIds::CONTRAST); |
|
175 |
} |
|
176 |
catch (CxeException exception) { |
|
177 |
QString message = "Exception thrown, error id = "; |
|
178 |
message.append(exception.error()); |
|
179 |
QFAIL(message.toAscii()); |
|
180 |
return; |
|
181 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
182 |
|
46 | 183 |
mSettingsStore->get(CxeSettingIds::CONTRAST, testValue); |
184 |
QCOMPARE(testValue.toInt(), contrastValue); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
185 |
|
46 | 186 |
// Testing reading file name folder suffix setting value |
187 |
QString fnameValue; |
|
188 |
try { |
|
189 |
fnameValue = mSettingsImp->CxeSettings::get<QString>(CxeSettingIds::FNAME_FOLDER_SUFFIX); |
|
190 |
} |
|
191 |
catch (CxeException exception) { |
|
192 |
QString message = "Exception thrown, error id = "; |
|
193 |
message.append(exception.error()); |
|
194 |
QFAIL(message.toAscii()); |
|
195 |
return; |
|
196 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
197 |
|
46 | 198 |
mSettingsStore->get(CxeSettingIds::FNAME_FOLDER_SUFFIX, testValue); |
199 |
QCOMPARE(testValue.toString(), fnameValue); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
200 |
|
46 | 201 |
// Testing reading scene data |
202 |
QVariantMap sceneData; |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
203 |
|
46 | 204 |
// First set the still camera scene to auto |
205 |
mSettingsStore->set(CxeSettingIds::IMAGE_SCENE, Cxe::IMAGE_SCENE_AUTO); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
206 |
|
46 | 207 |
try { |
208 |
sceneData = mSettingsImp->CxeSettings::get<QVariantMap>(CxeSettingIds::IMAGE_SCENE_DATA); |
|
209 |
} |
|
210 |
catch (CxeException exception) { |
|
211 |
QString message = "Exception thrown, error id = "; |
|
212 |
message.append(exception.error()); |
|
213 |
QFAIL(message.toAscii()); |
|
214 |
return; |
|
215 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
216 |
|
46 | 217 |
QCOMPARE(sceneData[CxeSettingIds::EV_COMPENSATION_VALUE].toInt(), SCENE_AUTO_EV_VALUE); |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
218 |
|
46 | 219 |
// Now let's try same with video scene |
220 |
sceneData.clear(); |
|
221 |
mSettingsStore->set(CxeSettingIds::VIDEO_SCENE, Cxe::VIDEO_SCENE_AUTO); |
|
222 |
try { |
|
223 |
sceneData = mSettingsImp->CxeSettings::get<QVariantMap>(CxeSettingIds::VIDEO_SCENE_DATA); |
|
224 |
} |
|
225 |
catch (CxeException exception) { |
|
226 |
QString message = "Exception thrown, error id = "; |
|
227 |
message.append(exception.error()); |
|
228 |
QFAIL(message.toAscii()); |
|
229 |
return; |
|
230 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
231 |
|
46 | 232 |
QCOMPARE(sceneData[CxeSettingIds::EV_COMPENSATION_VALUE].toInt(), SCENE_AUTO_EV_VALUE); |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
233 |
|
46 | 234 |
CX_DEBUG_EXIT_FUNCTION(); |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
235 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
236 |
|
46 | 237 |
/* |
238 |
* Testing get(long int uid, |
|
239 |
* unsigned long int key, |
|
240 |
* Cxe::SettingKeyType type, |
|
241 |
* QVariant &value) |
|
242 |
*/ |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
243 |
void UnitTestCxeSettingsImp::testGet2() |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
244 |
{ |
46 | 245 |
CX_DEBUG_ENTER_FUNCTION(); |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
246 |
QVariant value; |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
247 |
|
46 | 248 |
mSettingsImp->get(CxSettingsCrUid, FileNameSuffixCr, Cxe::Repository, value); |
249 |
// 42 is just a test value from cxefakesettingsstore |
|
250 |
// we just check that it is correctly returned |
|
251 |
QCOMPARE(value.toInt(), 42); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
252 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
253 |
mSettingsImp->get(0, 0, Cxe::PublishAndSubscribe, value); |
46 | 254 |
// 42 is just a test value from cxefakesettingsstore |
255 |
// we just check that it is correctly returned |
|
256 |
QCOMPARE(value.toInt(), 42); |
|
257 |
CX_DEBUG_EXIT_FUNCTION(); |
|
258 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
259 |
|
46 | 260 |
/* |
261 |
* Testing get(const QString &key, const T &defaultValue) |
|
262 |
* defined in cxesettings.h as template |
|
263 |
*/ |
|
264 |
void UnitTestCxeSettingsImp::testGet3() |
|
265 |
{ |
|
266 |
CX_DEBUG_ENTER_FUNCTION(); |
|
267 |
Cxe::Colortone defaultTone = Cxe::ColortoneNormal; |
|
268 |
mSettingsStore->set(CxeSettingIds::COLOR_TONE, Cxe::ColortoneVivid); |
|
269 |
Cxe::Colortone colorTone = mSettingsImp->CxeSettings::get<Cxe::Colortone>( |
|
270 |
CxeSettingIds::COLOR_TONE, defaultTone); |
|
271 |
QVERIFY(colorTone == Cxe::ColortoneVivid); |
|
272 |
||
273 |
// Now when using this version of the overloaded get<int>() |
|
274 |
// with invalid key parameter, it should internally |
|
275 |
// catch the exception and not modify the default value |
|
276 |
int defaultValue = 0; |
|
277 |
int value = mSettingsImp->CxeSettings::get<int>( |
|
278 |
FAIL_TEST_SETTING, defaultValue); |
|
279 |
QVERIFY(value == defaultValue); |
|
280 |
CX_DEBUG_EXIT_FUNCTION(); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
281 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
282 |
|
46 | 283 |
/* |
284 |
* Testing inputting some garbage into CxeSettingsImp::get() |
|
285 |
*/ |
|
286 |
void UnitTestCxeSettingsImp::testGetGarbage() |
|
287 |
{ |
|
288 |
CX_DEBUG_ENTER_FUNCTION(); |
|
289 |
int intTestValue = 0; |
|
290 |
CxeError::Id errorId; |
|
291 |
||
292 |
try { |
|
293 |
mSettingsImp->CxeSettings::get<int>(EMPTY_STRING, intTestValue); |
|
294 |
} |
|
295 |
catch (CxeException exception) { |
|
296 |
QString message = "Exception thrown, error id = "; |
|
297 |
message.append(exception.error()); |
|
298 |
errorId = CxeError::Id(exception.error()); |
|
299 |
QCOMPARE(errorId, CxeError::NotFound); |
|
300 |
} |
|
301 |
||
302 |
try { |
|
303 |
mSettingsImp->CxeSettings::get<int>(FAIL_TEST_SETTING, intTestValue); |
|
304 |
} |
|
305 |
catch (CxeException exception) { |
|
306 |
QString message = "Exception thrown, error id = "; |
|
307 |
message.append(exception.error()); |
|
308 |
errorId = CxeError::Id(exception.error()); |
|
309 |
QCOMPARE(errorId, CxeError::NotFound); |
|
310 |
} |
|
311 |
||
312 |
CX_DEBUG_EXIT_FUNCTION(); |
|
313 |
} |
|
314 |
||
315 |
/* |
|
316 |
* Testing inline void set(const QString &key, const T &value) |
|
317 |
* defined in cxesettings.h |
|
318 |
*/ |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
319 |
void UnitTestCxeSettingsImp::testSet() |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
320 |
{ |
46 | 321 |
CX_DEBUG_ENTER_FUNCTION(); |
322 |
||
323 |
// Point of this test case is to try all versions of the set() |
|
324 |
// method defined in cxesettings.inl |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
325 |
|
46 | 326 |
// Testing set<int>() version |
327 |
QVariant value; |
|
328 |
try { |
|
329 |
mSettingsImp->set(CxeSettingIds::COLOR_TONE, Cxe::ColortoneBlackAndWhite); |
|
330 |
} |
|
331 |
catch (CxeException exception) { |
|
332 |
QString message = "Exception thrown, error id = "; |
|
333 |
message.append(exception.error()); |
|
334 |
QFAIL(message.toAscii()); |
|
335 |
return; |
|
336 |
} |
|
337 |
mSettingsStore->get(CxeSettingIds::COLOR_TONE, value); |
|
338 |
QCOMPARE(value.toInt(), (int)Cxe::ColortoneBlackAndWhite); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
339 |
|
46 | 340 |
// Testing set<QString>() version |
341 |
QString stringValue = "some text"; |
|
342 |
try { |
|
343 |
mSettingsImp->set(CxeSettingIds::FNAME_FOLDER_SUFFIX, stringValue); |
|
344 |
} |
|
345 |
catch (CxeException exception) { |
|
346 |
QString message = "Exception thrown, error id = "; |
|
347 |
message.append(exception.error()); |
|
348 |
QFAIL(message.toAscii()); |
|
349 |
return; |
|
350 |
} |
|
351 |
mSettingsStore->get(CxeSettingIds::FNAME_FOLDER_SUFFIX, value); |
|
352 |
QCOMPARE(value.toString(), stringValue); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
353 |
|
46 | 354 |
// Testing set<bool>() version |
355 |
bool boolValue = true; |
|
356 |
try { |
|
357 |
mSettingsImp->set(CxeSettingIds::STILL_SHOWCAPTURED, boolValue); |
|
358 |
} |
|
359 |
catch (CxeException exception) { |
|
360 |
QString message = "Exception thrown, error id = "; |
|
361 |
message.append(exception.error()); |
|
362 |
QFAIL(message.toAscii()); |
|
363 |
return; |
|
364 |
} |
|
365 |
mSettingsStore->get(CxeSettingIds::STILL_SHOWCAPTURED, value); |
|
366 |
QCOMPARE(value.toBool(), boolValue); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
367 |
|
46 | 368 |
// Testing set<qreal>() version |
369 |
qreal qrealValue = -1.25; |
|
370 |
try { |
|
371 |
mSettingsImp->set(CxeSettingIds::EV_COMPENSATION_VALUE, qrealValue); |
|
372 |
} |
|
373 |
catch (CxeException exception) { |
|
374 |
QString message = "Exception thrown, error id = "; |
|
375 |
message.append(exception.error()); |
|
376 |
QFAIL(message.toAscii()); |
|
377 |
return; |
|
378 |
} |
|
379 |
mSettingsStore->get(CxeSettingIds::EV_COMPENSATION_VALUE, value); |
|
380 |
QCOMPARE(value.toReal(), qrealValue); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
381 |
|
46 | 382 |
// Testing set<QVariantMap>() version |
383 |
CxeScene testSceneData; |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
384 |
|
46 | 385 |
testSceneData.insert(CxeSettingIds::SCENE_ID, Cxe::IMAGE_SCENE_AUTO); |
386 |
testSceneData.insert(CxeSettingIds::WHITE_BALANCE, Cxe::WhitebalanceAutomatic); |
|
387 |
testSceneData.insert(CxeSettingIds::EXPOSURE_MODE, Cxe::ExposureAuto); |
|
388 |
testSceneData.insert(CxeSettingIds::COLOR_TONE, Cxe::ColortoneNormal); |
|
389 |
testSceneData.insert(CxeSettingIds::CONTRAST, 5); |
|
390 |
testSceneData.insert(CxeSettingIds::SHARPNESS, Cxe::SharpnessNormal); |
|
391 |
testSceneData.insert(CxeSettingIds::LIGHT_SENSITIVITY, Cxe::LightSensitivityAutomatic); |
|
392 |
testSceneData.insert(CxeSettingIds::EV_COMPENSATION_VALUE, -2); |
|
393 |
testSceneData.insert(CxeSettingIds::BRIGHTNESS, 8); |
|
394 |
testSceneData.insert(CxeSettingIds::FLASH_MODE, Cxe::FlashAuto); |
|
395 |
testSceneData.insert(CxeSettingIds::FACE_TRACKING, 1); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
396 |
|
46 | 397 |
// First set the still camera scene to auto |
398 |
mSettingsStore->set(CxeSettingIds::IMAGE_SCENE, Cxe::IMAGE_SCENE_AUTO); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
399 |
|
46 | 400 |
// Now setting the value |
401 |
try { |
|
402 |
//This should throw an exception with CxeError::NotSupported |
|
403 |
mSettingsImp->set(CxeSettingIds::IMAGE_SCENE_DATA, testSceneData); |
|
404 |
} |
|
405 |
catch (CxeException exception) { |
|
406 |
QString message = "Exception thrown, error id = "; |
|
407 |
message.append((int)exception.error()); |
|
408 |
QCOMPARE(exception.error(), (int)CxeError::NotSupported); |
|
409 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
410 |
|
46 | 411 |
CX_DEBUG_EXIT_FUNCTION(); |
412 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
413 |
|
46 | 414 |
/* |
415 |
* This will test calling void method of reset() |
|
416 |
*/ |
|
417 |
void UnitTestCxeSettingsImp::testReset() |
|
418 |
{ |
|
419 |
CX_DEBUG_ENTER_FUNCTION(); |
|
420 |
mSettingsImp->reset(); |
|
421 |
CX_DEBUG_EXIT_FUNCTION(); |
|
422 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
423 |
|
46 | 424 |
void UnitTestCxeSettingsImp::testGetVariationSetting() |
425 |
{ |
|
426 |
CX_DEBUG_ENTER_FUNCTION(); |
|
427 |
QVariant value; |
|
428 |
CxeError::Id error = mSettingsImp->getVariationValue(CxeVariationKeys::STILL_MAX_ZOOM_LIMITS, value); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
429 |
QCOMPARE(error, CxeError::None); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
430 |
|
46 | 431 |
error = mSettingsImp->getVariationValue(FAIL_TEST_SETTING, value); |
432 |
QCOMPARE(error, CxeError::NotFound); |
|
433 |
CX_DEBUG_EXIT_FUNCTION(); |
|
434 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
435 |
|
46 | 436 |
void UnitTestCxeSettingsImp::testListenForSetting() |
437 |
{ |
|
438 |
CX_DEBUG_ENTER_FUNCTION(); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
439 |
|
46 | 440 |
// This test case will initialize listening for certain setting changes |
441 |
// and will verify that listener has succesfully deployed the signal |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
442 |
|
46 | 443 |
// First let's initialize a signal spy |
444 |
QSignalSpy spy(mSettingsImp, SIGNAL(settingValueChanged(QString, QVariant))); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
445 |
|
46 | 446 |
// Initializing the original value to make sure it changes later on |
447 |
mSettingsStore->set(CxeSettingIds::CAMERA_MODE, Cxe::ImageMode); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
448 |
|
46 | 449 |
// Now start listening and verify that starting was succesfull |
450 |
bool result = mSettingsImp->listenForSetting(CxeSettingIds::CAMERA_MODE, this, SLOT(testSlot())); |
|
451 |
QVERIFY(result); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
452 |
|
46 | 453 |
// Now change the setting and wait for the signal |
454 |
//mSettingsStore->set(CxeSettingIds::CAMERA_MODE, Cxe::VideoMode); |
|
455 |
mSettingsImp->set(CxeSettingIds::CAMERA_MODE, Cxe::VideoMode); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
456 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
457 |
|
46 | 458 |
// Check that signal was emitted |
459 |
QVERIFY(CxeTestUtils::waitForSignal(spy, SIGNAL_TIMEOUT)); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
460 |
|
46 | 461 |
// One more check with invalid input parameter |
462 |
result = mSettingsImp->listenForSetting(FAIL_TEST_SETTING, this, SLOT(testSlot())); |
|
463 |
QVERIFY(!result); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
464 |
|
46 | 465 |
// Now disconnecting the listener and checking if the signal is still emitted |
466 |
disconnect(mSettingsImp, SIGNAL(settingValueChanged(QString,QVariant)), this, SLOT(testSlot())); |
|
467 |
delete mSettingsImp; |
|
468 |
mSettingsImp = NULL; |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
469 |
|
46 | 470 |
mSettingsStore->set(CxeSettingIds::CAMERA_MODE, Cxe::ImageMode); |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
471 |
|
46 | 472 |
// Make sure that no additional signals are emitted |
473 |
QVERIFY(!CxeTestUtils::waitForSignal(spy, SIGNAL_TIMEOUT)); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
474 |
|
46 | 475 |
CX_DEBUG_EXIT_FUNCTION(); |
476 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
477 |
|
46 | 478 |
/* |
479 |
* Just a dummy slot |
|
480 |
*/ |
|
481 |
void UnitTestCxeSettingsImp::testSlot() |
|
482 |
{ |
|
483 |
CX_DEBUG_IN_FUNCTION(); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
484 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
485 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
486 |
// main() function non-GUI testing |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
487 |
QTEST_MAIN(UnitTestCxeSettingsImp) |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
488 |