37
|
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 |
|
|
18 |
#include "ut_cpdivertselectionitem.h"
|
|
19 |
#include "qtestmains60ui.h"
|
|
20 |
#include <HbDataFormModel>
|
|
21 |
#include <HbWidget>
|
|
22 |
#include <HbDataForm>
|
|
23 |
#include "cpdivertselectioncustomitem.h"
|
|
24 |
|
|
25 |
#define protected public
|
|
26 |
#define private public
|
|
27 |
#include "cpdivertselectionitem.h"
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
/*!
|
|
32 |
UT_CpDivertSelectionItem::UT_CpDivertSelectionItem
|
|
33 |
*/
|
|
34 |
UT_CpDivertSelectionItem::UT_CpDivertSelectionItem()
|
|
35 |
: m_item(NULL)
|
|
36 |
{
|
|
37 |
|
|
38 |
}
|
|
39 |
|
|
40 |
/*!
|
|
41 |
UT_CpDivertSelectionItem::~UT_CpDivertSelectionItem
|
|
42 |
*/
|
|
43 |
UT_CpDivertSelectionItem::~UT_CpDivertSelectionItem()
|
|
44 |
{
|
|
45 |
|
|
46 |
}
|
|
47 |
|
|
48 |
/*!
|
|
49 |
UT_CpDivertSelectionItem::init
|
|
50 |
*/
|
|
51 |
void UT_CpDivertSelectionItem::init()
|
|
52 |
{
|
|
53 |
initialize();
|
|
54 |
m_item = new CpDivertSelectionItem();
|
|
55 |
m_form = new HbDataForm;
|
|
56 |
m_form->setModel(new HbDataFormModel);
|
|
57 |
|
|
58 |
QList<HbAbstractViewItem *> prototypes = m_form->itemPrototypes();
|
|
59 |
prototypes.append(m_item);
|
|
60 |
m_form->setItemPrototypes(prototypes);
|
|
61 |
}
|
|
62 |
|
|
63 |
/*!
|
|
64 |
UT_CpDivertSelectionItem::cleanup
|
|
65 |
*/
|
|
66 |
void UT_CpDivertSelectionItem::cleanup()
|
|
67 |
{
|
|
68 |
reset();
|
|
69 |
if (m_form) {
|
|
70 |
delete m_form->model();
|
|
71 |
}
|
|
72 |
delete m_form;
|
|
73 |
m_form = NULL;
|
|
74 |
}
|
|
75 |
|
|
76 |
/*!
|
|
77 |
UT_CpDivertSelectionItem::t_memleak
|
|
78 |
*/
|
|
79 |
void UT_CpDivertSelectionItem::t_memleak()
|
|
80 |
{
|
|
81 |
|
|
82 |
}
|
|
83 |
|
|
84 |
/*!
|
|
85 |
UT_CpDivertSelectionItem::t_createItem
|
|
86 |
*/
|
|
87 |
void UT_CpDivertSelectionItem::t_createItem()
|
|
88 |
{
|
|
89 |
delete m_item->createItem();
|
|
90 |
}
|
|
91 |
|
|
92 |
/*!
|
|
93 |
UT_CpDivertSelectionItem::t_canSetModelIndex
|
|
94 |
*/
|
|
95 |
void UT_CpDivertSelectionItem::t_canSetModelIndex()
|
|
96 |
{
|
|
97 |
QModelIndex index = qobject_cast<HbDataFormModel*>(m_form->model())->indexFromItem(
|
|
98 |
qobject_cast<HbDataFormModel*>(m_form->model())->appendDataFormItem(
|
|
99 |
HbDataFormModelItem::TextItem, "test"));
|
|
100 |
|
|
101 |
QVERIFY( !m_item->canSetModelIndex(index) );
|
|
102 |
|
|
103 |
index = qobject_cast<HbDataFormModel*>(m_form->model())->indexFromItem(
|
|
104 |
qobject_cast<HbDataFormModel*>(m_form->model())->appendDataFormItem(
|
|
105 |
static_cast<HbDataFormModelItem::DataItemType>(
|
|
106 |
CpDivertSelectionItem::CpDivertSelectionItemId),
|
|
107 |
"test2"));
|
|
108 |
|
|
109 |
QVERIFY( m_item->canSetModelIndex(index) );
|
|
110 |
}
|
|
111 |
|
|
112 |
/*!
|
|
113 |
UT_CpDivertSelectionItem::t_createCustomWidget
|
|
114 |
*/
|
|
115 |
void UT_CpDivertSelectionItem::t_createCustomWidget()
|
|
116 |
{
|
|
117 |
QVERIFY( !m_item->createCustomWidget() );
|
|
118 |
|
|
119 |
QModelIndex index = qobject_cast<HbDataFormModel*>(m_form->model())->indexFromItem(
|
|
120 |
qobject_cast<HbDataFormModel*>(m_form->model())->appendDataFormItem(
|
|
121 |
static_cast<HbDataFormModelItem::DataItemType>(
|
|
122 |
CpDivertSelectionItem::CpDivertSelectionItemId),
|
|
123 |
"test3"));
|
|
124 |
|
|
125 |
m_item->setModelIndex(index);
|
|
126 |
HbWidget *widget=NULL;
|
|
127 |
QVERIFY( widget = m_item->createCustomWidget() );
|
|
128 |
QVERIFY( widget->setProperty("number", "12345") );
|
|
129 |
QVERIFY( widget->property("number").toString() == QString("12345") );
|
|
130 |
|
|
131 |
QVERIFY( widget->setProperty("timeoutText", "Delay:") );
|
|
132 |
QVERIFY( widget->property("timeoutText").toString() == QString("Delay:") );
|
|
133 |
|
|
134 |
QVERIFY( widget->setProperty("timeout", "25") );
|
|
135 |
QVERIFY( widget->property("timeout").toInt() == 25 );
|
|
136 |
|
|
137 |
QVERIFY( widget->setProperty("state", "0"));
|
|
138 |
QVERIFY( widget->property("state").toInt()
|
|
139 |
== CpDivertSelectionCustomitem::Enabled);
|
|
140 |
QVERIFY( widget->setProperty("state", "1"));
|
|
141 |
QVERIFY( widget->property("state").toInt()
|
|
142 |
== CpDivertSelectionCustomitem::Deactivated);
|
|
143 |
QVERIFY( widget->setProperty("state", "2"));
|
|
144 |
QVERIFY( widget->property("state").toInt()
|
|
145 |
== CpDivertSelectionCustomitem::Disabled);
|
|
146 |
|
|
147 |
delete widget;
|
|
148 |
}
|
|
149 |
|
|
150 |
QTEST_MAIN_S60UI(UT_CpDivertSelectionItem)
|