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