14 * Description: tester for methods in VideoCollectionViewUtils |
14 * Description: tester for methods in VideoCollectionViewUtils |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <qapplication.h> |
18 #include <qapplication.h> |
|
19 #include <vcxmyvideosdefs.h> |
19 #include "centralrepository.h" |
20 #include "centralrepository.h" |
20 #include "testvideocollectionviewutils.h" |
21 #include "testvideocollectionviewutils.h" |
21 #include "hblabel.h" |
22 #include "hblabel.h" |
22 #include "hbaction.h" |
23 #include "hbaction.h" |
23 #include "videocollectionwrapper.h" |
24 #include "videocollectionwrapper.h" |
24 #include "videosortfilterproxymodeldata.h" |
25 #include "videosortfilterproxymodeldata.h" |
|
26 #include "videoactivitystate.h" |
25 #include "videocollectioncommon.h" |
27 #include "videocollectioncommon.h" |
26 #include "centralrepository.h" |
28 #include "centralrepository.h" |
27 #include "hbmessageboxdata.h" |
29 #include "hbmessageboxdata.h" |
28 #include "hbnotificationdialog.h" |
30 #include "hbnotificationdialog.h" |
29 #include "hblistview.h" |
31 #include "hblistview.h" |
33 #define private public |
35 #define private public |
34 #include "videocollectionviewutils.h" |
36 #include "videocollectionviewutils.h" |
35 #undef private |
37 #undef private |
36 |
38 |
37 // following consts are copied from videocollectionviewutils.cpp |
39 // following consts are copied from videocollectionviewutils.cpp |
38 const int KVideoSortingRoleKey(0x5); |
40 const int KVideoSortingRoleKey(0x1); |
39 const int KVideoSortingOrderKey(0x6); |
41 const int KVideoSortingOrderKey(0x2); |
40 const int KCollectionsSortingRoleKey(0x7); |
42 const int KCollectionsSortingRoleKey(0x3); |
41 const int KCollectionsSortingOrderKey(0x8); |
43 const int KCollectionsSortingOrderKey(0x4); |
|
44 static const QString KEY_WIDGET_LEVEL = "_VideoActivity_widget_level_"; |
|
45 |
|
46 // id of the collection whose videolist is to be shown (int). |
|
47 static const QString KEY_COLLECTION_ID = "_VideoActivity_collection_id_"; |
|
48 |
|
49 // name of the collection whose videolist is to be shown (QString) |
|
50 static const QString KEY_COLLECTION_NAME = "_VideoActivity_collection_name_"; |
42 |
51 |
43 // --------------------------------------------------------------------------- |
52 // --------------------------------------------------------------------------- |
44 // main |
53 // main |
45 // --------------------------------------------------------------------------- |
54 // --------------------------------------------------------------------------- |
46 // |
55 // |
695 QVERIFY(testObject.mVideosSortOrder == Qt::DescendingOrder); |
708 QVERIFY(testObject.mVideosSortOrder == Qt::DescendingOrder); |
696 QVERIFY(testObject.mCollectionsSortRole == VideoCollectionCommon::KeyTitle); |
709 QVERIFY(testObject.mCollectionsSortRole == VideoCollectionCommon::KeyTitle); |
697 QVERIFY(testObject.mCollectionsSortOrder == Qt::DescendingOrder); |
710 QVERIFY(testObject.mCollectionsSortOrder == Qt::DescendingOrder); |
698 } |
711 } |
699 |
712 |
700 void TestVideoVideoCollectionViewUtils::testSaveAndLoadWidgetLevel() |
713 // ----------------------------------------------------------------------------- |
|
714 // testSetAndGetWidgetLevel |
|
715 // ----------------------------------------------------------------------------- |
|
716 // |
|
717 void TestVideoVideoCollectionViewUtils::testSetAndGetWidgetLevel() |
701 { |
718 { |
702 static const char* ACTIVITY_VIDEOS_MAINVIEW = "VideosMainView"; |
719 static const char* ACTIVITY_VIDEOS_MAINVIEW = "VideosMainView"; |
703 |
720 |
704 VideoCollectionCommon::TCollectionLevels level; |
721 VideoCollectionCommon::TCollectionLevels level; |
705 |
722 |
706 // Invalid level |
723 // Invalid level |
707 level = VideoCollectionCommon::ELevelInvalid; |
724 level = VideoCollectionCommon::ELevelInvalid; |
708 VideoCollectionViewUtils::saveWidgetLevel(level); |
725 VideoCollectionViewUtils::setWidgetActivityLevel(level); |
709 level = VideoCollectionViewUtils::loadWidgetLevel(); |
726 VideoCollectionViewUtils::getActivityWidgetLevel( level); |
710 QVERIFY(level == VideoCollectionCommon::ELevelVideos); |
727 QVERIFY(level == VideoCollectionCommon::ELevelVideos); |
711 |
728 |
712 // Category level. |
729 // Category level. |
713 level = VideoCollectionCommon::ELevelCategory; |
730 level = VideoCollectionCommon::ELevelCategory; |
714 VideoCollectionViewUtils::saveWidgetLevel(level); |
731 VideoCollectionViewUtils::setWidgetActivityLevel(level); |
715 level = VideoCollectionViewUtils::loadWidgetLevel(); |
732 VideoCollectionViewUtils::getActivityWidgetLevel( level); |
716 QVERIFY(level == VideoCollectionCommon::ELevelCategory); |
733 QVERIFY(level == VideoCollectionCommon::ELevelCategory); |
|
734 |
|
735 // make sure unneeded data is cleared |
|
736 TMPXItemId id = TMPXItemId(1,1); |
|
737 QString name = "name"; |
|
738 VideoCollectionViewUtils::setCollectionActivityData(id, name); |
|
739 level = VideoCollectionCommon::ELevelVideos; |
|
740 VideoCollectionViewUtils::setWidgetActivityLevel(level); |
|
741 |
|
742 QVERIFY(level == VideoCollectionCommon::ELevelVideos); |
|
743 QVariant data = VideoActivityState::instance().getActivityData(KEY_COLLECTION_ID); |
|
744 QVERIFY(data.toInt() == 0); |
|
745 data = VideoActivityState::instance().getActivityData(KEY_COLLECTION_NAME); |
|
746 QVERIFY(data.toString().isEmpty()); |
|
747 |
|
748 id = TMPXItemId(1,1); |
|
749 name = "name"; |
|
750 VideoCollectionViewUtils::setCollectionActivityData(id, name); |
|
751 level = VideoCollectionCommon::ELevelAlbum; |
|
752 VideoCollectionViewUtils::setWidgetActivityLevel(level); |
|
753 |
|
754 QVERIFY(level == VideoCollectionCommon::ELevelAlbum); |
|
755 data = VideoActivityState::instance().getActivityData(KEY_COLLECTION_ID); |
|
756 QVERIFY(data.toInt() == 1); |
|
757 data = VideoActivityState::instance().getActivityData(KEY_COLLECTION_NAME); |
|
758 QVERIFY(data.toString() == "name"); |
|
759 |
|
760 } |
|
761 |
|
762 void TestVideoVideoCollectionViewUtils::testSetAndGetCollectionActivityData() |
|
763 { |
|
764 TMPXItemId id = TMPXItemId(1,1); |
|
765 QString name = "name"; |
|
766 |
|
767 // no default collection nor user defined collection |
|
768 VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelVideos; |
|
769 VideoCollectionViewUtils::setWidgetActivityLevel(level); |
|
770 VideoCollectionViewUtils::setCollectionActivityData(id, name); |
|
771 VideoCollectionViewUtils::getCollectionActivityData(id, name); |
|
772 QVERIFY(id == TMPXItemId::InvalidId()); |
|
773 QVERIFY(name.isEmpty()); |
|
774 |
|
775 // default collection |
|
776 level = VideoCollectionCommon::ELevelDefaultColl; |
|
777 id = TMPXItemId(1,1); |
|
778 name = "name"; |
|
779 VideoCollectionViewUtils::setWidgetActivityLevel(level); |
|
780 VideoCollectionViewUtils::setCollectionActivityData(id, name); |
|
781 VideoCollectionViewUtils::getCollectionActivityData(id, name); |
|
782 |
|
783 QVERIFY(id == TMPXItemId(1, KVcxMvcMediaTypeCategory)); |
|
784 QVERIFY(name == "name"); |
|
785 |
|
786 // user defined collection |
|
787 level = VideoCollectionCommon::ELevelAlbum; |
|
788 id = TMPXItemId(1,1); |
|
789 name = "name"; |
|
790 VideoCollectionViewUtils::setWidgetActivityLevel(level); |
|
791 VideoCollectionViewUtils::setCollectionActivityData(id, name); |
|
792 VideoCollectionViewUtils::getCollectionActivityData(id, name); |
|
793 |
|
794 QVERIFY(id == TMPXItemId(1, KVcxMvcMediaTypeAlbum)); |
|
795 QVERIFY(name == "name"); |
|
796 |
717 } |
797 } |
718 |
798 |
719 // End of file |
799 // End of file |
720 |
800 |
721 |
801 |