os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclntavi/src/testvideoplayer2.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2007-2010 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 <e32math.h>
    17 #include "testvideoplayer2.h"
    18 
    19 #ifdef SYMBIAN_BUILD_GCE
    20 #include <graphics/surfacemanager.h>
    21 #endif
    22 
    23 const TInt KSettingsAndAlignmentTest = 3;
    24 
    25 //
    26 // RTestVclntPlayAviFile
    27 //
    28 
    29 /**
    30  * RTestVclnt2PlayFile::Constructor
    31  */
    32 RTestVclnt2PlayFile::RTestVclnt2PlayFile(const TDesC& aTestName, 
    33                                          const TDesC& aSectName, 
    34                                          const TDesC& aKeyName, 
    35                                          TInt aExpectedError)
    36     : RTestVclnt2AviPlayerStep(aTestName, aSectName, aKeyName, aExpectedError)
    37     {
    38     }
    39 
    40 /**
    41  * RTestVclnt2PlayFile::NewL
    42  */
    43 RTestVclnt2PlayFile* RTestVclnt2PlayFile::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
    44     {
    45     RTestVclnt2PlayFile* self = new (ELeave) RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError);
    46     return self;
    47     }
    48 
    49 /**
    50  * RTestVclnt2PlayFile::DoTestStepPreambleL
    51  */
    52 TVerdict RTestVclnt2PlayFile::DoTestStepPreambleL()
    53     {
    54     return RTestVclnt2AviPlayerStep::DoTestStepPreambleL();
    55     }
    56 
    57 /**
    58  * RTestVclnt2PlayFile::DoTestStepPostambleL
    59  */
    60 TVerdict RTestVclnt2PlayFile::DoTestStepPostambleL()
    61     {
    62     return RTestVclnt2AviPlayerStep::DoTestStepPostambleL();        
    63     }
    64 
    65 /**
    66  * RTestVclnt2PlayFile::FsmL
    67  */
    68 void RTestVclnt2PlayFile::FsmL(TVclntTestPlayEvents aEventCode)
    69     {
    70     if (FsmCheck(aEventCode))
    71         {
    72         switch (aEventCode)
    73             {
    74             case EVPIdle:
    75                 HandleIdleL();
    76                 break;
    77                 
    78             case EVPOpenComplete:
    79                 HandleOpenCompleteL();
    80                 break;
    81                 
    82             case EVPPrepareComplete:                    
    83                 HandlePrepareCompleteL();
    84                 break;
    85                 
    86             case EVPPlayComplete:
    87                 HandlePlayCompleteL();
    88                 break;
    89             }
    90         }
    91     }
    92     
    93 void RTestVclnt2PlayFile::HandleIdleL()
    94 	{
    95 	// Open iVideoPlayer
    96     INFO_PRINTF2(_L("iVideoPlayer2->OpenFileL() %S"), &iFilename);
    97     iVideoPlayer2->OpenFileL(iFilename, KMmfTestAviPlayControllerUid);
    98     PrepareState(EVPOpenComplete, KErrNone);
    99 	}
   100 
   101 void RTestVclnt2PlayFile::HandleOpenCompleteL()
   102 	{
   103 	// Prepare iVideoPlayer2
   104     INFO_PRINTF1(_L("iVideoPlayer2->Prepare()"));
   105     iVideoPlayer2->Prepare();
   106     PrepareState(EVPPrepareComplete, KErrNone);
   107 	}
   108 	
   109 void RTestVclnt2PlayFile::HandlePrepareCompleteL()
   110 	{
   111 	// Add display window using default values - ie. video extent & window clipping 
   112 	// defaulted to whole window
   113 	INFO_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL()"));
   114 	iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);
   115 
   116     // trigger the video to start playing                
   117     StartPlayback();
   118 	}
   119 
   120 void RTestVclnt2PlayFile::HandlePlayCompleteL()
   121 	{
   122 	iTestStepResult = EPass;
   123 	CActiveScheduler::Stop();
   124 	}
   125 
   126 void RTestVclnt2PlayFile::StartPlayback()
   127 	{
   128     iError = KErrTimedOut;
   129     INFO_PRINTF1(_L("iVideoPlayer2->Play()"));
   130     PrepareState(EVPPlayComplete, KErrNone);
   131     iVideoPlayer2->Play();
   132 	}
   133 	
   134 #ifdef SYMBIAN_BUILD_GCE
   135 //
   136 // RTestMediaClientVideoDisplay
   137 //
   138 
   139 /**
   140  * RTestMediaClientVideoDisplay::Constructor
   141  */
   142 
   143 
   144 RTestMediaClientVideoDisplay::RTestMediaClientVideoDisplay(const TDesC& aTestName, 
   145                                          const TDesC& aSectName, 
   146                                          const TDesC& aKeyName, 
   147                                          TInt aExpectedError)
   148     : RTestVclnt2AviPlayerStep(aTestName, aSectName, aKeyName, aExpectedError)
   149     {
   150     }
   151 
   152 /**
   153  * RTestMediaClientVideoDisplay::NewL
   154  */
   155 
   156 RTestMediaClientVideoDisplay* RTestMediaClientVideoDisplay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   157     {
   158     RTestMediaClientVideoDisplay* self = new (ELeave) RTestMediaClientVideoDisplay(aTestName, aSectName, aKeyName, aExpectedError);
   159     return self;
   160     }
   161 
   162 /**
   163  * RTestMediaClientVideoDisplay::DoTestStepPreambleL
   164  */
   165  
   166 TVerdict RTestMediaClientVideoDisplay::DoTestStepPreambleL()
   167     {
   168     return RTestVclnt2AviPlayerStep::DoTestStepPreambleL();
   169     }
   170 
   171 /**
   172  * RTestMediaClientVideoDisplay::DoTestStepPostambleL
   173  */
   174  
   175 TVerdict RTestMediaClientVideoDisplay::DoTestStepPostambleL()
   176     {
   177     return RTestVclnt2AviPlayerStep::DoTestStepPostambleL();        
   178     }
   179 
   180 /**
   181  * RTestMediaClientVideoDisplay::FsmL
   182  */
   183 void RTestMediaClientVideoDisplay::FsmL(TVclntTestPlayEvents aEventCode)
   184     {
   185     if (FsmCheck(aEventCode))
   186         {
   187         switch (aEventCode)
   188             {
   189             case EVPIdle:
   190                 HandleIdleL();
   191                 break;
   192                 
   193             case EVPOpenComplete:
   194                 HandleOpenCompleteL();
   195                 break;
   196                 
   197             case EVPPrepareComplete:                    
   198                 HandlePrepareCompleteL();
   199                 break;
   200                 
   201             case EVPPlayComplete:
   202                 HandlePlayCompleteL();
   203                 break;
   204             }
   205         }
   206     }
   207     
   208 void RTestMediaClientVideoDisplay::HandleIdleL()
   209 	{
   210 	// Open iVideoPlayer
   211     INFO_PRINTF2(_L("iVideoPlayer2->OpenFileL() %S"), &iFilename);
   212     iVideoPlayer2->OpenFileL(iFilename, KMmfTestAviPlayControllerUid);
   213     PrepareState(EVPOpenComplete, KErrNone);
   214 	}
   215 
   216 void RTestMediaClientVideoDisplay::HandleOpenCompleteL()
   217 	{
   218 	// Prepare iVideoPlayer2
   219     INFO_PRINTF1(_L("iVideoPlayer2->Prepare()"));
   220     iVideoPlayer2->Prepare();
   221     PrepareState(EVPPrepareComplete, KErrNone);
   222 	}
   223 	
   224 void RTestMediaClientVideoDisplay::HandlePrepareCompleteL()
   225 	{
   226 	// trigger the video to start playing  
   227 	StartPlayback();
   228 	
   229 	TInt displayId = iScreen->GetScreenNumber();
   230 	TRect clipRect = TRect(iWindow->Size());
   231 	TRect cropRegion = clipRect;
   232 	
   233 	// ==========================
   234 	
   235     iMediaClientVideoDisplay = CMediaClientVideoDisplay::NewL(displayId);
   236     
   237  	RSurfaceManager surfaceManager;
   238  	User::LeaveIfError(surfaceManager.Open());
   239 	
   240 	RSurfaceManager::TSurfaceCreationAttributesBuf bf;
   241 	RSurfaceManager::TSurfaceCreationAttributes& b=bf();
   242 	b.iSize.iWidth = 320;
   243 	b.iSize.iHeight = 240;
   244 	b.iBuffers = 1;
   245 	b.iPixelFormat = EUidPixelFormatXRGB_8888;	
   246 	b.iStride = 320 * 4;
   247 	b.iOffsetToFirstBuffer = 0;
   248 	b.iAlignment=4;
   249 	b.iContiguous=ETrue;
   250 	
   251 	TRect cropRect(0, 0, 320, 240);
   252 	TVideoAspectRatio par(1,2);
   253 	TSurfaceId surfaceId;
   254 	
   255 	User::LeaveIfError(surfaceManager.CreateSurface(bf, surfaceId));
   256  	
   257     iMediaClientVideoDisplay->SurfaceCreated(surfaceId, cropRect, par, cropRegion);
   258     INFO_PRINTF1(_L("iMediaClientVideoDisplay->SurfaceCreated()"));
   259     
   260     delete iMediaClientVideoDisplay;
   261     iMediaClientVideoDisplay = NULL;
   262     
   263     // ==================
   264     
   265     iMediaClientVideoDisplay = CMediaClientVideoDisplay::NewL(displayId);
   266     
   267 	TRect videoExtent = clipRect;
   268 	TReal32 scaleWidth(100.0f);
   269 	TReal32 scaleHeight(100.0f);
   270 	TInt horizPos(EHorizontalAlignCenter);
   271 	TInt vertPos(EVerticalAlignCenter);	
   272 	
   273 	TReal32 widthPercentage(50.0f); 
   274 	TReal32 heightPercentage(50.0f);
   275 	TReal32 widthP; 
   276 	TReal32 heightP;
   277 	RWindow newWindow;
   278 	
   279 	// Check for invalid rotation when adding new window
   280 	INFO_PRINTF1(_L("Testing invalid rotations for AddDisplayWindowL"));
   281 	TInt err = KErrNone;
   282 	TVideoRotation rotation = static_cast<TVideoRotation>(-1);
   283 	TRAP(err, iMediaClientVideoDisplay->AddDisplayWindowL(iWindow, clipRect, cropRegion, videoExtent, scaleWidth, scaleHeight, rotation, EAutoScaleBestFit, horizPos, vertPos, iWindow));
   284 	if (err != KErrArgument)
   285 		{
   286 		ERR_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() did not leave with KErrArgument for negative rotation"));
   287     	iTestStepResult = EFail;
   288     	CActiveScheduler::Stop();
   289     	return;
   290 		}
   291 
   292 	rotation = static_cast<TVideoRotation>(4);
   293 	TRAP(err, iMediaClientVideoDisplay->AddDisplayWindowL(iWindow, clipRect, cropRegion, videoExtent, scaleWidth, scaleHeight, rotation, EAutoScaleBestFit, horizPos, vertPos, iWindow));
   294 	if (err != KErrArgument)
   295 		{
   296 		ERR_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() did not leave with KErrArgument for out of range rotation"));
   297     	iTestStepResult = EFail;
   298     	CActiveScheduler::Stop();
   299     	return;
   300 		}
   301 
   302 	rotation = EVideoRotationNone;
   303 
   304 	// Check for invalid autoScaleType when adding new window
   305 	INFO_PRINTF1(_L("Testing invalid autoScaleType for AddDisplayWindowL"));
   306 	TAutoScaleType autoScaleType = static_cast<TAutoScaleType>(-1);
   307 	TRAP(err, iMediaClientVideoDisplay->AddDisplayWindowL(iWindow, clipRect, cropRegion, videoExtent, scaleWidth, scaleHeight, rotation, autoScaleType, horizPos, vertPos, iWindow));
   308 	if (err != KErrArgument)
   309 		{
   310 		ERR_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() did not leave with KErrArgument for negative scale"));
   311     	iTestStepResult = EFail;
   312     	CActiveScheduler::Stop();
   313     	return;
   314 		}
   315 
   316 	autoScaleType = static_cast<TAutoScaleType>(4);
   317 	TRAP(err, iMediaClientVideoDisplay->AddDisplayWindowL(iWindow, clipRect, cropRegion, videoExtent, scaleWidth, scaleHeight, rotation, autoScaleType, horizPos, vertPos, iWindow));
   318 	if (err != KErrArgument)
   319 		{
   320 		ERR_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() did not leave with KErrArgument for out of range scale"));
   321     	iTestStepResult = EFail;
   322     	CActiveScheduler::Stop();
   323     	return;
   324 		}
   325 	
   326 	iMediaClientVideoDisplay->AddDisplayWindowL(iWindow, clipRect, cropRegion, videoExtent, scaleWidth, scaleHeight, rotation, EAutoScaleBestFit, horizPos, vertPos, iWindow);
   327 	INFO_PRINTF1(_L("iMediaClientVideoDisplay->AddDisplayWindowL()"));   
   328 
   329 	// Check for invalid rotation when setting rotation for window
   330 	INFO_PRINTF1(_L("Testing invalid rotation for SetRotationL"));
   331 	TVideoRotation videoRotation = static_cast<TVideoRotation>(-1);
   332 	TRAP(err, iMediaClientVideoDisplay->SetRotationL(*iWindow, videoRotation, cropRegion));
   333 	if (err != KErrArgument)
   334 		{
   335 		ERR_PRINTF1(_L("iVideoPlayer2->SetRotationL(window) did not leave with KErrArgument for negative value"));
   336     	iTestStepResult = EFail;
   337     	CActiveScheduler::Stop();
   338     	return;
   339 		}
   340 
   341 	videoRotation = static_cast<TVideoRotation>(4);
   342 	TRAP(err, iMediaClientVideoDisplay->SetRotationL(*iWindow, videoRotation, cropRegion));
   343 	if (err != KErrArgument)
   344 		{
   345 		ERR_PRINTF1(_L("iVideoPlayer2->SetRotationL(window) did not leave with KErrArgument for out of range value"));
   346     	iTestStepResult = EFail;
   347     	CActiveScheduler::Stop();
   348     	return;
   349 		}
   350 
   351 	// Check for invalid rotation when setting rotation for all windows
   352 	videoRotation = static_cast<TVideoRotation>(-1);
   353 	TRAP(err, iMediaClientVideoDisplay->SetRotationL(videoRotation, cropRegion));
   354 	if (err != KErrArgument)
   355 		{
   356 		ERR_PRINTF1(_L("iVideoPlayer2->SetRotationL() did not leave with KErrArgument for negative value"));
   357     	iTestStepResult = EFail;
   358     	CActiveScheduler::Stop();
   359     	return;
   360 		}
   361 
   362 	videoRotation = static_cast<TVideoRotation>(4);
   363 	TRAP(err, iMediaClientVideoDisplay->SetRotationL(videoRotation, cropRegion));
   364 	if (err != KErrArgument)
   365 		{
   366 		ERR_PRINTF1(_L("iVideoPlayer2->SetRotationL() did not leave with KErrArgument for out of range value"));
   367     	iTestStepResult = EFail;
   368     	CActiveScheduler::Stop();
   369     	return;
   370 		}
   371 
   372 	videoRotation = EVideoRotationClockwise180;
   373 
   374     iMediaClientVideoDisplay->SetRotationL(*iWindow, videoRotation, cropRegion);
   375     INFO_PRINTF1(_L("iMediaClientVideoDisplay->SetRotationL()"));
   376     
   377     if (iMediaClientVideoDisplay->RotationL(*iWindow) != videoRotation)
   378         {
   379         ERR_PRINTF1(_L("iMediaClientVideoDisplay->RotationL() returns an unexpected value.  Test aborted."));
   380 
   381 		iTestStepResult = EInconclusive;
   382 		CActiveScheduler::Stop();
   383         }
   384 	else
   385 		{
   386 		INFO_PRINTF1(_L("iMediaClientVideoDisplay->RotationL()"));	
   387 		}
   388     
   389     iMediaClientVideoDisplay->SetScaleFactorL(*iWindow, widthPercentage, heightPercentage, cropRegion);
   390     iMediaClientVideoDisplay->SetScaleFactorL(widthPercentage, heightPercentage, cropRegion);
   391     INFO_PRINTF1(_L("iMediaClientVideoDisplay->SetScaleFactorL()"));
   392     
   393     iMediaClientVideoDisplay->SetRotationL(EVideoRotationClockwise90, cropRegion);
   394     INFO_PRINTF1(_L("iMediaClientVideoDisplay->SetRotationL()"));
   395     
   396     iMediaClientVideoDisplay->GetScaleFactorL(*iWindow, widthP, heightP);
   397     INFO_PRINTF3(_L("iMediaClientVideoDisplay->GetScaleFactorL() %df %df"), &widthP, &heightP);
   398 
   399     iMediaClientVideoDisplay->SetVideoExtentL(*iWindow, videoExtent, cropRegion);
   400     INFO_PRINTF1(_L("iMediaClientVideoDisplay->SetVideoExtentL()"));
   401     
   402     iMediaClientVideoDisplay->SetWindowClipRectL(*iWindow, clipRect, cropRegion);
   403     INFO_PRINTF1(_L("iMediaClientVideoDisplay->SetWindowClipRectL()"));
   404 
   405 	// Check for invalid autoScaleType when setting autoScaleType for window
   406 	INFO_PRINTF1(_L("Testing invalid autoScaleType for SetAutoScaleL"));
   407 	autoScaleType = static_cast<TAutoScaleType>(-1);
   408 	TRAP(err, iMediaClientVideoDisplay->SetAutoScaleL(*iWindow, autoScaleType, horizPos, vertPos, cropRegion));
   409 	if (err != KErrArgument)
   410 		{
   411 		ERR_PRINTF1(_L("iVideoPlayer2->SetAutoScaleL(window) did not leave with KErrArgument for negative value"));
   412     	iTestStepResult = EFail;
   413     	CActiveScheduler::Stop();
   414     	return;
   415 		}
   416 
   417 	autoScaleType = static_cast<TAutoScaleType>(4);
   418 	TRAP(err, iMediaClientVideoDisplay->SetAutoScaleL(*iWindow, autoScaleType, horizPos, vertPos, cropRegion));
   419 	if (err != KErrArgument)
   420 		{
   421 		ERR_PRINTF1(_L("iVideoPlayer2->SetAutoScaleL(window) did not leave with KErrArgument for out of range value"));
   422     	iTestStepResult = EFail;
   423     	CActiveScheduler::Stop();
   424     	return;
   425 		}
   426 
   427 	// Check for invalid autoScaleType when setting autoScaleType for all windows
   428 	autoScaleType = static_cast<TAutoScaleType>(-1);
   429 	TRAP(err, iMediaClientVideoDisplay->SetAutoScaleL(autoScaleType, horizPos, vertPos, cropRegion));
   430 	if (err != KErrArgument)
   431 		{
   432 		ERR_PRINTF1(_L("iVideoPlayer2->SetAutoScaleL() did not leave with KErrArgument for negative value"));
   433     	iTestStepResult = EFail;
   434     	CActiveScheduler::Stop();
   435     	return;
   436 		}
   437 
   438 	autoScaleType = static_cast<TAutoScaleType>(4);
   439 	TRAP(err, iMediaClientVideoDisplay->SetAutoScaleL(autoScaleType, horizPos, vertPos, cropRegion));
   440 	if (err != KErrArgument)
   441 		{
   442 		ERR_PRINTF1(_L("iVideoPlayer2->SetAutoScaleL() did not leave with KErrArgument for out of range value"));
   443     	iTestStepResult = EFail;
   444     	CActiveScheduler::Stop();
   445     	return;
   446 		}
   447     
   448     iMediaClientVideoDisplay->SetAutoScaleL(EAutoScaleBestFit, horizPos, vertPos, cropRegion);
   449     INFO_PRINTF1(_L("iMediaClientVideoDisplay->SetAutoScaleL()"));
   450     
   451     iMediaClientVideoDisplay->RedrawWindows(cropRegion);
   452     INFO_PRINTF1(_L("iMediaClientVideoDisplay->RedrawWindows()"));   
   453     
   454 	iMediaClientVideoDisplay->SurfaceParametersChanged(surfaceId, cropRect, par);
   455 	INFO_PRINTF1(_L("iMediaClientVideoDisplay->SurfaceParametersChanged()"));
   456 	
   457 	iMediaClientVideoDisplay->RemoveSurface();
   458     INFO_PRINTF1(_L("iMediaClientVideoDisplay->ReplaceSurface()"));
   459     
   460     iMediaClientVideoDisplay->RemoveDisplayWindow(*iWindow);
   461     INFO_PRINTF1(_L("iMediaClientVideoDisplay->RemoveDisplayWindow()"));
   462     
   463     surfaceManager.CloseSurface(surfaceId);
   464 	surfaceId = TSurfaceId::CreateNullId();
   465 	surfaceManager.Close();
   466     
   467     delete iMediaClientVideoDisplay;  
   468     iMediaClientVideoDisplay = NULL;              
   469    	}
   470 
   471 void RTestMediaClientVideoDisplay::HandlePlayCompleteL()
   472 	{
   473 	iTestStepResult = EPass;
   474 	CActiveScheduler::Stop();
   475 	}
   476 
   477 void RTestMediaClientVideoDisplay::StartPlayback()
   478 	{
   479     iError = KErrTimedOut;
   480     INFO_PRINTF1(_L("iVideoPlayer2->Play()"));
   481     PrepareState(EVPPlayComplete, KErrNone);
   482     iVideoPlayer2->Play();
   483 	}
   484 	
   485 #endif
   486 
   487 //
   488 // RTestVclnt2PerformActionDuringVideoPlayback
   489 //
   490 
   491 /**
   492  * RTestVclnt2PerformActionDuringVideoPlayback::Constructor
   493  */
   494 RTestVclnt2PerformActionDuringVideoPlayback::RTestVclnt2PerformActionDuringVideoPlayback(
   495     const TDesC& aTestName, 
   496     const TDesC& aSectName, 
   497     const TDesC& aKeyName, 
   498     TInt aExpectedError)
   499     : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
   500     {
   501     }
   502 
   503 /**
   504  * RTestVclnt2PerformActionDuringVideoPlayback::HandlePlayCompleteL
   505  */
   506 void RTestVclnt2PerformActionDuringVideoPlayback::HandlePlayCompleteL()
   507     {
   508     if (iActionError != KErrNone)
   509         {
   510         ERR_PRINTF2(_L("Playback event left with error %d."), iActionError);
   511         iTestStepResult = EFail;
   512         }
   513     else 
   514         {
   515         iTestStepResult = EPass;
   516         }
   517 
   518 	CActiveScheduler::Stop();        
   519     }
   520 
   521 /**
   522  * RTestVclnt2PerformActionDuringVideoPlayback::StartPlayback
   523  */     
   524 void RTestVclnt2PerformActionDuringVideoPlayback::StartPlayback()
   525 	{
   526 	RTestVclnt2PlayFile::StartPlayback();
   527 	
   528 	iActionError = KErrNone;
   529     TRAP(iActionError, DoThisActionDuringPlaybackL(*iVideoPlayer2));
   530 	}
   531 
   532 
   533 //
   534 // RTestVclnt2AddWin
   535 //
   536 /**
   537  * RTestVclnt2AddWin::Constructor
   538  */
   539 RTestVclnt2AddWin::RTestVclnt2AddWin(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
   540     : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
   541     {
   542     }
   543 
   544 /**
   545  * RTestVclnt2AddWin::NewL
   546  */
   547 RTestVclnt2AddWin* RTestVclnt2AddWin::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
   548     {
   549     RTestVclnt2AddWin* self = new (ELeave) RTestVclnt2AddWin(aTestName, aSectName, aKeyName, aExpectedError);
   550     return self;
   551     }
   552    
   553 /**
   554  * RTestVclnt2AddWin::HandlePrepareCompleteL
   555  */
   556 void RTestVclnt2AddWin::HandlePrepareCompleteL()
   557     {
   558     // retrieve video size
   559     TSize videoSize;
   560     iVideoPlayer2->VideoFrameSizeL(videoSize);                
   561 
   562     if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0505")) == 0)
   563         {
   564         // create a clipping rect partially out of screen
   565         TRect windowRect(iWindow->Size());
   566         windowRect.SetWidth(windowRect.Width() * 2);
   567         
   568         // Add the display window with a partially out of screen clipping rect
   569         TRAPD(err, iVideoPlayer2->AddDisplayWindowL(iWs, 
   570                                                     *iScreen, 
   571                                                     *iWindow, 
   572                                                     TRect(iWindow->Size()), 
   573                                                     windowRect));
   574         if (err != iTestExpectedError)
   575             {
   576             ERR_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() leaves with an unexpected error.  Test failed."));
   577 
   578     		iTestStepResult = EFail;
   579     		CActiveScheduler::Stop();
   580 
   581     		return;
   582             }
   583 
   584         // create a clipping rect completely out of screen
   585         windowRect.SetRect(TPoint(0, 0), iWindow->Size());
   586         windowRect.Move(windowRect.Width() + 10, 0);
   587         
   588         // Add the display window with a completely out of screen clipping rect
   589         TRAP(err, iVideoPlayer2->AddDisplayWindowL(iWs, 
   590                                                    *iScreen, 
   591                                                    *iWindow, 
   592                                                    TRect(iWindow->Size()), 
   593                                                    windowRect));
   594         if (err != iTestExpectedError)
   595             {
   596             ERR_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() leaves with an unexpected error.  Test failed."));
   597             
   598     		iTestStepResult = EFail;
   599     		CActiveScheduler::Stop();
   600 
   601     		return;
   602             }
   603         else 
   604             {
   605             // Reset the expected error to KErrNone as all expected failure tests have been completed.  
   606             // Any error that appears after this should fail the test
   607             iTestExpectedError = KErrNone;
   608             }
   609 
   610         // after failing to add window display with a partially & a completely out of screen
   611         // clipping rect, proceed to add a valid clipping rect below            
   612         }    
   613     
   614     if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0401")) == 0 ||
   615         iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0505")) == 0) 
   616         {
   617         // shrink both the video & window size by half
   618         TRect videoRect(videoSize);     
   619         videoRect.SetHeight(videoSize.iHeight / 2);
   620         videoRect.SetWidth(videoSize.iWidth / 2); 
   621         
   622         TRect windowRect(iWindow->Size());
   623         windowRect.SetHeight(iWindow->Size().iHeight / 2);
   624         windowRect.SetWidth(iWindow->Size().iWidth / 2); 
   625 
   626         // ensure the rect is within the boundary of the window        
   627         TRect finalRect(windowRect);
   628         finalRect.Intersection(videoRect);
   629 
   630         // add display window using this valid clipping rect 
   631         iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, finalRect, finalRect);
   632         }
   633     else
   634         {
   635         // Invalid test case
   636         User::Panic(_L("RTestVclnt2AddWin"), KErrArgument);        
   637         }
   638 
   639     // Start video playback
   640     StartPlayback();
   641     }
   642 
   643 
   644 //
   645 // RTestVclnt2RemoveWin
   646 //
   647 
   648 /**
   649  * RTestVclnt2RemoveWin::Constructor
   650  */ 
   651 RTestVclnt2RemoveWin::RTestVclnt2RemoveWin(const TDesC& aTestName, 
   652                                            const TDesC& aSectName,
   653                                            const TDesC& aKeyName, 
   654                                            TInt aExpectedError,
   655                                            TBool aAddBack)
   656     : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError),
   657       iAddBack(aAddBack)
   658     {
   659     }
   660 
   661 /**
   662  * RTestVclnt2RemoveWin::NewL
   663  */
   664 RTestVclnt2RemoveWin* RTestVclnt2RemoveWin::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, TBool aAddBack)
   665     {
   666     RTestVclnt2RemoveWin* self = new (ELeave) RTestVclnt2RemoveWin(aTestName, aSectName, aKeyName, aExpectedError, aAddBack);
   667     return self;
   668     }
   669 
   670 /**
   671  * RTestVclnt2RemoveWin::HandlePrepareCompleteL
   672  */
   673 void RTestVclnt2RemoveWin::HandlePrepareCompleteL()
   674     {
   675     // retrieve video size
   676     TSize videoSize;
   677     iVideoPlayer2->VideoFrameSizeL(videoSize);
   678 
   679     // shrink both the video & window size by half
   680     TRect videoRect(videoSize);     
   681     videoRect.SetHeight(videoSize.iHeight / 2);
   682     videoRect.SetWidth(videoSize.iWidth / 2); 
   683 
   684     TRect windowRect(iWindow->Size());
   685     windowRect.SetHeight(iWindow->Size().iHeight / 2);
   686     windowRect.SetWidth(iWindow->Size().iWidth / 2); 
   687 
   688     // ensure the rect is within the boundary of the window        
   689     TRect finalRect(windowRect);
   690     finalRect.Intersection(videoRect);
   691 
   692     // add display window using this valid clipping rect 
   693     iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, finalRect, finalRect);
   694 
   695     // trigger the video to start playing
   696     StartPlayback();    
   697     }
   698 
   699 /**
   700  * RTestVclnt2RemoveWin::DoThisActionDuringPlaybackL
   701  */ 
   702 void RTestVclnt2RemoveWin::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& aPlayer)
   703     {
   704     // Play the video clip using a specific display window & video clipping setting 
   705     // first
   706     TTimeIntervalMicroSeconds duration = aPlayer.DurationL();        
   707 
   708     // After a quarter of the clip's duration
   709     User::After(duration.Int64() / 4);
   710 
   711     // remove the original display        
   712     aPlayer.RemoveDisplayWindow(*iWindow);
   713 
   714 
   715     if (iAddBack)
   716     	{
   717 	    // Add the window using default values to continues
   718 	    aPlayer.AddDisplayWindowL(iWs, *iScreen, *iWindow);
   719     	}
   720     }
   721 
   722 
   723 //
   724 // RTestVclnt2WinPos
   725 //
   726 
   727 /**
   728  * RTestVclnt2WinPos::Constructor
   729  */
   730 RTestVclnt2WinPos::RTestVclnt2WinPos(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
   731     : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError)
   732     {
   733     }
   734 
   735 /**
   736  * RTestVclnt2WinPos::NewL
   737  */
   738 RTestVclnt2WinPos* RTestVclnt2WinPos::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
   739     {
   740     RTestVclnt2WinPos* self = new (ELeave) RTestVclnt2WinPos(aTestName, aSectName, aKeyName, aExpectedError);
   741     return self;
   742     }
   743 
   744 /**
   745  * RTestVclnt2WinPos::DoThisActionDuringPlaybackL
   746  */
   747 void RTestVclnt2WinPos::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& aPlayer)
   748     {
   749     TSize windowSize(iWindow->Size().iWidth / 2, iWindow->Size().iHeight / 2);
   750             
   751     // shrink the window clipping rect by half the height & width            
   752     aPlayer.SetWindowClipRectL(*iWindow, TRect(windowSize));    
   753     }
   754 
   755 
   756 //
   757 // RTestVclnt2VideoExt
   758 //
   759 
   760 /**
   761  * RTestVclnt2VideoExt::Constructor
   762  */
   763 RTestVclnt2VideoExt::RTestVclnt2VideoExt(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
   764     : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError)
   765     {
   766     }
   767 
   768 /**
   769  * RTestVclnt2VideoExt::NewL
   770  */
   771 RTestVclnt2VideoExt* RTestVclnt2VideoExt::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
   772     {
   773     RTestVclnt2VideoExt* self = new (ELeave) RTestVclnt2VideoExt(aTestName, aSectName, aKeyName, aExpectedError);
   774     return self;
   775     }
   776 
   777 /**
   778  * RTestVclnt2VideoExt::DoThisActionDuringPlaybackL
   779  */
   780 void RTestVclnt2VideoExt::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& aPlayer)
   781     {
   782     TSize windowSize(iWindow->Size().iWidth / 2, iWindow->Size().iHeight / 2);
   783             
   784     // shrink the video extent by half the height & width            
   785     aPlayer.SetVideoExtentL(*iWindow, TRect(windowSize));
   786     }
   787 
   788 
   789 //
   790 // RTestVclnt2ClipRect
   791 //
   792 
   793 /**
   794  * RTestVclnt2ClipRect::Constructor
   795  */
   796 RTestVclnt2ClipRect::RTestVclnt2ClipRect(const TDesC& aTestName, 
   797                                          const TDesC& aSectName,
   798                                          const TDesC& aKeyName, 
   799                                          TInt aExpectedError)
   800     : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError)
   801     {
   802     }
   803 
   804 /**
   805  * RTestVclnt2ClipRect::NewL
   806  */
   807 RTestVclnt2ClipRect* RTestVclnt2ClipRect::NewL(const TDesC& aTestName, 
   808                                                const TDesC& aSectName,
   809                                                const TDesC& aKeyName, 
   810                                                TInt aExpectedError)
   811     {
   812     RTestVclnt2ClipRect* self 
   813         = new (ELeave) RTestVclnt2ClipRect(aTestName, aSectName, aKeyName, aExpectedError);
   814     return self;
   815     }
   816 
   817 /**
   818  * RTestVclnt2ClipRect::DoThisActionDuringPlaybackL
   819  */
   820 void RTestVclnt2ClipRect::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& aPlayer)
   821     {
   822     TRect clipRect;    
   823     if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0405")) == 0)
   824         {
   825         // shrink the current window clipping rect by half the height & width 
   826         clipRect.Resize(iWindow->Size().iWidth / 2, iWindow->Size().iHeight / 2);            
   827         }
   828     else if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0503")) == 0)
   829         {
   830         // grow the current window clipping rect by double the width         
   831         clipRect.Resize(iWindow->Size().iWidth * 2, iWindow->Size().iHeight);
   832         }
   833     else if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0504")) == 0)
   834         {
   835         // move the current window clipping rect to be out of the window
   836         clipRect.SetSize(iWindow->Size());
   837         clipRect.Move(TPoint(iWindow->Size().iWidth + 1, 0));
   838         }
   839     else
   840         {
   841         User::Panic(_L("RTestVclnt2ClipRect"), KErrArgument);
   842         }
   843     
   844     // change the window clipping of the display window
   845     TRAPD(err, aPlayer.SetWindowClipRectL(*iWindow, clipRect));
   846     if (err != iTestExpectedError)
   847         {
   848         if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0503")) == 0 || 
   849             iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0504")) == 0)
   850             {
   851             // for negative tests, stop the test if the failure is not expected
   852             ERR_PRINTF1(_L("iVideoPlayer2->SetWindowClipRectL() did not failed as expected.  Test failed."));
   853 
   854     		iTestStepResult = EInconclusive;
   855     		CActiveScheduler::Stop();
   856 
   857     		return;
   858             }
   859         else
   860             {
   861             // fail only if error is returned for positive tests
   862             User::LeaveIfError(err);
   863             }
   864         }
   865     else
   866         {        
   867         // Reset the expected error to KErrNone as all expected failure tests have been completed.  
   868         // Any error that appears after this should fail the test
   869         iTestExpectedError = KErrNone;
   870         }
   871     }
   872 
   873 //
   874 // RTestVclnt2Scale
   875 //
   876 
   877 /**
   878  * RTestVclnt2Scale::Constructor
   879  */
   880 RTestVclnt2Scale::RTestVclnt2Scale(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
   881     : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError)
   882     {
   883     }
   884 
   885 /**
   886  * RTestVclnt2Scale::NewL
   887  */
   888 RTestVclnt2Scale* RTestVclnt2Scale::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
   889     {
   890     RTestVclnt2Scale* self = new (ELeave) RTestVclnt2Scale(aTestName, aSectName, aKeyName, aExpectedError);
   891     return self;
   892     }
   893 
   894 /**
   895  * RTestVclnt2Scale::DoThisActionDuringPlaybackL
   896  */
   897 void RTestVclnt2Scale::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& aPlayer)
   898     {
   899     // Change the scale factor during playback
   900     aPlayer.SetScaleFactorL(*iWindow, 150, 150);
   901     }
   902 
   903 /**
   904  * RTestVclnt2Scale::HandlePrepareCompleteL
   905  */ 
   906 void RTestVclnt2Scale::HandlePrepareCompleteL()
   907     {
   908     // Continue to setup the video utility and then trigger playback
   909     RTestVclnt2PerformActionDuringVideoPlayback::HandlePrepareCompleteL();
   910     
   911     TReal32 scaleFactor = 50.0;
   912      
   913     // set scale factor to less than 100%
   914     iVideoPlayer2->SetScaleFactorL(*iWindow, scaleFactor, scaleFactor);
   915 
   916     // get scale factor 
   917     TReal32 widthScale;
   918     TReal32 heightScale;
   919     iVideoPlayer2->GetScaleFactorL(*iWindow, widthScale, heightScale);
   920 
   921     if (widthScale != scaleFactor || heightScale != scaleFactor)
   922         {
   923         ERR_PRINTF1(_L("iVideoPlayer2->GetScaleFactorL() returns unexpected values.  Test aborted."));
   924         
   925 		iTestStepResult = EInconclusive;
   926 		CActiveScheduler::Stop();
   927 		
   928 		return;
   929         }    
   930     }
   931 
   932 
   933 //
   934 // RTestVclnt2Viewport
   935 //
   936 
   937 /**
   938  * RTestVclnt2Viewport::Constructor
   939  */
   940 RTestVclnt2Viewport::RTestVclnt2Viewport(const TDesC& aTestName,
   941                                          const TDesC& aSectName,
   942                                          const TDesC& aKeyName, 
   943                                          const TSize& aViewportSize,
   944                                          TInt aExpectedError)
   945     : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError),
   946       iViewportSize(aViewportSize)
   947     {
   948     }
   949 
   950 /**
   951  * RTestVclnt2Viewport::NewL
   952  */
   953 RTestVclnt2Viewport* RTestVclnt2Viewport::NewL(const TDesC& aTestName, 
   954                                                const TDesC& aSectName,
   955                                                const TDesC& aKeyName, 
   956                                                const TSize& aViewportSize,
   957                                                TInt aExpectedError)
   958     {
   959     RTestVclnt2Viewport* self = new (ELeave) RTestVclnt2Viewport(aTestName, 
   960                                                                  aSectName, 
   961                                                                  aKeyName, 
   962                                                                  aViewportSize,
   963                                                                  aExpectedError); 
   964     return self;
   965     }
   966 
   967 void RTestVclnt2Viewport::HandlePrepareCompleteL()
   968 	{
   969 	// retrive original video size
   970     TSize videoSize;
   971     iVideoPlayer2->VideoFrameSizeL(videoSize);
   972         
   973     // crop the top left quarter of the video
   974     TRect cropRegion;
   975     if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0508")) == 0)
   976         {
   977         // Crop the right half of the video
   978         cropRegion.SetHeight(videoSize.iHeight);        
   979         cropRegion.SetWidth(videoSize.iWidth / 2);
   980         cropRegion.Move(cropRegion.Width(), 0);
   981         }
   982     else
   983         {
   984         cropRegion.SetWidth(iViewportSize.iWidth == -1 ? videoSize.iWidth : iViewportSize.iWidth);
   985         cropRegion.SetHeight(iViewportSize.iHeight == -1 ? videoSize.iHeight : iViewportSize.iHeight);
   986         }
   987     
   988     TRect videoExtentRect;
   989     TRect clipRegion;
   990     
   991     if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0508")) == 0)
   992         {
   993         videoExtentRect.SetRect(TPoint(0, 0), videoSize);
   994         clipRegion.SetRect(TPoint(0, 0), videoSize); 
   995         clipRegion.SetWidth(clipRegion.Width() / 2);
   996         clipRegion.Move(clipRegion.Width(), 0);
   997         }
   998     else 
   999         {
  1000         // Calculate the video extent to be exactly the same size as the cropped video picture, 
  1001         // placed at the center of the window
  1002         TInt offsetX = (iWindow->Size().iWidth - cropRegion.Width()) / 2;
  1003         TInt offsetY = (iWindow->Size().iHeight - cropRegion.Height()) / 2;
  1004         videoExtentRect.SetRect(TPoint(offsetX, offsetY), cropRegion.Size());                    
  1005 
  1006         // Set the window clipping region to the top vertical half of the cropped image, originating
  1007         // from the top left corner of the window                    
  1008         clipRegion = videoExtentRect;                    
  1009         clipRegion.SetHeight(videoExtentRect.Height() / 2);
  1010         }
  1011     
  1012     HandlePrepareCompleteL(cropRegion, videoExtentRect, clipRegion);
  1013     
  1014     if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0508")) == 0)
  1015     	{
  1016     	// Align the image to the left of the window
  1017         iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignLeft, 0);
  1018     	}
  1019     // trigger the video to start playing                
  1020     StartPlayback();
  1021 	}
  1022 
  1023 void RTestVclnt2Viewport::HandlePrepareCompleteL(const TRect& aCropRegion, 
  1024                                                  const TRect& aVideoExtent, 
  1025                                                  const TRect& aClipRect)
  1026     {
  1027     iVideoPlayer2->SetCropRegionL(aCropRegion);
  1028     
  1029     // get the video crop region to ensure the crop region is set
  1030     TRect currentCropRegion;
  1031     iVideoPlayer2->GetCropRegionL(currentCropRegion);
  1032     
  1033     if (currentCropRegion != aCropRegion)
  1034         {
  1035         ERR_PRINTF1(_L("iVideoPlayer2->GetCropRegionL() returns an unexpected value.  Test aborted."));
  1036         
  1037 		iTestStepResult = EInconclusive;
  1038 		CActiveScheduler::Stop();
  1039         }
  1040         
  1041     iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, aVideoExtent, aClipRect);                    
  1042     }
  1043 
  1044 //
  1045 // RTestVclnt2InvalidViewport
  1046 //
  1047 
  1048 /**
  1049  * RTestVclnt2InvalidViewport::Constructor
  1050  */
  1051 RTestVclnt2InvalidViewport::RTestVclnt2InvalidViewport(const TDesC& aTestName,
  1052                                                        const TDesC& aSectName,
  1053                                                        const TDesC& aKeyName, 
  1054                                                        TInt aExpectedError)
  1055     : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
  1056     {
  1057     }
  1058 
  1059 /**
  1060  * RTestVclnt2InvalidViewport::NewL
  1061  */
  1062 RTestVclnt2InvalidViewport* RTestVclnt2InvalidViewport::NewL(const TDesC& aTestName, 
  1063                                                              const TDesC& aSectName,
  1064                                                              const TDesC& aKeyName, 
  1065                                                              TInt aExpectedError)
  1066     {
  1067     RTestVclnt2InvalidViewport* self = new (ELeave) RTestVclnt2InvalidViewport(aTestName, 
  1068                                                                                aSectName, 
  1069                                                                                aKeyName, 
  1070                                                                                aExpectedError); 
  1071     return self;
  1072     }
  1073 
  1074 /**
  1075  * RTestVclnt2InvalidViewport::HandlePrepareCompleteL
  1076  */
  1077 void RTestVclnt2InvalidViewport::HandlePrepareCompleteL()
  1078     {
  1079 	// retrive original video size
  1080     TSize videoSize;
  1081     iVideoPlayer2->VideoFrameSizeL(videoSize);
  1082 
  1083     // set the crop region to be completely out of the video image bound 
  1084     TRect cropRegion;
  1085     cropRegion.SetRect(TPoint(videoSize.iWidth, videoSize.iHeight), TSize(100, 100));
  1086 
  1087     // continue playback even if this fails
  1088     TRAPD(err, iVideoPlayer2->SetCropRegionL(cropRegion));
  1089     if (err == iTestExpectedError)
  1090         {
  1091         // the invalid crop area is not supposed to be set 
  1092         INFO_PRINTF1(_L("iVideoPlayer2->SetCropRegionL() returned expected.  Test continues."));
  1093 
  1094         // reset the expected error.  Any error that appears after this should fail the test
  1095         iTestExpectedError = KErrNone;
  1096         }
  1097     else 
  1098         {
  1099         // the invalid crop area is not supposed to be set 
  1100         ERR_PRINTF1(_L("iVideoPlayer2->SetCropRegionL() didn't leave with expected error.  Test cannot be continued."));
  1101 
  1102 		iTestStepResult = EInconclusive;
  1103 		CActiveScheduler::Stop();
  1104 		return;
  1105         }
  1106 
  1107     // get the video crop region to ensure the crop region is set
  1108     TRect currentCropRegion;
  1109     iVideoPlayer2->GetCropRegionL(currentCropRegion);
  1110 
  1111     if (currentCropRegion != cropRegion)
  1112         {
  1113         // the invalid crop area is not supposed to be set 
  1114         ERR_PRINTF1(_L("iVideoPlayer2->GetCropRegionL() returns an unexpected value.  Test cannot be continued."));
  1115         
  1116 		iTestStepResult = EInconclusive;
  1117 		CActiveScheduler::Stop();
  1118 		return;
  1119         }
  1120 
  1121     // setup the display then trigger the video to start playing
  1122     RTestVclnt2PlayFile::HandlePrepareCompleteL();
  1123     }
  1124 
  1125 
  1126 //
  1127 // RTestVclnt2Rotation
  1128 //
  1129 /**
  1130  * RTestVclnt2Rotation::Constructor
  1131  */
  1132 RTestVclnt2Rotation::RTestVclnt2Rotation(const TDesC& aTestName,
  1133                                          const TDesC& aSectName,
  1134                                          const TDesC& aKeyName, 
  1135                                          TInt aExpectedError)
  1136     : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
  1137     {
  1138     }
  1139 
  1140 /**
  1141  * RTestVclnt2Rotation::NewL
  1142  */
  1143 RTestVclnt2Rotation* RTestVclnt2Rotation::NewL(const TDesC& aTestName, 
  1144                                                const TDesC& aSectName,
  1145                                                const TDesC& aKeyName, 
  1146                                                TInt aExpectedError)
  1147     {
  1148     RTestVclnt2Rotation* self = new (ELeave) RTestVclnt2Rotation(aTestName, 
  1149                                                                  aSectName, 
  1150                                                                  aKeyName, 
  1151                                                                  aExpectedError);
  1152     return self;
  1153     }
  1154 
  1155 /**
  1156  * RTestVclnt2Rotation::HandlePrepareCompleteL
  1157  */
  1158 void RTestVclnt2Rotation::HandlePrepareCompleteL()
  1159     {
  1160     // call parent's HandlePrepareCompleteL to finish off all preparation
  1161     RTestVclnt2PlayFile::HandlePrepareCompleteL();
  1162     
  1163     // set the video to be displayed upside-down
  1164     TVideoRotation videoRotation(EVideoRotationClockwise180);
  1165     iVideoPlayer2->SetRotationL(*iWindow, videoRotation);
  1166 
  1167     // retrieve the rotation setting, and check if it's been properly updated
  1168     if (iVideoPlayer2->RotationL(*iWindow) != videoRotation)
  1169         {
  1170         ERR_PRINTF1(_L("iVideoPlayer2->RotationL() returns an unexpected value.  Test aborted."));
  1171 
  1172 		iTestStepResult = EInconclusive;
  1173 		CActiveScheduler::Stop();
  1174 
  1175 		return;
  1176         }
  1177     }
  1178 
  1179 //
  1180 // RTestVclnt2Settings
  1181 //
  1182 /**
  1183  * RTestVclnt2Settings::Constructor
  1184  */
  1185 RTestVclnt2Settings::RTestVclnt2Settings(const TDesC& aTestName,
  1186                                          const TDesC& aSectName,
  1187                                          const TDesC& aKeyName, 
  1188                                          TInt aExpectedError)
  1189     : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
  1190     {
  1191     }
  1192 
  1193 /**
  1194  * RTestVclnt2Settings::NewL
  1195  */
  1196 RTestVclnt2Settings* RTestVclnt2Settings::NewL(const TDesC& aTestName, 
  1197                                                const TDesC& aSectName,
  1198                                                const TDesC& aKeyName, 
  1199                                                TInt aExpectedError)
  1200     {
  1201     RTestVclnt2Settings* self = new (ELeave) RTestVclnt2Settings(aTestName, aSectName, aKeyName, aExpectedError);
  1202     return self;
  1203     }
  1204    
  1205 /**
  1206  * RTestVclnt2Settings::HandlePrepareCompleteL
  1207  */
  1208 void RTestVclnt2Settings::HandlePrepareCompleteL()
  1209     {
  1210     // retrieve the current frame size
  1211     TSize frameSize;
  1212     iVideoPlayer2->VideoFrameSizeL(frameSize);    
  1213     
  1214     TRect cropRegion(frameSize);
  1215     // shrink the crop region to half its original height
  1216     cropRegion.SetHeight(cropRegion.Height() / 2);
  1217     iVideoPlayer2->SetCropRegionL(cropRegion);
  1218     
  1219     TRect videoExtentRect;
  1220     videoExtentRect.SetWidth(cropRegion.Width());
  1221     videoExtentRect.SetHeight(cropRegion.Height());
  1222     
  1223     videoExtentRect.Move((iWindow->Size().iWidth - videoExtentRect.Width()) / 2,
  1224                          (iWindow->Size().iHeight - videoExtentRect.Height()) / 2); 
  1225     
  1226     TRect clippingRect(videoExtentRect);
  1227     clippingRect.SetWidth(clippingRect.Height() / 2);
  1228 
  1229     // add display window using this valid clipping rect 
  1230     iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, videoExtentRect, clippingRect);
  1231 
  1232  	// Scale the movie with best fit scaling, and vertically center the picture
  1233     iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleBestFit);
  1234     
  1235     // Start video playback
  1236     StartPlayback();
  1237     }
  1238 
  1239 
  1240 
  1241 //
  1242 // RTestVclnt2SettingsAndAlignments
  1243 //
  1244 /**
  1245  * RTestVclnt2SettingsAndAlignments::Constructor
  1246  */
  1247 RTestVclnt2SettingsAndAlignments::RTestVclnt2SettingsAndAlignments(const TDesC& aTestName,
  1248                                                                    const TDesC& aSectName,
  1249                                                                    const TDesC& aKeyName, 
  1250                                                                    TInt aExpectedError)
  1251     : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
  1252     {
  1253     }
  1254 
  1255 /**
  1256  * RTestVclnt2SettingsAndAlignments::NewL
  1257  */
  1258 RTestVclnt2SettingsAndAlignments* RTestVclnt2SettingsAndAlignments::NewL(const TDesC& aTestName, 
  1259                                                                          const TDesC& aSectName,
  1260                                                                          const TDesC& aKeyName, 
  1261                                                                          TInt aExpectedError)
  1262     {
  1263     RTestVclnt2SettingsAndAlignments* self = new (ELeave) RTestVclnt2SettingsAndAlignments(aTestName, aSectName, aKeyName, aExpectedError);
  1264     return self;
  1265     }
  1266 
  1267 TVerdict RTestVclnt2SettingsAndAlignments::DoTestStepPreambleL()
  1268 	{
  1269 	iCount = 0;
  1270 	return RTestVclnt2PlayFile::DoTestStepPreambleL();
  1271 	}
  1272 
  1273 /**
  1274  * RTestVclnt2SettingsAndAlignments::HandlePrepareCompleteL
  1275  */
  1276 void RTestVclnt2SettingsAndAlignments::HandlePrepareCompleteL()
  1277     {    
  1278     TRect cropRegion;
  1279     SetCropRegionL(cropRegion);
  1280 
  1281 	AddDisplayWindowL(cropRegion);
  1282     
  1283     if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0418")) == 0)
  1284         {            
  1285         SetContentOffsetL();
  1286         }
  1287     else if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0419")) == 0)        
  1288         {
  1289         SetContentAlignmentL();            
  1290         }        
  1291 
  1292     SetScaleFactorL();
  1293        
  1294     // Start video playback
  1295     StartPlayback();
  1296     }
  1297 
  1298 /**
  1299  * RTestVclnt2SettingsAndAlignments::HandlePlayCompleteL
  1300  */
  1301 void RTestVclnt2SettingsAndAlignments::HandlePlayCompleteL()
  1302     {    
  1303     iCount++;
  1304     
  1305     if (iCount == KSettingsAndAlignmentTest)
  1306         {
  1307     	iTestStepResult = EPass;
  1308     	CActiveScheduler::Stop();
  1309         }
  1310     else
  1311         {
  1312         HandlePrepareCompleteL();                                
  1313         }
  1314     }
  1315 
  1316 /**
  1317  * RTestVclnt2SettingsAndAlignments::SetCropRegionL
  1318  */
  1319 void RTestVclnt2SettingsAndAlignments::SetCropRegionL(TRect& aCropRegion)
  1320     {
  1321     // retrieve the current frame size
  1322     TSize frameSize;
  1323     iVideoPlayer2->VideoFrameSizeL(frameSize);    
  1324     
  1325     // Framesize is used in this case as crop region is not returning default values
  1326     aCropRegion.SetRect(TPoint(0, 0), frameSize);
  1327     
  1328     // set the crop region 
  1329     switch (iCount % KSettingsAndAlignmentTest)
  1330         {
  1331         case 0:                
  1332             // set the crop region to the top half of the image
  1333             aCropRegion.SetHeight(aCropRegion.Height() / 2);
  1334             iVideoPlayer2->SetCropRegionL(aCropRegion);
  1335             break;
  1336 
  1337         case 1:
  1338             // set the crop region to the left half of the image
  1339             aCropRegion.SetWidth(aCropRegion.Width() / 2);
  1340             iVideoPlayer2->SetCropRegionL(aCropRegion);
  1341             break;
  1342 
  1343         default:
  1344             // set the crop region to the bottom, right quarter of the image
  1345             aCropRegion.SetHeight(aCropRegion.Height() / 2);
  1346             aCropRegion.SetWidth(aCropRegion.Width() / 2);
  1347             aCropRegion.Move(aCropRegion.Width(), aCropRegion.Height());                        
  1348             iVideoPlayer2->SetCropRegionL(aCropRegion);
  1349             break;
  1350         }
  1351     }
  1352 
  1353 /**
  1354  * RTestVclnt2SettingsAndAlignments::SetContentOffsetL
  1355  */
  1356 void RTestVclnt2SettingsAndAlignments::SetContentOffsetL()
  1357     {
  1358     switch (iCount % KSettingsAndAlignmentTest)
  1359         {
  1360         case 0:
  1361             iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, 0, 100);
  1362             break;
  1363         
  1364         case 1:
  1365             iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, 100, 0);
  1366             break;
  1367         
  1368         default:
  1369             iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, 100, 100);
  1370             break;
  1371         }    
  1372     }
  1373 
  1374 /**
  1375  * RTestVclnt2SettingsAndAlignments::SetContentAlignmentL
  1376  */
  1377 void RTestVclnt2SettingsAndAlignments::SetContentAlignmentL()
  1378     {
  1379     switch (iCount % KSettingsAndAlignmentTest)
  1380         {
  1381         case 0:
  1382             iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, 0, EVerticalAlignCenter);
  1383             break;
  1384         
  1385         case 1:
  1386             iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignCenter, 0);
  1387             break;
  1388         
  1389         default:
  1390             iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignCenter, EVerticalAlignCenter);
  1391             break;
  1392         }    
  1393     }
  1394     
  1395 /**
  1396  * RTestVclnt2SettingsAndAlignments::SetScaleFactorL
  1397  */
  1398 void RTestVclnt2SettingsAndAlignments::SetScaleFactorL()
  1399     {
  1400     switch (iCount % KSettingsAndAlignmentTest)
  1401         {
  1402         case 0:
  1403             iVideoPlayer2->SetScaleFactorL(*iWindow, 1, 200);
  1404             break;
  1405         
  1406         case 1:
  1407             iVideoPlayer2->SetScaleFactorL(*iWindow, 200, 1);
  1408             break;
  1409         
  1410         default:
  1411             iVideoPlayer2->SetScaleFactorL(*iWindow, 200, 200);
  1412             break;
  1413         }    
  1414     }    
  1415 
  1416 /**
  1417  * RTestVclnt2SettingsAndAlignments::AddDisplayWindowL
  1418  */
  1419 void RTestVclnt2SettingsAndAlignments::AddDisplayWindowL(const TRect& aCropRegion)
  1420     {
  1421     TRect videoExtentRect(iWindow->Size());
  1422     TRect clippingRect(iWindow->Size());
  1423     
  1424     switch (iCount % KSettingsAndAlignmentTest)
  1425         {
  1426         case 0:
  1427             videoExtentRect.SetWidth(aCropRegion.Width());
  1428             if (iWindow->Size().iWidth > videoExtentRect.Width())
  1429                 {                    
  1430                 videoExtentRect.Move((iWindow->Size().iWidth - videoExtentRect.Width()) / 2, 0);
  1431                 }
  1432             clippingRect = videoExtentRect;
  1433             break;
  1434             
  1435         case 1:
  1436             videoExtentRect.SetHeight(aCropRegion.Height());
  1437             if (iWindow->Size().iHeight > videoExtentRect.Height())
  1438                 {                    
  1439                 videoExtentRect.Move(0, (iWindow->Size().iHeight - videoExtentRect.Height()) / 2);
  1440                 }
  1441             clippingRect = videoExtentRect;
  1442             break;
  1443             
  1444         default:
  1445             clippingRect.SetHeight(clippingRect.Height() / 2);
  1446             clippingRect.SetWidth(clippingRect.Width() / 2);            
  1447             clippingRect.Move(clippingRect.Width(), clippingRect.Height());            
  1448             break;                        
  1449         }
  1450     
  1451     iVideoPlayer2->RemoveDisplayWindow(*iWindow);    
  1452     iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, videoExtentRect, clippingRect);    
  1453     }
  1454        
  1455     
  1456 //
  1457 // RTestVclnt2SecDisplay
  1458 //
  1459 /**
  1460  * RTestVclnt2SecDisplay::Constructor
  1461  */
  1462 RTestVclnt2SecDisplay::RTestVclnt2SecDisplay(const TDesC& aTestName,
  1463                                              const TDesC& aSectName,
  1464                                              const TDesC& aKeyName, 
  1465                                              TInt aExpectedError)
  1466     : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
  1467     {
  1468     }
  1469 
  1470 /**
  1471  * RTestVclnt2SecDisplay::NewL
  1472  */
  1473 RTestVclnt2SecDisplay* RTestVclnt2SecDisplay::NewL(const TDesC& aTestName, 
  1474                                                    const TDesC& aSectName,
  1475                                                    const TDesC& aKeyName, 
  1476                                                    TInt aExpectedError)
  1477     {
  1478     RTestVclnt2SecDisplay* self = new (ELeave) RTestVclnt2SecDisplay(aTestName, aSectName, aKeyName, aExpectedError);
  1479     return self;
  1480     }
  1481    
  1482 /**
  1483  * RTestVclnt2SecDisplay::DoTestStepPreambleL
  1484  */
  1485 TVerdict RTestVclnt2SecDisplay::DoTestStepPreambleL()
  1486     {
  1487     TVerdict verdict = RTestVclnt2PlayFile::DoTestStepPreambleL();    
  1488     if (verdict == EPass)
  1489         {
  1490         // make a 2nd device for this session
  1491         iSecondScreen = new (ELeave) CWsScreenDevice(iWs); 
  1492         User::LeaveIfError(iSecondScreen->Construct()); 
  1493         }
  1494     
  1495     return verdict;
  1496     }
  1497 
  1498 /**
  1499  * RTestVclnt2SecDisplay::DoTestStepPostambleL
  1500  */
  1501 TVerdict RTestVclnt2SecDisplay::DoTestStepPostambleL()
  1502     {
  1503     delete iSecondScreen;
  1504     
  1505     return EPass;
  1506     }
  1507 
  1508 /**
  1509  * RTestVclnt2SecDisplay::HandlePrepareCompleteL
  1510  */
  1511 void RTestVclnt2SecDisplay::HandlePrepareCompleteL()
  1512 	{
  1513 	// Add display window using default values - ie. video extent & window clipping 
  1514 	// defaulted to whole window
  1515 	INFO_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL()"));
  1516 	iVideoPlayer2->AddDisplayWindowL(iWs, *iSecondScreen, *iWindow);
  1517 
  1518     // trigger the video to start playing                
  1519     StartPlayback();
  1520 	}
  1521 
  1522 
  1523 //
  1524 // RTestVclnt2CropRectPause
  1525 //
  1526 /**
  1527  * RTestVclnt2CropRectPause::Constructor
  1528  */
  1529 RTestVclnt2CropRectPause::RTestVclnt2CropRectPause(const TDesC& aTestName, 
  1530                                                    const TDesC& aSectName, 
  1531                                                    const TDesC& aKeyName, 
  1532                                                    TInt aExpectedError)
  1533     : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError)
  1534     {
  1535     }
  1536 
  1537 /**
  1538  * RTestVclnt2CropRectPause::NewL
  1539  */
  1540 RTestVclnt2CropRectPause* RTestVclnt2CropRectPause::NewL(const TDesC& aTestName, 
  1541                                                          const TDesC& aSectName,
  1542                                                          const TDesC& aKeyName, 
  1543                                                          TInt aExpectedError)
  1544     {
  1545     RTestVclnt2CropRectPause* self 
  1546         = new (ELeave) RTestVclnt2CropRectPause(aTestName, aSectName, aKeyName, aExpectedError);
  1547     return self;
  1548     }
  1549 	
  1550 /**
  1551  * RTestVclnt2CropRectPause::DoThisActionDuringPlaybackL
  1552  */
  1553 void RTestVclnt2CropRectPause::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& aPlayer)
  1554     {    
  1555     TRect cropRegion;
  1556 	aPlayer.GetCropRegionL(cropRegion);
  1557 	
  1558 	// change the crop region and continue to play the clip
  1559 	cropRegion.SetHeight(cropRegion.Height() / 2);
  1560     aPlayer.SetCropRegionL(cropRegion);    
  1561     }
  1562     
  1563     
  1564     
  1565 //
  1566 // RTestVclnt2Overlay
  1567 //
  1568 /**
  1569  * RTestVclnt2Overlay::Constructor
  1570  */
  1571 RTestVclnt2Overlay::RTestVclnt2Overlay(const TDesC& aTestName,
  1572                                        const TDesC& aSectName,
  1573                                        const TDesC& aKeyName, 
  1574                                        TInt aExpectedError)
  1575     : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
  1576     {
  1577     }
  1578 
  1579 /**
  1580  * RTestVclnt2Overlay::NewL
  1581  */
  1582 RTestVclnt2Overlay* RTestVclnt2Overlay::NewL(const TDesC& aTestName, 
  1583                                              const TDesC& aSectName,
  1584                                              const TDesC& aKeyName, 
  1585                                              TInt aExpectedError)
  1586     {
  1587     RTestVclnt2Overlay* self = new (ELeave) RTestVclnt2Overlay(aTestName, 
  1588                                                                aSectName, 
  1589                                                                aKeyName, 
  1590                                                                aExpectedError);
  1591     return self;
  1592     }
  1593 
  1594 /**
  1595  * RTestVclnt2Overlay::DoTestStepPreambleL
  1596  */
  1597 TVerdict RTestVclnt2Overlay::DoTestStepPreambleL()
  1598     {
  1599     TVerdict verdict = RTestVclnt2PlayFile::DoTestStepPreambleL();    
  1600     if (verdict == EPass)
  1601         {
  1602         TFontSpec fontSpec; // use default fonts
  1603         fontSpec.iHeight = 20;
  1604 
  1605         // Get a font to draw overlay text
  1606         if (iScreen->GetNearestFontToDesignHeightInPixels(iFont, fontSpec) != KErrNone)
  1607             {
  1608             // if no font can be retrieved, abort the test
  1609             ERR_PRINTF1(_L("Cannot retrieve font to perform test.  Test aborted."));
  1610             
  1611     		return EInconclusive;
  1612             }
  1613 
  1614         iGc->Activate(*iWindow);
  1615         iGc->UseFont(iFont);
  1616         }
  1617     
  1618     return verdict;
  1619     }
  1620 
  1621 /**
  1622  * RTestVclnt2Overlay::DoTestStepPostambleL
  1623  */
  1624 TVerdict RTestVclnt2Overlay::DoTestStepPostambleL()
  1625     {
  1626     iGc->DiscardFont();    
  1627     iGc->Deactivate();                    
  1628                
  1629     return RTestVclnt2PlayFile::DoTestStepPostambleL();        
  1630     }
  1631 
  1632 /**
  1633  * RTestVclnt2Overlay::HandlePrepareCompleteL
  1634  */
  1635 void RTestVclnt2Overlay::HandlePrepareCompleteL()
  1636 	{
  1637     TRect rect(iWindow->Size());
  1638     TInt baseline = (rect.Height() + iFont->AscentInPixels()) >> 1;
  1639     
  1640     // Draw the overlay text if needed
  1641     iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1642     iGc->SetBrushColor(KRgbRed);
  1643          
  1644     iGc->SetPenStyle(CGraphicsContext::ESolidPen);
  1645     iGc->SetPenColor(KRgbBlue);
  1646     
  1647     iGc->DrawText(_L("Overlay Testing"), rect, baseline, CGraphicsContext::ELeft);
  1648 
  1649     // setup the display window and trigger the video to start playing
  1650     RTestVclnt2PlayFile::HandlePrepareCompleteL();
  1651 	}
  1652 	
  1653 
  1654 //
  1655 // RTestVclnt2AddWin2
  1656 //
  1657 
  1658 /**
  1659  * RTestVclnt2AddWin2::Constructor
  1660  */
  1661 RTestVclnt2AddWin2::RTestVclnt2AddWin2(const TDesC& aTestName,
  1662                                        const TDesC& aSectName,
  1663                                        const TDesC& aKeyName, 
  1664                                        TInt aExpectedError)
  1665     : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
  1666     {
  1667     }
  1668 
  1669 /**
  1670  * RTestVclnt2AddWin2::NewL
  1671  */
  1672 RTestVclnt2AddWin2* RTestVclnt2AddWin2::NewL(const TDesC& aTestName, 
  1673                                              const TDesC& aSectName,
  1674                                              const TDesC& aKeyName, 
  1675                                              TInt aExpectedError)
  1676     {
  1677     RTestVclnt2AddWin2* self = new (ELeave) RTestVclnt2AddWin2(aTestName, 
  1678                                                                aSectName, 
  1679                                                                aKeyName, 
  1680                                                                aExpectedError);
  1681     return self;
  1682     }
  1683 
  1684 /**
  1685  * RTestVclnt2AddWin2::HandlePrepareCompleteL
  1686  */
  1687 void RTestVclnt2AddWin2::HandlePrepareCompleteL()
  1688 	{
  1689     // add the display window for the player to use for displaying the video
  1690     iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);
  1691     
  1692     // Add the same display window again
  1693     TRAPD(err, iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow));
  1694     if (err != iTestExpectedError)
  1695         {
  1696         ERR_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() leaves with an unexpected error.  Test failed."));
  1697 
  1698 		iTestStepResult = EFail;
  1699 		CActiveScheduler::Stop();
  1700 
  1701 		return;
  1702         }
  1703     else
  1704         {
  1705         INFO_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() leaves with an expected error.  Test continues."));
  1706 
  1707         // reset the expected error.  Any error that appears after this should fail the test
  1708         iTestExpectedError = KErrNone;        
  1709         }
  1710 
  1711     // trigger the video to start playing
  1712     StartPlayback();
  1713 	}
  1714 
  1715 //
  1716 // RTestVclnt2AddWin2WithSettings
  1717 //
  1718 
  1719 /**
  1720  * RTestVclnt2AddWin2WithSettings::Constructor
  1721  */
  1722 RTestVclnt2AddWin2WithSettings::RTestVclnt2AddWin2WithSettings(const TDesC& aTestName,
  1723                                                                const TDesC& aSectName,
  1724                                                                const TDesC& aKeyName, 
  1725                                                                TInt aExpectedError)
  1726     : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
  1727     {
  1728     }
  1729 
  1730 /**
  1731  * RTestVclnt2AddWin2WithSettings::NewL
  1732  */
  1733 RTestVclnt2AddWin2WithSettings* RTestVclnt2AddWin2WithSettings::NewL(const TDesC& aTestName, 
  1734                                                                      const TDesC& aSectName,
  1735                                                                      const TDesC& aKeyName,     
  1736                                                                      TInt aExpectedError)
  1737     {
  1738     RTestVclnt2AddWin2WithSettings* self = new (ELeave) RTestVclnt2AddWin2WithSettings(aTestName, 
  1739                                                                                        aSectName, 
  1740                                                                                        aKeyName, 
  1741                                                                                        aExpectedError);
  1742     return self;
  1743     }
  1744 
  1745 /**
  1746  * RTestVclnt2AddWin2WithSettings::HandlePrepareCompleteL
  1747  */
  1748 void RTestVclnt2AddWin2WithSettings::HandlePrepareCompleteL()
  1749 	{
  1750 	TRect windowRect(iWindow->Size());
  1751 	windowRect.SetHeight(windowRect.Height() / 2);
  1752 
  1753 	iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, windowRect, windowRect);
  1754 
  1755 	// Add the same display window again with default values
  1756 	TRAPD(err, iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow));
  1757 	if (err != iTestExpectedError)
  1758 	    {
  1759 	    ERR_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() leaves with an unexpected error.  Test failed."));
  1760 
  1761 		iTestStepResult = EFail;
  1762 		CActiveScheduler::Stop();
  1763 
  1764 		return;
  1765 	    }
  1766     else
  1767         {
  1768         INFO_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() leaves with an expected error.  Test continues."));
  1769 
  1770         // reset the expected error.  Any error that appears after this should fail the test
  1771         iTestExpectedError = KErrNone;
  1772 	    }
  1773 
  1774 	// trigger the video to start playing
  1775     StartPlayback();
  1776 	}
  1777 
  1778 //
  1779 // RTestVclnt2ContOffset
  1780 //
  1781 
  1782 /**
  1783  * RTestVclnt2ContOffset::Constructor
  1784  */
  1785 RTestVclnt2ContOffset::RTestVclnt2ContOffset(const TDesC& aTestName, 
  1786                                              const TDesC& aSectName, 
  1787                                              const TDesC& aKeyName, 
  1788                                              TInt aExpectedError)
  1789     : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
  1790     {
  1791     iHeapSize = 2000000; //~2MB
  1792     }
  1793 
  1794 /**
  1795  * RTestVclnt2ContOffset::NewL
  1796  */
  1797 RTestVclnt2ContOffset* RTestVclnt2ContOffset::NewL(const TDesC& aTestName, 
  1798                                                    const TDesC& aSectName,
  1799                                                    const TDesC& aKeyName, 
  1800                                                    TInt aExpectedError)
  1801     {
  1802     RTestVclnt2ContOffset* self = new (ELeave) RTestVclnt2ContOffset(aTestName, 
  1803                                                                      aSectName, 
  1804                                                                      aKeyName, 
  1805                                                                      aExpectedError);
  1806     return self;
  1807     }
  1808 
  1809 /**
  1810  * RTestVclnt2ContOffset::HandlePrepareCompleteL
  1811  */
  1812 void RTestVclnt2ContOffset::HandlePrepareCompleteL()
  1813 	{
  1814     // call parent's HandlePrepareCompleteL to finish off all preparation    
  1815 	RTestVclnt2PlayFile::HandlePrepareCompleteL();
  1816     // Set the content offset before starting to play the video.
  1817     INFO_PRINTF1(_L("iVideoPlayer2->SetAutoScale()"));
  1818     iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, 100, 100);
  1819     
  1820     if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0409")) == 0)
  1821         {
  1822         // Set the content alignment after setting the content offset
  1823         iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignLeft, EVerticalAlignTop);
  1824         }
  1825 	}
  1826 
  1827 //
  1828 // RTestVclnt2ContOffsetAtPlay
  1829 //
  1830 /**
  1831  * RTestVclnt2ContOffsetAtPlay::Constructor
  1832  */
  1833 RTestVclnt2ContOffsetAtPlay::RTestVclnt2ContOffsetAtPlay(const TDesC& aTestName, 
  1834                                                          const TDesC& aSectName, 
  1835                                                          const TDesC& aKeyName, 
  1836                                                          TInt aExpectedError)
  1837     : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError)
  1838     {
  1839     iHeapSize = 2000000; //~2MB
  1840     }
  1841 
  1842 /**
  1843  * RTestVclnt2ContOffsetAtPlay::NewL
  1844  */
  1845 RTestVclnt2ContOffsetAtPlay* RTestVclnt2ContOffsetAtPlay::NewL(const TDesC& aTestName, 
  1846                                                                const TDesC& aSectName,
  1847                                                                const TDesC& aKeyName, 
  1848                                                                TInt aExpectedError)
  1849     {
  1850     RTestVclnt2ContOffsetAtPlay* self = new (ELeave) RTestVclnt2ContOffsetAtPlay(aTestName, 
  1851                                                                                  aSectName, 
  1852                                                                                  aKeyName, 
  1853                                                                                  aExpectedError);
  1854     return self;
  1855     }
  1856         
  1857 /**
  1858  * RTestVclnt2ContOffsetAtPlay::DoThisActionDuringPlaybackL
  1859  */
  1860 void RTestVclnt2ContOffsetAtPlay::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& /* aPlayer */)
  1861     {
  1862     // Change the scale factor during playback
  1863 	INFO_PRINTF1(_L("iVideoPlayer2->SetAutoScale()"));
  1864 	iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, 10, 10);    
  1865     }
  1866 
  1867 
  1868 //
  1869 // RTestVclnt2Align
  1870 //
  1871 /**
  1872  * RTestVclnt2Align::Constructor
  1873  */
  1874 RTestVclnt2Align::RTestVclnt2Align(const TDesC& aTestName, 
  1875                                    const TDesC& aSectName, 
  1876                                    const TDesC& aKeyName, 
  1877                                    TInt aExpectedError)
  1878     : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError)
  1879     {
  1880     iHeapSize = 2000000; //~2MB
  1881     }
  1882 
  1883 /**
  1884  * RTestVclnt2Align::NewL
  1885  */
  1886 RTestVclnt2Align* RTestVclnt2Align::NewL(const TDesC& aTestName, 
  1887                                          const TDesC& aSectName,
  1888                                          const TDesC& aKeyName, 
  1889                                          TInt aExpectedError)
  1890     {
  1891     RTestVclnt2Align* self = new (ELeave) RTestVclnt2Align(aTestName, aSectName, aKeyName, aExpectedError);
  1892     return self;
  1893     }
  1894 
  1895 /**
  1896  * RTestVclnt2Align::HandlePrepareCompleteL
  1897  */ 
  1898 void RTestVclnt2Align::HandlePrepareCompleteL()
  1899     {
  1900     // Continue to setup the video utility and then trigger playback
  1901     RTestVclnt2PlayFile::HandlePrepareCompleteL();
  1902 	// Set the content offset before starting to play the video.
  1903     INFO_PRINTF1(_L("iVideoPlayer2->SetAutoScale()"));
  1904     iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignCenter, EVerticalAlignCenter);
  1905     }
  1906     
  1907 /**
  1908  * RTestVclnt2Align::DoThisActionDuringPlaybackL
  1909  */
  1910 void RTestVclnt2Align::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& /* aPlayer */)
  1911     {    
  1912     iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignLeft, EVerticalAlignCenter);    
  1913     iVideoPlayer2->RemoveDisplayWindow(*iWindow);
  1914     iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, TRect(10, 10, 100, 100), TRect(0, 3, 4, 220));        
  1915     
  1916     iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignRight, EVerticalAlignCenter);    
  1917     iVideoPlayer2->RemoveDisplayWindow(*iWindow);
  1918     iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);        
  1919         
  1920     iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignCenter, EVerticalAlignTop);    
  1921     iVideoPlayer2->RemoveDisplayWindow(*iWindow);
  1922     iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, TRect(10, 10, 100, 100), TRect(0, 5, 5, 200));        
  1923     
  1924     iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignLeft, EVerticalAlignTop);
  1925     iVideoPlayer2->RemoveDisplayWindow(*iWindow);
  1926     iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);        
  1927     
  1928     iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignRight, EVerticalAlignTop);
  1929     iVideoPlayer2->RemoveDisplayWindow(*iWindow);
  1930     iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, TRect(0, 0, 100, 100), TRect(0, 5, 5, 200));        
  1931         
  1932     iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignCenter, EVerticalAlignBottom);
  1933     iVideoPlayer2->RemoveDisplayWindow(*iWindow);
  1934     iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);        
  1935     
  1936     iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignLeft, EVerticalAlignBottom);
  1937     iVideoPlayer2->RemoveDisplayWindow(*iWindow);
  1938     iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, TRect(0, 0, 100, 100), TRect(0, 5, 300, 230));        
  1939     
  1940     iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignRight, EVerticalAlignBottom);
  1941     iVideoPlayer2->RemoveDisplayWindow(*iWindow);
  1942     iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);        
  1943     }
  1944 
  1945 
  1946 //
  1947 // RTestVclnt2AutoScale
  1948 //
  1949 /**
  1950  * RTestVclnt2AutoScale::Constructor
  1951  */
  1952 RTestVclnt2AutoScale::RTestVclnt2AutoScale(const TDesC& aTestName, 
  1953                                            const TDesC& aSectName, 
  1954                                            const TDesC& aKeyName, 
  1955                                            TInt aExpectedError)
  1956     : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError)
  1957     {
  1958     iHeapSize = 2000000; //~2MB
  1959     }
  1960 
  1961 /**
  1962  * RTestVclnt2AutoScale::NewL
  1963  */
  1964 RTestVclnt2AutoScale* RTestVclnt2AutoScale::NewL(const TDesC& aTestName, 
  1965                                                  const TDesC& aSectName,
  1966                                                  const TDesC& aKeyName, 
  1967                                                  TInt aExpectedError)
  1968     {
  1969     RTestVclnt2AutoScale* self = new (ELeave) RTestVclnt2AutoScale(aTestName, aSectName, aKeyName, aExpectedError);
  1970     return self;
  1971     }
  1972 
  1973 /**
  1974  * RTestVclnt2AutoScale::HandlePrepareCompleteL
  1975  */ 
  1976 void RTestVclnt2AutoScale::HandlePrepareCompleteL()
  1977     {
  1978     iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);
  1979 	// Set the content offset before starting to play the video.
  1980     INFO_PRINTF1(_L("iVideoPlayer2->SetAutoScale()"));
  1981     iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleClip);
  1982     
  1983     // trigger the video to start playing                
  1984     StartPlayback();
  1985     }
  1986 	
  1987 /**
  1988  * RTestVclnt2AutoScale::DoThisActionDuringPlaybackL
  1989  */
  1990 void RTestVclnt2AutoScale::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& aPlayer)
  1991     {    
  1992 	aPlayer.SetAutoScaleL(*iWindow, EAutoScaleBestFit);
  1993 	aPlayer.SetAutoScaleL(*iWindow, EAutoScaleNone);
  1994 	aPlayer.SetAutoScaleL(*iWindow, EAutoScaleStretch);
  1995     }
  1996 
  1997 //
  1998 // RTestVclnt2OldController
  1999 //
  2000 
  2001 RTestVclnt2OldController::RTestVclnt2OldController(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
  2002 	: RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
  2003 	{
  2004 	}
  2005 
  2006 /**
  2007  * RTestVclnt2OldController::NewL
  2008  */
  2009 RTestVclnt2OldController* RTestVclnt2OldController::NewL(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
  2010     {
  2011     RTestVclnt2OldController* self = new (ELeave) RTestVclnt2OldController(aTestName, aSectName, aKeyName, aExpectedError);
  2012     return self;
  2013     }
  2014 
  2015 void RTestVclnt2OldController::HandleIdleL()
  2016 	{
  2017 	// Open iVideoPlayer using a controller that does not support surfaces. 
  2018     INFO_PRINTF2(_L("iVideoPlayer2->OpenFileL() %S"), &iFilename);
  2019     iVideoPlayer2->OpenFileL(iFilename, KMmfTestAviNonGcePlayControllerUid);
  2020     PrepareState(EVPOpenComplete, KErrNone);
  2021 	}
  2022 
  2023 void RTestVclnt2OldController::HandlePrepareCompleteL()
  2024 	{
  2025 	TRAPD(err, RTestVclnt2PlayFile::HandlePrepareCompleteL());
  2026 	
  2027 	if (err != KErrNotSupported)
  2028 		{
  2029 		ERR_PRINTF1(_L("AddDisplay did not leave with KErrNotSupported."));
  2030 		iTestStepResult = EFail;
  2031 		}
  2032 	else
  2033 		{
  2034 		iTestStepResult = EPass;
  2035 		}
  2036 	
  2037 	// Stop the test.
  2038 	CActiveScheduler::Stop();
  2039 	}
  2040 //
  2041 // RTestVclnt2NoFile
  2042 //
  2043 
  2044 RTestVclnt2NoFile::RTestVclnt2NoFile(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
  2045 	: RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
  2046 	{
  2047 	}
  2048 
  2049 /**
  2050  * RTestVclnt2NoFile::NewL
  2051  */
  2052 RTestVclnt2NoFile* RTestVclnt2NoFile::NewL(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
  2053     {
  2054     RTestVclnt2NoFile* self = new (ELeave) RTestVclnt2NoFile(aTestName, aSectName, aKeyName, aExpectedError);
  2055     return self;
  2056     }
  2057 
  2058 void RTestVclnt2NoFile::HandleIdleL()
  2059 	{
  2060 	iTestStepResult = EFail;
  2061 	TRAPD(err, iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow));
  2062 	
  2063 	if (err != iTestExpectedError)
  2064 		{
  2065 		ERR_PRINTF1(_L("AddDisplayWindowL did not leave with KErrNotReady."));
  2066 		User::Leave(KErrGeneral);
  2067 		}
  2068 	
  2069 	TSize windowSize = iWindow->Size();
  2070 	TRect videoExtent(-5, -5, windowSize.iWidth + 5, windowSize.iHeight + 5);
  2071 	TRect windowClipRect(5, 5, windowSize.iWidth - 5, windowSize.iHeight - 5);
  2072 	TRAP(err, iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, videoExtent, windowClipRect));
  2073 	
  2074 	if (err != iTestExpectedError)
  2075 		{
  2076 		ERR_PRINTF1(_L("AddDisplayWindowL did not leave with KErrNotReady."));
  2077 		User::Leave(KErrGeneral);
  2078 		}
  2079 	
  2080 	TRAP(err, iVideoPlayer2->SetWindowClipRectL(*iWindow, windowClipRect));
  2081 	
  2082 	if (err != iTestExpectedError)
  2083 		{
  2084 		ERR_PRINTF1(_L("SetWindowClipRectL did not leave with KErrNotReady."));
  2085 		User::Leave(KErrGeneral);
  2086 		}
  2087 	
  2088 	TRAP(err, iVideoPlayer2->SetVideoExtentL(*iWindow, videoExtent));
  2089 	
  2090 	if (err != iTestExpectedError)
  2091 		{
  2092 		ERR_PRINTF1(_L("SetVideoExtentL did not leave with KErrNotReady."));
  2093 		User::Leave(KErrGeneral);
  2094 		}
  2095 	
  2096 	// reset the expected error to KErrNone as any error happens after this is unexpected
  2097     iTestExpectedError = KErrNone;	
  2098 	
  2099 	// The video should still play when we try to play the video.  Perform 
  2100 	// the basic play test now.
  2101 	RTestVclnt2PlayFile::HandleIdleL();
  2102 	}
  2103 
  2104 //
  2105 // RTestVclnt2PlayAfterRemoveWin
  2106 //
  2107 
  2108 RTestVclnt2PlayAfterRemoveWin::RTestVclnt2PlayAfterRemoveWin(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
  2109 	: RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
  2110 	{
  2111 	}
  2112 
  2113 /**
  2114  * RTestVclnt2PlayAfterRemoveWin::NewL
  2115  */
  2116 RTestVclnt2PlayAfterRemoveWin* RTestVclnt2PlayAfterRemoveWin::NewL(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
  2117     {
  2118     RTestVclnt2PlayAfterRemoveWin* self = new (ELeave) RTestVclnt2PlayAfterRemoveWin(aTestName, aSectName, aKeyName, aExpectedError);
  2119     return self;
  2120     }
  2121 
  2122 void RTestVclnt2PlayAfterRemoveWin::HandlePrepareCompleteL()
  2123 	{
  2124 	// Don't add a window. Just play the video.
  2125 	StartPlayback();
  2126 	}
  2127 
  2128 void RTestVclnt2PlayAfterRemoveWin::HandlePlayCompleteL()
  2129 	{
  2130 	switch(iPlayAttempt)
  2131 		{
  2132 	case 0:
  2133 		{
  2134 		TSize windowSize = iWindow->Size();
  2135 		TRect videoExtent(-5, -5, windowSize.iWidth + 5, windowSize.iHeight + 5);
  2136 		TRect windowClipRect(5, 5, windowSize.iWidth - 5, windowSize.iHeight - 5);
  2137 		iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, videoExtent, windowClipRect);
  2138 		iVideoPlayer2->RemoveDisplayWindow(*iWindow);
  2139 		iVideoPlayer2->Play();
  2140 		PrepareState(EVPPlayComplete, KErrNone);
  2141 		break;
  2142 		}
  2143 	case 1:
  2144 		// Removing the window again should have no effect.
  2145 		iVideoPlayer2->RemoveDisplayWindow(*iWindow);
  2146 		iVideoPlayer2->Play();
  2147 		PrepareState(EVPPlayComplete, KErrNone);
  2148 		break;
  2149 	case 2:
  2150 		// The previous play commands should have no effect when we try to add a 
  2151 		// display window and render to surfaces. Use the base class to do this.
  2152 		RTestVclnt2PlayFile::HandlePrepareCompleteL();
  2153 		break;
  2154 	default:
  2155 		// Use the parent handler after we have tried the above play commands.
  2156 		RTestVclnt2PlayFile::HandlePlayCompleteL();
  2157 		break;
  2158 		}
  2159 	
  2160 	iPlayAttempt++;
  2161 	}
  2162 
  2163 //
  2164 // RTestVclnt2NoGce
  2165 //
  2166 
  2167 RTestVclnt2NoGce::RTestVclnt2NoGce(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
  2168 	: RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
  2169 	{
  2170 	}
  2171 
  2172 /**
  2173  * RTestVclnt2NoGce::NewL
  2174  */
  2175 RTestVclnt2NoGce* RTestVclnt2NoGce::NewL(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
  2176     {
  2177     RTestVclnt2NoGce* self = new (ELeave) RTestVclnt2NoGce(aTestName, aSectName, aKeyName, aExpectedError);
  2178     return self;
  2179     }
  2180 
  2181 void RTestVclnt2NoGce::HandleIdleL()
  2182 	{
  2183 	// Open iVideoPlayer
  2184     INFO_PRINTF2(_L("iVideoPlayer2->OpenFileL() %S"), &iFilename);
  2185     iVideoPlayer2->OpenFileL(iFilename, KMmfTestAviPlayControllerUid);
  2186     PrepareState(EVPOpenComplete, KErrNotSupported);
  2187 	}
  2188 
  2189 void RTestVclnt2NoGce::HandleOpenCompleteL()
  2190 	{
  2191 	iTestStepResult = EPass;
  2192 	CActiveScheduler::Stop();
  2193 	}
  2194 	
  2195 //
  2196 // RTestVclnt2Alloc
  2197 //
  2198 
  2199 RTestVclnt2Alloc::RTestVclnt2Alloc(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
  2200 	: RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
  2201 	{
  2202 	}
  2203 
  2204 /**
  2205  * RTestVclnt2Alloc::NewL
  2206  */
  2207 RTestVclnt2Alloc* RTestVclnt2Alloc::NewL(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
  2208     {
  2209     RTestVclnt2Alloc* self = new (ELeave) RTestVclnt2Alloc(aTestName, aSectName, aKeyName, aExpectedError);
  2210     return self;
  2211     }
  2212 
  2213 TVerdict RTestVclnt2Alloc::DoTestStepPreambleL()
  2214 	{
  2215     INFO_PRINTF1(_L("RTestVclnt2Alloc::DoTestStepPreambleL()"));
  2216         
  2217     // Call RTestMmfVclntAviStep::DoTestStepPreambleL instead of the immediate parent's 
  2218     // DoTestStepPreambleL as there is no need for CVideoPlayerUtility setup.
  2219     // Similarly, there is no need to initialize CVideoPlayerUtility2, as it will be
  2220     // created in each alloc iteration.
  2221     return RTestMmfVclntAviStep::DoTestStepPreambleL();
  2222 	}
  2223 
  2224 TVerdict RTestVclnt2Alloc::PerformTestL()
  2225 	{
  2226 	iVideoPlayer2 = CVideoPlayerUtility2::NewL(*this, EMdaPriorityNormal, EMdaPriorityPreferenceTimeAndQuality);
  2227 	ResetState();
  2228 	iError = KErrNone;
  2229 	TVerdict result = RTestVclnt2AviPlayerStep::DoTestStepL();
  2230 	delete iVideoPlayer2;
  2231 	iVideoPlayer2 = NULL;
  2232 	return result;
  2233 	}
  2234 
  2235 /**
  2236  * RTestVclnt2Alloc::DoTestStepL()
  2237  */
  2238 TVerdict RTestVclnt2Alloc::DoTestStepL()
  2239     {
  2240     TVerdict allocTestStepResult = EPass;
  2241     TInt err = KErrNone;
  2242     TBool result = EFalse;
  2243     
  2244     //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
  2245     if (PerformTestL() != EPass)
  2246         {
  2247         err = iError;
  2248         }
  2249 
  2250     if (err != KErrNone)
  2251         {
  2252         INFO_PRINTF2(_L("Test error, returned error code =  %d"), err);
  2253         User::Leave(err);
  2254         }
  2255     else
  2256         {
  2257         //Check the iAllocTestStepResult
  2258         if (allocTestStepResult != EPass)
  2259             {
  2260             result = ETrue;
  2261             }
  2262         }    
  2263     
  2264     TInt failCount = 1;
  2265     TBool completed = EFalse;
  2266     allocTestStepResult = EPass;
  2267     TBool reachedEnd = EFalse;
  2268     for(;;)    
  2269         {
  2270         __UHEAP_SETFAIL(RHeap::EFailNext, failCount);
  2271         __MM_HEAP_MARK;
  2272 
  2273         //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
  2274         TVerdict verdict = EFail;
  2275         TRAP(err, verdict = PerformTestL());
  2276         if (err == KErrNone && verdict != EPass)
  2277             {
  2278             err = iError;
  2279             }
  2280 
  2281         completed = EFalse;
  2282         if (err == KErrNone)
  2283             {
  2284             TAny* testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
  2285             if (testAlloc == NULL)
  2286                 {
  2287                 reachedEnd = ETrue;
  2288                 failCount -= 1;
  2289                 }
  2290             else
  2291                 {
  2292                 User::Free(testAlloc);    
  2293                 }            
  2294             
  2295             //Check the iAllocTestStepResult
  2296             if (allocTestStepResult != EPass)
  2297                 {
  2298                 result = ETrue;
  2299                 }
  2300             
  2301             completed = reachedEnd || result;
  2302             }
  2303         else if (err != KErrNoMemory) // bad error code
  2304             {
  2305             completed = ETrue;
  2306             result = EFail;
  2307             }            
  2308 
  2309         __MM_HEAP_MARKEND;
  2310         __UHEAP_SETFAIL(RHeap::ENone, 0);
  2311 
  2312         if (completed)
  2313             {
  2314             break; // exit loop
  2315             }
  2316 
  2317         failCount++;
  2318         }
  2319 
  2320     failCount -= 1; // Failcount of 1 equates to 0 successful allocs, etc
  2321 
  2322     if (err != KErrNone || result)
  2323         {
  2324         allocTestStepResult = EFail;
  2325         TBuf<80> format;
  2326         if (result)
  2327             {
  2328             format.Format(_L("  Bad result with %d memory allocations tested\n"), failCount);
  2329             }
  2330         else
  2331             {
  2332             format.Format(_L("  Error(%d) with %d memory allocations tested\n"), err, failCount);
  2333             }
  2334         Log(format);
  2335         }
  2336     else 
  2337         {
  2338         TBuf<80> format;
  2339         format.Format(_L("  Completed OK with %d memory allocations tested\n"), failCount);
  2340         Log(format);
  2341         }
  2342 
  2343     return allocTestStepResult;
  2344     }
  2345 
  2346 //
  2347 // RTestVclnt2InvalidScaleFactor
  2348 //
  2349 RTestVclnt2InvalidScaleFactor::RTestVclnt2InvalidScaleFactor(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
  2350 	: RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
  2351 	{
  2352 	}
  2353 
  2354 /**
  2355  * RTestVclnt2InvalidScaleFactor::NewL
  2356  */
  2357 RTestVclnt2InvalidScaleFactor* RTestVclnt2InvalidScaleFactor::NewL(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
  2358     {
  2359     RTestVclnt2InvalidScaleFactor* self = new (ELeave) RTestVclnt2InvalidScaleFactor(aTestName, aSectName, aKeyName, aExpectedError);
  2360     return self;
  2361     }
  2362 
  2363 void RTestVclnt2InvalidScaleFactor::HandlePrepareCompleteL()
  2364 	{
  2365 	INFO_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL()"));
  2366 	iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);
  2367 
  2368 	// Try to scale the video to an invalid values
  2369 	TRAPD(err, iVideoPlayer2->SetScaleFactorL(*iWindow, 0, 100));
  2370 	if (err != KErrArgument)
  2371 		{
  2372 		User::Leave(err == KErrNone ? KErrGeneral : err); 
  2373 		}
  2374 	
  2375 	TRAP(err, iVideoPlayer2->SetScaleFactorL(*iWindow, 100, -100));
  2376 	if (err != KErrArgument)
  2377 		{
  2378 		User::Leave(err == KErrNone ? KErrGeneral : err); 
  2379 		}
  2380 	
  2381 	// trigger the video to start playing                
  2382     StartPlayback();
  2383 	}