os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclntavi/src/testvideoplayer_subtitles.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2008-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 "testvideoplayer_subtitles.h"
    17 
    18 const TUint KCacheSize = 1000000; //1MB
    19 const TUint KMaxCacheSize = 50000000; //50MB
    20 
    21 
    22 CPlayTimer* CPlayTimer::NewL(RTestVclnt2Subtitle& aTestStep)
    23 	{
    24 	CPlayTimer* self = new (ELeave) CPlayTimer(aTestStep);
    25 	CleanupStack::PushL(self);
    26 	self->ConstructL();
    27 	CleanupStack::Pop();
    28 	return self;
    29 	}
    30 
    31 CPlayTimer::CPlayTimer(RTestVclnt2Subtitle& aTestStep)
    32 	: CTimer(EPriorityHigh), iTestStep(aTestStep)
    33 	{
    34 	CActiveScheduler::Add(this);
    35 	}
    36 
    37 void CPlayTimer::RunL()
    38 	{
    39 	iTestStep.DoDuringPlaybackActionsL();
    40 	}
    41 
    42 TInt CPlayTimer::RunError(TInt aError)
    43 	{
    44 	// Tell the test to fail with error code aError.  
    45 	iTestStep.FailTest(aError);
    46 	return KErrNone;
    47 	}
    48 
    49 //
    50 // RTestVclnt2Subtitle
    51 //
    52 
    53 RTestVclnt2Subtitle* RTestVclnt2Subtitle::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
    54 	{
    55 	return new (ELeave) RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError);
    56 	}
    57 
    58 RTestVclnt2Subtitle::RTestVclnt2Subtitle(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
    59 	: RTestVclnt2AviPlayerStep(aTestName, aSectName, aKeyName, aExpectedError)
    60 	{
    61 	}
    62 
    63 void RTestVclnt2Subtitle::FailTest(TInt aError)
    64 	{
    65 	ERR_PRINTF2(_L("Test step failed with error %d."), aError);
    66 	iError = aError;
    67 	iTestStepResult = EFail;
    68     CActiveScheduler::Stop();
    69 	}
    70 
    71 TVerdict RTestVclnt2Subtitle::DoTestStepPreambleL()
    72 	{
    73 	User::LeaveIfError(SetCacheSize());
    74 	TVerdict result = RTestVclnt2AviPlayerStep::DoTestStepPreambleL();
    75 	
    76 	if (result == EPass)
    77 		{
    78 		iPlayTimer = CPlayTimer::NewL(*this);
    79 		}
    80 	
    81 	return result;
    82 	}
    83 
    84 TVerdict RTestVclnt2Subtitle::DoTestStepPostambleL()
    85 	{
    86 	User::LeaveIfError(RevertCacheSize());
    87 	
    88 	delete iPlayTimer;
    89 	iPlayTimer = NULL;
    90 	return RTestVclnt2AviPlayerStep::DoTestStepPostambleL();
    91 	}
    92 
    93 void RTestVclnt2Subtitle::DoBeforePlaybackActionsL()
    94 	{
    95 	if (!iVideoPlayer2->SubtitlesAvailable())
    96 		{
    97 		ERR_PRINTF1(_L("SubtitlesAvailable() returned EFalse.  Expected ETrue."));
    98 		User::Leave(KErrNotSupported);
    99 		}
   100 	
   101 	iVideoPlayer2->EnableSubtitlesL();
   102 	}
   103 
   104 void RTestVclnt2Subtitle::DoDuringPlaybackActionsL()
   105 	{
   106 	}
   107 
   108 void RTestVclnt2Subtitle::FsmL(TVclntTestPlayEvents aEventCode)
   109 	{
   110 	if (FsmCheck(aEventCode))
   111 		{
   112 		switch (aEventCode)
   113 			{
   114 		case EVPIdle:
   115 			// Open iVideoPlayer2
   116 			LOG_CALL(iVideoPlayer2->OpenFileL(iFilename, KMmfTestAviPlayControllerUid));
   117 			PrepareState(EVPOpenComplete, KErrNone);
   118 			break;
   119 
   120 		case EVPOpenComplete:
   121 			// Prepare iVideoPlayer2
   122 			LOG_CALL(iVideoPlayer2->Prepare());
   123 			PrepareState(EVPPrepareComplete, KErrNone);
   124 			break;
   125 
   126 		case EVPPrepareComplete:
   127 			// Add display window using default values - ie. video extent & window clipping 
   128 			// defaulted to whole window.
   129 			LOG_CALL(iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow));
   130 			
   131 			// Perform any actions that the class or subclasses need before starting video playback.
   132 			DoBeforePlaybackActionsL();
   133 			
   134 			// trigger the video to start playing
   135 			iError = KErrTimedOut;
   136 			PrepareState(EVPPlayComplete, KErrNone);
   137 			LOG_CALL(iVideoPlayer2->Play());
   138 			
   139 			// Trigger a call to DoDuringPlaybackActionsL
   140 			iPlayTimer->After(KOneSecond);
   141 			break;
   142 
   143 		case EVPPlayComplete:
   144 			iTestStepResult = EPass;
   145 			iPlayTimer->Cancel();
   146 			CActiveScheduler::Stop();
   147 			break;
   148 			}
   149 		}
   150 	}
   151 
   152 TInt RTestVclnt2Subtitle::SetCacheSize()
   153 	{
   154 	TInt error=UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)KCacheSize,(TAny*)KMaxCacheSize);
   155 	TInt ret=CheckCacheError(error);
   156 		
   157 	return ret;
   158 	}
   159 
   160 TInt RTestVclnt2Subtitle::CheckCacheError(TInt aError)
   161 	{
   162 	TInt ret=KErrNone;
   163 	#ifdef __WINSCW__
   164 	//Winscw does not support getting cache size. Ignoring -5 error
   165 	if(aError!=KErrNone)
   166 		{
   167 		if(aError!=KErrNotSupported)
   168 			{
   169 			INFO_PRINTF2(_L("Could not get the cache size  %d"),aError);
   170 			ret=aError;
   171 			}
   172 		}
   173 	#else
   174 	if(aError!=KErrNone)
   175 		{//For ARMV5 we stop for all errors
   176 		INFO_PRINTF2(_L("Could not get the cache size  %d"),aError);
   177 		ret=aError;
   178 		}
   179 	#endif
   180 	return ret;
   181 	}
   182 
   183 TInt RTestVclnt2Subtitle::RevertCacheSize()
   184 	{
   185 	TUint defaultCacheSize = 0; 
   186 	//Done with the test. Setting 0 makes the cache size revert back to boot up values
   187 	TInt error=UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)defaultCacheSize,(TAny*)defaultCacheSize);
   188 	return CheckCacheError(error);
   189   	}
   190 
   191 
   192 //
   193 // RTestVclnt2SubtitleEnableDuringPlayback
   194 //
   195 
   196 RTestVclnt2SubtitleEnableDuringPlayback* RTestVclnt2SubtitleEnableDuringPlayback::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   197 	{
   198 	return new (ELeave) RTestVclnt2SubtitleEnableDuringPlayback(aTestName, aSectName, aKeyName, aExpectedError);
   199 	}
   200 
   201 RTestVclnt2SubtitleEnableDuringPlayback::RTestVclnt2SubtitleEnableDuringPlayback(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   202 : RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError)
   203 	{
   204 	}
   205 
   206 void RTestVclnt2SubtitleEnableDuringPlayback::DoBeforePlaybackActionsL()
   207 	{
   208 	INFO_PRINTF1(_L("Don't enable subtitles before playback; do nothing in DoBeforePlaybackActionsL()"));
   209 	}
   210 
   211 void RTestVclnt2SubtitleEnableDuringPlayback::DoDuringPlaybackActionsL()
   212 	{
   213 	if (!iVideoPlayer2->SubtitlesAvailable())
   214 		{
   215 		ERR_PRINTF1(_L("SubtitlesAvailable() returned EFalse.  Expected ETrue."));
   216 		User::Leave(KErrNotSupported);
   217 		}
   218 	
   219 	iVideoPlayer2->EnableSubtitlesL();
   220 	}
   221 
   222 //
   223 // RTestVclnt2SubtitleDisableDuringPlayback
   224 //
   225 
   226 RTestVclnt2SubtitleDisableDuringPlayback* RTestVclnt2SubtitleDisableDuringPlayback::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   227 	{
   228 	return new (ELeave) RTestVclnt2SubtitleDisableDuringPlayback(aTestName, aSectName, aKeyName, aExpectedError);
   229 	}
   230 
   231 RTestVclnt2SubtitleDisableDuringPlayback::RTestVclnt2SubtitleDisableDuringPlayback(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   232 : RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError)
   233 	{
   234 	}
   235 
   236 void RTestVclnt2SubtitleDisableDuringPlayback::DoDuringPlaybackActionsL()
   237 	{
   238 	iVideoPlayer2->DisableSubtitles();
   239 	}
   240 
   241 //
   242 // RTestVclnt2SubtitleDisableTwice
   243 //
   244 
   245 RTestVclnt2SubtitleDisableTwice* RTestVclnt2SubtitleDisableTwice::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   246 	{
   247 	return new (ELeave) RTestVclnt2SubtitleDisableTwice(aTestName, aSectName, aKeyName, aExpectedError);
   248 	}
   249 
   250 RTestVclnt2SubtitleDisableTwice::RTestVclnt2SubtitleDisableTwice(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   251 : RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError)
   252 	{
   253 	}
   254 
   255 void RTestVclnt2SubtitleDisableTwice::DoBeforePlaybackActionsL()
   256 	{
   257 	iVideoPlayer2->DisableSubtitles();
   258 	}
   259 
   260 void RTestVclnt2SubtitleDisableTwice::DoDuringPlaybackActionsL()
   261 	{
   262 	iVideoPlayer2->DisableSubtitles();
   263 	}
   264 
   265 //
   266 // RTestVclnt2SubtitleWindowClipBefore
   267 //
   268 
   269 RTestVclnt2SubtitleWindowClipBefore* RTestVclnt2SubtitleWindowClipBefore::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   270 	{
   271 	return new (ELeave) RTestVclnt2SubtitleWindowClipBefore(aTestName, aSectName, aKeyName, aExpectedError);
   272 	}
   273 
   274 RTestVclnt2SubtitleWindowClipBefore::RTestVclnt2SubtitleWindowClipBefore(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   275 : RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError)
   276 	{
   277 	}
   278 
   279 void RTestVclnt2SubtitleWindowClipBefore::DoBeforePlaybackActionsL()
   280 	{
   281 	RTestVclnt2Subtitle::DoBeforePlaybackActionsL();
   282 		
   283 	TSize windowSize(iWindow->Size().iWidth / 2, iWindow->Size().iHeight / 2);
   284     
   285     // shrink the window clipping rect by half the height & width            
   286     iVideoPlayer2->SetWindowClipRectL(*iWindow, TRect(windowSize));
   287 	}
   288 
   289 //
   290 // RTestVclnt2SubtitleWindowClipDuring
   291 //
   292 
   293 RTestVclnt2SubtitleWindowClipDuring* RTestVclnt2SubtitleWindowClipDuring::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   294 	{
   295 	return new (ELeave) RTestVclnt2SubtitleWindowClipDuring(aTestName, aSectName, aKeyName, aExpectedError);
   296 	}
   297 
   298 RTestVclnt2SubtitleWindowClipDuring::RTestVclnt2SubtitleWindowClipDuring(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   299 : RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError)
   300 	{
   301 	}
   302 
   303 void RTestVclnt2SubtitleWindowClipDuring::DoDuringPlaybackActionsL()
   304 	{
   305 	TSize windowSize(iWindow->Size().iWidth / 2, iWindow->Size().iHeight / 2);
   306     
   307     // shrink the window clipping rect by half the height & width            
   308     iVideoPlayer2->SetWindowClipRectL(*iWindow, TRect(windowSize));
   309 	}
   310 
   311 //
   312 // RTestVclnt2SubtitleRotateBefore
   313 //
   314 
   315 RTestVclnt2SubtitleRotateBefore* RTestVclnt2SubtitleRotateBefore::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   316 	{
   317 	return new (ELeave) RTestVclnt2SubtitleRotateBefore(aTestName, aSectName, aKeyName, aExpectedError);
   318 	}
   319 
   320 RTestVclnt2SubtitleRotateBefore::RTestVclnt2SubtitleRotateBefore(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   321 : RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError)
   322 	{
   323 	}
   324 
   325 void RTestVclnt2SubtitleRotateBefore::DoBeforePlaybackActionsL()
   326 	{
   327 	RTestVclnt2Subtitle::DoBeforePlaybackActionsL();
   328     iVideoPlayer2->SetRotationL(*iWindow, EVideoRotationClockwise180);
   329 	}
   330 
   331 //
   332 // RTestVclnt2SubtitleRotateDuring
   333 //
   334 
   335 RTestVclnt2SubtitleRotateDuring* RTestVclnt2SubtitleRotateDuring::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   336 	{
   337 	return new (ELeave) RTestVclnt2SubtitleRotateDuring(aTestName, aSectName, aKeyName, aExpectedError);
   338 	}
   339 
   340 RTestVclnt2SubtitleRotateDuring::RTestVclnt2SubtitleRotateDuring(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   341 : RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError)
   342 	{
   343 	}
   344 
   345 void RTestVclnt2SubtitleRotateDuring::DoDuringPlaybackActionsL()
   346 	{
   347     iVideoPlayer2->SetRotationL(*iWindow, EVideoRotationClockwise180);
   348 	}
   349 
   350 //
   351 // RTestVclnt2SubtitleRemoveDisplayDuring
   352 //
   353 
   354 RTestVclnt2SubtitleRemoveDisplayDuring* RTestVclnt2SubtitleRemoveDisplayDuring::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   355 	{
   356 	return new (ELeave) RTestVclnt2SubtitleRemoveDisplayDuring(aTestName, aSectName, aKeyName, aExpectedError);
   357 	}
   358 
   359 RTestVclnt2SubtitleRemoveDisplayDuring::RTestVclnt2SubtitleRemoveDisplayDuring(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   360 : RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError)
   361 	{
   362 	}
   363 
   364 void RTestVclnt2SubtitleRemoveDisplayDuring::DoDuringPlaybackActionsL()
   365 	{
   366     iVideoPlayer2->RemoveDisplayWindow(*iWindow);
   367     iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);
   368 	}
   369 
   370 //
   371 // RTestVclnt2SubtitleNotAvailable
   372 //
   373 
   374 RTestVclnt2SubtitleNotAvailable* RTestVclnt2SubtitleNotAvailable::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   375 	{
   376 	return new (ELeave) RTestVclnt2SubtitleNotAvailable(aTestName, aSectName, aKeyName, aExpectedError);
   377 	}
   378 
   379 RTestVclnt2SubtitleNotAvailable::RTestVclnt2SubtitleNotAvailable(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   380 : RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError)
   381 	{
   382 	}
   383 
   384 void RTestVclnt2SubtitleNotAvailable::DoBeforePlaybackActionsL()
   385 	{
   386 	if (iVideoPlayer2->SubtitlesAvailable())
   387 		{
   388 		ERR_PRINTF1(_L("SubtitlesAvailable() returned ETrue.  Expected EFalse."));
   389 		User::Leave(KErrGeneral);
   390 		}
   391 	
   392 	TRAPD(err, iVideoPlayer2->EnableSubtitlesL());
   393 	
   394 	if (KErrNotFound != err)
   395 		{
   396 		ERR_PRINTF3(_L("EnableSubtitlesL() left with %d. Expected %d."), err, KErrNotFound);
   397 		User::Leave(KErrGeneral);
   398 		}
   399 	}
   400 
   401 //
   402 // RTestVclnt2SubtitleLanguage
   403 //
   404 
   405 RTestVclnt2SubtitleLanguage* RTestVclnt2SubtitleLanguage::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   406 	{
   407 	return new (ELeave) RTestVclnt2SubtitleLanguage(aTestName, aSectName, aKeyName, aExpectedError);
   408 	}
   409 
   410 RTestVclnt2SubtitleLanguage::RTestVclnt2SubtitleLanguage(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   411 : RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError)
   412 	{
   413 	}
   414 
   415 void RTestVclnt2SubtitleLanguage::DoBeforePlaybackActionsL()
   416 	{
   417 	RTestVclnt2Subtitle::DoBeforePlaybackActionsL();
   418 	
   419 	TLanguage lang = ELangNone;
   420 	TRAPD(err, lang = iVideoPlayer2->SubtitleLanguageL());
   421 	if (KErrNone != err)
   422 		{
   423 		ERR_PRINTF3(_L("SubtitleLanguageL() left with %d. Expected %d."), err, KErrNone);
   424 		User::Leave(err);
   425 		}
   426 	else if (ELangNone != lang)
   427 		{
   428 		// Languages are not supported; ELangNone should be returned.
   429 		ERR_PRINTF3(_L("SubtitleLanguageL() returned %d.  Expected %d."), lang, ELangNone);
   430 		User::Leave(KErrGeneral);
   431 		}
   432 	
   433 	TInt count = -1;
   434 	TRAP(err, count = iVideoPlayer2->SupportedSubtitleLanguagesL().Count());
   435 	if (KErrNone != err)
   436 		{
   437 		ERR_PRINTF3(_L("SupportedSubtitleLanguagesL() left with %d. Expected %d."), err, KErrNone);
   438 		User::Leave(KErrGeneral);
   439 		}
   440 	if (count != 0)
   441 		{
   442 		ERR_PRINTF1(_L("SupportedSubtitleLanguagesL() returned a non-empty array"));
   443 		User::Leave(KErrGeneral);
   444 		}
   445 	
   446 	TRAP(err, iVideoPlayer2->SetSubtitleLanguageL(lang));
   447 	
   448 	if (KErrNotSupported != err)
   449 		{
   450 		ERR_PRINTF3(_L("SetSubtitleLanguageL() left with %d. Expected %d."), err, KErrNone);
   451 		User::Leave(KErrGeneral);
   452 		}
   453 	}
   454 
   455 //
   456 // RTestVclnt2SubtitleRedraw
   457 //
   458 
   459 RTestVclnt2SubtitleRedraw* RTestVclnt2SubtitleRedraw::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError, TBool aEnableSubtitles)
   460 	{
   461 	return new (ELeave) RTestVclnt2SubtitleRedraw(aTestName, aSectName, aKeyName, aExpectedError, aEnableSubtitles);
   462 	}
   463 
   464 RTestVclnt2SubtitleRedraw::RTestVclnt2SubtitleRedraw(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError, TBool aEnableSubtitles)
   465 : RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError), iEnableSubtitles(aEnableSubtitles)
   466 	{
   467 	}
   468 
   469 void RTestVclnt2SubtitleRedraw::DoBeforePlaybackActionsL()
   470 	{
   471 	if (iEnableSubtitles)
   472 		{
   473 		// The parent class will enable subtitle support
   474 		RTestVclnt2Subtitle::DoBeforePlaybackActionsL();
   475 		}
   476 	}
   477 
   478 void RTestVclnt2SubtitleRedraw::DoDuringPlaybackActionsL()
   479 	{
   480 	// Redraw the whole subtitle
   481 	iWindow->Invalidate();
   482 	LOG_CALL(iVideoPlayer2->RedrawSubtitle(*iWindow, TRect(iWindow->Size())));
   483 	}
   484 
   485 //
   486 // RTestVclnt2SubtitleRotateClipRedraw
   487 //
   488 
   489 RTestVclnt2SubtitleRotateClipRedraw* RTestVclnt2SubtitleRotateClipRedraw::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   490 	{
   491 	return new (ELeave) RTestVclnt2SubtitleRotateClipRedraw(aTestName, aSectName, aKeyName, aExpectedError);
   492 	}
   493 
   494 RTestVclnt2SubtitleRotateClipRedraw::RTestVclnt2SubtitleRotateClipRedraw(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   495 : RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError)
   496 	{
   497 	}
   498 
   499 void RTestVclnt2SubtitleRotateClipRedraw::DoBeforePlaybackActionsL()
   500 	{
   501 	RTestVclnt2Subtitle::DoBeforePlaybackActionsL();
   502 	
   503 	iVideoPlayer2->SetRotationL(*iWindow, EVideoRotationClockwise90);
   504     
   505 	// shrink the window clipping rect by half the height & width
   506 	TSize windowSize(iWindow->Size().iWidth / 3, iWindow->Size().iHeight / 2);
   507 	iVideoPlayer2->SetWindowClipRectL(*iWindow, TRect(windowSize));
   508 	}
   509 
   510 void RTestVclnt2SubtitleRotateClipRedraw::DoDuringPlaybackActionsL()
   511 	{
   512 	// Redraw the whole subtitle
   513 	iWindow->Invalidate();
   514 	iVideoPlayer2->RedrawSubtitle(*iWindow, TRect(iWindow->Size()));
   515 	}
   516 
   517 //
   518 // RTestVclnt2SubtitleMultipleWindows
   519 //
   520 
   521 RTestVclnt2SubtitleMultipleWindows* RTestVclnt2SubtitleMultipleWindows::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   522 	{
   523 	return new (ELeave) RTestVclnt2SubtitleMultipleWindows(aTestName, aSectName, aKeyName, aExpectedError);
   524 	}
   525 
   526 RTestVclnt2SubtitleMultipleWindows::RTestVclnt2SubtitleMultipleWindows(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   527 : RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError)
   528 	{
   529 	}
   530 
   531 TVerdict RTestVclnt2SubtitleMultipleWindows::DoTestStepPreambleL()
   532 	{
   533 	TVerdict result = RTestVclnt2Subtitle::DoTestStepPreambleL();
   534 	
   535 	if (result != EPass)
   536 		{
   537 		return result;
   538 		}
   539 	
   540 	iSecondaryWin = new(ELeave) RWindow(iWs);
   541 	   
   542 	// Construct an RWindow with a unique id.  Use this pointer to get a unique number.
   543 	User::LeaveIfError(iSecondaryWin->Construct(iRootWindow, ((TInt) this) + 3));
   544 	iSecondaryWin->SetRequiredDisplayMode(EColor16MA);
   545 	iSecondaryWin->SetExtent(TPoint(0,0), TSize(100,100));
   546 	iSecondaryWin->SetVisible(ETrue);
   547 	iSecondaryWin->SetBackgroundColor(TRgb(0, 0));
   548 	iSecondaryWin->Activate();
   549 	iSecondaryWin->BeginRedraw();
   550 	iSecondaryWin->EndRedraw();
   551     iWs.Flush();
   552     
   553     return EPass;
   554 	}
   555 
   556 TVerdict RTestVclnt2SubtitleMultipleWindows::DoTestStepPostambleL()
   557 	{
   558 	
   559 	delete iVideoPlayer2;  
   560     iVideoPlayer2 = NULL;      
   561     
   562     iSecondaryWin->Close();
   563 	delete iSecondaryWin;
   564     iSecondaryWin = NULL;
   565         
   566     // Base DoTestStepPostambleL
   567     return RTestVclnt2Subtitle::DoTestStepPostambleL();
   568 	}
   569 	
   570 void RTestVclnt2SubtitleMultipleWindows::DoBeforePlaybackActionsL()
   571 	{
   572 	TRAPD(err, iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iSecondaryWin));
   573 	
   574 	if (err != KErrNone)
   575 		{
   576 		ERR_PRINTF3(_L("Adding second display window with AddDisplayWindowL() left with %d. Expected %d."), err, KErrNone);
   577 		User::Leave(err);
   578 		}
   579 	
   580 	RTestVclnt2Subtitle::DoBeforePlaybackActionsL();
   581 	}
   582 
   583 //
   584 // RTestVclnt2SubtitleEnableTwice
   585 //
   586 
   587 RTestVclnt2SubtitleEnableTwice* RTestVclnt2SubtitleEnableTwice::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   588 	{
   589 	return new (ELeave) RTestVclnt2SubtitleEnableTwice(aTestName, aSectName, aKeyName, aExpectedError);
   590 	}
   591 
   592 RTestVclnt2SubtitleEnableTwice::RTestVclnt2SubtitleEnableTwice(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   593 : RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError)
   594 	{
   595 	}
   596 
   597 void RTestVclnt2SubtitleEnableTwice::DoBeforePlaybackActionsL()
   598 	{	
   599 	RTestVclnt2Subtitle::DoBeforePlaybackActionsL();
   600 	
   601 	// Enable subtitles again
   602 	TRAPD(err, iVideoPlayer2->EnableSubtitlesL());
   603 	
   604 	if (KErrInUse != err)
   605 		{
   606 		ERR_PRINTF3(_L("Calling EnableSubtitlesL twice left with %d. Expected %d."), err, KErrInUse);
   607 		// Leave with KErrGeneral if err is no error.  Otherwise leave with err.
   608 		User::Leave(KErrNone == err ? KErrGeneral : err);
   609 		}
   610 	}
   611 
   612 //
   613 // RTestVclnt2SubtitleEnableDisableStress
   614 //
   615 
   616 RTestVclnt2SubtitleEnableDisableStress* RTestVclnt2SubtitleEnableDisableStress::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   617 	{
   618 	return new (ELeave) RTestVclnt2SubtitleEnableDisableStress(aTestName, aSectName, aKeyName, aExpectedError);
   619 	}
   620 
   621 RTestVclnt2SubtitleEnableDisableStress::RTestVclnt2SubtitleEnableDisableStress(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   622 : RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError)
   623 	{
   624 	// Expect subtitles to be available if this is not being run with "subtitlesUnavailable" file.
   625 	iExpectAvailable = (aKeyName != _L("subtitleUnavailable"));
   626 	}
   627 
   628 void RTestVclnt2SubtitleEnableDisableStress::DoBeforePlaybackActionsL()
   629 	{
   630 	TBool subtitlesAvail = iVideoPlayer2->SubtitlesAvailable();
   631 		
   632 	if (iExpectAvailable != subtitlesAvail)
   633 		{
   634 		ERR_PRINTF1(_L("SubtitlesAvailable() gave unexpected result"));
   635 		User::Leave(KErrGeneral);
   636 		}
   637 		
   638 	if (subtitlesAvail)
   639 		{		
   640 		INFO_PRINTF1(_L("Enabling subtitles"));
   641 		iVideoPlayer2->EnableSubtitlesL();
   642 		}
   643 	else
   644 		{
   645 		INFO_PRINTF1(_L("Subtitles not available"));
   646 		}
   647 	
   648 	iDisableNext = ETrue;
   649 	}
   650 
   651 void RTestVclnt2SubtitleEnableDisableStress::DoDuringPlaybackActionsL()
   652 	{
   653 	TBool subtitlesAvail = iVideoPlayer2->SubtitlesAvailable();
   654 	
   655 	if (iExpectAvailable != subtitlesAvail)
   656 		{
   657 		ERR_PRINTF1(_L("SubtitlesAvailable() gave unexpected result"));
   658 		User::Leave(KErrGeneral);
   659 		}
   660 	
   661 	if (iDisableNext)
   662 		{
   663 		INFO_PRINTF1(_L("Disabling subtitles"));
   664 		iVideoPlayer2->DisableSubtitles();
   665 		}
   666 	else if (subtitlesAvail)
   667 		{
   668 		INFO_PRINTF1(_L("Enabling subtitles"));
   669 		iVideoPlayer2->EnableSubtitlesL();
   670 		}
   671 	else
   672 		{
   673 		INFO_PRINTF1(_L("Subtitles not available... cannot enable"));
   674 		}
   675 	
   676 	iDisableNext = !iDisableNext;
   677 	iPlayTimer->After(KOneSecond / 4);
   678 	}
   679 
   680 //
   681 // RTestVclnt2SubtitleAlloc
   682 //
   683 
   684 RTestVclnt2SubtitleAlloc* RTestVclnt2SubtitleAlloc::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   685 	{
   686 	return new (ELeave) RTestVclnt2SubtitleAlloc(aTestName, aSectName, aKeyName, aExpectedError);
   687 	}
   688 
   689 RTestVclnt2SubtitleAlloc::RTestVclnt2SubtitleAlloc(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
   690 : RTestVclnt2Subtitle(aTestName, aSectName, aKeyName, aExpectedError)
   691 	{
   692 	}
   693 
   694 TVerdict RTestVclnt2SubtitleAlloc::DoTestStepPreambleL()
   695 	{
   696 	// Don't do the normal initialization here.  It will be done before each alloc test iteration.
   697 	return EPass;
   698 	}
   699 
   700 TVerdict RTestVclnt2SubtitleAlloc::DoTestStepPostambleL()
   701 	{
   702 	// Don't do the normal cleanup here.  It will be done after each alloc test iteration.
   703 	return EPass;
   704 	}
   705 
   706 TVerdict  RTestVclnt2SubtitleAlloc::PerformTestL()
   707 	{	
   708 	TVerdict result = EFail;
   709 	TRAPD(err, result = RTestVclnt2Subtitle::DoTestStepPreambleL());
   710 	if (iError != KErrNone)
   711 		{
   712 		err = iError;
   713 		}
   714 	
   715 	if (err == KErrNone && result == EPass && iError == KErrNone)
   716 		{
   717 		TRAP(err, result = RTestVclnt2AviPlayerStep::DoTestStepL());
   718 		
   719 		if (iError != KErrNone)
   720 			{
   721 			err = iError;
   722 			}
   723 		}
   724 	
   725 	// Call postable function, but don't overwrite verdict from previous test call results.
   726 	TVerdict postResult = RTestVclnt2Subtitle::DoTestStepPostambleL();
   727 
   728 	if (iError != KErrNone)
   729 		{
   730 		err = iError;
   731 		}
   732 
   733 	User::LeaveIfError(err);
   734 	if (EPass != result)
   735 		{
   736 		return result;
   737 		}
   738 	if (EPass != postResult)
   739 		{
   740 		return postResult;
   741 		}
   742 	
   743 	return EPass;
   744 	}
   745 
   746 TVerdict RTestVclnt2SubtitleAlloc::DoTestStepL()
   747 	{
   748 	TVerdict allocTestResult = EFail;
   749 	TVerdict result = EFail;
   750 	
   751 	TRAPD(err, result = PerformTestL());
   752 	
   753 	if (err != KErrNone || result != EPass)
   754 		{
   755 		ERR_PRINTF1(_L("Failed to run test iteration without setting heap allocation failure flag"));
   756 		return allocTestResult;
   757 		}
   758 	
   759 	TBool completed = EFalse;
   760 	
   761 	for (TInt rate = 1; !completed; rate++)
   762 		{
   763 		__UHEAP_SETFAIL(RHeap::EFailNext, rate);
   764         __MM_HEAP_MARK;
   765         
   766         result = EFail;
   767         TRAPD(err, result = PerformTestL());
   768         
   769         INFO_PRINTF3(_L("Iteration %d. Alloc failed %d times"), rate, __UHEAP_CHECKFAILURE);
   770         
   771         if (__UHEAP_CHECKFAILURE == 0)
   772         	{
   773         	// Heap did not fail.  Test should have passed with no errors.
   774         	if (KErrNone != result)
   775         		{
   776         		ERR_PRINTF2(_L("Failed on iteration %d. Test failed when no heap allocation failed"), rate);
   777         		allocTestResult = EFail;
   778         		}
   779         	else
   780         		{
   781         		INFO_PRINTF2(_L("Passed on iteration %d."), rate);
   782         		allocTestResult = EPass;
   783         		}
   784         	
   785         	completed = ETrue; // Finished iterating the test
   786         	}
   787         else if ((err == KErrNone && result == EPass) || (err == KErrNoMemory))
   788         	{
   789         	// Continue with next iteration if (a) alloc fail was handled and no error and a pass or 
   790         	// (b) we got an out of memory error.
   791         	INFO_PRINTF3(_L("Iteration result is %d, error is %d.  Starting next iteration"), result, err);
   792         	}
   793         else
   794         	{
   795         	ERR_PRINTF4(_L("Failed on iteration %d. Test failed with error %d.  Expected %d."), rate, err, KErrNoMemory);
   796         	completed = ETrue;
   797         	allocTestResult = EFail;
   798         	}
   799         
   800         __MM_HEAP_MARKEND;
   801 		}
   802 	
   803     __UHEAP_SETFAIL(RHeap::ENone, 0);
   804     
   805     return allocTestResult;
   806 	}