31
|
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 |
#include "ut_cpapi.h"
|
|
18 |
|
|
19 |
#include <hbmainwindow.h>
|
|
20 |
#include <QGraphicsWidget>
|
|
21 |
#include <qDebug>
|
|
22 |
#include <QtTest/QtTest>
|
32
|
23 |
#include <QtAlgorithms>
|
31
|
24 |
#include <HbView.h>
|
|
25 |
#include <hbdataform.h>
|
|
26 |
#include <hbdataformmodel.h>
|
|
27 |
#include <hbdataformmodelitem.h>
|
|
28 |
#include <hbabstractviewitem.h>
|
|
29 |
#include <hbsettingformitem.h>
|
32
|
30 |
#include <hbpushbutton.h>
|
31
|
31 |
//testing following classes
|
|
32 |
|
|
33 |
#include "cpbasesettingview.h"
|
|
34 |
#include "cpsettingformentryitemdata.h"
|
|
35 |
#include "cpsettingformentryitemdataimpl.h"
|
|
36 |
#include <cpsettingformitemdata.h>
|
|
37 |
#include <cpitemdatahelper.h>
|
32
|
38 |
#include <cppluginutility.h>
|
|
39 |
#include <cppluginloader.h>
|
|
40 |
#include <cpplugininterface.h>
|
|
41 |
#include <cplogger.h>
|
31
|
42 |
|
|
43 |
void TestCpAPI::initTestCase()
|
|
44 |
{
|
|
45 |
mainWindow = new HbMainWindow;
|
|
46 |
mainWindow->show();
|
|
47 |
}
|
|
48 |
|
|
49 |
void TestCpAPI::cleanupTestCase()
|
|
50 |
{
|
|
51 |
delete mainWindow;
|
|
52 |
mainWindow = 0;
|
|
53 |
}
|
|
54 |
void TestCpAPI::testCpBaseSettingView()
|
|
55 |
{
|
|
56 |
CpBaseSettingView * pview = new CpBaseSettingView(0);
|
32
|
57 |
QVERIFY( pview != 0 );
|
31
|
58 |
HbDataForm *pForm = new HbDataForm(0);
|
|
59 |
pview->setSettingForm(pForm);
|
|
60 |
QVERIFY( pview->settingForm() == pForm );
|
|
61 |
delete pview;
|
32
|
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 |
|
31
|
70 |
}
|
|
71 |
|
|
72 |
void TestCpAPI::testCpSettingFormEntryItemDataImpl()
|
|
73 |
{
|
|
74 |
CpItemDataHelper *pHelper = new CpItemDataHelper();
|
|
75 |
CpSettingFormEntryItemDataImpl<CpBaseSettingView> *pdataimp = new CpSettingFormEntryItemDataImpl<CpBaseSettingView>( *pHelper, "text", "description" );
|
|
76 |
QVERIFY( pdataimp !=0 );
|
|
77 |
QString strtxt = "input texts";
|
|
78 |
pdataimp->setText(strtxt);
|
|
79 |
QVERIFY( pdataimp->text() == strtxt );
|
|
80 |
|
|
81 |
QString strDes = "input descriptions";
|
|
82 |
pdataimp->setDescription(strDes);
|
|
83 |
QVERIFY( pdataimp->description() == strDes);
|
|
84 |
delete pdataimp;
|
|
85 |
delete pHelper;
|
|
86 |
}
|
|
87 |
void TestCpAPI::testCpSettingFormItemData()
|
|
88 |
{
|
|
89 |
CpSettingFormItemData *pdata = new CpSettingFormItemData( HbDataFormModelItem::TextItem, "label" );
|
|
90 |
QVERIFY( pdata !=0 );
|
|
91 |
delete pdata;
|
|
92 |
pdata = 0;
|
|
93 |
pdata = new CpSettingFormItemData( HbDataFormModelItem::SliderItem, "label" );
|
|
94 |
QVERIFY( pdata !=0 );
|
|
95 |
delete pdata;
|
|
96 |
pdata = 0;
|
|
97 |
pdata = new CpSettingFormItemData( HbDataFormModelItem::VolumeSliderItem, "label" );
|
|
98 |
QVERIFY( pdata !=0 );
|
|
99 |
delete pdata;
|
|
100 |
pdata = new CpSettingFormItemData( HbDataFormModelItem::CheckBoxItem, "label" );
|
|
101 |
QVERIFY( pdata !=0 );
|
|
102 |
delete pdata;
|
|
103 |
pdata = 0;
|
|
104 |
pdata = new CpSettingFormItemData( HbDataFormModelItem::ToggleValueItem, "label" );
|
|
105 |
QVERIFY( pdata !=0 );
|
|
106 |
delete pdata;
|
|
107 |
pdata = 0;
|
|
108 |
pdata = new CpSettingFormItemData( HbDataFormModelItem::RadioButtonListItem, "label" );
|
|
109 |
QVERIFY( pdata !=0 );
|
|
110 |
delete pdata;
|
|
111 |
pdata = 0;
|
|
112 |
pdata = new CpSettingFormItemData( HbDataFormModelItem::MultiselectionItem, "label" );
|
|
113 |
QVERIFY( pdata !=0 );
|
|
114 |
delete pdata;
|
|
115 |
pdata = 0;
|
|
116 |
pdata = new CpSettingFormItemData( HbDataFormModelItem::ComboBoxItem, "label" );
|
|
117 |
QVERIFY( pdata !=0 );
|
|
118 |
delete pdata;
|
|
119 |
pdata = 0;
|
|
120 |
}
|
|
121 |
void TestCpAPI::testItemDataHelper()
|
|
122 |
{
|
|
123 |
HbDataForm* form = new HbDataForm();
|
|
124 |
HbDataFormModel *model = new HbDataFormModel();
|
|
125 |
HbDataFormModelItem *general = model->appendDataFormPage(QString("General"));
|
|
126 |
CpItemDataHelper *phelper = new CpItemDataHelper();
|
|
127 |
phelper->addConnection( general, "hello",form,"hello");
|
|
128 |
phelper->removeConnection(general,"hello",form, "hello");
|
|
129 |
phelper->bindToForm(form);
|
|
130 |
HbSettingFormItem *pitem = new HbSettingFormItem();
|
|
131 |
phelper->addItemPrototype(pitem);
|
|
132 |
delete phelper;
|
|
133 |
}
|
32
|
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 |
|
31
|
179 |
QTEST_MAIN(TestCpAPI)
|