os/mm/mmlibs/mmfw/tsrc/mmfunittest/avictrl/tsu_mmf_avictrlplay.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2006-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 <hal.h>
    17 #include <hal_data.h> 
    18 
    19 // Specific includes for this test code
    20 #include <mmf/common/mmfstandardcustomcommands.h>
    21 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    22 #include <mmf/common/mmfstandardcustomcommandsenums.h>
    23 #include <mmf/common/mmfstandardcustomcommandsimpl.h>
    24 #endif
    25 #include "tsu_mmf_avictrl_teststep.h"
    26 #include "tsu_mmf_avictrl_testsuite.h"
    27 #include "tsu_mmf_avictrlplay.h"
    28 #include "tsu_mmf_avictrltestids.h"
    29 #define KExtraIterations 5
    30 
    31 const TUint RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap::KMaxFreeRamForTest;
    32 
    33 /**
    34 Test step constructor. It initialises its own name and the input filename
    35 */
    36 RTestStepAviPlayCtrlPlay::RTestStepAviPlayCtrlPlay(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
    37 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
    38 	{
    39 	}
    40 	
    41 /**
    42 Do the test step. This test Primes the AviPlayController and Plays an avi file to its completion
    43 and checks for the proper play completion
    44 */
    45 TVerdict RTestStepAviPlayCtrlPlay::DoTestStepL()
    46 	{
    47 	INFO_PRINTF1(_L("this step plays an avi file "));
    48 	TInt errorCode = iController.Prime();
    49 	if(errorCode)
    50 		{
    51 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
    52 		return EFail;
    53 		}
    54 	errorCode = iController.Play();
    55 	if(errorCode)
    56 		{
    57 		INFO_PRINTF2(_L("Play() is failed with  %d "), errorCode);
    58 		return EFail;
    59 		}
    60 	CActiveScheduler::Start();	
    61 	return iTestStepResult;
    62 	}
    63 
    64 /**
    65 Test step constructor. It initialises its own name and the input filename
    66 */
    67 RTestStepAviPlayCtrlVolume::RTestStepAviPlayCtrlVolume(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
    68 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
    69 	{
    70 	}
    71 	
    72 /**
    73 Do the test step.This tests setting the volume on AviPlayController in Stopped, Primed and Playing 
    74 states and checks if the volume set is same as the volume got.
    75 */
    76 TVerdict RTestStepAviPlayCtrlVolume::DoTestStepL( void )
    77 	{
    78 	TInt errorCode = 0;
    79 	RMMFVideoPlayControllerCustomCommands  thePlayCommander(iController);
    80 	TBool enabled = EFalse;
    81 	thePlayCommander.GetAudioEnabled(enabled);
    82 	if(!enabled)
    83 		{
    84 		INFO_PRINTF2(_L("GetAudioEnabled() is failed with  %d "), errorCode);
    85 		return EInconclusive;
    86 		}
    87 	INFO_PRINTF1(_L("this step tests SetVolume/GetVolume() APIs of AviPlayController"));
    88 	RMMFAudioPlayDeviceCustomCommands theAudioDevice(iController);
    89 	TInt maxVolume(0);
    90 	errorCode =theAudioDevice.GetMaxVolume(maxVolume);
    91 	if(errorCode)
    92 		{
    93 		INFO_PRINTF2(_L("GetMaxVolume() is failed with  %d "), errorCode);
    94 		return EInconclusive;
    95 		}
    96 	TInt theVolume = maxVolume /2;
    97 	TTimeIntervalMicroSeconds ramp(100);
    98 	 //try setting volume in Stopped State
    99 	errorCode =theAudioDevice.SetVolume(theVolume);
   100 	if(errorCode)
   101 		{
   102 		INFO_PRINTF2(_L("SetVolume() during Stopped State is failed with  %d "), errorCode);
   103 		return EFail;
   104 		}
   105 	TInt theNewVolume (0);
   106 	errorCode =theAudioDevice.GetVolume(theNewVolume);
   107 	if(errorCode)
   108 		{
   109 		INFO_PRINTF2(_L("GetVolume() during Stopped State is failed with  %d "), errorCode);
   110 		return EFail;
   111 		}
   112 	 if( theNewVolume != theVolume )
   113 	 	{
   114 	       INFO_PRINTF1(_L("Set and Get Volumes are different during Stopped State"));
   115 	       return EFail;
   116 	    	}
   117 	errorCode =theAudioDevice.SetVolumeRamp(ramp);
   118 	if(errorCode)
   119 		{
   120 		INFO_PRINTF2(_L("SetVolumeRamp() during Stopped State is failed with  %d "), errorCode);
   121 		return EFail;
   122 		}	    	
   123 	errorCode = iController.Prime();
   124 	if(errorCode)
   125 		{
   126 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
   127 		return EInconclusive;
   128 		}
   129 	//try setting volume in Primed State
   130 	errorCode =theAudioDevice.SetVolume(theVolume);
   131 	if(errorCode)
   132 		{
   133 	    	INFO_PRINTF2(_L("SetVolume() during Primed State is failed with  %d "), errorCode);
   134 	    	return EFail;
   135 	    	}
   136 	errorCode =theAudioDevice.GetVolume(theNewVolume);
   137 	if(errorCode)
   138 	    	{
   139 	    	INFO_PRINTF2(_L("GetVolume() during Primed State is failed with  %d "), errorCode);
   140 	    	return EFail;
   141 	    	}
   142 	if( theNewVolume != theVolume )
   143 	    	{
   144 		INFO_PRINTF1(_L("Set and Get Volumes are different during Primed State"));
   145 	       return EFail;
   146 	    	}
   147 	 errorCode =theAudioDevice.SetVolumeRamp(ramp);
   148 	 if(errorCode)
   149 		{
   150 		INFO_PRINTF2(_L("SetVolumeRamp() during primed State is failed with  %d "), errorCode);
   151 		return EFail;
   152 		}	   	
   153 	 errorCode = iController.Play();
   154 	 if(errorCode)
   155 	 	{
   156 	    	INFO_PRINTF2(_L("Play() is failed with  %d "), errorCode);
   157 	    	return EInconclusive;
   158 	    	}
   159 	   //try setting volume in Playing State
   160 	 errorCode =theAudioDevice.SetVolume(theVolume);
   161 	 if(errorCode)
   162 	  	{
   163 	    	INFO_PRINTF2(_L("SetVolume() during Playing State is failed with  %d "), errorCode);
   164 	    	iController.Stop();
   165 	    	return EFail;
   166 	    	}
   167 	 errorCode =theAudioDevice.GetVolume(theNewVolume);
   168 	 if(errorCode)
   169 	    	{
   170 	    	INFO_PRINTF2(_L("GetVolume() during Playing State is failed with  %d "), errorCode);
   171 	    	iController.Stop();
   172 	    	return EFail;
   173 	    	}
   174 	 if(theNewVolume != theVolume)
   175 		{
   176 	        //stop the controller
   177 	        INFO_PRINTF1(_L("Set and Get Volumes are different during Playing State"));
   178 	        iController.Stop();
   179 	        return EFail;
   180 		}
   181 	 errorCode =theAudioDevice.SetVolumeRamp(ramp);
   182 	 if(errorCode)
   183 		{
   184 		INFO_PRINTF2(_L("SetVolumeRamp() during play State is failed with  %d "), errorCode);
   185 		return EFail;
   186 		}		
   187     //get the play completion event
   188 	 CActiveScheduler::Start();
   189 	 return iTestStepResult; 		
   190 	}
   191 
   192 	
   193 /**
   194 Test step constructor. It initialises its own name and the input filename
   195 */
   196 RTestStepAviPlayCtrlPlayBalance::RTestStepAviPlayCtrlPlayBalance(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
   197 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
   198 	{
   199 	}
   200 	
   201 /**
   202 Do the test step.This tests setting the PlayBalance on AviPlayController in Stopped, Primed and Playing 
   203 states and checks if the PlayBalance set is same as the PlayBalance got.
   204 */ 
   205 TVerdict RTestStepAviPlayCtrlPlayBalance::DoTestStepL( void )
   206 	 {
   207 	TInt errorCode=0;
   208 	INFO_PRINTF1(_L("this checks if audio is enabled on the sample.avi file"));
   209 	RMMFVideoPlayControllerCustomCommands thePlayCommander(iController);
   210 	TBool enabled = EFalse;
   211 	thePlayCommander.GetAudioEnabled(enabled);
   212 	if(!enabled)
   213 		{
   214 		INFO_PRINTF2(_L("GetAudioEnabled() is failed with  %d "), errorCode);
   215 		return EInconclusive;
   216 		}
   217 	INFO_PRINTF1(_L("this step tests SetBalance/GetBalance() APIs of AviPlayController "));
   218 	RMMFAudioPlayDeviceCustomCommands theAudioDevice( iController );
   219 	TInt theBalance = (30 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;
   220 	errorCode = theAudioDevice.SetBalance(theBalance);
   221 	if(errorCode)
   222 	    	{
   223 	    	INFO_PRINTF2(_L("SetBalance() during Stopped State is failed with  %d "), errorCode);
   224 	    	return EFail;
   225 	    	}
   226 	TInt theNewBalance (0);
   227 	errorCode =theAudioDevice.GetBalance(theNewBalance);
   228 	if(errorCode)
   229 		{
   230 	    	INFO_PRINTF2(_L("GetBalance() during Stopped State is failed with  %d "), errorCode);
   231 	    	return EFail;
   232 	    	}
   233 	if( theNewBalance != theBalance )
   234 		{
   235 		INFO_PRINTF1(_L("Set and Get Balances are different during Stopped State"));
   236 		return EFail;
   237 		}
   238 	errorCode = iController.Prime();
   239 	if(errorCode)
   240 		{
   241 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
   242 		return EInconclusive;
   243 		}
   244 	errorCode = theAudioDevice.SetBalance( theBalance );
   245 	if(errorCode)
   246 		{
   247 		INFO_PRINTF2(_L("SetBalance() during Primed State is failed with  %d "), errorCode);
   248 		return EFail;
   249 		}
   250 	errorCode =theAudioDevice.GetBalance( theNewBalance );
   251 	if(errorCode)
   252 	       {
   253 		INFO_PRINTF2(_L("GetBalance() during Primed State is failed with  %d "), errorCode);
   254 		return EFail;
   255 		}
   256 	 if( theNewBalance != theBalance )
   257 		{
   258 		INFO_PRINTF1(_L("Set and Get Balances are different during Primed State"));
   259 		return EFail;
   260 		}
   261 	errorCode = iController.Play();
   262 	if(errorCode)
   263 		{
   264 		INFO_PRINTF2(_L("Play() is failed with  %d "), errorCode);
   265 		return EInconclusive;
   266 		}
   267 	errorCode =theAudioDevice.SetBalance(theBalance);
   268 	if(errorCode)
   269 		{
   270 		INFO_PRINTF2(_L("SetBalance() during Playing State is failed with  %d "), errorCode);
   271 		iController.Stop();
   272 		return EFail;
   273 		}
   274 	errorCode =theAudioDevice.GetBalance(theNewBalance);
   275 	if(errorCode)
   276 		{
   277 		INFO_PRINTF2(_L("GetBalance() during Playing State is failed with  %d "), errorCode);
   278 		iController.Stop();
   279 		return EFail;
   280 		}
   281 	if(theNewBalance != theBalance)
   282 		{
   283 	       //stop the controller
   284 	       INFO_PRINTF1(_L("Set and Get Balances are different during Playing State"));
   285 	       iController.Stop();
   286 	       return EFail;
   287 		}
   288 	//get the play completion event
   289 	CActiveScheduler::Start();
   290 	return iTestStepResult;
   291 	}
   292 
   293 /**
   294 Test step constructor. It initialises its own name and the input filename
   295 */
   296 RTestStepAviPlayCtrlDuration::RTestStepAviPlayCtrlDuration(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
   297 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
   298 		{
   299 		
   300 		}
   301 
   302 /**
   303  Do the test step.This tests checks for the duration of the file in Stopped, Primed and Playing states. 
   304 */
   305 TVerdict RTestStepAviPlayCtrlDuration::DoTestStepL(void)
   306 	{
   307 	const TTimeIntervalMicroSeconds  KExpectedDuration = 6300000;
   308 	INFO_PRINTF1(_L("this step checks for duration of the file"));
   309 	TTimeIntervalMicroSeconds expectedDuration(KExpectedDuration);
   310 	TTimeIntervalMicroSeconds currentDuration;
   311 	TInt errorCode = iController.GetDuration(currentDuration);
   312 	if(errorCode)
   313 		{
   314 		INFO_PRINTF2(_L("DurationL() is failed with  %d "), errorCode);
   315 		return EFail;
   316 		}
   317 	else if(currentDuration != expectedDuration)
   318 		{
   319 		INFO_PRINTF2(_L("GetDuration() returned the wrong duration %d "), currentDuration. Int64());
   320 		return EFail;
   321 		}
   322 	errorCode = iController.Prime();
   323 	if(errorCode)
   324 		{
   325 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
   326 		return EInconclusive;
   327 		}
   328 	errorCode = iController.GetDuration(currentDuration);
   329 	if(errorCode)
   330 		{
   331 		INFO_PRINTF2(_L("DurationL() is failed with  %d "), errorCode);
   332 		return EFail;
   333 		}
   334 	else if(currentDuration != expectedDuration)
   335 		{
   336 		INFO_PRINTF2(_L("GetDuration() returned the wrong duration %d "), currentDuration. Int64());
   337 		return EFail;
   338 		}
   339 	errorCode = iController.Play();
   340 	if(errorCode)
   341 		{
   342 		INFO_PRINTF2(_L("Play() is failed with  %d "), errorCode);
   343 		return EInconclusive;
   344 		}
   345 	errorCode = iController.GetDuration(currentDuration);
   346 	if(errorCode)
   347 		{
   348 		INFO_PRINTF2(_L("DurationL() is failed with  %d "), errorCode);
   349 		iController.Stop();
   350 		return EFail;
   351 		}
   352 	else if(currentDuration != expectedDuration)
   353 		{
   354 		INFO_PRINTF2(_L("GetDuration() returned the wrong duration %d "), currentDuration. Int64());
   355 		iController.Stop();
   356 		return EFail;
   357 		}
   358 	return EPass;
   359 	}
   360 	
   361 /**
   362 Test step constructor. It initialises its own name and the input filename
   363 */
   364 RTestStepAviPlayCtrlPause::RTestStepAviPlayCtrlPause(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
   365 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
   366 	{
   367 		
   368 	}
   369 
   370 /**
   371 Do the test step. This tests the Pause functionality of the AviPlayController in Stopped, Primed and Playing 
   372 states and checks if it returns KErrNot Supported.
   373 */
   374 TVerdict RTestStepAviPlayCtrlPause::DoTestStepL(void)
   375 	{
   376 	INFO_PRINTF1(_L("this step tests Pause() API of AviPlayController "));
   377 	TInt errorCode = iController.Pause();
   378 	if(errorCode != KErrNotSupported)
   379 		{
   380 		INFO_PRINTF2(_L("Pause() during Stopped State is failed to return KErrNotSupported but returned %d "), errorCode);
   381 		return EFail;
   382 		}
   383 	errorCode = iController.Prime();
   384 	if(errorCode)
   385 		{
   386 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
   387 		return EInconclusive;
   388 		}
   389 	errorCode = iController.Pause();
   390 	if(errorCode != KErrNotSupported)
   391 		{
   392 		INFO_PRINTF2(_L("Pause() during Primed State is failed to return KErrNotSupported but returned %d "), errorCode);
   393 		return EFail;
   394 		}
   395 	errorCode = iController.Play();
   396 	if(errorCode)
   397 		{
   398 		INFO_PRINTF2(_L("Play() is failed with  %d "), errorCode);
   399 		return EInconclusive;
   400 		}
   401 	errorCode = iController.Pause();
   402 	if(errorCode != KErrNotSupported)
   403 		{
   404 		INFO_PRINTF2(_L("Pause() during Playing State is failed with  %d "), errorCode);
   405 		return EFail;
   406 		}
   407 	errorCode = iController.Play();
   408 	if(errorCode != KErrNotReady)
   409 		{
   410 		INFO_PRINTF2(_L("Play() after Pause() is failed with  %d "), errorCode);
   411 		return EFail;
   412 		}
   413 	//get the play completion event
   414 	CActiveScheduler::Start();
   415 	return iTestStepResult;
   416 	}
   417 	
   418 /**
   419 Test step constructor. It initialises its own name and the input filename
   420 */
   421 RTestStepAviPlayCtrlStop::RTestStepAviPlayCtrlStop(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
   422 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
   423 	{
   424 		
   425 	}
   426 
   427 /**
   428 Do the test step. This tests the Stop functionality of the AviPlayController in Stopped, Primed and Playing 
   429 states It expects KErrNotReady error if Stop is called during Stopped state.
   430 */
   431 TVerdict RTestStepAviPlayCtrlStop::DoTestStepL(void)
   432 	{
   433 	INFO_PRINTF1(_L("this step tests Stop() API of AviPlayController "));
   434 	TInt errorCode = iController.Stop();
   435 	if(errorCode)
   436 		{
   437 		INFO_PRINTF2(_L("Stop() during Stopped State is failed with %d "), errorCode);
   438 		return EFail;
   439 		}
   440 	errorCode = iController.Prime();
   441 	if(errorCode)
   442 		{
   443 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
   444 		return EInconclusive;
   445 		}
   446 	errorCode = iController.Stop();
   447 	if(errorCode)
   448 		{
   449 		INFO_PRINTF2(_L("Stop() during Primed State is failed with %d "), errorCode);
   450 		return EFail;
   451 		}
   452 	errorCode = iController.Prime();
   453 	if(errorCode)
   454 		{
   455 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
   456 		return EInconclusive;
   457 		}
   458 	errorCode = iController.Play();
   459 	if(errorCode)
   460 		{
   461 		INFO_PRINTF2(_L("Play() is failed with  %d "), errorCode);
   462 		return EInconclusive;
   463 		}
   464 	User::After(2000000);
   465 	errorCode = iController.Stop();
   466 	if(errorCode)
   467 		{
   468 		INFO_PRINTF2(_L("Stop() during Playing State is failed with  %d "), errorCode);
   469 		return EFail;
   470 		}
   471 	errorCode = iController.Prime();
   472 	if(errorCode)
   473 		{
   474 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
   475 		return EInconclusive;
   476 		}
   477 	errorCode = iController.Play();
   478 	if(errorCode)
   479 		{
   480 		INFO_PRINTF2(_L("Play() after Stop() is failed with  %d "), errorCode);
   481 		iController.Stop();
   482 		return EInconclusive;
   483 		}
   484 	//get the play completion event
   485 	CActiveScheduler::Start();
   486 	return iTestStepResult;
   487 	}
   488 
   489 
   490 /**
   491 Test step constructor. It initialises its own name and the input filename
   492 */
   493 RTestStepAviPlayCtrlSetGetCropRegion::RTestStepAviPlayCtrlSetGetCropRegion(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
   494 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
   495 	{
   496 	
   497 	}
   498 
   499 /**
   500 Do the test step.This test tries to set and get the crop region for the file.
   501 */
   502  TVerdict RTestStepAviPlayCtrlSetGetCropRegion::DoTestStepL(void)
   503 	{
   504 	INFO_PRINTF1(_L("this step tests GetCropRegion() APIs of AviPlayController"));
   505 	TRect cropRegion(1,3,5,7);
   506 	TRect newCropRegion(1,3,5,7);
   507 	RMMFVideoPlayControllerCustomCommands thePlayCommander(iController);
   508 	TInt errorCode =thePlayCommander.SetCropRegion(cropRegion);
   509 	if(errorCode != KErrNotSupported)
   510 		{
   511 		INFO_PRINTF2(_L("SetCropRegion() during Stopped State is failed with  %d "), errorCode);
   512 		return EFail;
   513 		}
   514 	errorCode =thePlayCommander.GetCropRegion(newCropRegion);
   515 	if(errorCode != KErrNotSupported)
   516 		{
   517 		INFO_PRINTF2(_L("GetCropRegion() during Stopped State is failed with  %d "), errorCode);
   518 		return EFail;
   519 		}
   520 	errorCode = iController.Prime();
   521 	if(errorCode)
   522 		{
   523 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
   524 		return EInconclusive;
   525 		}
   526 	errorCode =thePlayCommander.SetCropRegion(cropRegion);
   527 	if(errorCode != KErrNotSupported)
   528 		{
   529 		INFO_PRINTF2(_L("SetCropRegion() during primed State is failed with  %d "), errorCode);
   530 		return EFail;
   531 		}
   532 	errorCode =thePlayCommander.GetCropRegion(newCropRegion);
   533 	if(errorCode != KErrNotSupported)
   534 		{
   535 		INFO_PRINTF2(_L("GetCropRegion() during primed State is failed with  %d "), errorCode);
   536 		return EFail;
   537 		}
   538 	errorCode = iController.Play();
   539 	if(errorCode)
   540 		{
   541 		INFO_PRINTF2(_L("Play() is failed with  %d "), errorCode);
   542 		return EInconclusive;
   543 		}
   544 	errorCode =thePlayCommander.SetCropRegion(cropRegion);
   545 	if(errorCode != KErrNotSupported)
   546 		{
   547 		INFO_PRINTF2(_L("SetCropRegion() during play State is failed with  %d "), errorCode);
   548 		iController.Stop();
   549 		return EFail;
   550 		}
   551 	errorCode =thePlayCommander.GetCropRegion(newCropRegion);
   552 	if(errorCode != KErrNotSupported)
   553 		{
   554 		INFO_PRINTF2(_L("GetCropRegion() during play State is failed with  %d "), errorCode);
   555 		iController.Stop();
   556 		return EFail;
   557 		}
   558 	CActiveScheduler::Start();	
   559 	return EPass;
   560 	}
   561 
   562 /**
   563 Test step constructor. It initialises its own name and the input filename
   564 */
   565 RTestStepAviPlayCtrlSetGetFrameRate::RTestStepAviPlayCtrlSetGetFrameRate(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
   566 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
   567 	{
   568 		
   569 	}
   570 
   571 /**
   572 Do the test step.This test tries to set and get the framerate for the file
   573 */
   574 TVerdict RTestStepAviPlayCtrlSetGetFrameRate::DoTestStepL(void)
   575 	{
   576 	INFO_PRINTF1(_L("this step tests SetFrameRate/GetFrameRate() APIs of AviPlayController"));
   577 	TInt KFrameRate = 10;
   578 	TReal32 frameRate(KFrameRate);
   579 	TReal32 expectedFrameRate(KFrameRate) ;
   580 	RMMFVideoControllerCustomCommands theVideoCommander(iController);
   581 	TInt errorCode =theVideoCommander.SetFrameRate(frameRate);
   582 	if(errorCode != KErrNotSupported)
   583 		{
   584 		INFO_PRINTF2(_L("SetFrameRate() during Stopped State is failed with  %d "), errorCode);
   585 		return EFail;
   586 		}	
   587 	errorCode =theVideoCommander.GetFrameRate(expectedFrameRate);
   588 	if(errorCode)
   589 		{
   590 		INFO_PRINTF2(_L("GetFrameRate() during Stopped State is failed with  %d "), errorCode);
   591 		return EFail;
   592 		}
   593 	if(expectedFrameRate != KFrameRate)
   594 		{
   595 	        INFO_PRINTF1(_L("Set and Get Framerates are different during Stopped State"));
   596 	        return EFail;
   597 		}
   598 	errorCode = iController.Prime();
   599 	if(errorCode)
   600 		{
   601 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
   602 		return EInconclusive;
   603 		}
   604 	errorCode =theVideoCommander.SetFrameRate(frameRate);
   605 	if(errorCode != KErrNotSupported)
   606 		{
   607 		INFO_PRINTF2(_L("SetFrameRate() during Primed State is failed with  %d "), errorCode);
   608 		return EFail;
   609 		}	
   610 	errorCode =theVideoCommander.GetFrameRate(expectedFrameRate);
   611 	if(errorCode)
   612 		{
   613 		INFO_PRINTF2(_L("GetFrameRate() during Primed State is failed with  %d "), errorCode);
   614 		return EFail;
   615 		}
   616 	if(expectedFrameRate != KFrameRate)
   617 		{
   618 	       INFO_PRINTF1(_L("Set and Get Framerates are different during Primed State"));
   619 	       return EFail;
   620 		}
   621 	errorCode = iController.Play();
   622 	if(errorCode)
   623 		{
   624 		INFO_PRINTF2(_L("Play() is failed with  %d "), errorCode);
   625 		iController.Stop();
   626 		return EInconclusive;
   627 		}
   628 	//try getting framerate inPlaying State
   629 	errorCode =theVideoCommander.SetFrameRate(frameRate);
   630 	if(errorCode != KErrNotSupported)
   631 		{
   632 		INFO_PRINTF2(_L("SetFrameRate() during Playing State is failed with  %d "), errorCode);
   633 		iController.Stop();
   634 		return EFail;
   635 		}	
   636 	errorCode =theVideoCommander.GetFrameRate(expectedFrameRate);
   637 	if(errorCode)
   638 		{
   639 		INFO_PRINTF2(_L("GetFrameRate() during Playing State is failed with  %d "), errorCode);
   640 		iController.Stop();
   641 		return EFail;
   642 		}
   643 	if(expectedFrameRate != KFrameRate)
   644 		{
   645 	        INFO_PRINTF1(_L("Set and Get Framerates are different during Playing State"));
   646 	        return EFail;
   647 		}
   648 	CActiveScheduler::Start();	
   649 	return EPass;
   650 	}
   651 
   652 
   653 /**
   654 Test step constructor. It initialises its own name and the input filename
   655 */
   656 RTestStepAviPlayCtrlGetFrameSize::RTestStepAviPlayCtrlGetFrameSize(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
   657 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
   658 	{
   659 	
   660 	}
   661 
   662 /**
   663 Do the test step.This test tries to get the framesize from the file.
   664 */
   665 TVerdict RTestStepAviPlayCtrlGetFrameSize::DoTestStepL(void)
   666 	{
   667 	INFO_PRINTF1(_L("this step tests GetFrameSize() APIs of AviPlayController"));
   668 	TSize frameSize(0,0);
   669 	TSize expectedFrameSize(176,144);
   670 	RMMFVideoControllerCustomCommands theVideoCommander(iController);
   671 	TInt errorCode =theVideoCommander.GetVideoFrameSize(frameSize);
   672 	if(errorCode)
   673 		{
   674 		INFO_PRINTF2(_L("GetFrameSize() during Stopped State is failed with  %d "), errorCode);
   675 		return EFail;
   676 		}
   677 	if(frameSize != expectedFrameSize)
   678 		{
   679 	        INFO_PRINTF1(_L("Frame sizes are different during Stopped states"));
   680 	        return EFail;
   681 		}
   682 	errorCode = iController.Prime();
   683 	if(errorCode)
   684 		{
   685 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
   686 		return EInconclusive;
   687 		}
   688 	errorCode =theVideoCommander.GetVideoFrameSize(frameSize);
   689 	if(errorCode)
   690 		{
   691 		INFO_PRINTF2(_L("GetFrameSize() during primed State is failed with  %d "), errorCode);
   692 		return EFail;
   693 		}
   694 	if( frameSize != expectedFrameSize )
   695 		{
   696 	        INFO_PRINTF1(_L("Frame sizes are different during Primed state"));
   697 	        return EFail;
   698 		}
   699 	errorCode = iController.Play();
   700 	if(errorCode)
   701 		{
   702 		INFO_PRINTF2(_L("Play is failed with  %d "), errorCode);
   703 		iController.Stop();
   704 		return EInconclusive;
   705 		}
   706 	errorCode =theVideoCommander.GetVideoFrameSize(frameSize);
   707 	if(errorCode)
   708 		{
   709 		INFO_PRINTF2(_L("GetFrameSize() during play State is failed with  %d "), errorCode);
   710 		iController.Stop();
   711 		return EFail;
   712 		}
   713 	if( frameSize != expectedFrameSize )
   714 		{
   715 	        INFO_PRINTF1(_L("Frame sizes are different during play state"));
   716 	        iController.Stop();
   717 	        return EFail;
   718 		}
   719 	//get the play completion event
   720 	CActiveScheduler::Start();
   721 	return EPass;
   722 	}
   723 
   724 
   725 /**
   726 Test step constructor. It initialises its own name and the input filename
   727 */
   728 RTestStepAviPlayCtrlGetAudioDataType::RTestStepAviPlayCtrlGetAudioDataType(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
   729 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
   730 	{
   731 
   732 	}
   733 
   734 /**
   735 Do the test step.This test tries to get the audio data type from the avi file.
   736 */
   737  TVerdict RTestStepAviPlayCtrlGetAudioDataType::DoTestStepL()
   738 	{
   739 	INFO_PRINTF1(_L("this step tests GetAudioType() and GetAudioBitRate() APIs of AviPlayController"));
   740 	TFourCC audioCodec;
   741 	TFourCC expectedAudioCodec(KMMFFourCCCodePCM16);
   742 	TInt errorCode = 0;
   743 	TInt bitRate = 705600;
   744 	TInt newBitRate =0;
   745 	RMMFVideoPlayControllerCustomCommands thePlayCommander(iController);
   746 	TBool enabled(EFalse);
   747 	thePlayCommander.GetAudioEnabled(enabled);
   748 	if(!enabled)
   749 		{
   750 		INFO_PRINTF2(_L("GetAudioEnabled() is failed with  %d "), errorCode);
   751 		return EInconclusive;
   752 		}	
   753 	RMMFVideoControllerCustomCommands theCommander(iController);
   754 	errorCode =theCommander.GetAudioCodec(audioCodec);
   755 	if(errorCode)
   756 		{
   757 		INFO_PRINTF2(_L("GetAudioCodec() during Stopped State is failed with  %d "), errorCode);
   758 		return EFail;
   759 		}
   760 	if( audioCodec != expectedAudioCodec )
   761 		{
   762 	        INFO_PRINTF1(_L("Wrong audio codec was returned"));
   763 	        return EFail;
   764 		}
   765 	errorCode = theCommander.GetAudioBitRate(newBitRate);
   766 	if(errorCode)
   767 		{
   768 		INFO_PRINTF2(_L("GetAudioBitRate() during Stopped State is failed with  %d "), errorCode);
   769 		return EFail;
   770 		}
   771 	if(newBitRate != bitRate )
   772 		{
   773 	        INFO_PRINTF1(_L("Wrong audio bitrate was returned"));
   774 	        return EFail;
   775 		}	
   776 	errorCode = iController.Prime();
   777 	if(errorCode)
   778 		{
   779 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
   780 		return EInconclusive;
   781 		}
   782 	//Check for audio codec
   783 	errorCode =theCommander.GetAudioCodec(audioCodec);
   784 	if(errorCode)
   785 		{
   786 		INFO_PRINTF2(_L("GetAudioCodec() during primed  State is failed with  %d "), errorCode);
   787 		return EFail;
   788 		}
   789 	if( audioCodec != expectedAudioCodec )
   790 		{
   791 	        INFO_PRINTF1(_L("Wrong audio codec was  returned"));
   792 	        return EFail;
   793 		}
   794 	errorCode = theCommander.GetAudioBitRate(newBitRate);
   795 	if(errorCode)
   796 		{
   797 		INFO_PRINTF2(_L("GetAudioBitRate() during primed  State is failed with  %d "), errorCode);
   798 		return EFail;
   799 		}
   800 	if(newBitRate != bitRate )
   801 		{
   802 	        INFO_PRINTF1(_L("Wrong audio bitrate was returned"));
   803 	        return EFail;
   804 		}		
   805 	errorCode = iController.Play();						
   806 	//Check for audio codec
   807 	errorCode =theCommander.GetAudioCodec(audioCodec);
   808 	if(errorCode)
   809 		{
   810 		INFO_PRINTF2(_L("GetAudioCodec() during play State is failed with  %d "), errorCode);
   811 		iController.Stop();
   812 		return EFail;
   813 		}
   814 	if( audioCodec != expectedAudioCodec )
   815 		{
   816 	        INFO_PRINTF1(_L("Wrong audio codec was returned"));
   817 	        iController.Stop();
   818 	        return EFail;
   819 		}
   820 	errorCode = theCommander.GetAudioBitRate(newBitRate);
   821 	if(errorCode)
   822 		{
   823 		INFO_PRINTF2(_L("GetAudioBitRate() during play State is failed with  %d "), errorCode);
   824 		iController.Stop();
   825 		return EFail;
   826 		}
   827 	if(newBitRate != bitRate )
   828 		{
   829 	        INFO_PRINTF1(_L("Wrong audio bitrate was returned"));
   830 	        iController.Stop();
   831 	        return EFail;
   832 		}		
   833 	CActiveScheduler::Start();	
   834 	return EPass;			
   835 	}
   836  
   837 	
   838 /**
   839 Test step constructor. It initialises its own name and the input filename
   840 */
   841 RTestStepAviPlayCtrlGetVideoDataType::RTestStepAviPlayCtrlGetVideoDataType(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
   842 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
   843 	{
   844 	
   845 	}
   846 /**
   847 Do the test step.This test tries to get the video mime type
   848 */
   849 TVerdict RTestStepAviPlayCtrlGetVideoDataType::DoTestStepL(void)
   850 	{
   851 	const TInt KBufferSize = 256;
   852 	INFO_PRINTF1(_L("this step tests GetVideoMimeType() APIs of AviPlayController"));
   853 	HBufC8* iMimeType = HBufC8::NewL(KBufferSize);
   854 	TPtr8 des = iMimeType->Des();
   855 	TInt errorCode = 0;
   856 	char xv[]="XVID";
   857 	TUint8* p = (TUint8*)xv;
   858 	TPtrC8 temp(p);	
   859 	RMMFVideoControllerCustomCommands theCommander(iController);
   860 	errorCode =theCommander.GetVideoMimeType(des);
   861 	if(errorCode)
   862 		{
   863 		INFO_PRINTF2(_L("GetVideoMimeType() during Stopped State is failed with  %d "), errorCode);
   864 		return EFail;
   865 		}
   866 	if (des.Compare(temp))
   867 		{
   868 	       INFO_PRINTF1(_L("Wrong video mime type returned"));
   869 	       return EFail;
   870 		}
   871 	else
   872 		{
   873 		INFO_PRINTF1(_L("Correct video mime type returned"));	
   874 		}	
   875 	errorCode = iController.Prime();
   876 	if(errorCode)
   877 		{
   878 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
   879 		return EInconclusive;
   880 		}
   881 	errorCode =theCommander.GetVideoMimeType(des);
   882 	if(errorCode)
   883 		{
   884 		INFO_PRINTF2(_L("GetVideoMimeType() during primed State is failed with  %d "), errorCode);
   885 		return EFail;
   886 		}
   887 	if (des.Compare(temp))
   888 		{
   889 	       INFO_PRINTF1(_L("Wrong video mime type returned"));
   890 	       return EFail;
   891 		}
   892 	else
   893 		{
   894 		INFO_PRINTF1(_L("Correct video mime type returned"));	
   895 		}	
   896 			
   897 	errorCode = iController.Play();
   898 	if(errorCode)
   899 		{
   900 		INFO_PRINTF2(_L("Play is failed with  %d "), errorCode);
   901 		return EInconclusive;
   902 		}
   903 	errorCode =theCommander.GetVideoMimeType(des);
   904 	if(errorCode)
   905 		{
   906 		INFO_PRINTF2(_L("GetVideoMimeType() during play State is failed with  %d "), errorCode);
   907 		return EFail;
   908 		}
   909 	if (des.Compare(temp))
   910 		{
   911 	       INFO_PRINTF1(_L("Wrong video mime type returned"));
   912 	       return EFail;
   913 		}
   914 	else
   915 		{
   916 		INFO_PRINTF1(_L("Correct video mime type returned"));	
   917 		}
   918 	CActiveScheduler::Start();		
   919 	return EPass;	
   920 	}
   921 
   922 	
   923 /**
   924 Test step constructor. It initialises its own name and the input filename
   925 */
   926 RTestStepAviPlayCtrlMetaData::RTestStepAviPlayCtrlMetaData(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
   927 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
   928 	{
   929 		
   930 	}
   931 
   932 /**
   933 Do the test step.This test tries to fetch the metadata from the avi file.
   934 */
   935 TVerdict RTestStepAviPlayCtrlMetaData::DoTestStepL(void)
   936 	{
   937 	INFO_PRINTF1(_L("this step tests GetNumberOfMetaDataEntries/GetMetaDataEntryL() APIs of AviPlayController "));
   938 	TInt numEntries = 0;
   939 	TInt errorCode = iController.GetNumberOfMetaDataEntries( numEntries );
   940 	CMMFMetaDataEntry* metaEntry = NULL;
   941 	if(errorCode != KErrNotSupported)
   942 		{
   943 		INFO_PRINTF2(_L("GetNumberOfMetaDataEntries() is failed with  %d "), errorCode);
   944 		return EFail;
   945 	 	}
   946 	if(numEntries == 0)
   947 		{
   948 		INFO_PRINTF1(_L("File does not have meta entries "));
   949 		}
   950 	else
   951 		{
   952 		for(TInt counter = 0; counter < numEntries; ++counter)
   953         		{
   954 		      	TRAP(errorCode, metaEntry =  iController.GetMetaDataEntryL(counter));
   955 		      	if(errorCode)
   956 		      		{
   957 		      		INFO_PRINTF2(_L("GetMetaDataEntryL is failed with  %d "), errorCode);
   958 		      		return EFail;
   959 		      		}
   960 		      	INFO_PRINTF3(_L("%S    %S"), &metaEntry->Name(), &metaEntry->Value());
   961         		}
   962 		}
   963 	return EPass;
   964 	}
   965 
   966 /**
   967 Test step constructor. It initialises its own name and the input filename
   968 */
   969 RTestStepAviPlayCtrlSetGetRotation::RTestStepAviPlayCtrlSetGetRotation(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
   970 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
   971 	{
   972 		
   973 	}
   974 
   975 /**
   976 Do the test step.This test tries to set and get the rotation
   977 */
   978 TVerdict RTestStepAviPlayCtrlSetGetRotation::DoTestStepL(void)	
   979 	{
   980 	INFO_PRINTF1(_L("this step tests SetRotation/GetRotation() APIs of AviPlayController"));
   981 	TVideoRotation aRotation;
   982 	RMMFVideoPlayControllerCustomCommands theVideoPlayCommander(iController);
   983 	TInt errorCode = theVideoPlayCommander.SetRotation(EVideoRotationClockwise90);
   984 	if(errorCode != KErrNotSupported)
   985 		{
   986 		INFO_PRINTF2(_L("SetRotation() during Stopped State is failed with  %d "), errorCode);
   987 		return EFail;
   988 		}	
   989 	errorCode =theVideoPlayCommander.GetRotation(aRotation);
   990 	if(errorCode != KErrNotSupported)
   991 		{
   992 		INFO_PRINTF2(_L("GetRotation() during Stopped State is failed with  %d "), errorCode);
   993 		return EFail;
   994 		}
   995 	errorCode = iController.Prime();
   996 	if(errorCode)
   997 		{
   998 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
   999 		return EInconclusive;
  1000 		}
  1001 	errorCode =theVideoPlayCommander.SetRotation(EVideoRotationClockwise90);	
  1002 	if(errorCode != KErrNotSupported)
  1003 		{
  1004 		INFO_PRINTF2(_L("SetRotation() during Primed State is failed with  %d "), errorCode);
  1005 		return EFail;
  1006 		}	
  1007 	errorCode =theVideoPlayCommander.GetRotation(aRotation);
  1008 	if(errorCode != KErrNotSupported)
  1009 		{
  1010 		INFO_PRINTF2(_L("GetRotation() during Primed State is failed with  %d "), errorCode);
  1011 		return EFail;
  1012 		}
  1013 	errorCode = iController.Play();
  1014 	if(errorCode)
  1015 		{
  1016 		INFO_PRINTF2(_L("Play is failed with  %d "), errorCode);
  1017 		return EInconclusive;
  1018 		}
  1019 	errorCode =theVideoPlayCommander.SetRotation(EVideoRotationClockwise90);	
  1020 	if(errorCode != KErrNotSupported)
  1021 		{
  1022 		INFO_PRINTF2(_L("SetRotation() during Play State is failed with  %d "), errorCode);
  1023 		return EFail;
  1024 		}	
  1025 	errorCode =theVideoPlayCommander.GetRotation(aRotation);
  1026 	if(errorCode != KErrNotSupported)
  1027 		{
  1028 		INFO_PRINTF2(_L("GetRotation() during Play State is failed with  %d "), errorCode);
  1029 		iController.Stop();
  1030 		return EFail;
  1031 		}
  1032 	CActiveScheduler::Start();
  1033 	return EPass;					
  1034 	}
  1035 	
  1036 /**
  1037 Test step constructor. It initialises its own name and the input filename
  1038 */
  1039 RTestStepAviPlayCtrlSetGetScaling::RTestStepAviPlayCtrlSetGetScaling(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  1040 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
  1041 	{
  1042 		
  1043 	}
  1044 
  1045 /**
  1046 * Do the test step.This test tries to do the scaling and expect KErrNotsupported
  1047 */
  1048 TVerdict RTestStepAviPlayCtrlSetGetScaling::DoTestStepL(void)	
  1049 	{
  1050 	INFO_PRINTF1(_L("this step tests SetScaling/GetScaling() APIs of AviPlayController"));
  1051 	TReal32 aWidthPercentage = .75;
  1052 	TReal32 aHeightPercentage = .3;
  1053 	TBool aAntiAliasFiltering = EFalse;
  1054 	
  1055 	RMMFVideoPlayControllerCustomCommands theVideoPlayCommander(iController);
  1056 	TInt errorCode = theVideoPlayCommander.SetScaleFactor(aWidthPercentage,aHeightPercentage,aAntiAliasFiltering);
  1057 	if(errorCode != KErrNotSupported)
  1058 		{
  1059 		INFO_PRINTF2(_L("SetScaleFactor() during Stopped State is failed with  %d "), errorCode);
  1060 		return EFail;
  1061 		}	
  1062 	errorCode =theVideoPlayCommander.GetScaleFactor(aWidthPercentage,aHeightPercentage,aAntiAliasFiltering);
  1063 	if(errorCode != KErrNotSupported)
  1064 		{
  1065 		INFO_PRINTF2(_L("GetScaleFactor() during Stopped State is failed with  %d "), errorCode);
  1066 		return EFail;
  1067 		}
  1068 	errorCode = iController.Prime();
  1069 	if(errorCode)
  1070 		{
  1071 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
  1072 		return EInconclusive;
  1073 		}
  1074 	errorCode = theVideoPlayCommander.SetScaleFactor(aWidthPercentage,aHeightPercentage,aAntiAliasFiltering);
  1075 	if(errorCode != KErrNotSupported)
  1076 		{
  1077 		INFO_PRINTF2(_L("SetScaleFactor() during primed State is failed with  %d "), errorCode);
  1078 		return EFail;
  1079 		}	
  1080 	errorCode =theVideoPlayCommander.GetScaleFactor(aWidthPercentage,aHeightPercentage,aAntiAliasFiltering);
  1081 	if(errorCode != KErrNotSupported)
  1082 		{
  1083 		INFO_PRINTF2(_L("GetScaleFactor() during primed State is failed with  %d "), errorCode);
  1084 		return EFail;
  1085 		}
  1086 	errorCode = iController.Play();
  1087 	if(errorCode)
  1088 		{
  1089 		INFO_PRINTF2(_L("Play is failed with  %d "), errorCode);
  1090 		return EInconclusive;
  1091 		}
  1092 	errorCode = theVideoPlayCommander.SetScaleFactor(aWidthPercentage,aHeightPercentage,aAntiAliasFiltering);
  1093 	if(errorCode != KErrNotSupported)
  1094 		{
  1095 		INFO_PRINTF2(_L("SetScaleFactor() during play  State is failed with  %d "), errorCode);
  1096 		return EFail;
  1097 		}	
  1098 	errorCode =theVideoPlayCommander.GetScaleFactor(aWidthPercentage,aHeightPercentage,aAntiAliasFiltering);
  1099 	if(errorCode != KErrNotSupported)
  1100 		{
  1101 		INFO_PRINTF2(_L("GetScaleFactor() during play  State is failed with  %d "), errorCode);
  1102 		iController.Stop();
  1103 		return EFail;
  1104 		}
  1105 	CActiveScheduler::Start();
  1106 	return EPass;					
  1107 	}
  1108 	
  1109 /**
  1110 Test step constructor. It initialises its own name and the input filename
  1111 */
  1112 RTestStepAviPlayCtrlSetPosition::RTestStepAviPlayCtrlSetPosition(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  1113 	:RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
  1114 		{
  1115 		
  1116 		}
  1117 
  1118 /**
  1119  Do the test step.This test tries to set the position in the file and expect KErrNotSupported
  1120  */
  1121 TVerdict RTestStepAviPlayCtrlSetPosition::DoTestStepL(void)	
  1122 	{
  1123 	INFO_PRINTF1(_L("this step tests SetPosition() APIs of AviPlayController"));
  1124 	TTimeIntervalMicroSeconds aPosition;
  1125 	TInt errorCode = KErrNone;
  1126 	errorCode = iController.SetPosition(aPosition);
  1127 	if(errorCode != KErrNotSupported)
  1128 		{
  1129 		INFO_PRINTF2(_L("SetPosition() during Stopped State is failed with  %d "), errorCode);
  1130 		return EFail;
  1131 		}	
  1132 	errorCode = iController.Prime();
  1133 	if(errorCode)
  1134 		{
  1135 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
  1136 		return EInconclusive;
  1137 		}
  1138 	errorCode = iController.SetPosition(aPosition);
  1139 	if(errorCode != KErrNotSupported)
  1140 		{
  1141 		INFO_PRINTF2(_L("SetPosition() during Primed State is failed with  %d "), errorCode);
  1142 		return EFail;
  1143 		}	
  1144 	errorCode = iController.Play();
  1145 	if(errorCode)
  1146 		{
  1147 		INFO_PRINTF2(_L("Play is failed with  %d "), errorCode);
  1148 		return EInconclusive;
  1149 		}
  1150 	errorCode = iController.SetPosition(aPosition);
  1151 	if(errorCode != KErrNotSupported)
  1152 		{
  1153 		INFO_PRINTF2(_L("SetPosition() during Playing State is failed with  %d "), errorCode);
  1154 		iController.Stop();
  1155 		return EFail;
  1156 		}	
  1157 	CActiveScheduler::Start();
  1158 	return EPass;					
  1159 	}
  1160 
  1161 
  1162 /**
  1163 Test step constructor. It initialises its own name and the input filename
  1164 */
  1165 RTestStepAviPlayCtrlGetVideoBitrate::RTestStepAviPlayCtrlGetVideoBitrate(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  1166 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
  1167 	{
  1168 		
  1169 	}
  1170 
  1171 /**
  1172 Do the test step.This test tries to get the bitrate from the file
  1173 */
  1174 TVerdict RTestStepAviPlayCtrlGetVideoBitrate::DoTestStepL(void)
  1175 	{
  1176 	INFO_PRINTF1(_L("this step tests GetVideoBitrate() APIs of AviPlayController"));
  1177 	TInt aBitRate;
  1178 	RMMFVideoControllerCustomCommands theVideoCommander(iController);
  1179 	TInt errorCode =theVideoCommander.GetVideoBitRate(aBitRate);
  1180 	if(errorCode != KErrNotSupported)
  1181 		{
  1182 		INFO_PRINTF2(_L("GetVideoBitRate() during Stopped State is failed with  %d "), errorCode);
  1183 		return EFail;
  1184 		}
  1185 	else
  1186 		{
  1187 		INFO_PRINTF2(_L("GetVideoBitRate() during Stopped State returned KErrNotSupported %d "), errorCode);	
  1188 		}		
  1189 	errorCode = iController.Prime();
  1190 	if(errorCode)
  1191 		{
  1192 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
  1193 		return EInconclusive;
  1194 		}
  1195 	errorCode =theVideoCommander.GetVideoBitRate(aBitRate);
  1196 	if(errorCode != KErrNotSupported)
  1197 		{
  1198 		INFO_PRINTF2(_L("GetVideoBitRate() during Primed State is failed with  %d "), errorCode);
  1199 		return EFail;
  1200 		}
  1201 	else
  1202 		{
  1203 		INFO_PRINTF2(_L("GetVideoBitRate() during Primed State returned KErrNotSupported %d "), errorCode);	
  1204 		}		
  1205 	errorCode = iController.Play();
  1206 	if(errorCode)
  1207 		{
  1208 		INFO_PRINTF2(_L("Play() is failed with  %d "), errorCode);
  1209 		iController.Stop();
  1210 		return EInconclusive;
  1211 		}
  1212 	errorCode =theVideoCommander.GetVideoBitRate(aBitRate);
  1213 	if(errorCode != KErrNotSupported)
  1214 		{
  1215 		INFO_PRINTF2(_L("GetVideoBitRate() during Playing State is failed with  %d "), errorCode);
  1216 		iController.Stop();
  1217 		return EFail;
  1218 		}	
  1219 	else
  1220 		{
  1221 		INFO_PRINTF2(_L("GetVideoBitRate() during Play State returned KErrNotSupported %d "), errorCode);	
  1222 		}			
  1223 	CActiveScheduler::Start();	
  1224 	return EPass;
  1225 	}
  1226 
  1227 /**
  1228 Test step constructor. It initialises its own name and the input filename
  1229 */
  1230 RTestStepAviPlayCtrlGetAudioBitrate::RTestStepAviPlayCtrlGetAudioBitrate(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  1231 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
  1232 	{
  1233 		
  1234 	}
  1235 
  1236 /**
  1237 Do the test step.This test tries to fetch the audio bit rate.
  1238 */
  1239 TVerdict RTestStepAviPlayCtrlGetAudioBitrate::DoTestStepL(void)
  1240 	{
  1241 	INFO_PRINTF1(_L("this step tests GetAudioBitrate() APIs of AviPlayController"));
  1242 	TInt audioBitRate;
  1243 	RMMFVideoControllerCustomCommands theVideoCommander(iController);
  1244 	TInt errorCode =theVideoCommander.GetAudioBitRate(audioBitRate);
  1245 	if(errorCode != KErrNotSupported)
  1246 		{
  1247 		INFO_PRINTF2(_L("GetAudioBitRate() during Stopped State is failed with  %d "), errorCode);
  1248 		return EFail;
  1249 		}
  1250 	else
  1251 		{
  1252 		INFO_PRINTF2(_L("GetAudioBitRate() during Stopped State returned KErrNotSupported %d "), errorCode);	
  1253 		}					
  1254 	errorCode = iController.Prime();
  1255 	if(errorCode)
  1256 		{
  1257 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
  1258 		return EInconclusive;
  1259 		}
  1260 	else
  1261 		{
  1262 		INFO_PRINTF2(_L("GetAudioBitRate() during Primed State returned KErrNotSupported %d "), errorCode);	
  1263 		}						
  1264 	errorCode =theVideoCommander.GetAudioBitRate(audioBitRate);
  1265 	if(errorCode != KErrNotSupported)
  1266 		{
  1267 		INFO_PRINTF2(_L("GetAudioBitRate() during Primed State is failed with  %d "), errorCode);
  1268 		return EFail;
  1269 		}	
  1270 	errorCode = iController.Play();
  1271 	if(errorCode)
  1272 		{
  1273 		INFO_PRINTF2(_L("Play() is failed with  %d "), errorCode);
  1274 		iController.Stop();
  1275 		return EInconclusive;
  1276 		}
  1277 	//try getting framerate inPlaying State
  1278 	errorCode =theVideoCommander.GetAudioBitRate(audioBitRate);
  1279 	if(errorCode != KErrNotSupported)
  1280 		{
  1281 		INFO_PRINTF2(_L("GetAudioBitRate() during Playing State is failed with  %d "), errorCode);
  1282 		iController.Stop();
  1283 		return EFail;
  1284 		}
  1285 	else
  1286 		{
  1287 		INFO_PRINTF2(_L("GetAudioBitRate() during Playing State returned KErrNotSupported %d "), errorCode);	
  1288 		}								
  1289 	CActiveScheduler::Start();	
  1290 	return EPass;
  1291 	}
  1292 	
  1293 /**
  1294 Test step constructor. It initialises its own name and the input filename
  1295 */
  1296 RTestStepAviCtrlDirectScreenAccess::RTestStepAviCtrlDirectScreenAccess(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  1297 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
  1298 	{
  1299 	
  1300 	}
  1301 
  1302 /**
  1303 This test code tries to check the direct screen access property.
  1304 */	
  1305 TVerdict RTestStepAviCtrlDirectScreenAccess::DoTestStepL(void)
  1306 	{	
  1307 	INFO_PRINTF1(_L("this step tests DirectScreenAccessL of AviPlayController when audio not enabled"));
  1308 	RMMFVideoPlayControllerCustomCommands theVideoCommander(iController);
  1309 	TMMFDSAEvent  dsaEvent1 = EAbortDSA;
  1310 	TMMFDSAEvent  dsaEvent2 = EResumeDSA;
  1311 	TInt errorCode = iController.Prime();
  1312 	if(errorCode)
  1313 		{
  1314 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
  1315 		return EInconclusive;
  1316 		} 
  1317 	errorCode = theVideoCommander.DirectScreenAccessEvent(dsaEvent2);	
  1318 	if(errorCode)
  1319 		{
  1320 		INFO_PRINTF2(_L("DirectScreenAccessEvent() is failed during primed state  %d "), errorCode);
  1321 		return EInconclusive;
  1322 		}
  1323 	errorCode = iController.Play();
  1324 	if(errorCode)
  1325 	 	{
  1326     	INFO_PRINTF2(_L("Play() is failed with  %d "), errorCode);
  1327     	return EInconclusive;
  1328     	}
  1329 	errorCode = theVideoCommander.DirectScreenAccessEvent(dsaEvent1);	
  1330 	if(errorCode)
  1331 		{
  1332 		INFO_PRINTF2(_L("DirectScreenAccessEvent() is failed during primed state  %d "), errorCode);
  1333 		return EInconclusive;
  1334 		}
  1335 	CActiveScheduler::Start();	
  1336 	return iTestStepResult;
  1337 	}
  1338 
  1339 /**
  1340 Test step constructor. It initialises its own name and the input filename
  1341 */
  1342 RTestStepAviCtrlSetPlayWindow::RTestStepAviCtrlSetPlayWindow(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  1343 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
  1344 	{
  1345 	}
  1346 
  1347 /**
  1348 This test code tries to set the set playwindow and expects KErrNotSupported
  1349 */	
  1350 TVerdict RTestStepAviCtrlSetPlayWindow::DoTestStepL(void)
  1351 	{
  1352 	INFO_PRINTF1(_L("this step plays an avi file "));
  1353 	TInt errorCode = iController.Prime();
  1354 	if(errorCode)
  1355 		{
  1356 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
  1357 		return EFail;
  1358 		}
  1359 	RMMFVideoPlayControllerCustomCommands theVideoCommander(iController);	
  1360 	TTimeIntervalMicroSeconds theDuration;
  1361 	errorCode = iController.GetDuration(theDuration);
  1362 	if(errorCode)
  1363 		{
  1364 		INFO_PRINTF2(_L("DurationL() is failed with  %d "), errorCode);
  1365 		return EInconclusive;
  1366 		}
  1367 	TInt64 duration = theDuration. Int64();
  1368 	TTimeIntervalMicroSeconds thePlayStart(duration/2);
  1369 	TTimeIntervalMicroSeconds thePlayEnd(duration);
  1370 	errorCode = theVideoCommander.Play(thePlayStart, thePlayEnd);
  1371 	if(errorCode != KErrNotSupported)
  1372 		{
  1373 		INFO_PRINTF2(_L("Play() is failed with  %d "), errorCode);
  1374 		return EFail;
  1375 		}
  1376 	errorCode = iController.Play();
  1377 	if(errorCode)
  1378 		{
  1379 		INFO_PRINTF2(_L("Play() after SetPlayWindow() is failed with  %d "), errorCode);
  1380 		return EInconclusive;
  1381 		}	
  1382 	CActiveScheduler::Start();
  1383 	return iTestStepResult;
  1384 	}
  1385 	
  1386 //Negative Tests
  1387 /**
  1388 Test step constructor. It initialises its own name and the input filename
  1389 */
  1390 RTestStepAviCtrlPlayInvalid::RTestStepAviCtrlPlayInvalid(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  1391 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
  1392 	{
  1393 		
  1394 	}
  1395 
  1396 TVerdict RTestStepAviCtrlPlayInvalid::DoTestStepPreambleL(void)
  1397 	{
  1398 	return EPass;
  1399 	}
  1400 
  1401 /**
  1402 Do the test step(Negative Test).This test tries to open an invalid file. Expects KErrCurrupt from AviPlayController
  1403 */
  1404 TVerdict RTestStepAviCtrlPlayInvalid::DoTestStepL(void)
  1405     	{
  1406     	const TUid KAviPlayControllerUid   = {0x102737A5};
  1407 	INFO_PRINTF1(_L("This test tries to open an invalid file using AviPlayController"));
  1408 	iScheduler = new(ELeave)CActiveScheduler;
  1409          CleanupStack::PushL(iScheduler );
  1410 	CActiveScheduler::Install(iScheduler );
  1411 	CleanupStack::Pop();
  1412 	iPriority.iPriority = 11;  // set the priority to some default value
  1413 	iPriority.iPref = EMdaPriorityPreferenceQuality;
  1414 	iControllerEventMonitor = CMMFControllerEventMonitor::NewL(*this, iController);
  1415 	TInt errorCode = iController.Open(KAviPlayControllerUid, iPriority);
  1416 	 if(errorCode)
  1417 		{
  1418 		INFO_PRINTF2(_L("Failed to load the controller  %d "), errorCode);
  1419 		return EInconclusive;
  1420 		}
  1421 	 iControllerEventMonitor->Start();
  1422 	 SetupReadFileConfigL();
  1423 	 errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
  1424 	 if(errorCode != KErrCorrupt)
  1425 		{
  1426 		INFO_PRINTF2(_L("AddDataSource failed with  %d "), errorCode);
  1427 		return EFail;
  1428 		}
  1429 	 else
  1430 		{
  1431 		INFO_PRINTF2(_L("AddDataSource() returned KErrCorrupt with invalid .avi file %d "), errorCode);	
  1432 		return EPass;
  1433 		}
  1434 	}
  1435 
  1436 /**
  1437 Test step constructor. It initialises its own name and the input filename
  1438 */
  1439 RTestStepAviCtrlNotAudioEnabled::RTestStepAviCtrlNotAudioEnabled(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  1440 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
  1441 	{
  1442 		
  1443 	}
  1444 
  1445 /**
  1446 This test step tries to get the volume and balance from a file where audio is not enabled and expect KErrNotsupported
  1447 */
  1448 TVerdict RTestStepAviCtrlNotAudioEnabled::DoTestStepL(void)
  1449 	{
  1450 	TInt theNewBalance (0);
  1451 	TTimeIntervalMicroSeconds ramp(100);
  1452 	INFO_PRINTF1(_L("this step tests SetVolume/GetVolume() APIs of AviPlayController when audio not enabled"));
  1453 	RMMFAudioPlayDeviceCustomCommands theAudioDevice(iController);
  1454 	TInt maxVolume(0);
  1455 	TInt errorCode = theAudioDevice.GetMaxVolume(maxVolume);
  1456 	if(errorCode != KErrNotSupported)
  1457 		{
  1458 		INFO_PRINTF2(_L("GetMaxVolume() is failed with  %d "), errorCode);
  1459 		return EInconclusive;
  1460 		}
  1461 	TInt theVolume = maxVolume /2;
  1462 	 //try setting volume in Stopped State
  1463 	errorCode =theAudioDevice.SetVolume(theVolume);
  1464 	if(errorCode != KErrNotSupported)
  1465 		{
  1466 		INFO_PRINTF2(_L("SetVolume() during Stopped State is failed with  %d "), errorCode);
  1467 		return EFail;
  1468 		}
  1469 	TInt theNewVolume (0);
  1470 	errorCode =theAudioDevice.GetVolume(theNewVolume);
  1471 	if(errorCode != KErrNotSupported)
  1472 		{
  1473 		INFO_PRINTF2(_L("GetVolume() during Stopped State is failed with  %d "), errorCode);
  1474 		return EFail;
  1475 		}
  1476 	TInt theBalance = (30 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;
  1477 	errorCode = theAudioDevice.SetBalance(theBalance);
  1478 	if(errorCode != KErrNotSupported)
  1479 	    	{
  1480 	    	INFO_PRINTF2(_L("SetBalance() during Stopped State is failed with  %d "), errorCode);
  1481 	    	return EFail;
  1482 	    	}
  1483 	errorCode =theAudioDevice.GetBalance(theNewBalance);
  1484 	if(errorCode != KErrNotSupported)
  1485 		{
  1486 	    	INFO_PRINTF2(_L("GetBalance() during Stopped State is failed with  %d "), errorCode);
  1487 	    	return EFail;
  1488 	    	}
  1489 	 errorCode =theAudioDevice.SetVolumeRamp(ramp);
  1490 	 if(errorCode != KErrNotSupported)
  1491 		{
  1492 		INFO_PRINTF2(_L("SetVolumeRamp() during Stopped State is failed with  %d "), errorCode);
  1493 		return EFail;
  1494 		}	   		
  1495 	errorCode = iController.Prime();
  1496 	if(errorCode)
  1497 		{
  1498 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
  1499 		return EInconclusive;
  1500 		}
  1501 	  //try setting volume in Primed State
  1502 	errorCode =theAudioDevice.SetVolume(theVolume);
  1503 	if(errorCode != KErrNotSupported)
  1504 	 	{
  1505 	    	INFO_PRINTF2(_L("SetVolume() during Primed State is failed with  %d "), errorCode);
  1506 	    	return EFail;
  1507 	    	}
  1508 	errorCode =theAudioDevice.GetVolume(theNewVolume);
  1509 	if(errorCode != KErrNotSupported)
  1510 	    	{
  1511 	    	INFO_PRINTF2(_L("GetVolume() during Primed State is failed with  %d "), errorCode);
  1512 	    	return EFail;
  1513 	    	}
  1514 	errorCode =theAudioDevice.SetVolumeRamp(ramp);
  1515      if(errorCode != KErrNotSupported)
  1516 		{
  1517 		INFO_PRINTF2(_L("SetVolumeRamp() during primed State is failed with  %d "), errorCode);
  1518 		return EFail;
  1519 		}    	
  1520 	theBalance = (30 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;
  1521 	errorCode = theAudioDevice.SetBalance(theBalance);
  1522 	if(errorCode != KErrNotSupported)
  1523     	{
  1524     	INFO_PRINTF2(_L("SetBalance() during primed State is failed with  %d "), errorCode);
  1525     	return EFail;
  1526     	}
  1527 	errorCode =theAudioDevice.GetBalance(theNewBalance);
  1528 	if(errorCode != KErrNotSupported)
  1529 		{
  1530     	INFO_PRINTF2(_L("GetBalance() during primed State is failed with  %d "), errorCode);
  1531     	return EFail;
  1532 	    	}   	
  1533 	 errorCode = iController.Play();
  1534 	 if(errorCode)
  1535 	 	{
  1536     	INFO_PRINTF2(_L("Play() is failed with  %d "), errorCode);
  1537     	return EInconclusive;
  1538 	    	}
  1539 	    //try setting volume in Playing State
  1540 	 errorCode =theAudioDevice.SetVolume(theVolume);
  1541 	  if(errorCode!= KErrNotSupported)
  1542 	  	{
  1543     	INFO_PRINTF2(_L("SetVolume() during Playing State is failed with  %d "), errorCode);
  1544     	iController.Stop();
  1545     	return EFail;
  1546 	    	}
  1547 	 errorCode =theAudioDevice.GetVolume(theNewVolume);
  1548 	 if(errorCode!= KErrNotSupported)
  1549     	{
  1550     	INFO_PRINTF2(_L("GetVolume() during Playing State is failed with  %d "), errorCode);
  1551     	iController.Stop();
  1552     	return EFail;
  1553     	}
  1554 	errorCode =theAudioDevice.SetVolumeRamp(ramp);
  1555 	 if(errorCode != KErrNotSupported)
  1556 		{
  1557 		INFO_PRINTF2(_L("SetVolumeRamp() during play State is failed with  %d "), errorCode);
  1558 		return EFail;
  1559 		}    	
  1560 	theBalance = (30 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;
  1561 	errorCode = theAudioDevice.SetBalance(theBalance);
  1562 	if(errorCode != KErrNotSupported)
  1563     	{
  1564     	INFO_PRINTF2(_L("SetBalance() during playing State is failed with  %d "), errorCode);
  1565     	return EFail;
  1566     	}
  1567 	errorCode =theAudioDevice.GetBalance(theNewBalance);
  1568 	if(errorCode != KErrNotSupported)
  1569 		{
  1570     	INFO_PRINTF2(_L("GetBalance() during playing State is failed with  %d "), errorCode);
  1571     	return EFail;
  1572     	}	
  1573 	  //get the play completion event
  1574 	  CActiveScheduler::Start();
  1575 	  return iTestStepResult;
  1576 	}
  1577 	
  1578 /**
  1579 Test step constructor. It initialises its own name, input filename and the screen number.
  1580 */
  1581 RTestStepAviPlayCtrlSetScrnPlay::RTestStepAviPlayCtrlSetScrnPlay(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid, TInt aScreenNumber)
  1582 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
  1583 	{
  1584 	iScreenNumber = aScreenNumber;
  1585 	}
  1586 
  1587 //Override base class Preamble
  1588 TVerdict RTestStepAviPlayCtrlSetScrnPlay::DoTestStepPreambleL(void)
  1589 	{
  1590 	RTestStepAviCtrlBase::DoTestStepPreambleL();
  1591 	return EPass;
  1592 	}
  1593 
  1594 /**
  1595 This is from MMMFControllerEventMonitorObserver.which handles all the events from AviPlayController.
  1596 Base class version is overridden to avoid starting the active schedular twice.
  1597 */
  1598 void RTestStepAviPlayCtrlSetScrnPlay::HandleEvent(const TMMFEvent& aEvent)
  1599 	{
  1600 	TInt errorCode = 0;
  1601 	if (aEvent.iEventType==KMMFEventCategoryPlaybackComplete)
  1602 		{
  1603 		if(aEvent.iErrorCode == KErrNone)
  1604 			{
  1605 			INFO_PRINTF2(_L("PlayCompletion is passed with  %d "), aEvent.iErrorCode);
  1606 			iTestStepResult = EPass;
  1607 			}
  1608 		else
  1609 			{
  1610 			iTestStepResult = EFail;
  1611 			INFO_PRINTF2(_L("PlayCompletion is failed with  %d "), aEvent.iErrorCode);
  1612 			}
  1613 		CActiveScheduler::Stop();	
  1614 		}
  1615 	else if (aEvent.iEventType == KMMFEventCategoryVideoOpenComplete)
  1616 		{
  1617 		if((aEvent.iErrorCode == KErrNone) || (aEvent.iErrorCode == KErrEof))
  1618 			{
  1619 			//add code here to set display window and to update display region.	
  1620 			RMMFVideoPlayControllerCustomCommands thePlayCommander(iController);
  1621 			errorCode = thePlayCommander.SetDisplayWindow(iScreenRect,iClipRect);
  1622 			if(errorCode)
  1623 				{
  1624 				INFO_PRINTF2(_L("SetDisplayWindow failed with  %d "), errorCode);
  1625 				iTestStepResult = EFail;
  1626 				CActiveScheduler::Stop();
  1627 				return;
  1628 				}
  1629 			errorCode = thePlayCommander.UpdateDisplayRegion(iRegion);
  1630 			if(errorCode)
  1631 				{
  1632 				INFO_PRINTF2(_L("UpdateDisplayRegion failed with  %d "), errorCode);
  1633 				iTestStepResult = EFail;
  1634 				CActiveScheduler::Stop();
  1635 				return;
  1636 				}
  1637 			INFO_PRINTF2(_L("Open completion is passed with  %d "), aEvent.iErrorCode);	
  1638 			errorCode = thePlayCommander.Prepare();	
  1639 			if(errorCode)
  1640 				{
  1641 				INFO_PRINTF2(_L("Prepare failed with  %d "), errorCode);
  1642 				iTestStepResult = EFail;
  1643 				CActiveScheduler::Stop();
  1644 				}			
  1645 			}
  1646 		else
  1647 			{
  1648 			iTestStepResult = EFail;
  1649 			INFO_PRINTF2(_L("Video open complete is failed with  %d "), aEvent.iErrorCode);
  1650 			CActiveScheduler::Stop();
  1651 			}
  1652 		}
  1653 	else if (aEvent.iEventType == KMMFEventCategoryVideoPrepareComplete)
  1654 		{
  1655 		if((aEvent.iErrorCode == KErrNone) || (aEvent.iErrorCode == KErrEof))
  1656 			{
  1657 			INFO_PRINTF2(_L("Prepare completion is passed with  %d "), aEvent.iErrorCode);	
  1658 			errorCode = iController.Prime();
  1659 			if(errorCode)
  1660 				{
  1661 				INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
  1662 				iTestStepResult = EFail;
  1663 				CActiveScheduler::Stop();
  1664 				return;
  1665 				}
  1666 			errorCode = iController.Play();
  1667 			if(errorCode)
  1668 				{
  1669 				INFO_PRINTF2(_L("Play() is failed with  %d "), errorCode);
  1670 				iTestStepResult = EFail;
  1671 				CActiveScheduler::Stop();
  1672 				}
  1673 			}
  1674 		else
  1675 			{
  1676 			iTestStepResult = EFail;
  1677 			INFO_PRINTF2(_L("PrepareComplete is failed with  %d "),aEvent.iErrorCode);
  1678 			CActiveScheduler::Stop();
  1679 			}
  1680 		}
  1681 	else
  1682 		{
  1683 		INFO_PRINTF1(_L("Unexpected Event from the Controller"));
  1684 		iTestStepResult = EFail;
  1685 		CActiveScheduler::Stop();
  1686 		}			
  1687 	
  1688 	}
  1689 
  1690 /**
  1691 This test step plays the video on the primary or secondary screen depending the value of screen number passed during its construction.
  1692 */	
  1693 TVerdict RTestStepAviPlayCtrlSetScrnPlay::DoTestStepL(void)
  1694 	{
  1695 	INFO_PRINTF2(_L("this step plays an avi file on screen %d using RMMFVideoSetInitScreenCustomCommands"), iScreenNumber);
  1696 	iTestStepResult = EFail;
  1697 	TInt errorCode = iController.Open(KAviPlayControllerUid, iPriority);
  1698 	if(errorCode)
  1699 		{
  1700 		INFO_PRINTF2(_L("Failed to load the controller  %d "), errorCode);
  1701 		User::LeaveIfError( errorCode );
  1702 		}
  1703 	iControllerEventMonitor->Start();
  1704 	if(!SetupReadFileConfigL())
  1705 		{
  1706 		return EInconclusive;
  1707 		}
  1708 	RMMFVideoSetInitScreenCustomCommands setInitScrn(iController);
  1709 	errorCode = setInitScrn.SetInitScreenNumber(iScreenNumber);
  1710 	if(errorCode)
  1711 		{
  1712 		INFO_PRINTF2(_L("SetInitScreenNumber failed with  %d "), errorCode);
  1713 		User::LeaveIfError( errorCode );
  1714 		}
  1715 	errorCode = iController.AddDataSink(KUidMmfAudioOutput,KNullDesC8);
  1716 #ifdef __EABI__ //we dont have secondary screen support on hardware. So fail gracefully.
  1717 	if(errorCode == KErrNotSupported && iScreenNumber == KSecondaryScreenNo)
  1718 		{
  1719 		INFO_PRINTF1(_L("No support for secondary display"));
  1720 		return EKnownFailure;
  1721 		}
  1722 #endif	
  1723 	if(errorCode)
  1724 		{
  1725 		INFO_PRINTF2(_L("AddDataSink failed with  %d "), errorCode);
  1726 		User::LeaveIfError( errorCode );
  1727 		}
  1728 	errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
  1729 	if(errorCode)
  1730 		{
  1731 		INFO_PRINTF2(_L("AddDataSource failed with  %d "), errorCode);
  1732 		User::LeaveIfError( errorCode );
  1733 		}
  1734 	CActiveScheduler::Start();		
  1735 	return iTestStepResult;
  1736 	}
  1737 	
  1738 /**
  1739 Test step constructor. It initialises its own name, input filename and the screen number.
  1740 */
  1741 RTestStepAviPlayCtrlSetInvalidScrn::RTestStepAviPlayCtrlSetInvalidScrn(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid, TInt aScreenNumber)
  1742 :RTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid)
  1743 	{
  1744 	iScreenNumber = aScreenNumber;
  1745 	}
  1746 	
  1747 //Override base class Preamble
  1748 TVerdict RTestStepAviPlayCtrlSetInvalidScrn::DoTestStepPreambleL(void)
  1749 	{
  1750 	RTestStepAviCtrlBase::DoTestStepPreambleL();
  1751 	return EPass;
  1752 	}
  1753 
  1754 /**
  1755 This test step tries to set an invalid screen on AviPlayController and expects AddDataSink to fail with KErrNotSupported..
  1756 */
  1757 TVerdict RTestStepAviPlayCtrlSetInvalidScrn::DoTestStepL(void)
  1758 	{
  1759 	INFO_PRINTF1(_L("this step tries to set an invalid screen number on the AviPlayController"));
  1760 	TInt errorCode = iController.Open(KAviPlayControllerUid, iPriority);
  1761 	if(errorCode)
  1762 		{
  1763 		INFO_PRINTF2(_L("Failed to load the controller  %d "), errorCode);
  1764 		User::LeaveIfError( errorCode );
  1765 		}
  1766 	iControllerEventMonitor->Start();
  1767 	if(!SetupReadFileConfigL())
  1768 		{
  1769 		return EInconclusive;
  1770 		}
  1771 	RMMFVideoSetInitScreenCustomCommands setInitScrn(iController);
  1772 	errorCode = setInitScrn.SetInitScreenNumber(iScreenNumber);
  1773 	if(errorCode)
  1774 		{
  1775 		INFO_PRINTF2(_L("SetInitScreenNumber failed with  %d "), errorCode);
  1776 		User::LeaveIfError( errorCode );
  1777 		}
  1778 	errorCode = iController.AddDataSink(KUidMmfAudioOutput,KNullDesC8);
  1779 	if(errorCode != KErrNotSupported)
  1780 		{
  1781 		INFO_PRINTF2(_L("AddDataSink failed to return KErrNotSupported but returned %d with an invalid screen"), errorCode);
  1782 		return EFail;
  1783 		}
  1784 	return EPass;
  1785 	}
  1786 
  1787 /**
  1788 Test step constructor. It initialises its own name, input filename and the screen number.
  1789 */
  1790 RTestStepAviPlayCtrlAddDataSinkTwice::RTestStepAviPlayCtrlAddDataSinkTwice(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid, TInt aScreenNumber)
  1791 :RTestStepAviPlayCtrlSetScrnPlay(aTestName, aSectName, aKeyName, aControllerUid, aScreenNumber)
  1792 	{
  1793 	}
  1794 /**
  1795 This test step tries to set an invalid screen after calling AddDataSink on AviController and tries playing.
  1796 It resets the controller after the play is successful and tries to call AddDataSink again and expects
  1797 it to fail with KErrNotSupported.
  1798 */	
  1799 TVerdict RTestStepAviPlayCtrlAddDataSinkTwice::DoTestStepPreambleL(void)
  1800 	{
  1801 	RTestStepAviCtrlBase::DoTestStepPreambleL();
  1802 	return EPass;
  1803 	}
  1804 
  1805 TVerdict RTestStepAviPlayCtrlAddDataSinkTwice::DoTestStepL(void)
  1806 	{
  1807 	INFO_PRINTF1(_L("this step tries to add data sink twice.Second time invalid screen"));
  1808 	iTestStepResult = EFail;
  1809 	TInt errorCode = iController.Open(KAviPlayControllerUid, iPriority);
  1810 	if(errorCode)
  1811 		{
  1812 		INFO_PRINTF2(_L("Failed to load the controller  %d "), errorCode);
  1813 		User::LeaveIfError( errorCode );
  1814 		}
  1815 	iControllerEventMonitor->Start();
  1816 	if(!SetupReadFileConfigL())
  1817 		{
  1818 		return EInconclusive;
  1819 		}
  1820 	errorCode = iController.AddDataSink(KUidMmfAudioOutput,KNullDesC8);
  1821 	if(errorCode)
  1822 		{
  1823 		INFO_PRINTF2(_L("AddDataSink failed with  %d "), errorCode);
  1824 		User::LeaveIfError( errorCode );
  1825 		}
  1826 	RMMFVideoSetInitScreenCustomCommands setInitScrn(iController);
  1827 	errorCode = setInitScrn.SetInitScreenNumber(iScreenNumber);
  1828 	if(errorCode)
  1829 		{
  1830 		INFO_PRINTF2(_L("SetInitScreenNumber failed with  %d "), errorCode);
  1831 		User::LeaveIfError( errorCode );
  1832 		}
  1833 	errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
  1834 	if(errorCode)
  1835 		{
  1836 		INFO_PRINTF2(_L("AddDataSource failed with  %d "), errorCode);
  1837 		User::LeaveIfError( errorCode );
  1838 		}
  1839 	CActiveScheduler::Start();
  1840 	if(iTestStepResult == EFail)
  1841 		{
  1842 		return iTestStepResult;
  1843 		}
  1844 	errorCode = iController.Reset();
  1845 	if(errorCode)
  1846 		{
  1847 		INFO_PRINTF2(_L("Reset is failed with  %d "), errorCode);
  1848 		return EFail;
  1849 		}
  1850 	errorCode = iController.AddDataSink(KUidMmfAudioOutput,KNullDesC8);
  1851 	if(errorCode != KErrNotSupported)
  1852 		{
  1853 		INFO_PRINTF2(_L("AddDataSink failed to return KErrNotSupported but returned %d with an invalid screen"), errorCode);
  1854 		return EFail;
  1855 		}
  1856 	return iTestStepResult;
  1857 	}
  1858 
  1859 
  1860 /**
  1861 Test step constructor. It initialises its own name and the input filename
  1862 */
  1863 RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap::
  1864 RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap(const TDesC& aTestName,
  1865 												const TDesC& aSectName,
  1866 												const TDesC& aKeyName,
  1867 												TUid aControllerUid)
  1868 	:
  1869 	RAsyncTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid),
  1870 	iTestState(EStateDefault),
  1871 	iRChunk(),
  1872 	iKickoff01(NULL),
  1873 	iKickoff02(NULL),
  1874 	iKickoff03(NULL),
  1875 	iKickoff04(NULL),
  1876 	iKickoff05(NULL),
  1877 	iKickoff06(NULL)
  1878 	{
  1879 	}
  1880 
  1881 
  1882 /**
  1883 Do the test step. This test check that under low memory conditions the xvid
  1884 codec may leave and DevVideo will be notified by the codec and and in turn
  1885 AviPlayController will be notified too by DevVideo using the FatalError
  1886 callbacks.  Once the low memory conditions return to normal, the test case
  1887 Primes the AviPlayController and Plays an avi file to its completion and checks
  1888 for the proper play completion. This will prove that DevVideo is destroyed and
  1889 then recreated after a FatalError occurs.
  1890 
  1891 The idea here is :
  1892 
  1893 1.- To allocate enough memory with the aim of leaving around KMaxFreeRamForTest
  1894 bytes available for the rest of the test case.
  1895 
  1896 2.- After that, the testcase Primes the AviPlayController and Plays an avi
  1897 file. Play is expected to fail with KErrTooBig (in the play completion event).
  1898 
  1899 3.- Then returns memory back to the system.
  1900 
  1901 4.- Then try to play the video file again, this time everything will work
  1902 fine...With this we test that DevVideo's been recreated...
  1903 
  1904 */
  1905 void RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap::KickoffTestL()
  1906 	{
  1907 	iTestState = EStateLoadKickoffTestLComplete;
  1908 
  1909 	INFO_PRINTF1(_L("this step plays an avi file under low memory conditions for the xvid decoder "));
  1910 
  1911 	// This will install two callbacks
  1912 	RAsyncTestStepAviCtrlPlayBase::KickoffTestL();
  1913 
  1914 	// STEP 1: The idea here is to allocate enough memory with the aim of
  1915 	// leaving around KMaxFreeRamForTest bytes available for the rest of the
  1916 	// step. That will make the xvid decoder to fail the frame decoding as the
  1917 	// decoder heap will not be large enough.
  1918 	TCallBack callback01 (AllocChunkCallBack, this);
  1919 	delete iKickoff01;
  1920 	iKickoff01 = NULL;
  1921 	iKickoff01 = new (ELeave) CAsyncCallBack (callback01, CActive::EPriorityLow);
  1922 	
  1923 
  1924     // STEP 2: Prime the controller...
  1925 	TCallBack callback02 (PrimeControllerCallBack, this);
  1926 	delete iKickoff02;
  1927 	iKickoff02 = NULL;
  1928 	iKickoff02 = new (ELeave) CAsyncCallBack (callback02, CActive::EPriorityLow);
  1929 
  1930 	// STEP 3: play is expected to fail with KErrTooBig (in the play completion event ) ...
  1931 	TCallBack callback03 (PlayControllerCallBack, this);
  1932 	delete iKickoff03;
  1933 	iKickoff03 = NULL;
  1934 	iKickoff03 = new (ELeave) CAsyncCallBack (callback03, CActive::EPriorityLow);
  1935 
  1936 	// STEP 4: Return memory back to system here...
  1937 	TCallBack callback04 (ReturnChunckAndStopControllerCallBack, this);
  1938 	delete iKickoff04;
  1939 	iKickoff04 = NULL;
  1940 	iKickoff04 = new (ELeave) CAsyncCallBack (callback04, CActive::EPriorityLow);
  1941 
  1942 	// Repeat prime....
  1943 	TCallBack callback05 (PrimeControllerCallBack, this);
  1944 	delete iKickoff05;
  1945 	iKickoff05 = NULL;
  1946 	iKickoff05 = new (ELeave) CAsyncCallBack (callback05, CActive::EPriorityLow);
  1947 
  1948 	// ...and repeat play
  1949 	TCallBack callback06 (PlayControllerCallBack, this);
  1950 	delete iKickoff06;
  1951 	iKickoff06 = NULL;
  1952 	iKickoff06 = new (ELeave) CAsyncCallBack (callback06, CActive::EPriorityLow);
  1953 
  1954 	// Start allocate chunck callback.
  1955 	iKickoff01->Call();
  1956 	}
  1957 
  1958 void RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap::CloseTest()
  1959 	{
  1960 	delete iKickoff01; // no need to Cancel
  1961 	iKickoff01 = NULL;
  1962 	delete iKickoff02; // no need to Cancel
  1963 	iKickoff02 = NULL;
  1964 	delete iKickoff03; // no need to Cancel
  1965 	iKickoff03 = NULL;
  1966 	delete iKickoff04; // no need to Cancel
  1967 	iKickoff04 = NULL;
  1968 	delete iKickoff05; // no need to Cancel
  1969 	iKickoff05 = NULL;
  1970 	delete iKickoff06; // no need to Cancel
  1971 	iKickoff06 = NULL;
  1972 
  1973 	RAsyncTestStepAviCtrlPlayBase::CloseTest();
  1974 	}
  1975 
  1976 
  1977 TInt RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap::AllocChunkCallBack(TAny* aPtr)
  1978 	{
  1979 	RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap* self =
  1980 		static_cast<RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap*> (aPtr);
  1981 	self->DoAllocChunkCallBack();
  1982 	return KErrNone;
  1983 	}
  1984 
  1985 void RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap::DoAllocChunkCallBack()
  1986 	{
  1987 	// Check simple FSM
  1988 	if (iTestState != EStateLoadKickoffTestLComplete)
  1989 		{
  1990 		INFO_PRINTF1(_L("FSM error in DoAllocChunkCallBack"));
  1991 		StopTest(KErrGeneral, EFail);
  1992 		return;
  1993 		}
  1994 
  1995 	iTestState = EStateAllocChunkCallBackComplete;
  1996 
  1997 	TInt freeRam = 0;
  1998 
  1999 	TInt halError = KErrNone;
  2000 	if ((halError = HAL::Get(HALData::EMemoryRAMFree, freeRam)) != KErrNone)
  2001 		{
  2002 		INFO_PRINTF1(_L("Unable to obtain the amount of free ram available "));
  2003 		StopTest(halError, EInconclusive);
  2004 		return;
  2005 		}
  2006 
  2007 	if (freeRam > KMaxFreeRamForTest)
  2008 		{
  2009 		TInt memToAllocate = freeRam - KMaxFreeRamForTest;
  2010 		INFO_PRINTF3(_L("freeRam  = %d bytes, before allocating %d bytes"),
  2011 					 freeRam, memToAllocate);
  2012 		TInt chunkError = KErrNone;
  2013 		//We have calculated the amount of memory to allocate
  2014 		//start by allocating half of that amount
  2015 		
  2016 		if((chunkError=iRChunk[0].CreateLocal(memToAllocate/2, memToAllocate/2 + 1))!=KErrNone)
  2017 			{
  2018 			INFO_PRINTF3(_L("At least %d mem bytes are needed for this test (err=%d)"),
  2019 						 KMaxFreeRamForTest, chunkError);
  2020 			StopTest(chunkError, EInconclusive);
  2021 			return;
  2022 			}
  2023 		//WDP: we are allocating on paged memory. So keep allocating chunks till you are Out of Memory
  2024 		//Now allocate smaller chunks. Only half of memToAllocate has been allocated yet
  2025 		//In every iteration we try to allocate KMaxFreeRamForTest/2
  2026 		//Calculate the max loop value till which we should run, add some extra iterations so that this loop goes on till OOM for sure
  2027 		//Number of iterations is (0.5*memToAllocate)/(0.5*KMaxFreeRamForTest)
  2028 		TInt loopValue=(memToAllocate/KMaxFreeRamForTest)+KExtraIterations;
  2029 		if(loopValue>KMaxChunks)
  2030 			{
  2031 			//We should not get here.
  2032 			INFO_PRINTF1(_L("Cannot Create so many chunks"));		
  2033 			StopTest(chunkError, EInconclusive);
  2034 			return;
  2035 			}
  2036 		for(iNumAllocatedChunks=1;iNumAllocatedChunks<KMaxChunks;iNumAllocatedChunks++)
  2037 			{
  2038 			chunkError = KErrNone;
  2039 			if ((chunkError = iRChunk[iNumAllocatedChunks].CreateLocal(KMaxFreeRamForTest/2, KMaxFreeRamForTest/2 + 1)) != KErrNone)
  2040 				{
  2041 				if(chunkError==KErrNoMemory)
  2042 					{
  2043 					//We have run out of memory
  2044 					//Close the last two chunks so now you have approximately KMaxFreeRamForTest free
  2045 					iRChunk[--iNumAllocatedChunks].Close();
  2046 					if(iNumAllocatedChunks>0)
  2047 						{
  2048 						iRChunk[--iNumAllocatedChunks].Close();
  2049 						}
  2050 					break;
  2051 					}
  2052 				else
  2053 					{
  2054 					//Unexpected error
  2055 					INFO_PRINTF1(_L("Received Unexpected error"));		
  2056 					StopTest(chunkError, EInconclusive);
  2057 					return;
  2058 					}
  2059 				}
  2060 			}
  2061 		if(chunkError!=KErrNoMemory)
  2062 			{
  2063 			//We are out of the loop and still not out of memory. This is not expected
  2064 			INFO_PRINTF2(_L("Expecting -4 by now but still not out of memory. Allocated chunks %d"),iNumAllocatedChunks);		
  2065 			StopTest(chunkError, EInconclusive);
  2066 			return;
  2067 			}
  2068 		
  2069 		iKickoff02->Call(); // Start prime
  2070 		}
  2071 	else
  2072 		{
  2073 		INFO_PRINTF2(_L("At least %d mem bytes are needed for this test "), KMaxFreeRamForTest);
  2074 		StopTest(KErrGeneral, EInconclusive);
  2075 		}
  2076 	}
  2077 
  2078 
  2079 TInt RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap::PrimeControllerCallBack(TAny* aPtr)
  2080 	{
  2081 	RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap* self =
  2082 		static_cast<RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap*> (aPtr);
  2083 	self->DoPrimeControllerCallBack();
  2084 	return KErrNone;
  2085 	}
  2086 
  2087 void RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap::DoPrimeControllerCallBack()
  2088 	{
  2089 
  2090 	// Check simple fsm
  2091 	switch (iTestState)
  2092 		{
  2093 	case EStateAllocChunkCallBackComplete:
  2094 		{
  2095 		iTestState = EStatePrimeControllerCallBackComplete1;
  2096 		iKickoff03->Call(); // Start 1st playback
  2097 		break;
  2098 		}
  2099 	case EStateReturnChunckAndStopControllerCallBackComplete:
  2100 		{
  2101 		iTestState = EStatePrimeControllerCallBackComplete2;
  2102 		iKickoff06->Call(); // Start 2nd playback
  2103 		break;
  2104 		}
  2105 	default:
  2106 		{
  2107 		INFO_PRINTF1(_L("FSM error in DoPrimeControllerCallBack"));
  2108 		StopTest(KErrGeneral, EFail);
  2109 		return;
  2110 		}
  2111 		};
  2112 
  2113 	INFO_PRINTF1(_L("iController.Prime()"));
  2114 
  2115 	TInt errorCode = iController.Prime();
  2116 	if(errorCode)
  2117 		{
  2118 		INFO_PRINTF2(_L("Prime is failed with  %d "), errorCode);
  2119 		StopTest(errorCode, EFail);
  2120 		}
  2121 	}
  2122 
  2123 
  2124 TInt RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap::PlayControllerCallBack(TAny* aPtr)
  2125 	{
  2126 	RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap* self =
  2127 		static_cast<RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap*> (aPtr);
  2128 	self->DoPlayControllerCallBack();
  2129 	return KErrNone;
  2130 	}
  2131 
  2132 void RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap::DoPlayControllerCallBack()
  2133 	{
  2134 
  2135 	// Check simple fsm
  2136 	switch (iTestState)
  2137 		{
  2138 	case EStatePrimeControllerCallBackComplete1:
  2139 		{
  2140 		iTestState = EStatePlayControllerCallBackComplete1;
  2141 		break;
  2142 		}
  2143 	case EStatePrimeControllerCallBackComplete2:
  2144 		{
  2145 		iTestState = EStatePlayControllerCallBackComplete2;
  2146 		break;
  2147 		}
  2148 	default:
  2149 		{
  2150 		INFO_PRINTF1(_L("FSM error in DoPlayControllerCallBack"));
  2151 		StopTest(KErrGeneral, EFail);
  2152 		return;
  2153 		}
  2154 		};
  2155 
  2156 	INFO_PRINTF1(_L("iController.Play()"));
  2157 
  2158 	TInt errorCode = iController.Play();
  2159 	if(errorCode)
  2160 		{
  2161 		INFO_PRINTF2(_L("Play() failed with error %d"), errorCode);
  2162 		StopTest(errorCode, EFail);
  2163 		}
  2164 	}
  2165 
  2166 TInt RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap::ReturnChunckAndStopControllerCallBack(TAny* aPtr)
  2167 	{
  2168 	RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap* self =
  2169 		static_cast<RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap*> (aPtr);
  2170 	self->DoReturnChunckAndStopControllerCallBack();
  2171 	return KErrNone;
  2172 	}
  2173 
  2174 void RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap::DoReturnChunckAndStopControllerCallBack()
  2175 	{
  2176 	// Check simple fsm
  2177 	if (iTestState != EStatePlayControllerCallBackComplete1)
  2178 		{
  2179 		INFO_PRINTF1(_L("FSM error in DoReturnChunckAndStopControllerCallBack"));
  2180 		StopTest(KErrGeneral, EFail);
  2181 		return;
  2182 		}
  2183 	iTestState = EStateReturnChunckAndStopControllerCallBackComplete;
  2184 
  2185 	INFO_PRINTF1(_L("Returning memory back to the system"));
  2186 
  2187 	for(TInt i=0;i<iNumAllocatedChunks;i++)
  2188 		{
  2189 		iRChunk[i].Close();
  2190 		}
  2191 	// Get controller back to an initial state
  2192 	iController.Stop();
  2193 	
  2194 	iKickoff05->Call(); // call prime again
  2195 	}
  2196 
  2197 
  2198 /**
  2199 This is from MMMFControllerEventMonitorObserver.which handles all the events
  2200 from AviPlayController.  Base class version is overridden to avoid starting the
  2201 active schedular twice.
  2202 */
  2203 void RTestStepAviPlayNotEnoughMemoryForXvidCodecHeap::HandleEvent(const TMMFEvent& aEvent)
  2204 	{
  2205 	INFO_PRINTF2(_L("HandleEvent  aEvent.iEventType %d "),
  2206 				 aEvent.iEventType);
  2207 	INFO_PRINTF2(_L("::HandleEvent  aEvent.iErrorCode %d "),
  2208 				 aEvent.iErrorCode);
  2209 
  2210 	if (aEvent.iEventType == KMMFEventCategoryPlaybackComplete)
  2211 		{
  2212 		if(aEvent.iErrorCode == KErrNone)
  2213 			{
  2214 			iTestStepResult = EPass;
  2215 			INFO_PRINTF2(_L("PlayCompletion is passed with  %d "),
  2216 						 aEvent.iErrorCode);
  2217 			}
  2218 		else
  2219 			{
  2220 			iTestStepResult = EFail;
  2221 			INFO_PRINTF2(_L("PlayCompletion is failed with  %d "),
  2222 						 aEvent.iErrorCode);
  2223 			}
  2224 
  2225 		//
  2226 		// Match fsm state with play completion event just processed
  2227 		//
  2228 		switch(iTestState)
  2229 			{
  2230 		case EStatePlayControllerCallBackComplete1:
  2231 			{
  2232 			if (iTestStepResult == EPass)
  2233 				{
  2234 				INFO_PRINTF1(_L("Error: completion event was expected to be failed at this point"));
  2235 				StopTest(KErrGeneral, EFail);
  2236 				return;
  2237 				}
  2238 			
  2239 			iKickoff04->Call(); // Return memory
  2240 			break;
  2241 			}
  2242 		case EStatePlayControllerCallBackComplete2:
  2243 			{
  2244 			if (iTestStepResult == EFail)
  2245 				{
  2246 				INFO_PRINTF1(_L("Error: PlayCompletion event was expected to pass at this point"));
  2247 				StopTest(KErrGeneral, EFail);
  2248 				return;
  2249 				}
  2250 			else
  2251 				{
  2252 				// Test has finished succesfully at this point
  2253 				INFO_PRINTF1(_L("Test successfully completed"));
  2254 				StopTest();
  2255 				return;
  2256 				}
  2257 			}
  2258 		default:
  2259 			{
  2260 			INFO_PRINTF1(_L("FSM error in HandleEvent"));
  2261 			StopTest(KErrGeneral, EFail);
  2262 			return;
  2263 			}
  2264 			};
  2265 		}
  2266 	else if (aEvent.iEventType == KMMFEventCategoryVideoOpenComplete)
  2267 		{
  2268 		if(aEvent.iErrorCode != KErrNone)
  2269 			{
  2270 			INFO_PRINTF2(_L("Video open complete is failed with  %d "), aEvent.iErrorCode);
  2271 			StopTest(KErrGeneral, EFail);
  2272 			return;
  2273 			}
  2274 		}
  2275 	else
  2276 		{
  2277 		INFO_PRINTF1(_L("Unexpected Event from the Controller"));
  2278 		StopTest(KErrGeneral, EFail);
  2279 		}
  2280 	}
  2281 
  2282 /**
  2283 Test step constructor. It initialises its own name and the input filename
  2284 */
  2285 RTestStepAviPlayCtrlMemAlloc1::RTestStepAviPlayCtrlMemAlloc1(const TDesC& aTestName,
  2286 															const TDesC& aSectName,
  2287 															const TDesC& aKeyName,
  2288 															TUid aControllerUid)
  2289 	: RTestStepAviCtrlBase(aTestName, aSectName, aKeyName, aControllerUid)
  2290 	{
  2291 	}
  2292 
  2293 /**
  2294 Do the test step. This test issue a custom command to the custom AviPlay controller
  2295 and runs the OOM test within the controller.
  2296 */
  2297 TVerdict RTestStepAviPlayCtrlMemAlloc1::DoTestStepL()
  2298 	{
  2299 	TVerdict result = EPass;
  2300 	
  2301 	Log( _L("Memory Allocation Test 1") );
  2302 	
  2303 	Log( _L("This test checks memory allocation of the plugin") );
  2304 	
  2305    	TInt errorCode = iController.Open(KUidCustomTestAviPlayPlugin, iPriority);
  2306 	User::LeaveIfError( errorCode );
  2307 	
  2308 	//[ send the custom command to the custom audio controller ]
  2309 	TMMFMessageDestinationPckg destinationPckg(KMemoryAllocationTestId);
  2310 	
  2311 	//[ send memory alloc test to the custom plugin ]
  2312 	//[ we have only ensured that the controller is loaded into memory
  2313 	// and that all add sources etc will be don
  2314 	errorCode = iController.CustomCommandSync(destinationPckg, 
  2315 		KMemoryAllocTest1, 
  2316 		KNullDesC8,
  2317 		KNullDesC8);
  2318 	
  2319 	//[ ensure the controller is unloaded so that it does 
  2320 	// not interfere with the following test ]
  2321 	// There is a bug in this code and the stop followed by reset
  2322 	// ensure the controller resources are released.
  2323 	iController.Stop();
  2324 	iController.Reset();
  2325 	iController.Close();  
  2326 
  2327 	User::LeaveIfError( errorCode );
  2328 	return result ;
  2329 	}
  2330 
  2331 /**
  2332 This is from MMMFControllerEventMonitorObserver.which handles all the events
  2333 from AviPlayController.  Base class version is overridden to avoid starting the
  2334 active schedular twice.
  2335 */
  2336 void RTestStepAviPlayCtrlMemAlloc1::HandleEvent(const TMMFEvent& aEvent)
  2337 	{
  2338 	(void)aEvent;
  2339 	};
  2340 
  2341 /**
  2342 Test step constructor. It initialises its own name and the input filename
  2343 */
  2344 RTestStepAviPlayCtrlMemAlloc2::RTestStepAviPlayCtrlMemAlloc2(const TDesC& aTestName,
  2345 															const TDesC& aSectName,
  2346 															const TDesC& aKeyName,
  2347 															TUid aControllerUid)
  2348 	: RTestStepAviCtrlBase(aTestName, aSectName, aKeyName, aControllerUid)
  2349 	{
  2350 	}
  2351 
  2352 /**
  2353 Do the test step. This test issue a custom command to the custom AviPlay controller
  2354 and runs the OOM test within the controller.
  2355 */
  2356 TVerdict RTestStepAviPlayCtrlMemAlloc2::DoTestStepL()
  2357 	{
  2358 	TVerdict result = EPass;
  2359 	
  2360 	Log( _L("Memory Allocation Test 2") );
  2361 	
  2362 	Log( _L("This test checks memory allocation of the plugin") );
  2363 	
  2364    	TInt errorCode = iController.Open(KUidCustomTestAviPlayPlugin, iPriority);
  2365 	User::LeaveIfError( errorCode );
  2366 	
  2367 	//[ send the custom command to the custom audio controller ]
  2368 	TMMFMessageDestinationPckg destinationPckg(KMemoryAllocationTestId);
  2369 	
  2370 	//[ set the prime OOM test mode ]
  2371 	//[ we have only ensured that the controller is loaded into memory
  2372 	// and that all add sources etc will be don
  2373 	TPckgBuf<TBool> primeTestEnable(ETrue);
  2374 	errorCode = iController.CustomCommandSync(destinationPckg, 
  2375 		KOOMPrimeTestEnable, 
  2376 		primeTestEnable,
  2377 		KNullDesC8);
  2378 	if (errorCode == KErrNone)
  2379 		{
  2380 		TInt failCount = 1;
  2381 		for (;;)
  2382 			{
  2383 			TPckgBuf<TInt> primeTestFailCount(failCount);
  2384 			errorCode = iController.CustomCommandSync(destinationPckg, 
  2385 				KOOMPrimeTestFailCount, 
  2386 				primeTestFailCount,
  2387 				KNullDesC8);
  2388 			if (errorCode != KErrNone)
  2389 				{
  2390 				result = EInconclusive;
  2391 				break;
  2392 				}
  2393 			
  2394 			errorCode = iController.CustomCommandSync(destinationPckg, 
  2395 				KMemoryAllocTest2, 
  2396 				KNullDesC8,
  2397 				KNullDesC8);
  2398 			if (errorCode != KErrNone)
  2399 				{
  2400 				result = EInconclusive;
  2401 				break;
  2402 				}
  2403 
  2404 			errorCode = iController.Prime();
  2405 			if (errorCode == KErrNone)
  2406 				{
  2407 				result = EPass;
  2408 				break;
  2409 				}
  2410 			else if (errorCode != KErrNoMemory)
  2411 				{
  2412 				result = EFail;
  2413 				break;
  2414 				}
  2415 			
  2416 			iController.Reset();
  2417 			failCount++;
  2418 			}
  2419 		}
  2420 	else
  2421 		{
  2422 		result = EInconclusive;
  2423 		}
  2424 	
  2425 	primeTestEnable() = EFalse;
  2426 	iController.CustomCommandSync(destinationPckg, 
  2427 		KOOMPrimeTestEnable, 
  2428 		primeTestEnable,
  2429 		KNullDesC8);
  2430 		
  2431 	//[ ensure the controller is unloaded so that it does 
  2432 	// not interfere with the following test ]
  2433 	// There is a bug in this code and the stop followed by reset
  2434 	// ensure the controller resources are released.
  2435 	iController.Stop();
  2436 	iController.Reset();
  2437 	iController.Close();  
  2438 
  2439 	return result ;
  2440 	}
  2441 
  2442 /**
  2443 This is from MMMFControllerEventMonitorObserver.which handles all the events
  2444 from AviPlayController.  Base class version is overridden to avoid starting the
  2445 active schedular twice.
  2446 */
  2447 void RTestStepAviPlayCtrlMemAlloc2::HandleEvent(const TMMFEvent& aEvent)
  2448 	{
  2449 	(void)aEvent;
  2450 	};
  2451 
  2452 /**
  2453 Test step constructor. It initialises its own name and the input filename
  2454 */
  2455 RTestStepAviPlayCtrlMemAlloc3::RTestStepAviPlayCtrlMemAlloc3(const TDesC& aTestName,
  2456 															const TDesC& aSectName,
  2457 															const TDesC& aKeyName,
  2458 															TUid aControllerUid)
  2459 	: RTestStepAviCtrlBase(aTestName, aSectName, aKeyName, aControllerUid)
  2460 	{
  2461 	}
  2462 
  2463 /**
  2464 Do the test step. This test issue a custom command to the custom AviPlay controller
  2465 and runs the OOM test within the controller.
  2466 */
  2467 TVerdict RTestStepAviPlayCtrlMemAlloc3::DoTestStepL()
  2468 	{
  2469 	TVerdict result = EPass;
  2470 	
  2471 	Log( _L("Memory Allocation Test 3") );
  2472 	
  2473 	Log( _L("This test checks memory allocation of the plugin") );
  2474 	
  2475    	TInt errorCode = iController.Open(KUidCustomTestAviPlayPlugin, iPriority);
  2476 	User::LeaveIfError( errorCode );
  2477 	
  2478 	//[ send the custom command to the custom audio controller ]
  2479 	TMMFMessageDestinationPckg destinationPckg(KMemoryAllocationTestId);
  2480 	
  2481 	TInt failCount = 1;
  2482 	for (;;)
  2483 		{
  2484 		TPckgBuf<TInt> primeTestFailCount(failCount);
  2485 		errorCode = iController.CustomCommandSync(destinationPckg, 
  2486 			KOOMPrimeTestFailCount, 
  2487 			primeTestFailCount,
  2488 			KNullDesC8);
  2489 		if (errorCode != KErrNone)
  2490 			{
  2491 			result = EInconclusive;
  2492 			break;
  2493 			}
  2494 		
  2495 		errorCode = iController.CustomCommandSync(destinationPckg, 
  2496 			KMemoryAllocTest2, 
  2497 			KNullDesC8,
  2498 			KNullDesC8);
  2499 		if (errorCode != KErrNone)
  2500 			{
  2501 			result = EInconclusive;
  2502 			break;
  2503 			}
  2504 
  2505 		errorCode = iController.Prime();
  2506 		if (errorCode != KErrNone)
  2507 			{
  2508 			result = EInconclusive;
  2509 			break;
  2510 			}
  2511 
  2512 		errorCode = iController.CustomCommandSync(destinationPckg, 
  2513 			KMemoryAllocTest3, 
  2514 			KNullDesC8,
  2515 			KNullDesC8);
  2516 		
  2517 		if (errorCode == KErrNone)
  2518 			{
  2519 			result = EPass;
  2520 			break;
  2521 			}
  2522 		else if (errorCode != KErrNoMemory)
  2523 			{
  2524 			result = EFail;
  2525 			break;
  2526 			}
  2527 		
  2528 		iController.Reset();
  2529 		failCount++;
  2530 		}
  2531 	
  2532 	//[ ensure the controller is unloaded so that it does 
  2533 	// not interfere with the following test ]
  2534 	// There is a bug in this code and the stop followed by reset
  2535 	// ensure the controller resources are released.
  2536 	iController.Stop();
  2537 	iController.Reset();
  2538 	iController.Close();  
  2539 
  2540 	return result ;
  2541 	}
  2542 
  2543 /**
  2544 This is from MMMFControllerEventMonitorObserver.which handles all the events
  2545 from AviPlayController.  Base class version is overridden to avoid starting the
  2546 active schedular twice.
  2547 */
  2548 void RTestStepAviPlayCtrlMemAlloc3::HandleEvent(const TMMFEvent& aEvent)
  2549 	{
  2550 	(void)aEvent;
  2551 	};
  2552 
  2553 #ifdef SYMBIAN_BUILD_GCE
  2554 
  2555 /**
  2556 Test step constructor. It initialises its own name and the input filename.
  2557 */
  2558 RTestStepAviPlayCtrlSurfaceSupport::RTestStepAviPlayCtrlSurfaceSupport(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  2559 :RAsyncTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid), iVpsCommands(iController)
  2560 	{
  2561 	}
  2562 
  2563 void RTestStepAviPlayCtrlSurfaceSupport::KickoffTestL()
  2564 	{
  2565 	// Allow parent to create some call backs for its initialization.
  2566 	// Should open the video controller, set the filename, add the source and add the sink.
  2567 	RAsyncTestStepAviCtrlPlayBase::KickoffTestL();
  2568 	
  2569 	iSurfaceCreated = EFalse;
  2570 	
  2571 	// Call UseSurfaces
  2572 	TCallBack callbackUseSurfaces(UseSurfacesCallBack, this);
  2573 	delete iKickoffUseSurfaces;
  2574 	iKickoffUseSurfaces = NULL;
  2575 	iKickoffUseSurfaces = new (ELeave) CAsyncCallBack(callbackUseSurfaces, CActive::EPriorityLow);
  2576 	iKickoffUseSurfaces->Call();
  2577 	
  2578 	// Call UseSurfaces again.  This should not fail or cause any other subsequent step to fail.
  2579 	delete iKickoffUseSurfaces2;
  2580 	iKickoffUseSurfaces2 = NULL;
  2581 	iKickoffUseSurfaces2 = new (ELeave) CAsyncCallBack(callbackUseSurfaces, CActive::EPriorityLow);
  2582 	iKickoffUseSurfaces2->Call();
  2583 
  2584 	// Prime the controller
  2585 	TCallBack callbackPrimeController(PrimeControllerCallBack, this);
  2586 	delete iKickoffPrimeController;
  2587 	iKickoffPrimeController = NULL;
  2588 	iKickoffPrimeController = new (ELeave) CAsyncCallBack(callbackPrimeController, CActive::EPriorityLow);
  2589 	iKickoffPrimeController->Call();
  2590 
  2591 	TCallBack callbackPlayController(PlayControllerCallBack, this);
  2592 	delete iKickoffPlayController;
  2593 	iKickoffPlayController = NULL;
  2594 	iKickoffPlayController = new (ELeave) CAsyncCallBack(callbackPlayController, CActive::EPriorityLow);
  2595 	iKickoffPlayController->Call();
  2596 	}
  2597 
  2598 void RTestStepAviPlayCtrlSurfaceSupport::CloseTest()
  2599 	{
  2600 	// no need to Cancel before deleting.
  2601 	delete iKickoffUseSurfaces;
  2602 	iKickoffUseSurfaces = NULL;
  2603 	delete iKickoffUseSurfaces2;
  2604 	iKickoffUseSurfaces2 = NULL;
  2605 	delete iKickoffPrimeController;
  2606 	iKickoffPrimeController = NULL;
  2607 	
  2608 	RAsyncTestStepAviCtrlPlayBase::CloseTest();
  2609 	}
  2610 
  2611 /**
  2612 Check if we have passed the test.  We need to make sure that we have received all the event
  2613 messages that we expect.
  2614 */	
  2615 TVerdict RTestStepAviPlayCtrlSurfaceSupport::CheckTestResult()
  2616 	{
  2617 	// Only report that we have not received all expected events if everything else passes.
  2618 	// We don't expect the event generators to work properly if something else failed (and those
  2619 	// other error codes and reasons should be more useful).  We won't see these events if GCE is
  2620 	// not enabled.  So, if GCE is disabled, do not fail because we didn't see these events.
  2621 	if (Result() == EPass && !iSurfaceCreated && iGceEnabled)
  2622 		{
  2623 		if (!iSurfaceCreated)
  2624 			{
  2625 			ERR_PRINTF1(_L("Failed to receive surface created event"));
  2626 			}
  2627 			
  2628 		return EFail;
  2629 		}
  2630 		
  2631 	return RAsyncTestStepAviCtrlPlayBase::CheckTestResult();
  2632 	}
  2633 
  2634 /**
  2635 This is from MMMFControllerEventMonitorObserver.which handles all the events
  2636 from AviPlayController.  Base class version is overridden to avoid starting the
  2637 active schedular twice.
  2638 */
  2639 void RTestStepAviPlayCtrlSurfaceSupport::HandleEvent(const TMMFEvent& aEvent)
  2640 	{	
  2641 	if (aEvent.iEventType == KMMFEventCategoryVideoOpenComplete)
  2642 		{
  2643 		if(aEvent.iErrorCode != KErrNone)
  2644 			{
  2645 			ERR_PRINTF2(_L("Video open complete has failed with %d "), aEvent.iErrorCode);
  2646 			StopTest(KErrGeneral, EInconclusive);
  2647 			return;
  2648 			}
  2649 		}
  2650 	else if (aEvent.iEventType == KMMFEventCategoryVideoSurfaceCreated)
  2651 		{	
  2652 		if (!iGceEnabled)
  2653 			{
  2654 			ERR_PRINTF1(_L("Surface events should not be generated when GCE is not enabled"));
  2655 			StopTest(KErrGeneral, EFail);
  2656 			return;
  2657 			}
  2658 			
  2659 		// The error code is actually the display for which a surface has been created.
  2660 		if (aEvent.iErrorCode != KErrNone)
  2661 			{
  2662 			ERR_PRINTF2(_L("Video surface created event has error %d."), aEvent.iErrorCode);
  2663 			StopTest(KErrGeneral, EFail);
  2664 			}
  2665 		
  2666 		// Now that the surface has been created we can check if can retrieve the surface parameters
  2667 		TRect cropRect;
  2668 		TVideoAspectRatio pixelAspectRatio;
  2669 	
  2670 		TInt error = iVpsCommands.GetSurfaceParameters(iSurfaceId, cropRect, pixelAspectRatio);
  2671 		if (error)
  2672 			{
  2673 			ERR_PRINTF2(_L("GetSurfaceParameters failed with code %d."), error);
  2674 			StopTest(error, EFail);
  2675 			}
  2676 		
  2677 		iSurfaceCreated = ETrue;
  2678 		}
  2679 	else if (aEvent.iEventType == KMMFEventCategoryPlaybackComplete)
  2680 		{
  2681 		if(aEvent.iErrorCode == KErrNone)
  2682 			{
  2683 			if(iGceEnabled)
  2684 				{
  2685 				TInt error = iVpsCommands.SurfaceRemoved(iSurfaceId);
  2686 				if (error)
  2687 					{
  2688 					ERR_PRINTF2(_L("SurfaceRemoved failed with code %d."), error);
  2689 					StopTest(error, EFail);
  2690 					}
  2691 				}
  2692 			StopTest();
  2693 			}
  2694 		else
  2695 			{
  2696 			ERR_PRINTF2(_L("Video playback complete has failed with %d "), aEvent.iErrorCode);
  2697 			StopTest(KErrGeneral, EInconclusive);
  2698 			}
  2699 		}
  2700 	else
  2701 		{
  2702 		ERR_PRINTF3(_L("Unexpected Event from the Controller: type %d error: %d"), aEvent.iEventType, aEvent.iErrorCode);
  2703 		StopTest(KErrGeneral, EFail);
  2704 		}
  2705 	}
  2706 
  2707 TInt RTestStepAviPlayCtrlSurfaceSupport::UseSurfacesCallBack(TAny* aPtr)
  2708 	{
  2709 	RTestStepAviPlayCtrlSurfaceSupport* self =
  2710 		static_cast<RTestStepAviPlayCtrlSurfaceSupport*> (aPtr);
  2711 	self->DoUseSurfacesCallBack();
  2712 	return KErrNone;
  2713 	}
  2714 	
  2715 void RTestStepAviPlayCtrlSurfaceSupport::DoUseSurfacesCallBack()
  2716 	{
  2717 	TInt error = iVpsCommands.UseSurfaces();
  2718 	
  2719 	if (iGceEnabled && error != KErrNone)
  2720 		{
  2721 		ERR_PRINTF2(_L("UseSurfaces failed with code %d."), error);
  2722 		StopTest(error, EFail);
  2723 		}
  2724 	else if (!iGceEnabled && error != KErrNotSupported)
  2725 		{
  2726 		ERR_PRINTF2(_L("UseSurfaces failed to return KErrNotSupported. Actual result: %d."), error);
  2727 		StopTest(error, EFail);
  2728 		}
  2729 	}
  2730 
  2731 TInt RTestStepAviPlayCtrlSurfaceSupport::PrimeControllerCallBack(TAny* aPtr)
  2732 	{
  2733 	RTestStepAviPlayCtrlSurfaceSupport* self =
  2734 		static_cast<RTestStepAviPlayCtrlSurfaceSupport*> (aPtr);
  2735 	self->DoPrimeControllerCallBack();
  2736 	return KErrNone;
  2737 	}
  2738 
  2739 void RTestStepAviPlayCtrlSurfaceSupport::DoPrimeControllerCallBack()
  2740 	{
  2741 	TInt error = iController.Prime();
  2742 	if (error != KErrNone)
  2743 		{
  2744 		ERR_PRINTF2(_L("Prime failed with  %d "), error);
  2745 		StopTest(error, EFail);
  2746 		}
  2747 	}
  2748 	
  2749 TInt RTestStepAviPlayCtrlSurfaceSupport::PlayControllerCallBack(TAny* aPtr)
  2750 	{
  2751 	RTestStepAviPlayCtrlSurfaceSupport* self =
  2752 		static_cast<RTestStepAviPlayCtrlSurfaceSupport*> (aPtr);
  2753 	self->DoPlayControllerCallBack();
  2754 	return KErrNone;
  2755 	}
  2756 
  2757 void RTestStepAviPlayCtrlSurfaceSupport::DoPlayControllerCallBack()
  2758 	{
  2759 	TInt error = iController.Play();
  2760 	if (error != KErrNone)
  2761 		{
  2762 		ERR_PRINTF2(_L("Play failed with  %d "), error);
  2763 		StopTest(error, EFail);
  2764 		}
  2765 	}
  2766 
  2767 RTestStepAviPlayCtrlSurfaceRemovedNoUS::RTestStepAviPlayCtrlSurfaceRemovedNoUS(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  2768 :RAsyncTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid), iVpsCommands(iController)
  2769 	{
  2770 	}
  2771 
  2772 void RTestStepAviPlayCtrlSurfaceRemovedNoUS::KickoffTestL()
  2773 	{
  2774 	// Allow parent to create some call backs for its initialization.
  2775 	// Should open the video controller, set the filename, add the source and add the sink.
  2776 	RAsyncTestStepAviCtrlPlayBase::KickoffTestL();
  2777 	
  2778 	// Call SurfaceRemoved
  2779 	iSurfaceId = TSurfaceId::CreateNullId();
  2780 
  2781 	TCallBack callbackSurfaceRemoved(SurfaceRemovedCallBack, this);
  2782 	delete iKickoffSurfaceRemoved;
  2783 	iKickoffSurfaceRemoved = NULL;
  2784 	iKickoffSurfaceRemoved = new (ELeave) CAsyncCallBack(callbackSurfaceRemoved, CActive::EPriorityLow);
  2785 	iKickoffSurfaceRemoved->Call();
  2786 	}
  2787 
  2788 void RTestStepAviPlayCtrlSurfaceRemovedNoUS::CloseTest()
  2789 	{
  2790 	// no need to Cancel before deleting.
  2791 	delete iKickoffSurfaceRemoved;
  2792 	iKickoffSurfaceRemoved = NULL;
  2793 	
  2794 	RAsyncTestStepAviCtrlPlayBase::CloseTest();
  2795 	}
  2796 
  2797 TInt RTestStepAviPlayCtrlSurfaceRemovedNoUS::SurfaceRemovedCallBack(TAny* aPtr)
  2798 	{
  2799 	RTestStepAviPlayCtrlSurfaceRemovedNoUS* self =
  2800 		static_cast<RTestStepAviPlayCtrlSurfaceRemovedNoUS*> (aPtr);
  2801 	self->DoSurfaceRemovedCallBack();
  2802 	return KErrNone;
  2803 	}
  2804 
  2805 void RTestStepAviPlayCtrlSurfaceRemovedNoUS::DoSurfaceRemovedCallBack()
  2806 	{
  2807 	TInt error = iVpsCommands.SurfaceRemoved(iSurfaceId);
  2808 	
  2809 	if (iGceEnabled && error != KErrNotSupported)
  2810 		{
  2811 		ERR_PRINTF2(_L("SurfaceRemoved failed to return error KErrNotSupported.  Actual error was %d "), error);
  2812 		StopTest(KErrGeneral, EFail);
  2813 		}
  2814 	else if (!iGceEnabled && error != KErrNotSupported)
  2815 		{
  2816 		ERR_PRINTF2(_L("SurfaceRemoved failed to return KErrNotSupported. Actual result: %d."), error);
  2817 		StopTest(error, EFail);
  2818 		}
  2819 	else
  2820 		{
  2821 		StopTest();
  2822 		}
  2823 	}
  2824 
  2825 RTestStepAviPlayCtrlGetSurfaceParametersNoUS::RTestStepAviPlayCtrlGetSurfaceParametersNoUS(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  2826 :RAsyncTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid), iVpsCommands(iController)
  2827 	{
  2828 	}
  2829 
  2830 void RTestStepAviPlayCtrlGetSurfaceParametersNoUS::KickoffTestL()
  2831 	{
  2832 	// Allow parent to create some call backs for its initialization.
  2833 	// Should open the video controller, set the filename, add the source and add the sink.
  2834 	RAsyncTestStepAviCtrlPlayBase::KickoffTestL();
  2835 	
  2836 	// Get the surface parameters.
  2837 	TCallBack callbackGetSurfaceParameters(GetSurfaceParametersCallBack, this);
  2838 	delete iKickoffGetSurfaceParameters;
  2839 	iKickoffGetSurfaceParameters = NULL;
  2840 	iKickoffGetSurfaceParameters = new (ELeave) CAsyncCallBack(callbackGetSurfaceParameters, CActive::EPriorityLow);
  2841 	iKickoffGetSurfaceParameters->Call();
  2842 	}
  2843 
  2844 void RTestStepAviPlayCtrlGetSurfaceParametersNoUS::CloseTest()
  2845 	{
  2846 	// no need to Cancel before deleting.
  2847 	delete iKickoffGetSurfaceParameters;
  2848 	iKickoffGetSurfaceParameters = NULL;
  2849 	
  2850 	RAsyncTestStepAviCtrlPlayBase::CloseTest();
  2851 	}
  2852 
  2853 TInt RTestStepAviPlayCtrlGetSurfaceParametersNoUS::GetSurfaceParametersCallBack(TAny* aPtr)
  2854 	{
  2855 	RTestStepAviPlayCtrlGetSurfaceParametersNoUS* self =
  2856 		static_cast<RTestStepAviPlayCtrlGetSurfaceParametersNoUS*> (aPtr);
  2857 	self->DoGetSurfaceParametersCallBack();
  2858 	return KErrNone;
  2859 	}
  2860 	
  2861 void RTestStepAviPlayCtrlGetSurfaceParametersNoUS::DoGetSurfaceParametersCallBack()
  2862 	{
  2863 	TSurfaceId surfaceID;	
  2864 	TRect cropRect;
  2865 	TVideoAspectRatio pixelAspectRatio;
  2866 
  2867 	TInt error = iVpsCommands.GetSurfaceParameters(surfaceID, cropRect, pixelAspectRatio);
  2868 	
  2869 	if (iGceEnabled && error != KErrNotSupported)
  2870 		{
  2871 		ERR_PRINTF2(_L("GetSurfaceParameters failed to return error KErrNotSupported.  Actual error was %d "), error);
  2872 		StopTest(KErrGeneral, EFail);
  2873 		}
  2874 	else if (!iGceEnabled && error != KErrNotSupported)
  2875 		{
  2876 		ERR_PRINTF2(_L("GetSurfaceParameters failed to return KErrNotSupported. Actual result: %d."), error);
  2877 		StopTest(error, EFail);
  2878 		}
  2879 	else
  2880 		{
  2881 		StopTest();
  2882 		}
  2883 	}
  2884 
  2885 RTestStepAviPlayCtrlSurfaceRemovedNullSurfaceId::RTestStepAviPlayCtrlSurfaceRemovedNullSurfaceId(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  2886 :RAsyncTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid), iVpsCommands(iController)
  2887 	{
  2888 	}
  2889 
  2890 void RTestStepAviPlayCtrlSurfaceRemovedNullSurfaceId::KickoffTestL()
  2891 	{
  2892 	// Allow parent to create some call backs for its initialization.
  2893 	// Should open the video controller, set the filename, add the source and add the sink.
  2894 	RAsyncTestStepAviCtrlPlayBase::KickoffTestL();
  2895 	
  2896 	// Call UseSurfaces
  2897 	TCallBack callbackUseSurfaces(UseSurfacesCallBack, this);
  2898 	delete iKickoffUseSurfaces;
  2899 	iKickoffUseSurfaces = NULL;
  2900 	iKickoffUseSurfaces = new (ELeave) CAsyncCallBack(callbackUseSurfaces, CActive::EPriorityLow);
  2901 	iKickoffUseSurfaces->Call();
  2902 	
  2903 	// Call SurfaceRemoved
  2904 	iSurfaceId = TSurfaceId::CreateNullId();
  2905 
  2906 	TCallBack callbackSurfaceRemoved(SurfaceRemovedCallBack, this);
  2907 	delete iKickoffSurfaceRemoved;
  2908 	iKickoffSurfaceRemoved = NULL;
  2909 	iKickoffSurfaceRemoved = new (ELeave) CAsyncCallBack(callbackSurfaceRemoved, CActive::EPriorityLow);
  2910 	iKickoffSurfaceRemoved->Call();
  2911 	}
  2912 
  2913 void RTestStepAviPlayCtrlSurfaceRemovedNullSurfaceId::CloseTest()
  2914 	{
  2915 	// no need to Cancel before deleting.
  2916 	delete iKickoffSurfaceRemoved;
  2917 	iKickoffSurfaceRemoved = NULL;
  2918 	
  2919 	RAsyncTestStepAviCtrlPlayBase::CloseTest();
  2920 	}
  2921 
  2922 TInt RTestStepAviPlayCtrlSurfaceRemovedNullSurfaceId::SurfaceRemovedCallBack(TAny* aPtr)
  2923 	{
  2924 	RTestStepAviPlayCtrlSurfaceRemovedNullSurfaceId* self =
  2925 		static_cast<RTestStepAviPlayCtrlSurfaceRemovedNullSurfaceId*> (aPtr);
  2926 	self->DoSurfaceRemovedCallBack();
  2927 	return KErrNone;
  2928 	}
  2929 
  2930 void RTestStepAviPlayCtrlSurfaceRemovedNullSurfaceId::DoSurfaceRemovedCallBack()
  2931 	{
  2932 	TInt error = iVpsCommands.SurfaceRemoved(iSurfaceId);
  2933 	
  2934 	if (iGceEnabled && error != KErrArgument)
  2935 		{
  2936 		ERR_PRINTF2(_L("SurfaceRemoved failed to return error KErrArgument.  Actual error was %d "), error);
  2937 		StopTest(KErrGeneral, EFail);
  2938 		}
  2939 	else if (!iGceEnabled && error != KErrNotSupported)
  2940 		{
  2941 		ERR_PRINTF2(_L("SurfaceRemoved failed to return KErrNotSupported. Actual result: %d."), error);
  2942 		StopTest(error, EFail);
  2943 		}
  2944 	else
  2945 		{
  2946 		StopTest();
  2947 		}
  2948 	}
  2949 
  2950 TInt RTestStepAviPlayCtrlSurfaceRemovedNullSurfaceId::UseSurfacesCallBack(TAny* aPtr)
  2951 	{
  2952 	RTestStepAviPlayCtrlSurfaceRemovedNullSurfaceId* self =
  2953 		static_cast<RTestStepAviPlayCtrlSurfaceRemovedNullSurfaceId*> (aPtr);
  2954 	self->DoUseSurfacesCallBack();
  2955 	return KErrNone;
  2956 	}
  2957 	
  2958 void RTestStepAviPlayCtrlSurfaceRemovedNullSurfaceId::DoUseSurfacesCallBack()
  2959 	{
  2960 	TInt error = iVpsCommands.UseSurfaces();
  2961 	
  2962 	if (iGceEnabled && error != KErrNone)
  2963 		{
  2964 		ERR_PRINTF2(_L("UseSurfaces failed with code %d."), error);
  2965 		StopTest(error, EFail);
  2966 		}
  2967 	else if (!iGceEnabled && error != KErrNotSupported)
  2968 		{
  2969 		ERR_PRINTF2(_L("UseSurfaces failed to return KErrNotSupported. Actual result: %d."), error);
  2970 		StopTest(error, EFail);
  2971 		}
  2972 	}
  2973 
  2974 RTestStepAviPlayCtrlSurfaceRemovedInvalidSurfaceId::RTestStepAviPlayCtrlSurfaceRemovedInvalidSurfaceId(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  2975 :RAsyncTestStepAviCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid), iVpsCommands(iController)
  2976 	{
  2977 	}
  2978 
  2979 void RTestStepAviPlayCtrlSurfaceRemovedInvalidSurfaceId::KickoffTestL()
  2980 	{
  2981 	// Allow parent to create some call backs for its initialization.
  2982 	// Should open the video controller, set the filename, add the source and add the sink.
  2983 	RAsyncTestStepAviCtrlPlayBase::KickoffTestL();
  2984 	
  2985 	// Call UseSurfaces
  2986 	TCallBack callbackUseSurfaces(UseSurfacesCallBack, this);
  2987 	delete iKickoffUseSurfaces;
  2988 	iKickoffUseSurfaces = NULL;
  2989 	iKickoffUseSurfaces = new (ELeave) CAsyncCallBack(callbackUseSurfaces, CActive::EPriorityLow);
  2990 	iKickoffUseSurfaces->Call();
  2991 	
  2992 	// Call SurfaceRemoved
  2993 	iSurfaceId.iInternal[0] = 1111;
  2994 	iSurfaceId.iInternal[1] = 1111;
  2995 	iSurfaceId.iInternal[2] = 1111;
  2996 	iSurfaceId.iInternal[3] = 1111;
  2997 	
  2998 	TCallBack callbackSurfaceRemoved(SurfaceRemovedCallBack, this);
  2999 	delete iKickoffSurfaceRemoved;
  3000 	iKickoffSurfaceRemoved = NULL;
  3001 	iKickoffSurfaceRemoved = new (ELeave) CAsyncCallBack(callbackSurfaceRemoved, CActive::EPriorityLow);
  3002 	iKickoffSurfaceRemoved->Call();
  3003 	}
  3004 
  3005 void RTestStepAviPlayCtrlSurfaceRemovedInvalidSurfaceId::CloseTest()
  3006 	{
  3007 	// no need to Cancel before deleting.
  3008 	delete iKickoffSurfaceRemoved;
  3009 	iKickoffSurfaceRemoved = NULL;
  3010 	
  3011 	RAsyncTestStepAviCtrlPlayBase::CloseTest();
  3012 	}
  3013 
  3014 TInt RTestStepAviPlayCtrlSurfaceRemovedInvalidSurfaceId::SurfaceRemovedCallBack(TAny* aPtr)
  3015 	{
  3016 	RTestStepAviPlayCtrlSurfaceRemovedInvalidSurfaceId* self =
  3017 		static_cast<RTestStepAviPlayCtrlSurfaceRemovedInvalidSurfaceId*> (aPtr);
  3018 	self->DoSurfaceRemovedCallBack();
  3019 	return KErrNone;
  3020 	}
  3021 
  3022 void RTestStepAviPlayCtrlSurfaceRemovedInvalidSurfaceId::DoSurfaceRemovedCallBack()
  3023 	{
  3024 	TInt error = iVpsCommands.SurfaceRemoved(iSurfaceId);
  3025 	
  3026 	if (iGceEnabled && error != KErrNotReady)
  3027 		{
  3028 		ERR_PRINTF2(_L("SurfaceRemoved failed to return error KErrNotReady.  Actual error was %d "), error);
  3029 		StopTest(KErrGeneral, EFail);
  3030 		}
  3031 	else if (!iGceEnabled && error != KErrNotSupported)
  3032 		{
  3033 		ERR_PRINTF2(_L("SurfaceRemoved failed to return KErrNotSupported. Actual result: %d."), error);
  3034 		StopTest(error, EFail);
  3035 		}
  3036 	else
  3037 		{
  3038 		StopTest();
  3039 		}
  3040 	}
  3041 
  3042 TInt RTestStepAviPlayCtrlSurfaceRemovedInvalidSurfaceId::UseSurfacesCallBack(TAny* aPtr)
  3043 	{
  3044 	RTestStepAviPlayCtrlSurfaceRemovedInvalidSurfaceId* self =
  3045 		static_cast<RTestStepAviPlayCtrlSurfaceRemovedInvalidSurfaceId*> (aPtr);
  3046 	self->DoUseSurfacesCallBack();
  3047 	return KErrNone;
  3048 	}
  3049 	
  3050 void RTestStepAviPlayCtrlSurfaceRemovedInvalidSurfaceId::DoUseSurfacesCallBack()
  3051 	{
  3052 	TInt error = iVpsCommands.UseSurfaces();
  3053 	
  3054 	if (iGceEnabled && error != KErrNone)
  3055 		{
  3056 		ERR_PRINTF2(_L("UseSurfaces failed with code %d."), error);
  3057 		StopTest(error, EFail);
  3058 		}
  3059 	else if (!iGceEnabled && error != KErrNotSupported)
  3060 		{
  3061 		ERR_PRINTF2(_L("UseSurfaces failed to return KErrNotSupported. Actual result: %d."), error);
  3062 		StopTest(error, EFail);
  3063 		}
  3064 	}
  3065 
  3066 #endif // SYMBIAN_BUILD_GCE
  3067 
  3068 #ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
  3069 
  3070 //
  3071 // RAsyncTestSubtitlePlay
  3072 //
  3073 RAsyncTestSubtitlePlay::RAsyncTestSubtitlePlay(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  3074 	:RAsyncTestStepSubtitleBase(aTestName, aSectName, aKeyName, aControllerUid)
  3075 	{
  3076 	SetExpectedCrpReadyCount(1);
  3077 	}
  3078 
  3079 void RAsyncTestSubtitlePlay::OnOpenCompleteL()
  3080 	{
  3081 	CheckAndEnableSubtitlesL();
  3082 	AddDefaultSubtitleConfL();
  3083 	
  3084 	RArray<TLanguage> languages;
  3085 	CleanupClosePushL(languages);
  3086 	TRAPD(err, iSubtitleCommands.GetSupportedSubtitleLanguagesL(languages));
  3087 	
  3088 	if (err != KErrNotSupported)
  3089 		{
  3090 		ERR_PRINTF3(_L("GetSupportedSubtitleLanguagesL left with %d; expected %d"), err, KErrNotSupported);
  3091 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3092 		}
  3093 	
  3094 	if (languages.Count() != 0)
  3095 		{
  3096 		ERR_PRINTF2(_L("GetSupportedSubtitleLanguagesL returned %d languages"), languages.Count());
  3097 		User::Leave(KErrGeneral);
  3098 		}
  3099 	
  3100 	CleanupStack::PopAndDestroy(); // languages
  3101 	
  3102 	TLanguage language = ELangNone;
  3103 	err = iSubtitleCommands.GetSubtitleLanguage(language);
  3104 	
  3105 	if (err != KErrNotSupported)
  3106 		{
  3107 		ERR_PRINTF3(_L("GetSubtitleLanguage failed with %d; expected %d"), err, KErrNotSupported);
  3108 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3109 		}
  3110 	
  3111 	if (language != ELangNone)
  3112 		{
  3113 		ERR_PRINTF3(_L("GetSubtitleLanguage returned %d, expected %d"), language, ELangNone);
  3114 		User::Leave(KErrGeneral);
  3115 		}
  3116 	
  3117 	err = iSubtitleCommands.SetSubtitleLanguage(ELangCanadianEnglish);
  3118 	
  3119 	if (err != KErrNotSupported)
  3120 		{
  3121 		ERR_PRINTF3(_L("SetSubtitleLanguage failed with %d, expected %d"), err, KErrNotSupported);
  3122 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3123 		}
  3124 	
  3125 	StartPlaybackL();
  3126 	}
  3127 
  3128 void RAsyncTestSubtitlePlay::OnPlayCompleteL()
  3129 	{
  3130 	RemoveConfigDisableL();
  3131 	}
  3132 
  3133 //
  3134 // RAsyncTestSubtitleUpdateConfig
  3135 //
  3136 RAsyncTestSubtitleUpdateConfig::RAsyncTestSubtitleUpdateConfig(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  3137 	:RAsyncTestStepSubtitleBase(aTestName, aSectName, aKeyName, aControllerUid)
  3138 	{
  3139 	SetExpectedCrpReadyCount(2);
  3140 	}
  3141 
  3142 void RAsyncTestSubtitleUpdateConfig::OnOpenCompleteL()
  3143 	{
  3144 	CheckAndEnableSubtitlesL();
  3145 	AddDefaultSubtitleConfL();
  3146 	
  3147 	TMMFSubtitleWindowConfig config;
  3148 	config.iWindowId = KWindowIdValid;
  3149 	config.iDisplayMode = EColor16MA;
  3150 	config.iRotation = EVideoRotationClockwise90;
  3151 	config.iWindowClipRect = KWindowClipRectAlt1;
  3152 	TInt err = iSubtitleCommands.UpdateSubtitleConfig(config);
  3153 	
  3154 	if (err != KErrNone)
  3155 		{
  3156 		ERR_PRINTF2(_L("UpdateSubtitleConfig failed with %d"), err);
  3157 		User::Leave(err);
  3158 		}
  3159 	
  3160 	StartPlaybackL();
  3161 	}
  3162 
  3163 void RAsyncTestSubtitleUpdateConfig::OnPlayCompleteL()
  3164 	{
  3165 	RemoveConfigDisableL();
  3166 	}
  3167 
  3168 //
  3169 // RAsyncTestSubtitleUpdateDuring
  3170 //
  3171 
  3172 CCallBackTimer* CCallBackTimer::NewL(const TCallBack& aCallBack, TInt aPriority)
  3173 	{
  3174 	CCallBackTimer* self = new (ELeave) CCallBackTimer(aCallBack, aPriority);
  3175 	CleanupStack::PushL(self);
  3176 	self->ConstructL();
  3177 	CleanupStack::Pop();
  3178 	return self;
  3179 	}
  3180 
  3181 CCallBackTimer::CCallBackTimer(const TCallBack& aCallBack, TInt aPriority)
  3182 	: CTimer(aPriority), iCallBack(aCallBack)
  3183 	{
  3184 	CActiveScheduler::Add(this);
  3185 	}
  3186 
  3187 void CCallBackTimer::RunL()
  3188 	{
  3189 	User::LeaveIfError(iCallBack.CallBack());
  3190 	}
  3191 
  3192 RAsyncTestSubtitleUpdateDuring::RAsyncTestSubtitleUpdateDuring(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  3193 	:RAsyncTestStepSubtitleBase(aTestName, aSectName, aKeyName, aControllerUid)
  3194 	{
  3195 	SetExpectedCrpReadyCount(2);
  3196 	}
  3197 
  3198 void RAsyncTestSubtitleUpdateDuring::KickoffTestL()
  3199 	{
  3200 	TCallBack callBack(DuringPlaybackCallBack, this);
  3201 	iCallBackTimer = CCallBackTimer::NewL(callBack, CTimer::EPriorityStandard);
  3202 	iHasUpdated = EFalse;
  3203 	RAsyncTestStepSubtitleBase::KickoffTestL();
  3204 	}
  3205 
  3206 void RAsyncTestSubtitleUpdateDuring::CloseTest()
  3207 	{
  3208 	delete iCallBackTimer;
  3209 	iCallBackTimer = NULL;
  3210 	RAsyncTestStepSubtitleBase::CloseTest();
  3211 	}
  3212 
  3213 TInt RAsyncTestSubtitleUpdateDuring::DuringPlaybackCallBack(TAny* aPtr)
  3214 	{
  3215 	RAsyncTestSubtitleUpdateDuring* self = static_cast<RAsyncTestSubtitleUpdateDuring*>(aPtr);
  3216 	self->OnDuringPlayback();
  3217 	return KErrNone;
  3218 	}
  3219 
  3220 void RAsyncTestSubtitleUpdateDuring::OnOpenCompleteL()
  3221 	{
  3222 	CheckAndEnableSubtitlesL();
  3223 	AddDefaultSubtitleConfL();
  3224 	
  3225 	// Start the call back timer.  Will trigger the during playback handler.
  3226 	iCallBackTimer->After(2500000);
  3227 	
  3228 	StartPlaybackL();
  3229 	}
  3230 
  3231 void RAsyncTestSubtitleUpdateDuring::OnDuringPlayback()
  3232 	{
  3233 	TMMFSubtitleWindowConfig config;
  3234 	config.iWindowId = KWindowIdValid;
  3235 	config.iDisplayMode = EColor16MA;
  3236 	config.iRotation = EVideoRotationClockwise90;
  3237 	config.iWindowClipRect = KWindowClipRectAlt1;
  3238 	TInt err = iSubtitleCommands.UpdateSubtitleConfig(config);
  3239 	
  3240 	if (err != KErrNone)
  3241 		{
  3242 		ERR_PRINTF2(_L("UpdateSubtitleConfig during playback failed with %d"), err);
  3243 		StopTest(err, EFail);
  3244 		}
  3245 	else
  3246 		{
  3247 		iHasUpdated = ETrue;
  3248 		}
  3249 	}
  3250 
  3251 void RAsyncTestSubtitleUpdateDuring::OnPlayCompleteL()
  3252 	{
  3253 	RemoveConfigDisableL();
  3254 	
  3255 	if (!iHasUpdated)
  3256 		{
  3257 		ERR_PRINTF1(_L("Subtitle configuration was not updated during playback."));
  3258 		User::Leave(KErrGeneral);
  3259 		}
  3260 	}
  3261 
  3262 //
  3263 // RAsyncTestSubtitleRemoveAdd
  3264 //
  3265 RAsyncTestSubtitleRemoveAdd::RAsyncTestSubtitleRemoveAdd(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  3266 	:RAsyncTestStepSubtitleBase(aTestName, aSectName, aKeyName, aControllerUid)
  3267 	{
  3268 	SetExpectedCrpReadyCount(2);
  3269 	}
  3270 
  3271 void RAsyncTestSubtitleRemoveAdd::OnOpenCompleteL()
  3272 	{
  3273 	CheckAndEnableSubtitlesL();
  3274 	AddDefaultSubtitleConfL();
  3275 	
  3276 	TInt err = iSubtitleCommands.RemoveSubtitleConfig(KWindowIdValid);
  3277 	
  3278 	if (err != KErrNone)
  3279 		{
  3280 		ERR_PRINTF2(_L("RemoveSubtitleConfig failed with %d"), err);
  3281 		User::Leave(err);
  3282 		}
  3283 	
  3284 	TMMFSubtitleWindowConfig config;
  3285 	config.iWindowId = KWindowIdValid;
  3286 	config.iDisplayMode = EColor16MA;
  3287 	config.iRotation = EVideoRotationClockwise270;
  3288 	config.iWindowClipRect = KWindowClipRectAlt2;
  3289 	err = iSubtitleCommands.AddSubtitleConfig(config);
  3290 	
  3291 	if (err != KErrNone)
  3292 		{
  3293 		ERR_PRINTF2(_L("AddSubtitleConfig failed with %d"), err);
  3294 		User::Leave(err);
  3295 		}
  3296 	
  3297 	StartPlaybackL();
  3298 	}
  3299 
  3300 void RAsyncTestSubtitleRemoveAdd::OnPlayCompleteL()
  3301 	{
  3302 	RemoveConfigDisableL();
  3303 	}
  3304 
  3305 //
  3306 // RAsyncTestSubtitleNotEnabled
  3307 //
  3308 RAsyncTestSubtitleNotEnabled::RAsyncTestSubtitleNotEnabled(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  3309 	:RAsyncTestStepSubtitleBase(aTestName, aSectName, aKeyName, aControllerUid)
  3310 	{
  3311 	SetExpectedCrpReadyCount(0);
  3312 	}
  3313 
  3314 void RAsyncTestSubtitleNotEnabled::OnOpenCompleteL()
  3315 	{
  3316 	// Make sure that subtitles are available:	
  3317 	TBool available = EFalse;
  3318 	TInt err = iSubtitleCommands.GetSubtitlesAvailable(available);
  3319 	
  3320 	if (err != KErrNone)
  3321 		{
  3322 		ERR_PRINTF2(_L("GetSubtitlesAvailable failed with %d"), err);
  3323 		User::Leave(err);
  3324 		}
  3325 	
  3326 	if (!available)
  3327 		{
  3328 		ERR_PRINTF1(_L("Subtitles unavailable"));
  3329 		User::Leave(KErrGeneral);
  3330 		}
  3331 	
  3332 	// Perform severy subtitle related functions without enabling subtitles.
  3333 	TMMFSubtitleWindowConfig config;
  3334 	config.iWindowId = KWindowIdValid;
  3335 	config.iDisplayMode = EColor16MA;
  3336 	config.iRotation = EVideoRotationNone;
  3337 	config.iWindowClipRect = KWindowClipRectFull;
  3338 	
  3339 	err = iSubtitleCommands.AddSubtitleConfig(config);
  3340 	if (err != KErrNotReady)
  3341 		{
  3342 		ERR_PRINTF3(_L("AddSubtitleConfig returned %d; expected %d"), err, KErrNotReady);
  3343 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3344 		}
  3345 	
  3346 	err = iSubtitleCommands.UpdateSubtitleConfig(config);
  3347 	if (err != KErrNotReady)
  3348 		{
  3349 		ERR_PRINTF3(_L("UpdateSubtitleConfig returned %d; expected %d"), err, KErrNotReady);
  3350 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3351 		}
  3352 	
  3353 	RArray<TLanguage> languages;
  3354 	TRAP(err, iSubtitleCommands.GetSupportedSubtitleLanguagesL(languages));
  3355 	languages.Close();
  3356 	
  3357 	if (err != KErrNotReady)
  3358 		{
  3359 		ERR_PRINTF3(_L("GetSupportedSubtitleLanguagesL left with %d; expected %d"), err, KErrNotReady);
  3360 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3361 		}
  3362 	
  3363 	TLanguage language = ELangNone;
  3364 	err = iSubtitleCommands.GetSubtitleLanguage(language);
  3365 	
  3366 	if (err != KErrNotReady)
  3367 		{
  3368 		ERR_PRINTF3(_L("GetSubtitleLanguage returned %d; expected %d"), err, KErrNotReady);
  3369 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3370 		}
  3371 	
  3372 	err = iSubtitleCommands.SetSubtitleLanguage(ELangCanadianEnglish);
  3373 	
  3374 	if (err != KErrNotReady)
  3375 		{
  3376 		ERR_PRINTF3(_L("SetSubtitleLanguage returned %d; expected %d"), err, KErrNotReady);
  3377 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3378 		}
  3379 	
  3380 	StartPlaybackL();
  3381 	}
  3382 
  3383 void RAsyncTestSubtitleNotEnabled::OnPlayCompleteL()
  3384 	{
  3385 	TInt err = iSubtitleCommands.RemoveSubtitleConfig(KWindowIdValid);
  3386 	
  3387 	if (err != KErrNotReady)
  3388 		{
  3389 		ERR_PRINTF3(_L("RemoveSubtitleConfig returned %d; expected %d"), err, KErrNotReady);
  3390 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3391 		}
  3392 	
  3393 	err = iSubtitleCommands.DisableSubtitles();
  3394 	
  3395 	if (err != KErrNone)
  3396 		{
  3397 		ERR_PRINTF3(_L("DisableSubtitles returned %d; expected %d"), err, KErrNone);
  3398 		User::Leave(err);
  3399 		}
  3400 	}
  3401 
  3402 //
  3403 // RAsyncTestSubtitleNotAvailable
  3404 //
  3405 RAsyncTestSubtitleNotAvailable::RAsyncTestSubtitleNotAvailable(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  3406 	:RAsyncTestStepSubtitleBase(aTestName, aSectName, aKeyName, aControllerUid)
  3407 	{
  3408 	SetExpectedCrpReadyCount(0);
  3409 	}
  3410 
  3411 void RAsyncTestSubtitleNotAvailable::OnOpenCompleteL()
  3412 	{
  3413 	// Make sure that subtitles are available:	
  3414 	TBool available = EFalse;
  3415 	TInt err = iSubtitleCommands.GetSubtitlesAvailable(available);
  3416 	
  3417 	if (err != KErrNone)
  3418 		{
  3419 		ERR_PRINTF2(_L("GetSubtitlesAvailable failed with %d"), err);
  3420 		User::Leave(err);
  3421 		}
  3422 	
  3423 	if (available)
  3424 		{
  3425 		ERR_PRINTF1(_L("Subtitles available, but should not be"));
  3426 		User::Leave(KErrGeneral);
  3427 		}
  3428 	
  3429 	err = iSubtitleCommands.EnableSubtitles();
  3430 	
  3431 	if (err != KErrNotFound)
  3432 		{
  3433 		ERR_PRINTF3(_L("EnableSubtitles returned %d; expected %d"), err, KErrNotFound);
  3434 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3435 		}
  3436 	
  3437 	// Perform severy subtitle related functions without enabling subtitles.
  3438 	TMMFSubtitleWindowConfig config;
  3439 	config.iWindowId = KWindowIdValid;
  3440 	config.iDisplayMode = EColor16MA;
  3441 	config.iRotation = EVideoRotationNone;
  3442 	config.iWindowClipRect = KWindowClipRectFull;
  3443 	
  3444 	err = iSubtitleCommands.AddSubtitleConfig(config);
  3445 	if (err != KErrNotReady)
  3446 		{
  3447 		ERR_PRINTF3(_L("AddSubtitleConfig returned %d; expected %d"), err, KErrNotReady);
  3448 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3449 		}
  3450 	
  3451 	err = iSubtitleCommands.UpdateSubtitleConfig(config);
  3452 	if (err != KErrNotReady)
  3453 		{
  3454 		ERR_PRINTF3(_L("UpdateSubtitleConfig returned %d; expected %d"), err, KErrNotReady);
  3455 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3456 		}
  3457 	
  3458 	RArray<TLanguage> languages;
  3459 	TRAP(err, iSubtitleCommands.GetSupportedSubtitleLanguagesL(languages));
  3460 	languages.Close();
  3461 	
  3462 	if (err != KErrNotReady)
  3463 		{
  3464 		ERR_PRINTF3(_L("GetSupportedSubtitleLanguagesL left with %d; expected %d"), err, KErrNotReady);
  3465 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3466 		}
  3467 	
  3468 	TLanguage language = ELangNone;
  3469 	err = iSubtitleCommands.GetSubtitleLanguage(language);
  3470 	
  3471 	if (err != KErrNotReady)
  3472 		{
  3473 		ERR_PRINTF3(_L("GetSubtitleLanguage returned %d; expected %d"), err, KErrNotReady);
  3474 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3475 		}
  3476 	
  3477 	err = iSubtitleCommands.SetSubtitleLanguage(ELangCanadianEnglish);
  3478 	
  3479 	if (err != KErrNotReady)
  3480 		{
  3481 		ERR_PRINTF3(_L("SetSubtitleLanguage returned %d; expected %d"), err, KErrNotReady);
  3482 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3483 		}
  3484 	
  3485 	StartPlaybackL();
  3486 	}
  3487 
  3488 void RAsyncTestSubtitleNotAvailable::OnPlayCompleteL()
  3489 	{
  3490 	TInt err = iSubtitleCommands.RemoveSubtitleConfig(KWindowIdValid);
  3491 	
  3492 	if (err != KErrNotReady)
  3493 		{
  3494 		ERR_PRINTF3(_L("RemoveSubtitleConfig returned %d; expected %d"), err, KErrNotReady);
  3495 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3496 		}
  3497 	
  3498 	err = iSubtitleCommands.DisableSubtitles();
  3499 	
  3500 	if (err != KErrNone)
  3501 		{
  3502 		ERR_PRINTF3(_L("DisableSubtitles returned %d; expected %d"), err, KErrNone);
  3503 		User::Leave(err);
  3504 		}
  3505 	}
  3506 
  3507 //
  3508 // RAsyncTestSubtitleMismatchedId
  3509 //
  3510 RAsyncTestSubtitleMismatchedId::RAsyncTestSubtitleMismatchedId(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  3511 	:RAsyncTestStepSubtitleBase(aTestName, aSectName, aKeyName, aControllerUid)
  3512 	{
  3513 	SetExpectedCrpReadyCount(1);
  3514 	}
  3515 
  3516 void RAsyncTestSubtitleMismatchedId::OnOpenCompleteL()
  3517 	{
  3518 	CheckAndEnableSubtitlesL();
  3519 	AddDefaultSubtitleConfL();
  3520 	
  3521 	TMMFSubtitleWindowConfig config;
  3522 	config.iWindowId = KWindowIdMismatched;
  3523 	config.iDisplayMode = EColor16MA;
  3524 	config.iRotation = EVideoRotationClockwise90;
  3525 	config.iWindowClipRect = KWindowClipRectAlt1;
  3526 	
  3527 	TInt err = iSubtitleCommands.UpdateSubtitleConfig(config);
  3528 	if (err != KErrNotFound)
  3529 		{
  3530 		ERR_PRINTF3(_L("UpdateSubtitleConfig returned %d; expected %d"), err, KErrNotFound);
  3531 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3532 		}
  3533 	
  3534 	err = iSubtitleCommands.RemoveSubtitleConfig(KWindowIdMismatched);
  3535 	if (err != KErrNotFound)
  3536 		{
  3537 		ERR_PRINTF3(_L("RemoveSubtitleConfig returned %d; expected %d"), err, KErrNotFound);
  3538 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3539 		}
  3540 	
  3541 	TWsGraphicId id(TWsGraphicId::EUninitialized);
  3542 	TRect rect;
  3543 	err = iSubtitleCommands.GetCrpParameters(KWindowIdMismatched, id, rect);
  3544 	if (err != KErrNotFound)
  3545 		{
  3546 		ERR_PRINTF3(_L("GetCrpParameters returned %d; expected %d"), err, KErrNotFound);
  3547 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3548 		}
  3549 	
  3550 	// If we haven't left yet then the test passes.
  3551 	StopTest();
  3552 	}
  3553 
  3554 //
  3555 // RAsyncTestSubtitleDoubleCall
  3556 //
  3557 RAsyncTestSubtitleDoubleCall::RAsyncTestSubtitleDoubleCall(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  3558 	:RAsyncTestStepSubtitleBase(aTestName, aSectName, aKeyName, aControllerUid)
  3559 	{
  3560 	SetExpectedCrpReadyCount(1);
  3561 	}
  3562 
  3563 void RAsyncTestSubtitleDoubleCall::OnOpenCompleteL()
  3564 	{
  3565 	TBool available = EFalse;
  3566 	
  3567 	TInt err = iSubtitleCommands.GetSubtitlesAvailable(available);
  3568 	
  3569 	if (err != KErrNone)
  3570 		{
  3571 		ERR_PRINTF2(_L("GetSubtitlesAvailable failed with %d"), err);
  3572 		User::Leave(err);
  3573 		}
  3574 	
  3575 	if (!available)
  3576 		{
  3577 		ERR_PRINTF1(_L("Subtitles unavailable"));
  3578 		User::Leave(KErrGeneral);
  3579 		}
  3580 	
  3581 	// Disable subtitles when they are not enabled.
  3582 	err = iSubtitleCommands.DisableSubtitles();
  3583 	if (err != KErrNone)
  3584 		{
  3585 		ERR_PRINTF2(_L("DisableSubtitles failed with %d"), err);
  3586 		User::Leave(err);
  3587 		}
  3588 	
  3589 	err = iSubtitleCommands.EnableSubtitles();
  3590 	if (err != KErrNone)
  3591 		{
  3592 		ERR_PRINTF2(_L("EnableSubtitles failed with %d"), err);
  3593 		User::Leave(err);
  3594 		}
  3595 	
  3596 	// Enable subtitles when they are already enabled.
  3597 	err = iSubtitleCommands.EnableSubtitles();
  3598 	if (err != KErrInUse)
  3599 		{
  3600 		ERR_PRINTF3(_L("EnableSubtitles failed with %d; expecting %d when already enabled."), err, KErrInUse);
  3601 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3602 		}
  3603 	
  3604 	AddDefaultSubtitleConfL();
  3605 	StartPlaybackL();
  3606 	}
  3607 
  3608 void RAsyncTestSubtitleDoubleCall::OnPlayCompleteL()
  3609 	{
  3610 	RemoveConfigDisableL();
  3611 	
  3612 	// Disable subtitles when they are not enabled.
  3613 	TInt err = iSubtitleCommands.DisableSubtitles();
  3614 	if (err != KErrNone)
  3615 		{
  3616 		ERR_PRINTF2(_L("DisableSubtitles failed with %d"), err);
  3617 		User::Leave(err);
  3618 		}
  3619 	}
  3620 
  3621 //
  3622 // RAsyncTestSubtitleMultipleConfigs
  3623 //
  3624 RAsyncTestSubtitleMultipleConfigs::RAsyncTestSubtitleMultipleConfigs(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid)
  3625 	:RAsyncTestStepSubtitleBase(aTestName, aSectName, aKeyName, aControllerUid)
  3626 	{
  3627 	SetExpectedCrpReadyCount(1);
  3628 	}
  3629 
  3630 void RAsyncTestSubtitleMultipleConfigs::OnOpenCompleteL()
  3631 	{
  3632 	CheckAndEnableSubtitlesL();
  3633 	AddDefaultSubtitleConfL();
  3634 	
  3635 	TMMFSubtitleWindowConfig config;
  3636 	config.iWindowId = KWindowIdValid;
  3637 	config.iDisplayMode = EColor16MA;
  3638 	config.iRotation = EVideoRotationClockwise90;
  3639 	config.iWindowClipRect = KWindowClipRectAlt1;
  3640 	
  3641 	// Add a config with the same window ID.
  3642 	TInt err = iSubtitleCommands.AddSubtitleConfig(config);
  3643 	if (err != KErrArgument)
  3644 		{
  3645 		ERR_PRINTF3(_L("AddSubtitleConfig returned %d; expected %d"), err, KErrArgument);
  3646 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3647 		}
  3648 	
  3649 	// Add a config with a different ID.
  3650 	config.iWindowId = KWindowIdValidAlt;
  3651 	err = iSubtitleCommands.AddSubtitleConfig(config);
  3652 	if (err != KErrInUse)
  3653 		{
  3654 		ERR_PRINTF3(_L("AddSubtitleConfig returned %d; expected %d"), err, KErrInUse);
  3655 		User::Leave(err == KErrNone ? KErrGeneral : err);
  3656 		}
  3657 	
  3658 	// If we haven't left yet then the test passes.
  3659 	StopTest();
  3660 	}
  3661 
  3662 #endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT