27 #include <hbdataformmodelitem.h> |
30 #include <hbdataformmodelitem.h> |
28 #include <hbdataformviewitem.h> |
31 #include <hbdataformviewitem.h> |
29 #include <hbabstractviewitem.h> |
32 #include <hbabstractviewitem.h> |
30 #include <hbpushbutton.h> |
33 #include <hbpushbutton.h> |
31 //testing following classes |
34 //testing following classes |
32 |
35 #include <cpbasesettingview.h> |
33 #include "cpbasesettingview.h" |
|
34 #include "cpsettingformentryitemdata.h" |
36 #include "cpsettingformentryitemdata.h" |
35 #include "cpsettingformentryitemdataimpl.h" |
37 #include "cpsettingformentryitemdataimpl.h" |
36 #include <cpsettingformitemdata.h> |
38 #include <cpsettingformitemdata.h> |
37 #include <cpitemdatahelper.h> |
39 #include <cpitemdatahelper.h> |
38 #include <cppluginutility.h> |
40 #include <cppluginutility.h> |
39 #include <cppluginloader.h> |
41 #include <cppluginloader.h> |
40 #include <cpplugininterface.h> |
42 #include <cpplugininterface.h> |
|
43 #include <cplauncherinterface.h> |
41 #include <cplogger.h> |
44 #include <cplogger.h> |
42 |
45 /*! |
|
46 \class TestCpAPI |
|
47 \brief class name: TestCpAPI \n |
|
48 class's description: \n |
|
49 type of test case: API class test \n |
|
50 test cases' number totally: 9 \n |
|
51 */ |
43 void TestCpAPI::initTestCase() |
52 void TestCpAPI::initTestCase() |
44 { |
53 { |
45 //mainWindow = new HbMainWindow; |
54 |
46 //mainWindow->show(); |
|
47 } |
55 } |
48 |
56 |
49 void TestCpAPI::cleanupTestCase() |
57 void TestCpAPI::cleanupTestCase() |
50 { |
58 { |
51 //delete mainWindow; |
|
52 //mainWindow = 0; |
|
53 //if delete mainwindow, test app will be freezing |
|
54 QCoreApplication::processEvents(); |
59 QCoreApplication::processEvents(); |
55 } |
60 } |
|
61 /*! |
|
62 <b>Test Case Description:</b> \n |
|
63 Verify the class CpBaseSettingView can created corresponding views via different parameters.\n |
|
64 1. Fucntion Name: \n |
|
65 <1> CpBaseSettingView::CpBaseSettingView(QGraphicsWidget *widget,QGraphicsItem *parent)\n |
|
66 <2> virtual void close()\n |
|
67 2. Case Descrition: \n |
|
68 <1> test the constructor function\n |
|
69 <2> Test the close() function. \n |
|
70 3. Input Parameters: \n |
|
71 <1> widget = 0 , parent = 0 \n |
|
72 widget = 0, parent = new HbWidget () \n |
|
73 widget = new Hbpushbuton (), parent = 0 \n |
|
74 widget = new hbpushbutton(), parent = new HbWidget() \n |
|
75 <2> none \n |
|
76 4. Expected result: \n |
|
77 <1> pview != 0, no crash \n |
|
78 <2> no crash \n |
|
79 */ |
56 void TestCpAPI::testCpBaseSettingView() |
80 void TestCpAPI::testCpBaseSettingView() |
57 { |
81 { |
58 CpBaseSettingView * pview = new CpBaseSettingView(0); |
82 //set the parameters as 0 |
59 QVERIFY( pview != 0 ); |
83 CpBaseSettingView * pview = new CpBaseSettingView(0); |
60 HbDataForm *pForm = new HbDataForm(0); |
84 QVERIFY( pview != 0 ); |
61 pview->setWidget(pForm); |
85 HbDataForm *pForm = new HbDataForm(0); |
62 QVERIFY( qobject_cast<HbDataForm *>(pview->widget()) == pForm ); |
86 pview->setWidget(pForm); |
|
87 QVERIFY( qobject_cast<HbDataForm *>(pview->widget()) == pForm ); |
63 delete pview; |
88 delete pview; |
|
89 pview = 0; |
|
90 |
64 HbPushButton *widget = new HbPushButton(); |
91 HbPushButton *widget = new HbPushButton(); |
65 QVERIFY(widget != 0); |
92 QVERIFY(widget != 0); |
|
93 // set the first parameter as widget |
66 CpBaseSettingView *pView1 = new CpBaseSettingView(widget); |
94 CpBaseSettingView *pView1 = new CpBaseSettingView(widget); |
67 QVERIFY(pView1!=0); |
95 QVERIFY(pView1!=0); |
68 HbPushButton *button = qobject_cast<HbPushButton *>(pView1->widget()); |
96 HbPushButton *button = qobject_cast<HbPushButton *>(pView1->widget()); |
69 QVERIFY(button != 0); |
97 QVERIFY(button != 0); |
70 delete pView1; |
98 delete pView1; |
|
99 pView1 = 0; |
71 |
100 |
72 } |
101 // test close() function in CpBaseSettingView class. |
73 |
102 CpTestView *pview3 = new CpTestView(); |
|
103 pview3->testClose(); |
|
104 delete pview3; |
|
105 pview3 = 0; |
|
106 } |
|
107 /*! |
|
108 <b>Test Case Description:</b> \n |
|
109 . Verify this class could create the corresponding control panel defined HbDataFormModelItem. \n\n |
|
110 <b>Function 1:</b> \n |
|
111 1. Fucntion Name: \n |
|
112 CpSettingFormItemData(HbDataFormModelItem::DataItemType type, const QString &label, const HbDataFormModelItem *parent = 0) \n |
|
113 2. Case Descrition: \n |
|
114 Test the constructor function. \n |
|
115 3. Input Parameters: \n |
|
116 <1> type = HbDataFormModelItem::DataItemType, label = QString, parent = new HbDataFormModelItem(), \n |
|
117 <2> type = (HbDataFormModelItem::DataItemType) invaildValue, label = 0, parent = 0 \n |
|
118 4. Expected result: \n |
|
119 <1> pdata != 0, pdata->type() == type \n |
|
120 <2> no crash \n |
|
121 <b>Function 2:</b> \n |
|
122 1. Fucntion Name: \n |
|
123 CpSettingFormItemData(const HbDataFormModelItem *parent = 0) \n |
|
124 2. Case Descrition: \n |
|
125 Test the constructor function. \n |
|
126 3. Input Parameters: \n |
|
127 none \n |
|
128 4. Expected result: \n |
|
129 pdata != 0 & no crash \n |
|
130 <b>Function 3:</b> \n |
|
131 1. Fucntion Name: \n |
|
132 QString text() const; \n |
|
133 2. Case Descrition: \n |
|
134 Verify it returns the right text string. \n |
|
135 3. Input Parameters: \n |
|
136 none \n |
|
137 4. Expected result: \n |
|
138 return the correct text string \n |
|
139 <b>Function 4:</b> \n |
|
140 1. Fucntion Name: \n |
|
141 void setText(const QString &text); \n |
|
142 2. Case Descrition: \n |
|
143 Verify that the text can be set via this function. \n |
|
144 3. Input Parameters: \n |
|
145 text = QString(xx) |
|
146 4. Expected result: \n |
|
147 pItemData->text() == text \n |
|
148 <b>Function 5:</b> \n |
|
149 1. Fucntion Name: \n |
|
150 QString description() const; \n |
|
151 2. Case Descrition: \n |
|
152 Verify that it returns the correct description name. \n |
|
153 3. Input Parameters: \n |
|
154 none \n |
|
155 4. Expected result: \n |
|
156 return the correct text string \n |
|
157 <b>Function 6:</b> \n |
|
158 1. Fucntion Name: \n |
|
159 void setDescription(const QString &description); \n |
|
160 2. Case Descrition: \n |
|
161 Verify it can set description successfully. \n |
|
162 3. Input Parameters: \n |
|
163 description = QString(xx) |
|
164 4. Expected result: \n |
|
165 pItemData->description() == description \n |
|
166 <b>Function 7:</b> \n |
|
167 1. Fucntion Name: \n |
|
168 QString iconName() const;\n |
|
169 2. Case Descrition: \n |
|
170 Verify it can return the right icon name. \n |
|
171 3. Input Parameters: \n |
|
172 none \n |
|
173 4. Expected result: \n |
|
174 return the correct icon name \n |
|
175 <b>Function 8:</b> \n |
|
176 1. Fucntion Name: \n |
|
177 void setIconName(const QString &icon); \n |
|
178 2. Case Descrition: \n |
|
179 Verify it can set the given icon name successfully.\n |
|
180 3. Input Parameters: \n |
|
181 iconName = QString(xx) |
|
182 4. Expected result: \n |
|
183 pItemData->iconNmae() == iconName \n |
|
184 <b>Function 9:</b> \n |
|
185 1. Fucntion Name: \n |
|
186 void setEntryItemIcon(const HbIcon &icon); \n |
|
187 2. Case Descrition: \n |
|
188 Verify it can set the item icon successfully. \n |
|
189 3. Input Parameters: \n |
|
190 icon = HbIcon() |
|
191 4. Expected result: \n |
|
192 entryItemIcon() == icon \n |
|
193 */ |
|
194 void TestCpAPI::testCpSettingFormEntryItemData() |
|
195 { |
|
196 // create CpTestPluginEntryItemData class firstly |
|
197 CpItemDataHelper *pHelper = new CpItemDataHelper(); |
|
198 HbIcon pIcon = HbIcon("icon"); |
|
199 |
|
200 // test the first constructor |
|
201 CpTestPluginEntryItemData *pItemData = new CpTestPluginEntryItemData(0); |
|
202 QVERIFY (pItemData!=0); |
|
203 delete pItemData; |
|
204 pItemData = 0; |
|
205 |
|
206 // The second constructor |
|
207 pItemData = new CpTestPluginEntryItemData(*pHelper, "test","test", pIcon, 0); |
|
208 QVERIFY (pItemData!=0); |
|
209 |
|
210 // test settext() and text() function |
|
211 QString aText = "strText"; |
|
212 pItemData->setText(aText); |
|
213 QString aTextTemp = pItemData->text(); |
|
214 QVERIFY( aTextTemp == aText); |
|
215 |
|
216 // test setDescription() and description() function |
|
217 QString aDescription = "strDescription"; |
|
218 pItemData->setDescription(aDescription); |
|
219 QString aDesTemp = pItemData->description(); |
|
220 QVERIFY( aDesTemp == aDescription); |
|
221 |
|
222 // test setIconName() and iconName() function |
|
223 QString aIconName = "strIconName"; |
|
224 pItemData->setIconName(aIconName); |
|
225 QString aIconTemp = pItemData->iconName(); |
|
226 QVERIFY( aIconTemp == aIconName); |
|
227 |
|
228 // test setEntryItemIcon() and entryItemIcon() function |
|
229 pItemData->setEntryItemIcon(pIcon); |
|
230 HbIcon pIconTemp = pItemData->entryItemIcon(); |
|
231 QVERIFY( pIconTemp == pIcon); |
|
232 |
|
233 // test onLaunchView() function |
|
234 pItemData->onLaunchView(); |
|
235 |
|
236 delete pItemData; |
|
237 pItemData = 0; |
|
238 delete pHelper; |
|
239 pHelper = 0; |
|
240 } |
|
241 |
|
242 /*! |
|
243 Test Case Description: \n |
|
244 Verify this class could create the corresponding CpSettingFormEntryItemData. \n |
|
245 <b>Function 1:</b> \n |
|
246 1. Fucntion Name: \n |
|
247 explicit CpSettingFormEntryItemDataImpl(CpItemDataHelper &itemDataHelper,const QString &text = QString(), \n |
|
248 const QString &description = QString(),const HbIcon &icon = HbIcon(), \n |
|
249 const HbDataFormModelItem *parent = 0) \n |
|
250 2. Case Descrition: \n |
|
251 Test the first constructor function. \n |
|
252 3. Input Parameters: \n |
|
253 <1> itemDataHelper = CpItemDataHelper, text = Qstring(XX),description = Qstring(XX), |
|
254 icon = HbIcon(), parent = new HbDataFormModelItem() \n |
|
255 <2> itemDataHelper = CpItemDataHelper , text = Qstring(), |
|
256 description = Qstring(), icon = HbIcon(), parent = 0 \n |
|
257 4. Expected result: \n |
|
258 <1> pdataimp != 0 \n |
|
259 <2> no crash \n |
|
260 <b>Function 2:</b> \n |
|
261 1. Fucntion Name: \n |
|
262 explicit CpSettingFormEntryItemDataImpl(HbDataForm *dataForm,const QString &text = QString(), \n |
|
263 const QString &description = QString(),const HbIcon &icon = HbIcon(), \n |
|
264 const HbDataFormModelItem *parent = 0) \n |
|
265 2. Case Descrition: \n |
|
266 Test the second constructor function. \n |
|
267 3. Input Parameters: \n |
|
268 <1> dataform = new HbDataForm(), text = Qstring(XX), description Qstring(XX), |
|
269 icon = HbIcon(XX), parent = new HbDataFormModelItem(), \n |
|
270 <2> dataForm = 0, text = Qstring(), description Qstring(), icon = HbIcon(), parent = 0 \n |
|
271 4. Expected result: \n |
|
272 pdata != 0 \n |
|
273 <b>Function 3:</b> \n |
|
274 1. Fucntion Name: \n |
|
275 explicit CpSettingFormEntryItemDataImpl(EntryItemType type,CpItemDataHelper &itemDataHelper, \n |
|
276 const QString &text = QString(),const QString &description = QString(), \n |
|
277 const QString &icon = QString(),const HbDataFormModelItem *parent = 0) \n |
|
278 2. Case Descrition: \n |
|
279 Test the third constructor function. \n |
|
280 3. Input Parameters: \n |
|
281 <1> type = HbDataFormModelItem::DataItemType, itemDataHelper = CpItemDataHelper, \n |
|
282 text = QString(XX), description = QString(XX), icon = QString(XX), parent = new HbDataFormModelItem() \n |
|
283 <2> type = HbDataFormModelItem::DataItemType, itemDataHelper = CpItemDataHelper default, \n |
|
284 text = QString(), description = QString(), icon = QString(), parent = 0 \n |
|
285 4. Expected result: \n |
|
286 <1> pdataimp != 0, pdataimp->icon() != icon,\n |
|
287 <2> pdataimp != 0, pdataimp->icon() == 0, \n |
|
288 <b>Function 4:</b> \n |
|
289 1. Fucntion Name: \n |
|
290 explicit CpSettingFormEntryItemDataImpl(EntryItemType type,HbDataForm *dataForm,const QString &text = QString(),\n |
|
291 const QString &description = QString(),const QString &icon = QString(),\n |
|
292 const HbDataFormModelItem *parent = 0) \n |
|
293 2. Case Descrition: \n |
|
294 Test the forth constructor function. \n |
|
295 3. Input Parameters: \n |
|
296 <1> type = HbDataFormModelItem::DataItemType, dataform = new HbDataForm(), \n |
|
297 text = QString(XX), description = QString(XX), icon = QString(XX), parent = new HbDataFormModelItem() \n |
|
298 <2> type = HbDataFormModelItem::DataItemType, dataform = 0, text = QString(), \n |
|
299 description = QString(), icon = QString(), parent = 0 \n |
|
300 4. Expected result: \n |
|
301 <1> pdataimp != 0, pdataimp->icon() != icon,\n |
|
302 <2> pdataimp != 0, pdataimp->icon() == 0, \n |
|
303 */ |
74 void TestCpAPI::testCpSettingFormEntryItemDataImpl() |
304 void TestCpAPI::testCpSettingFormEntryItemDataImpl() |
75 { |
305 { |
76 CpItemDataHelper *pHelper = new CpItemDataHelper(); |
306 //Define the parameters for the constructors. |
77 CpSettingFormEntryItemDataImpl<CpBaseSettingView> *pdataimp = new CpSettingFormEntryItemDataImpl<CpBaseSettingView>( *pHelper, "text", "description" ); |
307 QString strText = "testText"; |
78 QVERIFY( pdataimp !=0 ); |
308 QString strDes = "testDescription"; |
79 QString strtxt = "input texts"; |
309 QString strIcon = "iconString"; |
80 pdataimp->setText(strtxt); |
310 CpItemDataHelper *pHelper = new CpItemDataHelper(); |
81 QVERIFY( pdataimp->text() == strtxt ); |
311 HbDataFormModelItem *aParent = new HbDataFormModelItem(); |
82 |
312 HbIcon icon = HbIcon("icon"); |
83 QString strDes = "input descriptions"; |
313 HbDataForm *pDataform = new HbDataForm(); |
84 pdataimp->setDescription(strDes); |
314 CpSettingFormEntryItemData::EntryItemType EType1 = CpSettingFormEntryItemData::ListEntryItem; |
85 QVERIFY( pdataimp->description() == strDes); |
315 CpSettingFormEntryItemData::EntryItemType EType2 = CpSettingFormEntryItemData::ButtonEntryItem; |
86 delete pdataimp; |
316 // test the first constructor function. |
87 delete pHelper; |
317 CpSettingFormEntryItemDataImpl<CpBaseSettingView> *pdataimp = |
88 } |
318 new CpSettingFormEntryItemDataImpl<CpBaseSettingView>( *pHelper, strText, strDes, icon, aParent ); // first constructor |
|
319 QVERIFY (pdataimp != 0); |
|
320 QVERIFY( pdataimp->text() == strText ); |
|
321 QVERIFY( pdataimp->description()==strDes ); |
|
322 QVERIFY( pdataimp->icon() == icon.iconName() ); |
|
323 delete pdataimp; |
|
324 pdataimp = 0; |
|
325 pdataimp = new CpSettingFormEntryItemDataImpl<CpBaseSettingView>( *pHelper, QString(), QString(), icon, 0); |
|
326 QVERIFY (pdataimp != 0); |
|
327 delete pdataimp; |
|
328 pdataimp = 0; |
|
329 |
|
330 pdataimp = new CpSettingFormEntryItemDataImpl<CpBaseSettingView>(0); // set parameter as "0" |
|
331 QVERIFY (pdataimp != 0); |
|
332 QVERIFY( pdataimp->text() == 0 ); |
|
333 QVERIFY( pdataimp->description()==0 ); |
|
334 delete pdataimp; |
|
335 pdataimp = 0; |
|
336 // test the second constructor function. |
|
337 pdataimp = new CpSettingFormEntryItemDataImpl <CpBaseSettingView> ( pDataform,strText, strDes, icon, aParent ); //second contructor |
|
338 QVERIFY( pdataimp->text() == strText ); |
|
339 QVERIFY( pdataimp->description()==strDes ); |
|
340 QVERIFY( pdataimp->icon() == icon.iconName() ); |
|
341 delete pdataimp; |
|
342 pdataimp = 0; |
|
343 pdataimp = new CpSettingFormEntryItemDataImpl <CpBaseSettingView> ( 0, QString(), QString(), icon, 0 ); |
|
344 QVERIFY (pdataimp != 0); |
|
345 delete pdataimp; |
|
346 pdataimp = 0; |
|
347 // test the third constructor function. |
|
348 pdataimp = new CpSettingFormEntryItemDataImpl<CpBaseSettingView>( EType1,*pHelper, strText, strDes, strIcon, aParent );// the third constructor |
|
349 HbDataFormModelItem::DataItemType EdataItmeTypeTemp1 = pdataimp->type(); |
|
350 QVERIFY (EdataItmeTypeTemp1 == EType1); |
|
351 QVERIFY( pdataimp->text() == strText ); |
|
352 QVERIFY( pdataimp->description()==strDes ); |
|
353 QVERIFY( pdataimp->icon() == strIcon ); |
|
354 delete pdataimp; |
|
355 pdataimp = 0; |
|
356 // test the forth constructor function. |
|
357 pdataimp = new CpSettingFormEntryItemDataImpl<CpBaseSettingView>(EType2,pDataform, strText, strDes, strIcon, aParent );// the fourth constructor |
|
358 CpSettingFormEntryItemData::DataItemType EdataItmeTypeTemp2 = pdataimp->type(); |
|
359 QVERIFY (EdataItmeTypeTemp2 == EType2); |
|
360 QVERIFY( pdataimp->text() == strText ); |
|
361 QVERIFY( pdataimp->description()==strDes ); |
|
362 QVERIFY( pdataimp->icon() == strIcon ); |
|
363 delete pdataimp; |
|
364 pdataimp = 0; |
|
365 |
|
366 delete pHelper; |
|
367 pHelper=0; |
|
368 delete pDataform; |
|
369 pDataform = 0; |
|
370 } |
|
371 /*! |
|
372 provide test data for the testCpSettingFormItemData() |
|
373 */ |
|
374 void TestCpAPI::testCpSettingFormItemData_data() |
|
375 { |
|
376 // add the test data as below |
|
377 QTest::addColumn<int>("aType"); |
|
378 QTest::addColumn<QString>("aLabel"); |
|
379 QTest::newRow("FormPageItem value") << (int)HbDataFormModelItem::FormPageItem << "FormPageItem Label"; |
|
380 QTest::newRow("GroupItem value") << (int)HbDataFormModelItem::GroupItem << "GroupItem Label"; |
|
381 QTest::newRow("GroupPageItem value") << (int)HbDataFormModelItem::GroupPageItem << "GroupPageItem Label"; |
|
382 QTest::newRow("TextItem value") << (int)HbDataFormModelItem::TextItem << "TextItem Label"; |
|
383 QTest::newRow("SliderItem value") << (int)HbDataFormModelItem::SliderItem << "SliderItem Label"; |
|
384 QTest::newRow("VolumeSliderItem value") << (int)HbDataFormModelItem::VolumeSliderItem << "VolumeSliderItem Label"; |
|
385 QTest::newRow("CheckBoxItem value") << (int)HbDataFormModelItem::CheckBoxItem << "CheckBoxItem Label"; |
|
386 QTest::newRow("ToggleValueItem value") << (int)HbDataFormModelItem::ToggleValueItem << "ToggleValueItem Label"; |
|
387 QTest::newRow("RadioButtonListItem value") << (int)HbDataFormModelItem::RadioButtonListItem << "RadioButtonListItem Label"; |
|
388 QTest::newRow("MultiselectionItem value") << (int)HbDataFormModelItem::MultiselectionItem << "MultiselectionItem Label"; |
|
389 QTest::newRow("ComboBoxItem value") << (int)HbDataFormModelItem::ComboBoxItem << "ComboBoxItem Label"; |
|
390 } |
|
391 /*! |
|
392 <b>Test Case Description:</b> \n |
|
393 Verify this class could create the corresponding control panel defined HbDataFormModelItem. \n |
|
394 <b>Function 1:</b> \n |
|
395 1. Fucntion Name: \n |
|
396 CpSettingFormItemData(HbDataFormModelItem::DataItemType type, const QString &label,const HbDataFormModelItem *parent = 0); \n |
|
397 2. Case Descrition: \n |
|
398 Test the first constructor function. \n |
|
399 3. Input Parameters: \n |
|
400 <1> type = HbDataFormModelItem::DataItemType, label = QString, parent = new HbDataFormModelItem() \n |
|
401 <2> type = (HbDataFormModelItem::DataItemType) invaildValue, label = 0, parent = 0 \n |
|
402 4. Expected result: \n |
|
403 <1> pdata != 0, pdata->type() == type \n |
|
404 <2> no crash \n |
|
405 <b>Function 2:</b> \n |
|
406 1. Fucntion Name: \n |
|
407 CpSettingFormItemData(const HbDataFormModelItem *parent = 0 \n |
|
408 2. Case Descrition: \n |
|
409 Test the second constructor function. \n |
|
410 3. Input Parameters: \n |
|
411 <1> parent = new HbDataFormModelItem() \n |
|
412 4. Expected result: \n |
|
413 <1> pdata != 0, no crash \n |
|
414 */ |
89 void TestCpAPI::testCpSettingFormItemData() |
415 void TestCpAPI::testCpSettingFormItemData() |
90 { |
416 { |
91 CpSettingFormItemData *pdata = new CpSettingFormItemData( HbDataFormModelItem::TextItem, "label" ); |
417 // Fectch the test data from testCpSettingFormItemData_data() |
92 QVERIFY( pdata !=0 ); |
418 QFETCH(int, aType); |
93 delete pdata; |
419 QFETCH(QString, aLabel); |
94 pdata = 0; |
420 // test the constructor using the above data |
95 pdata = new CpSettingFormItemData( HbDataFormModelItem::SliderItem, "label" ); |
421 HbDataFormModelItem::DataItemType itemType = (HbDataFormModelItem::DataItemType)aType; |
96 QVERIFY( pdata !=0 ); |
422 CpSettingFormItemData *pdata=new CpSettingFormItemData(itemType,aLabel); |
97 delete pdata; |
423 QVERIFY( pdata !=0 ); |
98 pdata = 0; |
424 HbDataFormModelItem::DataItemType itemTemp=pdata->type(); |
99 pdata = new CpSettingFormItemData( HbDataFormModelItem::VolumeSliderItem, "label" ); |
425 QVERIFY(itemType==itemTemp); |
100 QVERIFY( pdata !=0 ); |
426 delete pdata; |
101 delete pdata; |
427 pdata=0; |
102 pdata = new CpSettingFormItemData( HbDataFormModelItem::CheckBoxItem, "label" ); |
428 } |
103 QVERIFY( pdata !=0 ); |
429 /*! |
104 delete pdata; |
430 <b>Test Case Description:</b> \n |
105 pdata = 0; |
431 To verify all the functions in CpItemdataHelper class. \n |
106 pdata = new CpSettingFormItemData( HbDataFormModelItem::ToggleValueItem, "label" ); |
432 <b>Function 1:</b> \n |
107 QVERIFY( pdata !=0 ); |
433 1. Fucntion Name: \n |
108 delete pdata; |
434 explicit CpItemDataHelper(HbDataForm *form = 0) \n |
109 pdata = 0; |
435 2. Case Descrition: \n |
110 pdata = new CpSettingFormItemData( HbDataFormModelItem::RadioButtonListItem, "label" ); |
436 Test the first constructor function. \n |
111 QVERIFY( pdata !=0 ); |
437 3. Input Parameters: \n |
112 delete pdata; |
438 <1> form = 0 \n |
113 pdata = 0; |
439 <2> form = new HbDataForm() \n |
114 pdata = new CpSettingFormItemData( HbDataFormModelItem::MultiselectionItem, "label" ); |
440 4. Expected result: \n |
115 QVERIFY( pdata !=0 ); |
441 <1> pHelper != 0 \n |
116 delete pdata; |
442 <2> pHelper != 0 \n |
117 pdata = 0; |
443 <b>Function 2:</b> \n |
118 pdata = new CpSettingFormItemData( HbDataFormModelItem::ComboBoxItem, "label" ); |
444 1. Fucntion Name: \n |
119 QVERIFY( pdata !=0 ); |
445 void bindToForm(HbDataForm *form) \n |
120 delete pdata; |
446 2. Input Parameters: \n |
121 pdata = 0; |
447 <1> form = 0 \n |
122 } |
448 <2> form = new HbDataForm() \n |
|
449 3. Expected result: \n |
|
450 no crash \n |
|
451 <b>Function 3:</b> \n |
|
452 1. Fucntion Name: \n |
|
453 void addItemPrototype(HbAbstractViewItem *prototype) \n |
|
454 2. Input Parameters: \n |
|
455 <1> prototype = HbDataFormViewItem() \n |
|
456 <2> prototype = 0 \n |
|
457 3. Expected result: \n |
|
458 no crash \n |
|
459 <b>Function 4:</b> \n |
|
460 1. Fucntion Name: \n |
|
461 void addConnection(HbDataFormModelItem *item, const char *signal, QObject *receiver,const char *method) \n |
|
462 2. Input Parameters: \n |
|
463 <1> item = new HbDataFormModelItem(), signal = char*, receiver = Qobject*, method = const char* \n |
|
464 <2> set all parameters as '0' \n |
|
465 3. Expected result: \n |
|
466 no crash \n |
|
467 <b>Function 5:</b> \n |
|
468 1. Fucntion Name: \n |
|
469 void removeConnection(HbDataFormModelItem *item, const char *signal, Qobject *receiver, const char *method) \n |
|
470 2. Input Parameters: \n |
|
471 <1> item = new HbDataFormModelItem(), signal = char*, receiver = Qobject*, method = const char*\n |
|
472 <2> set all parameters as '0' |
|
473 3. Expected result: \n |
|
474 no crash \n |
|
475 <b>Function 6:</b> \n |
|
476 1. Fucntion Name: \n |
|
477 void connectToForm(const char *signal, QObject *receiver, const char *method) \n |
|
478 2. Input Parameters: \n |
|
479 <1> signal = char*, receiver = Qobject*, method = const char* \n |
|
480 <2> set all parameters as '0' \n |
|
481 3. Expected result: \n |
|
482 no crash \n |
|
483 <b>Function 7:</b> \n |
|
484 1. Fucntion Name: \n |
|
485 HbWidget *widgetFromModelIndex(const QModelIndex &index) \n |
|
486 2. Input Parameters: \n |
|
487 <1> index = const QModelIndex \n |
|
488 3. Expected result: \n |
|
489 no crash \n |
|
490 <b>Function 8:</b> \n |
|
491 1. Fucntion Name: \n |
|
492 HbDataFormModelItem *modelItemFromModelIndex(const QModelIndex &index) \n |
|
493 2. Input Parameters: \n |
|
494 <1> index = const QModelIndex() \n |
|
495 <2> set all parameters as '0' \n |
|
496 3. Expected result: \n |
|
497 no crash \n |
|
498 */ |
123 void TestCpAPI::testItemDataHelper() |
499 void TestCpAPI::testItemDataHelper() |
124 { |
500 { |
|
501 HbDataForm* form = new HbDataForm(); // create a dataform |
|
502 HbDataFormModel *model = new HbDataFormModel(); |
|
503 HbDataFormModelItem *general = model->appendDataFormPage(QString("General")); // add a dataformpage |
|
504 CpSettingFormItemData *mItem = new CpSettingFormItemData(HbDataFormModelItem::SliderItem, |
|
505 QString("New Slider")); |
|
506 general->appendChild(mItem); // add a slider to the dataformgroup, use it as a parameter when testing addConnection() function |
|
507 form->setModel(model); |
|
508 |
|
509 // test constructor using default parameter |
|
510 CpItemDataHelper *phelperdefault = new CpItemDataHelper(0); |
|
511 QVERIFY (phelperdefault!=0); |
|
512 |
|
513 // test constructor using a HbDataForm parameter |
|
514 CpItemDataHelper *phelperForm = new CpItemDataHelper(form); |
|
515 QVERIFY (phelperForm!=0); |
|
516 |
|
517 // test bindtoForm() |
|
518 phelperForm->bindToForm(0); |
|
519 phelperForm->bindToForm(form); |
|
520 |
|
521 // test the addItemPrototype() function |
|
522 int oldProtoTypeListNr = form->itemPrototypes().count(); |
|
523 HbDataFormViewItem *pitem = new HbDataFormViewItem(); |
|
524 phelperForm->addItemPrototype(pitem); |
|
525 int newProtoTypeListNr = form->itemPrototypes().count(); |
|
526 //Verify that the prototype is added to the prototypelist |
|
527 QVERIFY( newProtoTypeListNr == oldProtoTypeListNr + 1 ); |
|
528 |
|
529 phelperForm->addItemPrototype(0); // pitem = 0 |
|
530 |
|
531 // test addConnection() function |
|
532 char aSignal[] = "asignal"; |
|
533 char aMethod[] = "amethod"; |
|
534 phelperForm->addConnection( general, aSignal,mItem,aMethod); |
|
535 phelperForm->removeConnection(general,aSignal,mItem, aMethod); |
|
536 phelperForm->addConnection( 0,0,0,0 ); |
|
537 phelperForm->removeConnection(0,0,0,0); |
|
538 phelperdefault->addConnection(general, aSignal,mItem,aMethod); |
|
539 |
|
540 // test connectToForm() function |
|
541 phelperForm->connectToForm(aSignal,mItem, aMethod); |
|
542 phelperForm->disconnectFromForm(aSignal,mItem, aMethod); |
|
543 phelperForm->connectToForm(0,0,0); |
|
544 phelperForm->disconnectFromForm(0,0,0); |
|
545 phelperdefault->connectToForm(aSignal,mItem, aMethod); |
|
546 |
|
547 // test widgetFromModelIndex() function |
|
548 QModelIndex aIndex = model->indexFromItem(mItem); |
|
549 HbWidget * widget = phelperForm->widgetFromModelIndex(aIndex); |
|
550 QVERIFY( widget->type() == Hb::ItemType_Slider ); |
|
551 |
|
552 // test modelItemFromModelIndex() function |
|
553 HbDataFormModelItem *itemTest = phelperForm->modelItemFromModelIndex(aIndex); |
|
554 HbDataFormModelItem *itemGeneral = model->itemFromIndex(aIndex); |
|
555 QVERIFY(itemTest == itemGeneral); |
|
556 |
|
557 delete phelperdefault; |
|
558 phelperdefault = 0; |
|
559 delete phelperForm; |
|
560 phelperForm = 0; |
|
561 delete form; |
|
562 form = 0; |
|
563 delete model; |
|
564 |
|
565 } |
|
566 /*! |
|
567 <b>Test Case Description:</b> \n |
|
568 Verify the class can add the control panel's proto type of setting items( only entry item currently) to the settingForm \n |
|
569 1. Fucntion Name: \n |
|
570 static void addCpItemPrototype(HbDataForm *settingForm) \n |
|
571 2. Case Descrition: \n |
|
572 Verify it can add the control panel's proto type of setting items( only entry item currently) to the settingForm \n |
|
573 3. Input Parameters: \n |
|
574 <1> settingForm = new HbDataForm () \n |
|
575 <2> settingForm = 0 \n |
|
576 4. Expected result: \n |
|
577 <1> The proto type is added to the prototype list \n |
|
578 */ |
|
579 void TestCpAPI::testCpPluginUtility() |
|
580 { |
125 HbDataForm* form = new HbDataForm(); |
581 HbDataForm* form = new HbDataForm(); |
126 HbDataFormModel *model = new HbDataFormModel(); |
582 int oldListNr = form->itemPrototypes().count(); |
127 HbDataFormModelItem *general = model->appendDataFormPage(QString("General")); |
583 CpPluginUtility::addCpItemPrototype(form); // set settingForm = new HbDataForm () |
128 CpItemDataHelper *phelper = new CpItemDataHelper(); |
584 int newListNr = form->itemPrototypes().count(); |
129 phelper->addConnection( general, "hello",form,"hello"); |
585 QVERIFY( newListNr = oldListNr + 1 ); |
130 phelper->removeConnection(general,"hello",form, "hello"); |
586 |
131 phelper->bindToForm(form); |
587 CpPluginUtility::addCpItemPrototype(0); // set settingForm = 0 |
132 HbDataFormViewItem *pitem = new HbDataFormViewItem(); |
588 } |
133 phelper->addItemPrototype(pitem); |
589 /*! |
134 delete phelper; |
590 <b>Test Case Description:</b> \n |
135 } |
591 To verify the class could load the control panel plugin. \n |
136 void TestCpAPI::testCpPluginUtility() |
592 <b>Function 1:</b> \n |
137 { |
593 1. Fucntion Name: \n |
138 HbDataForm* form = new HbDataForm(); |
594 static CpPluginInterface *loadCpPluginInterface(const QString &pluginFile) \n |
139 QList<HbAbstractViewItem *> oldList = form->itemPrototypes(); |
595 2. Case Descrition: \n |
140 CpPluginUtility::addCpItemPrototype(form); |
596 Verify that it can load the cp interface successfully. \n |
141 QList<HbAbstractViewItem *> newList = form->itemPrototypes(); |
597 3. Input Parameters: \n |
142 QVERIFY( oldList.count() < newList.count() ); |
598 <1> pluginFile = const Qstring (a vaild plugin file) \n |
143 } |
599 <2> pluginFile = const Qstring (an invaild plugin file) \n |
144 |
600 <3> pluginFile = 0 \n |
|
601 4. Expected result: \n |
|
602 no crash \n |
|
603 <b>Function 2:</b> \n |
|
604 1. Fucntion Name: \n |
|
605 static CpLauncherInterface *loadCpLauncherInterface(const QString &pluginFile) \n |
|
606 2. Case Descrition: \n |
|
607 Verify that it can load the cp cplaucher interface successfully. \n |
|
608 3. Input Parameters: \n |
|
609 <1> pluginFile = const Qstring (a vaild plugin file) \n |
|
610 <2> pluginFile = const Qstring (an invaild plugin file) \n |
|
611 <3> pluginFile = 0 \n |
|
612 4. Expected result: \n |
|
613 no crash |
|
614 */ |
145 void TestCpAPI::testCpPluginLoader() |
615 void TestCpAPI::testCpPluginLoader() |
146 { |
616 { |
147 CpPluginInterface *plugin = CpPluginLoader::loadCpPluginInterface("non_existing_plugin.dll"); |
617 // the plugins for test are created via the codes in tsrc/unit/pluginfortest. |
148 QVERIFY(plugin == 0); |
618 QString aInvaildFile = "non_existing_plugin.dll"; |
149 |
619 QString aVaildFile1 = "firstpluginfortest"; |
150 plugin = CpPluginLoader::loadCpPluginInterface("cppersonalizationplugin"); |
620 QString aVaildFile2 = "secondpluginfortest.dll"; |
151 QVERIFY(plugin != 0); |
621 QString aVaildFile3 = "thirdpluginfortest.qtplugin"; |
152 |
622 |
153 plugin = CpPluginLoader::loadCpPluginInterface("cppersonalizationplugin.dll"); |
623 CpPluginInterface *pluginInterface = CpPluginLoader::loadCpPluginInterface(aVaildFile1); |
154 QVERIFY(plugin != 0); |
624 QVERIFY(pluginInterface != 0); |
155 |
625 |
156 plugin = CpPluginLoader::loadCpPluginInterface("cppersonalizationplugin.qtplugin"); |
626 pluginInterface = CpPluginLoader::loadCpPluginInterface(aVaildFile2); |
157 QVERIFY(plugin != 0); |
627 QVERIFY(pluginInterface != 0); |
158 } |
628 |
159 |
629 pluginInterface = CpPluginLoader::loadCpPluginInterface(aVaildFile3); |
|
630 QVERIFY(pluginInterface != 0); |
|
631 |
|
632 //Test the 'loadCpLauncherInterface' function |
|
633 CpLauncherInterface *pluginLauncherInterface = CpPluginLoader::loadCpLauncherInterface(aInvaildFile); |
|
634 QVERIFY(pluginLauncherInterface == 0); |
|
635 |
|
636 pluginLauncherInterface = CpPluginLoader::loadCpLauncherInterface(aVaildFile1); |
|
637 QVERIFY(pluginLauncherInterface != 0); |
|
638 |
|
639 pluginLauncherInterface = CpPluginLoader::loadCpLauncherInterface(aVaildFile2); |
|
640 QVERIFY(pluginLauncherInterface != 0); |
|
641 |
|
642 pluginLauncherInterface = CpPluginLoader::loadCpLauncherInterface(aVaildFile3); |
|
643 QVERIFY(pluginLauncherInterface != 0); |
|
644 } |
|
645 /*! |
|
646 <b>Test Case Description:</b> \n |
|
647 Test the CP interface can work well. \n |
|
648 1. Fucntion Name: \n |
|
649 virtual QList<CpSettingFormItemData*> createSettingFormItemData(CpItemDataHelper &itemDataHelper) const \n |
|
650 2. Case Descrition: \n |
|
651 Test the create settingformItemData() function, it's a pure vitual function. Define a simple class and test its interface. \n |
|
652 3. Input Parameters: \n |
|
653 <1> itemDataHelper = CpItemDataHelper \n |
|
654 4. Expected result: \n |
|
655 <1> no crash \n |
|
656 */ |
160 void TestCpAPI::testCpPluginInterface() |
657 void TestCpAPI::testCpPluginInterface() |
161 { |
658 { |
162 CpPluginInterface *plugin = CpPluginLoader::loadCpPluginInterface("cppersonalizationplugin.dll"); |
659 CpItemDataHelper *helper = new CpItemDataHelper(); |
163 if (plugin) { |
660 CpPluginInterface *plugin = CpPluginLoader::loadCpPluginInterface("firstpluginfortest"); |
164 CpItemDataHelper helper; |
661 QVERIFY( plugin != 0 ); |
165 QList<CpSettingFormItemData*> itemData = plugin->createSettingFormItemData(helper); |
662 QList<CpSettingFormItemData*> itemData = plugin->createSettingFormItemData(*helper); |
166 QVERIFY(itemData.size() > 0); |
663 QVERIFY( itemData.size() == 1 ); |
167 qDeleteAll(itemData.begin(),itemData.end()); |
664 qDeleteAll(itemData.begin(),itemData.end()); |
168 itemData.clear(); |
665 itemData.clear(); |
169 } |
666 } |
|
667 /*! |
|
668 <b>Test Case Description:</b> \n |
|
669 Test the CP launcher interface can work well.\n |
|
670 1. Fucntion Name: \n |
|
671 virtual CpBaseSettingView *createSettingView(const QVariant &hint) const \n |
|
672 2. Case Descrition: \n |
|
673 Test it can create setting view after loading the plugin. \n |
|
674 3. Input Parameters: \n |
|
675 <1> hint = Qvariant() \n |
|
676 4. Expected result: \n |
|
677 <1> no crash \n |
|
678 */ |
|
679 void TestCpAPI::testCpLancherInterface() |
|
680 { |
|
681 QVariant hint = QVariant(); |
|
682 CpLauncherInterface *plugin = CpPluginLoader::loadCpLauncherInterface("secondpluginfortest"); |
|
683 QVERIFY( plugin != 0 ); |
|
684 CpBaseSettingView *testView = plugin->createSettingView(hint); |
|
685 QVERIFY( testView != 0 ); |
|
686 delete testView; |
|
687 testView = 0; |
170 } |
688 } |
171 |
689 |
172 void TestCpAPI::testCpLogger() |
690 void TestCpAPI::testCpLogger() |
173 { |
691 { |
174 const QString logConf = "C:/data/.config/ut_cpapi/controlpanellog.conf"; |
692 } |
175 Logger::instance(CPFW_LOGGER_NAME)->configure(logConf,QSettings::IniFormat); |
693 |
176 CPFW_LOG("Hello World!"); |
694 QTEST_MAIN(TestCpAPI) |
177 Logger::closeAll(); |
|
178 } |
|
179 |
|
180 |
|