15 * |
15 * |
16 */ |
16 */ |
17 #include "ut_infowidgetlayoutmanager.h" |
17 #include "ut_infowidgetlayoutmanager.h" |
18 |
18 |
19 #include <QGraphicsWidget> |
19 #include <QGraphicsWidget> |
20 |
20 #include <hbmarqueeitem.h> |
21 #define private public |
21 #define private public |
22 #include "infowidgetlayoutmanager.h" |
22 #include "infowidgetlayoutmanager.h" |
23 #include "qtestmains60.h" |
23 #include "qtestmains60.h" |
24 |
24 |
25 |
25 |
26 const int KNumOfSettingsDisplayRoles = 15; |
26 const int KNumOfSettingsDisplayRoles = 12; |
27 const int KNumOfInfoDisplayRoles = 10; |
27 const int KNumOfInfoDisplayRoles = 8; |
28 const QString KInfoWidgetDocmlFile = ":/resource/infowidget.docml"; |
28 const QString KInfoWidgetDocmlFile = ":/resource/infowidget.docml"; |
|
29 const QString KMargueeItemClassName = HbMarqueeItem::staticMetaObject.className(); |
|
30 |
29 |
31 |
30 /*! |
32 /*! |
31 UT_InfoWidgetLayoutManager::UT_InfoWidgetLayoutManager |
33 UT_InfoWidgetLayoutManager::UT_InfoWidgetLayoutManager |
32 */ |
34 */ |
33 UT_InfoWidgetLayoutManager::UT_InfoWidgetLayoutManager() |
35 UT_InfoWidgetLayoutManager::UT_InfoWidgetLayoutManager() |
162 QVERIFY(roles.count() == KNumOfInfoDisplayRoles); |
173 QVERIFY(roles.count() == KNumOfInfoDisplayRoles); |
163 if (roles.count() == KNumOfInfoDisplayRoles) { |
174 if (roles.count() == KNumOfInfoDisplayRoles) { |
164 QVERIFY(0 <= roles.indexOf( |
175 QVERIFY(0 <= roles.indexOf( |
165 InfoWidgetLayoutManager::RoleContent)); |
176 InfoWidgetLayoutManager::RoleContent)); |
166 QVERIFY(0 <= roles.indexOf( |
177 QVERIFY(0 <= roles.indexOf( |
167 InfoWidgetLayoutManager::RoleHomeZoneLabel)); |
178 InfoWidgetLayoutManager::RoleSpnLabel)); |
168 QVERIFY(0 <= roles.indexOf( |
179 QVERIFY(0 <= roles.indexOf( |
169 InfoWidgetLayoutManager::RoleMcnMarqueeItem)); |
180 InfoWidgetLayoutManager::RoleMcnMarqueeItem)); |
170 QVERIFY(0 <= roles.indexOf( |
181 QVERIFY(0 <= roles.indexOf( |
171 InfoWidgetLayoutManager::RoleActiveLineLabel)); |
182 InfoWidgetLayoutManager::RoleSatMarqueeItem)); |
172 QVERIFY(0 <= roles.indexOf( |
183 QVERIFY(0 <= roles.indexOf( |
173 InfoWidgetLayoutManager::RoleSatTextLabel)); |
184 InfoWidgetLayoutManager::RoleSpnIcon)); |
174 QVERIFY(0 <= roles.indexOf( |
|
175 InfoWidgetLayoutManager::RoleHomeZoneIcon)); |
|
176 QVERIFY(0 <= roles.indexOf( |
185 QVERIFY(0 <= roles.indexOf( |
177 InfoWidgetLayoutManager::RoleMcnIcon)); |
186 InfoWidgetLayoutManager::RoleMcnIcon)); |
178 QVERIFY(0 <= roles.indexOf( |
|
179 InfoWidgetLayoutManager::RoleActiveLineIcon)); |
|
180 QVERIFY(0 <= roles.indexOf( |
187 QVERIFY(0 <= roles.indexOf( |
181 InfoWidgetLayoutManager::RoleSatTextIcon)); |
188 InfoWidgetLayoutManager::RoleSatTextIcon)); |
182 QVERIFY(0 <= roles.indexOf( |
189 QVERIFY(0 <= roles.indexOf( |
183 InfoWidgetLayoutManager::RoleSettingsContainer)); |
190 InfoWidgetLayoutManager::RoleSettingsContainer)); |
184 } |
191 } |
211 const int KLayoutRows = 1; |
218 const int KLayoutRows = 1; |
212 m_layoutManager->setLayoutRows(KLayoutRows); |
219 m_layoutManager->setLayoutRows(KLayoutRows); |
213 QVERIFY(KLayoutRows == m_layoutManager->layoutRows()); |
220 QVERIFY(KLayoutRows == m_layoutManager->layoutRows()); |
214 } |
221 } |
215 |
222 |
|
223 /*! |
|
224 UT_InfoWidgetLayoutManager::t_setLayoutRows |
|
225 *//* |
|
226 void UT_InfoWidgetLayoutManager::t_rowHeight() |
|
227 { |
|
228 QVERIFY(m_layoutManager->rowHeight()); |
|
229 }*/ |
216 |
230 |
217 /*! |
231 /*! |
218 UT_InfoWidgetLayoutManager::t_layoutInfoDisplay |
232 UT_InfoWidgetLayoutManager::t_layoutInfoDisplay |
219 */ |
233 */ |
220 void UT_InfoWidgetLayoutManager::t_layoutInfoDisplay() |
234 void UT_InfoWidgetLayoutManager::t_layoutInfoDisplay() |
221 { |
235 { |
222 m_layoutManager->layoutInfoDisplay(); |
236 QVERIFY(!m_layoutManager->layoutInfoDisplay()); |
223 } |
237 } |
224 |
238 |
225 |
239 |
226 /*! |
240 /*! |
227 UT_InfoWidgetLayoutManager::t_layoutSettingsDisplay |
241 UT_InfoWidgetLayoutManager::t_layoutSettingsDisplay |
228 */ |
242 */ |
229 void UT_InfoWidgetLayoutManager::t_layoutSettingsDisplay() |
243 void UT_InfoWidgetLayoutManager::t_layoutSettingsDisplay() |
230 { |
244 { |
231 m_layoutManager->layoutSettingsDisplay(); |
245 QVERIFY(!m_layoutManager->layoutSettingsDisplay()); |
232 } |
246 } |
233 |
247 |
234 /*! |
248 /*! |
235 UT_InfoWidgetLayoutManager::t_widgetRoles |
249 UT_InfoWidgetLayoutManager::t_widgetRoles |
236 */ |
250 */ |
242 QVERIFY(settingDisplayRoles.count() == KNumOfSettingsDisplayRoles); |
256 QVERIFY(settingDisplayRoles.count() == KNumOfSettingsDisplayRoles); |
243 if (settingDisplayRoles.count() == KNumOfSettingsDisplayRoles) { |
257 if (settingDisplayRoles.count() == KNumOfSettingsDisplayRoles) { |
244 QVERIFY(0 <= settingDisplayRoles.indexOf( |
258 QVERIFY(0 <= settingDisplayRoles.indexOf( |
245 InfoWidgetLayoutManager::RoleContent)); |
259 InfoWidgetLayoutManager::RoleContent)); |
246 QVERIFY(0 <= settingDisplayRoles.indexOf( |
260 QVERIFY(0 <= settingDisplayRoles.indexOf( |
247 InfoWidgetLayoutManager::RoleHomeZoneLabel)); |
|
248 QVERIFY(0 <= settingDisplayRoles.indexOf( |
|
249 InfoWidgetLayoutManager::RoleMcnLabel)); |
261 InfoWidgetLayoutManager::RoleMcnLabel)); |
250 QVERIFY(0 <= settingDisplayRoles.indexOf( |
262 QVERIFY(0 <= settingDisplayRoles.indexOf( |
251 InfoWidgetLayoutManager::RoleActiveLineLabel)); |
|
252 QVERIFY(0 <= settingDisplayRoles.indexOf( |
|
253 InfoWidgetLayoutManager::RoleSatTextLabel)); |
263 InfoWidgetLayoutManager::RoleSatTextLabel)); |
254 QVERIFY(0 <= settingDisplayRoles.indexOf( |
264 QVERIFY(0 <= settingDisplayRoles.indexOf( |
255 InfoWidgetLayoutManager::RoleHomeZoneIcon)); |
|
256 QVERIFY(0 <= settingDisplayRoles.indexOf( |
|
257 InfoWidgetLayoutManager::RoleMcnIcon)); |
265 InfoWidgetLayoutManager::RoleMcnIcon)); |
258 QVERIFY(0 <= settingDisplayRoles.indexOf( |
266 QVERIFY(0 <= settingDisplayRoles.indexOf( |
259 InfoWidgetLayoutManager::RoleActiveLineIcon)); |
|
260 QVERIFY(0 <= settingDisplayRoles.indexOf( |
|
261 InfoWidgetLayoutManager::RoleSatTextIcon)); |
267 InfoWidgetLayoutManager::RoleSatTextIcon)); |
262 QVERIFY(0 <= settingDisplayRoles.indexOf( |
268 QVERIFY(0 <= settingDisplayRoles.indexOf( |
263 InfoWidgetLayoutManager::RoleHomeZoneCheckBox)); |
|
264 QVERIFY(0 <= settingDisplayRoles.indexOf( |
|
265 InfoWidgetLayoutManager::RoleMcnCheckBox)); |
269 InfoWidgetLayoutManager::RoleMcnCheckBox)); |
266 QVERIFY(0 <= settingDisplayRoles.indexOf( |
270 QVERIFY(0 <= settingDisplayRoles.indexOf( |
267 InfoWidgetLayoutManager::RoleActiveLineCheckBox)); |
|
268 QVERIFY(0 <= settingDisplayRoles.indexOf( |
|
269 InfoWidgetLayoutManager::RoleSatTextCheckBox)); |
271 InfoWidgetLayoutManager::RoleSatTextCheckBox)); |
270 QVERIFY(0 <= settingDisplayRoles.indexOf( |
272 QVERIFY(0 <= settingDisplayRoles.indexOf( |
271 InfoWidgetLayoutManager::RoleOkButton)); |
273 InfoWidgetLayoutManager::RoleOkButton)); |
|
274 QVERIFY(0 <= settingDisplayRoles.indexOf( |
|
275 InfoWidgetLayoutManager::RoleSpnLabel)); |
|
276 QVERIFY(0 <= settingDisplayRoles.indexOf( |
|
277 InfoWidgetLayoutManager::RoleSpnIcon)); |
|
278 QVERIFY(0 <= settingDisplayRoles.indexOf( |
|
279 InfoWidgetLayoutManager::RoleSpnCheckBox)); |
|
280 |
272 QVERIFY(0 <= settingDisplayRoles.indexOf( |
281 QVERIFY(0 <= settingDisplayRoles.indexOf( |
273 InfoWidgetLayoutManager::RoleSettingsContainer)); |
282 InfoWidgetLayoutManager::RoleSettingsContainer)); |
274 } |
283 } |
275 |
284 |
276 const QList<InfoWidgetLayoutManager::LayoutItemRole> infoDisplayRoles = |
285 const QList<InfoWidgetLayoutManager::LayoutItemRole> infoDisplayRoles = |
278 QVERIFY(infoDisplayRoles.count() == KNumOfInfoDisplayRoles); |
287 QVERIFY(infoDisplayRoles.count() == KNumOfInfoDisplayRoles); |
279 if (infoDisplayRoles.count() == KNumOfInfoDisplayRoles) { |
288 if (infoDisplayRoles.count() == KNumOfInfoDisplayRoles) { |
280 QVERIFY(0 <= infoDisplayRoles.indexOf( |
289 QVERIFY(0 <= infoDisplayRoles.indexOf( |
281 InfoWidgetLayoutManager::RoleContent)); |
290 InfoWidgetLayoutManager::RoleContent)); |
282 QVERIFY(0 <= infoDisplayRoles.indexOf( |
291 QVERIFY(0 <= infoDisplayRoles.indexOf( |
283 InfoWidgetLayoutManager::RoleHomeZoneLabel)); |
292 InfoWidgetLayoutManager::RoleSpnLabel)); |
284 QVERIFY(0 <= infoDisplayRoles.indexOf( |
293 QVERIFY(0 <= infoDisplayRoles.indexOf( |
285 InfoWidgetLayoutManager::RoleMcnMarqueeItem)); |
294 InfoWidgetLayoutManager::RoleMcnMarqueeItem)); |
286 QVERIFY(0 <= infoDisplayRoles.indexOf( |
295 QVERIFY(0 <= infoDisplayRoles.indexOf( |
287 InfoWidgetLayoutManager::RoleActiveLineLabel)); |
296 InfoWidgetLayoutManager::RoleSatMarqueeItem)); |
288 QVERIFY(0 <= infoDisplayRoles.indexOf( |
297 QVERIFY(0 <= infoDisplayRoles.indexOf( |
289 InfoWidgetLayoutManager::RoleSatTextLabel)); |
298 InfoWidgetLayoutManager::RoleSpnIcon)); |
290 QVERIFY(0 <= infoDisplayRoles.indexOf( |
|
291 InfoWidgetLayoutManager::RoleHomeZoneIcon)); |
|
292 QVERIFY(0 <= infoDisplayRoles.indexOf( |
299 QVERIFY(0 <= infoDisplayRoles.indexOf( |
293 InfoWidgetLayoutManager::RoleMcnIcon)); |
300 InfoWidgetLayoutManager::RoleMcnIcon)); |
294 QVERIFY(0 <= infoDisplayRoles.indexOf( |
301 QVERIFY(0 <= infoDisplayRoles.indexOf( |
295 InfoWidgetLayoutManager::RoleActiveLineIcon)); |
|
296 QVERIFY(0 <= infoDisplayRoles.indexOf( |
|
297 InfoWidgetLayoutManager::RoleSatTextIcon)); |
302 InfoWidgetLayoutManager::RoleSatTextIcon)); |
298 QVERIFY(0 <= infoDisplayRoles.indexOf( |
303 QVERIFY(0 <= infoDisplayRoles.indexOf( |
299 InfoWidgetLayoutManager::RoleSettingsContainer)); |
304 InfoWidgetLayoutManager::RoleSettingsContainer)); |
300 } |
305 } |
301 } |
306 } |
302 |
307 |
303 |
|
304 /*! |
308 /*! |
305 UT_InfoWidgetLayoutManager::t_loadWidgets |
309 UT_InfoWidgetLayoutManager::t_loadWidgets |
306 */ |
310 */ |
307 void UT_InfoWidgetLayoutManager::t_loadWidgets() |
311 void UT_InfoWidgetLayoutManager::t_loadWidgets() |
308 { |
312 { |
309 bool loadResult; |
313 QObjectList list = QObjectList(); |
310 //m_layoutManager->loadWidgets(); |
314 EXPECT(HbDocumentLoader::load) |
|
315 .willOnce(invoke(this, &fillParams)).returns(list); |
|
316 |
|
317 const QList<InfoWidgetLayoutManager::LayoutItemRole> settingDisplayRoles = |
|
318 m_layoutManager->widgetRoles(InfoWidgetLayoutManager::SettingsDisplay); |
|
319 bool loadResult = m_layoutManager->loadWidgets(InfoWidgetLayoutManager::SettingsDisplay, |
|
320 settingDisplayRoles, |
|
321 m_layoutManager->m_infoDisplayWidgets); |
|
322 |
|
323 QVERIFY(!loadResult); |
311 } |
324 } |
312 |
325 |
313 /*! |
326 /*! |
314 UT_InfoWidgetLayoutManager::t_loadWidget |
327 UT_InfoWidgetLayoutManager::t_loadWidget |
315 */ |
328 */ |
319 InfoWidgetLayoutManager::LayoutItemRole currentRole; |
332 InfoWidgetLayoutManager::LayoutItemRole currentRole; |
320 |
333 |
321 QList<InfoWidgetLayoutManager::LayoutItemRole> |
334 QList<InfoWidgetLayoutManager::LayoutItemRole> |
322 infoDisplayWidgetRoles = m_layoutManager->widgetRoles( |
335 infoDisplayWidgetRoles = m_layoutManager->widgetRoles( |
323 InfoWidgetLayoutManager::InfoDisplay); |
336 InfoWidgetLayoutManager::InfoDisplay); |
|
337 |
|
338 infoDisplayWidgetRoles.append(InfoWidgetLayoutManager::RoleUndefined); |
|
339 infoDisplayWidgetRoles.append(InfoWidgetLayoutManager::RoleContainer); |
|
340 |
324 |
341 |
325 foreach (currentRole, infoDisplayWidgetRoles) { |
342 foreach (currentRole, infoDisplayWidgetRoles) { |
326 currentWidget = m_layoutManager->loadWidget(*m_documentLoader, |
343 currentWidget = m_layoutManager->loadWidget(*m_documentLoader, |
327 InfoWidgetLayoutManager::InfoDisplay, |
344 InfoWidgetLayoutManager::InfoDisplay, |
328 currentRole); |
345 currentRole); |
|
346 QVERIFY(!currentWidget); |
329 } |
347 } |
330 |
348 |
331 QList<InfoWidgetLayoutManager::LayoutItemRole> |
349 QList<InfoWidgetLayoutManager::LayoutItemRole> |
332 settingsDisplayWidgetRoles = m_layoutManager->widgetRoles( |
350 settingsDisplayWidgetRoles = m_layoutManager->widgetRoles( |
333 InfoWidgetLayoutManager::SettingsDisplay); |
351 InfoWidgetLayoutManager::SettingsDisplay); |
334 |
352 |
335 foreach (currentRole, settingsDisplayWidgetRoles) { |
353 foreach (currentRole, settingsDisplayWidgetRoles) { |
336 currentWidget = m_layoutManager->loadWidget(*m_documentLoader, |
354 currentWidget = m_layoutManager->loadWidget(*m_documentLoader, |
337 InfoWidgetLayoutManager::SettingsDisplay, |
355 InfoWidgetLayoutManager::SettingsDisplay, |
338 currentRole); |
356 currentRole); |
339 } |
357 QVERIFY(!currentWidget); |
340 |
358 } |
|
359 |
|
360 currentWidget = m_layoutManager->loadWidget(*m_documentLoader, |
|
361 (InfoWidgetLayoutManager::DisplayRole)2, |
|
362 InfoWidgetLayoutManager::RoleLastEnum ); |
|
363 |
|
364 QVERIFY(!currentWidget); |
341 } |
365 } |
342 |
366 |
343 /*! |
367 /*! |
344 UT_InfoWidgetLayoutManager::t_getWidget |
368 UT_InfoWidgetLayoutManager::t_getWidget |
345 */ |
369 */ |
346 void UT_InfoWidgetLayoutManager::t_getWidget() |
370 void UT_InfoWidgetLayoutManager::t_getWidget() |
347 { |
371 { |
348 fillCurrentWidgetsContainer(); |
372 fillCurrentWidgetsContainer(); |
349 |
373 |
350 m_layoutManager->getWidget(InfoWidgetLayoutManager::RoleUndefined); |
374 QVERIFY(!m_layoutManager->getWidget(InfoWidgetLayoutManager::RoleUndefined)); |
351 m_layoutManager->getWidget(InfoWidgetLayoutManager::RoleContent); |
375 QVERIFY(m_layoutManager->getWidget(InfoWidgetLayoutManager::RoleContent)); |
352 m_layoutManager->getWidget(InfoWidgetLayoutManager::RoleLastEnum); |
376 QVERIFY(!m_layoutManager->getWidget(InfoWidgetLayoutManager::RoleLastEnum)); |
|
377 } |
|
378 |
|
379 /*! |
|
380 UT_InfoWidgetLayoutManager::t_removeWidget |
|
381 */ |
|
382 void UT_InfoWidgetLayoutManager::t_removeWidget() |
|
383 { |
|
384 fillCurrentWidgetsContainer(); |
|
385 |
|
386 m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleUndefined); |
|
387 m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleContent); |
|
388 m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleLastEnum); |
|
389 |
|
390 QVERIFY(verify()); |
353 } |
391 } |
354 |
392 |
355 |
393 |
356 /*! |
394 /*! |
357 UT_InfoWidgetLayoutManager::t_contentWidget |
395 UT_InfoWidgetLayoutManager::t_contentWidget |
358 */ |
396 */ |
359 void UT_InfoWidgetLayoutManager::t_contentWidget() |
397 void UT_InfoWidgetLayoutManager::t_contentWidget() |
360 { |
398 { |
361 fillCurrentWidgetsContainer(); |
399 fillCurrentWidgetsContainer(); |
362 |
400 |
363 m_layoutManager->contentWidget(); |
401 QVERIFY(m_layoutManager->contentWidget()); |
364 } |
402 } |
365 |
403 |
366 |
404 |
367 /*! |
405 /*! |
368 UT_InfoWidgetLayoutManager::t_hideWidget |
406 UT_InfoWidgetLayoutManager::t_hideWidget |
372 fillCurrentWidgetsContainer(); |
410 fillCurrentWidgetsContainer(); |
373 |
411 |
374 m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleUndefined); |
412 m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleUndefined); |
375 m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleContent); |
413 m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleContent); |
376 m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleLastEnum); |
414 m_layoutManager->hideWidget(InfoWidgetLayoutManager::RoleLastEnum); |
|
415 |
|
416 QVERIFY(verify()); |
377 } |
417 } |
378 |
418 |
379 |
419 |
380 /*! |
420 /*! |
381 UT_InfoWidgetLayoutManager::t_hideAll |
421 UT_InfoWidgetLayoutManager::t_hideAll |
382 */ |
422 */ |
383 void UT_InfoWidgetLayoutManager::t_hideAll() |
423 void UT_InfoWidgetLayoutManager::t_hideAll() |
384 { |
424 { |
385 fillCurrentWidgetsContainer(); |
|
386 |
|
387 m_layoutManager->hideAll(); |
425 m_layoutManager->hideAll(); |
|
426 |
|
427 QVERIFY(verify()); |
388 } |
428 } |
389 |
429 |
390 |
430 |
391 /*! |
431 /*! |
392 UT_InfoWidgetLayoutManager::t_showAll |
432 UT_InfoWidgetLayoutManager::t_showAll |
393 */ |
433 */ |
394 void UT_InfoWidgetLayoutManager::t_showAll() |
434 void UT_InfoWidgetLayoutManager::t_showAll() |
395 { |
435 { |
396 fillCurrentWidgetsContainer(); |
436 fillCurrentWidgetsContainer();//times 2 HbDocumentLoader::load |
397 |
|
398 m_layoutManager->showAll(); |
437 m_layoutManager->showAll(); |
399 } |
438 |
400 |
439 QVERIFY(verify()); |
|
440 } |
|
441 |
|
442 /*! |
|
443 UT_InfoWidgetLayoutManager::t_reloadWidgets |
|
444 */ |
|
445 void UT_InfoWidgetLayoutManager::t_reloadWidgets() |
|
446 { |
|
447 QVERIFY(!m_layoutManager->reloadWidgets(InfoWidgetLayoutManager::SettingsDisplay)); |
|
448 QVERIFY(!m_layoutManager->reloadWidgets((InfoWidgetLayoutManager::DisplayRole)101)); |
|
449 } |
|
450 |
|
451 /*! |
|
452 UT_InfoWidgetLayoutManager::t_createObject |
|
453 */ |
401 void UT_InfoWidgetLayoutManager::t_createObject() |
454 void UT_InfoWidgetLayoutManager::t_createObject() |
402 { |
455 { |
403 m_documentLoader->createObject(QString(), QString()); |
456 QObject *object = m_documentLoader->createObject(QString(), QString()); |
|
457 QVERIFY(!object); |
|
458 object = m_documentLoader->createObject(KMargueeItemClassName, QString()); |
|
459 QVERIFY(object); |
|
460 delete object; |
|
461 |
|
462 //For destructor coverage |
|
463 delete m_layoutManager->m_documentLoader; |
|
464 m_layoutManager->m_documentLoader = NULL; |
404 } |
465 } |
405 |
466 |
406 QTEST_MAIN_S60(UT_InfoWidgetLayoutManager) |
467 QTEST_MAIN_S60(UT_InfoWidgetLayoutManager) |