First public contribution.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "TestPlayer.h"
23 CTestVclntVideoFile::CTestVclntVideoFile(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
26 // store the name of this test case
27 // this is the name that is used by the script file
28 // Each test step initialises it's own name
29 iTestStepName = aTestName;
30 iSectName = aSectName;
33 // expand heap, so we can load 80k video
37 CTestVclntVideoFile* CTestVclntVideoFile::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
39 CTestVclntVideoFile* self = new (ELeave) CTestVclntVideoFile(aTestName,aSectName,aKeyName,aPlay);
43 CTestVclntVideoFile* CTestVclntVideoFile::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
45 CTestVclntVideoFile* self = CTestVclntVideoFile::NewLC(aTestName,aSectName,aKeyName,aPlay);
46 CleanupStack::PushL(self);
50 void CTestVclntVideoFile::MvpuoOpenComplete(TInt aError)
53 INFO_PRINTF1(_L("Open Complete callback"));
54 CActiveScheduler::Stop();
57 void CTestVclntVideoFile::MvpuoPrepareComplete(TInt aError)
60 INFO_PRINTF1(_L("Open Complete callback"));
61 CActiveScheduler::Stop();
64 void CTestVclntVideoFile::MvpuoFrameReady(CFbsBitmap& /*aFrame*/, TInt aError)
67 INFO_PRINTF1(_L("Frame Ready callback"));
70 void CTestVclntVideoFile::MvpuoPlayComplete(TInt aError)
73 INFO_PRINTF1(_L("Play Complete callback"));
74 CActiveScheduler::Stop();
77 void CTestVclntVideoFile::MvpuoEvent(const TMMFEvent& /*aEvent*/)
83 * Load and initialise an audio file.
85 TVerdict CTestVclntVideoFile::DoTestStepL()
88 iError = KErrTimedOut;
90 INFO_PRINTF1(_L("Test : Video Player - File"));
93 if(!GetStringFromConfig(iSectName,iKeyName,filename))
99 CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
100 EMdaPriorityPreferenceTimeAndQuality,
101 iWs, *iScreen, *iWindow, rect, clipRect);
102 CleanupStack::PushL(player);
103 TRAP(iError,player->OpenFileL(filename));
105 if(iError == KErrNone)
107 // Wait for initialisation callback
108 INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file"));
109 CActiveScheduler::Start();
113 #ifndef JETSTREAM_TESTS
114 if(iError == KErrNotSupported)
119 if (iError == KErrNone && player != NULL)
122 CActiveScheduler::Start();
126 if (iError == KErrNone && player != NULL)
127 ret = DoTestL(player);
129 INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying"));
130 CleanupStack::PopAndDestroy(player);
131 if(iError != KErrNone)
132 ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );
136 TVerdict CTestVclntVideoFile::DoTestL(CVideoPlayerUtility* aPlayer)
138 TVerdict ret = EFail;
140 // #ifdef JETSTREAM_TESTS
143 iError = KErrTimedOut;
145 INFO_PRINTF1(_L("CVideoPlayerUtility: Playing file"));
146 // Wait for init callback
147 CActiveScheduler::Start();
148 if(iError == KErrNone)
160 //------------------------------------------------------------------
165 CTestVclntVideoDes::CTestVclntVideoDes(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, const TBool aPlay)
169 // store the name of this test case
170 // this is the name that is used by the script file
171 // Each test step initialises it's own name
172 iTestStepName = aTestName;
173 iSectName = aSectName;
176 // *** Jim : expand heap, so we can load 80k video
180 CTestVclntVideoDes* CTestVclntVideoDes::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
182 CTestVclntVideoDes* self = new (ELeave) CTestVclntVideoDes(aTestName,aSectName,aKeyName,aPlay);
186 CTestVclntVideoDes* CTestVclntVideoDes::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
188 CTestVclntVideoDes* self = CTestVclntVideoDes::NewLC(aTestName,aSectName,aKeyName,aPlay);
189 CleanupStack::PushL(self);
193 void CTestVclntVideoDes::MvpuoOpenComplete(TInt aError)
196 CActiveScheduler::Stop();
199 void CTestVclntVideoDes::MvpuoPrepareComplete(TInt aError)
202 CActiveScheduler::Stop();
205 void CTestVclntVideoDes::MvpuoFrameReady(CFbsBitmap& /*aFrame*/,TInt aError)
208 // Will this function require a Active Scheduler Stop?
211 void CTestVclntVideoDes::MvpuoPlayComplete(TInt aError)
214 CActiveScheduler::Stop();
217 void CTestVclntVideoDes::MvpuoEvent(const TMMFEvent& /*aEvent*/)
222 TVerdict CTestVclntVideoDes::DoTestStepPreambleL()
225 if(!GetStringFromConfig(iSectName, iKeyName, filename))
226 return EInconclusive;
232 // connect to file system and open file
233 User::LeaveIfError(fs.Connect());
234 User::LeaveIfError(file.Open(fs,filename,EFileRead));
235 CleanupClosePushL(file);
238 User::LeaveIfError(file.Size(size));
239 INFO_PRINTF2(_L("size of file = %d\n"),size);//Statement Changed under DEF105143
241 iVideo = HBufC8::NewMaxL(size);
243 // read data into Hbuf
244 TPtr8 bufferDes(iVideo->Des());
245 User::LeaveIfError(file.Read(bufferDes));
247 CleanupStack::PopAndDestroy(); //file
248 return CTestMmfVclntStep::DoTestStepPreambleL();
251 TVerdict CTestVclntVideoDes::DoTestStepPostambleL()
255 return CTestMmfVclntStep::DoTestStepPostambleL();
259 * Load and initialise an audio descriptor.
261 TVerdict CTestVclntVideoDes::DoTestStepL()
263 TVerdict ret = EFail;
265 INFO_PRINTF1(_L("Test : Video Player - Descriptor"));
267 iError = KErrTimedOut;
271 TRect rect, clipRect;
272 CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
273 EMdaPriorityPreferenceTimeAndQuality,
274 iWs, *iScreen, *iWindow, rect, clipRect);
275 CleanupStack::PushL(player);
278 TRAP(iError, player->OpenDesL(iVideo->Des()));
280 if(iError == KErrNone)
282 INFO_PRINTF1(_L("CVideoPlayerUtility: Opening descriptor"));
283 // Wait for init callback
284 CActiveScheduler::Start();
288 #ifndef JETSTREAM_TESTS
289 if(iError == KErrNotSupported)
293 if (iError == KErrNone && player != NULL)
296 CActiveScheduler::Start();
300 if ((iError == KErrNone) && (player != NULL))
301 ret = DoTestL(player);
303 INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying"));
304 CleanupStack::PopAndDestroy(player);
305 if(iError != KErrNone)
306 ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );
310 TVerdict CTestVclntVideoDes::DoTestL(CVideoPlayerUtility* aPlayer)
312 TVerdict ret = EFail;
313 // #ifdef JETSTREAM_TESTS
317 iError = KErrTimedOut;
319 INFO_PRINTF1(_L("CVideoPlayerUtility: Playing descriptor"));
320 // Wait for init callback
321 CActiveScheduler::Start();
322 if(iError == KErrNone)
334 //------------------------------------------------------------------
339 CTestVclntVideoUrl::CTestVclntVideoUrl(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
342 // store the name of this test case
343 // this is the name that is used by the script file
344 // Each test step initialises it's own name
345 iTestStepName = aTestName;
346 iSectName = aSectName;
350 CTestVclntVideoUrl* CTestVclntVideoUrl::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
352 CTestVclntVideoUrl* self = CTestVclntVideoUrl::NewLC(aTestName,aSectName,aKeyName,aPlay);
357 CTestVclntVideoUrl* CTestVclntVideoUrl::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
359 CTestVclntVideoUrl* self = new (ELeave) CTestVclntVideoUrl(aTestName,aSectName,aKeyName,aPlay);
360 CleanupStack::PushL(self);
364 void CTestVclntVideoUrl::MvpuoOpenComplete(TInt aError)
367 INFO_PRINTF1(_L("Open complete callback"));
368 CActiveScheduler::Stop();
371 void CTestVclntVideoUrl::MvpuoPrepareComplete(TInt aError)
374 INFO_PRINTF1(_L("Open complete callback"));
375 CActiveScheduler::Stop();
378 void CTestVclntVideoUrl::MvpuoFrameReady(CFbsBitmap& /*aFrame*/, TInt aError)
382 INFO_PRINTF1(_L("Frame Ready callback"));
385 void CTestVclntVideoUrl::MvpuoPlayComplete(TInt aError)
388 INFO_PRINTF1(_L("Play complete callback"));
389 CActiveScheduler::Stop();
392 void CTestVclntVideoUrl::MvpuoEvent(const TMMFEvent& /*aEvent*/)
398 * Open audio from a URL and play.
400 TVerdict CTestVclntVideoUrl::DoTestStepL()
402 TVerdict ret = EFail;
404 INFO_PRINTF1(_L("Test : Video Player - URL"));
406 iError = KErrTimedOut;
409 if(!GetStringFromConfig(iSectName,iKeyName,urlname))
410 return EInconclusive;
414 TRect rect, clipRect;
415 CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
416 EMdaPriorityPreferenceTimeAndQuality,
417 iWs, *iScreen, *iWindow, rect, clipRect);
418 // wait for init to complete
419 CleanupStack::PushL(player);
420 player->OpenUrlL(urlname);
421 INFO_PRINTF1(_L("CVideoPlayerUtility: Opening URL"));
422 CActiveScheduler::Start();
425 #ifndef JETSTREAM_TESTS
426 if(iError == KErrNotSupported)
430 if (iError == KErrNone)
433 CActiveScheduler::Start();
436 if (iError == KErrNone)
437 ret = DoTestL(player);
439 INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying"));
440 CleanupStack::PopAndDestroy(player);
441 if(iError != KErrNone)
442 ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );
446 TVerdict CTestVclntVideoUrl::DoTestL(CVideoPlayerUtility* aPlayer)
448 TVerdict ret = EFail;
450 //#ifdef JETSTREAM_TESTS
452 iError = KErrTimedOut;
455 INFO_PRINTF1(_L("CVideoPlayerUtility: Playing URL"));
456 // Wait for play to complete
457 CActiveScheduler::Start();
459 if(iError == KErrNone)
469 //------------------------------------------------------------------
472 CTestVclntEnqFrameRate::CTestVclntEnqFrameRate(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aFrameRate)
473 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
475 iFrameRate = aFrameRate;
478 CTestVclntEnqFrameRate* CTestVclntEnqFrameRate::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aFrameRate)
480 CTestVclntEnqFrameRate* self = new (ELeave) CTestVclntEnqFrameRate(aTestName,aSectName,aKeyName,aFrameRate);
484 TVerdict CTestVclntEnqFrameRate::DoTestL(CVideoPlayerUtility* aPlayer)
486 INFO_PRINTF1(_L("Test : Video Player - Enquire Frame Rate"));
488 TVerdict ret = EFail;
491 Math::Int(theFrameRate, aPlayer->VideoFrameRateL());
492 INFO_PRINTF2(_L("(Frame rate : %d)"), theFrameRate);
494 // if we get here, we pass. The player does not have a SetVideoFrameRate()
501 //------------------------------------------------------------------
503 CTestVclntPosition::CTestVclntPosition(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aPosition)
504 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
506 iPosition = aPosition;
509 CTestVclntPosition* CTestVclntPosition::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aPosition)
511 CTestVclntPosition* self = new (ELeave) CTestVclntPosition(aTestName,aSectName,aKeyName,aPosition);
515 TVerdict CTestVclntPosition::DoTestL(CVideoPlayerUtility* aPlayer)
517 // NB test video controller is stubbing certain functions. May have to rewrite this
520 TVerdict ret = EFail;
522 INFO_PRINTF1(_L("Test : Video Player - Position"));
524 TBool validPosition = EFalse;
526 INFO_PRINTF3(_L("Set Position %d Duration = %d"),
527 I64INT(iPosition.Int64()), I64INT(aPlayer->DurationL().Int64()));
529 // Set position: middle of clip.
530 if (I64INT(iPosition.Int64()) == 0)
531 iPosition = I64INT(aPlayer->DurationL().Int64()) / 2;
532 // Set position: end of clip.
533 if (I64INT(iPosition.Int64()) == -1)
534 iPosition = aPlayer->DurationL();
536 // Position is beyond the end of the clips duration
537 // so check that the value is clipped.
538 if(aPlayer->DurationL() < iPosition)
540 INFO_PRINTF2(_L("Longer than duration : Setting position to %d"), I64INT(iPosition.Int64()));
541 aPlayer->SetPositionL(iPosition);
542 INFO_PRINTF3(_L("Set : position = %d (if clipped : %d)"),
543 I64INT(aPlayer->PositionL().Int64()), I64INT(aPlayer->DurationL().Int64()));
544 if(aPlayer->PositionL() == aPlayer->DurationL())
545 validPosition = ETrue;
547 // Position is negative
548 // so check that the value is clipped.
549 else if (I64INT(iPosition.Int64()) < 0)
551 INFO_PRINTF2(_L("Negative value : Setting position to %d"), I64INT(iPosition.Int64()));
552 aPlayer->SetPositionL(iPosition);
553 INFO_PRINTF2(_L("Set : position = %d (if clipped : 0)"), I64INT(aPlayer->PositionL().Int64()));
554 if (I64INT(aPlayer->PositionL().Int64()) == 0)
555 validPosition = ETrue;
559 INFO_PRINTF2(_L("Normal : Setting position to %d"), I64INT(iPosition.Int64()));
560 aPlayer->SetPositionL(iPosition);
561 INFO_PRINTF3(_L("Set : position = %d (if clipped : %d)"),
562 I64INT(aPlayer->PositionL().Int64()), I64INT(iPosition.Int64()));
563 if(aPlayer->PositionL() == iPosition)
564 validPosition = ETrue;
567 // Position was set to a valid value.
571 INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
572 // wait for play to complete
573 CActiveScheduler::Start();
575 INFO_PRINTF2(_L("Error : %d"), iError);
576 if (iError == KErrNone)
581 // We've got an invalid position, attempt to play anyway...
582 // the test controller should handle it
584 INFO_PRINTF1(_L("CVideoPlayerUtility: Playing from invalid position"));
585 // wait for play to complete
586 CActiveScheduler::Start();
588 INFO_PRINTF2(_L("Error : %d"), iError);
589 if (iError == KErrNone)
598 //------------------------------------------------------------------
600 CTestVclntPriority::CTestVclntPriority(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aPriority)
601 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
603 iPriority = aPriority;
606 CTestVclntPriority* CTestVclntPriority::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aPriority)
608 CTestVclntPriority* self = new (ELeave) CTestVclntPriority(aTestName,aSectName,aKeyName,aPriority);
612 TVerdict CTestVclntPriority::DoTestL(CVideoPlayerUtility* aPlayer)
614 TVerdict ret = EFail;
616 INFO_PRINTF1(_L("Test : Video Player - Priority"));
618 aPlayer->SetPriorityL(iPriority, EMdaPriorityPreferenceNone);
620 TMdaPriorityPreference thePref;
621 aPlayer->PriorityL(thePriority, thePref);
622 INFO_PRINTF3(_L("Priority = %d (expecting %d)"), thePriority, iPriority);
623 INFO_PRINTF3(_L("Pref = %d (expecting %d)"), thePref, EMdaPriorityPreferenceNone);
624 if( (thePriority == iPriority) && (thePref == EMdaPriorityPreferenceNone) )
630 //------------------------------------------------------------------
632 CTestVclntDuration::CTestVclntDuration(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aDuration)
633 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
635 iDuration = aDuration;
638 CTestVclntDuration* CTestVclntDuration::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aDuration)
640 CTestVclntDuration* self = new (ELeave) CTestVclntDuration(aTestName,aSectName,aKeyName,aDuration);
644 TVerdict CTestVclntDuration::DoTestL(CVideoPlayerUtility* aPlayer)
646 TVerdict ret = EFail;
648 INFO_PRINTF1(_L("Test : Video Player - Duration"));
650 if (I64INT(iDuration.Int64()) == 0)
652 TInt duration = I64INT(aPlayer->DurationL().Int64());
654 INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
657 CActiveScheduler::Start();
661 TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
663 INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d Duration = %d ActualDuration = %d"),
664 iError, I64INT(start.Int64()), I64INT(stop.Int64()), duration, actualDuration);
665 if((iError == KErrNone) && (TimeComparison(actualDuration, duration, KExpectedDeviation)))
670 if(aPlayer->DurationL() == iDuration)
676 //------------------------------------------------------------------
678 CTestVclntVolume::CTestVclntVolume(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aVolume)
679 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
684 CTestVclntVolume* CTestVclntVolume::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aVolume)
686 CTestVclntVolume* self = new (ELeave) CTestVclntVolume(aTestName,aSectName,aKeyName,aVolume);
690 TVerdict CTestVclntVolume::DoTestL(CVideoPlayerUtility* aPlayer)
692 TVerdict ret = EFail;
694 // NB : test video controller does not adjust invalid volumes
695 // comment the checks back in for JS
697 INFO_PRINTF1(_L("Test : Video Player - Volume"));
699 INFO_PRINTF1(_L("Warning : test video controller does not adjust invalid volumes"));
701 // Check maxvolume function
704 iVolume = aPlayer->MaxVolume();
705 INFO_PRINTF3(_L("Volume = %d MaxVolume = %d"), iVolume, KMaxVolume);
706 //if(iVolume == KMaxVolume)
709 // Volume is truncated to maxvolume
710 else if(iVolume > aPlayer->MaxVolume())
712 aPlayer->SetVolumeL(iVolume);
713 INFO_PRINTF3(_L("Volume = %d MaxVolume = %d"), aPlayer->Volume(), aPlayer->MaxVolume());
714 //if(aPlayer->Volume() == aPlayer->MaxVolume())
717 // Volume is truncated to 0
720 aPlayer->SetVolumeL(iVolume);
721 INFO_PRINTF2(_L("Volume = %d (expecting 0)"), aPlayer->Volume());
722 //if(aPlayer->Volume() == 0)
725 // Set volume and check
728 aPlayer->SetVolumeL(iVolume);
729 INFO_PRINTF3(_L("Volume = %d (expecting %d)"), aPlayer->Volume(), iVolume);
730 if(aPlayer->Volume() == iVolume)
737 //------------------------------------------------------------------
739 CTestVclntCloseOpen::CTestVclntCloseOpen(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
740 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
743 CTestVclntCloseOpen* CTestVclntCloseOpen::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
745 CTestVclntCloseOpen* self = new (ELeave) CTestVclntCloseOpen(aTestName,aSectName,aKeyName);
749 TVerdict CTestVclntCloseOpen::DoTestL(CVideoPlayerUtility* aPlayer)
751 TVerdict ret = EFail;
753 INFO_PRINTF1(_L("Test : Video Player - Close/Open"));
755 //#ifdef JETSTREAM_TESTS
758 if(!GetStringFromConfig(iSectName,iKeyName,filename))
759 return EInconclusive;
762 User::After(KOneSecond);
764 TRAP(iError,aPlayer->OpenFileL(filename));
765 if(iError == KErrNone)
767 // Wait for initialisation callback
768 INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file"));
779 //------------------------------------------------------------------
781 CTestVclntPause::CTestVclntPause(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
782 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
785 CTestVclntPause* CTestVclntPause::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
787 CTestVclntPause* self = new (ELeave) CTestVclntPause(aTestName,aSectName,aKeyName);
791 TVerdict CTestVclntPause::DoTestL(CVideoPlayerUtility* aPlayer)
793 TVerdict ret = EFail;
795 INFO_PRINTF1(_L("Test : Video Player - Pause"));
797 // Tests pause functionality
798 // NB : not implemented in test controller
799 INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
801 CActiveScheduler::Start();
804 #ifdef JETSTREAM_TESTS
805 TInt duration = I64INT(aPlayer->DurationL().Int64());
807 iError = KErrTimedOut;
809 INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
812 CActiveScheduler::Start();
816 TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
818 INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d Duration = %d ActualDuration = %d"),
819 iError, I64INT(start.Int64()), I64INT(stop.Int64()), duration, actualDuration);
820 if((iError == KErrNone) && (TimeComparison(actualDuration, duration, KExpectedDeviation)))
823 INFO_PRINTF1(_L("Warning : PauseL() functionality not supported in test controller"));
831 //------------------------------------------------------------------
833 CTestVclntBalance::CTestVclntBalance(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aBalance)
834 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
839 CTestVclntBalance* CTestVclntBalance::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aBalance)
841 CTestVclntBalance* self = new (ELeave) CTestVclntBalance(aTestName,aSectName,aKeyName,aBalance);
845 TVerdict CTestVclntBalance::DoTestL(CVideoPlayerUtility* aPlayer)
847 INFO_PRINTF1(_L("Test : Video Player - Balance"));
849 #ifdef JETSTREAM_TESTS
850 if (iBalance < KMinBalance)
852 aPlayer->SetBalanceL(iBalance);
853 INFO_PRINTF3(_L("Balance = %d (expecting %d)"), aPlayer->Balance(), KMinBalance);
854 if(aPlayer->Balance() == KMinBalance)
857 else if (iBalance > KMaxBalance)
859 aPlayer->SetBalanceL(iBalance);
860 INFO_PRINTF3(_L("Balance = %d (expecting %d)"), aPlayer->Balance(), KMaxBalance);
861 if(aPlayer->Balance() == KMaxBalance)
866 aPlayer->SetBalanceL(iBalance);
867 INFO_PRINTF3(_L("Balance = %d (expecting %d)"), aPlayer->Balance(), iBalance);
868 if(aPlayer->Balance() == iBalance)
872 // the test video controller returns 1 for all calls of Balance()
873 // call SetBalanceL() to show it doesn't leave
874 aPlayer->SetBalanceL(iBalance);
875 INFO_PRINTF1(_L("Test controller should return 1 for all calls of Balance()"));
876 INFO_PRINTF2(_L("Balance = %d (expecting 1)"), aPlayer->Balance());
877 if(aPlayer->Balance() == 1)
885 //------------------------------------------------------------------
887 CTestVclntPlayWindow::CTestVclntPlayWindow(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aStart, const TTimeIntervalMicroSeconds aEnd)
888 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
894 CTestVclntPlayWindow* CTestVclntPlayWindow::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aStart, const TTimeIntervalMicroSeconds aEnd)
896 CTestVclntPlayWindow* self = new (ELeave) CTestVclntPlayWindow(aTestName,aSectName,aKeyName,aStart,aEnd);
900 TVerdict CTestVclntPlayWindow::DoTestL(CVideoPlayerUtility* aPlayer)
902 TVerdict ret = EFail;
904 INFO_PRINTF1(_L("Test : Video Player - Window"));
908 TRect rect, clipRect;
909 TRAPD(err, aPlayer->SetDisplayWindowL(iWs, *iScreen, *iWindow, rect, clipRect));
912 ERR_PRINTF2(_L("SetDisplayWindowL() failed, error %d"), err);
920 // removed an attempt at opening a window server manually - it seemed to work, but a RWsSession
921 // couldn't Connect(), connectL() claimed no asynchronous operation...
923 // we have no window server, so the test can't run -
924 // so call it with dummy parameters and add explanatory note to the test
926 // NB ws.Connect() will panic on the target, hence don't run it
928 #if defined (__WINS__)
929 TBool testInvalid = EFalse;
931 if(ws.Connect() != KErrNone)
934 // we can't call it at all - SetDisplayWindowL() will cause an access violation if ws is null
937 INFO_PRINTF1(_L("Warning : SetDisplayWindowL() cannot be tested, no window server available"));
942 // TBD - arguments to be correctly set
945 TRect rect, clipRect;
947 TRAPD(err, aPlayer->SetDisplayWindowL(ws, sd, window, rect, clipRect));
950 ERR_PRINTF2(_L("SetDisplayWindowL() failed, error %d"), err);
958 INFO_PRINTF1(_L("Warning : SetDisplayWindowL() cannot be tested on target"));
967 //------------------------------------------------------------------
969 CTestVclntMeta::CTestVclntMeta(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
970 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
973 CTestVclntMeta* CTestVclntMeta::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
975 CTestVclntMeta* self = new (ELeave) CTestVclntMeta(aTestName,aSectName,aKeyName);
979 TVerdict CTestVclntMeta::DoTestL(CVideoPlayerUtility* aPlayer)
981 INFO_PRINTF1(_L("Test : Video Player - Metadata"));
984 TRAPD(err, numOfMeta = aPlayer->NumberOfMetaDataEntriesL() );
985 INFO_PRINTF3(_L("Error : %d Entries = %d"), err, numOfMeta);
986 if (err != KErrNone || numOfMeta != 0)
988 // call that goes to the dummy controller
989 // NB we expect zero metadata entries
990 CMMFMetaDataEntry* theEntry=NULL;
991 TRAP(err, theEntry = aPlayer->MetaDataEntryL(1));
992 INFO_PRINTF2(_L("Error : %d"), err);
1003 //------------------------------------------------------------------
1005 CTestVclntFrameSize::CTestVclntFrameSize(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TInt aFrameSize)
1006 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
1008 iFrameSize = aFrameSize;
1011 CTestVclntFrameSize* CTestVclntFrameSize::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TInt aFrameSize)
1013 CTestVclntFrameSize* self = new (ELeave) CTestVclntFrameSize(aTestName,aSectName,aKeyName,aFrameSize);
1017 TVerdict CTestVclntFrameSize::DoTestL(CVideoPlayerUtility* aPlayer)
1019 TVerdict ret = EFail;
1021 INFO_PRINTF1(_L("Test : Video Player - Frame Size"));
1024 TRAPD(err, aPlayer->VideoFrameSizeL(frameSize) );
1026 INFO_PRINTF4(_L("Error : %d, Frame size : (%d, %d)"), err, frameSize.iWidth, frameSize.iHeight);
1027 if (err == KErrNone &&
1028 frameSize.iWidth >= 0 && frameSize.iHeight >= 0 )
1034 //------------------------------------------------------------------
1036 CTestVclntMimeType::CTestVclntMimeType(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
1037 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
1041 CTestVclntMimeType* CTestVclntMimeType::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
1043 CTestVclntMimeType* self = new (ELeave) CTestVclntMimeType(aTestName,aSectName,aKeyName);
1047 TVerdict CTestVclntMimeType::DoTestL(CVideoPlayerUtility* aPlayer)
1049 INFO_PRINTF1(_L("Test : Video Player - MimeType"));
1051 // NB we cannot check whether the mime type returned is valid, or even exists.
1052 TPtrC8 mimeType = aPlayer->VideoFormatMimeType();
1054 // take it to a 16-bit string
1055 TBuf<64> mimeType16;
1056 mimeType16.Copy(mimeType);
1057 INFO_PRINTF2(_L("Mime type : \'%S\'"), &mimeType16);
1061 //------------------------------------------------------------------
1063 CTestVclntRebuffering::CTestVclntRebuffering(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
1064 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
1068 CTestVclntRebuffering* CTestVclntRebuffering::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
1070 CTestVclntRebuffering* self = new (ELeave) CTestVclntRebuffering(aTestName,aSectName,aKeyName);
1074 TVerdict CTestVclntRebuffering::DoTestL(CVideoPlayerUtility* aPlayer)
1076 INFO_PRINTF1(_L("Test : Video Player - Rebuffering"));
1078 aPlayer->RegisterForVideoLoadingNotification(*this);
1080 INFO_PRINTF1(_L("Rebuffering request completed"));
1084 // from MRebufferCallback
1085 void CTestVclntRebuffering::MvloLoadingStarted()
1087 INFO_PRINTF1(_L("CTestVclntRebuffering::MvloLoadingStarted"));
1090 void CTestVclntRebuffering::MvloLoadingComplete()
1092 INFO_PRINTF1(_L("CTestVclntRebuffering::MvloLoadingComplete"));
1095 //------------------------------------------------------------------
1097 CTestVclntRepeat::CTestVclntRepeat(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TInt aRepeat)
1098 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
1103 CTestVclntRepeat* CTestVclntRepeat::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TInt aRepeat)
1105 CTestVclntRepeat* self = new (ELeave) CTestVclntRepeat(aTestName,aSectName,aKeyName,aRepeat);
1109 TVerdict CTestVclntRepeat::DoTestL(CVideoPlayerUtility* aPlayer)
1111 TVerdict ret = EFail;
1113 INFO_PRINTF1(_L("Test : Video Player - Repeats"));
1115 TInt duration = I64INT(aPlayer->DurationL().Int64());
1117 // SetRepeats() doesn't exist in the video controller, so set iRepeat to 1
1119 INFO_PRINTF1(_L("Warning : SetRepeats() does not exist in player API. Repeat count set to 1"));
1122 INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
1125 CActiveScheduler::Start();
1129 TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
1131 INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d Duration = %d ActualDuration = %d"),
1132 iError, I64INT(start.Int64()), I64INT(stop.Int64()), duration, actualDuration);
1133 if((iError == KErrNone) && (TimeComparison(actualDuration, duration * (iRepeat + 1),
1134 KExpectedDeviation * iRepeat)))
1140 //------------------------------------------------------------------
1142 CTestVclntDelete::CTestVclntDelete(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
1143 : CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
1146 CTestVclntDelete* CTestVclntDelete::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
1148 CTestVclntDelete* self = new (ELeave) CTestVclntDelete(aTestName,aSectName,aKeyName);
1152 TVerdict CTestVclntDelete::DoTestL(CVideoPlayerUtility* /* aPlayer */)
1154 // this is never called
1158 TVerdict CTestVclntDelete::DoTestStepL()
1160 TVerdict ret = EFail;
1162 INFO_PRINTF1(_L("Test : Video Player - Delete"));
1165 if(!GetStringFromConfig(iSectName,iKeyName,filename))
1166 return EInconclusive;
1170 TRect rect, clipRect;
1171 CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
1172 EMdaPriorityPreferenceTimeAndQuality,
1173 iWs, *iScreen, *iWindow, rect, clipRect);
1174 CleanupStack::PushL(player);
1176 iError = KErrTimedOut;
1177 INFO_PRINTF2(_L("Attempting to open file %S"), &filename);
1178 TRAP(iError,player->OpenFileL(filename));
1180 if(iError == KErrNone)
1182 // Wait for initialisation callback
1183 INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file"));
1184 CActiveScheduler::Start();
1187 if (iError == KErrNone)
1190 CActiveScheduler::Start();
1193 if(iError == KErrNone)
1196 INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
1197 INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying before play complete"));
1198 CleanupStack::Pop(player); // destroy player before play has completed
1200 User::Heap().Check();
1204 CleanupStack::Pop(player);
1205 ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );