|
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 |
|
18 |
|
19 #include "ut_cpkeyscreen.h" |
|
20 #include "cpkeyscreenmodel.h" |
|
21 #include "cpkeyscreenconstants.h" |
|
22 #include "cpkeyscreenplugin.h" |
|
23 #include "cpkeyscreenview.h" |
|
24 #include <cpsettingformentryitemdata.h> |
|
25 #include <cpitemdatahelper.h> |
|
26 #include <QtTest/QtTest> |
|
27 |
|
28 /*! |
|
29 Initial test case's resource |
|
30 */ |
|
31 void TestCpKeyScreen::initTestCase() |
|
32 { |
|
33 mModel = new CpKeyScreenModel(); |
|
34 QVERIFY(mModel != 0); |
|
35 } |
|
36 |
|
37 /*! |
|
38 Cleanup test case's resource |
|
39 */ |
|
40 void TestCpKeyScreen::cleanupTestCase() |
|
41 { |
|
42 delete mModel; |
|
43 } |
|
44 |
|
45 /*! |
|
46 1. FunctionName: CpKeyScreenModel() \n |
|
47 2. Description: Test constructor of CpKeyScreenModel \n |
|
48 */ |
|
49 void TestCpKeyScreen::TestConstructorAndDestructor() |
|
50 { |
|
51 CpKeyScreenModel *model = new CpKeyScreenModel(); |
|
52 QVERIFY(model != 0); |
|
53 delete model; |
|
54 model = 0; |
|
55 } |
|
56 /*! |
|
57 1. FucntionName: bool isKeyguardSupported() \n |
|
58 2. Description: Test key guard supported function \n |
|
59 */ |
|
60 void TestCpKeyScreen::TestKeyguardSupported() |
|
61 { |
|
62 // NULL testing, result is decided by feature flag |
|
63 mModel->isKeyguardSupported(); |
|
64 } |
|
65 |
|
66 /*! |
|
67 1. FucntionName: bool isScreensaverSupported() \n |
|
68 2. Description: Test screen saver supported function \n |
|
69 */ |
|
70 void TestCpKeyScreen::TestScreensaverSupported() |
|
71 { |
|
72 // NULL testing, result is decided by feature flag |
|
73 mModel->isScreensaverSupported(); |
|
74 } |
|
75 |
|
76 /*! |
|
77 1. FucntionName: bool isBrightnessSupported() \n |
|
78 2. Description: Test brightness supported function \n |
|
79 */ |
|
80 void TestCpKeyScreen::TestBrightnessSupported() |
|
81 { |
|
82 // NULL testing, result is decided by feature flag |
|
83 mModel->isBrightnessSupported(); |
|
84 } |
|
85 |
|
86 /*! |
|
87 1. FucntionName: bool isRotateSupported() \n |
|
88 2. Description: Test rotate supported function \n |
|
89 */ |
|
90 void TestCpKeyScreen::TestRotateSupported() |
|
91 { |
|
92 // NULL testing, result is decided by feature flag |
|
93 mModel->isRotateSupported(); |
|
94 } |
|
95 |
|
96 /*! |
|
97 1. FunctionName: bool setKeyguard(int value) \n |
|
98 int keyguard() \n |
|
99 2. Description: test KeyGuard settings set and get \n |
|
100 3. Input: 1. valid value of set function, and verify by get function \n |
|
101 4. ExpectedOutput: 1. same between set and get function |
|
102 */ |
|
103 void TestCpKeyScreen::TestSetAndGetKeyGuard() |
|
104 { |
|
105 mModel->setKeyguard(KCpKeyscreenLock15s); |
|
106 QVERIFY(mModel->keyguard() == KCpKeyscreenLock15s); |
|
107 |
|
108 } |
|
109 |
|
110 /*! |
|
111 1. FunctionName: bool setKeyguard(int value) \n |
|
112 int keyguard() \n |
|
113 2. Description: test KeyGuard settings set and get \n |
|
114 3. Input: 1. invalid value of set function, for example "-1" and verify by get function \n |
|
115 2. invalid value of set function, for example "100" and verify by get function \n |
|
116 4. ExpectedOutput: 1. same with the previous one. |
|
117 */ |
|
118 void TestCpKeyScreen::TestSetAndGetKeyGuardWithInvalidInput() |
|
119 { |
|
120 int oldValue = mModel->keyguard(); |
|
121 |
|
122 mModel->setKeyguard(-1); |
|
123 int valueAfterSet = mModel->keyguard(); |
|
124 |
|
125 QVERIFY(oldValue == valueAfterSet); |
|
126 |
|
127 mModel->setKeyguard(100); |
|
128 valueAfterSet = mModel->keyguard(); |
|
129 |
|
130 QVERIFY(oldValue == valueAfterSet); |
|
131 } |
|
132 |
|
133 /*! |
|
134 1. FunctionName: bool setRotate(bool value) \n |
|
135 bool rotate() \n |
|
136 2. Description: test rotate settings set and get \n |
|
137 3. Input: 1. "true" value of set function and verify by get function \n |
|
138 4. ExpectedOutput: 1. return true. |
|
139 */ |
|
140 void TestCpKeyScreen::TestSetAndGetRotateWithTrue() |
|
141 { |
|
142 mModel->setRotate(true); |
|
143 QVERIFY(mModel->rotate() == true); |
|
144 } |
|
145 |
|
146 /*! |
|
147 1. FunctionName: bool setRotate(bool value) \n |
|
148 bool rotate() \n |
|
149 2. Description: test rotate settings set and get \n |
|
150 3. Input: 1. "false" value of set function and verify by get function \n |
|
151 4. ExpectedOutput: 1. return false. |
|
152 */ |
|
153 void TestCpKeyScreen::TestSetAndGetRotateWithFalse() |
|
154 { |
|
155 mModel->setRotate(false); |
|
156 QVERIFY(mModel->rotate() == false); |
|
157 } |
|
158 |
|
159 /*! |
|
160 1. FunctionName: bool setBrightness(int value) \n |
|
161 int brightness() \n |
|
162 2. Description: test brightness settings set and get \n |
|
163 3. Input: 1. valid value of set function, and verify by get function \n |
|
164 4. ExpectedOutput: 1. same between set and get function |
|
165 */ |
|
166 void TestCpKeyScreen::TestSetAndGetBrightness() |
|
167 { |
|
168 mModel->setBrightness(3); |
|
169 QVERIFY(mModel->brightness() == 3); |
|
170 } |
|
171 |
|
172 /*! |
|
173 1. FunctionName: bool setBrightness(int value) \n |
|
174 int brightness() \n |
|
175 2. Description: test KeyGuard settings set and get \n |
|
176 3. Input: 1. invalid value of set function, for example "-1" and verify by get function \n |
|
177 2. invalid value of set function, for example "100" and verify by get function \n |
|
178 4. ExpectedOutput: 1. same with the previous one. |
|
179 */ |
|
180 void TestCpKeyScreen::TestSetAndGetBrightnessWithInvalidInput() |
|
181 { |
|
182 int oldValue = mModel->brightness(); |
|
183 |
|
184 mModel->setBrightness(-1); |
|
185 int valueAfterSet = mModel->brightness(); |
|
186 |
|
187 QVERIFY(oldValue == valueAfterSet); |
|
188 |
|
189 mModel->setBrightness(100); |
|
190 valueAfterSet = mModel->brightness(); |
|
191 |
|
192 QVERIFY(oldValue == valueAfterSet); |
|
193 } |
|
194 |
|
195 /*! |
|
196 1. FunctionName: bool setScreensaver(bool value) \n |
|
197 bool screensaver() \n |
|
198 2. Description: test screen saver settings set and get \n |
|
199 3. Input: 1. "true" value of set function and verify by get function \n |
|
200 4. ExpectedOutput: 1. return true. |
|
201 */ |
|
202 void TestCpKeyScreen::TestSetAndGetScreenSaverWithTrue() |
|
203 { |
|
204 mModel->setScreensaver(true); |
|
205 QVERIFY(mModel->screensaver() == true); |
|
206 } |
|
207 |
|
208 /*! |
|
209 1. FunctionName: bool setScreensaver(bool value) \n |
|
210 bool screensaver() \n |
|
211 2. Description: test screen saver settings set and get \n |
|
212 3. Input: 1. "false" value of set function and verify by get function \n |
|
213 4. ExpectedOutput: 1. return false. |
|
214 */ |
|
215 void TestCpKeyScreen::TestSetAndGetScreenSaverWithFalse() |
|
216 { |
|
217 mModel->setScreensaver(false); |
|
218 QVERIFY(mModel->screensaver() == false); |
|
219 } |
|
220 /*! |
|
221 1. FunctionName: CpKeyScreenPlugin(); |
|
222 2. Description: test CpKeyScreenPlugin's constructor and destructor |
|
223 */ |
|
224 void TestCpKeyScreen::TestPluginConstructorAndDestructor() |
|
225 { |
|
226 CpKeyScreenPlugin *plugin = new CpKeyScreenPlugin(); |
|
227 QVERIFY(plugin != 0); |
|
228 delete plugin; |
|
229 plugin = 0; |
|
230 } |
|
231 |
|
232 /*! |
|
233 1. FunctionName: virtual QList<CpSettingFormItemData*> createSettingFormItemData(CpItemDataHelper &itemDataHelper) const; |
|
234 2. Description: interface of cpkeyscreen plugin |
|
235 3. Input: instance of itemDataHelper |
|
236 4. Expected Output: QList<CpSettingFormItemData*> |
|
237 */ |
|
238 void TestCpKeyScreen::TestPluginInterface() |
|
239 { |
|
240 CpKeyScreenPlugin *plugin = new CpKeyScreenPlugin(); |
|
241 QVERIFY(plugin != 0); |
|
242 CpItemDataHelper *helper = new CpItemDataHelper(); |
|
243 QList<CpSettingFormItemData*> itemList = plugin->createSettingFormItemData(*helper); |
|
244 QVERIFY(itemList.count() == 1); |
|
245 CpSettingFormEntryItemData *entryItem = qobject_cast<CpSettingFormEntryItemData *>(itemList.at(0)); |
|
246 QVERIFY(entryItem != 0); |
|
247 |
|
248 delete plugin; |
|
249 plugin = 0; |
|
250 delete helper; |
|
251 helper = 0; |
|
252 |
|
253 qDeleteAll(itemList.begin(),itemList.end()); |
|
254 itemList.clear(); |
|
255 } |
|
256 |
|
257 /*! |
|
258 1. FunctionName CpKeyScreenView |
|
259 2. Description: ui of key and screen plugin |
|
260 3. Input: a null parent and a QObject |
|
261 4. Expected Output: a instance of cpkeyscreenview |
|
262 */ |
|
263 void TestCpKeyScreen::TestViewConstructorAndDestructor() |
|
264 { |
|
265 CpKeyScreenView *view = new CpKeyScreenView(0); |
|
266 QVERIFY(view != 0); |
|
267 |
|
268 CpKeyScreenView *view1 = new CpKeyScreenView(new HbWidget()); |
|
269 QVERIFY(view1 != 0); |
|
270 |
|
271 delete view; |
|
272 view = 0; |
|
273 delete view1; |
|
274 view = 0; |
|
275 } |
|
276 QTEST_MAIN(TestCpKeyScreen) |