9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Test class for CalenDayContentWidget |
14 * Description: Test class for CalenDayItem |
15 * |
15 * |
16 */ |
16 */ |
17 #include <QGraphicsItem> |
17 #include <QGraphicsItem> |
18 #include <QtTest/QtTest> |
18 #include <QtTest/QtTest> |
|
19 #include <QGraphicsSceneEvent> |
|
20 #include <QDebug> |
19 |
21 |
20 |
22 |
|
23 #include "agendaentry.h" |
|
24 #include "calendaycontainer.h" |
|
25 |
|
26 #define private public |
|
27 #define protected public |
|
28 |
21 #include "calendayitem.h" |
29 #include "calendayitem.h" |
22 #include "calendaycontainer.h" |
30 |
|
31 |
|
32 QRectF gTestWindowRect; |
|
33 Qt::Orientation gTestOrientation; |
23 |
34 |
24 class TestCalenDayItem : public QObject |
35 class TestCalenDayItem : public QObject |
25 { |
36 { |
26 Q_OBJECT |
37 Q_OBJECT |
27 |
38 |
33 void initTestCase(); |
44 void initTestCase(); |
34 void cleanupTestCase(); |
45 void cleanupTestCase(); |
35 void init(); |
46 void init(); |
36 void cleanup(); |
47 void cleanup(); |
37 |
48 |
|
49 void testCreateItem(); |
|
50 void testUpdateChildItems(); |
|
51 void testHasEventDescription(); |
|
52 void testHasBackgroundFrame(); |
|
53 |
38 void testConstructors(); |
54 void testConstructors(); |
39 void testCreateItem(); |
|
40 |
|
41 private: |
55 private: |
42 CalenDayItem *mItem; |
56 CalenDayItem *mItem; |
43 CalenDayContainer *mContainer; |
57 CalenDayContainer *mContainer; |
44 }; |
58 }; |
45 |
59 |
46 /*! |
60 /*! |
47 Constructor |
61 Constructor |
48 */ |
62 */ |
49 TestCalenDayItem::TestCalenDayItem() : |
63 TestCalenDayItem::TestCalenDayItem() : |
50 mItem(NULL) |
64 mItem(NULL), mContainer(NULL) |
51 { |
65 { |
52 |
66 |
53 } |
67 } |
54 |
68 |
55 /*! |
69 /*! |
80 */ |
94 */ |
81 void TestCalenDayItem::init() |
95 void TestCalenDayItem::init() |
82 { |
96 { |
83 mContainer = new CalenDayContainer(); |
97 mContainer = new CalenDayContainer(); |
84 mItem = new CalenDayItem(mContainer); |
98 mItem = new CalenDayItem(mContainer); |
|
99 |
|
100 mItem->mBg = new HbFrameItem(); |
|
101 mItem->mEventDesc = new HbTextItem(0); |
85 } |
102 } |
86 |
103 |
87 /*! |
104 /*! |
88 Called after everyfunction |
105 Called after everyfunction |
89 */ |
106 */ |
116 QVERIFY(testItem); |
133 QVERIFY(testItem); |
117 delete testItem; |
134 delete testItem; |
118 } |
135 } |
119 |
136 |
120 /*! |
137 /*! |
121 Test function for creating new abstract items. |
138 Test function for creating new abstract items. |
122 1. Test if item is created |
139 1. Test if item is created |
123 2. Test if is the same as orginal. |
140 2. Test if is the same as orginal. |
124 */ |
141 */ |
125 void TestCalenDayItem::testCreateItem() |
142 void TestCalenDayItem::testCreateItem() |
126 { |
143 { |
127 HbAbstractViewItem *testItem = mItem->createItem(); |
144 HbAbstractViewItem *testItem = mItem->createItem(); |
128 QVERIFY(testItem); |
145 QVERIFY(testItem); |
129 |
146 delete testItem; |
130 delete testItem; |
147 } |
131 } |
148 |
|
149 void TestCalenDayItem::testUpdateChildItems() |
|
150 { |
|
151 |
|
152 } |
|
153 |
|
154 void TestCalenDayItem::testHasEventDescription() |
|
155 { |
|
156 QGraphicsSceneResizeEvent *event = new QGraphicsSceneResizeEvent(); |
|
157 qreal width = mItem->rect().width(); |
|
158 |
|
159 qDebug() << "inited"; |
|
160 |
|
161 mItem->mEventDescMinWidth = width - 4; |
|
162 |
|
163 qDebug() << "before resize"; |
|
164 |
|
165 mItem->resizeEvent(event); |
|
166 |
|
167 qDebug() << "resize called"; |
|
168 |
|
169 QVERIFY(mItem->hasEventDescription() == true); |
|
170 |
|
171 |
|
172 mItem->mEventDescMinWidth = width + 8; |
|
173 mItem->resizeEvent(event); |
|
174 |
|
175 qDebug() << "resize 2 called"; |
|
176 |
|
177 QVERIFY(mItem->hasEventDescription() == false); |
|
178 } |
|
179 |
|
180 void TestCalenDayItem::testHasBackgroundFrame() |
|
181 { |
|
182 QGraphicsSceneResizeEvent *event = new QGraphicsSceneResizeEvent(); |
|
183 qreal width = mItem->rect().width(); |
|
184 |
|
185 |
|
186 mItem->mFrameMinWidth = width - 4; |
|
187 mItem->resizeEvent(event); |
|
188 |
|
189 QVERIFY(mItem->hasBackgroundFrame() == true); |
|
190 |
|
191 mItem->mFrameMinWidth = width + 8; |
|
192 mItem->resizeEvent(event); |
|
193 |
|
194 QVERIFY(mItem->hasBackgroundFrame() == false); |
|
195 } |
132 |
196 |
133 QTEST_MAIN(TestCalenDayItem); |
197 QTEST_MAIN(TestCalenDayItem); |
134 #include "unittest_calendayitem.moc" |
198 #include "unittest_calendayitem.moc" |