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 void testCipheringIcon(); |
|
56 void testAvatar(); |
|
57 |
|
58 private: |
|
59 BubbleStylePlugin* mPluginInstance; |
|
60 HbStyleInterface* mPlugin; |
|
61 HbWidget* mParent; |
|
62 }; |
|
63 |
|
64 void ut_BubbleStylePlugin::initTestCase() |
|
65 { |
|
66 mPluginInstance = new BubbleStylePlugin(); |
|
67 mPlugin = static_cast<HbStyleInterface*>(mPluginInstance); |
|
68 mParent = new HbWidget(); |
|
69 } |
|
70 |
|
71 void ut_BubbleStylePlugin::cleanupTestCase() |
|
72 { |
|
73 delete mPluginInstance; |
|
74 delete mParent; |
|
75 } |
|
76 |
|
77 void ut_BubbleStylePlugin::testPrimitiveCount() |
|
78 { |
|
79 QVERIFY(mPlugin->primitiveCount()==BP_Bubble_primitive_count); |
|
80 } |
|
81 |
|
82 void ut_BubbleStylePlugin::testLayoutPath() |
|
83 { |
|
84 QVERIFY(mPlugin->layoutPath()==":/"); |
|
85 } |
|
86 |
|
87 void ut_BubbleStylePlugin::testBubbleFrame() |
|
88 { |
|
89 QGraphicsItem *item = mPlugin->createPrimitive( |
|
90 (HbStyle::Primitive)(BP_Bubble_frame),mParent); |
|
91 QVERIFY(item); |
|
92 QVERIFY(item->zValue()==-1.0); |
|
93 QVERIFY(item->parentItem()==mParent); |
|
94 |
|
95 HbFrameItem* frame = qgraphicsitem_cast<HbFrameItem*>(item); |
|
96 QVERIFY(frame); |
|
97 |
|
98 BubbleStyleOption option; |
|
99 mPlugin->updatePrimitive( |
|
100 item, (HbStyle::Primitive)(BP_Bubble_frame), |
|
101 &option); |
|
102 QVERIFY(frame->frameDrawer().frameGraphicsName()== |
|
103 "qtg_fr_list_normal"); |
|
104 } |
|
105 |
|
106 void ut_BubbleStylePlugin::testText1() |
|
107 { |
|
108 QGraphicsItem *item = mPlugin->createPrimitive( |
|
109 (HbStyle::Primitive)(BP_Text1_text),mParent); |
|
110 QVERIFY(item); |
|
111 QVERIFY(item->parentItem()==mParent); |
|
112 |
|
113 HbTextItem* text = qgraphicsitem_cast<HbTextItem*>(item); |
|
114 QVERIFY(text); |
|
115 |
|
116 BubbleStyleOption option; |
|
117 option.mText1 = "foo"; |
|
118 option.mText1Clip = Qt::ElideRight; |
|
119 mPlugin->updatePrimitive( |
|
120 item, (HbStyle::Primitive)(BP_Text1_text), |
|
121 &option); |
|
122 QVERIFY(text->text()=="foo"); |
|
123 QVERIFY(text->elideMode()==Qt::ElideRight); |
|
124 |
|
125 } |
|
126 |
|
127 void ut_BubbleStylePlugin::testText2() |
|
128 { |
|
129 QGraphicsItem *item = mPlugin->createPrimitive( |
|
130 (HbStyle::Primitive)(BP_Text2_text),mParent); |
|
131 QVERIFY(item); |
|
132 QVERIFY(item->parentItem()==mParent); |
|
133 |
|
134 HbTextItem* text = qgraphicsitem_cast<HbTextItem*>(item); |
|
135 QVERIFY(text); |
|
136 |
|
137 BubbleStyleOption option; |
|
138 option.mText2 = "foo"; |
|
139 option.mText2Clip = Qt::ElideRight; |
|
140 mPlugin->updatePrimitive( |
|
141 item, (HbStyle::Primitive)(BP_Text2_text), |
|
142 &option); |
|
143 QVERIFY(text->text()=="foo"); |
|
144 QVERIFY(text->elideMode()==Qt::ElideRight); |
|
145 |
|
146 } |
|
147 |
|
148 void ut_BubbleStylePlugin::testText3() |
|
149 { |
|
150 QGraphicsItem *item = mPlugin->createPrimitive( |
|
151 (HbStyle::Primitive)(BP_Text3_text),mParent); |
|
152 QVERIFY(item); |
|
153 QVERIFY(item->parentItem()==mParent); |
|
154 |
|
155 HbTextItem* text = qgraphicsitem_cast<HbTextItem*>(item); |
|
156 QVERIFY(text); |
|
157 |
|
158 BubbleStyleOption option; |
|
159 option.mText3 = "foo"; |
|
160 option.mText3Clip = Qt::ElideLeft; |
|
161 mPlugin->updatePrimitive( |
|
162 item, (HbStyle::Primitive)(BP_Text3_text), |
|
163 &option); |
|
164 QVERIFY(text->text()=="foo"); |
|
165 QVERIFY(text->elideMode()==Qt::ElideLeft); |
|
166 |
|
167 } |
|
168 |
|
169 void ut_BubbleStylePlugin::testCallStatusIcon() |
|
170 { |
|
171 QGraphicsItem *item = mPlugin->createPrimitive( |
|
172 (HbStyle::Primitive)(BP_CallStatus_icon),mParent); |
|
173 QVERIFY(item); |
|
174 QVERIFY(item->parentItem()==mParent); |
|
175 |
|
176 BubbleAnimIconItem* icon = static_cast<BubbleAnimIconItem*>(item); |
|
177 QVERIFY(icon); |
|
178 |
|
179 BubbleStyleOption option; |
|
180 option.mCallState = BubbleManagerIF::Active; |
|
181 mPlugin->updatePrimitive( |
|
182 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
183 &option); |
|
184 option.mCallState = BubbleManagerIF::OnHold; |
|
185 mPlugin->updatePrimitive( |
|
186 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
187 &option); |
|
188 option.mCallState = BubbleManagerIF::Disconnected; |
|
189 mPlugin->updatePrimitive( |
|
190 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
191 &option); |
|
192 option.mCallState = BubbleManagerIF::AlertToDisconnected; |
|
193 mPlugin->updatePrimitive( |
|
194 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
195 &option); |
|
196 option.mCallState = BubbleManagerIF::Incoming; |
|
197 mPlugin->updatePrimitive( |
|
198 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
199 &option); |
|
200 option.mCallState = BubbleManagerIF::Alerting; |
|
201 mPlugin->updatePrimitive( |
|
202 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
203 &option); |
|
204 option.mCallState = BubbleManagerIF::Waiting; |
|
205 mPlugin->updatePrimitive( |
|
206 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
207 &option); |
|
208 option.mCallState = BubbleManagerIF::Outgoing; |
|
209 mPlugin->updatePrimitive( |
|
210 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
211 &option); |
|
212 } |
|
213 |
|
214 void ut_BubbleStylePlugin::testVideoCallStatusIcon() |
|
215 { |
|
216 QGraphicsItem *item = mPlugin->createPrimitive( |
|
217 (HbStyle::Primitive)(BP_CallStatus_icon),mParent); |
|
218 QVERIFY(item); |
|
219 QVERIFY(item->parentItem()==mParent); |
|
220 |
|
221 BubbleAnimIconItem* icon = static_cast<BubbleAnimIconItem*>(item); |
|
222 QVERIFY(icon); |
|
223 |
|
224 BubbleStyleOption option; |
|
225 option.mCallFlags |= BubbleManagerIF::Video; |
|
226 option.mCallState = BubbleManagerIF::Active; |
|
227 mPlugin->updatePrimitive( |
|
228 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
229 &option); |
|
230 option.mCallState = BubbleManagerIF::OnHold; |
|
231 mPlugin->updatePrimitive( |
|
232 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
233 &option); |
|
234 option.mCallState = BubbleManagerIF::Disconnected; |
|
235 mPlugin->updatePrimitive( |
|
236 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
237 &option); |
|
238 option.mCallState = BubbleManagerIF::AlertToDisconnected; |
|
239 mPlugin->updatePrimitive( |
|
240 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
241 &option); |
|
242 option.mCallState = BubbleManagerIF::Incoming; |
|
243 mPlugin->updatePrimitive( |
|
244 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
245 &option); |
|
246 option.mCallState = BubbleManagerIF::Alerting; |
|
247 mPlugin->updatePrimitive( |
|
248 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
249 &option); |
|
250 option.mCallState = BubbleManagerIF::Waiting; |
|
251 mPlugin->updatePrimitive( |
|
252 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
253 &option); |
|
254 option.mCallState = BubbleManagerIF::Outgoing; |
|
255 mPlugin->updatePrimitive( |
|
256 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
257 &option); |
|
258 } |
|
259 |
|
260 void ut_BubbleStylePlugin::testVoipCallStatusIcon() |
|
261 { |
|
262 QGraphicsItem *item = mPlugin->createPrimitive( |
|
263 (HbStyle::Primitive)(BP_CallStatus_icon),mParent); |
|
264 QVERIFY(item); |
|
265 QVERIFY(item->parentItem()==mParent); |
|
266 |
|
267 BubbleAnimIconItem* icon = static_cast<BubbleAnimIconItem*>(item); |
|
268 QVERIFY(icon); |
|
269 |
|
270 BubbleStyleOption option; |
|
271 option.mCallFlags |= BubbleManagerIF::VoIPCall; |
|
272 option.mCallState = BubbleManagerIF::Active; |
|
273 mPlugin->updatePrimitive( |
|
274 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
275 &option); |
|
276 option.mCallState = BubbleManagerIF::OnHold; |
|
277 mPlugin->updatePrimitive( |
|
278 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
279 &option); |
|
280 option.mCallState = BubbleManagerIF::Disconnected; |
|
281 mPlugin->updatePrimitive( |
|
282 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
283 &option); |
|
284 option.mCallState = BubbleManagerIF::AlertToDisconnected; |
|
285 mPlugin->updatePrimitive( |
|
286 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
287 &option); |
|
288 option.mCallState = BubbleManagerIF::Incoming; |
|
289 mPlugin->updatePrimitive( |
|
290 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
291 &option); |
|
292 option.mCallState = BubbleManagerIF::Alerting; |
|
293 mPlugin->updatePrimitive( |
|
294 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
295 &option); |
|
296 option.mCallState = BubbleManagerIF::Waiting; |
|
297 mPlugin->updatePrimitive( |
|
298 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
299 &option); |
|
300 option.mCallState = BubbleManagerIF::Outgoing; |
|
301 mPlugin->updatePrimitive( |
|
302 item, (HbStyle::Primitive)(BP_CallStatus_icon), |
|
303 &option); |
|
304 } |
|
305 |
|
306 void ut_BubbleStylePlugin::testNumberTypeIcon() |
|
307 { |
|
308 QGraphicsItem *item = mPlugin->createPrimitive( |
|
309 (HbStyle::Primitive)(BP_NumberType_icon),mParent); |
|
310 QVERIFY(item); |
|
311 QVERIFY(item->parentItem()==mParent); |
|
312 |
|
313 HbIconItem* icon = qgraphicsitem_cast<HbIconItem*>(item); |
|
314 QVERIFY(icon); |
|
315 BubbleStyleOption option; |
|
316 // incoming call |
|
317 option.mCallState = BubbleManagerIF::Incoming; |
|
318 option.mCallFlags |= BubbleManagerIF::Diverted; |
|
319 mPlugin->updatePrimitive( |
|
320 item, (HbStyle::Primitive)(BP_NumberType_icon), |
|
321 &option); |
|
322 QVERIFY(icon->icon().iconName()==":/qgn_indi_call_diverted.svg"); |
|
323 option.mCallState = BubbleManagerIF::Incoming; |
|
324 option.mCallFlags &= ~BubbleManagerIF::Diverted; |
|
325 mPlugin->updatePrimitive( |
|
326 item, (HbStyle::Primitive)(BP_NumberType_icon), |
|
327 &option); |
|
328 QVERIFY(icon->icon().iconName()==""); |
|
329 |
|
330 // waiting call |
|
331 option.mCallState = BubbleManagerIF::Waiting; |
|
332 option.mCallFlags |= BubbleManagerIF::Diverted; |
|
333 mPlugin->updatePrimitive( |
|
334 item, (HbStyle::Primitive)(BP_NumberType_icon), |
|
335 &option); |
|
336 QVERIFY(icon->icon().iconName()==":/qgn_indi_call_diverted.svg"); |
|
337 option.mCallState = BubbleManagerIF::Waiting; |
|
338 option.mCallFlags &= ~BubbleManagerIF::Diverted; |
|
339 mPlugin->updatePrimitive( |
|
340 item, (HbStyle::Primitive)(BP_NumberType_icon), |
|
341 &option); |
|
342 QVERIFY(icon->icon().iconName()==""); |
|
343 } |
|
344 |
|
345 void ut_BubbleStylePlugin::testCipheringIcon() |
|
346 { |
|
347 QGraphicsItem *item = mPlugin->createPrimitive( |
|
348 (HbStyle::Primitive)(BP_Ciphering_icon),mParent); |
|
349 QVERIFY(item); |
|
350 QVERIFY(item->parentItem()==mParent); |
|
351 |
|
352 HbIconItem* icon = qgraphicsitem_cast<HbIconItem*>(item); |
|
353 QVERIFY(icon); |
|
354 BubbleStyleOption option; |
|
355 option.mCallState = BubbleManagerIF::Active; |
|
356 option.mCallFlags |= BubbleManagerIF::NoCiphering; |
|
357 mPlugin->updatePrimitive( |
|
358 item, (HbStyle::Primitive)(BP_Ciphering_icon), |
|
359 &option); |
|
360 QVERIFY(icon->icon().iconName()=="qtg_mono_ciphering_off"); |
|
361 option.mCallState = BubbleManagerIF::Incoming; |
|
362 option.mCallFlags &= ~BubbleManagerIF::NoCiphering; |
|
363 mPlugin->updatePrimitive( |
|
364 item, (HbStyle::Primitive)(BP_Ciphering_icon), |
|
365 &option); |
|
366 QVERIFY(icon->icon().iconName()==""); |
|
367 } |
|
368 |
|
369 void ut_BubbleStylePlugin::testAvatar() |
|
370 { |
|
371 QGraphicsItem *item = mPlugin->createPrimitive( |
|
372 (HbStyle::Primitive)(BP_DefaultAvatar_icon),mParent); |
|
373 QVERIFY(item); |
|
374 QVERIFY(item->parentItem()==mParent); |
|
375 |
|
376 HbIconItem* icon = qgraphicsitem_cast<HbIconItem*>(item); |
|
377 QVERIFY(icon); |
|
378 BubbleStyleOption option; |
|
379 mPlugin->updatePrimitive( |
|
380 item, (HbStyle::Primitive)(BP_DefaultAvatar_icon), |
|
381 &option); |
|
382 QVERIFY(icon->icon().iconName()=="qtg_large_avatar"); |
|
383 } |
|
384 |
|
385 BUBBLE_TEST_MAIN(ut_BubbleStylePlugin) |
|
386 #include "ut_bubblestyleplugin.moc" |
|