13 * |
13 * |
14 * Description: tester for methods in VideoListWidget |
14 * Description: tester for methods in VideoListWidget |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
|
18 // Version : %version: 46 % |
|
19 |
18 #include <qmap.h> |
20 #include <qmap.h> |
19 #include <vcxmyvideosdefs.h> |
21 #include <vcxmyvideosdefs.h> |
20 #include <mpxhbvideocommondefs.h> |
22 #include <mpxhbvideocommondefs.h> |
21 |
23 |
22 #include "hbglobal.h" |
24 #include "hbglobal.h" |
23 #include "hblistview.h" |
25 #include "hblistview.h" |
24 #include "hbview.h" |
26 #include "hbview.h" |
25 #include "videoservices.h" |
|
26 #include "videosortfilterproxymodel.h" |
27 #include "videosortfilterproxymodel.h" |
27 #include "hbscrollbar.h" |
28 #include "hbscrollbar.h" |
28 #include "hbmenu.h" |
29 #include "hbmenu.h" |
29 #include "hbmessagebox.h" |
30 #include "hbmessagebox.h" |
30 #include "hbinstance.h" |
31 #include "hbinstance.h" |
31 #include "hbmainwindow.h" |
32 #include "hbmainwindow.h" |
32 #include "hbstyleloader.h" |
33 #include "hbstyleloader.h" |
|
34 #include "hbinputdialog.h" |
33 #include "videothumbnaildata.h" |
35 #include "videothumbnaildata.h" |
34 #include "videocollectioncommon.h" |
36 #include "videocollectioncommon.h" |
35 #include "videocollectionwrapper.h" |
37 #include "videocollectionwrapper.h" |
36 #include "videocollectionwrapperdata.h" |
38 #include "videocollectionwrapperdata.h" |
37 #include "hbmenudata.h" |
39 #include "hbmenudata.h" |
38 #include "videothumbnailtestdata.h" |
40 #include "videothumbnailtestdata.h" |
39 #include "videolistdatamodel.h" |
41 #include "videolistdatamodel.h" |
40 #include "videolistdatamodeldata.h" |
42 #include "videolistdatamodeldata.h" |
41 #include "videosortfilterproxymodeldata.h" |
43 #include "videosortfilterproxymodeldata.h" |
42 #include "videoservices.h" |
|
43 #include "videocollectionuiloader.h" |
44 #include "videocollectionuiloader.h" |
44 #include "videocollectionuiloaderdata.h" |
45 #include "videocollectionuiloaderdata.h" |
45 #include "videolistselectiondialog.h" |
46 #include "videolistselectiondialog.h" |
46 #include "videolistselectiondialogdata.h" |
47 #include "videolistselectiondialogdata.h" |
47 #include "hbmessageboxdata.h" |
48 #include "hbmessageboxdata.h" |
48 |
49 |
49 #include "testlistwidget.h" |
50 #include "testlistwidget.h" |
50 |
51 |
51 #define private public |
52 #define private public |
52 #include "videolistwidget.h" |
53 #include "videolistwidget.h" |
|
54 #include "videoservices.h" |
53 #undef private |
55 #undef private |
54 |
56 |
55 static const int CONTEXT_MENU_COUNT = 8; |
57 static const int CONTEXT_MENU_COUNT = 8; |
56 |
58 |
57 /** |
59 /** |
234 HbMenuData::mEnabledSetted = true; |
246 HbMenuData::mEnabledSetted = true; |
235 HbListView::mLatestVisibility = false; |
247 HbListView::mLatestVisibility = false; |
236 HbListView::mLatestEnableValue = false; |
248 HbListView::mLatestEnableValue = false; |
237 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0; |
249 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0; |
238 |
250 |
239 // model exists, current view exists, level neither ELevelAlbum nor ELevelDefaultColl, |
251 // model exists, current view exists, level neither ELevelAlbum nor ELevelDefaultColl |
240 // no mNavKeyQuitAction |
|
241 HbView *tmpView = new HbView(); |
252 HbView *tmpView = new HbView(); |
242 hbInstance->allMainWindows().value(0)->addView(tmpView); |
253 hbInstance->allMainWindows().value(0)->addView(tmpView); |
243 HbAction *tmpAction = mTestWidget->mNavKeyQuitAction; |
|
244 mTestWidget->mNavKeyQuitAction = 0; |
|
245 QVERIFY(mTestWidget->activate() == 0); |
254 QVERIFY(mTestWidget->activate() == 0); |
246 QCOMPARE(HbMenuData::mEnabledSetted, true); |
255 QCOMPARE(HbMenuData::mEnabledSetted, true); |
247 QCOMPARE(HbListView::mLatestVisibility, true); |
256 QCOMPARE(HbListView::mLatestVisibility, true); |
248 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1); |
257 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1); |
249 QVERIFY(!tmpView->mNavigationAction); |
258 QVERIFY(mTestWidget->mNavKeyAction); |
250 |
259 QVERIFY(HbAction::mNavAction == Hb::QuitAction); |
|
260 |
251 HbMenuData::mEnabledSetted = true; |
261 HbMenuData::mEnabledSetted = true; |
252 HbListView::mLatestVisibility = false; |
262 HbListView::mLatestVisibility = false; |
253 HbListView::mLatestEnableValue = false; |
263 HbListView::mLatestEnableValue = false; |
254 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0; |
264 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0; |
255 mTestWidget->mNavKeyQuitAction = tmpAction; |
265 |
256 |
266 // model exists, current view exists, level is ELevelAlbum |
257 // model exists, current view exists, level neither ELevelAlbum nor ELevelDefaultColl, |
267 delete mTestWidget; |
258 // mNavKeyQuitAction exists |
268 mTestWidget = 0; |
259 QVERIFY(mTestWidget->activate() == 0); |
269 mTestWidget = new ListWidgetTester(mTestUiLoader, mTempView); |
260 QCOMPARE(HbMenuData::mEnabledSetted, true); |
270 model = wrapper.getModel(VideoCollectionCommon::EModelTypeCollectionContent); |
261 QCOMPARE(HbListView::mLatestVisibility, true); |
|
262 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1); |
|
263 QVERIFY(tmpView->mNavigationAction == tmpAction); |
|
264 |
|
265 HbMenuData::mEnabledSetted = true; |
|
266 HbListView::mLatestVisibility = false; |
|
267 HbListView::mLatestEnableValue = false; |
|
268 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0; |
|
269 |
|
270 // model exists, current view exists, level is ELevelAlbum |
|
271 // no mNavKeyBackAction |
|
272 tmpView->mNavigationAction = 0; |
271 tmpView->mNavigationAction = 0; |
273 tmpAction = mTestWidget->mNavKeyBackAction; |
272 QVERIFY(mTestWidget->initialize(*model) == 0); |
274 mTestWidget->mNavKeyBackAction = 0; |
|
275 QVERIFY(mTestWidget->activate(VideoCollectionCommon::ELevelAlbum) == 0); |
273 QVERIFY(mTestWidget->activate(VideoCollectionCommon::ELevelAlbum) == 0); |
276 QCOMPARE(HbMenuData::mEnabledSetted, true); |
274 QCOMPARE(HbMenuData::mEnabledSetted, true); |
277 QCOMPARE(HbListView::mLatestVisibility, true); |
275 QCOMPARE(HbListView::mLatestVisibility, true); |
278 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1); |
276 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1); |
279 QVERIFY(!tmpView->mNavigationAction); |
277 QVERIFY(mTestWidget->mNavKeyAction); |
|
278 QVERIFY(HbAction::mNavAction == Hb::BackAction); |
280 |
279 |
281 HbMenuData::mEnabledSetted = true; |
280 HbMenuData::mEnabledSetted = true; |
282 HbListView::mLatestVisibility = false; |
281 HbListView::mLatestVisibility = false; |
283 HbListView::mLatestEnableValue = false; |
282 HbListView::mLatestEnableValue = false; |
284 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0; |
283 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0; |
285 |
284 |
286 mTestWidget->mNavKeyBackAction = tmpAction; |
285 // activate: |
287 // model exists, current view exists, level neither ELevelAlbum nor ELevelDefaultColl, |
286 // -is service |
288 // mNavKeyBackAction exists |
287 // -current service is browse |
289 QVERIFY(mTestWidget->activate(VideoCollectionCommon::ELevelAlbum) == 0); |
288 VideoServices *videoServices = VideoServices::instance(); |
290 QCOMPARE(HbMenuData::mEnabledSetted, true); |
289 videoServices->mCurrentService = VideoServices::EBrowse; |
291 QCOMPARE(HbListView::mLatestVisibility, true); |
290 delete mTestWidget; |
292 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1); |
291 mTestWidget = 0; |
293 QVERIFY(tmpView->mNavigationAction == tmpAction); |
292 mTestWidget = new ListWidgetTester(mTestUiLoader, mTempView); |
294 |
293 QVERIFY(mTestWidget->initialize(*model, videoServices) == 0); |
295 HbMenuData::mEnabledSetted = true; |
294 QVERIFY(mTestWidget->activate(VideoCollectionCommon::ELevelDefaultColl) == 0); |
296 HbListView::mLatestVisibility = false; |
295 QVERIFY(mTestWidget->mNavKeyAction); |
297 HbListView::mLatestEnableValue = false; |
296 QVERIFY(HbAction::mNavAction == Hb::QuitAction); |
298 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0; |
297 |
299 |
|
300 hbInstance->allMainWindows().value(0)->removeView(tmpView); |
298 hbInstance->allMainWindows().value(0)->removeView(tmpView); |
301 delete tmpView; |
299 delete tmpView; |
|
300 |
|
301 // final cleanup |
|
302 videoServices->mCurrentService = VideoServices::ENoService; |
|
303 videoServices->decreaseReferenceCount(); |
302 } |
304 } |
303 |
305 |
304 // --------------------------------------------------------------------------- |
306 // --------------------------------------------------------------------------- |
305 // testDeactivate |
307 // testDeactivate |
306 // --------------------------------------------------------------------------- |
308 // --------------------------------------------------------------------------- |
307 // |
309 // |
308 void TestListWidget::testDeactivate() |
310 void TestListWidget::testDeactivate() |
309 { |
311 { |
310 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
312 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
311 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
313 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); |
312 |
314 |
313 HbListView::mLatestVisibility = true; |
315 HbListView::mLatestVisibility = true; |
314 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 1; |
316 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 1; |
315 |
317 |
316 mTestWidget->activate(); |
318 mTestWidget->activate(); |
485 mTestWidget->callEmiteActivated(fetchIndex); |
508 mTestWidget->callEmiteActivated(fetchIndex); |
486 QVERIFY(spysignal.count() == 0); |
509 QVERIFY(spysignal.count() == 0); |
487 QVERIFY(spysignalFileUri.count() == 0); |
510 QVERIFY(spysignalFileUri.count() == 0); |
488 QVERIFY(spysignalActivated.count() == 0); |
511 QVERIFY(spysignalActivated.count() == 0); |
489 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); |
512 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); |
490 } |
513 |
491 |
514 // final cleanup |
492 |
515 videoServices->decreaseReferenceCount(); |
493 // --------------------------------------------------------------------------- |
516 } |
494 // testLongPressGesture |
517 |
495 // --------------------------------------------------------------------------- |
518 // --------------------------------------------------------------------------- |
496 // |
519 // testLongPressedSlot |
497 void TestListWidget::testLongPressGesture() |
520 // --------------------------------------------------------------------------- |
498 { |
521 // |
499 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
522 void TestListWidget::testLongPressedSlot() |
500 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
523 { |
|
524 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
|
525 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); |
501 |
526 |
502 QVariant data = QString("test"); |
527 QVariant data = QString("test"); |
503 // correct data to index 0 |
528 // correct data to index 0 |
504 VideoListDataModelData::setData( Qt::DisplayRole, data); |
529 VideoListDataModelData::setData(Qt::DisplayRole, data); |
505 setRowCount(2); |
530 setRowCount(2); |
506 |
531 |
507 QPointF point(1,1); |
532 QPointF point(1,1); |
508 mTestWidget->initialize(*model); |
533 mTestWidget->initialize(*model); |
509 |
534 |
|
535 HbAbstractViewItem *item = new HbAbstractViewItem(); |
|
536 item->mModelIndex = mTestWidget->mModel->index(0, 0, QModelIndex()); |
510 mTestWidget->setSelectionMode(HbAbstractItemView::MultiSelection); |
537 mTestWidget->setSelectionMode(HbAbstractItemView::MultiSelection); |
|
538 |
511 // mDetailsReady is false |
539 // mDetailsReady is false |
512 mTestWidget->callLongPressGesture(point); |
540 mTestWidget->callLongPressedSlot(item, point); |
513 QVERIFY(HbMenuData::mExecPoint != point); |
541 QVERIFY(HbMenuData::mExecPoint != point); |
514 QVERIFY(HbListView::mLongPressedPoint != point); |
|
515 |
542 |
516 // multiselection is on |
543 // multiselection is on |
517 mTestWidget->callLongPressGesture(point); |
544 mTestWidget->callLongPressedSlot(item, point); |
518 QVERIFY(HbMenuData::mExecPoint != point); |
545 QVERIFY(HbMenuData::mExecPoint != point); |
519 |
546 |
520 // selection mode is custom |
547 // selection mode is custom |
521 mTestWidget->setSelectionMode(-1); |
548 mTestWidget->setSelectionMode(-1); |
522 |
549 mTestWidget->callLongPressedSlot(item, point); |
523 mTestWidget->callLongPressGesture(point); |
|
524 QVERIFY(HbMenuData::mExecPoint != point); |
550 QVERIFY(HbMenuData::mExecPoint != point); |
525 |
551 |
526 // item at position is null |
552 // item is null |
527 HbListViewItem *pTmp = mTestWidget->mItem; |
|
528 mTestWidget->mItem = 0; |
|
529 mTestWidget->setSelectionMode(HbAbstractItemView::NoSelection); |
553 mTestWidget->setSelectionMode(HbAbstractItemView::NoSelection); |
530 HbListView::mCurrentIndex = QModelIndex(); |
554 HbListView::mCurrentIndex = QModelIndex(); |
531 mTestWidget->callLongPressGesture(point); |
555 mTestWidget->callLongPressedSlot(0, point); |
532 QVERIFY(HbMenuData::mExecPoint != point); |
556 QVERIFY(HbMenuData::mExecPoint != point); |
533 QVERIFY(HbListView::mLongPressedPoint == point); |
557 |
534 |
558 // item has invalid index |
535 // item at position is not null, but returns invalid index |
559 item->mModelIndex = QModelIndex(); |
536 mTestWidget->mItem = pTmp; |
560 mTestWidget->callLongPressedSlot(item, point); |
537 mTestWidget->mItem->mModelIndex = QModelIndex(); |
|
538 mTestWidget->callLongPressGesture(point); |
|
539 QVERIFY(HbMenuData::mExecPoint != point); |
561 QVERIFY(HbMenuData::mExecPoint != point); |
540 QVERIFY(HbListView::mLongPressedPoint == point); |
|
541 |
562 |
542 // item at position is not null, returns current index is valid |
563 // item at position is not null, returns current index is valid |
543 HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); |
564 item->mModelIndex = model->index(0, 0, QModelIndex()); |
544 mTestWidget->mItem->mModelIndex = HbListView::mCurrentIndex ; |
565 mTestWidget->mItem->mModelIndex = HbListView::mCurrentIndex ; |
545 |
566 |
546 // model is == 0 |
567 // model is null |
547 VideoSortFilterProxyModel *tmp = mTestWidget->mModel; |
568 VideoSortFilterProxyModel *tmp = mTestWidget->mModel; |
548 mTestWidget->mModel = 0; |
569 mTestWidget->mModel = 0; |
549 mTestWidget->callLongPressGesture(point); |
570 mTestWidget->callLongPressedSlot(item, point); |
550 QVERIFY(HbMenuData::mExecPoint != point); |
571 QVERIFY(HbMenuData::mExecPoint != point); |
551 QVERIFY(HbListView::mLongPressedPoint == point); |
|
552 mTestWidget->mModel = tmp; |
572 mTestWidget->mModel = tmp; |
553 HbListView::mLongPressedPoint = QPointF(); |
573 |
554 |
574 // gotten id != KVcxMvcMediaTypeVideo, service is true and id != KVcxMvcMediaTypeAlbum |
555 // gotten id != KVcxMvcMediaTypeVideo, service is true and id != KVcxMvcMediaTypeAlbum |
|
556 VideoSortFilterProxyModelData::mItemIds.clear(); |
575 VideoSortFilterProxyModelData::mItemIds.clear(); |
557 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,1)); |
576 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,1)); |
558 mTestWidget->mIsService = true; |
577 mTestWidget->mIsService = true; |
559 mTestWidget->callLongPressGesture(point); |
578 mTestWidget->callLongPressedSlot(item, point); |
560 QVERIFY(HbMenuData::mExecPoint != point); |
579 QVERIFY(HbMenuData::mExecPoint == point); |
561 QVERIFY(HbListView::mLongPressedPoint == point); |
|
562 HbListView::mLongPressedPoint = QPointF(); |
|
563 |
580 |
564 // gotten id != KVcxMvcMediaTypeVideo, service is false and id != KVcxMvcMediaTypeAlbum |
581 // gotten id != KVcxMvcMediaTypeVideo, service is false and id != KVcxMvcMediaTypeAlbum |
565 VideoSortFilterProxyModelData::mItemIds.clear(); |
582 VideoSortFilterProxyModelData::mItemIds.clear(); |
566 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,1)); |
583 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,1)); |
567 mTestWidget->mIsService = false; |
584 mTestWidget->mIsService = false; |
568 mTestWidget->callLongPressGesture(point); |
585 mTestWidget->callLongPressedSlot(item, point); |
569 QVERIFY(HbMenuData::mExecPoint != point); |
586 QVERIFY(HbMenuData::mExecPoint == point); |
570 QVERIFY(HbListView::mLongPressedPoint == point); |
|
571 HbListView::mLongPressedPoint = QPointF(); |
|
572 |
587 |
573 // gotten id != KVcxMvcMediaTypeVideo, service is false and id == KVcxMvcMediaTypeAlbum |
588 // gotten id != KVcxMvcMediaTypeVideo, service is false and id == KVcxMvcMediaTypeAlbum |
574 VideoSortFilterProxyModelData::mItemIds.clear(); |
589 VideoSortFilterProxyModelData::mItemIds.clear(); |
575 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,2)); |
590 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,2)); |
576 mTestWidget->mIsService = false; |
591 mTestWidget->mIsService = false; |
577 mTestWidget->callLongPressGesture(point); |
592 mTestWidget->callLongPressedSlot(item, point); |
578 QVERIFY(HbMenuData::mExecPoint == point); |
593 QVERIFY(HbMenuData::mExecPoint == point); |
579 QVERIFY(HbListView::mLongPressedPoint == point); |
|
580 HbMenuData::mExecPoint = QPointF(); |
594 HbMenuData::mExecPoint = QPointF(); |
581 HbListView::mLongPressedPoint = QPointF(); |
|
582 |
595 |
583 // gotten id == KVcxMvcMediaTypeVideo |
596 // gotten id == KVcxMvcMediaTypeVideo |
584 VideoSortFilterProxyModelData::mItemIds.clear(); |
597 VideoSortFilterProxyModelData::mItemIds.clear(); |
585 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,02)); |
598 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,02)); |
586 mTestWidget->mIsService = false; |
599 mTestWidget->mIsService = false; |
587 mTestWidget->callLongPressGesture(point); |
600 mTestWidget->callLongPressedSlot(item, point); |
588 QVERIFY(HbMenuData::mExecPoint == point); |
601 QVERIFY(HbMenuData::mExecPoint == point); |
589 QVERIFY(HbListView::mLongPressedPoint == point); |
|
590 HbMenuData::mExecPoint = QPointF(); |
602 HbMenuData::mExecPoint = QPointF(); |
591 HbListView::mLongPressedPoint = QPointF(); |
|
592 |
603 |
593 // no context menu |
604 // no context menu |
594 // (context menu setup fails, due invalid amount of correct actions) |
605 // (context menu setup fails, due invalid amount of correct actions) |
595 QMap<VideoListWidget::TContextActionIds, HbAction*>::iterator iter = mTestWidget->mContextMenuActions.begin(); |
606 QMap<VideoListWidget::TContextActionIds, HbAction*>::iterator iter = |
|
607 mTestWidget->mContextMenuActions.begin(); |
596 iter++; |
608 iter++; |
597 HbAction *nullAction = 0; |
609 HbAction *nullAction = 0; |
598 iter.value() = nullAction; |
610 iter.value() = nullAction; |
599 mTestWidget->callLongPressGesture(point); |
611 mTestWidget->callLongPressedSlot(item, point); |
600 QVERIFY(HbMenuData::mExecPoint != point); |
612 QVERIFY(HbMenuData::mExecPoint != point); |
601 QVERIFY(HbListView::mLongPressedPoint == point); |
613 |
|
614 // long press gesture: |
|
615 // -is service |
|
616 // -current service is browse |
|
617 HbMenuData::mExecPoint = QPointF(); |
|
618 VideoServices *videoServices = VideoServices::instance(); |
|
619 videoServices->mCurrentService = VideoServices::EBrowse; |
|
620 delete mTestWidget; |
|
621 mTestWidget = 0; |
|
622 mTestWidget = new ListWidgetTester(mTestUiLoader, mTempView); |
|
623 QVERIFY(mTestWidget->initialize(*model, videoServices) == 0); |
|
624 QVERIFY(mTestWidget->activate(VideoCollectionCommon::ELevelDefaultColl) == 0); |
|
625 mTestWidget->mItem->mModelIndex = model->index(0, 0, QModelIndex()); |
|
626 mTestWidget->callLongPressedSlot(item, point); |
|
627 QCOMPARE(mTestWidget->mContextMenuActions.count(), 3); |
|
628 QVERIFY(mTestWidget->mContextMenuActions[VideoListWidget::EActionPlay]->isVisible()); |
|
629 QVERIFY(mTestWidget->mContextMenuActions[VideoListWidget::EActionDelete]->isVisible()); |
|
630 QVERIFY(mTestWidget->mContextMenuActions[VideoListWidget::EActionDetails]->isVisible()); |
|
631 |
|
632 // long press gesture: |
|
633 // -is service |
|
634 // -current service is EUriFetcher |
|
635 HbMenuData::mExecPoint = QPointF(); |
|
636 videoServices = VideoServices::instance(); |
|
637 videoServices->mCurrentService = VideoServices::EUriFetcher; |
|
638 delete mTestWidget; |
|
639 mTestWidget = 0; |
|
640 mTestWidget = new ListWidgetTester(mTestUiLoader, mTempView); |
|
641 QVERIFY(mTestWidget->initialize(*model, videoServices) == 0); |
|
642 QVERIFY(mTestWidget->activate(VideoCollectionCommon::ELevelDefaultColl) == 0); |
|
643 mTestWidget->mItem->mModelIndex = model->index(0, 0, QModelIndex()); |
|
644 mTestWidget->callLongPressedSlot(item, point); |
|
645 QCOMPARE(mTestWidget->mContextMenuActions.count(), 2); |
|
646 QVERIFY(mTestWidget->mContextMenuActions[VideoListWidget::EActionPlay]->isVisible()); |
|
647 QVERIFY(mTestWidget->mContextMenuActions[VideoListWidget::EActionDetails]->isVisible()); |
|
648 |
|
649 // final cleanup |
|
650 videoServices->decreaseReferenceCount(); |
|
651 delete item; |
|
652 } |
|
653 |
|
654 // --------------------------------------------------------------------------- |
|
655 // testPanGesture |
|
656 // --------------------------------------------------------------------------- |
|
657 // |
|
658 void TestListWidget::testPanGesture() |
|
659 { |
|
660 QPointF point(1,1); |
|
661 // no context menu |
|
662 mTestWidget->callPanGesture(point); |
|
663 QVERIFY(HbListView::mPanGesturePoint == point); |
|
664 |
|
665 // create context menu |
|
666 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
|
667 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); |
|
668 mTestWidget->initialize(*model); |
|
669 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(doDelayedsSlot())); |
|
670 emit testSignal(); |
|
671 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(doDelayedsSlot())); |
|
672 |
|
673 HbListView::mPanGesturePoint = QPointF(); |
|
674 |
|
675 // context menu visible |
|
676 mTestWidget->mContextMenu->setVisible(true); |
|
677 mTestWidget->callPanGesture(point); |
|
678 QVERIFY(HbListView::mPanGesturePoint != point); |
|
679 |
|
680 // context menu not visible |
|
681 mTestWidget->mContextMenu->setVisible(false); |
|
682 mTestWidget->callPanGesture(point); |
|
683 QVERIFY(HbListView::mPanGesturePoint == point); |
602 } |
684 } |
603 |
685 |
604 // --------------------------------------------------------------------------- |
686 // --------------------------------------------------------------------------- |
605 // testSetContextMenu |
687 // testSetContextMenu |
606 // --------------------------------------------------------------------------- |
688 // --------------------------------------------------------------------------- |
607 // |
689 // |
608 void TestListWidget::testSetContextMenu() |
690 void TestListWidget::testSetContextMenu() |
609 { |
691 { |
610 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
692 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
611 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
693 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); |
612 VideoListDataModel *sourceModel = qobject_cast<VideoListDataModel*>(model->sourceModel()); |
694 VideoListDataModel *sourceModel = qobject_cast<VideoListDataModel*>(model->sourceModel()); |
613 VideoSortFilterProxyModelData::mItemIds.clear(); |
695 VideoSortFilterProxyModelData::mItemIds.clear(); |
614 mTestWidget->initialize(*model); |
696 mTestWidget->initialize(*model); |
615 |
697 |
616 setRowCount(1); |
698 setRowCount(1); |
620 TMPXItemId itemId; |
702 TMPXItemId itemId; |
621 QPointF point(1,1); |
703 QPointF point(1,1); |
622 itemId.iId2 = 0; |
704 itemId.iId2 = 0; |
623 VideoSortFilterProxyModelData::mItemIds.append(itemId); |
705 VideoSortFilterProxyModelData::mItemIds.append(itemId); |
624 |
706 |
|
707 HbAbstractViewItem *item = new HbAbstractViewItem(); |
|
708 item->mModelIndex = model->index(0, 0, QModelIndex()); |
|
709 |
625 // no context menu |
710 // no context menu |
626 delete mTestWidget->mContextMenu; |
711 delete mTestWidget->mContextMenu; |
627 mTestWidget->mContextMenu = 0; |
712 mTestWidget->mContextMenu = 0; |
628 |
713 |
629 // mCurrentLevel == ELevelVideos |
714 // mCurrentLevel == ELevelVideos |
630 int visibleCount = 0; |
715 int visibleCount = 0; |
631 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelVideos; |
716 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelVideos; |
632 mTestWidget->callLongPressGesture(point); |
717 mTestWidget->callLongPressedSlot(item, point); |
633 |
718 |
634 QMap<VideoListWidget::TContextActionIds, HbAction*>::iterator iter = mTestWidget->mContextMenuActions.begin(); |
719 QMap<VideoListWidget::TContextActionIds, HbAction*>::iterator iter = mTestWidget->mContextMenuActions.begin(); |
635 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
720 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
636 |
721 |
637 while(iter != mTestWidget->mContextMenuActions.end()) |
722 while(iter != mTestWidget->mContextMenuActions.end()) |
638 { |
723 { |
639 if(iter.value()->mVisible) |
724 if(iter.value()->isVisible()) |
640 { |
725 { |
641 visibleCount++; |
726 visibleCount++; |
642 } |
727 } |
643 ++iter; |
728 ++iter; |
644 } |
729 } |
645 QVERIFY(visibleCount == 3); |
730 QVERIFY(visibleCount == 4); |
646 |
731 |
647 // invalid amount of actions -> invalid items gets removed |
732 // invalid amount of actions -> invalid items gets removed |
648 HbAction *nullAction = 0; |
733 HbAction *nullAction = 0; |
649 iter = mTestWidget->mContextMenuActions.begin(); |
734 iter = mTestWidget->mContextMenuActions.begin(); |
650 iter++; |
735 iter++; |
651 iter.value() = nullAction; |
736 iter.value() = nullAction; |
652 mTestWidget->callLongPressGesture(point); |
737 mTestWidget->callLongPressedSlot(item, point); |
653 QVERIFY(!mTestWidget->mContextMenu); |
738 QVERIFY(!mTestWidget->mContextMenu); |
654 QVERIFY(mTestWidget->mContextMenuActions.count() == 0); |
739 QVERIFY(mTestWidget->mContextMenuActions.count() == 0); |
655 |
740 |
656 // mCurrentLevel == ELevelCategory |
741 // mCurrentLevel == ELevelCategory |
657 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelCategory; |
742 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelCategory; |
658 // mIsService is false |
743 // mIsService is false |
659 mTestWidget->mIsService = false; |
744 mTestWidget->mIsService = false; |
660 mTestWidget->callLongPressGesture(point); |
745 mTestWidget->callLongPressedSlot(item, point); |
661 iter = mTestWidget->mContextMenuActions.begin(); |
746 iter = mTestWidget->mContextMenuActions.begin(); |
662 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
747 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
663 visibleCount = 0; |
748 visibleCount = 0; |
664 while(iter != mTestWidget->mContextMenuActions.end()) |
749 while(iter != mTestWidget->mContextMenuActions.end()) |
665 { |
750 { |
666 if(iter.value()->mVisible) |
751 if(iter.value()->isVisible()) |
667 { |
752 { |
668 visibleCount++; |
753 visibleCount++; |
669 } |
754 } |
670 ++iter; |
755 ++iter; |
671 } |
756 } |
672 QVERIFY(visibleCount == 2); |
757 QVERIFY(visibleCount == 1); |
673 |
758 |
674 // mIsService is true |
759 // mIsService is true, mpxId.iId2 != KVcxMvcMediaTypeAlbum |
675 mTestWidget->mIsService = true; |
760 mTestWidget->mIsService = true; |
676 mTestWidget->callLongPressGesture(point); |
761 mTestWidget->callLongPressedSlot(item, point); |
677 iter = mTestWidget->mContextMenuActions.begin(); |
762 iter = mTestWidget->mContextMenuActions.begin(); |
678 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
763 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
679 visibleCount = 0; |
764 visibleCount = 0; |
680 while(iter != mTestWidget->mContextMenuActions.end()) |
765 while(iter != mTestWidget->mContextMenuActions.end()) |
681 { |
766 { |
682 if(iter.value()->mVisible) |
767 if(iter.value()->isVisible()) |
683 { |
768 { |
684 visibleCount++; |
769 visibleCount++; |
685 } |
770 } |
686 ++iter; |
771 ++iter; |
687 } |
772 } |
688 QVERIFY(visibleCount == 0); |
773 QVERIFY(visibleCount == 1); |
|
774 |
|
775 // mIsService is false, mpxId.iId2 == KVcxMvcMediaTypeAlbum |
|
776 //VideoSortFilterProxyModelData::mItemIds.clear(); |
|
777 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,KVcxMvcMediaTypeAlbum)); |
|
778 HbListView::mCurrentIndex = model->index(1, 0, QModelIndex()); |
|
779 item->mModelIndex = model->index(1, 0, QModelIndex()); |
|
780 mTestWidget->mIsService = false; |
|
781 mTestWidget->callLongPressedSlot(item, point); |
|
782 iter = mTestWidget->mContextMenuActions.begin(); |
|
783 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
|
784 visibleCount = 0; |
|
785 while(iter != mTestWidget->mContextMenuActions.end()) |
|
786 { |
|
787 if(iter.value()->isVisible()) |
|
788 { |
|
789 visibleCount++; |
|
790 } |
|
791 ++iter; |
|
792 } |
|
793 QVERIFY(visibleCount == 3); |
|
794 HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); |
689 |
795 |
690 // mCurrentLevel == ELevelAlbum |
796 // mCurrentLevel == ELevelAlbum |
691 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelAlbum; |
797 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelAlbum; |
692 // mIsService is false |
798 // mIsService is false |
693 mTestWidget->mIsService = false; |
799 mTestWidget->mIsService = false; |
694 mTestWidget->callLongPressGesture(point); |
800 mTestWidget->callLongPressedSlot(item, point); |
695 iter = mTestWidget->mContextMenuActions.begin(); |
801 iter = mTestWidget->mContextMenuActions.begin(); |
696 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
802 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
697 visibleCount = 0; |
803 visibleCount = 0; |
698 while(iter != mTestWidget->mContextMenuActions.end()) |
804 while(iter != mTestWidget->mContextMenuActions.end()) |
699 { |
805 { |
700 if(iter.value()->mVisible) |
806 if(iter.value()->isVisible()) |
701 { |
807 { |
702 visibleCount++; |
808 visibleCount++; |
703 } |
809 } |
704 ++iter; |
810 ++iter; |
705 } |
811 } |
706 QVERIFY(visibleCount == 3); |
812 QVERIFY(visibleCount == 4); |
707 |
813 |
708 // mIsService is true |
814 // mIsService is true |
709 // object needs to be resetted for the service use |
815 // object needs to be resetted for the service use |
710 cleanup(); |
816 cleanup(); |
711 init(); |
817 init(); |
712 setRowCount(1); |
818 setRowCount(1); |
713 model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
819 model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); |
714 mTestWidget->initialize(*model); |
820 mTestWidget->initialize(*model); |
715 HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); |
821 HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); |
716 mTestWidget->mItem->mModelIndex = HbListView::mCurrentIndex ; |
822 mTestWidget->mItem->mModelIndex = HbListView::mCurrentIndex ; |
717 |
823 |
718 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelAlbum; |
824 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelAlbum; |
719 VideoSortFilterProxyModelData::mItemIds.append(itemId); |
825 VideoSortFilterProxyModelData::mItemIds.append(itemId); |
720 mTestWidget->mIsService = true; |
826 mTestWidget->mIsService = true; |
721 mTestWidget->callLongPressGesture(point); |
827 mTestWidget->callLongPressedSlot(item, point); |
722 iter = mTestWidget->mContextMenuActions.begin(); |
828 iter = mTestWidget->mContextMenuActions.begin(); |
723 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
829 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
724 visibleCount = 0; |
830 visibleCount = 0; |
725 while(iter != mTestWidget->mContextMenuActions.end()) |
831 while(iter != mTestWidget->mContextMenuActions.end()) |
726 { |
832 { |
727 if(iter.value()->mVisible) |
833 if(iter.value()->isVisible()) |
728 { |
834 { |
729 visibleCount++; |
835 visibleCount++; |
730 } |
836 } |
731 ++iter; |
837 ++iter; |
732 } |
838 } |
733 QVERIFY(visibleCount == 2); |
839 QVERIFY(visibleCount == 2); |
734 |
840 |
735 //invalid level |
841 //invalid level |
736 mTestWidget->mCurrentLevel = (VideoCollectionCommon::TCollectionLevels)0; |
842 mTestWidget->mCurrentLevel = (VideoCollectionCommon::TCollectionLevels)0; |
737 mTestWidget->callLongPressGesture(point); |
843 mTestWidget->callLongPressedSlot(item, point); |
738 iter = mTestWidget->mContextMenuActions.begin(); |
844 iter = mTestWidget->mContextMenuActions.begin(); |
739 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
845 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
740 visibleCount = 0; |
846 visibleCount = 0; |
741 while(iter != mTestWidget->mContextMenuActions.end()) |
847 while(iter != mTestWidget->mContextMenuActions.end()) |
742 { |
848 { |
743 if(iter.value()->mVisible) |
849 if(iter.value()->isVisible()) |
744 { |
850 { |
745 visibleCount++; |
851 visibleCount++; |
746 } |
852 } |
747 ++iter; |
853 ++iter; |
748 } |
854 } |
749 QVERIFY(visibleCount == 0); |
855 QVERIFY(visibleCount == 0); |
750 } |
856 } |
751 |
857 |
752 void TestListWidget::testDoDelayedsSlot() |
858 void TestListWidget::testDoDelayedsSlot() |
753 { |
859 { |
754 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(doDelayedsSlot())); |
860 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(doDelayedsSlot())); |
755 |
861 |
756 //dodelayed calls create context menu, which is already tested at |
862 //dodelayed calls create context menu, which is already tested at |
757 // testSetContextMenu -method, these tests are just for coverity's sake |
863 // testSetContextMenu -method, these tests are just for coverity's sake |
758 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
864 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
759 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
865 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); |
760 mTestWidget->initialize(*model); |
866 mTestWidget->initialize(*model); |
761 |
867 |
762 delete mTestWidget->mContextMenu; |
868 delete mTestWidget->mContextMenu; |
763 mTestWidget->mContextMenu = 0; |
869 mTestWidget->mContextMenu = 0; |
764 int visibleCount = 0; |
870 int visibleCount = 0; |
765 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelVideos; |
871 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelVideos; |
766 |
872 |
767 // no context menu |
873 // no context menu |
768 emit testSignal(); |
874 emit testSignal(); |
769 |
875 |
770 QVERIFY(mTestWidget->mContextMenuActions.count() == 6); |
876 QVERIFY(mTestWidget->mContextMenuActions.count() == 8); |
771 |
877 |
772 // context menu exists |
878 // context menu exists |
773 emit testSignal(); |
879 emit testSignal(); |
774 |
880 |
775 QVERIFY(mTestWidget->mContextMenuActions.count() == 6); |
881 QVERIFY(mTestWidget->mContextMenuActions.count() == 8); |
776 |
882 |
777 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(scrollingStartedSlot())); |
883 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(scrollingStartedSlot())); |
778 } |
884 } |
779 |
885 |
780 // --------------------------------------------------------------------------- |
886 // --------------------------------------------------------------------------- |
843 // --------------------------------------------------------------------------- |
949 // --------------------------------------------------------------------------- |
844 // |
950 // |
845 void TestListWidget::testRenameSlot() |
951 void TestListWidget::testRenameSlot() |
846 { |
952 { |
847 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
953 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
848 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
954 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); |
849 |
955 |
850 // nothing to test yet |
|
851 HbMessageBoxData::mLatestTxt = ""; |
|
852 mTestWidget->initialize(*model); |
|
853 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(renameSlot())); |
956 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(renameSlot())); |
854 emit testSignal(); |
957 |
855 QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty()); |
958 VideoSortFilterProxyModelData::reset(); |
|
959 VideoSortFilterProxyModelData::mLastIndex = QModelIndex(); |
|
960 mTestWidget->initialize(*model); |
|
961 |
|
962 // Good case |
|
963 VideoSortFilterProxyModelData::mLastAlbumNameInRename = ""; |
|
964 HbInputDialog::mGetTextReturnValue = "renamedVideo"; |
|
965 HbInputDialog::mGetTextCallCount = 0; |
|
966 setRowCount(1); |
|
967 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(0, KVcxMvcMediaTypeAlbum)); |
|
968 QVariant data = QString("albumName"); |
|
969 VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, data); |
|
970 mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex()); |
|
971 emit testSignal(); |
|
972 QVERIFY(VideoSortFilterProxyModelData::mLastAlbumNameInRename == "renamedVideo"); |
|
973 QCOMPARE(HbInputDialog::mGetTextCallCount, 1); |
|
974 |
|
975 // New name is same as previous |
|
976 HbInputDialog::mGetTextReturnValue = QString(); |
|
977 HbInputDialog::mGetTextCallCount = 0; |
|
978 VideoSortFilterProxyModelData::mLastAlbumNameInRename = ""; |
|
979 data = QString("albumName"); |
|
980 VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, data); |
|
981 mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex()); |
|
982 emit testSignal(); |
|
983 QVERIFY(VideoSortFilterProxyModelData::mLastAlbumNameInRename == ""); |
|
984 QCOMPARE(HbInputDialog::mGetTextCallCount, 1); |
|
985 |
|
986 // Getting name from input dialog fails |
|
987 HbInputDialog::mGetTextFails = true; |
|
988 VideoSortFilterProxyModelData::mLastAlbumNameInRename = ""; |
|
989 HbInputDialog::mGetTextReturnValue = QString(); |
|
990 HbInputDialog::mGetTextCallCount = 0; |
|
991 data = QString("albumName"); |
|
992 VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, data); |
|
993 mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex()); |
|
994 emit testSignal(); |
|
995 QVERIFY(VideoSortFilterProxyModelData::mLastAlbumNameInRename == ""); |
|
996 QCOMPARE(HbInputDialog::mGetTextCallCount, 1); |
|
997 |
|
998 // New name is empty. |
|
999 HbInputDialog::mGetTextFails = false; |
|
1000 VideoSortFilterProxyModelData::mLastAlbumNameInRename = ""; |
|
1001 HbInputDialog::mGetTextReturnValue = ""; |
|
1002 HbInputDialog::mGetTextCallCount = 0; |
|
1003 data = QString("albumName"); |
|
1004 VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, data); |
|
1005 mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex()); |
|
1006 emit testSignal(); |
|
1007 QVERIFY(VideoSortFilterProxyModelData::mLastAlbumNameInRename == ""); |
|
1008 QCOMPARE(HbInputDialog::mGetTextCallCount, 1); |
|
1009 |
|
1010 // Item is video |
|
1011 VideoSortFilterProxyModelData::mItemIds.clear(); |
|
1012 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(0, KVcxMvcMediaTypeVideo)); |
|
1013 HbInputDialog::mGetTextFails = false; |
|
1014 VideoSortFilterProxyModelData::mLastAlbumNameInRename = ""; |
|
1015 HbInputDialog::mGetTextReturnValue = ""; |
|
1016 HbInputDialog::mGetTextCallCount = 0; |
|
1017 data = QString("albumName"); |
|
1018 VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, data); |
|
1019 mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex()); |
|
1020 emit testSignal(); |
|
1021 QVERIFY(VideoSortFilterProxyModelData::mLastAlbumNameInRename == ""); |
|
1022 QCOMPARE(HbInputDialog::mGetTextCallCount, 0); |
|
1023 |
|
1024 // No model |
|
1025 VideoSortFilterProxyModelData::mLastAlbumNameInRename = ""; |
|
1026 HbInputDialog::mGetTextReturnValue = "renamedVideo"; |
|
1027 HbInputDialog::mGetTextCallCount = 0; |
|
1028 VideoSortFilterProxyModelData::mItemIds.clear(); |
|
1029 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(0, KVcxMvcMediaTypeAlbum)); |
|
1030 data = QString("albumName"); |
|
1031 VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, data); |
|
1032 mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex()); |
|
1033 VideoSortFilterProxyModel *tmp = mTestWidget->mModel; |
|
1034 mTestWidget->mModel = 0; |
|
1035 emit testSignal(); |
|
1036 mTestWidget->mModel = tmp; |
|
1037 QVERIFY(VideoSortFilterProxyModelData::mLastAlbumNameInRename == ""); |
|
1038 QCOMPARE(HbInputDialog::mGetTextCallCount, 0); |
|
1039 |
|
1040 // Variant data is invalid |
|
1041 VideoSortFilterProxyModelData::mLastAlbumNameInRename = ""; |
|
1042 HbInputDialog::mGetTextReturnValue = "renamedVideo"; |
|
1043 HbInputDialog::mGetTextCallCount = 0; |
|
1044 VideoSortFilterProxyModelData::mItemIds.clear(); |
|
1045 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(0, KVcxMvcMediaTypeAlbum)); |
|
1046 data = QVariant(); |
|
1047 VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, data); |
|
1048 mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex()); |
|
1049 emit testSignal(); |
|
1050 QVERIFY(VideoSortFilterProxyModelData::mLastAlbumNameInRename == ""); |
|
1051 QCOMPARE(HbInputDialog::mGetTextCallCount, 0); |
|
1052 |
856 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(renameSlot())); |
1053 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(renameSlot())); |
857 } |
1054 } |
858 |
1055 |
859 // --------------------------------------------------------------------------- |
1056 // --------------------------------------------------------------------------- |
860 // testPlayItemSlot |
1057 // testOpenItemSlot |
861 // --------------------------------------------------------------------------- |
1058 // --------------------------------------------------------------------------- |
862 // |
1059 // |
863 void TestListWidget::testPlayItemSlot() |
1060 void TestListWidget::testOpenItemSlot() |
864 { |
1061 { |
865 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
1062 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
866 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
1063 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); |
867 mTestWidget->initialize(*model); |
1064 mTestWidget->initialize(*model); |
868 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(playItemSlot())); |
1065 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(openItemSlot())); |
869 setRowCount(1); |
1066 setRowCount(1); |
870 TMPXItemId savedId = TMPXItemId(1,1); |
1067 TMPXItemId savedId = TMPXItemId(1,1); |
871 VideoSortFilterProxyModelData::mItemIds.clear(); |
1068 VideoSortFilterProxyModelData::mItemIds.clear(); |
872 VideoSortFilterProxyModelData::mItemIds.append(savedId); |
1069 VideoSortFilterProxyModelData::mItemIds.append(savedId); |
873 HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); |
1070 HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); |
874 |
1071 |
875 emit testSignal(); |
1072 emit testSignal(); |
876 |
1073 |
877 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == savedId); |
1074 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == savedId); |
878 |
1075 |
879 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(playItemSlot())); |
1076 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(openItemSlot())); |
880 } |
1077 } |
881 |
1078 |
882 // --------------------------------------------------------------------------- |
|
883 // testPlayAllSlot |
|
884 // --------------------------------------------------------------------------- |
|
885 // |
|
886 void TestListWidget::testPlayAllSlot() |
|
887 { |
|
888 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(playAllSlot())); |
|
889 emit testSignal(); |
|
890 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(playAllSlot())); |
|
891 } |
|
892 |
|
893 // --------------------------------------------------------------------------- |
1079 // --------------------------------------------------------------------------- |
894 // testAddToCollectionSlot |
1080 // testAddToCollectionSlot |
895 // --------------------------------------------------------------------------- |
1081 // --------------------------------------------------------------------------- |
896 // |
1082 // |
897 void TestListWidget::testAddToCollectionSlot() |
1083 void TestListWidget::testAddToCollectionSlot() |
898 { |
1084 { |
899 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
1085 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
900 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
1086 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); |
901 |
1087 |
902 VideoListSelectionDialogData::mSelectionType = -1; |
1088 VideoListSelectionDialogData::mSelectionType = -1; |
903 VideoListSelectionDialogData::mSettedMpxId = TMPXItemId::InvalidId(); |
1089 VideoListSelectionDialogData::mSettedMpxId = TMPXItemId::InvalidId(); |
904 |
1090 |
905 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(addToCollectionSlot())); |
1091 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(addToCollectionSlot())); |