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: Test class for CalenDayContainerWidget
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include <QtTest/QtTest>
|
|
18 |
|
|
19 |
#include "calenservices.h"
|
|
20 |
#include "calendateutils.h"
|
|
21 |
#include "calendaymodelmanager.h"
|
75
|
22 |
|
|
23 |
#define private public
|
|
24 |
|
45
|
25 |
#include "calendayview.h"
|
|
26 |
|
|
27 |
class TestCalenDayView : public QObject
|
|
28 |
{
|
|
29 |
Q_OBJECT
|
|
30 |
|
|
31 |
public:
|
|
32 |
TestCalenDayView();
|
|
33 |
virtual ~TestCalenDayView();
|
|
34 |
|
|
35 |
private slots:
|
|
36 |
void initTestCase();
|
|
37 |
void cleanupTestCase();
|
|
38 |
void init();
|
|
39 |
void cleanup();
|
|
40 |
|
|
41 |
void testConstructors();
|
75
|
42 |
void testPopulationComplete();
|
|
43 |
void testDoPopulation();
|
|
44 |
void testOnBack();
|
|
45 |
void testDayChangeStarted();
|
|
46 |
void testRunChangeToAgendaView();
|
|
47 |
void testRunLunarData();
|
|
48 |
void testRunNewMeeting();
|
|
49 |
void testRunGoToToday();
|
|
50 |
void testChangeView();
|
|
51 |
|
|
52 |
|
45
|
53 |
private:
|
|
54 |
CalenDayView *mView;
|
75
|
55 |
MCalenServices mServices;
|
45
|
56 |
};
|
|
57 |
|
|
58 |
/*!
|
|
59 |
Constructor
|
|
60 |
*/
|
|
61 |
TestCalenDayView::TestCalenDayView() :
|
|
62 |
mView(NULL)
|
|
63 |
{
|
|
64 |
|
|
65 |
}
|
|
66 |
|
|
67 |
/*!
|
|
68 |
Destructor
|
|
69 |
*/
|
|
70 |
TestCalenDayView::~TestCalenDayView()
|
|
71 |
{
|
|
72 |
|
|
73 |
}
|
|
74 |
|
|
75 |
/*!
|
|
76 |
Called before testcase
|
|
77 |
*/
|
|
78 |
void TestCalenDayView::initTestCase()
|
|
79 |
{
|
|
80 |
}
|
|
81 |
|
|
82 |
/*!
|
|
83 |
Called after testcase
|
|
84 |
*/
|
|
85 |
void TestCalenDayView::cleanupTestCase()
|
|
86 |
{
|
|
87 |
|
|
88 |
}
|
|
89 |
|
|
90 |
/*!
|
|
91 |
Called before every function
|
|
92 |
*/
|
|
93 |
void TestCalenDayView::init()
|
|
94 |
{
|
75
|
95 |
mServices.IssueCommandL(0);
|
|
96 |
mView = new CalenDayView(mServices);
|
45
|
97 |
}
|
|
98 |
|
|
99 |
/*!
|
|
100 |
Called after everyfunction
|
|
101 |
*/
|
|
102 |
void TestCalenDayView::cleanup()
|
|
103 |
{
|
|
104 |
|
|
105 |
}
|
|
106 |
|
75
|
107 |
/*!
|
|
108 |
Test function for constructors
|
|
109 |
1. Test if content widget is not initialized
|
|
110 |
2. Test if content widget is correcty created
|
|
111 |
*/
|
45
|
112 |
void TestCalenDayView::testConstructors()
|
|
113 |
{
|
|
114 |
MCalenServices services;
|
|
115 |
//1)
|
|
116 |
CalenDayView *testView = 0;
|
|
117 |
QVERIFY(!testView);
|
|
118 |
|
|
119 |
//2)
|
|
120 |
testView = new CalenDayView(services);
|
|
121 |
QVERIFY(testView);
|
|
122 |
|
|
123 |
delete testView;
|
|
124 |
}
|
|
125 |
|
75
|
126 |
/*!
|
|
127 |
Test if population was done.
|
|
128 |
1)Check if there is no command before
|
|
129 |
2)Check if command population complete is send
|
|
130 |
*/
|
|
131 |
void TestCalenDayView::testPopulationComplete()
|
|
132 |
{
|
|
133 |
//1)
|
|
134 |
QVERIFY(mServices.lastCommand() == 0);
|
|
135 |
|
|
136 |
//2)
|
|
137 |
mView->doPopulation();
|
|
138 |
|
|
139 |
QVERIFY(mServices.lastCommand() == ECalenNotifyViewPopulationComplete);
|
|
140 |
}
|
|
141 |
|
|
142 |
/*!
|
|
143 |
Test if population was done.
|
|
144 |
1)Check if there is no command before
|
|
145 |
2)Check if command population complete is send
|
|
146 |
*/
|
|
147 |
void TestCalenDayView::testDoPopulation()
|
|
148 |
{
|
|
149 |
QVERIFY(mServices.lastCommand() == 0);
|
|
150 |
|
|
151 |
mView->populationComplete();
|
|
152 |
|
|
153 |
QVERIFY(mServices.lastCommand() == ECalenNotifyViewPopulationComplete);
|
|
154 |
}
|
|
155 |
|
|
156 |
/*!
|
|
157 |
Test if population was done.
|
|
158 |
1)Check if there is no command before
|
|
159 |
2)Check if command month view is send
|
|
160 |
*/
|
|
161 |
void TestCalenDayView::testOnBack()
|
|
162 |
{
|
|
163 |
#ifndef __WINSCW__
|
|
164 |
QVERIFY(mServices.lastCommand() == 0);
|
|
165 |
|
|
166 |
mView->onBack();
|
|
167 |
|
|
168 |
QVERIFY(mServices.lastCommand() == ECalenMonthView);
|
|
169 |
#endif /*__WINSCW__*/
|
|
170 |
}
|
|
171 |
|
|
172 |
/*!
|
|
173 |
Test if population was done.
|
|
174 |
1)Check if next date is set
|
|
175 |
2)Check if priovor date is set
|
|
176 |
*/
|
|
177 |
void TestCalenDayView::testDayChangeStarted()
|
|
178 |
{
|
|
179 |
#ifndef __WINSCW__
|
|
180 |
mView->mDate = QDateTime(QDate(2010,9,8),QTime(10,10,10));
|
|
181 |
mView->dayChangeStarted(ECalenScrollToNext);
|
|
182 |
|
|
183 |
QVERIFY(mView->mDate == QDateTime(QDate(2010,9,9),QTime(10,10,10)));
|
|
184 |
|
|
185 |
mView->dayChangeStarted(ECalenScrollToPrev);
|
|
186 |
|
|
187 |
QVERIFY(mView->mDate == QDateTime(QDate(2010,9,8),QTime(10,10,10)));
|
|
188 |
#endif /*__WINSCW__*/
|
|
189 |
}
|
|
190 |
|
|
191 |
/*!
|
|
192 |
Test if population was done.
|
|
193 |
1)Check if there is no command before
|
|
194 |
2)Check if command go to agenda view is send
|
|
195 |
*/
|
|
196 |
void TestCalenDayView::testRunChangeToAgendaView()
|
|
197 |
{
|
|
198 |
#ifndef __WINSCW__
|
|
199 |
QVERIFY(mServices.lastCommand() == 0);
|
|
200 |
|
|
201 |
mView->runChangeToAgendaView();
|
|
202 |
|
|
203 |
QVERIFY(mServices.lastCommand() == ECalenAgendaView);
|
|
204 |
#endif /*__WINSCW__*/
|
|
205 |
}
|
|
206 |
|
|
207 |
/*!
|
|
208 |
Test if population was done.
|
|
209 |
1)Check if there is no command before
|
|
210 |
2)Check if command regional info taped is send
|
|
211 |
*/
|
|
212 |
void TestCalenDayView::testRunLunarData()
|
|
213 |
{
|
|
214 |
#ifndef __WINSCW__
|
|
215 |
QVERIFY(mServices.lastCommand() == 0);
|
|
216 |
|
|
217 |
mView->runLunarData();
|
|
218 |
|
|
219 |
QVERIFY(mServices.lastCommand() == ECalenRegionalPluginTapEvent);
|
|
220 |
#endif /*__WINSCW__*/
|
|
221 |
}
|
|
222 |
|
|
223 |
/*!
|
|
224 |
Test if population was done.
|
|
225 |
1)Check if there is no command before
|
|
226 |
2)Check if command new meeting is send
|
|
227 |
*/
|
|
228 |
void TestCalenDayView::testRunNewMeeting()
|
|
229 |
{
|
|
230 |
#ifndef __WINSCW__
|
|
231 |
QVERIFY(mServices.lastCommand() == 0);
|
|
232 |
|
|
233 |
mView->runNewMeeting();
|
|
234 |
|
|
235 |
QVERIFY(mServices.lastCommand() == ECalenNewMeeting);
|
|
236 |
#endif /*__WINSCW__*/
|
|
237 |
}
|
|
238 |
|
|
239 |
/*!
|
|
240 |
Test if population was done.
|
|
241 |
1)Check if there is no command before
|
|
242 |
2)Check if command go to today is send
|
|
243 |
*/
|
|
244 |
void TestCalenDayView::testRunGoToToday()
|
|
245 |
{
|
|
246 |
#ifndef __WINSCW__
|
|
247 |
QVERIFY(mServices.lastCommand() == 0);
|
|
248 |
|
|
249 |
mView->runGoToToday();
|
|
250 |
|
|
251 |
QVERIFY(mServices.lastCommand() == ECalenGotoToday);
|
|
252 |
#endif /*__WINSCW__*/
|
|
253 |
}
|
|
254 |
|
|
255 |
/*!
|
|
256 |
Test if population was done.
|
|
257 |
1)Check if there is no command before
|
|
258 |
2)Check if command givenn command is send
|
|
259 |
*/
|
|
260 |
void TestCalenDayView::testChangeView()
|
|
261 |
{
|
|
262 |
QVERIFY(mServices.lastCommand() == 0);
|
|
263 |
|
|
264 |
mView->changeView(ECalenAgendaView);
|
|
265 |
|
|
266 |
QVERIFY(mServices.lastCommand() == ECalenAgendaView);
|
|
267 |
}
|
|
268 |
|
57
|
269 |
QTEST_MAIN(TestCalenDayView);
|
45
|
270 |
|
|
271 |
#include "unittest_calendayview.moc"
|