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 * test application for qt control panel public apis. |
|
16 */ |
|
17 #include "ut_cpdataformbuttonentryviewitem.h" |
|
18 |
|
19 #include "cpdataformbuttonentryviewitem.h" |
|
20 #include "mycpdataformbuttonentryviewitem.h" |
|
21 #include "cpbasesettingview.h" |
|
22 |
|
23 #include <QtTest/QtTest> |
|
24 #include <HbMainWindow> |
|
25 #include <hbdataform.h> |
|
26 #include <cppluginutility.h> |
|
27 #include <hbdataformmodel.h> |
|
28 #include <cpsettingformentryitemdata.h> |
|
29 #include <cpsettingformentryitemdataimpl.h> |
|
30 |
|
31 /*! |
|
32 \class TestCpDataFormButtonEntryViewItem |
|
33 \brief The TestCpDataFormButtonEntryViewItem class is designed for the unit testing for CpDataFormButtonEntryViewItem class. |
|
34 This unit test is supported by QTest. |
|
35 There are total 8 test cases in this unit. |
|
36 */ |
|
37 |
|
38 void TestCpDataFormButtonEntryViewItem::initTestCase() |
|
39 { |
|
40 mainWindow = 0; |
|
41 } |
|
42 |
|
43 void TestCpDataFormButtonEntryViewItem::cleanupTestCase() |
|
44 { |
|
45 delete mainWindow; |
|
46 |
|
47 //if delete mainwindow, test app will be freezing |
|
48 QCoreApplication::processEvents(); |
|
49 } |
|
50 |
|
51 /*! |
|
52 * Test Case Description:\n |
|
53 * 1. Fucntion Name: CpDataFormButtonEntryViewItem() \n |
|
54 2. Function Descrition: \n |
|
55 2.1 Create CpDataFormButtonEntryViewItem object with a HbDataForm pointer.\n |
|
56 2.2 verify object created successfully.\n |
|
57 2.3 delete the object.\n |
|
58 3. Input Parameters: \n |
|
59 @param: HbDataForm pointer.\n |
|
60 4. Expected result: \n |
|
61 case run without verify failed.\n |
|
62 */ |
|
63 void TestCpDataFormButtonEntryViewItem::testCpDataFormButtonEntryViewItemWithDataFormParent() |
|
64 { |
|
65 HbDataForm * form = new HbDataForm(); |
|
66 QVERIFY( form != 0 ); |
|
67 |
|
68 int count0 = form->itemPrototypes().count(); |
|
69 CpPluginUtility::addCpItemPrototype(form); |
|
70 int count1 = form->itemPrototypes().count(); |
|
71 QVERIFY( count0 + 2 == count1 ); |
|
72 |
|
73 CpDataFormButtonEntryViewItem * item = new CpDataFormButtonEntryViewItem(form); |
|
74 QVERIFY(item != 0); |
|
75 |
|
76 delete item; |
|
77 } |
|
78 |
|
79 /*! |
|
80 * Test Case Description:\n |
|
81 * 1. Fucntion Name: CpDataFormButtonEntryViewItem() \n |
|
82 2. Function Descrition: \n |
|
83 2.1 Create CpDataFormButtonEntryViewItem object with a 0 pointer.\n |
|
84 2.2 verify object created successfully.\n |
|
85 2.3 delete the object.\n |
|
86 3. Input Parameters: \n |
|
87 @param: 0 pointer.\n |
|
88 4. Expected result: \n |
|
89 case run without verify failed.\n |
|
90 */ |
|
91 void TestCpDataFormButtonEntryViewItem::testCpDataFormButtonEntryViewItemWithNullParent() |
|
92 { |
|
93 CpDataFormButtonEntryViewItem * item = new CpDataFormButtonEntryViewItem(); |
|
94 QVERIFY(item != 0); |
|
95 |
|
96 delete item; |
|
97 } |
|
98 |
|
99 /*! |
|
100 * Test Case Description:\n |
|
101 * 1. Fucntion Name: CpDataFormButtonEntryViewItem(const CpDataFormButtonEntryViewItem &ohter) \n |
|
102 2. Function Descrition: \n |
|
103 2.1 Create CpDataFormButtonEntryViewItem object with another CpDataFormButtonEntryViewItem object.\n |
|
104 2.2 verify object created successfully.\n |
|
105 2.3 delete the object.\n |
|
106 3. Input Parameters: \n |
|
107 @param: CpDataFormButtonEntryViewItem object.\n |
|
108 4. Expected result: \n |
|
109 case run without verify failed.\n |
|
110 */ |
|
111 void TestCpDataFormButtonEntryViewItem::testCpDataFormButtonEntryViewItemWithCopyConstructor() |
|
112 { |
|
113 MyCpDataFormButtonEntryViewItem * item1 = new MyCpDataFormButtonEntryViewItem(); |
|
114 QVERIFY( item1 != 0 ); |
|
115 |
|
116 MyCpDataFormButtonEntryViewItem * item2 = new MyCpDataFormButtonEntryViewItem(*item1); |
|
117 QVERIFY( item2 != 0 ); |
|
118 |
|
119 delete item1; |
|
120 delete item2; |
|
121 } |
|
122 |
|
123 /*! |
|
124 * Test Case Description:\n |
|
125 * 1. Fucntion Name:\n |
|
126 HbAbstractViewItem *createItem();\n |
|
127 2. Function Descrition: \n |
|
128 2.1 Create CpDataFormButtonEntryViewItem object.\n |
|
129 2.2 verify object created successfully.\n |
|
130 2.3 call createItem() to create a HbAbstractViewItem object.\n |
|
131 2.4 verify the object is not 0.\n |
|
132 2.5 delete both objects.\n |
|
133 3. Input Parameters: \n |
|
134 @param: none.\n |
|
135 4. Expected result: \n |
|
136 case run without verify failed.\n |
|
137 */ |
|
138 void TestCpDataFormButtonEntryViewItem::testCreateItemWithDataForm() |
|
139 { |
|
140 HbDataForm * form = new HbDataForm(); |
|
141 QVERIFY( form != 0 ); |
|
142 |
|
143 int count0 = form->itemPrototypes().count(); |
|
144 CpPluginUtility::addCpItemPrototype(form); |
|
145 int count1 = form->itemPrototypes().count(); |
|
146 QVERIFY( count0 + 2 == count1 ); |
|
147 |
|
148 CpDataFormButtonEntryViewItem * item = new CpDataFormButtonEntryViewItem(form); |
|
149 QVERIFY(item != 0); |
|
150 |
|
151 HbAbstractViewItem * pvItem1 = item->createItem(); |
|
152 QVERIFY(pvItem1 != 0); |
|
153 |
|
154 delete pvItem1; |
|
155 delete item; |
|
156 delete form; |
|
157 } |
|
158 |
|
159 /*! |
|
160 * Test Case Description:\n |
|
161 * 1. Fucntion Name:\n |
|
162 HbAbstractViewItem *createItem();\n |
|
163 2. Function Descrition: \n |
|
164 2.1 Create CpDataFormButtonEntryViewItem object.\n |
|
165 2.2 verify object created successfully.\n |
|
166 2.3 call createItem() to create a HbAbstractViewItem object.\n |
|
167 2.4 verify the object is not 0.\n |
|
168 2.5 delete both objects.\n |
|
169 3. Input Parameters: \n |
|
170 @param: none.\n |
|
171 4. Expected result: \n |
|
172 case run without verify failed.\n |
|
173 */ |
|
174 void TestCpDataFormButtonEntryViewItem::testCreateItemNoDataForm() |
|
175 { |
|
176 CpDataFormButtonEntryViewItem * item = new CpDataFormButtonEntryViewItem(); |
|
177 QVERIFY(item != 0); |
|
178 |
|
179 HbAbstractViewItem * pvItem1 = item->createItem(); |
|
180 QVERIFY(pvItem1 != 0); |
|
181 |
|
182 delete pvItem1; |
|
183 delete item; |
|
184 } |
|
185 |
|
186 /*! |
|
187 * Test Case Description:\n |
|
188 * 1. Fucntion Name:\n |
|
189 CpDataFormButtonEntryViewItem &operator = (const CpDataFormButtonEntryViewItem &ohter);\n\n |
|
190 |
|
191 2. Function Descrition: \n |
|
192 2.1 Create CpDataFormButtonEntryViewItem object.\n |
|
193 2.2 verify object created successfully.\n |
|
194 2.3 assign this object to another object.\n |
|
195 2.4 delete object.\n\n |
|
196 |
|
197 3. Input Parameters: \n\n |
|
198 @param: none.\n |
|
199 |
|
200 4. Expected result: \n |
|
201 case run without verify failed.\n |
|
202 */ |
|
203 void TestCpDataFormButtonEntryViewItem::testAssignmentOperatorWithOtherObject() |
|
204 { |
|
205 MyCpDataFormButtonEntryViewItem * item1 = new MyCpDataFormButtonEntryViewItem(); |
|
206 QVERIFY(item1 != 0); |
|
207 |
|
208 MyCpDataFormButtonEntryViewItem item2; |
|
209 |
|
210 item2 = *item1; |
|
211 |
|
212 delete item1; |
|
213 } |
|
214 |
|
215 /*! |
|
216 * Test Case Description:\n |
|
217 * 1. Fucntion Name:\n |
|
218 CpDataFormButtonEntryViewItem &operator = (const CpDataFormButtonEntryViewItem &ohter);\n\n |
|
219 |
|
220 2. Function Descrition: \n |
|
221 2.1 Create CpDataFormButtonEntryViewItem object.\n |
|
222 2.2 verify object created successfully.\n |
|
223 2.3 assign this object to itself.\n |
|
224 2.4 delete object.\n\n |
|
225 |
|
226 3. Input Parameters: \n\n |
|
227 @param: none.\n |
|
228 |
|
229 4. Expected result: \n |
|
230 case run without verify failed.\n |
|
231 */ |
|
232 void TestCpDataFormButtonEntryViewItem::testAssignmentOperatorBySelf() |
|
233 { |
|
234 MyCpDataFormButtonEntryViewItem * item1 = new MyCpDataFormButtonEntryViewItem(); |
|
235 QVERIFY(item1 != 0); |
|
236 |
|
237 *item1 = *item1; |
|
238 |
|
239 delete item1; |
|
240 } |
|
241 |
|
242 /*! |
|
243 * Test Case Description:\n |
|
244 * 1. Fucntion Name:\n |
|
245 HbWidget *createCustomWidget(); |
|
246 |
|
247 2. Function Descrition: \n |
|
248 |
|
249 3. Input Parameters: \n\n |
|
250 @param: none.\n |
|
251 |
|
252 4. Expected result: \n |
|
253 case run without verify failed.\n |
|
254 */ |
|
255 void TestCpDataFormButtonEntryViewItem::testCreateCustomedWidgetWithDataForm() |
|
256 { |
|
257 HbDataForm * form = new HbDataForm(); |
|
258 QVERIFY( form != 0 ); |
|
259 |
|
260 int count0 = form->itemPrototypes().count(); |
|
261 CpPluginUtility::addCpItemPrototype(form); |
|
262 int count1 = form->itemPrototypes().count(); |
|
263 QVERIFY( count0 + 2 == count1 ); |
|
264 |
|
265 CpSettingFormEntryItemDataImpl<CpBaseSettingView> *pdataimp1 = new CpSettingFormEntryItemDataImpl<CpBaseSettingView>( CpSettingFormEntryItemData::ButtonEntryItem, form, "text", "description" ); |
|
266 QVERIFY( pdataimp1 !=0 ); |
|
267 |
|
268 HbDataFormModel * model = new HbDataFormModel; |
|
269 QVERIFY( model != 0 ); |
|
270 |
|
271 model->appendDataFormItem(pdataimp1); |
|
272 form->setModel(model); |
|
273 |
|
274 mainWindow = new HbMainWindow; |
|
275 QVERIFY( mainWindow != 0 ); |
|
276 |
|
277 CpBaseSettingView *mainView = new CpBaseSettingView(form); |
|
278 QVERIFY( mainView != 0 ); |
|
279 |
|
280 QObject::connect(mainView,SIGNAL(aboutToClose()),qApp,SLOT(quit())); |
|
281 HbView * view = mainWindow->addView(mainView); |
|
282 QVERIFY( view != 0 ); |
|
283 |
|
284 mainWindow->setCurrentView(mainView); |
|
285 HbView * curView = mainWindow->currentView(); |
|
286 QVERIFY( curView == mainView ); |
|
287 |
|
288 mainWindow->show(); |
|
289 } |
|
290 |
|
291 QTEST_MAIN(TestCpDataFormButtonEntryViewItem) |
|