31 #include <hbmarqueeitem.h> |
32 #include <hbmarqueeitem.h> |
32 #include <hbstackedwidget.h> |
33 #include <hbstackedwidget.h> |
33 |
34 |
34 #include "videodetailslabel.h" |
35 #include "videodetailslabel.h" |
35 #include "hbmessagebox.h" |
36 #include "hbmessagebox.h" |
|
37 #include "shareui.h" |
36 #include "thumbnailmanager_qt.h" |
38 #include "thumbnailmanager_qt.h" |
37 #include "videocollectioncommon.h" |
39 #include "videocollectioncommon.h" |
38 #include "mpxhbvideocommondefs.h" |
40 #include "mpxhbvideocommondefs.h" |
39 #include "videocollectionwrapper.h" |
41 #include "videocollectionwrapper.h" |
40 #include "videosortfilterproxymodel.h" |
42 #include "videosortfilterproxymodel.h" |
61 { |
63 { |
62 mDummyModel = 0; |
64 mDummyModel = 0; |
63 mDummyModel = new VideoSortFilterProxyModel(); |
65 mDummyModel = new VideoSortFilterProxyModel(); |
64 |
66 |
65 connect(this, SIGNAL(shortDetailsReady(TMPXItemId)), mDummyModel, SIGNAL(shortDetailsReady(TMPXItemId))); |
67 connect(this, SIGNAL(shortDetailsReady(TMPXItemId)), mDummyModel, SIGNAL(shortDetailsReady(TMPXItemId))); |
66 connect(this, SIGNAL(fullDetailsReady(TMPXItemId)), mDummyModel, SIGNAL(fullVideoDetailsReady(TMPXItemId))); |
68 connect(this, SIGNAL(fullDetailsReady(QVariant&)), mDummyModel, SIGNAL(fullVideoDetailsReady(QVariant&))); |
67 |
69 |
68 connect(this, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
70 connect(this, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
69 mDummyModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&))); |
71 mDummyModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&))); |
70 |
72 |
71 connect(this, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), |
73 connect(this, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), |
79 // --------------------------------------------------------------------------- |
81 // --------------------------------------------------------------------------- |
80 // |
82 // |
81 void TestVideoFileDetails::cleanupTestCase() |
83 void TestVideoFileDetails::cleanupTestCase() |
82 { |
84 { |
83 disconnect(this, SIGNAL(shortDetailsReady(int)), mDummyModel, SIGNAL(shortDetailsReady(int))); |
85 disconnect(this, SIGNAL(shortDetailsReady(int)), mDummyModel, SIGNAL(shortDetailsReady(int))); |
84 disconnect(this, SIGNAL(fullDetailsReady(int)),mDummyModel, SIGNAL(fullVideoDetailsReady(int))); |
86 disconnect(this, SIGNAL(fullDetailsReady(QVariant&)),mDummyModel, SIGNAL(fullVideoDetailsReady(QVariant&))); |
85 disconnect(this, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
87 disconnect(this, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
86 mDummyModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&))); |
88 mDummyModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&))); |
87 disconnect(this, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), |
89 disconnect(this, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), |
88 mDummyModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int))); |
90 mDummyModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int))); |
89 delete mDummyModel; mDummyModel = 0; |
91 delete mDummyModel; mDummyModel = 0; |
397 |
397 |
398 QCOMPARE( mPlugin->mVideoId, testIndex ); |
398 QCOMPARE( mPlugin->mVideoId, testIndex ); |
399 QVERIFY( mPlugin->mTitleAnim->text().isEmpty() ); |
399 QVERIFY( mPlugin->mTitleAnim->text().isEmpty() ); |
400 QCOMPARE( mPlugin->mThumbnailManager->mRequests.count(), 0 ); |
400 QCOMPARE( mPlugin->mThumbnailManager->mRequests.count(), 0 ); |
401 |
401 |
402 mDummyModel->setData(Qt::DisplayRole, display); |
402 mDummyModel->setData(VideoCollectionCommon::KeyTitle, title); |
403 mDummyModel->setData(VideoCollectionCommon::KeyFilePath, filepath); |
403 mDummyModel->setData(VideoCollectionCommon::KeyFilePath, filepath); |
404 |
404 |
405 // no tn manager |
405 // no tn manager |
406 ThumbnailManager *tmpTnManager = mPlugin->mThumbnailManager; |
406 ThumbnailManager *tmpTnManager = mPlugin->mThumbnailManager; |
407 mPlugin->mThumbnailManager = 0; |
407 mPlugin->mThumbnailManager = 0; |
408 emit shortDetailsReady(testIndex); |
408 emit shortDetailsReady(testIndex); |
409 QCOMPARE( mPlugin->mVideoId, testIndex ); |
409 QCOMPARE( mPlugin->mVideoId, testIndex ); |
410 QCOMPARE( mPlugin->mTitleAnim->text(), display.at(0) ); |
410 QCOMPARE( mPlugin->mTitleAnim->text(), title ); |
411 mPlugin->mThumbnailManager = tmpTnManager; |
411 mPlugin->mThumbnailManager = tmpTnManager; |
412 |
412 |
413 // data exists |
413 // data exists |
414 emit shortDetailsReady(testIndex); |
414 emit shortDetailsReady(testIndex); |
415 |
415 |
416 QCOMPARE( mPlugin->mVideoId, testIndex ); |
416 QCOMPARE( mPlugin->mVideoId, testIndex ); |
417 QCOMPARE( mDummyModel->lastId(), testIndex ); |
417 QCOMPARE( mDummyModel->lastId(), testIndex ); |
418 QCOMPARE( mPlugin->mTitleAnim->text(), display.at(0) ); |
418 QCOMPARE( mPlugin->mTitleAnim->text(), title ); |
419 QVERIFY( ThumbnailManager::mRequests.contains(0) ); |
419 QVERIFY( ThumbnailManager::mRequests.contains(0) ); |
420 ThumbnailManager::TnRequest request = ThumbnailManager::mRequests[0]; |
420 ThumbnailManager::TnRequest request = ThumbnailManager::mRequests[0]; |
421 QCOMPARE( request.name, filepath ); |
421 QCOMPARE( request.name, filepath ); |
422 // 20 == priorityHight in this case |
422 // 20 == priorityHight in this case |
423 QCOMPARE( request.priority, 5000 ); |
423 QCOMPARE( request.priority, 5000 ); |
424 |
424 |
425 |
425 |
426 mDummyModel->setData(VideoCollectionCommon::KeyMetaData, createDummyMetadata() ); |
426 QVariant variant = QVariant(createDummyMetadata()); |
427 emit fullDetailsReady(testIndex); |
427 emit fullDetailsReady(variant); |
428 |
428 |
429 emit shortDetailsReady(testIndex); |
429 emit shortDetailsReady(testIndex); |
430 |
430 |
431 int detailCount = sizeof(VideoCollectionCommon::VideoDetailLabelKeys) / sizeof(int); |
431 int detailCount = sizeof(VideoCollectionCommon::VideoDetailLabelKeys) / sizeof(int); |
432 |
432 |
433 HbListWidget* list = findWidget<HbListWidget>(TEST_VIDEO_DETAILS_LISTWIDGET); |
433 HbListWidget* list = findWidget<HbListWidget>(TEST_VIDEO_DETAILS_LISTWIDGET); |
434 |
434 |
435 QVERIFY(list); |
435 QVERIFY(list); |
436 QVERIFY(list->count() == 0); |
436 QVERIFY(list->count() == 0); |
437 |
437 |
438 cleanup(); |
438 cleanup(); |
439 } |
439 } |
440 |
440 |
441 // --------------------------------------------------------------------------- |
441 // --------------------------------------------------------------------------- |
442 // Slot: test for the fullDetailsReadySlot |
442 // Slot: test for the fullDetailsReadySlot |
443 // --------------------------------------------------------------------------- |
443 // --------------------------------------------------------------------------- |
452 |
452 |
453 HbListWidget* list = findWidget<HbListWidget>(TEST_VIDEO_DETAILS_LISTWIDGET); |
453 HbListWidget* list = findWidget<HbListWidget>(TEST_VIDEO_DETAILS_LISTWIDGET); |
454 QVERIFY(list); |
454 QVERIFY(list); |
455 QVERIFY(list->count() == 0); |
455 QVERIFY(list->count() == 0); |
456 |
456 |
457 mDummyModel->setData(VideoCollectionCommon::KeyMetaData, createDummyMetadata() ); |
457 QVariant variant = QVariant(createDummyMetadata()); |
458 |
458 |
459 emit fullDetailsReady(testIndex); |
459 emit fullDetailsReady(variant); |
460 |
460 |
461 // verify that actions are currently enabled. |
461 // verify that actions are currently enabled. |
462 HbStackedWidget* thumbWidget = findWidget<HbStackedWidget>(VIDEO_DETAILS_THUMBNAIL); |
462 HbStackedWidget* thumbWidget = findWidget<HbStackedWidget>(VIDEO_DETAILS_THUMBNAIL); |
463 VideoDetailsLabel* thumbLabel = (VideoDetailsLabel*)thumbWidget->widgetAt(0); |
463 VideoDetailsLabel* thumbLabel = (VideoDetailsLabel*)thumbWidget->widgetAt(0); |
464 HbAction* deleteAction = findObject<HbAction>(TEST_VIDEO_DETAILS_MENUACTION_DELETE); |
464 HbAction* deleteAction = findObject<HbAction>(TEST_VIDEO_DETAILS_MENUACTION_DELETE); |
477 QVERIFY( detail != 0 ); |
477 QVERIFY( detail != 0 ); |
478 QVERIFY( detail->text().contains(expected) ); |
478 QVERIFY( detail->text().contains(expected) ); |
479 } |
479 } |
480 |
480 |
481 // for coverity sake, retest without star-rating |
481 // for coverity sake, retest without star-rating |
482 mDummyModel->reset(); |
482 variant = QVariant(createDummyMetadata()); |
483 mDummyModel->setData(VideoCollectionCommon::KeyMetaData, createDummyMetadata() ); |
483 emit fullDetailsReady(variant); |
484 emit fullDetailsReady(testIndex); |
|
485 |
484 |
486 int ii = 0; |
485 int ii = 0; |
487 for(int i = 0; i<detailCount; i++) |
486 for(int i = 0; i<detailCount; i++) |
488 { |
487 { |
489 if(VideoCollectionCommon::VideoDetailLabelKeys[i] != VideoCollectionCommon::MetaKeyStarRating) |
488 if(VideoCollectionCommon::VideoDetailLabelKeys[i] != VideoCollectionCommon::MetaKeyStarRating) |
541 // Slot: test for the sendVideoSlot |
541 // Slot: test for the sendVideoSlot |
542 // --------------------------------------------------------------------------- |
542 // --------------------------------------------------------------------------- |
543 // |
543 // |
544 void TestVideoFileDetails::testSendVideoSlot() |
544 void TestVideoFileDetails::testSendVideoSlot() |
545 { |
545 { |
546 // TODO add test after send video has been implemented. |
546 QFAIL("Feature not yet implemented!"); |
|
547 |
|
548 mDummyModel->reset(); |
|
549 init(); |
|
550 mPlugin->activateView(); |
|
551 |
|
552 HbPushButton* shareAction = findWidget<HbPushButton>(VIDEO_DETAILS_BUTTON); |
|
553 |
|
554 QVERIFY( shareAction != 0 ); |
|
555 shareAction->click(); |
|
556 QCOMPARE( mDummyModel->dataAccessCount(), 0 ); |
|
557 mPlugin->mVideoId = (0,0); |
|
558 |
|
559 mDummyModel->setDataReturnInvalid(true); |
|
560 QModelIndex expected = mDummyModel->index(0, 0); |
|
561 shareAction->click(); |
|
562 QCOMPARE( mDummyModel->dataAccessCount(), 1 ); |
|
563 QVERIFY( mDummyModel->lastIndex() == expected ); |
|
564 QCOMPARE( ShareUi::mFileList.count(), 0 ); |
|
565 QVERIFY( ShareUi::mEmbedded == false ); |
|
566 |
|
567 mDummyModel->setDataReturnInvalid(false); |
|
568 QString filePath("dummyfilepath"); |
|
569 mDummyModel->setData(VideoCollectionCommon::KeyFilePath, filePath); |
|
570 shareAction->click(); |
|
571 QCOMPARE( mDummyModel->dataAccessCount(), 2 ); |
|
572 QVERIFY( mDummyModel->lastIndex() == expected ); |
|
573 QVERIFY( ShareUi::mEmbedded ); |
|
574 QCOMPARE( ShareUi::mFileList.count(), 1 ); |
|
575 QCOMPARE( ShareUi::mFileList.at(0), filePath ); |
|
576 |
|
577 cleanup(); |
547 } |
578 } |
548 |
579 |
549 // --------------------------------------------------------------------------- |
580 // --------------------------------------------------------------------------- |
550 // Slot: test for the deleteVideoSlot |
581 // Slot: test for the deleteVideoSlot |
551 // --------------------------------------------------------------------------- |
582 // --------------------------------------------------------------------------- |
578 QCOMPARE( mDummyModel->deleteFileIndex(), -1 ); // verify that no file was deleted. |
609 QCOMPARE( mDummyModel->deleteFileIndex(), -1 ); // verify that no file was deleted. |
579 |
610 |
580 QStringList display; |
611 QStringList display; |
581 display.append("first row"); |
612 display.append("first row"); |
582 display.append("second row"); |
613 display.append("second row"); |
583 mDummyModel->setData(Qt::DisplayRole, display); |
614 mDummyModel->setData(VideoCollectionCommon::KeyTitle, display); |
584 |
615 |
585 QString expectedText = tr("Do you want to delete \"%1\"?").arg( |
616 QString expectedText = hbTrId("txt_videos_info_do_you_want_to_delete_1").arg( |
586 display.at(0)); |
617 display.first()); |
587 |
618 |
588 HbMessageBox::mQuestionReturnValue = true; |
619 HbMessageBox::mQuestionReturnValue = true; |
589 deleteAction->trigger(); |
620 deleteAction->trigger(); |
590 QCOMPARE( mDummyModel->dataAccessCount(), 3 ); |
621 QCOMPARE( mDummyModel->dataAccessCount(), 3 ); |
591 QVERIFY( mDummyModel->lastIndex() == expected ); |
622 QVERIFY( mDummyModel->lastIndex() == expected ); |
630 |
661 |
631 emit rowsRemoved(QModelIndex(), testIndex, testIndex); |
662 emit rowsRemoved(QModelIndex(), testIndex, testIndex); |
632 QCOMPARE( mCommandReceived, false ); |
663 QCOMPARE( mCommandReceived, false ); |
633 QCOMPARE( mReceivedCommand, -1 ); |
664 QCOMPARE( mReceivedCommand, -1 ); |
634 |
665 |
635 emit fullDetailsReady(testID); |
666 QVariant variant = QVariant(createDummyMetadata()); |
|
667 emit fullDetailsReady(variant); |
636 mPlugin->mVideoId = testID; |
668 mPlugin->mVideoId = testID; |
637 mPlugin->mDeletedIndex = testIndex; |
669 mPlugin->mDeletedIndex = testIndex; |
638 |
670 |
639 emit rowsRemoved(QModelIndex(), testIndex+1, testIndex-1); |
671 emit rowsRemoved(QModelIndex(), testIndex+1, testIndex-1); |
640 QCOMPARE( mCommandReceived, false ); |
672 QCOMPARE( mCommandReceived, false ); |
679 |
711 |
680 // - with additional data |
712 // - with additional data |
681 QString txt = "testdata"; |
713 QString txt = "testdata"; |
682 additional = txt; |
714 additional = txt; |
683 emit testErrorSignal( VideoCollectionCommon::statusSingleDeleteFail , additional); |
715 emit testErrorSignal( VideoCollectionCommon::statusSingleDeleteFail , additional); |
684 QCOMPARE(HbMessageBox::mLatestTxt, QString("Unable to delete item %1. It is currently open.").arg(txt)); |
716 QCOMPARE(HbMessageBox::mLatestTxt, hbTrId("txt_videos_info_unable_to_delete_1_it_is_current").arg(txt)); |
685 |
717 |
686 HbMessageBox::mLatestTxt = ""; |
718 HbMessageBox::mLatestTxt = ""; |
687 // VideoCollectionCommon::statusMultipleDeleteFail |
719 // VideoCollectionCommon::statusMultipleDeleteFail |
688 emit testErrorSignal( VideoCollectionCommon::statusMultipleDeleteFail , additional); |
720 emit testErrorSignal( VideoCollectionCommon::statusMultipleDeleteFail , additional); |
689 QVERIFY(HbMessageBox::mLatestTxt.isEmpty()); |
721 QVERIFY(HbMessageBox::mLatestTxt.isEmpty()); |