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