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 cpcategorymodel functions. |
|
16 */ |
|
17 |
|
18 #include "ut_categorymodelitemdata.h" |
|
19 #include "cpcategorysettingformitemdata.h" |
|
20 #include <QtTest/QtTest> |
|
21 #include <cpitemdatahelper.h> |
|
22 #include <hbdataformmodel.h> |
|
23 #include <hbdataformmodelitem.h> |
|
24 #include <HbView.h> |
|
25 |
|
26 /*! |
|
27 \class TestCpCategorySettingFormItem \n |
|
28 \brief class name: TestCpCategorySettingFormItem \n |
|
29 type of test case: unit test \n |
|
30 test cases' number totally: 3 \n |
|
31 */ |
|
32 |
|
33 void TestCpCategorySettingFormItem::initTestCase() |
|
34 { |
|
35 // initialize public test data here |
|
36 } |
|
37 |
|
38 /*! |
|
39 Test Case Description: \n |
|
40 1. Fucntion Name: \n |
|
41 CpCategorySettingFormItemData(HbDataFormModelItem::DataItemType type, |
|
42 const QString &label, |
|
43 const QString &configFile, |
|
44 const HbDataFormModelItem *parent = 0) \n |
|
45 2. Case Descrition: Test the first constructor function. \n |
|
46 3. Input Parameters: \n |
|
47 (1) type = HbDataFormModelItem::DataItemType, |
|
48 label = QString("XX"), |
|
49 configFile = QString("XX"), |
|
50 parent = new HbDataFormModelItem() \n |
|
51 (2) type = HbDataFormModelItem::DataItemType, |
|
52 label = QString(), |
|
53 configFile = QString(), |
|
54 parent = new HbDataFormModelItem()\n |
|
55 4. Expected result: \n |
|
56 (1) no crash\n |
|
57 (2) no crash \n |
|
58 */ |
|
59 void TestCpCategorySettingFormItem::testFirstConstructor() |
|
60 { |
|
61 HbDataFormModelItem::DataItemType aType = HbDataFormModelItem::CheckBoxItem; |
|
62 QString aLabel = "testLabel"; |
|
63 QString configFile = "testFile"; |
|
64 HbDataFormModelItem *pParent = new HbDataFormModelItem(); |
|
65 |
|
66 CpCategorySettingFormItemData *pCategoryItemData = new CpCategorySettingFormItemData(aType, aLabel, configFile, pParent); |
|
67 QVERIFY(pCategoryItemData != 0 ); |
|
68 QVERIFY(pCategoryItemData->type()== aType); |
|
69 delete pParent; |
|
70 |
|
71 pCategoryItemData = new CpCategorySettingFormItemData(aType, QString(), QString(), 0); |
|
72 QVERIFY(pCategoryItemData != 0 ); |
|
73 QVERIFY(pCategoryItemData->type()== aType); |
|
74 delete pCategoryItemData; |
|
75 } |
|
76 |
|
77 /*! |
|
78 Test Case Description: \n |
|
79 1. Fucntion Name: \n |
|
80 explicit CpCategorySettingFormItemData(const QString &configFile = QString(), const HbDataFormModelItem *parent = 0); |
|
81 2. Case Descrition: \n |
|
82 Test the second constructor function. \n |
|
83 3. Input Parameters: \n |
|
84 (1) configFile = QString("XX"), *parent = new HbDataFormModelItem()\n |
|
85 (2) configFile = QString(""), *parent = new HbDataFormModelItem() \n |
|
86 4. Expected result: \n |
|
87 (1) no crash \n |
|
88 (2) no crash |
|
89 */ |
|
90 void TestCpCategorySettingFormItem::testSecondConstructor() |
|
91 { |
|
92 QString configFile = "testFile"; |
|
93 HbDataFormModelItem *pParent = new HbDataFormModelItem(); |
|
94 CpCategorySettingFormItemData *pCategoryItemData = new CpCategorySettingFormItemData(configFile, pParent); |
|
95 delete pParent; |
|
96 |
|
97 pCategoryItemData = new CpCategorySettingFormItemData(QString(), 0); |
|
98 QVERIFY(pCategoryItemData != 0 ); |
|
99 delete pCategoryItemData; |
|
100 pCategoryItemData = 0; |
|
101 |
|
102 pCategoryItemData = new CpCategorySettingFormItemData(); |
|
103 QVERIFY(pCategoryItemData != 0 ); |
|
104 delete pCategoryItemData; |
|
105 } |
|
106 |
|
107 /*! |
|
108 Test Case Description: \n |
|
109 1. Fucntion Name: void initialize(CpItemDataHelper &itemDataHelper); \n |
|
110 2. Case Descrition: Test the initialize() function. \n |
|
111 3. Input Parameters: (1) itemDataHelper = new itemDataHelper() \n |
|
112 4. Expected result: (1) no crash \n |
|
113 */ |
|
114 void TestCpCategorySettingFormItem::testInit() |
|
115 { |
|
116 CpItemDataHelper *itemDataHelper = new CpItemDataHelper(); |
|
117 QString configFile = "pluginfileformodelitemdata.cpcfg"; |
|
118 HbDataFormModelItem *pParent = new HbDataFormModelItem(); |
|
119 CpCategorySettingFormItemData *pCategoryItemData = new CpCategorySettingFormItemData(configFile, pParent); |
|
120 QVERIFY(pCategoryItemData != 0 ); |
|
121 // mInitialized = FALSE |
|
122 pCategoryItemData->initialize(*itemDataHelper); |
|
123 // call initialize() again in order to test another branch (mInitialized = TRUE) |
|
124 pCategoryItemData->initialize(*itemDataHelper); |
|
125 delete itemDataHelper; |
|
126 delete pParent; |
|
127 } |
|
128 |
|
129 void TestCpCategorySettingFormItem::cleanupTestCase() |
|
130 { |
|
131 // release all test data |
|
132 QCoreApplication::processEvents(); |
|
133 } |
|
134 |
|
135 QTEST_MAIN(TestCpCategorySettingFormItem) |
|
136 //QTEST_APPLESS_MAIN(TestCpCategorySettingFormItem) |
|