55
|
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 control panel public apis.
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "ut_cpbasesettingview.h"
|
|
19 |
|
|
20 |
#include "cpbasesettingview.h"
|
|
21 |
#include "mycpbasesettingview.h"
|
|
22 |
|
|
23 |
#include <QtTest/QtTest>
|
|
24 |
#include <hbdataform.h>
|
|
25 |
#include <hbpushbutton.h>
|
|
26 |
|
|
27 |
/*!
|
|
28 |
\class TestCpBaseSettingView
|
|
29 |
\brief \n
|
|
30 |
The TestCpBaseSettingView is used for the unit testing for CpBaseSettingView class.
|
|
31 |
This unit test is supported by QTest.
|
|
32 |
There are 3 test cases for this unit.
|
|
33 |
*/
|
|
34 |
|
|
35 |
void TestCpBaseSettingView::initTestCase()
|
|
36 |
{
|
|
37 |
|
|
38 |
}
|
|
39 |
|
|
40 |
void TestCpBaseSettingView::cleanupTestCase()
|
|
41 |
{
|
|
42 |
QCoreApplication::processEvents();
|
|
43 |
}
|
|
44 |
|
|
45 |
/*!
|
|
46 |
* Test Case Description:\n
|
|
47 |
* 1. Fucntion Name: CpBaseSettingView() \n
|
|
48 |
2. Function Descrition: \n
|
|
49 |
2.1 Create CpBaseSettingView object with 0 pointer.\n
|
|
50 |
2.2 call setWidget to set a widget into the view object.\n
|
|
51 |
2.3 verify widget object is set correctly.\n
|
|
52 |
2.4 delete the object.\n
|
|
53 |
3. Input Parameters: \n
|
|
54 |
@param: 0\n
|
|
55 |
4. Expected result: \n
|
|
56 |
CpBaseSettingView object created successfully.\n
|
|
57 |
*/
|
|
58 |
void TestCpBaseSettingView::testCpBaseSettingViewWithNullPointer()
|
|
59 |
{
|
|
60 |
CpBaseSettingView * pView = new CpBaseSettingView(0);
|
|
61 |
QVERIFY( pView != 0 );
|
|
62 |
|
|
63 |
HbDataForm *pForm = new HbDataForm(0);
|
|
64 |
pView->setWidget(pForm);
|
|
65 |
HbDataForm *pForm1 = qobject_cast<HbDataForm *>(pView->widget());
|
|
66 |
QVERIFY( pForm1 != 0);
|
|
67 |
QVERIFY( pForm1 == pForm );
|
|
68 |
|
|
69 |
delete pView;
|
|
70 |
pView = 0;
|
|
71 |
}
|
|
72 |
|
|
73 |
/*!
|
|
74 |
* Test Case Description:\n
|
|
75 |
* 1. Fucntion Name: CpBaseSettingView() \n
|
|
76 |
2. Function Descrition: \n
|
|
77 |
2.1 Create CpBaseSettingView object with a widget pointer.\n
|
|
78 |
2.2 verify widget object is set correctly.\n
|
|
79 |
2.3 delete the object.\n
|
|
80 |
3. Input Parameters: \n
|
|
81 |
@param: widget pointer. \n
|
|
82 |
4. Expected result: \n
|
|
83 |
CpBaseSettingView object created successfully.\n
|
|
84 |
*/
|
|
85 |
void TestCpBaseSettingView::testCpBaseSettingViewWithPushButtonWidget()
|
|
86 |
{
|
|
87 |
HbPushButton *widget = new HbPushButton();
|
|
88 |
QVERIFY(widget != 0);
|
|
89 |
|
|
90 |
CpBaseSettingView *pView1 = new CpBaseSettingView(widget);
|
|
91 |
QVERIFY(pView1!=0);
|
|
92 |
|
|
93 |
HbPushButton *button = qobject_cast<HbPushButton *>(pView1->widget());
|
|
94 |
QVERIFY(button != 0);
|
|
95 |
QVERIFY(button == widget);
|
|
96 |
|
|
97 |
delete pView1;
|
|
98 |
pView1 = 0;
|
|
99 |
}
|
|
100 |
|
|
101 |
/*!
|
|
102 |
* Test protected close() function, must be called in derived class
|
|
103 |
*/
|
|
104 |
/*!
|
|
105 |
* Test Case Description:\n
|
|
106 |
* 1. Fucntion Name: close() \n
|
|
107 |
2. Function Descrition: \n
|
|
108 |
2.1 Declare a derived class, MyCpBaseSettingView, create a MyCpBaseSettingView object with default constructor.\n
|
|
109 |
2.2 call close().\n
|
|
110 |
2.3 delete the object.\n
|
|
111 |
3. Input Parameters: \n
|
|
112 |
@param: 0\n
|
|
113 |
4. Expected result: \n
|
|
114 |
view closed.\n
|
|
115 |
*/
|
|
116 |
void TestCpBaseSettingView::testCloseWithoutParam()
|
|
117 |
{
|
|
118 |
MyCpBaseSettingView * pMyView = new MyCpBaseSettingView();
|
|
119 |
QVERIFY( pMyView != 0 );
|
|
120 |
HbDataForm *pForm = new HbDataForm(0);
|
|
121 |
pMyView->setWidget(pForm);
|
|
122 |
HbDataForm *pForm1 = qobject_cast<HbDataForm *>(pMyView->widget());
|
|
123 |
QVERIFY( pForm1 != 0);
|
|
124 |
QVERIFY( pForm1 == pForm );
|
|
125 |
|
|
126 |
pMyView->close();
|
|
127 |
|
|
128 |
delete pMyView;
|
|
129 |
pMyView = 0;
|
|
130 |
}
|
|
131 |
|
|
132 |
void TestCpBaseSettingView::testPrivateFunc()
|
|
133 |
{
|
|
134 |
MyCpBaseSettingView * pMyView = new MyCpBaseSettingView();
|
|
135 |
QVERIFY( pMyView != 0 );
|
|
136 |
pMyView->testprivate();
|
|
137 |
|
|
138 |
delete pMyView;
|
|
139 |
pMyView = 0;
|
|
140 |
}
|
|
141 |
|
|
142 |
QTEST_MAIN(TestCpBaseSettingView)
|