|
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 |
|
18 #include <QtGui> |
|
19 #include <QtTest/QtTest> |
|
20 |
|
21 #include <hbapplication.h> |
|
22 #include <hbstyle.h> |
|
23 #include <hbinstance.h> |
|
24 #include <hbwidget.h> |
|
25 #include <hbframeitem.h> |
|
26 #include <hbframedrawer.h> |
|
27 #include <hbtextitem.h> |
|
28 #include <hbiconitem.h> |
|
29 |
|
30 #include "bubbletest.h" |
|
31 #include "bubblestyleplugin.h" |
|
32 #include "bubbleprimitives.h" |
|
33 #include "bubblestyleoption.h" |
|
34 #include "bubbleanimiconitem.h" |
|
35 |
|
36 class ut_BubbleStylePlugin : public QObject |
|
37 { |
|
38 Q_OBJECT |
|
39 |
|
40 private slots: |
|
41 void initTestCase(); |
|
42 void cleanupTestCase(); |
|
43 |
|
44 void testPrimitiveCount(); |
|
45 void testLayoutPath(); |
|
46 |
|
47 void testBubbleFrame(); |
|
48 void testText1(); |
|
49 void testText2(); |
|
50 void testText3(); |
|
51 void testCallStatusIcon(); |
|
52 void testVideoCallStatusIcon(); |
|
53 void testVoipCallStatusIcon(); |
|
54 void testNumberTypeIcon(); |
|
55 |
|
56 private: |
|
57 BubbleStylePlugin* mPlugin; |
|
58 HbWidget* mParent; |
|
59 }; |
|
60 |
|
61 void ut_BubbleStylePlugin::initTestCase() |
|
62 { |
|
63 mPlugin = new BubbleStylePlugin(); |
|
64 mParent = new HbWidget(); |
|
65 } |
|
66 |
|
67 void ut_BubbleStylePlugin::cleanupTestCase() |
|
68 { |
|
69 delete mPlugin; |
|
70 delete mParent; |
|
71 } |
|
72 |
|
73 void ut_BubbleStylePlugin::testPrimitiveCount() |
|
74 { |
|
75 QVERIFY(mPlugin->primitiveCount()==BP_Bubble_primitive_count); |
|
76 } |
|
77 |
|
78 void ut_BubbleStylePlugin::testLayoutPath() |
|
79 { |
|
80 QVERIFY(mPlugin->layoutPath()==":/"); |
|
81 } |
|
82 |
|
83 void ut_BubbleStylePlugin::testBubbleFrame() |
|
84 { |
|
85 QGraphicsItem *item = mPlugin->createPrimitive( |
|
86 (HbStyle::Primitive)(BP_Bubble_frame),mParent); |
|
87 QVERIFY(item); |
|
88 QVERIFY(item->zValue()==-1.0); |
|
89 QVERIFY(item->parentItem()==mParent); |
|
90 |
|
91 HbFrameItem* frame = qgraphicsitem_cast<HbFrameItem*>(item); |
|
92 QVERIFY(frame); |
|
93 |
|
94 BubbleStyleOption option; |
|
95 mPlugin->updatePrimitive( |
|
96 item, (HbStyle::Primitive)(BP_Bubble_frame), |
|
97 &option); |
|
98 QVERIFY(frame->frameDrawer().frameGraphicsName()== |
|
99 "qtg_fr_list_normal"); |
|
100 } |
|
101 |
|
102 void ut_BubbleStylePlugin::testText1() |
|
103 { |
|
104 QGraphicsItem *item = mPlugin->createPrimitive( |
|
105 (HbStyle::Primitive)(BP_Text1_text),mParent); |
|
106 QVERIFY(item); |
|
107 QVERIFY(item->parentItem()==mParent); |
|
108 |
|
109 HbTextItem* text = qgraphicsitem_cast<HbTextItem*>(item); |
|
110 QVERIFY(text); |
|
111 |
|
112 BubbleStyleOption option; |
|
113 option.mText1 = "foo"; |
|
114 option.mText1Clip = Qt::ElideRight; |
|
115 mPlugin->updatePrimitive( |
|
116 item, (HbStyle::Primitive)(BP_Text1_text), |
|
117 &option); |
|
118 QVERIFY(text->text()=="foo"); |
|
119 QVERIFY(text->elideMode()==Qt::ElideRight); |
|
120 |
|
121 } |
|
122 |
|
123 void ut_BubbleStylePlugin::testText2() |
|
124 { |
|
125 QGraphicsItem *item = mPlugin->createPrimitive( |
|
126 (HbStyle::Primitive)(BP_Text2_text),mParent); |
|
127 QVERIFY(item); |
|
128 QVERIFY(item->parentItem()==mParent); |
|
129 |
|
130 HbTextItem* text = qgraphicsitem_cast<HbTextItem*>(item); |
|
131 QVERIFY(text); |
|
132 |
|
133 BubbleStyleOption option; |
|
134 option.mText2 = "foo"; |
|
135 option.mText2Clip = Qt::ElideRight; |
|
136 mPlugin->updatePrimitive( |
|
137 item, (HbStyle::Primitive)(BP_Text2_text), |
|
138 &option); |
|
139 QVERIFY(text->text()=="foo"); |
|
140 QVERIFY(text->elideMode()==Qt::ElideRight); |
|
141 |
|
142 } |
|
143 |
|
144 void ut_BubbleStylePlugin::testText3() |
|
145 { |
|
146 QGraphicsItem *item = mPlugin->createPrimitive( |
|
147 (HbStyle::Primitive)(BP_Text3_text),mParent); |
|
148 QVERIFY(item); |
|
149 QVERIFY(item->parentItem()==mParent); |
|
150 |
|
151 HbTextItem* text = qgraphicsitem_cast<HbTextItem*>(item); |
|
152 QVERIFY(text); |
|
153 |
|
154 BubbleStyleOption option; |
|
155 option.mText3 = "foo"; |
|
156 option.mText3Clip = Qt::ElideLeft; |
|
157 mPlugin->updatePrimitive( |
|
158 item, (HbStyle::Primitive)(BP_Text3_text), |
|
159 &option); |
|
160 QVERIFY(text->text()=="foo"); |
|
161 QVERIFY(text->elideMode()==Qt::ElideLeft); |
|
162 |
|
163 } |
|
164 |
|
165 void ut_BubbleStylePlugin::testCallStatusIcon() |
|
166 { |
|
167 QGraphicsItem *item = mPlugin->createPrimitive( |
|
168 (HbStyle::Primitive)(BP_CallStatus_icon),mParent); |
|
169 QVERIFY(item); |
|
170 QVERIFY(item->parentItem()==mParent); |
|
171 |
|
172 BubbleAnimIconItem* icon = static_cast<BubbleAnimIconItem*>(item); |
|
173 QVERIFY(icon); |
|
174 |
|
175 BubbleStyleOption option; |
|
176 option.mCallState = BubbleManagerIF::Active; |
|
177 mPlugin->updatePrimitive( |
|
178 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
179 &option); |
|
180 option.mCallState = BubbleManagerIF::OnHold; |
|
181 mPlugin->updatePrimitive( |
|
182 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
183 &option); |
|
184 option.mCallState = BubbleManagerIF::Disconnected; |
|
185 mPlugin->updatePrimitive( |
|
186 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
187 &option); |
|
188 option.mCallState = BubbleManagerIF::AlertToDisconnected; |
|
189 mPlugin->updatePrimitive( |
|
190 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
191 &option); |
|
192 option.mCallState = BubbleManagerIF::Incoming; |
|
193 mPlugin->updatePrimitive( |
|
194 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
195 &option); |
|
196 option.mCallState = BubbleManagerIF::Alerting; |
|
197 mPlugin->updatePrimitive( |
|
198 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
199 &option); |
|
200 option.mCallState = BubbleManagerIF::Waiting; |
|
201 mPlugin->updatePrimitive( |
|
202 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
203 &option); |
|
204 option.mCallState = BubbleManagerIF::Outgoing; |
|
205 mPlugin->updatePrimitive( |
|
206 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
207 &option); |
|
208 } |
|
209 |
|
210 void ut_BubbleStylePlugin::testVideoCallStatusIcon() |
|
211 { |
|
212 QGraphicsItem *item = mPlugin->createPrimitive( |
|
213 (HbStyle::Primitive)(BP_CallStatus_icon),mParent); |
|
214 QVERIFY(item); |
|
215 QVERIFY(item->parentItem()==mParent); |
|
216 |
|
217 BubbleAnimIconItem* icon = static_cast<BubbleAnimIconItem*>(item); |
|
218 QVERIFY(icon); |
|
219 |
|
220 BubbleStyleOption option; |
|
221 option.mCallFlags |= BubbleManagerIF::Video; |
|
222 option.mCallState = BubbleManagerIF::Active; |
|
223 mPlugin->updatePrimitive( |
|
224 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
225 &option); |
|
226 option.mCallState = BubbleManagerIF::OnHold; |
|
227 mPlugin->updatePrimitive( |
|
228 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
229 &option); |
|
230 option.mCallState = BubbleManagerIF::Disconnected; |
|
231 mPlugin->updatePrimitive( |
|
232 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
233 &option); |
|
234 option.mCallState = BubbleManagerIF::AlertToDisconnected; |
|
235 mPlugin->updatePrimitive( |
|
236 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
237 &option); |
|
238 option.mCallState = BubbleManagerIF::Incoming; |
|
239 mPlugin->updatePrimitive( |
|
240 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
241 &option); |
|
242 option.mCallState = BubbleManagerIF::Alerting; |
|
243 mPlugin->updatePrimitive( |
|
244 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
245 &option); |
|
246 option.mCallState = BubbleManagerIF::Waiting; |
|
247 mPlugin->updatePrimitive( |
|
248 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
249 &option); |
|
250 option.mCallState = BubbleManagerIF::Outgoing; |
|
251 mPlugin->updatePrimitive( |
|
252 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
253 &option); |
|
254 } |
|
255 |
|
256 void ut_BubbleStylePlugin::testVoipCallStatusIcon() |
|
257 { |
|
258 QGraphicsItem *item = mPlugin->createPrimitive( |
|
259 (HbStyle::Primitive)(BP_CallStatus_icon),mParent); |
|
260 QVERIFY(item); |
|
261 QVERIFY(item->parentItem()==mParent); |
|
262 |
|
263 BubbleAnimIconItem* icon = static_cast<BubbleAnimIconItem*>(item); |
|
264 QVERIFY(icon); |
|
265 |
|
266 BubbleStyleOption option; |
|
267 option.mCallFlags |= BubbleManagerIF::VoIPCall; |
|
268 option.mCallState = BubbleManagerIF::Active; |
|
269 mPlugin->updatePrimitive( |
|
270 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
271 &option); |
|
272 option.mCallState = BubbleManagerIF::OnHold; |
|
273 mPlugin->updatePrimitive( |
|
274 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
275 &option); |
|
276 option.mCallState = BubbleManagerIF::Disconnected; |
|
277 mPlugin->updatePrimitive( |
|
278 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
279 &option); |
|
280 option.mCallState = BubbleManagerIF::AlertToDisconnected; |
|
281 mPlugin->updatePrimitive( |
|
282 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
283 &option); |
|
284 option.mCallState = BubbleManagerIF::Incoming; |
|
285 mPlugin->updatePrimitive( |
|
286 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
287 &option); |
|
288 option.mCallState = BubbleManagerIF::Alerting; |
|
289 mPlugin->updatePrimitive( |
|
290 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
291 &option); |
|
292 option.mCallState = BubbleManagerIF::Waiting; |
|
293 mPlugin->updatePrimitive( |
|
294 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
295 &option); |
|
296 option.mCallState = BubbleManagerIF::Outgoing; |
|
297 mPlugin->updatePrimitive( |
|
298 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
299 &option); |
|
300 } |
|
301 |
|
302 void ut_BubbleStylePlugin::testNumberTypeIcon() |
|
303 { |
|
304 QGraphicsItem *item = mPlugin->createPrimitive( |
|
305 (HbStyle::Primitive)(BP_NumberType_icon),mParent); |
|
306 QVERIFY(item); |
|
307 QVERIFY(item->parentItem()==mParent); |
|
308 |
|
309 HbIconItem* icon = qgraphicsitem_cast<HbIconItem*>(item); |
|
310 QVERIFY(icon); |
|
311 BubbleStyleOption option; |
|
312 // incoming call |
|
313 option.mCallState = BubbleManagerIF::Incoming; |
|
314 option.mCallFlags |= BubbleManagerIF::Diverted; |
|
315 mPlugin->updatePrimitive( |
|
316 item, (HbStyle::Primitive)(BP_NumberType_icon), |
|
317 &option); |
|
318 QVERIFY(icon->icon().iconName()==":/resources/qgn_indi_call_diverted.svg"); |
|
319 option.mCallState = BubbleManagerIF::Incoming; |
|
320 option.mCallFlags &= ~BubbleManagerIF::Diverted; |
|
321 mPlugin->updatePrimitive( |
|
322 item, (HbStyle::Primitive)(BP_NumberType_icon), |
|
323 &option); |
|
324 QVERIFY(icon->icon().iconName()==""); |
|
325 |
|
326 // waiting call |
|
327 option.mCallState = BubbleManagerIF::Waiting; |
|
328 option.mCallFlags |= BubbleManagerIF::Diverted; |
|
329 mPlugin->updatePrimitive( |
|
330 item, (HbStyle::Primitive)(BP_NumberType_icon), |
|
331 &option); |
|
332 QVERIFY(icon->icon().iconName()==":/resources/qgn_indi_call_diverted.svg"); |
|
333 option.mCallState = BubbleManagerIF::Waiting; |
|
334 option.mCallFlags &= ~BubbleManagerIF::Diverted; |
|
335 mPlugin->updatePrimitive( |
|
336 item, (HbStyle::Primitive)(BP_NumberType_icon), |
|
337 &option); |
|
338 QVERIFY(icon->icon().iconName()==""); |
|
339 } |
|
340 |
|
341 BUBBLE_TEST_MAIN(ut_BubbleStylePlugin) |
|
342 #include "ut_bubblestyleplugin.moc" |