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 |
*
|
57
|
14 |
* Description: Test class for CalenDayContainer
|
45
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include <QtTest/QtTest>
|
|
18 |
|
57
|
19 |
#include <HbEffect>
|
|
20 |
#include <HbWidget>
|
|
21 |
#include <HbAbstractViewItem>
|
|
22 |
|
|
23 |
#include "calendayinfo.h"
|
|
24 |
#include "calendaymodel.h"
|
81
|
25 |
#include "calendayitem.h"
|
57
|
26 |
|
|
27 |
#define private public
|
|
28 |
|
|
29 |
#include "calendaycontainertest.h"
|
|
30 |
|
|
31 |
QVariantList MOCK_EVENTS_LIST;
|
|
32 |
QDateTime MOCK_EVENTS_DATE;
|
45
|
33 |
|
|
34 |
// Test variables
|
|
35 |
QRectF gTestWindowRect = QRectF(0, 0, 10, 20);
|
57
|
36 |
Qt::Orientation gTestOrientation = Qt::Vertical;
|
45
|
37 |
|
|
38 |
class TestCalenDayContainer : public QObject
|
|
39 |
{
|
|
40 |
Q_OBJECT
|
|
41 |
|
|
42 |
public:
|
|
43 |
TestCalenDayContainer();
|
|
44 |
virtual ~TestCalenDayContainer();
|
|
45 |
|
|
46 |
private slots:
|
|
47 |
void initTestCase();
|
|
48 |
void cleanupTestCase();
|
|
49 |
void init();
|
|
50 |
void cleanup();
|
|
51 |
|
|
52 |
void testConstructors();
|
57
|
53 |
void testSetGetDayInfo();
|
81
|
54 |
void testSetGetDate();
|
57
|
55 |
void testItemAdded();
|
|
56 |
void testItemRemoved();
|
|
57 |
void testReset();
|
|
58 |
void testViewResized();
|
|
59 |
void testOrientationChanged();
|
|
60 |
void testCreateDefaultPrototype();
|
|
61 |
void testGetTimedEventLayoutValues();
|
|
62 |
void testCreateTouchEventAbsorbers();
|
|
63 |
void testCrateAbsorberBetweenSlots();
|
|
64 |
|
45
|
65 |
|
|
66 |
private:
|
57
|
67 |
CalenDayContainerTest *mContainer;
|
|
68 |
CalenDayInfo *mInfo;
|
45
|
69 |
};
|
|
70 |
|
|
71 |
/*!
|
|
72 |
Constructor
|
|
73 |
*/
|
|
74 |
TestCalenDayContainer::TestCalenDayContainer() :
|
57
|
75 |
mContainer(NULL), mInfo(NULL)
|
45
|
76 |
{
|
|
77 |
|
|
78 |
}
|
|
79 |
|
|
80 |
/*!
|
|
81 |
Destructor
|
|
82 |
*/
|
|
83 |
TestCalenDayContainer::~TestCalenDayContainer()
|
|
84 |
{
|
|
85 |
|
|
86 |
}
|
|
87 |
|
|
88 |
/*!
|
|
89 |
Called before testcase
|
|
90 |
*/
|
|
91 |
void TestCalenDayContainer::initTestCase()
|
|
92 |
{
|
|
93 |
}
|
|
94 |
|
|
95 |
/*!
|
|
96 |
Called after testcase
|
|
97 |
*/
|
|
98 |
void TestCalenDayContainer::cleanupTestCase()
|
|
99 |
{
|
|
100 |
|
|
101 |
}
|
|
102 |
|
|
103 |
/*!
|
|
104 |
Called before every function
|
|
105 |
*/
|
|
106 |
void TestCalenDayContainer::init()
|
|
107 |
{
|
57
|
108 |
mContainer = new CalenDayContainerTest();
|
|
109 |
mInfo = new CalenDayInfo(CalenDayInfo::EOne);
|
|
110 |
|
|
111 |
|
|
112 |
MOCK_EVENTS_DATE = QDateTime(QDate(12,07,2010),QTime(6,0));
|
|
113 |
|
|
114 |
QDateTime dateTimeStart1(QDate(12,07,2010),QTime(7,0));
|
|
115 |
QDateTime dateTimeEnd1(QDate(12,07,2010),QTime(10,0));
|
|
116 |
QDateTime dateTimeStart2(QDate(12,07,2010),QTime(11,0));
|
|
117 |
QDateTime dateTimeEnd2(QDate(12,07,2010),QTime(12,0));
|
|
118 |
QDateTime dateTimeStart3(QDate(12,07,2010),QTime(12,45));
|
|
119 |
QDateTime dateTimeEnd3(QDate(12,07,2010),QTime(18,45));
|
|
120 |
|
|
121 |
AgendaEntry entry1;
|
|
122 |
AgendaEntry entry2;
|
|
123 |
AgendaEntry entry3;
|
|
124 |
|
|
125 |
entry1.setStartAndEndTime(dateTimeStart1,dateTimeEnd1);
|
|
126 |
entry2.setStartAndEndTime(dateTimeStart2,dateTimeEnd2);
|
|
127 |
entry3.setStartAndEndTime(dateTimeStart3,dateTimeEnd3);
|
|
128 |
|
|
129 |
SCalenApptInfo calenInfo;
|
|
130 |
calenInfo.iStatus = AgendaEntry::Confirmed;
|
|
131 |
calenInfo.iId = TCalenInstanceId::create(entry1);
|
|
132 |
mInfo->InsertAlldayEvent(calenInfo);
|
|
133 |
mInfo->InsertAlldayEvent(calenInfo);
|
|
134 |
|
|
135 |
MOCK_EVENTS_LIST << QVariant::fromValue(entry1);
|
|
136 |
MOCK_EVENTS_LIST << QVariant::fromValue(entry2);
|
|
137 |
MOCK_EVENTS_LIST << QVariant::fromValue(entry3);
|
45
|
138 |
}
|
|
139 |
|
|
140 |
/*!
|
|
141 |
Called after everyfunction
|
|
142 |
*/
|
|
143 |
void TestCalenDayContainer::cleanup()
|
|
144 |
{
|
|
145 |
if (mContainer) {
|
|
146 |
delete mContainer;
|
|
147 |
mContainer = NULL;
|
|
148 |
}
|
57
|
149 |
if (mInfo) {
|
|
150 |
delete mInfo;
|
|
151 |
mInfo = NULL;
|
|
152 |
}
|
45
|
153 |
}
|
|
154 |
|
|
155 |
/*!
|
|
156 |
Test function for constructors
|
|
157 |
1. Test if container is not initialized
|
|
158 |
2. Test if container is correcty created
|
|
159 |
*/
|
|
160 |
void TestCalenDayContainer::testConstructors()
|
|
161 |
{
|
|
162 |
//1)
|
57
|
163 |
CalenDayContainerTest *testContainer = 0;
|
45
|
164 |
QVERIFY(!testContainer);
|
|
165 |
|
|
166 |
//2)
|
57
|
167 |
testContainer = new CalenDayContainerTest();
|
45
|
168 |
QVERIFY(testContainer);
|
|
169 |
|
|
170 |
delete testContainer;
|
|
171 |
}
|
|
172 |
|
57
|
173 |
/*!
|
|
174 |
Test function to check set and get day info
|
|
175 |
Test after set if info day is good
|
|
176 |
*/
|
|
177 |
void TestCalenDayContainer::testSetGetDayInfo()
|
|
178 |
{
|
|
179 |
QVERIFY(mContainer->dayInfo() ==0);
|
|
180 |
mContainer->setDayInfo(mInfo);
|
|
181 |
|
|
182 |
QVERIFY(mContainer->dayInfo()!=0);
|
|
183 |
}
|
|
184 |
|
|
185 |
/*!
|
81
|
186 |
Test function to check set and get date
|
|
187 |
1) Test setDate()
|
|
188 |
2) Test date()
|
|
189 |
*/
|
|
190 |
void TestCalenDayContainer::testSetGetDate()
|
|
191 |
{
|
|
192 |
QDate today = QDate::currentDate();
|
|
193 |
|
|
194 |
//1)
|
|
195 |
mContainer->setDate(today);
|
|
196 |
QCOMPARE(mContainer->mDate, today);
|
|
197 |
|
|
198 |
//2)
|
|
199 |
QCOMPARE(mContainer->date(), today);
|
|
200 |
}
|
|
201 |
|
|
202 |
/*!
|
57
|
203 |
Function not implemented
|
|
204 |
*/
|
|
205 |
void TestCalenDayContainer::testItemAdded()
|
|
206 |
{
|
81
|
207 |
// function does nothing - just check function call
|
|
208 |
CalenDayItem *item = new CalenDayItem(mContainer);
|
|
209 |
mContainer->itemAdded(1, item, false);
|
57
|
210 |
}
|
|
211 |
|
|
212 |
/*!
|
|
213 |
Function not implemented
|
|
214 |
*/
|
|
215 |
void TestCalenDayContainer::testItemRemoved()
|
|
216 |
{
|
81
|
217 |
// function does nothing - just check function call
|
|
218 |
CalenDayItem *item = new CalenDayItem(mContainer);
|
|
219 |
mContainer->itemRemoved(item, false);
|
57
|
220 |
}
|
|
221 |
|
|
222 |
/*!
|
|
223 |
Test reset of caontainer based on absorders
|
|
224 |
*/
|
|
225 |
void TestCalenDayContainer::testReset()
|
|
226 |
{
|
|
227 |
QVERIFY(mContainer->mAbsorbers.count() == 0);
|
|
228 |
mContainer->mAbsorbers << mContainer->crateAbsorberBetweenSlots(0,1,false);
|
|
229 |
QVERIFY(mContainer->mAbsorbers.count() == 1);
|
|
230 |
mContainer->reset();
|
|
231 |
QVERIFY(mContainer->mAbsorbers.count() == 0);
|
|
232 |
}
|
|
233 |
|
|
234 |
/*!
|
|
235 |
Test is view of container is good resized.
|
|
236 |
1)test if size is changed
|
|
237 |
2)test if new size is good set
|
|
238 |
*/
|
|
239 |
void TestCalenDayContainer::testViewResized()
|
|
240 |
{
|
|
241 |
QSizeF size = mContainer->size();
|
|
242 |
//set new size
|
|
243 |
QSizeF newSize(size.width()+100,size.height()+100);
|
|
244 |
mContainer->viewResized(newSize);
|
|
245 |
//1)
|
|
246 |
QVERIFY(size != mContainer->size());
|
|
247 |
//2)
|
|
248 |
QCOMPARE(mContainer->size(),newSize);
|
|
249 |
}
|
|
250 |
|
|
251 |
/*!
|
|
252 |
It test change of orientation based on count of absorbers
|
|
253 |
*/
|
|
254 |
void TestCalenDayContainer::testOrientationChanged()
|
|
255 |
{
|
|
256 |
mContainer->setDayInfo(mInfo);
|
|
257 |
QVERIFY(mContainer->mAbsorbers.count() == 0);
|
|
258 |
|
|
259 |
mContainer->orientationChanged(Qt::Vertical);
|
|
260 |
|
|
261 |
QVERIFY(mContainer->mAbsorbers.count() != 0);
|
|
262 |
}
|
|
263 |
|
|
264 |
/*!
|
|
265 |
Test creating item prototype
|
|
266 |
*/
|
|
267 |
void TestCalenDayContainer::testCreateDefaultPrototype()
|
|
268 |
{
|
|
269 |
HbAbstractViewItem *testItem = 0;
|
|
270 |
QVERIFY(!testItem);
|
|
271 |
|
|
272 |
testItem = mContainer->createDefaultPrototype();
|
|
273 |
|
|
274 |
QVERIFY(testItem);
|
|
275 |
|
|
276 |
delete testItem;
|
|
277 |
}
|
|
278 |
|
|
279 |
/*!
|
|
280 |
Test geting timed layouts.
|
|
281 |
*/
|
|
282 |
void TestCalenDayContainer::testGetTimedEventLayoutValues()
|
|
283 |
{
|
|
284 |
CalenDayContainer::LayoutValues layoutValues;
|
|
285 |
|
|
286 |
QVERIFY(layoutValues.eventAreaWidth == 0);
|
|
287 |
QVERIFY(layoutValues.eventAreaX == 0);
|
|
288 |
QVERIFY(layoutValues.eventMargin == 0);
|
|
289 |
QVERIFY(layoutValues.maxColumns == 0);
|
|
290 |
QVERIFY(layoutValues.slotHeight == 0);
|
|
291 |
QVERIFY(layoutValues.unitInPixels == 0);
|
|
292 |
|
|
293 |
mContainer->getTimedEventLayoutValues(layoutValues);
|
|
294 |
|
|
295 |
QVERIFY(layoutValues.eventAreaWidth != 0);
|
|
296 |
QVERIFY(layoutValues.eventAreaX == 0);
|
|
297 |
QVERIFY(layoutValues.eventMargin != 0);
|
|
298 |
QVERIFY(layoutValues.maxColumns != 0);
|
|
299 |
QVERIFY(layoutValues.slotHeight != 0);
|
|
300 |
QVERIFY(layoutValues.unitInPixels != 0);
|
|
301 |
}
|
|
302 |
|
|
303 |
/*!
|
|
304 |
Test creating touch event absorbers.
|
|
305 |
*/
|
|
306 |
void TestCalenDayContainer::testCreateTouchEventAbsorbers()
|
|
307 |
{
|
|
308 |
mContainer->setDayInfo(mInfo);
|
|
309 |
QVERIFY(mContainer->mAbsorbers.count() == 0);
|
|
310 |
mContainer->createTouchEventAbsorbers();
|
|
311 |
QVERIFY(mContainer->mAbsorbers.count() != 0);
|
|
312 |
}
|
|
313 |
|
|
314 |
/*!
|
|
315 |
test creating touch absorber beatween slots.
|
|
316 |
*/
|
|
317 |
void TestCalenDayContainer::testCrateAbsorberBetweenSlots()
|
|
318 |
{
|
|
319 |
TouchEventAbsorber* testValue = 0;
|
|
320 |
QVERIFY(!testValue);
|
|
321 |
testValue = mContainer->crateAbsorberBetweenSlots(0,1,false);
|
|
322 |
QVERIFY(testValue);
|
|
323 |
delete testValue;
|
|
324 |
}
|
|
325 |
|
|
326 |
|
45
|
327 |
QTEST_MAIN(TestCalenDayContainer);
|
|
328 |
#include "unittest_calendaycontainer.moc"
|