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