18 |
18 |
19 #include <hbmainwindow.h> |
19 #include <hbmainwindow.h> |
20 #include <QGraphicsWidget> |
20 #include <QGraphicsWidget> |
21 #include <qDebug> |
21 #include <qDebug> |
22 #include <QtTest/QtTest> |
22 #include <QtTest/QtTest> |
|
23 #include <QtAlgorithms> |
23 #include <HbView.h> |
24 #include <HbView.h> |
24 #include <hbdataform.h> |
25 #include <hbdataform.h> |
25 #include <hbdataformmodel.h> |
26 #include <hbdataformmodel.h> |
26 #include <hbdataformmodelitem.h> |
27 #include <hbdataformmodelitem.h> |
27 #include <hbabstractviewitem.h> |
28 #include <hbabstractviewitem.h> |
28 #include <hbsettingformitem.h> |
29 #include <hbsettingformitem.h> |
|
30 #include <hbpushbutton.h> |
29 //testing following classes |
31 //testing following classes |
30 |
32 |
31 #include "cpbasesettingview.h" |
33 #include "cpbasesettingview.h" |
32 #include "cpsettingformentryitemdata.h" |
34 #include "cpsettingformentryitemdata.h" |
33 #include "cpsettingformentryitemdataimpl.h" |
35 #include "cpsettingformentryitemdataimpl.h" |
34 #include <cpsettingformitemdata.h> |
36 #include <cpsettingformitemdata.h> |
35 #include <cpitemdatahelper.h> |
37 #include <cpitemdatahelper.h> |
|
38 #include <cppluginutility.h> |
|
39 #include <cppluginloader.h> |
|
40 #include <cpplugininterface.h> |
|
41 #include <cplogger.h> |
36 |
42 |
37 void TestCpAPI::initTestCase() |
43 void TestCpAPI::initTestCase() |
38 { |
44 { |
39 mainWindow = new HbMainWindow; |
45 mainWindow = new HbMainWindow; |
40 mainWindow->show(); |
46 mainWindow->show(); |
46 mainWindow = 0; |
52 mainWindow = 0; |
47 } |
53 } |
48 void TestCpAPI::testCpBaseSettingView() |
54 void TestCpAPI::testCpBaseSettingView() |
49 { |
55 { |
50 CpBaseSettingView * pview = new CpBaseSettingView(0); |
56 CpBaseSettingView * pview = new CpBaseSettingView(0); |
51 QVERIFY( pview !=0 ); |
57 QVERIFY( pview != 0 ); |
52 HbDataForm *pForm = new HbDataForm(0); |
58 HbDataForm *pForm = new HbDataForm(0); |
53 pview->setSettingForm(pForm); |
59 pview->setSettingForm(pForm); |
54 QVERIFY( pview->settingForm() == pForm ); |
60 QVERIFY( pview->settingForm() == pForm ); |
55 delete pview; |
61 delete pview; |
|
62 HbPushButton *widget = new HbPushButton(); |
|
63 QVERIFY(widget != 0); |
|
64 CpBaseSettingView *pView1 = new CpBaseSettingView(widget); |
|
65 QVERIFY(pView1!=0); |
|
66 HbPushButton *button = qobject_cast<HbPushButton *>(pView1->widget()); |
|
67 QVERIFY(button != 0); |
|
68 delete pView1; |
|
69 |
56 } |
70 } |
57 |
71 |
58 void TestCpAPI::testCpSettingFormEntryItemDataImpl() |
72 void TestCpAPI::testCpSettingFormEntryItemDataImpl() |
59 { |
73 { |
60 CpItemDataHelper *pHelper = new CpItemDataHelper(); |
74 CpItemDataHelper *pHelper = new CpItemDataHelper(); |
115 phelper->bindToForm(form); |
129 phelper->bindToForm(form); |
116 HbSettingFormItem *pitem = new HbSettingFormItem(); |
130 HbSettingFormItem *pitem = new HbSettingFormItem(); |
117 phelper->addItemPrototype(pitem); |
131 phelper->addItemPrototype(pitem); |
118 delete phelper; |
132 delete phelper; |
119 } |
133 } |
|
134 void TestCpAPI::testCpPluginUtility() |
|
135 { |
|
136 HbDataForm* form = new HbDataForm(); |
|
137 QList<HbAbstractViewItem *> oldList = form->itemPrototypes(); |
|
138 CpPluginUtility::addCpItemPrototype(form); |
|
139 QList<HbAbstractViewItem *> newList = form->itemPrototypes(); |
|
140 QVERIFY( oldList.count() == newList.count()-1 ); |
|
141 } |
|
142 |
|
143 void TestCpAPI::testCpPluginLoader() |
|
144 { |
|
145 CpPluginInterface *plugin = CpPluginLoader::loadCpPlugin("non_existing_plugin.dll"); |
|
146 QVERIFY(plugin == 0); |
|
147 |
|
148 plugin = CpPluginLoader::loadCpPlugin("cppincodeplugin"); |
|
149 QVERIFY(plugin != 0); |
|
150 |
|
151 plugin = CpPluginLoader::loadCpPlugin("cppincodeplugin.dll"); |
|
152 QVERIFY(plugin != 0); |
|
153 |
|
154 plugin = CpPluginLoader::loadCpPlugin("cppincodeplugin.qtplugin"); |
|
155 QVERIFY(plugin != 0); |
|
156 } |
|
157 |
|
158 void TestCpAPI::testCpPluginInterface() |
|
159 { |
|
160 CpPluginInterface *plugin = CpPluginLoader::loadCpPlugin("cppersonalizationplugin.dll"); |
|
161 if (plugin) { |
|
162 CpItemDataHelper helper; |
|
163 QList<CpSettingFormItemData*> itemData = plugin->createSettingFormItemData(helper); |
|
164 QVERIFY(itemData.size() > 0); |
|
165 qDeleteAll(itemData.begin(),itemData.end()); |
|
166 itemData.clear(); |
|
167 } |
|
168 } |
|
169 |
|
170 void TestCpAPI::testCpLogger() |
|
171 { |
|
172 const QString logConf = "C:/data/.config/ut_cpapi/controlpanellog.conf"; |
|
173 Logger::instance(CPFW_LOGGER_NAME)->configure(logConf,QSettings::IniFormat); |
|
174 CPFW_LOG("Hello World!"); |
|
175 Logger::closeAll(); |
|
176 } |
|
177 |
|
178 |
120 QTEST_MAIN(TestCpAPI) |
179 QTEST_MAIN(TestCpAPI) |