45
|
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 <QGraphicsItem>
|
|
18 |
#include <hbmodeliterator.h>
|
|
19 |
#include <QtTest/QtTest>
|
|
20 |
|
|
21 |
#include "calenservices.h"
|
57
|
22 |
|
|
23 |
#include <hbabstractitemview.h>
|
|
24 |
#include <hbmenu.h>
|
|
25 |
|
|
26 |
#define private public
|
|
27 |
|
45
|
28 |
#include "calendayitemview.h"
|
|
29 |
|
57
|
30 |
|
45
|
31 |
// Test variables
|
|
32 |
QRectF gTestWindowRect = QRectF(0, 0, 10, 20);
|
|
33 |
Qt::Orientation gTestOrientation = Qt::Horizontal;
|
57
|
34 |
quint32 SELECTED_COMMAND = 0;
|
45
|
35 |
|
|
36 |
class TestCalenItemView : public QObject
|
|
37 |
{
|
|
38 |
Q_OBJECT
|
|
39 |
|
|
40 |
public:
|
|
41 |
TestCalenItemView();
|
|
42 |
virtual ~TestCalenItemView();
|
|
43 |
|
|
44 |
private slots:
|
|
45 |
void initTestCase();
|
|
46 |
void cleanupTestCase();
|
|
47 |
void init();
|
|
48 |
void cleanup();
|
|
49 |
|
|
50 |
void testConstructors();
|
57
|
51 |
void testIssueCommandOnSelectedItem();
|
|
52 |
void testOpenSelectedItem();
|
|
53 |
void testEditSelectedItem();
|
|
54 |
void testDeleteSelectedItem();
|
45
|
55 |
private:
|
|
56 |
MCalenServices mMCalenServices;
|
57
|
57 |
CalenDayItemView *mCalenDayItemView;
|
45
|
58 |
|
|
59 |
};
|
|
60 |
|
|
61 |
/*!
|
|
62 |
Constructor
|
|
63 |
*/
|
|
64 |
TestCalenItemView::TestCalenItemView()
|
|
65 |
{
|
|
66 |
|
|
67 |
}
|
|
68 |
|
|
69 |
/*!
|
|
70 |
Destructor
|
|
71 |
*/
|
|
72 |
TestCalenItemView::~TestCalenItemView()
|
|
73 |
{
|
|
74 |
|
|
75 |
}
|
|
76 |
|
|
77 |
/*!
|
|
78 |
Called before testcase
|
|
79 |
*/
|
|
80 |
void TestCalenItemView::initTestCase()
|
|
81 |
{
|
57
|
82 |
|
45
|
83 |
}
|
|
84 |
|
|
85 |
/*!
|
|
86 |
Called after testcase
|
|
87 |
*/
|
|
88 |
void TestCalenItemView::cleanupTestCase()
|
|
89 |
{
|
|
90 |
|
|
91 |
}
|
|
92 |
|
|
93 |
/*!
|
|
94 |
Called before every function
|
|
95 |
*/
|
|
96 |
void TestCalenItemView::init()
|
|
97 |
{
|
57
|
98 |
HbModelIterator *iterator = new HbModelIterator();
|
|
99 |
mCalenDayItemView = new CalenDayItemView(mMCalenServices,iterator,0);
|
|
100 |
SELECTED_COMMAND = 0;
|
45
|
101 |
}
|
|
102 |
|
|
103 |
/*!
|
|
104 |
Called after everyfunction
|
|
105 |
*/
|
|
106 |
void TestCalenItemView::cleanup()
|
|
107 |
{
|
57
|
108 |
if(mCalenDayItemView){
|
|
109 |
delete mCalenDayItemView;
|
|
110 |
mCalenDayItemView = NULL;
|
|
111 |
}
|
45
|
112 |
}
|
|
113 |
|
|
114 |
/*!
|
|
115 |
Test function for constructors
|
|
116 |
1. Test if content widget is not initialized
|
|
117 |
2. Test if content widget is correcty created
|
|
118 |
*/
|
|
119 |
void TestCalenItemView::testConstructors()
|
|
120 |
{
|
|
121 |
//1)
|
|
122 |
CalenDayItemView *testItemView = 0;
|
|
123 |
QVERIFY(!testItemView);
|
|
124 |
|
|
125 |
//2)
|
|
126 |
HbModelIterator *iterator = new HbModelIterator();
|
|
127 |
testItemView = new CalenDayItemView(mMCalenServices,iterator,0);
|
|
128 |
QVERIFY(testItemView);
|
|
129 |
delete testItemView;
|
|
130 |
}
|
|
131 |
|
57
|
132 |
void TestCalenItemView::testIssueCommandOnSelectedItem()
|
|
133 |
{
|
|
134 |
#ifndef __WINSCW__
|
|
135 |
mCalenDayItemView->issueCommandOnSelectedItem((quint32)ECalenEventView);
|
|
136 |
QCOMPARE(SELECTED_COMMAND,(quint32)ECalenEventView);
|
|
137 |
#endif
|
|
138 |
}
|
|
139 |
|
|
140 |
void TestCalenItemView::testOpenSelectedItem()
|
|
141 |
{
|
|
142 |
#ifndef __WINSCW__
|
|
143 |
mCalenDayItemView->openSelectedItem();
|
|
144 |
QCOMPARE(SELECTED_COMMAND,(quint32)ECalenEventView);
|
|
145 |
#endif
|
|
146 |
}
|
|
147 |
|
|
148 |
void TestCalenItemView::testEditSelectedItem()
|
|
149 |
{
|
|
150 |
#ifndef __WINSCW__
|
|
151 |
mCalenDayItemView->editSelectedItem();
|
|
152 |
QCOMPARE(SELECTED_COMMAND,(quint32)ECalenEditCurrentEntry);
|
|
153 |
#endif
|
|
154 |
}
|
|
155 |
|
|
156 |
void TestCalenItemView::testDeleteSelectedItem()
|
|
157 |
{
|
|
158 |
#ifndef __WINSCW__
|
|
159 |
mCalenDayItemView->deleteSelectedItem();
|
|
160 |
QCOMPARE(SELECTED_COMMAND,(quint32)ECalenDeleteCurrentEntry);
|
|
161 |
#endif
|
|
162 |
}
|
|
163 |
|
45
|
164 |
QTEST_MAIN(TestCalenItemView);
|
|
165 |
#include "unittest_calendayitemview.moc"
|