21 |
21 |
22 #include "mpxaudioeffectengine.h" |
22 #include "mpxaudioeffectengine.h" |
23 #include "unittest_mpmpxplaybackframeworkwrapper.h" |
23 #include "unittest_mpmpxplaybackframeworkwrapper.h" |
24 #include "stub/inc/mpplaybackdata.h" |
24 #include "stub/inc/mpplaybackdata.h" |
25 #include "stub/inc/mpxplaybackutility.h" |
25 #include "stub/inc/mpxplaybackutility.h" |
26 |
26 #include "stub/inc/mpsongdata.h" |
27 |
27 |
28 // Do this so we can access all member variables. |
28 // Do this so we can access all member variables. |
29 #define private public |
29 #define private public |
30 #include "mpmpxplaybackframeworkwrapper.h" |
30 #include "mpmpxplaybackframeworkwrapper.h" |
31 #include "mpmpxplaybackframeworkwrapper_p.h" |
31 #include "mpmpxplaybackframeworkwrapper_p.h" |
32 #undef private |
32 #undef private |
33 |
33 |
34 //This so we can test private functions |
34 // This so we can test private functions |
35 #include "mpmpxplaybackframeworkwrapper_p.cpp" |
35 #include "mpmpxplaybackframeworkwrapper_p.cpp" |
36 //Test data |
36 |
|
37 // Test data |
37 struct TTestAttrs |
38 struct TTestAttrs |
38 { |
39 { |
39 const wchar_t* GeneralTitle; |
40 const wchar_t* GeneralTitle; |
40 const wchar_t* MusicArtist; |
41 const wchar_t* MusicArtist; |
41 const TInt GeneralCount; |
42 const TInt GeneralCount; |
72 } |
73 } |
73 } |
74 } |
74 |
75 |
75 TestMpMpxPlaybackFrameworkWrapper::TestMpMpxPlaybackFrameworkWrapper() |
76 TestMpMpxPlaybackFrameworkWrapper::TestMpMpxPlaybackFrameworkWrapper() |
76 : mTest(0), |
77 : mTest(0), |
77 iMediaTestData(0) |
78 iMediaTestData(0), |
|
79 mSongData(0) |
78 { |
80 { |
79 } |
81 } |
80 |
82 |
81 TestMpMpxPlaybackFrameworkWrapper::~TestMpMpxPlaybackFrameworkWrapper() |
83 TestMpMpxPlaybackFrameworkWrapper::~TestMpMpxPlaybackFrameworkWrapper() |
82 { |
84 { |
83 delete mTest; |
85 delete mTest; |
84 delete iMediaTestData; |
86 delete iMediaTestData; |
|
87 delete mSongData; |
85 } |
88 } |
86 |
89 |
87 /*! |
90 /*! |
88 Called before the first testfunction is executed. |
91 Called before the first testfunction is executed. |
89 */ |
92 */ |
90 void TestMpMpxPlaybackFrameworkWrapper::initTestCase() |
93 void TestMpMpxPlaybackFrameworkWrapper::initTestCase() |
91 { |
94 { |
|
95 mSongData = new MpSongData(); |
92 } |
96 } |
93 |
97 |
94 /*! |
98 /*! |
95 Called after the last testfunction was executed. |
99 Called after the last testfunction was executed. |
96 */ |
100 */ |
346 |
349 |
347 CleanupStack::PopAndDestroy(emptyTestData); |
350 CleanupStack::PopAndDestroy(emptyTestData); |
348 } |
351 } |
349 |
352 |
350 /*! |
353 /*! |
|
354 Tests handleMedia resulting from request from details |
|
355 */ |
|
356 void TestMpMpxPlaybackFrameworkWrapper::testHandleMediaDetails() |
|
357 { |
|
358 mTestPrivate->iDetailsRequest = true; |
|
359 loadTestData(0); |
|
360 mTestPrivate->HandleMediaL(*iMediaTestData, KErrNone); |
|
361 QCOMPARE(mTestPrivate->iSongData->iSetMedia, true); |
|
362 } |
|
363 |
|
364 /*! |
351 Tests retrieveSong |
365 Tests retrieveSong |
352 */ |
366 */ |
353 void TestMpMpxPlaybackFrameworkWrapper::testRetrieveSongDetails() |
367 void TestMpMpxPlaybackFrameworkWrapper::testRetrieveSongDetails() |
354 { |
368 { |
355 mTestPrivate->RetrieveSongDetailsL(); |
369 // Internal requests |
|
370 mTestPrivate->DoRetrieveSongDetailsL(false); |
356 QCOMPARE(mTestPrivate->iPlaybackUtility->iAttrs->Count(), 8); |
371 QCOMPARE(mTestPrivate->iPlaybackUtility->iAttrs->Count(), 8); |
|
372 |
|
373 // Request from Details view |
|
374 mTestPrivate->iDetailsRequest = false; |
|
375 mTest->retrieveSongDetails(); |
|
376 QCOMPARE(mTestPrivate->iPlaybackUtility->iAttrs->Count(), 18); |
|
377 QCOMPARE(mTestPrivate->iDetailsRequest, true); |
|
378 |
|
379 // Request from Details view - no source |
|
380 mTestPrivate->iDetailsRequest = false; |
|
381 mTestPrivate->iPlaybackUtility->iReturnSource = false; |
|
382 mTest->retrieveSongDetails(); |
|
383 QCOMPARE(mTestPrivate->iDetailsRequest, false); |
357 } |
384 } |
358 |
385 |
359 /*! |
386 /*! |
360 Tests updateState |
387 Tests updateState |
361 */ |
388 */ |
505 //HandleSubPlayerNamesL does nothing, included just to cover all declared functions. |
538 //HandleSubPlayerNamesL does nothing, included just to cover all declared functions. |
506 TUid stubUid = {0x00000001}; |
539 TUid stubUid = {0x00000001}; |
507 MDesCArray* stubArray = NULL; |
540 MDesCArray* stubArray = NULL; |
508 mTestPrivate->HandleSubPlayerNamesL(stubUid, stubArray, false, KErrNone); |
541 mTestPrivate->HandleSubPlayerNamesL(stubUid, stubArray, false, KErrNone); |
509 QVERIFY(mTestPrivate); |
542 QVERIFY(mTestPrivate); |
|
543 } |
|
544 |
|
545 /*! |
|
546 Tests closeCurrentPlayback() / DoCloseCurrentPlaybackL() |
|
547 */ |
|
548 void TestMpMpxPlaybackFrameworkWrapper::testCloseCurrentPlayback() |
|
549 { |
|
550 TMPXPlaybackCommand dummyCmd = EPbCmdPlay; |
|
551 mTestPrivate->iPlaybackUtility->iCmd = dummyCmd; |
|
552 |
|
553 //Simulate none file opened. |
|
554 mTestPrivate->iPlaybackUtility->iReturnSource = false; |
|
555 mTest->closeCurrentPlayback(); |
|
556 QVERIFY(mTestPrivate->iPlaybackUtility->iCmd != EPbCmdClose); |
|
557 |
|
558 //Simulate some file already opened. |
|
559 mTestPrivate->iPlaybackUtility->iReturnSource = true; |
|
560 mTest->closeCurrentPlayback(); |
|
561 QVERIFY(mTestPrivate->iPlaybackUtility->iCmd == EPbCmdClose); |
|
562 } |
|
563 |
|
564 /*! |
|
565 Tests pause. |
|
566 */ |
|
567 void TestMpMpxPlaybackFrameworkWrapper::testPause() |
|
568 { |
|
569 mTest->pause(); |
|
570 QCOMPARE(mTestPrivate->iPlaybackUtility->iCmd, EPbCmdPause); |
|
571 } |
|
572 |
|
573 /*! |
|
574 Tests getMaxVolume. |
|
575 */ |
|
576 void TestMpMpxPlaybackFrameworkWrapper::testGetMaxVolume() |
|
577 { |
|
578 mTest->getMaxVolume(); |
|
579 QCOMPARE(mTestPrivate->iPlaybackUtility->iProperty, EPbPropertyMaxVolume); |
|
580 } |
|
581 |
|
582 /*! |
|
583 Tests getVolume. |
|
584 */ |
|
585 void TestMpMpxPlaybackFrameworkWrapper::testGetVolume() |
|
586 { |
|
587 mTest->getVolume(); |
|
588 QCOMPARE(mTestPrivate->iPlaybackUtility->iProperty, EPbPropertyVolume); |
|
589 } |
|
590 |
|
591 /*! |
|
592 Tests increaseVolume. |
|
593 */ |
|
594 void TestMpMpxPlaybackFrameworkWrapper::testIncreaseVolume() |
|
595 { |
|
596 mTest->increaseVolume(); |
|
597 QCOMPARE(mTestPrivate->iPlaybackUtility->iCmd, EPbCmdIncreaseVolume); |
|
598 } |
|
599 |
|
600 /*! |
|
601 Tests decreaseVolume. |
|
602 */ |
|
603 void TestMpMpxPlaybackFrameworkWrapper::testDecreaseVolume() |
|
604 { |
|
605 mTest->decreaseVolume(); |
|
606 QCOMPARE(mTestPrivate->iPlaybackUtility->iCmd, EPbCmdDecreaseVolume); |
|
607 } |
|
608 |
|
609 /*! |
|
610 Tests setVolume. |
|
611 */ |
|
612 void TestMpMpxPlaybackFrameworkWrapper::testSetVolume() |
|
613 { |
|
614 int value = 30; |
|
615 mTest->setVolume( value ); |
|
616 QCOMPARE(mTestPrivate->iPlaybackUtility->iCmd, EPbCmdSetVolume); |
|
617 QCOMPARE(mTestPrivate->iPlaybackUtility->iComandData, value); |
|
618 } |
|
619 |
|
620 /*! |
|
621 Tests getMuteState. |
|
622 */ |
|
623 void TestMpMpxPlaybackFrameworkWrapper::testGetMuteState() |
|
624 { |
|
625 mTest->getMuteState(); |
|
626 QCOMPARE(mTestPrivate->iPlaybackUtility->iProperty, EPbPropertyMute); |
|
627 } |
|
628 |
|
629 /*! |
|
630 Tests mute. |
|
631 */ |
|
632 void TestMpMpxPlaybackFrameworkWrapper::testMute() |
|
633 { |
|
634 mTest->mute(); |
|
635 QCOMPARE(mTestPrivate->iPlaybackUtility->iCmd, EPbCmdMuteVolume); |
|
636 } |
|
637 |
|
638 /*! |
|
639 Tests unmute. |
|
640 */ |
|
641 void TestMpMpxPlaybackFrameworkWrapper::testUnmute() |
|
642 { |
|
643 mTest->unmute(); |
|
644 QCOMPARE(mTestPrivate->iPlaybackUtility->iCmd, EPbCmdUnMuteVolume); |
510 } |
645 } |
511 |
646 |
512 /*! |
647 /*! |
513 Used to load test data |
648 Used to load test data |
514 */ |
649 */ |