27 #include <mpxcollectionpath.h> |
27 #include <mpxcollectionpath.h> |
28 |
28 |
29 #include <mpxcollectionuihelper.h> |
29 #include <mpxcollectionuihelper.h> |
30 #include <mpxcollectionhelperfactory.h> |
30 #include <mpxcollectionhelperfactory.h> |
31 |
31 |
32 |
|
33 #include "unittest_mpmpxcollectiondata.h" |
32 #include "unittest_mpmpxcollectiondata.h" |
34 #include "mpcommondefs.h" |
33 #include "mpcommondefs.h" |
|
34 #include "unittest_helper.h" |
35 |
35 |
36 |
36 |
37 // Do this so we can access all member variables. |
37 // Do this so we can access all member variables. |
38 #define private public |
38 #define private public |
39 #include "mpmpxcollectiondata.h" |
39 #include "mpmpxcollectiondata.h" |
86 return QTest::qExec(&tv, 3, pass); |
86 return QTest::qExec(&tv, 3, pass); |
87 } |
87 } |
88 } |
88 } |
89 |
89 |
90 TestMpMpxCollectionData::TestMpMpxCollectionData() |
90 TestMpMpxCollectionData::TestMpMpxCollectionData() |
91 : mTest(0) |
91 : mTest(0), |
|
92 mHelper(0) |
92 { |
93 { |
93 } |
94 } |
94 |
95 |
95 TestMpMpxCollectionData::~TestMpMpxCollectionData() |
96 TestMpMpxCollectionData::~TestMpMpxCollectionData() |
96 { |
97 { |
97 delete mTest; |
98 delete mTest; |
|
99 delete mHelper; |
98 } |
100 } |
99 |
101 |
100 /*! |
102 /*! |
101 Called before the first testfunction is executed. |
103 Called before the first testfunction is executed. |
102 */ |
104 */ |
417 entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup); |
420 entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup); |
418 entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong); |
421 entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXSong); |
419 mTestPrivate->iContainerMedia = entries; |
422 mTestPrivate->iContainerMedia = entries; |
420 mTestPrivate->SetCollectionContextL(); |
423 mTestPrivate->SetCollectionContextL(); |
421 QCOMPARE(mTestPrivate->iContext, ECollectionContextAllSongs); |
424 QCOMPARE(mTestPrivate->iContext, ECollectionContextAllSongs); |
|
425 QCOMPARE(mTestPrivate->iSongIdIndexMapping.empty(), true); |
422 |
426 |
423 // All artists |
427 // All artists |
424 entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup); |
428 entries->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup); |
425 entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXArtist); |
429 entries->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXArtist); |
426 mTestPrivate->iContainerMedia = entries; |
430 mTestPrivate->iContainerMedia = entries; |
533 QSignalSpy spy(mTest, SIGNAL(contextChanged(TCollectionContext))); |
537 QSignalSpy spy(mTest, SIGNAL(contextChanged(TCollectionContext))); |
534 mTest->setMpxMedia(*entries); |
538 mTest->setMpxMedia(*entries); |
535 QCOMPARE(spy.count(), 1); |
539 QCOMPARE(spy.count(), 1); |
536 TCollectionContext context = qvariant_cast<TCollectionContext>(spy.at(0).at(0)); |
540 TCollectionContext context = qvariant_cast<TCollectionContext>(spy.at(0).at(0)); |
537 QCOMPARE(context, ECollectionContextAllSongs); |
541 QCOMPARE(context, ECollectionContextAllSongs); |
|
542 QCOMPARE(mTestPrivate->iReloadAlbumContent, false); |
538 CleanupStack::PopAndDestroy(entries); |
543 CleanupStack::PopAndDestroy(entries); |
539 } |
544 } |
540 |
545 |
541 /*! |
546 /*! |
542 Tests containerId(). |
547 Tests containerId(). |
564 CMPXMedia* item = CMPXMedia::NewL(); |
569 CMPXMedia* item = CMPXMedia::NewL(); |
565 CMPXMediaArray* array = CMPXMediaArray::NewL(); |
570 CMPXMediaArray* array = CMPXMediaArray::NewL(); |
566 array->AppendL(item); |
571 array->AppendL(item); |
567 |
572 |
568 mTestPrivate->iMediaArray = array; |
573 mTestPrivate->iMediaArray = array; |
569 QCOMPARE( mTest->itemId(0), -1); |
574 QCOMPARE( mTest->itemId(0), 0); |
570 |
575 |
571 item->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, itemId ); |
576 item->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, itemId ); |
572 QCOMPARE( mTest->itemId(0), itemId); |
577 QCOMPARE( mTest->itemId(0), itemId); |
573 |
578 |
574 delete array; |
579 delete array; |
750 Tests setCurrentAlbum(). |
755 Tests setCurrentAlbum(). |
751 */ |
756 */ |
752 void TestMpMpxCollectionData::testSetCurrentAlbum() |
757 void TestMpMpxCollectionData::testSetCurrentAlbum() |
753 { |
758 { |
754 QSignalSpy spy(mTest, SIGNAL(refreshAlbumSongs())); |
759 QSignalSpy spy(mTest, SIGNAL(refreshAlbumSongs())); |
|
760 mTestPrivate->iReloadAlbumContent = false; |
755 |
761 |
756 // Create media array that doesn't have the album songs yet. |
762 // Create media array that doesn't have the album songs yet. |
757 CMPXMediaArray* array = CMPXMediaArray::NewL(); |
763 CMPXMediaArray* array = CMPXMediaArray::NewL(); |
758 CleanupStack::PushL(array); |
764 CleanupStack::PushL(array); |
759 CMPXMedia* media = CMPXMedia::NewL(); |
765 CMPXMedia* media = CMPXMedia::NewL(); |
861 mTestPrivate->iMediaArray = NULL; |
867 mTestPrivate->iMediaArray = NULL; |
862 CleanupStack::PopAndDestroy(array); |
868 CleanupStack::PopAndDestroy(array); |
863 } |
869 } |
864 |
870 |
865 /*! |
871 /*! |
866 Tests hasAlbumSongProperty(). |
872 Tests hasItemProperty(). |
867 */ |
873 */ |
868 void TestMpMpxCollectionData::testHasItemProperty() |
874 void TestMpMpxCollectionData::testHasItemProperty() |
869 { |
875 { |
870 CMPXMediaArray* array = CMPXMediaArray::NewL(); |
876 CMPXMediaArray* array = CMPXMediaArray::NewL(); |
871 CleanupStack::PushL(array); |
877 CleanupStack::PushL(array); |
971 CleanupStack::PopAndDestroy(songArray); |
977 CleanupStack::PopAndDestroy(songArray); |
972 CleanupStack::PopAndDestroy(media); |
978 CleanupStack::PopAndDestroy(media); |
973 mTestPrivate->iMediaArray = NULL; |
979 mTestPrivate->iMediaArray = NULL; |
974 CleanupStack::PopAndDestroy(array); |
980 CleanupStack::PopAndDestroy(array); |
975 } |
981 } |
|
982 |
|
983 /*! |
|
984 Tests setCorruptValue(). |
|
985 */ |
|
986 void TestMpMpxCollectionData::testSetCorruptValue() |
|
987 { |
|
988 CMPXMediaArray* array = CMPXMediaArray::NewL(); |
|
989 CleanupStack::PushL(array); |
|
990 CMPXMedia* song = CMPXMedia::NewL(); |
|
991 array->AppendL(*song); |
|
992 mTestPrivate->iMediaArray = array; |
|
993 QModelIndex modelIndex = mHelper->indexFor(0); |
|
994 mTest->setCorruptValue(modelIndex,false); |
|
995 QCOMPARE(mTest->hasItemProperty( 0, MpMpxCollectionData::Corrupted), true); |
|
996 CleanupStack::PopAndDestroy(array); |
|
997 mTestPrivate->iMediaArray = NULL; |
|
998 } |
|
999 |
|
1000 /*! |
|
1001 Tests setReloadAlbumContent(). |
|
1002 */ |
|
1003 void TestMpMpxCollectionData::testSetReloadAlbumContent() |
|
1004 { |
|
1005 mTest->setReloadAlbumContent(false); |
|
1006 QCOMPARE(mTestPrivate->iReloadAlbumContent, false); |
|
1007 mTest->setReloadAlbumContent(true); |
|
1008 QCOMPARE(mTestPrivate->iReloadAlbumContent, true); |
|
1009 |
|
1010 } |
|
1011 |