mmlibs/mmfw/tsrc/mmfintegrationtest/vclnt/src/TestPlayer.cpp
changeset 24 2672ba96448e
equal deleted inserted replaced
21:1c0a769d0cc5 24:2672ba96448e
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "TestPlayer.h"
       
    17 
       
    18 #include <e32math.h>
       
    19 
       
    20 /**
       
    21  * Constructor
       
    22  */
       
    23 CTestVclntVideoFile::CTestVclntVideoFile(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
       
    24 	:iPlay (aPlay)
       
    25 	{
       
    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;
       
    31 	iKeyName = aKeyName;
       
    32 
       
    33 	// expand heap, so we can load 80k video
       
    34 	iHeapSize = 150000;
       
    35 	}
       
    36 
       
    37 CTestVclntVideoFile* CTestVclntVideoFile::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
       
    38 	{
       
    39 	CTestVclntVideoFile* self = new (ELeave) CTestVclntVideoFile(aTestName,aSectName,aKeyName,aPlay);
       
    40 	return self;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
       
    41 	}
       
    42 
       
    43 CTestVclntVideoFile* CTestVclntVideoFile::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
       
    44 	{
       
    45 	CTestVclntVideoFile* self = CTestVclntVideoFile::NewLC(aTestName,aSectName,aKeyName,aPlay);
       
    46 	CleanupStack::PushL(self);
       
    47 	return self;
       
    48 	}
       
    49 
       
    50 void CTestVclntVideoFile::MvpuoOpenComplete(TInt aError)
       
    51 	{
       
    52 	iError = aError;
       
    53 	INFO_PRINTF1(_L("Open Complete callback"));
       
    54 	CActiveScheduler::Stop();
       
    55 	}
       
    56 
       
    57 void CTestVclntVideoFile::MvpuoPrepareComplete(TInt aError)
       
    58 	{
       
    59 	iError = aError;
       
    60 	INFO_PRINTF1(_L("Open Complete callback"));
       
    61 	CActiveScheduler::Stop();
       
    62 	}
       
    63 
       
    64 void CTestVclntVideoFile::MvpuoFrameReady(CFbsBitmap& /*aFrame*/, TInt aError)
       
    65 	{
       
    66 	iError = aError;
       
    67 	INFO_PRINTF1(_L("Frame Ready callback"));
       
    68 	}
       
    69 
       
    70 void CTestVclntVideoFile::MvpuoPlayComplete(TInt aError)
       
    71 	{
       
    72 	iError = aError;
       
    73 	INFO_PRINTF1(_L("Play Complete callback"));
       
    74 	CActiveScheduler::Stop();
       
    75 	}
       
    76 	
       
    77 void CTestVclntVideoFile::MvpuoEvent(const TMMFEvent& /*aEvent*/)
       
    78 	{
       
    79 	}
       
    80 
       
    81 
       
    82 /**
       
    83  * Load and initialise an audio file.
       
    84  */
       
    85 TVerdict CTestVclntVideoFile::DoTestStepL()
       
    86 	{
       
    87 	TVerdict ret = EFail;
       
    88 	iError = KErrTimedOut;
       
    89 
       
    90 	INFO_PRINTF1(_L("Test : Video Player - File"));
       
    91 
       
    92 	TPtrC filename;
       
    93 	if(!GetStringFromConfig(iSectName,iKeyName,filename))
       
    94 		return EInconclusive;
       
    95 
       
    96 	InitWservL();
       
    97 
       
    98 	TRect rect, clipRect;
       
    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));
       
   104 	
       
   105 	if(iError == KErrNone)
       
   106 		{
       
   107 		// Wait for initialisation callback
       
   108 		INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file"));
       
   109 		CActiveScheduler::Start();
       
   110 		}
       
   111 
       
   112 	// Until JetStream
       
   113 #ifndef JETSTREAM_TESTS
       
   114 	if(iError == KErrNotSupported)
       
   115 		ret = EPass;
       
   116 #endif
       
   117 
       
   118 	// Check for errors.
       
   119 	if (iError == KErrNone && player != NULL)
       
   120 		{
       
   121 		player->Prepare();
       
   122 		CActiveScheduler::Start();
       
   123 		}
       
   124 
       
   125 	// Check for errors.
       
   126 	if (iError == KErrNone && player != NULL)
       
   127 		ret = DoTestL(player);
       
   128 		
       
   129 	INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying"));
       
   130 	CleanupStack::PopAndDestroy(player);
       
   131 	if(iError != KErrNone)
       
   132 		ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );
       
   133 	return	ret;
       
   134 	}
       
   135 
       
   136 TVerdict CTestVclntVideoFile::DoTestL(CVideoPlayerUtility* aPlayer)
       
   137 	{
       
   138 	TVerdict ret = EFail;
       
   139 
       
   140 // #ifdef JETSTREAM_TESTS
       
   141 	if(iPlay)
       
   142 		{
       
   143 		iError = KErrTimedOut;
       
   144 		aPlayer->Play();
       
   145 		INFO_PRINTF1(_L("CVideoPlayerUtility: Playing file"));
       
   146 		// Wait for init callback
       
   147 		CActiveScheduler::Start();
       
   148 		if(iError == KErrNone)
       
   149 			ret = EPass;
       
   150 		}
       
   151 	else
       
   152 		ret = EPass;
       
   153 // #else
       
   154 //	aPlayer->Stop();
       
   155 // #endif
       
   156 
       
   157 	return ret;
       
   158 	}
       
   159 
       
   160 //------------------------------------------------------------------
       
   161 
       
   162 /**
       
   163  * Constructor
       
   164  */
       
   165 CTestVclntVideoDes::CTestVclntVideoDes(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, const TBool aPlay)
       
   166 	:iPlay (aPlay)
       
   167 
       
   168 	{
       
   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;
       
   174 	iKeyName = aKeyName;
       
   175 
       
   176 	// *** Jim : expand heap, so we can load 80k video
       
   177 	iHeapSize = 150000;
       
   178 	}
       
   179 
       
   180 CTestVclntVideoDes* CTestVclntVideoDes::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
       
   181 	{
       
   182 	CTestVclntVideoDes* self = new (ELeave) CTestVclntVideoDes(aTestName,aSectName,aKeyName,aPlay);
       
   183 	return self;
       
   184 	}
       
   185 
       
   186 CTestVclntVideoDes* CTestVclntVideoDes::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
       
   187 	{
       
   188 	CTestVclntVideoDes* self = CTestVclntVideoDes::NewLC(aTestName,aSectName,aKeyName,aPlay);
       
   189 	CleanupStack::PushL(self);
       
   190 	return self;
       
   191 	}
       
   192 
       
   193 void CTestVclntVideoDes::MvpuoOpenComplete(TInt aError)
       
   194 	{
       
   195 	iError = aError;
       
   196 	CActiveScheduler::Stop();
       
   197 	}
       
   198 
       
   199 void CTestVclntVideoDes::MvpuoPrepareComplete(TInt aError)
       
   200 	{
       
   201 	iError = aError;
       
   202 	CActiveScheduler::Stop();
       
   203 	}
       
   204 
       
   205 void CTestVclntVideoDes::MvpuoFrameReady(CFbsBitmap& /*aFrame*/,TInt aError)
       
   206 	{
       
   207 	iError = aError;
       
   208 	// Will this function require a Active Scheduler Stop?
       
   209 	}
       
   210 
       
   211 void CTestVclntVideoDes::MvpuoPlayComplete(TInt aError)
       
   212 	{
       
   213 	iError = aError;
       
   214 	CActiveScheduler::Stop();
       
   215 	}
       
   216 	
       
   217 void CTestVclntVideoDes::MvpuoEvent(const TMMFEvent& /*aEvent*/)
       
   218 	{
       
   219 	}
       
   220 
       
   221 
       
   222 TVerdict  CTestVclntVideoDes::DoTestStepPreambleL()
       
   223 	{
       
   224 	TPtrC filename; 
       
   225 	if(!GetStringFromConfig(iSectName, iKeyName, filename))
       
   226 		return EInconclusive;
       
   227 
       
   228 	RFs fs;
       
   229 	RFile file;
       
   230 	TInt size = 0;
       
   231 
       
   232 	// connect to file system and open file
       
   233 	User::LeaveIfError(fs.Connect());
       
   234 	User::LeaveIfError(file.Open(fs,filename,EFileRead));
       
   235 	CleanupClosePushL(file);
       
   236 
       
   237 	// Set HBuf size
       
   238 	User::LeaveIfError(file.Size(size));
       
   239 	INFO_PRINTF2(_L("size of file = %d\n"),size);//Statement Changed under DEF105143
       
   240 
       
   241 	iVideo = HBufC8::NewMaxL(size);
       
   242 
       
   243 	// read data into Hbuf
       
   244 	TPtr8 bufferDes(iVideo->Des());
       
   245 	User::LeaveIfError(file.Read(bufferDes));
       
   246 	
       
   247 	CleanupStack::PopAndDestroy(); //file
       
   248 	return CTestMmfVclntStep::DoTestStepPreambleL();
       
   249 	}
       
   250 
       
   251 TVerdict CTestVclntVideoDes::DoTestStepPostambleL()
       
   252 	{
       
   253 	delete iVideo;
       
   254 	iVideo = NULL;
       
   255 	return CTestMmfVclntStep::DoTestStepPostambleL();
       
   256 	}
       
   257 
       
   258 /**
       
   259  * Load and initialise an audio descriptor.
       
   260  */
       
   261 TVerdict CTestVclntVideoDes::DoTestStepL()
       
   262 	{
       
   263 	TVerdict ret = EFail;
       
   264 
       
   265 	INFO_PRINTF1(_L("Test : Video Player - Descriptor"));
       
   266 
       
   267 	iError = KErrTimedOut;
       
   268 
       
   269 	InitWservL();
       
   270 
       
   271 	TRect rect, clipRect;
       
   272 	CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
       
   273 															EMdaPriorityPreferenceTimeAndQuality,
       
   274 															iWs, *iScreen, *iWindow, rect, clipRect);
       
   275 	CleanupStack::PushL(player);
       
   276 	
       
   277 
       
   278 	TRAP(iError, player->OpenDesL(iVideo->Des()));
       
   279 	
       
   280 	if(iError == KErrNone)
       
   281 		{
       
   282 		INFO_PRINTF1(_L("CVideoPlayerUtility: Opening descriptor"));
       
   283 		// Wait for init callback
       
   284 		CActiveScheduler::Start();
       
   285 		}
       
   286 
       
   287 	// Until JetStream
       
   288 #ifndef JETSTREAM_TESTS
       
   289 	if(iError == KErrNotSupported)
       
   290 		ret = EPass;
       
   291 #endif
       
   292 
       
   293 	if (iError == KErrNone && player != NULL)
       
   294 		{
       
   295 		player->Prepare();
       
   296 		CActiveScheduler::Start();
       
   297 		}
       
   298 
       
   299 
       
   300 	if ((iError == KErrNone) && (player != NULL))
       
   301 		ret = DoTestL(player);
       
   302 	
       
   303 	INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying"));
       
   304 	CleanupStack::PopAndDestroy(player);
       
   305 	if(iError != KErrNone)
       
   306 		ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );
       
   307 	return	ret;
       
   308 	}
       
   309 
       
   310 TVerdict CTestVclntVideoDes::DoTestL(CVideoPlayerUtility* aPlayer)
       
   311 	{
       
   312 	TVerdict ret = EFail;
       
   313 // #ifdef JETSTREAM_TESTS
       
   314 
       
   315 	if(iPlay)
       
   316 		{
       
   317 		iError = KErrTimedOut;
       
   318 		aPlayer->Play();
       
   319 		INFO_PRINTF1(_L("CVideoPlayerUtility: Playing descriptor"));
       
   320 		// Wait for init callback
       
   321 		CActiveScheduler::Start();
       
   322 		if(iError == KErrNone)
       
   323 			ret = EPass;
       
   324 		}
       
   325 	else
       
   326 		ret = EPass;	
       
   327 //#else
       
   328 //	aPlayer->Stop();
       
   329 //#endif
       
   330 	return ret;		
       
   331 	}
       
   332 
       
   333 
       
   334 //------------------------------------------------------------------
       
   335 
       
   336 /**
       
   337  * Constructor
       
   338  */
       
   339 CTestVclntVideoUrl::CTestVclntVideoUrl(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
       
   340 	:iPlay (aPlay)
       
   341 	{
       
   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;
       
   347 	iKeyName = aKeyName;
       
   348 	}
       
   349 
       
   350 CTestVclntVideoUrl* CTestVclntVideoUrl::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
       
   351 	{
       
   352 	CTestVclntVideoUrl* self = CTestVclntVideoUrl::NewLC(aTestName,aSectName,aKeyName,aPlay);
       
   353 	CleanupStack::Pop();
       
   354 	return self;
       
   355 	}
       
   356 
       
   357 CTestVclntVideoUrl* CTestVclntVideoUrl::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
       
   358 	{
       
   359 	CTestVclntVideoUrl* self = new (ELeave) CTestVclntVideoUrl(aTestName,aSectName,aKeyName,aPlay);
       
   360 	CleanupStack::PushL(self);
       
   361 	return self;
       
   362 	}
       
   363 
       
   364 void CTestVclntVideoUrl::MvpuoOpenComplete(TInt aError)
       
   365 	{
       
   366 	iError = aError;
       
   367 	INFO_PRINTF1(_L("Open complete callback"));
       
   368 	CActiveScheduler::Stop();
       
   369 	}
       
   370 
       
   371 void CTestVclntVideoUrl::MvpuoPrepareComplete(TInt aError)
       
   372 	{
       
   373 	iError = aError;
       
   374 	INFO_PRINTF1(_L("Open complete callback"));
       
   375 	CActiveScheduler::Stop();
       
   376 	}
       
   377 
       
   378 void CTestVclntVideoUrl::MvpuoFrameReady(CFbsBitmap& /*aFrame*/, TInt aError)
       
   379 	{
       
   380 	iError = aError;
       
   381 	// ???
       
   382 	INFO_PRINTF1(_L("Frame Ready callback"));
       
   383 	}
       
   384 
       
   385 void CTestVclntVideoUrl::MvpuoPlayComplete(TInt aError)
       
   386 	{
       
   387 	iError = aError;
       
   388 	INFO_PRINTF1(_L("Play complete callback"));
       
   389 	CActiveScheduler::Stop();
       
   390 	}
       
   391 	
       
   392 void CTestVclntVideoUrl::MvpuoEvent(const TMMFEvent& /*aEvent*/)
       
   393 	{
       
   394 	}
       
   395 
       
   396 
       
   397 /**
       
   398  * Open audio from a URL and play.
       
   399  */
       
   400 TVerdict CTestVclntVideoUrl::DoTestStepL()
       
   401 	{
       
   402 	TVerdict ret = EFail;
       
   403 
       
   404 	INFO_PRINTF1(_L("Test : Video Player - URL"));
       
   405 
       
   406 	iError = KErrTimedOut;	
       
   407 
       
   408 	TPtrC urlname;
       
   409 	if(!GetStringFromConfig(iSectName,iKeyName,urlname))
       
   410 		return EInconclusive;
       
   411 
       
   412 	InitWservL();
       
   413 
       
   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();
       
   423 
       
   424 	// Until JetStream
       
   425 #ifndef JETSTREAM_TESTS
       
   426 	if(iError == KErrNotSupported)
       
   427 		ret = EPass;
       
   428 #endif
       
   429 
       
   430 	if (iError == KErrNone)
       
   431 		{
       
   432 		player->Prepare();
       
   433 		CActiveScheduler::Start();
       
   434 		}
       
   435 
       
   436 	if (iError == KErrNone)
       
   437 		ret = DoTestL(player);
       
   438 
       
   439 	INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying"));
       
   440 	CleanupStack::PopAndDestroy(player);
       
   441 	if(iError != KErrNone)
       
   442 		ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );
       
   443 	return	ret;
       
   444 	}
       
   445 
       
   446 TVerdict CTestVclntVideoUrl::DoTestL(CVideoPlayerUtility* aPlayer)
       
   447 	{
       
   448 	TVerdict ret = EFail;
       
   449 
       
   450 //#ifdef JETSTREAM_TESTS
       
   451 
       
   452 	iError = KErrTimedOut;	
       
   453 
       
   454 	aPlayer->Play();
       
   455 	INFO_PRINTF1(_L("CVideoPlayerUtility: Playing URL"));
       
   456 	// Wait for play to complete
       
   457 	CActiveScheduler::Start();
       
   458 
       
   459 	if(iError == KErrNone)
       
   460 		ret = EPass;
       
   461 //#else
       
   462 //	aPlayer->Stop();
       
   463 //#endif
       
   464 
       
   465 	return ret;
       
   466 	}
       
   467 
       
   468 
       
   469 //------------------------------------------------------------------
       
   470 
       
   471 
       
   472 CTestVclntEnqFrameRate::CTestVclntEnqFrameRate(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aFrameRate)
       
   473 	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
       
   474 	{
       
   475 	iFrameRate = aFrameRate;
       
   476 	}
       
   477 
       
   478 CTestVclntEnqFrameRate* CTestVclntEnqFrameRate::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aFrameRate)
       
   479 	{
       
   480 	CTestVclntEnqFrameRate* self = new (ELeave) CTestVclntEnqFrameRate(aTestName,aSectName,aKeyName,aFrameRate);
       
   481 	return self;
       
   482 	}
       
   483 
       
   484 TVerdict CTestVclntEnqFrameRate::DoTestL(CVideoPlayerUtility* aPlayer)
       
   485 	{
       
   486 	INFO_PRINTF1(_L("Test : Video Player - Enquire Frame Rate"));
       
   487 
       
   488 	TVerdict ret = EFail;
       
   489 
       
   490 	TInt32 theFrameRate;
       
   491 	Math::Int(theFrameRate, aPlayer->VideoFrameRateL());
       
   492 	INFO_PRINTF2(_L("(Frame rate : %d)"), theFrameRate); 
       
   493 
       
   494 	// if we get here, we pass. The player does not have a SetVideoFrameRate()
       
   495 	ret = EPass;
       
   496 
       
   497 	return ret;
       
   498 	}
       
   499 
       
   500 
       
   501 //------------------------------------------------------------------
       
   502 
       
   503 CTestVclntPosition::CTestVclntPosition(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aPosition)
       
   504 	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
       
   505 	{
       
   506 	iPosition = aPosition;
       
   507 	}
       
   508 
       
   509 CTestVclntPosition* CTestVclntPosition::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aPosition)
       
   510 	{
       
   511 	CTestVclntPosition* self = new (ELeave) CTestVclntPosition(aTestName,aSectName,aKeyName,aPosition);
       
   512 	return self;
       
   513 	}
       
   514 
       
   515 TVerdict CTestVclntPosition::DoTestL(CVideoPlayerUtility* aPlayer)
       
   516 	{
       
   517 	// NB test video controller is stubbing certain functions. May have to rewrite this
       
   518 	// for Jet Stream
       
   519 
       
   520 	TVerdict ret = EFail;
       
   521 
       
   522 	INFO_PRINTF1(_L("Test : Video Player - Position"));
       
   523 
       
   524 	TBool validPosition = EFalse;
       
   525 
       
   526 	INFO_PRINTF3(_L("Set Position %d Duration = %d"), 
       
   527 		I64INT(iPosition.Int64()), I64INT(aPlayer->DurationL().Int64()));
       
   528 
       
   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();
       
   535 
       
   536 	// Position is beyond the end of the clips duration
       
   537 	// so check that the value is clipped.
       
   538 	if(aPlayer->DurationL() < iPosition)
       
   539 		{
       
   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;
       
   546 		}
       
   547 	// Position is negative
       
   548 	// so check that the value is clipped.
       
   549 	else if (I64INT(iPosition.Int64()) < 0)
       
   550 		{
       
   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;
       
   556 		}
       
   557 	else
       
   558 		{
       
   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;
       
   565 		}
       
   566 
       
   567 	// Position was set to a valid value.
       
   568 	if(validPosition)
       
   569 		{
       
   570 		aPlayer->Play();
       
   571 		INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
       
   572 		// wait for play to complete
       
   573 		CActiveScheduler::Start();
       
   574 
       
   575 		INFO_PRINTF2(_L("Error : %d"), iError);
       
   576 		if (iError == KErrNone)
       
   577 			ret = EPass;
       
   578 		}
       
   579 	else
       
   580 		{
       
   581 		// We've got an invalid position, attempt to play anyway...
       
   582 		// the test controller should handle it
       
   583 		aPlayer->Play();
       
   584 		INFO_PRINTF1(_L("CVideoPlayerUtility: Playing from invalid position"));
       
   585 		// wait for play to complete
       
   586 		CActiveScheduler::Start();
       
   587 
       
   588 		INFO_PRINTF2(_L("Error : %d"), iError);
       
   589 		if (iError == KErrNone)
       
   590 			ret = EPass;
       
   591 
       
   592 		}
       
   593 
       
   594 	return ret;
       
   595 	}
       
   596 
       
   597 
       
   598 //------------------------------------------------------------------
       
   599 
       
   600 CTestVclntPriority::CTestVclntPriority(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aPriority)
       
   601 	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
       
   602 	{
       
   603 	iPriority = aPriority;
       
   604 	}
       
   605 
       
   606 CTestVclntPriority* CTestVclntPriority::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aPriority)
       
   607 	{
       
   608 	CTestVclntPriority* self = new (ELeave) CTestVclntPriority(aTestName,aSectName,aKeyName,aPriority);
       
   609 	return self;
       
   610 	}
       
   611 
       
   612 TVerdict CTestVclntPriority::DoTestL(CVideoPlayerUtility* aPlayer)
       
   613 	{
       
   614 	TVerdict ret = EFail;
       
   615 
       
   616 	INFO_PRINTF1(_L("Test : Video Player - Priority"));
       
   617 
       
   618 	aPlayer->SetPriorityL(iPriority, EMdaPriorityPreferenceNone);	
       
   619 	TInt thePriority;
       
   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) )
       
   625 		return EPass;
       
   626 	return ret;
       
   627 	}
       
   628 
       
   629 
       
   630 //------------------------------------------------------------------
       
   631 
       
   632 CTestVclntDuration::CTestVclntDuration(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aDuration)
       
   633 	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
       
   634 	{
       
   635 	iDuration = aDuration;
       
   636 	}
       
   637 
       
   638 CTestVclntDuration* CTestVclntDuration::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aDuration)
       
   639 	{
       
   640 	CTestVclntDuration* self = new (ELeave) CTestVclntDuration(aTestName,aSectName,aKeyName,aDuration);
       
   641 	return self;
       
   642 	}
       
   643 
       
   644 TVerdict CTestVclntDuration::DoTestL(CVideoPlayerUtility* aPlayer)
       
   645 	{
       
   646 	TVerdict ret = EFail;
       
   647 
       
   648 	INFO_PRINTF1(_L("Test : Video Player - Duration"));
       
   649 
       
   650 	if (I64INT(iDuration.Int64()) == 0)
       
   651 		{
       
   652 		TInt duration = I64INT(aPlayer->DurationL().Int64());
       
   653 		aPlayer->Play();
       
   654 		INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
       
   655 		TTime start;
       
   656 		start.HomeTime();
       
   657 		CActiveScheduler::Start();
       
   658 		TTime stop;
       
   659 		stop.HomeTime();
       
   660 
       
   661 		TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
       
   662 
       
   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)))
       
   666 			ret = EPass;
       
   667 		}
       
   668 	else
       
   669 		{
       
   670 		if(aPlayer->DurationL() == iDuration)
       
   671 			ret = EPass;
       
   672 		}
       
   673 	return ret;
       
   674 	}
       
   675 
       
   676 //------------------------------------------------------------------
       
   677 
       
   678 CTestVclntVolume::CTestVclntVolume(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aVolume)
       
   679 	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
       
   680 	{
       
   681 	iVolume = aVolume;
       
   682 	}
       
   683 
       
   684 CTestVclntVolume* CTestVclntVolume::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aVolume)
       
   685 	{
       
   686 	CTestVclntVolume* self = new (ELeave) CTestVclntVolume(aTestName,aSectName,aKeyName,aVolume);
       
   687 	return self;
       
   688 	}
       
   689 
       
   690 TVerdict CTestVclntVolume::DoTestL(CVideoPlayerUtility* aPlayer)
       
   691 	{
       
   692 	TVerdict ret = EFail;
       
   693 
       
   694 	// NB : test video controller does not adjust invalid volumes
       
   695 	// comment the checks back in for JS
       
   696 
       
   697 	INFO_PRINTF1(_L("Test : Video Player - Volume"));
       
   698 
       
   699 	INFO_PRINTF1(_L("Warning : test video controller does not adjust invalid volumes"));
       
   700 
       
   701 	// Check maxvolume function
       
   702 	if(iVolume == -1)
       
   703 		{
       
   704 		iVolume = aPlayer->MaxVolume();
       
   705 		INFO_PRINTF3(_L("Volume = %d MaxVolume = %d"), iVolume, KMaxVolume);
       
   706 		//if(iVolume == KMaxVolume) 
       
   707 			ret = EPass;
       
   708 		}
       
   709 	// Volume is truncated to maxvolume
       
   710 	else if(iVolume > aPlayer->MaxVolume())
       
   711 		{
       
   712 		aPlayer->SetVolumeL(iVolume);
       
   713 		INFO_PRINTF3(_L("Volume = %d MaxVolume = %d"), aPlayer->Volume(), aPlayer->MaxVolume());
       
   714 		//if(aPlayer->Volume() == aPlayer->MaxVolume())
       
   715 			ret = EPass;
       
   716 		}
       
   717 	// Volume is truncated to 0
       
   718 	else if(iVolume < 0)
       
   719 		{
       
   720 		aPlayer->SetVolumeL(iVolume);
       
   721 		INFO_PRINTF2(_L("Volume = %d (expecting 0)"), aPlayer->Volume());
       
   722 		//if(aPlayer->Volume() == 0)
       
   723 			ret = EPass;
       
   724 		}
       
   725 	// Set volume and check
       
   726 	else
       
   727 		{
       
   728 		aPlayer->SetVolumeL(iVolume);
       
   729 		INFO_PRINTF3(_L("Volume = %d (expecting %d)"), aPlayer->Volume(), iVolume);
       
   730 		if(aPlayer->Volume() == iVolume)
       
   731 			ret = EPass;
       
   732 		}
       
   733 
       
   734 	return ret;
       
   735 	}
       
   736 
       
   737 //------------------------------------------------------------------
       
   738 
       
   739 CTestVclntCloseOpen::CTestVclntCloseOpen(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
       
   740 	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
       
   741 	{}
       
   742 
       
   743 CTestVclntCloseOpen* CTestVclntCloseOpen::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
       
   744 	{
       
   745 	CTestVclntCloseOpen* self = new (ELeave) CTestVclntCloseOpen(aTestName,aSectName,aKeyName);
       
   746 	return self;
       
   747 	}
       
   748 
       
   749 TVerdict CTestVclntCloseOpen::DoTestL(CVideoPlayerUtility* aPlayer)
       
   750 	{
       
   751 	TVerdict ret = EFail;
       
   752 
       
   753 	INFO_PRINTF1(_L("Test : Video Player - Close/Open"));
       
   754 
       
   755 //#ifdef JETSTREAM_TESTS
       
   756 
       
   757 	TPtrC filename;
       
   758 	if(!GetStringFromConfig(iSectName,iKeyName,filename))
       
   759 		return EInconclusive;
       
   760 
       
   761 	aPlayer->Close();
       
   762 	User::After(KOneSecond);
       
   763 
       
   764 	TRAP(iError,aPlayer->OpenFileL(filename));
       
   765 	if(iError == KErrNone)
       
   766 		{
       
   767 		// Wait for initialisation callback
       
   768 		INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file"));
       
   769 		ret = EPass;
       
   770 		}
       
   771 
       
   772 //#else
       
   773 //	aPlayer->Stop();
       
   774 //#endif
       
   775 
       
   776 	return ret;
       
   777 	}
       
   778 
       
   779 //------------------------------------------------------------------
       
   780 
       
   781 CTestVclntPause::CTestVclntPause(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
       
   782 	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
       
   783 	{}
       
   784 
       
   785 CTestVclntPause* CTestVclntPause::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
       
   786 	{
       
   787 	CTestVclntPause* self = new (ELeave) CTestVclntPause(aTestName,aSectName,aKeyName);
       
   788 	return self;
       
   789 	}
       
   790 
       
   791 TVerdict CTestVclntPause::DoTestL(CVideoPlayerUtility* aPlayer)
       
   792 	{
       
   793 	TVerdict ret = EFail;
       
   794 
       
   795 	INFO_PRINTF1(_L("Test : Video Player - Pause"));
       
   796 
       
   797 	// Tests pause functionality
       
   798 	// NB : not implemented in test controller
       
   799 	INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
       
   800 	aPlayer->Play();
       
   801 	CActiveScheduler::Start();
       
   802 	aPlayer->PauseL();
       
   803 
       
   804 #ifdef JETSTREAM_TESTS
       
   805 	TInt duration = I64INT(aPlayer->DurationL().Int64());
       
   806 
       
   807 	iError = KErrTimedOut;
       
   808 	aPlayer->Play();
       
   809 	INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
       
   810 	TTime start;
       
   811 	start.HomeTime();
       
   812 	CActiveScheduler::Start();
       
   813 	TTime stop;
       
   814 	stop.HomeTime();
       
   815 
       
   816 	TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
       
   817 
       
   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)))
       
   821 		ret = EPass;
       
   822 #else
       
   823 	INFO_PRINTF1(_L("Warning : PauseL() functionality not supported in test controller"));
       
   824 	aPlayer->Stop();
       
   825 	ret = EPass;
       
   826 #endif
       
   827 
       
   828 	return ret;
       
   829 	}
       
   830 
       
   831 //------------------------------------------------------------------
       
   832 
       
   833 CTestVclntBalance::CTestVclntBalance(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aBalance)
       
   834 	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
       
   835 	{
       
   836 	iBalance = aBalance;
       
   837 	}
       
   838 
       
   839 CTestVclntBalance* CTestVclntBalance::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aBalance)
       
   840 	{
       
   841 	CTestVclntBalance* self = new (ELeave) CTestVclntBalance(aTestName,aSectName,aKeyName,aBalance);
       
   842 	return self;
       
   843 	}
       
   844 
       
   845 TVerdict CTestVclntBalance::DoTestL(CVideoPlayerUtility* aPlayer)
       
   846 	{
       
   847 	INFO_PRINTF1(_L("Test : Video Player - Balance"));
       
   848 
       
   849 #ifdef JETSTREAM_TESTS
       
   850 	if (iBalance < KMinBalance)
       
   851 		{
       
   852 		aPlayer->SetBalanceL(iBalance);		
       
   853 		INFO_PRINTF3(_L("Balance = %d (expecting %d)"), aPlayer->Balance(), KMinBalance);
       
   854 		if(aPlayer->Balance() == KMinBalance)
       
   855 			return EPass;
       
   856 		}
       
   857 	else if (iBalance > KMaxBalance)
       
   858 		{
       
   859 		aPlayer->SetBalanceL(iBalance);		
       
   860 		INFO_PRINTF3(_L("Balance = %d (expecting %d)"), aPlayer->Balance(), KMaxBalance);
       
   861 		if(aPlayer->Balance() == KMaxBalance)
       
   862 			return EPass;
       
   863 		}
       
   864 	else
       
   865 		{
       
   866 		aPlayer->SetBalanceL(iBalance);		
       
   867 		INFO_PRINTF3(_L("Balance = %d (expecting %d)"), aPlayer->Balance(), iBalance);
       
   868 		if(aPlayer->Balance() == iBalance)
       
   869 			return EPass;
       
   870 		}
       
   871 #else
       
   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)
       
   878 		return EPass;
       
   879 #endif
       
   880 
       
   881 	return EFail;
       
   882 	}
       
   883 
       
   884 
       
   885 //------------------------------------------------------------------
       
   886 
       
   887 CTestVclntPlayWindow::CTestVclntPlayWindow(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aStart, const TTimeIntervalMicroSeconds aEnd)
       
   888 	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
       
   889 	{
       
   890 	iStart = aStart;
       
   891 	iEnd = aEnd;
       
   892 	}
       
   893 
       
   894 CTestVclntPlayWindow* CTestVclntPlayWindow::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aStart, const TTimeIntervalMicroSeconds aEnd)
       
   895 	{
       
   896 	CTestVclntPlayWindow* self = new (ELeave) CTestVclntPlayWindow(aTestName,aSectName,aKeyName,aStart,aEnd);
       
   897 	return self;
       
   898 	}
       
   899 
       
   900 TVerdict CTestVclntPlayWindow::DoTestL(CVideoPlayerUtility* aPlayer)
       
   901 	{
       
   902 	TVerdict ret = EFail;
       
   903 
       
   904 	INFO_PRINTF1(_L("Test : Video Player - Window"));
       
   905 
       
   906 //	InitWservL();
       
   907 
       
   908 	TRect rect, clipRect;
       
   909 	TRAPD(err, aPlayer->SetDisplayWindowL(iWs, *iScreen, *iWindow, rect, clipRect));
       
   910 	if(err)
       
   911 		{
       
   912 		ERR_PRINTF2(_L("SetDisplayWindowL() failed, error %d"), err);
       
   913 		ret = EFail;
       
   914 		}
       
   915 	else
       
   916 		{
       
   917 		ret = EPass;
       
   918 		}
       
   919 
       
   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...
       
   922 	
       
   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
       
   925 
       
   926 	// NB ws.Connect() will panic on the target, hence don't run it
       
   927 /*
       
   928 #if defined (__WINS__)
       
   929 	TBool testInvalid = EFalse;
       
   930  	RWsSession ws;
       
   931 	if(ws.Connect() != KErrNone)
       
   932 		testInvalid = ETrue;
       
   933 
       
   934 	// we can't call it at all - SetDisplayWindowL() will cause an access violation if ws is null
       
   935 	if(testInvalid)
       
   936 		{
       
   937 		INFO_PRINTF1(_L("Warning : SetDisplayWindowL() cannot be tested, no window server available"));
       
   938 		ret = EPass;
       
   939 		}
       
   940 	else
       
   941 		{
       
   942 		// TBD - arguments to be correctly set
       
   943 		CWsScreenDevice sd;
       
   944 		RBlankWindow window;
       
   945 		TRect rect, clipRect;
       
   946 
       
   947 		TRAPD(err, aPlayer->SetDisplayWindowL(ws, sd, window, rect, clipRect));
       
   948 		if(err)
       
   949 			{
       
   950 				ERR_PRINTF2(_L("SetDisplayWindowL() failed, error %d"), err);
       
   951 				ret = EFail;
       
   952 			}
       
   953 		else
       
   954 			ret = EPass;
       
   955 		
       
   956 		}
       
   957 #else
       
   958 	INFO_PRINTF1(_L("Warning : SetDisplayWindowL() cannot be tested on target"));
       
   959 	ret = EPass;
       
   960 #endif
       
   961 */
       
   962 	aPlayer->Stop();
       
   963 	return ret;
       
   964 	}
       
   965 
       
   966 
       
   967 //------------------------------------------------------------------
       
   968 
       
   969 CTestVclntMeta::CTestVclntMeta(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
       
   970 	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
       
   971 	{}
       
   972 
       
   973 CTestVclntMeta* CTestVclntMeta::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
       
   974 	{
       
   975 	CTestVclntMeta* self = new (ELeave) CTestVclntMeta(aTestName,aSectName,aKeyName);
       
   976 	return self;
       
   977 	}
       
   978 
       
   979 TVerdict CTestVclntMeta::DoTestL(CVideoPlayerUtility* aPlayer)
       
   980 	{
       
   981 	INFO_PRINTF1(_L("Test : Video Player - Metadata"));
       
   982 
       
   983 	TInt numOfMeta = -1;
       
   984 	TRAPD(err, numOfMeta = aPlayer->NumberOfMetaDataEntriesL() );
       
   985 	INFO_PRINTF3(_L("Error : %d Entries = %d"), err, numOfMeta);
       
   986 	if (err != KErrNone || numOfMeta != 0)
       
   987 		return EFail;
       
   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);
       
   993 	if (err != KErrNone)
       
   994 		return EFail;
       
   995 	else 
       
   996 		{
       
   997 		delete theEntry;
       
   998 		return EPass;
       
   999 		}
       
  1000 	}
       
  1001 
       
  1002 
       
  1003 //------------------------------------------------------------------
       
  1004 
       
  1005 CTestVclntFrameSize::CTestVclntFrameSize(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TInt aFrameSize)
       
  1006 	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
       
  1007 	{
       
  1008 	iFrameSize = aFrameSize;
       
  1009 	}
       
  1010 
       
  1011 CTestVclntFrameSize* CTestVclntFrameSize::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TInt aFrameSize)
       
  1012 	{
       
  1013 	CTestVclntFrameSize* self = new (ELeave) CTestVclntFrameSize(aTestName,aSectName,aKeyName,aFrameSize);
       
  1014 	return self;
       
  1015 	}
       
  1016 
       
  1017 TVerdict CTestVclntFrameSize::DoTestL(CVideoPlayerUtility* aPlayer)
       
  1018 	{
       
  1019 	TVerdict ret = EFail;
       
  1020 
       
  1021 	INFO_PRINTF1(_L("Test : Video Player - Frame Size"));
       
  1022 
       
  1023 	TSize	frameSize;
       
  1024 	TRAPD(err, aPlayer->VideoFrameSizeL(frameSize) );
       
  1025 
       
  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 )  
       
  1029 		return EPass;
       
  1030 
       
  1031 	return ret;
       
  1032 	}
       
  1033 
       
  1034 //------------------------------------------------------------------
       
  1035 
       
  1036 CTestVclntMimeType::CTestVclntMimeType(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
       
  1037 	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
       
  1038 	{
       
  1039 	}
       
  1040 
       
  1041 CTestVclntMimeType* CTestVclntMimeType::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
       
  1042 	{
       
  1043 	CTestVclntMimeType* self = new (ELeave) CTestVclntMimeType(aTestName,aSectName,aKeyName);
       
  1044 	return self;
       
  1045 	}
       
  1046 
       
  1047 TVerdict CTestVclntMimeType::DoTestL(CVideoPlayerUtility* aPlayer)
       
  1048 	{
       
  1049 	INFO_PRINTF1(_L("Test : Video Player - MimeType"));
       
  1050 
       
  1051 	// NB we cannot check whether the mime type returned is valid, or even exists.
       
  1052 	TPtrC8 mimeType = aPlayer->VideoFormatMimeType();
       
  1053 
       
  1054 	// take it to a 16-bit string
       
  1055 	TBuf<64> mimeType16;
       
  1056 	mimeType16.Copy(mimeType);
       
  1057 	INFO_PRINTF2(_L("Mime type : \'%S\'"), &mimeType16);
       
  1058 	return EPass;
       
  1059 	}
       
  1060 
       
  1061 //------------------------------------------------------------------
       
  1062 
       
  1063 CTestVclntRebuffering::CTestVclntRebuffering(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
       
  1064 	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
       
  1065 	{
       
  1066 	}
       
  1067 
       
  1068 CTestVclntRebuffering* CTestVclntRebuffering::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
       
  1069 	{
       
  1070 	CTestVclntRebuffering* self = new (ELeave) CTestVclntRebuffering(aTestName,aSectName,aKeyName);
       
  1071 	return self;
       
  1072 	}
       
  1073 
       
  1074 TVerdict CTestVclntRebuffering::DoTestL(CVideoPlayerUtility* aPlayer)
       
  1075 	{
       
  1076 	INFO_PRINTF1(_L("Test : Video Player - Rebuffering"));
       
  1077 
       
  1078 	aPlayer->RegisterForVideoLoadingNotification(*this);
       
  1079 
       
  1080 	INFO_PRINTF1(_L("Rebuffering request completed"));
       
  1081 	return EPass;
       
  1082 	}
       
  1083 
       
  1084 // from MRebufferCallback
       
  1085 void CTestVclntRebuffering::MvloLoadingStarted()
       
  1086 	{
       
  1087 	INFO_PRINTF1(_L("CTestVclntRebuffering::MvloLoadingStarted"));
       
  1088 	}
       
  1089 
       
  1090 void CTestVclntRebuffering::MvloLoadingComplete()
       
  1091 	{
       
  1092 	INFO_PRINTF1(_L("CTestVclntRebuffering::MvloLoadingComplete"));
       
  1093 	}
       
  1094 
       
  1095 //------------------------------------------------------------------
       
  1096 
       
  1097 CTestVclntRepeat::CTestVclntRepeat(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TInt aRepeat)
       
  1098 	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
       
  1099 	{
       
  1100 	iRepeat = aRepeat;
       
  1101 	}
       
  1102 
       
  1103 CTestVclntRepeat* CTestVclntRepeat::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TInt aRepeat)
       
  1104 	{
       
  1105 	CTestVclntRepeat* self = new (ELeave) CTestVclntRepeat(aTestName,aSectName,aKeyName,aRepeat);
       
  1106 	return self;
       
  1107 	}
       
  1108 
       
  1109 TVerdict CTestVclntRepeat::DoTestL(CVideoPlayerUtility* aPlayer)
       
  1110 	{
       
  1111 	TVerdict ret = EFail;
       
  1112 
       
  1113 	INFO_PRINTF1(_L("Test : Video Player - Repeats"));
       
  1114 
       
  1115 	TInt duration = I64INT(aPlayer->DurationL().Int64());
       
  1116 
       
  1117 	// SetRepeats() doesn't exist in the video controller, so set iRepeat to 1
       
  1118 	iRepeat = 1;
       
  1119 	INFO_PRINTF1(_L("Warning : SetRepeats() does not exist in player API. Repeat count set to 1"));
       
  1120 	
       
  1121 	aPlayer->Play();
       
  1122 	INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
       
  1123 	TTime start;
       
  1124 	start.HomeTime();
       
  1125 	CActiveScheduler::Start();
       
  1126 	TTime stop;
       
  1127 	stop.HomeTime();
       
  1128 
       
  1129 	TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
       
  1130 
       
  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)))
       
  1135 		ret = EPass;
       
  1136 
       
  1137 	return ret;
       
  1138 	}
       
  1139 
       
  1140 //------------------------------------------------------------------
       
  1141 
       
  1142 CTestVclntDelete::CTestVclntDelete(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
       
  1143 	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
       
  1144 	{}
       
  1145 
       
  1146 CTestVclntDelete* CTestVclntDelete::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
       
  1147 	{
       
  1148 	CTestVclntDelete* self = new (ELeave) CTestVclntDelete(aTestName,aSectName,aKeyName);
       
  1149 	return self;
       
  1150 	}
       
  1151 
       
  1152 TVerdict CTestVclntDelete::DoTestL(CVideoPlayerUtility* /* aPlayer */)
       
  1153 	{
       
  1154 	// this is never called
       
  1155 	return EFail;
       
  1156 	}
       
  1157 
       
  1158 TVerdict CTestVclntDelete::DoTestStepL()
       
  1159 	{
       
  1160 	TVerdict ret = EFail;
       
  1161 
       
  1162 	INFO_PRINTF1(_L("Test : Video Player - Delete"));
       
  1163 
       
  1164 	TPtrC filename;
       
  1165 	if(!GetStringFromConfig(iSectName,iKeyName,filename))
       
  1166 		return EInconclusive;
       
  1167 
       
  1168 	InitWservL();
       
  1169 
       
  1170 	TRect rect, clipRect;
       
  1171 	CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
       
  1172 															EMdaPriorityPreferenceTimeAndQuality,
       
  1173 															iWs, *iScreen, *iWindow, rect, clipRect);
       
  1174 	CleanupStack::PushL(player);
       
  1175 
       
  1176 	iError = KErrTimedOut;
       
  1177 	INFO_PRINTF2(_L("Attempting to open file %S"), &filename);
       
  1178 	TRAP(iError,player->OpenFileL(filename));
       
  1179 	
       
  1180 	if(iError == KErrNone)
       
  1181 		{
       
  1182 		// Wait for initialisation callback
       
  1183 		INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file"));
       
  1184 		CActiveScheduler::Start();
       
  1185 		}
       
  1186 
       
  1187 	if (iError == KErrNone)
       
  1188 		{
       
  1189 		player->Prepare();
       
  1190 		CActiveScheduler::Start();
       
  1191 		}
       
  1192 
       
  1193 	if(iError == KErrNone)
       
  1194 		{
       
  1195 		player->Play();
       
  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
       
  1199 
       
  1200 		User::Heap().Check();
       
  1201 		return EPass;
       
  1202 		}
       
  1203 
       
  1204 	CleanupStack::Pop(player);
       
  1205 	ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );
       
  1206 	return ret;
       
  1207 	}
       
  1208