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 CalenDayItem
|
45
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include <QGraphicsItem>
|
|
18 |
#include <QtTest/QtTest>
|
57
|
19 |
#include <QGraphicsSceneEvent>
|
|
20 |
#include <QDebug>
|
45
|
21 |
|
|
22 |
|
57
|
23 |
#include "agendaentry.h"
|
|
24 |
#include "calendaycontainer.h"
|
|
25 |
|
70
|
26 |
// System includes
|
|
27 |
#include <HbFrameItem>
|
|
28 |
#include <HbTextItem>
|
|
29 |
#include <HbStyle>
|
|
30 |
#include <HbColorScheme>
|
|
31 |
#include <agendaentry.h>
|
|
32 |
|
|
33 |
// User includes
|
|
34 |
#include "calendaycommonheaders.h"
|
|
35 |
#include "calendaystatusstrip.h"
|
|
36 |
#include "calendaymodel.h"
|
|
37 |
#include "calendayutils.h"
|
|
38 |
#include "calenagendautils.h"
|
|
39 |
#include "calendaycontainer.h"
|
|
40 |
|
|
41 |
#ifndef __WINSCW__
|
57
|
42 |
#define private public
|
|
43 |
#define protected public
|
70
|
44 |
#endif
|
57
|
45 |
|
45
|
46 |
#include "calendayitem.h"
|
70
|
47 |
#include "calendayitemtest.h"
|
57
|
48 |
|
|
49 |
|
|
50 |
QRectF gTestWindowRect;
|
|
51 |
Qt::Orientation gTestOrientation;
|
45
|
52 |
|
|
53 |
class TestCalenDayItem : public QObject
|
|
54 |
{
|
|
55 |
Q_OBJECT
|
|
56 |
|
|
57 |
public:
|
|
58 |
TestCalenDayItem();
|
|
59 |
virtual ~TestCalenDayItem();
|
|
60 |
|
|
61 |
private slots:
|
|
62 |
void initTestCase();
|
|
63 |
void cleanupTestCase();
|
|
64 |
void init();
|
|
65 |
void cleanup();
|
|
66 |
|
57
|
67 |
void testCreateItem();
|
|
68 |
void testUpdateChildItems();
|
|
69 |
void testHasEventDescription();
|
|
70 |
void testHasBackgroundFrame();
|
|
71 |
|
45
|
72 |
void testConstructors();
|
|
73 |
private:
|
70
|
74 |
CalenDayItemTest *mItem;
|
55
|
75 |
CalenDayContainer *mContainer;
|
45
|
76 |
};
|
|
77 |
|
|
78 |
/*!
|
|
79 |
Constructor
|
|
80 |
*/
|
70
|
81 |
TestCalenDayItem::TestCalenDayItem() : mItem(NULL), mContainer(NULL)
|
45
|
82 |
{
|
|
83 |
|
|
84 |
}
|
|
85 |
|
|
86 |
/*!
|
|
87 |
Destructor
|
|
88 |
*/
|
|
89 |
TestCalenDayItem::~TestCalenDayItem()
|
|
90 |
{
|
|
91 |
|
|
92 |
}
|
|
93 |
|
|
94 |
/*!
|
|
95 |
Called before testcase
|
|
96 |
*/
|
|
97 |
void TestCalenDayItem::initTestCase()
|
|
98 |
{
|
|
99 |
}
|
|
100 |
|
|
101 |
/*!
|
|
102 |
Called after testcase
|
|
103 |
*/
|
|
104 |
void TestCalenDayItem::cleanupTestCase()
|
|
105 |
{
|
|
106 |
|
|
107 |
}
|
|
108 |
|
|
109 |
/*!
|
|
110 |
Called before every function
|
|
111 |
*/
|
|
112 |
void TestCalenDayItem::init()
|
|
113 |
{
|
55
|
114 |
mContainer = new CalenDayContainer();
|
70
|
115 |
mItem = new CalenDayItemTest(mContainer);
|
|
116 |
#ifndef __WINSCW__
|
57
|
117 |
mItem->mBg = new HbFrameItem();
|
|
118 |
mItem->mEventDesc = new HbTextItem(0);
|
70
|
119 |
#endif
|
45
|
120 |
}
|
|
121 |
|
|
122 |
/*!
|
|
123 |
Called after everyfunction
|
|
124 |
*/
|
|
125 |
void TestCalenDayItem::cleanup()
|
|
126 |
{
|
|
127 |
if (mItem) {
|
|
128 |
delete mItem;
|
|
129 |
mItem = NULL;
|
|
130 |
}
|
55
|
131 |
|
|
132 |
if (mContainer) {
|
57
|
133 |
delete mContainer;
|
|
134 |
mContainer = NULL;
|
55
|
135 |
}
|
45
|
136 |
}
|
|
137 |
|
|
138 |
/*!
|
|
139 |
Test function for constructors
|
|
140 |
1. Test if content widget is not initialized
|
|
141 |
2. Test if content widget is correcty created
|
|
142 |
*/
|
|
143 |
void TestCalenDayItem::testConstructors()
|
|
144 |
{
|
|
145 |
//1)
|
70
|
146 |
CalenDayItemTest *testItem = 0;
|
45
|
147 |
QVERIFY(!testItem);
|
|
148 |
|
|
149 |
//2)
|
70
|
150 |
testItem = new CalenDayItemTest(mContainer);
|
45
|
151 |
QVERIFY(testItem);
|
|
152 |
delete testItem;
|
|
153 |
}
|
|
154 |
|
|
155 |
/*!
|
57
|
156 |
Test function for creating new abstract items.
|
|
157 |
1. Test if item is created
|
|
158 |
2. Test if is the same as orginal.
|
45
|
159 |
*/
|
|
160 |
void TestCalenDayItem::testCreateItem()
|
70
|
161 |
{
|
|
162 |
HbAbstractViewItem *testItem = mItem->createItem();
|
|
163 |
QVERIFY(testItem);
|
|
164 |
delete testItem;
|
|
165 |
}
|
57
|
166 |
|
|
167 |
void TestCalenDayItem::testUpdateChildItems()
|
70
|
168 |
{
|
|
169 |
|
|
170 |
}
|
57
|
171 |
|
|
172 |
void TestCalenDayItem::testHasEventDescription()
|
70
|
173 |
{
|
|
174 |
#ifndef __WINSCW__
|
|
175 |
QGraphicsSceneResizeEvent *event = new QGraphicsSceneResizeEvent();
|
|
176 |
qreal width = mItem->rect().width();
|
|
177 |
|
|
178 |
qDebug() << "inited";
|
|
179 |
|
|
180 |
mItem->mEventDescMinWidth = width - 4;
|
|
181 |
|
|
182 |
qDebug() << "before resize";
|
|
183 |
|
|
184 |
mItem->resizeEvent(event);
|
|
185 |
|
|
186 |
qDebug() << "resize called";
|
|
187 |
|
|
188 |
QVERIFY(mItem->hasEventDescription() == true);
|
|
189 |
|
|
190 |
mItem->mEventDescMinWidth = width + 8;
|
|
191 |
mItem->resizeEvent(event);
|
|
192 |
|
|
193 |
qDebug() << "resize 2 called";
|
|
194 |
|
|
195 |
QVERIFY(mItem->hasEventDescription() == false);
|
|
196 |
#endif
|
|
197 |
}
|
57
|
198 |
|
|
199 |
void TestCalenDayItem::testHasBackgroundFrame()
|
70
|
200 |
{
|
|
201 |
#ifndef __WINSCW__
|
|
202 |
QGraphicsSceneResizeEvent *event = new QGraphicsSceneResizeEvent();
|
|
203 |
qreal width = mItem->rect().width();
|
57
|
204 |
|
70
|
205 |
mItem->mFrameMinWidth = width - 4;
|
|
206 |
mItem->resizeEvent(event);
|
57
|
207 |
|
70
|
208 |
QVERIFY(mItem->hasBackgroundFrame() == true);
|
|
209 |
|
|
210 |
mItem->mFrameMinWidth = width + 8;
|
|
211 |
mItem->resizeEvent(event);
|
|
212 |
|
|
213 |
QVERIFY(mItem->hasBackgroundFrame() == false);
|
|
214 |
#endif
|
|
215 |
}
|
45
|
216 |
|
|
217 |
QTEST_MAIN(TestCalenDayItem);
|
|
218 |
#include "unittest_calendayitem.moc"
|