os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclntavi/src/testvideoplayer_apr.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 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 // CPP file: Audio Resource Notification tests for Video Player.
    15 // 
    16 //
    17 
    18 /**
    19  @file testvideoplayer_apr.cpp
    20 */
    21 
    22 #include "testvideoplayer_apr.h"
    23 const TUint KCacheSize = 1000000; //1MB
    24 const TUint KMaxCacheSize = 30000000; //20MB
    25 
    26 
    27 //------------------------------------------------------------------------------
    28 //******************** CR 0805 - Auto Pause Resume for video client********************
    29 //------------------------------------------------------------------------------
    30 
    31 /**
    32  * Standard static NewL() taking a callback function
    33  */
    34 CCallBackTimer* CCallBackTimer::NewL(TCallBack aCallBack, TPriority aPriority)
    35 	{
    36 	CCallBackTimer* self = new(ELeave) CCallBackTimer(aCallBack, aPriority);
    37 	CleanupStack::PushL(self);
    38 	self->ConstructL();
    39 	CleanupStack::Pop(); // self
    40 	return self;
    41 	}
    42 
    43 /**
    44  * Private c'tor
    45  */
    46 CCallBackTimer::CCallBackTimer(TCallBack aCallBack, TPriority aPriority)
    47 : CTimer(aPriority),
    48 iCallBack(aCallBack)
    49 	{
    50 	CActiveScheduler::Add(this);
    51 	}
    52 
    53 /*
    54  * Callback on timer complete
    55  */
    56 void CCallBackTimer::RunL()
    57 	{
    58 	iCallBack.CallBack();
    59 	}
    60 
    61 //
    62 //CTestAVPlayerAPRCallbackSupport
    63 //
    64 
    65 /**
    66  * NewL
    67  */
    68 CTestAVPlayerAPRCallbackSupport* CTestAVPlayerAPRCallbackSupport::NewL(MTestAVPlayerAPRCallback& aCallback)
    69 	{
    70 	return new(ELeave) CTestAVPlayerAPRCallbackSupport(aCallback);
    71 	}
    72 
    73 /** 
    74  * MvpuoOpenComplete
    75  */
    76  void CTestAVPlayerAPRCallbackSupport::MvpuoOpenComplete(TInt aError)
    77 	{
    78 	iCallback.MvpuoOpenCompleteTest(aError, *this);
    79 	}
    80 
    81 /** 
    82  * MvpuoPrepareComplete
    83  */
    84 void CTestAVPlayerAPRCallbackSupport::MvpuoPrepareComplete(TInt aError)
    85 	{
    86 	iCallback.MvpuoPrepareCompleteTest(aError, *this);
    87 	}
    88 
    89 /* 
    90  * MvpuoFrameReady
    91  */
    92 void CTestAVPlayerAPRCallbackSupport::MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError)
    93 	{
    94 	iCallback.MvpuoFrameReadyTest(aFrame, aError, *this);
    95 	}
    96 
    97 /* 
    98  * MvpuoPlayComplete
    99  */
   100 void CTestAVPlayerAPRCallbackSupport::MvpuoPlayComplete(TInt aError)
   101 	{
   102 	iCallback.MvpuoPlayCompleteTest(aError, *this);
   103 	}
   104 
   105 /* 
   106  * MvpuoEvent
   107  */
   108 void CTestAVPlayerAPRCallbackSupport::MvpuoEvent(const TMMFEvent &aEvent)
   109 	{
   110 	iCallback.MvpuoEventTest(aEvent, *this);
   111 	}
   112 
   113 /* 
   114  * MapcInitComplete
   115  */
   116 void CTestAVPlayerAPRCallbackSupport::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration)
   117 	{
   118 	iCallback.MapcInitCompleteTest(aError, aDuration, *this);
   119 	}
   120 
   121 /* 
   122  * MapcPlayComplete
   123  */
   124 void CTestAVPlayerAPRCallbackSupport::MapcPlayComplete(TInt aError)
   125 	{
   126 	iCallback.MapcPlayCompleteTest(aError, *this);
   127 	}
   128 	
   129 /**
   130  * MarncResourceAvailable
   131  */
   132 void CTestAVPlayerAPRCallbackSupport::MarncResourceAvailable(TUid aNotificationEventId, const TDesC8& aNotificationData)
   133 	{
   134 	iCallback.MarncResourceAvailableTest(aNotificationEventId, aNotificationData, *this);
   135 	}
   136 
   137 /**
   138  * Constructor
   139  */
   140 CTestAVPlayerAPRCallbackSupport::CTestAVPlayerAPRCallbackSupport(MTestAVPlayerAPRCallback& aCallback):iCallback(aCallback)
   141 	{
   142 
   143 	}
   144 
   145 //
   146 //RTestMmfVclntVideoPlayerAPR
   147 //
   148 
   149 /**
   150  * Constructor
   151  */
   152 RTestMmfVclntVideoPlayerAPR::RTestMmfVclntVideoPlayerAPR(const TDesC& aTestName, const TDesC& aSectName)
   153 		:RTestMmfVclntAviStep(aTestName, aSectName, _L(""), KErrNone)
   154 	{
   155 	iHeapSize = 1000000;
   156 	iExpEventCount = 1;
   157 	iActEventCount = 0;
   158 	}
   159 
   160 /**
   161  * MvpuoOpenCompleteTest
   162  */
   163 void RTestMmfVclntVideoPlayerAPR::MvpuoOpenCompleteTest(TInt aError, CTestAVPlayerAPRCallbackSupport& aVideoPlayerCallbackSupport)
   164 	{
   165 	if (&aVideoPlayerCallbackSupport == iVideoPlayerCallbackSupport1)
   166 		{
   167 		INFO_PRINTF2(_L("iVideoPlayer -> MMdaVideoPlayerCallback OpenComplete (%d)"), aError);
   168 		Fsm(EMvpuoOpenComplete, aError);
   169 		}
   170 	}
   171 
   172 /**
   173  * MvpuoPrepareCompleteTest
   174  */
   175 void RTestMmfVclntVideoPlayerAPR::MvpuoPrepareCompleteTest(TInt aError, CTestAVPlayerAPRCallbackSupport& aVideoPlayerCallbackSupport)
   176 	{
   177 	if (&aVideoPlayerCallbackSupport == iVideoPlayerCallbackSupport1)
   178 		{
   179 		INFO_PRINTF2(_L("iVideoPlayer -> MMdaVideoPlayerCallback PrepareComplete (%d)"), aError);
   180 		Fsm(EMvpuoPrepareComplete, aError);
   181 		}
   182 	}
   183 /**
   184  * MvpuoFrameReadyTest
   185  */
   186 void RTestMmfVclntVideoPlayerAPR::MvpuoFrameReadyTest(CFbsBitmap &/*aFrame*/, TInt aError, CTestAVPlayerAPRCallbackSupport& aVideoPlayerCallbackSupport)
   187 	{
   188 	if (&aVideoPlayerCallbackSupport == iVideoPlayerCallbackSupport1)
   189 		{
   190 		INFO_PRINTF2(_L("iVideoPlayer -> MMdaVideoPlayerCallback FrameReady (%d)"), aError);
   191 		Fsm(EMvpuoFrameReady, aError);
   192 		}
   193 	}
   194 /**
   195  * MvpuoPlayCompleteTest
   196  */
   197 void RTestMmfVclntVideoPlayerAPR::MvpuoPlayCompleteTest(TInt aError, CTestAVPlayerAPRCallbackSupport& aVideoPlayerCallbackSupport)
   198 	{
   199 	if (&aVideoPlayerCallbackSupport == iVideoPlayerCallbackSupport1)
   200 		{
   201 		Fsm(EMvpuoPlayComplete, aError);
   202 		}
   203 	}
   204 /**
   205  * MvpuoEventTest
   206  */
   207 void RTestMmfVclntVideoPlayerAPR::MvpuoEventTest(const TMMFEvent &aEvent, CTestAVPlayerAPRCallbackSupport& aVideoPlayerCallbackSupport)
   208 	{
   209 	if (&aVideoPlayerCallbackSupport == iVideoPlayerCallbackSupport1)
   210 		{
   211 		INFO_PRINTF2(_L("iVideoPlayer -> MMdaVideoPlayerCallback Event (%d)"), aEvent.iErrorCode);
   212 		Fsm(EMvpuoEvent, aEvent.iErrorCode);
   213 		}
   214 	}
   215 
   216 /**
   217  * MapcInitCompleteTest
   218  */
   219 void RTestMmfVclntVideoPlayerAPR::MapcInitCompleteTest(TInt aError, const TTimeIntervalMicroSeconds &/*aDuration*/, CTestAVPlayerAPRCallbackSupport& aMdaVideoPlayerCallbackSupport)
   220 	{
   221 	if (&aMdaVideoPlayerCallbackSupport == iAudioPlayerCallbackSupport1)
   222 		{
   223 		Fsm(EMapcInitComplete1, aError);
   224 		}
   225 	else if (&aMdaVideoPlayerCallbackSupport == iAudioPlayerCallbackSupport2)
   226 		{
   227 		Fsm(EMapcInitComplete2, aError);
   228 		}	
   229 	}
   230 
   231 /**
   232  * MapcPlayCompleteTest
   233  */
   234 void RTestMmfVclntVideoPlayerAPR::MapcPlayCompleteTest(TInt aError, CTestAVPlayerAPRCallbackSupport& aMdaVideoPlayerCallbackSupport)
   235 	{
   236 	if (&aMdaVideoPlayerCallbackSupport == iAudioPlayerCallbackSupport1)
   237 		{
   238 		Fsm(EMapcPlayComplete1, aError);
   239 		}
   240 	else if (&aMdaVideoPlayerCallbackSupport == iAudioPlayerCallbackSupport2)
   241 		{
   242 		Fsm(EMapcPlayComplete2, aError);
   243 		}	
   244 	}
   245 
   246 /**
   247  * MarncResourceAvailableTest
   248  */
   249 void RTestMmfVclntVideoPlayerAPR::MarncResourceAvailableTest(TUid aNotificationEventId, const TDesC8& aNotificationData, CTestAVPlayerAPRCallbackSupport& aVideoPlayerCallbackSupport)
   250 	{
   251 	if (aNotificationEventId == KMMFEventCategoryAudioResourceAvailable)
   252 		{
   253 		//Convert TDesc8 to TInt64
   254 		TMMFTimeIntervalMicroSecondsPckg timeIntvbuf;
   255 		timeIntvbuf.Copy(aNotificationData);
   256 		TTimeIntervalMicroSeconds intPos = timeIntvbuf();
   257 		iPosition = intPos;
   258 
   259 		if (&aVideoPlayerCallbackSupport == iVideoPlayerCallbackSupport1)
   260 			{
   261 			Fsm(EMarncResourceAvailable1, KErrNone);
   262 			}
   263 		else if (&aVideoPlayerCallbackSupport == iAudioPlayerCallbackSupport1)
   264 			{
   265 			Fsm(EMarncResourceAvailable2, KErrNone);
   266 			}
   267 		else if (&aVideoPlayerCallbackSupport == iAudioPlayerCallbackSupport2)
   268 			{
   269 			Fsm(EMarncResourceAvailable3, KErrNone);
   270 			}
   271 		}
   272 	else
   273 		{
   274 		INFO_PRINTF1(_L("MMMFAudioResourceNotificationCallback, but NOT KMMFEventCategoryAudioResourceAvailable"));
   275 		}
   276 	}
   277 
   278 /**
   279  * DoTestStepCreateL
   280  */
   281 TVerdict RTestMmfVclntVideoPlayerAPR::DoTestStepCreateL()
   282 	{
   283 	TPtrC filename;
   284 	TVerdict ret = EPass;
   285 	TRect rect, clipRect;
   286     //WDP::Increase cache size for paging, else we spend time thrashing
   287 	if(SetCacheSize())
   288     	{
   289     	return EInconclusive;
   290     	}
   291 
   292 	// Get Video file name
   293 	if(!GetStringFromConfig(iSectName, _L("VideoFile1"), filename))
   294 		{
   295 		return EInconclusive;
   296 		}
   297 	GetDriveName(iFilename1);
   298 	iFilename1.Append(filename);
   299 	
   300 	// Initialise Video Player
   301 	INFO_PRINTF2(_L("Initialise CVideoPlayerUtility : %S, EMdaPriorityNormal"), &iFilename1);
   302 	iVideoPlayerCallbackSupport1 = CTestAVPlayerAPRCallbackSupport::NewL(*this);
   303 	CleanupStack::PushL(iVideoPlayerCallbackSupport1);
   304 	iTestVideoPlayer = CVideoPlayerUtility::NewL(*iVideoPlayerCallbackSupport1, EMdaPriorityNormal, EMdaPriorityPreferenceTimeAndQuality, iWs, *iScreen, *iWindow, rect, clipRect);
   305 	CleanupStack::PushL(iTestVideoPlayer);
   306 	
   307 	// Get 1st Audio file name
   308 	if(!GetStringFromConfig(iSectName, _L("AudioFile1"), filename))
   309 		{
   310 		return EInconclusive;
   311 		}
   312 	GetDriveName(iFilename2);
   313 	iFilename2.Append(filename);
   314 	
   315 	// Initialise 1st Audio Player
   316 	INFO_PRINTF2(_L("Initialise CMdaAudioPlayerUtility1 : %S, EMdaPriorityMax"), &iFilename2);
   317 	iAudioPlayerCallbackSupport1 = CTestAVPlayerAPRCallbackSupport::NewL(*this); 
   318 	CleanupStack::PushL(iAudioPlayerCallbackSupport1);
   319 	iTestAudioPlayer1 = CMdaAudioPlayerUtility::NewL(*iAudioPlayerCallbackSupport1, EMdaPriorityMax);
   320 	CleanupStack::PushL(iTestAudioPlayer1);
   321 	
   322 	// Get 2nd Audio file name
   323 	if(!GetStringFromConfig(iSectName, _L("AudioFile2"), filename))
   324 		{
   325 		return EInconclusive;
   326 		}
   327 	GetDriveName(iFilename3);
   328 	iFilename3.Append(filename);
   329 	
   330 	// Initialise 2nd Audio Player
   331 	INFO_PRINTF2(_L("Initialise CMdaAudioPlayerUtility2 : %S, EMdaPriorityMin"), &iFilename3);
   332 	iAudioPlayerCallbackSupport2 = CTestAVPlayerAPRCallbackSupport::NewL(*this); 
   333 	CleanupStack::PushL(iAudioPlayerCallbackSupport2);
   334 	iTestAudioPlayer2 = CMdaAudioPlayerUtility::NewL(*iAudioPlayerCallbackSupport2, EMdaPriorityMin);
   335 	CleanupStack::PushL(iTestAudioPlayer2);
   336 	
   337 	// Initialise the CCallBackTimer.
   338 	iCallBackTimer = CCallBackTimer::NewL(TCallBack(stopActiveScheduler));
   339 	
   340 	// pop all the items from the stack in case of no errors.#
   341 	CleanupStack::Pop(6);
   342 	return ret;
   343 	}
   344 
   345 /**
   346  * DoTestStepDeleteL
   347  */
   348 TVerdict RTestMmfVclntVideoPlayerAPR::DoTestStepDeleteL()
   349 	{
   350 	// Delete all the AudioPlayer and VideoPlayer utilities.
   351 	iTestVideoPlayer->Close();
   352 	delete iTestVideoPlayer;
   353 	iTestVideoPlayer=NULL;
   354 	iTestAudioPlayer1->Close();
   355 	delete iTestAudioPlayer1;
   356 	iTestAudioPlayer1=NULL;
   357 	iTestAudioPlayer2->Close();
   358 	delete iTestAudioPlayer2;
   359 	iTestAudioPlayer2=NULL;
   360 	// Delete CTestAVPlayerAPRCallbackSupport
   361 	delete iVideoPlayerCallbackSupport1;
   362 	delete iAudioPlayerCallbackSupport1;
   363 	delete iAudioPlayerCallbackSupport2;
   364 	// Delete the CCallBackTimer.
   365 	delete iCallBackTimer;
   366 	iCallBackTimer=NULL;
   367 	// return Pass
   368 	return EPass;
   369 	}
   370 
   371 /**
   372  * DoTestStepL
   373  */
   374 TVerdict RTestMmfVclntVideoPlayerAPR::DoTestStepL()
   375 	{
   376 	TVerdict ret = EPass;
   377 	DoTestStepCreateL();
   378 	ret = DoTestL();
   379 	
   380 	TUint defaultCacheSize = 0; 
   381 	//Done with the test. Setting 0 makes the cache size revert back to boot up values
   382 	TInt error=UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)defaultCacheSize,(TAny*)defaultCacheSize);
   383     if(CheckCacheError(error))
   384     	{
   385     	INFO_PRINTF1(_L("Could not revert the cache size to default"));
   386     	ret=EInconclusive;
   387     	}
   388     
   389 	DoTestStepDeleteL();
   390 	return ret;
   391 	}
   392 
   393 /**
   394  * StateInit
   395  */
   396 void RTestMmfVclntVideoPlayerAPR::StateInit()
   397 	{
   398 	iCanStateChange = EFalse;
   399 	for (TInt i=0; i< KMaxEvents; i++)
   400 		{
   401 		iExpectedEvent[i] = EIdlePlayer;
   402 		iExpectedError[i] = KErrNone;
   403 		}
   404 	iState = EStateBegin;	
   405 	}
   406 
   407 /**
   408  * StateChange
   409  */
   410 void RTestMmfVclntVideoPlayerAPR::StateChange(TAVPlayerAPRState aState, TAVPlayerAPREvents aExpectedEvent, TInt aExpectedError, TInt aEventIndex)
   411 	{
   412 	iCanStateChange = EFalse;
   413 	iExpectedEvent[aEventIndex-1] = aExpectedEvent;
   414 	iExpectedError[aEventIndex-1] = aExpectedError;
   415 	iState = aState;
   416 	iActEventCount = 0;
   417 	}
   418 
   419 /**
   420  * FsmCheck
   421  */
   422 TBool RTestMmfVclntVideoPlayerAPR::FsmCheck(TAVPlayerAPREvents aEventCode, TInt aError)
   423 	{
   424 	TBool retFsmCheck = EFalse;
   425 #ifndef SYMBIAN_VARIABLE_BITRATE_CODEC	
   426 	if((aEventCode == EMvpuoOpenComplete) && (aError == KErrNotSupported))
   427 		{
   428 		iTestStepResult = EKnownFailure;
   429 		INFO_PRINTF1(_L("The AVI Play Controller is not available in this OS version, hence KNOWN FAILURE"));
   430 		CActiveScheduler::Stop();
   431 		return retFsmCheck;
   432 		}
   433 #endif
   434 	if (aError == KErrNoMemory)
   435 		{
   436 		// Added to enable Alloc tests with Use Client heap...
   437 		iError = aError;
   438 		iTestStepResult = EFail;
   439 		CActiveScheduler::Stop();
   440 		}
   441 	else
   442 		{
   443 		// analyse if we can go to the next state.
   444 		TInt analysisError = 0;
   445 		analysisError = AnalyseInput(aEventCode, aError);
   446 		if (analysisError == -1)
   447 			{
   448 			iError = aError;
   449 			iTestStepResult = EFail;
   450 			CActiveScheduler::Stop();
   451 			}
   452 		else
   453 			{
   454 			retFsmCheck = ETrue;
   455 			}
   456 		}
   457 	return retFsmCheck;
   458 	}
   459 
   460 /**
   461  * AnalyseInput
   462  * returns 1 = it can move to a new state
   463  * returns 0 = still waiting for more events
   464  * returns -1 = some error has occured
   465  */
   466  TInt RTestMmfVclntVideoPlayerAPR::AnalyseInput(TAVPlayerAPREvents aEventCode, TInt aError)
   467 	{
   468 	TInt res = 0;
   469 	TBool matchFound = EFalse;
   470 	for(TInt i = 0; i < iExpEventCount; i++)
   471 		{
   472 		//check for client and event.
   473 		if((iExpectedEvent[i] == aEventCode) && (iExpectedError[i] == aError))
   474 			{
   475 			iActEventCount++;
   476 			matchFound = ETrue;
   477 			break;
   478 			}
   479 		}
   480 	
   481 	if(matchFound == EFalse)
   482 		{
   483 		for(TInt i = 0; i < iExpEventCount; i++)
   484 			{
   485 			//check for client and event.
   486 			ERR_PRINTF5(_L("Expectedevent[%d]=%d, Actualevent[%d]=%d"), i, iExpectedEvent[i], i, aEventCode);
   487 			ERR_PRINTF5(_L("Expectederror[%d]=%d, Actualerror[%d]=%d"), i, iExpectedError[i], i, aError);
   488 			}
   489 		return -1;
   490 		}
   491 
   492 	if(iActEventCount == iExpEventCount)
   493 		{
   494 		iCanStateChange = ETrue;
   495 		// Reset the event counters, for processing next event.
   496 		iExpEventCount = 1;
   497 		iActEventCount = 0;
   498 		}
   499 	else
   500 		{
   501 		iCanStateChange = EFalse;
   502 		}	
   503 		
   504 	return res;
   505 	}
   506 
   507  TInt RTestMmfVclntVideoPlayerAPR::SetCacheSize()
   508  	{
   509  	TInt error=UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)KCacheSize,(TAny*)KMaxCacheSize);
   510 	TInt ret=CheckCacheError(error);
   511  		
   512  	return ret;
   513  	}
   514 
   515  TInt RTestMmfVclntVideoPlayerAPR::CheckCacheError(TInt aError)
   516  	{
   517  	TInt ret=KErrNone;
   518  	#ifdef __WINSCW__
   519  	//Winscw does not support getting cache size. Ignoring -5 error
   520  	if(aError!=KErrNone)
   521  		{
   522  		if(aError!=KErrNotSupported)
   523  			{
   524  			INFO_PRINTF2(_L("Could not get the cache size  %d"),aError);
   525  			ret=aError;
   526  			}
   527  		}
   528  	#else
   529  	if(aError!=KErrNone)
   530  		{//For ARMV5 we stop for all errors
   531  		INFO_PRINTF2(_L("Could not get the cache size  %d"),aError);
   532  		ret=aError;
   533  		}
   534  	#endif
   535  	return ret;
   536  	}
   537 
   538 
   539 //
   540 //POSITIVE TESTS//
   541 //
   542 
   543 //
   544 //RTestVclntAprRegOnce4SameEvent (MM-MMF-VCLNTAVIAPR-I-0001-HP)
   545 //
   546 
   547 /**
   548  * Constructor
   549  */
   550 RTestVclntAprRegOnce4SameEvent::RTestVclntAprRegOnce4SameEvent(const TDesC& aTestName, const TDesC& aSectName)
   551 	: RTestMmfVclntVideoPlayerAPR(aTestName, aSectName)
   552 	{}
   553 
   554 /**
   555  * NewL
   556  */
   557 RTestVclntAprRegOnce4SameEvent* RTestVclntAprRegOnce4SameEvent::NewL(const TDesC& aTestName, const TDesC& aSectName)
   558 	{
   559 	RTestVclntAprRegOnce4SameEvent* self = new (ELeave) RTestVclntAprRegOnce4SameEvent(aTestName, aSectName);
   560 	return self;
   561 	}
   562 
   563 /**
   564  * DoTestL
   565  */
   566 TVerdict RTestVclntAprRegOnce4SameEvent::DoTestL()
   567 	{
   568 	TVerdict testResult = EFail;
   569 	TRAPD(err, testResult = PerformTestL());
   570 	User::LeaveIfError(err);
   571 	return testResult;
   572 	}
   573 
   574 /**
   575  * FsmL
   576  */
   577 void RTestVclntAprRegOnce4SameEvent::Fsm(TAVPlayerAPREvents aEventCode, TInt aError)
   578 	{
   579 	if ((FsmCheck(aEventCode, aError)) && iCanStateChange)
   580 		{
   581 		TInt retErr = KErrNone;
   582 		switch (iState)
   583 			{
   584 			case EStateBegin:
   585 				{
   586 				// Open iTestVideoPlayer
   587 				if (iBinaryCompatibility)
   588 					{
   589 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1, ControllerUid()));
   590 					}
   591 				else
   592 					{
   593 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1));
   594 					}
   595 				
   596 				if( iError != KErrNone )
   597 					{
   598 					ERR_PRINTF2(_L("iTestVideoPlayer->OpenFileL - Failed with Error : %d"), iError);
   599 					iTestStepResult = EFail;
   600 					CActiveScheduler::Stop();
   601 					break;
   602 					}
   603 				StateChange(EStateOpenVideoPlayer, EMvpuoOpenComplete);
   604 				break;
   605 				}
   606 			case EStateOpenVideoPlayer:
   607 				{
   608 				// Prepare iTestVideoPlayer
   609 				iTestVideoPlayer->Prepare();
   610 				INFO_PRINTF1(_L("iTestVideoPlayer->Prepare()"));
   611 				StateChange(EStatePrepareVideoPlayer, EMvpuoPrepareComplete);
   612 				break;
   613 				}
   614 			case EStatePrepareVideoPlayer:
   615 				{
   616 				// Play iTestVideoPlayer
   617 				iTestVideoPlayer->Play();
   618 				// Open iTestAudioPlayer1
   619 				TRAP(iError, iTestAudioPlayer1->OpenFileL(iFilename2));
   620 				if( iError != KErrNone )
   621 					{
   622 					iTestStepResult = EFail;
   623 					CActiveScheduler::Stop();
   624 					break;
   625 					}
   626 				StateChange(EStateOpenAudioPlayer1, EMapcInitComplete1);
   627 				break;
   628 				}
   629 			case EStateOpenAudioPlayer1:
   630 				{
   631 				// Play iTestAudioPlayer#1
   632 				iTestAudioPlayer1->Play();
   633 				// Set ExpectedEvent and change the State
   634 				StateChange(EStateErrInUseVideoPlayer, EMvpuoPlayComplete, KErrInUse);
   635 				break;
   636 				}
   637 			case EStateErrInUseVideoPlayer:
   638 				{
   639 				// Register iTestVideoPlayer for Notification
   640 				retErr = iTestVideoPlayer->RegisterAudioResourceNotification(*iVideoPlayerCallbackSupport1, KMMFEventCategoryAudioResourceAvailable);
   641 				if( retErr != KErrNone )
   642 					{
   643 					ERR_PRINTF2(_L("iTestVideoPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), retErr);
   644 					iTestStepResult = EFail;
   645 					CActiveScheduler::Stop();
   646 					break;
   647 					}
   648 				// Set ExpectedEvent and change the State
   649 				iExpEventCount = 2;
   650 				StateChange(EStateNotifiedVideoPlayer, EMarncResourceAvailable1, KErrNone, 1);
   651 				StateChange(EStateEndAudioPlay1, EMapcPlayComplete1, KErrNone, 2);
   652 				break;
   653 				}
   654 			case EStateEndAudioPlay1:
   655 				{
   656 				INFO_PRINTF1(_L("iTestVideoPlayer-> Received Notification 1st time"));
   657 				iTestVideoPlayer->Play();
   658 				#ifndef __EABI__
   659 				INFO_PRINTF1(_L("iTestVideoPlayer->Play() - Again"));
   660 				#endif
   661 				iTestAudioPlayer1->Play();
   662 				StateChange(EStateErrInUseVideoPlayer1A, EMvpuoPlayComplete, KErrInUse);
   663 				break;
   664 				}
   665 			case EStateErrInUseVideoPlayer1A:
   666 				{
   667 				// Set ExpectedEvent and change the State
   668 				iExpEventCount = 2;
   669 				StateChange(EStateNotifiedVideoPlayer1A, EMarncResourceAvailable1, KErrNone, 1);
   670 				StateChange(EStateEndAudioPlay1A, EMapcPlayComplete1, KErrNone, 2);
   671 				break;
   672 				}
   673 			case EStateEndAudioPlay1A:
   674 				{
   675 				// we have received all the events, so pass the test
   676 				INFO_PRINTF1(_L("iTestVideoPlayer-> Received Notification 2nd time"));
   677 				iTestStepResult = EPass;
   678 				CActiveScheduler::Stop();
   679 				break;
   680 				}
   681 			}
   682 		}
   683 	}
   684 	
   685 /**
   686  * PerformTestL
   687  */
   688 TVerdict RTestVclntAprRegOnce4SameEvent::PerformTestL()
   689 	{
   690 	INFO_PRINTF1(_L("Register Once for same event"));
   691 	iTestStepResult = EFail;
   692 	
   693 	// Initialise the state variables
   694 	StateInit();
   695 	
   696 	// Begin the process
   697 	Fsm(EIdlePlayer, KErrNone);
   698 	
   699 	// Start the scheduler - Done only once !
   700 	CActiveScheduler::Start();
   701 	
   702 	User::LeaveIfError(iError);
   703 	
   704 	return iTestStepResult;
   705 	}
   706 	
   707 //
   708 //RTestVclntAprRegB4Open (MM-MMF-VCLNTAVIAPR-I-0002-HP)
   709 //
   710 
   711 /**
   712  * Constructor
   713  */
   714 RTestVclntAprRegB4Open::RTestVclntAprRegB4Open(const TDesC& aTestName, const TDesC& aSectName)
   715 	: RTestMmfVclntVideoPlayerAPR(aTestName, aSectName)
   716 	{}
   717 
   718 /**
   719  * NewL
   720  */
   721 RTestVclntAprRegB4Open* RTestVclntAprRegB4Open::NewL(const TDesC& aTestName, const TDesC& aSectName)
   722 	{
   723 	RTestVclntAprRegB4Open* self = new (ELeave) RTestVclntAprRegB4Open(aTestName, aSectName);
   724 	return self;
   725 	}
   726 
   727 /**
   728  * DoTestL
   729  */
   730 TVerdict RTestVclntAprRegB4Open::DoTestL()
   731 	{
   732 	TVerdict testResult = EFail;
   733 	TRAPD(err, testResult = PerformTestL());
   734 	User::LeaveIfError(err);
   735 	return testResult;
   736 	}
   737 
   738 /**
   739  * FsmL
   740  */
   741 void RTestVclntAprRegB4Open::Fsm(TAVPlayerAPREvents aEventCode, TInt aError)
   742 	{
   743 	if ((FsmCheck(aEventCode, aError)) && iCanStateChange)
   744 		{
   745 		TInt retErr = KErrNone;
   746 		switch (iState)
   747 			{
   748 			case EStateBegin:
   749 				{
   750 				// Register iTestVideoPlayer for Notification
   751 				retErr = iTestVideoPlayer->RegisterAudioResourceNotification(*iVideoPlayerCallbackSupport1, KMMFEventCategoryAudioResourceAvailable);
   752 				INFO_PRINTF1(_L("iTestVideoPlayer->RegisterAudioResourceNotification()"));
   753 				if( retErr != KErrNone )
   754 					{
   755 					ERR_PRINTF2(_L("iTestVideoPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), retErr);
   756 					iTestStepResult = EFail;
   757 					CActiveScheduler::Stop();
   758 					break;
   759 					}
   760 				// Open iTestVideoPlayer
   761 				if (iBinaryCompatibility)
   762 					{
   763 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1, ControllerUid()));
   764 					}
   765 				else
   766 					{
   767 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1));
   768 					}
   769 				
   770 				if( iError != KErrNone )
   771 					{
   772 					ERR_PRINTF2(_L("iTestVideoPlayer->OpenFileL - Failed with Error : %d"), iError);
   773 					iTestStepResult = EFail;
   774 					CActiveScheduler::Stop();
   775 					break;
   776 					}				
   777 				StateChange(EStateOpenVideoPlayer, EMvpuoOpenComplete);
   778 				break;
   779 				}
   780 			case EStateOpenVideoPlayer:
   781 				{
   782 				// Prepare iTestVideoPlayer
   783 				iTestVideoPlayer->Prepare();
   784 				INFO_PRINTF1(_L("iTestVideoPlayer->Prepare()"));
   785 				StateChange(EStatePrepareVideoPlayer, EMvpuoPrepareComplete);
   786 				break;
   787 				}
   788 			case EStatePrepareVideoPlayer:
   789 				{
   790 				// Open iTestAudioPlayer1
   791 				TRAP(iError, iTestAudioPlayer1->OpenFileL(iFilename2));
   792 				INFO_PRINTF2(_L("iTestAudioPlayer1->OpenFileL(), returned %d"), iError);
   793 				if( iError != KErrNone )
   794 					{
   795 					iTestStepResult = EFail;
   796 					CActiveScheduler::Stop();
   797 					break;
   798 					}				
   799 				// Set ExpectedEvent and change the State
   800 				StateChange(EStateOpenAudioPlayer1, EMapcInitComplete1);
   801 				break;
   802 				}
   803 			case EStateOpenAudioPlayer1:
   804 				{
   805 				// Play iTestAudioPlayer#1
   806 				iTestAudioPlayer1->Play();
   807 				INFO_PRINTF1(_L("iTestAudioPlayer1->Play()"));
   808 				// Play iTestVideoPlayer
   809 				iTestVideoPlayer->Play();
   810 				INFO_PRINTF1(_L("iTestVideoPlayer->Play()"));	
   811 				// Set ExpectedEvent and change the State
   812 				StateChange(EStateErrInUseVideoPlayer, EMvpuoPlayComplete, KErrInUse);
   813 				break;
   814 				}
   815 			case EStateErrInUseVideoPlayer:
   816 				{
   817 				// Set ExpectedEvent and change the State
   818 				iExpEventCount = 2;
   819 				StateChange(EStateNotifiedVideoPlayer, EMarncResourceAvailable1, KErrNone, 1);
   820 				StateChange(EStateEndAudioPlay1, EMapcPlayComplete1, KErrNone, 2);
   821 				break;
   822 				}
   823 			case EStateEndAudioPlay1:
   824 				{
   825 				// we have received all the events, so pass the test
   826 				INFO_PRINTF1(_L("iTestVideoPlayer->NotificationReceived"));
   827 				iTestStepResult = EPass;
   828 				CActiveScheduler::Stop();
   829 				break;
   830 				}
   831 			}
   832 		}
   833 	}
   834 		
   835 	
   836 /**
   837  * PerformTestL
   838  */
   839 TVerdict RTestVclntAprRegB4Open::PerformTestL()
   840 	{
   841 	INFO_PRINTF1(_L("Register before opening video player"));
   842 	iTestStepResult = EFail;
   843 	
   844 	// Initialise the state variables
   845 	StateInit();
   846 	
   847 	// Begin the process
   848 	Fsm(EIdlePlayer, KErrNone);
   849 	
   850 	// Start the scheduler - Done only once !
   851 	CActiveScheduler::Start();
   852 	
   853 	User::LeaveIfError(iError);
   854 	
   855 	return iTestStepResult;
   856 	}
   857 	
   858 //
   859 //RTestVclntAprRegAftrOpenAndB4Play (MM-MMF-VCLNTAVIAPR-I-0003-HP)
   860 //
   861 
   862 /**
   863  * Constructor
   864  */
   865 RTestVclntAprRegAftrOpenAndB4Play::RTestVclntAprRegAftrOpenAndB4Play(const TDesC& aTestName, const TDesC& aSectName)
   866 	: RTestMmfVclntVideoPlayerAPR(aTestName, aSectName)
   867 	{
   868 	 iVidPosition = 0;
   869 	}
   870 
   871 /**
   872  * NewL
   873  */
   874 RTestVclntAprRegAftrOpenAndB4Play* RTestVclntAprRegAftrOpenAndB4Play::NewL(const TDesC& aTestName, const TDesC& aSectName)
   875 	{
   876 	RTestVclntAprRegAftrOpenAndB4Play* self = new (ELeave) RTestVclntAprRegAftrOpenAndB4Play(aTestName, aSectName);
   877 	return self;
   878 	}
   879 
   880 /**
   881  * DoTestL
   882  */
   883 TVerdict RTestVclntAprRegAftrOpenAndB4Play::DoTestL()
   884 	{
   885 	TVerdict testResult = EFail;
   886 	TRAPD(err, testResult = PerformTestL());
   887 	User::LeaveIfError(err);
   888 	return testResult;
   889 	}
   890 
   891 /**
   892  * FsmL
   893  */
   894 void RTestVclntAprRegAftrOpenAndB4Play::Fsm(TAVPlayerAPREvents aEventCode, TInt aError)
   895 	{
   896 	if ((FsmCheck(aEventCode, aError)) && iCanStateChange)
   897 		{
   898 		TInt retErr = KErrNone;
   899 		switch (iState)
   900 			{
   901 			case EStateBegin:
   902 				{
   903 				// Open iTestVideoPlayer
   904 				if (iBinaryCompatibility)
   905 					{
   906 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1, ControllerUid()));
   907 					}
   908 				else
   909 					{
   910 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1));
   911 					}
   912 				
   913 				if( iError != KErrNone )
   914 					{
   915 					ERR_PRINTF2(_L("iTestVideoPlayer->OpenFileL - Failed with Error : %d"), iError);
   916 					iTestStepResult = EFail;
   917 					CActiveScheduler::Stop();
   918 					break;
   919 					}
   920 				StateChange(EStateOpenVideoPlayer, EMvpuoOpenComplete);
   921 				break;
   922 				}
   923 			case EStateOpenVideoPlayer:
   924 				{
   925 				// Register iTestVideoPlayer for Notification
   926 				retErr = iTestVideoPlayer->RegisterAudioResourceNotification(*iVideoPlayerCallbackSupport1, KMMFEventCategoryAudioResourceAvailable);
   927 				INFO_PRINTF1(_L("iTestVideoPlayer->RegisterAudioResourceNotification()"));
   928 				if( retErr != KErrNone )
   929 					{
   930 					ERR_PRINTF2(_L("iTestVideoPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), retErr);
   931 					iTestStepResult = EFail;
   932 					CActiveScheduler::Stop();
   933 					break;
   934 					}
   935 				// Prepare iTestVideoPlayer
   936 				iTestVideoPlayer->Prepare();
   937 				INFO_PRINTF1(_L("iTestVideoPlayer->Prepare()"));
   938 				StateChange(EStatePrepareVideoPlayer, EMvpuoPrepareComplete);
   939 				break;
   940 				}
   941 			case EStatePrepareVideoPlayer:
   942 				{
   943 				// Play iTestVideoPlayer
   944 				iTestVideoPlayer->Play();
   945 				INFO_PRINTF1(_L("iTestVideoPlayer->Play()"));
   946 				// Open iTestAudioPlayer1
   947 				TRAP(iError, iTestAudioPlayer1->OpenFileL(iFilename2));
   948 				INFO_PRINTF2(_L("iTestAudioPlayer1->OpenFileL(), returned %d"), iError);
   949 				if( iError != KErrNone )
   950 					{
   951 					iTestStepResult = EFail;
   952 					CActiveScheduler::Stop();
   953 					break;
   954 					}
   955 				// Set ExpectedEvent and change the State
   956 				StateChange(EStateOpenAudioPlayer1, EMapcInitComplete1);
   957 				break;
   958 				}
   959 			case EStateOpenAudioPlayer1:
   960 				{
   961 				// Get position for iTestVideoPlayer
   962 				TRAP(iError, iVidPosition = iTestVideoPlayer->PositionL());
   963 				INFO_PRINTF3(_L("iTestVideoPlayer->Position returned %d, error %d"), I64LOW(iVidPosition.Int64()), iError);
   964 				if( iError != KErrNone )
   965 					{
   966 					iTestStepResult = EFail;
   967 					CActiveScheduler::Stop();
   968 					break;
   969 					}
   970 				// Play iTestAudioPlayer#1
   971 				iTestAudioPlayer1->Play();
   972 				INFO_PRINTF1(_L("iTestAudioPlayer1->Play()"));
   973 				// Set ExpectedEvent and change the State
   974 				StateChange(EStateErrInUseVideoPlayer, EMvpuoPlayComplete, KErrInUse);
   975 				break;
   976 				}
   977 			case EStateErrInUseVideoPlayer:
   978 				{
   979 				// Set ExpectedEvent and change the State
   980 				iExpEventCount = 2;
   981 				StateChange(EStateNotifiedVideoPlayer, EMarncResourceAvailable1, KErrNone, 1);
   982 				StateChange(EStateEndAudioPlay1, EMapcPlayComplete1, KErrNone, 2);
   983 				break;
   984 				}
   985 			case EStateEndAudioPlay1:
   986 				{
   987 				INFO_PRINTF2(_L("iTestVideoPlayer->Position returned after receiving Notification = %d"), I64LOW(iPosition.Int64()));
   988 				// we have received all the events, so pass the test
   989 				// Check the position
   990 				CActiveScheduler::Stop();
   991 				// check the difference with a time dalay
   992 				if(TimeComparison(I64INT(iPosition.Int64()), I64INT(iVidPosition.Int64()), KExpectedDeviation))
   993 					{
   994 					INFO_PRINTF1(_L("Position matches..."));
   995 					iTestStepResult = EPass;
   996 					}
   997 				else
   998 					{
   999 					INFO_PRINTF1(_L("Position does not match..."));
  1000 					iTestStepResult = EFail;
  1001 					}
  1002 				break;
  1003 				}
  1004 			}
  1005 		}
  1006 	}
  1007 		
  1008 	
  1009 /**
  1010  * PerformTestL
  1011  */
  1012 TVerdict RTestVclntAprRegAftrOpenAndB4Play::PerformTestL()
  1013 	{
  1014 	INFO_PRINTF1(_L("Register after opening and before playing video player"));
  1015 	iTestStepResult = EFail;
  1016 	
  1017 	// Initialise the state variables
  1018 	StateInit();
  1019 	
  1020 	// Begin the process
  1021 	Fsm(EIdlePlayer, KErrNone);
  1022 	
  1023 	// Start the scheduler - Done only once !
  1024 	CActiveScheduler::Start();
  1025 	
  1026 	User::LeaveIfError(iError);
  1027 		
  1028 	return iTestStepResult;
  1029 	}
  1030 	
  1031 //
  1032 //RTestVclntAprRegAftrHpClntCompltPlay (MM-MMF-VCLNTAVIAPR-I-0004-HP)
  1033 //
  1034 
  1035 /**
  1036  * Constructor
  1037  */
  1038 RTestVclntAprRegAftrHpClntCompltPlay::RTestVclntAprRegAftrHpClntCompltPlay(const TDesC& aTestName, const TDesC& aSectName)
  1039 	: RTestMmfVclntVideoPlayerAPR(aTestName, aSectName)
  1040 	{}
  1041 
  1042 /**
  1043  * NewL
  1044  */
  1045 RTestVclntAprRegAftrHpClntCompltPlay* RTestVclntAprRegAftrHpClntCompltPlay::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1046 	{
  1047 	RTestVclntAprRegAftrHpClntCompltPlay* self = new (ELeave) RTestVclntAprRegAftrHpClntCompltPlay(aTestName, aSectName);
  1048 	return self;
  1049 	}
  1050 
  1051 /**
  1052  * DoTestL
  1053  */
  1054 TVerdict RTestVclntAprRegAftrHpClntCompltPlay::DoTestL()
  1055 	{
  1056 	TVerdict testResult = EFail;
  1057 	TRAPD(err, testResult = PerformTestL());
  1058 	User::LeaveIfError(err);
  1059 	return testResult;
  1060 	}
  1061 
  1062 /**
  1063  * FsmL
  1064  */
  1065 void RTestVclntAprRegAftrHpClntCompltPlay::Fsm(TAVPlayerAPREvents aEventCode, TInt aError)
  1066 	{
  1067 	if ((FsmCheck(aEventCode, aError)) && iCanStateChange)
  1068 		{
  1069 		TInt retErr = KErrNone;
  1070 		switch (iState)
  1071 			{
  1072 			case EStateBegin:
  1073 				{
  1074 				// Open iTestVideoPlayer
  1075 				if (iBinaryCompatibility)
  1076 					{
  1077 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1, ControllerUid()));
  1078 					}
  1079 				else
  1080 					{
  1081 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1));
  1082 					}
  1083 				
  1084 				if( iError != KErrNone )
  1085 					{
  1086 					ERR_PRINTF2(_L("iTestVideoPlayer->OpenFileL - Failed with Error : %d"), iError);
  1087 					iTestStepResult = EFail;
  1088 					CActiveScheduler::Stop();
  1089 					break;
  1090 					}
  1091 				StateChange(EStateOpenVideoPlayer, EMvpuoOpenComplete);
  1092 				break;
  1093 				}
  1094 			case EStateOpenVideoPlayer:
  1095 				{
  1096 				// Prepare iTestVideoPlayer
  1097 				iTestVideoPlayer->Prepare();
  1098 				INFO_PRINTF1(_L("iTestVideoPlayer->Prepare()"));
  1099 				StateChange(EStatePrepareVideoPlayer, EMvpuoPrepareComplete);
  1100 				break;
  1101 				}
  1102 			case EStatePrepareVideoPlayer:
  1103 				{
  1104 				// Play iTestVideoPlayer
  1105 				iTestVideoPlayer->Play();
  1106 				INFO_PRINTF1(_L("iTestVideoPlayer->Play()"));
  1107 				// Open iTestAudioPlayer1
  1108 				TRAP(iError, iTestAudioPlayer1->OpenFileL(iFilename2));
  1109 				INFO_PRINTF2(_L("iTestAudioPlayer1->OpenFileL(), returned %d"), iError);
  1110 				if( iError != KErrNone )
  1111 					{
  1112 					iTestStepResult = EFail;
  1113 					CActiveScheduler::Stop();
  1114 					break;
  1115 					}				
  1116 				// Set ExpectedEvent and change the State
  1117 				StateChange(EStateOpenAudioPlayer1, EMapcInitComplete1);
  1118 				break;
  1119 				}
  1120 			case EStateOpenAudioPlayer1:
  1121 				{
  1122 				// Play iTestAudioPlayer#1
  1123 				iTestAudioPlayer1->Play();
  1124 				INFO_PRINTF1(_L("iTestAudioPlayer1->Play()"));
  1125 				// Set ExpectedEvent and change the State
  1126 				StateChange(EStateErrInUseVideoPlayer, EMvpuoPlayComplete, KErrInUse);
  1127 				break;
  1128 				}
  1129 			case EStateErrInUseVideoPlayer:
  1130 				{
  1131 				// Set ExpectedEvent and change the State
  1132 				StateChange(EStateEndAudioPlay1, EMapcPlayComplete1);
  1133 				break;
  1134 				}
  1135 			case EStateEndAudioPlay1:
  1136 				{
  1137 				// Register iTestVideoPlayer for Notification
  1138 				retErr = iTestVideoPlayer->RegisterAudioResourceNotification(*iVideoPlayerCallbackSupport1, KMMFEventCategoryAudioResourceAvailable);
  1139 				INFO_PRINTF1(_L("iTestVideoPlayer->RegisterAudioResourceNotification()"));
  1140 				if( retErr != KErrNone )
  1141 					{
  1142 					ERR_PRINTF2(_L("iTestVideoPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), retErr);
  1143 					iTestStepResult = EFail;
  1144 					CActiveScheduler::Stop();
  1145 					break;
  1146 					}
  1147 				// Play iTestVideoPlayer again
  1148 				iTestVideoPlayer->Play();
  1149 				INFO_PRINTF1(_L("iTestVideoPlayer->Play() - Again"));
  1150 				// Play iTestAudioPlayer1 again
  1151 				iTestAudioPlayer1->Play();
  1152 				INFO_PRINTF1(_L("iTestAudioPlayer1->Play() - Again"));
  1153 				// Set ExpectedEvent and change the State
  1154 				StateChange(EStateErrInUseVideoPlayer1A, EMvpuoPlayComplete, KErrInUse);
  1155 				break;
  1156 				}
  1157 			case EStateErrInUseVideoPlayer1A:
  1158 				{
  1159 				iCallBackTimer->Cancel(); // in case some other event (apart from Notification is received)
  1160 				// Set ExpectedEvent and change the State 
  1161 				iExpEventCount = 2;
  1162 				StateChange(EStateNotifiedVideoPlayer1A, EMarncResourceAvailable1, KErrNone, 1);
  1163 				StateChange(EStateEndAudioPlay1A, EMapcPlayComplete1, KErrNone, 2);
  1164 				break;
  1165 				}
  1166 			case EStateEndAudioPlay1A:
  1167 				{
  1168 				// we have received all the events, so pass the test
  1169 				INFO_PRINTF1(_L("iTestVideoPlayer->NotificationReceived"));
  1170 				iTestStepResult = EPass;
  1171 				CActiveScheduler::Stop();
  1172 				break;
  1173 				}
  1174 			}
  1175 		}
  1176 	}
  1177 		
  1178 	
  1179 /**
  1180  * PerformTestL
  1181  */
  1182 TVerdict RTestVclntAprRegAftrHpClntCompltPlay::PerformTestL()
  1183 	{
  1184 	INFO_PRINTF1(_L("Registration after the the High priority client completes play"));
  1185 	iTestStepResult = EFail;
  1186 	
  1187 	// Initialise the state variables
  1188 	StateInit();
  1189 	
  1190 	// Begin the process
  1191 	Fsm(EIdlePlayer, KErrNone);
  1192 	
  1193 	// Start the scheduler - Done only once !
  1194 	CActiveScheduler::Start();
  1195 	
  1196 	User::LeaveIfError(iError);
  1197 	
  1198 	return iTestStepResult;
  1199 	}
  1200 
  1201 //
  1202 //RTestVclntAprRegSamePriorityPlayers (MM-MMF-VCLNTAVIAPR-I-0005-HP)
  1203 //
  1204 
  1205 /**
  1206  * Constructor
  1207  */
  1208 RTestVclntAprRegSamePriorityPlayers::RTestVclntAprRegSamePriorityPlayers(const TDesC& aTestName, const TDesC& aSectName)
  1209 	: RTestMmfVclntVideoPlayerAPR(aTestName, aSectName)
  1210 	{}
  1211 
  1212 /**
  1213  * NewL
  1214  */
  1215 RTestVclntAprRegSamePriorityPlayers* RTestVclntAprRegSamePriorityPlayers::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1216 	{
  1217 	RTestVclntAprRegSamePriorityPlayers* self = new (ELeave) RTestVclntAprRegSamePriorityPlayers(aTestName, aSectName);
  1218 	return self;
  1219 	}
  1220 
  1221 /**
  1222  * DoTestL
  1223  */
  1224 TVerdict RTestVclntAprRegSamePriorityPlayers::DoTestL()
  1225 	{
  1226 	TVerdict testResult = EFail;
  1227 	TRAPD(err, testResult = PerformTestL());
  1228 	User::LeaveIfError(err);
  1229 	return testResult;
  1230 	}
  1231 
  1232 /**
  1233  * FsmL
  1234  */
  1235 void RTestVclntAprRegSamePriorityPlayers::Fsm(TAVPlayerAPREvents aEventCode, TInt aError)
  1236 	{
  1237 	if ((FsmCheck(aEventCode, aError)) && iCanStateChange)
  1238 		{
  1239 		TInt retErr = KErrNone;
  1240 		TInt retErr1 = KErrNone;
  1241 		switch (iState)
  1242 			{
  1243 			case EStateBegin:
  1244 				{
  1245 				// Open iTestVideoPlayer
  1246 				if (iBinaryCompatibility)
  1247 					{
  1248 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1, ControllerUid()));
  1249 					}
  1250 				else
  1251 					{
  1252    				    TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1));
  1253 					}
  1254 				
  1255 				if( iError != KErrNone )
  1256 					{
  1257 					ERR_PRINTF2(_L("iTestVideoPlayer->OpenFileL - Failed with Error : %d"), iError);
  1258 					iTestStepResult = EFail;
  1259 					CActiveScheduler::Stop();
  1260 					break;
  1261 					}
  1262 				StateChange(EStateOpenVideoPlayer, EMvpuoOpenComplete);
  1263 				break;
  1264 				}
  1265 			case EStateOpenVideoPlayer:
  1266 				{
  1267 				// Prepare iTestVideoPlayer
  1268 				iTestVideoPlayer->Prepare();
  1269 				INFO_PRINTF1(_L("iTestVideoPlayer->Prepare()"));
  1270 				StateChange(EStatePrepareVideoPlayer, EMvpuoPrepareComplete);
  1271 				break;
  1272 				}
  1273 			case EStatePrepareVideoPlayer:
  1274 				{
  1275 				// Play iTestVideoPlayer
  1276 				iTestVideoPlayer->Play();
  1277 				INFO_PRINTF1(_L("iTestVideoPlayer->Play()"));
  1278 				// Open iTestAudioPlayer1
  1279 				TRAP(iError, iTestAudioPlayer1->OpenFileL(iFilename2));
  1280 				INFO_PRINTF2(_L("iTestAudioPlayer1->OpenFileL(), returned %d"), iError);
  1281 				if( iError != KErrNone )
  1282 					{
  1283 					iTestStepResult = EFail;
  1284 					CActiveScheduler::Stop();
  1285 					break;
  1286 					}				
  1287 				// Set ExpectedEvent and change the State
  1288 				StateChange(EStateOpenAudioPlayer1, EMapcInitComplete1);
  1289 				break;
  1290 				}
  1291 			case EStateOpenAudioPlayer1:
  1292 				{
  1293 				// Play iTestAudioPlayer#1
  1294 				iTestAudioPlayer1->Play();
  1295 				INFO_PRINTF1(_L("iTestAudioPlayer1->Play()"));
  1296 				// Set ExpectedEvent and change the State
  1297 				StateChange(EStateErrInUseVideoPlayer, EMvpuoPlayComplete, KErrInUse);
  1298 				break;
  1299 				}
  1300 			case EStateErrInUseVideoPlayer:
  1301 				{
  1302 				// Register iTestVideoPlayer for Notification
  1303 				retErr = iTestVideoPlayer->RegisterAudioResourceNotification(*iVideoPlayerCallbackSupport1, KMMFEventCategoryAudioResourceAvailable);
  1304 				INFO_PRINTF1(_L("iTestVideoPlayer->RegisterAudioResourceNotification()"));
  1305 				if( retErr != KErrNone )
  1306 					{
  1307 					ERR_PRINTF2(_L("iTestVideoPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), retErr);
  1308 					iTestStepResult = EFail;
  1309 					CActiveScheduler::Stop();
  1310 					break;
  1311 					}
  1312 				// Open iTestAudioPlayer2
  1313 				TRAP(iError, iTestAudioPlayer2->OpenFileL(iFilename3));
  1314 				INFO_PRINTF2(_L("iTestAudioPlayer2->OpenFileL(), returned %d"), iError);
  1315 				if( iError != KErrNone )
  1316 					{
  1317 					iTestStepResult = EFail;
  1318 					CActiveScheduler::Stop();
  1319 					break;
  1320 					}		
  1321 				// Set ExpectedEvent and change the State
  1322 				StateChange(EStateOpenAudioPlayer2, EMapcInitComplete2);
  1323 				break;
  1324 				}
  1325 			case EStateOpenAudioPlayer2:
  1326 				{
  1327 				// Play iTestAudioPlayer#2
  1328 				iTestAudioPlayer2->Play();
  1329 				INFO_PRINTF1(_L("iTestAudioPlayer2->Play()"));
  1330 				// Set ExpectedEvent and change the State
  1331 				StateChange(EStateErrInUseAudioPlayer2, EMapcPlayComplete2, KErrInUse);
  1332 				break;
  1333 				}
  1334 			case EStateErrInUseAudioPlayer2:
  1335 				{
  1336 				// Register iTestAudioPlayer2 for Notification
  1337 				retErr1 = iTestAudioPlayer2->RegisterAudioResourceNotification(*iAudioPlayerCallbackSupport2, KMMFEventCategoryAudioResourceAvailable);
  1338 				INFO_PRINTF1(_L("iTestAudioPlayer2->RegisterAudioResourceNotification()"));
  1339 				if( retErr1 != KErrNone )
  1340 					{
  1341 					ERR_PRINTF2(_L("iTestAudioPlayer2->RegisterAudioResourceNotification - Failed with Error : %d"), retErr1);
  1342 					iTestStepResult = EFail;
  1343 					CActiveScheduler::Stop();
  1344 					break;
  1345 					}
  1346 				// Set ExpectedEvent and change the State
  1347 				iExpEventCount = 2;
  1348 				StateChange(EStateNotifiedVideoPlayer, EMarncResourceAvailable1, KErrNone, 1);
  1349 				StateChange(EStateEndAudioPlay1, EMapcPlayComplete1, KErrNone, 2);
  1350 				break;
  1351 				}
  1352 			case EStateEndAudioPlay1:
  1353 				{
  1354 				// we have received all the events, so pass the test
  1355 				INFO_PRINTF1(_L("iTestVideoPlayer->NotificationReceived"));
  1356 				iTestStepResult = EPass;
  1357 				CActiveScheduler::Stop();
  1358 				break;
  1359 				}
  1360 			}
  1361 		}
  1362 	}
  1363 		
  1364 	
  1365 /**
  1366  * PerformTestL
  1367  */
  1368 TVerdict RTestVclntAprRegSamePriorityPlayers::PerformTestL()
  1369 	{
  1370 	INFO_PRINTF1(_L("Receive notification by same priority players in the order of registration"));
  1371 	iTestStepResult = EFail;
  1372 	
  1373 	// Initialise the state variables
  1374 	StateInit();
  1375 	
  1376 	// Begin the process
  1377 	Fsm(EIdlePlayer, KErrNone);
  1378 	
  1379 	// Start the scheduler - Done only once !
  1380 	CActiveScheduler::Start();
  1381 	
  1382 	User::LeaveIfError(iError);
  1383 	
  1384 	return iTestStepResult;
  1385 	}
  1386 
  1387 //
  1388 //RTestVclntAprRegAtPlayAndCancelNfn (MM-MMF-VCLNTAVIAPR-I-0006-HP)
  1389 //
  1390 
  1391 /**
  1392  * Constructor
  1393  */
  1394 RTestVclntAprRegAtPlayAndCancelNfn::RTestVclntAprRegAtPlayAndCancelNfn(const TDesC& aTestName, const TDesC& aSectName)
  1395 	: RTestMmfVclntVideoPlayerAPR(aTestName, aSectName)
  1396 	{}
  1397 
  1398 /**
  1399  * NewL
  1400  */
  1401 RTestVclntAprRegAtPlayAndCancelNfn* RTestVclntAprRegAtPlayAndCancelNfn::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1402 	{
  1403 	RTestVclntAprRegAtPlayAndCancelNfn* self = new (ELeave) RTestVclntAprRegAtPlayAndCancelNfn(aTestName, aSectName);
  1404 	return self;
  1405 	}
  1406 
  1407 /**
  1408  * DoTestL
  1409  */
  1410 TVerdict RTestVclntAprRegAtPlayAndCancelNfn::DoTestL()
  1411 	{
  1412 	TVerdict testResult = EFail;
  1413 	TRAPD(err, testResult = PerformTestL());
  1414 	User::LeaveIfError(err);
  1415 	return testResult;
  1416 	}
  1417 
  1418 /**
  1419  * FsmL
  1420  */
  1421 void RTestVclntAprRegAtPlayAndCancelNfn::Fsm(TAVPlayerAPREvents aEventCode, TInt aError)
  1422 	{
  1423 	if (FsmCheck(aEventCode, aError))
  1424 		{
  1425 		TInt retErr = KErrNone;
  1426 		TInt retErr1 = KErrNone;
  1427 		switch (iState)
  1428 			{
  1429 			case EStateBegin:
  1430 				{
  1431 				// Open iTestVideoPlayer
  1432 				if (iBinaryCompatibility)
  1433 					{
  1434 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1, ControllerUid()));
  1435 					}
  1436 				else
  1437 					{
  1438 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1));
  1439 					}
  1440 				
  1441 				if( iError != KErrNone )
  1442 					{
  1443 					ERR_PRINTF2(_L("iTestVideoPlayer->OpenFileL - Failed with Error : %d"), iError);
  1444 					iTestStepResult = EFail;
  1445 					CActiveScheduler::Stop();
  1446 					break;
  1447 					}
  1448 				StateChange(EStateOpenVideoPlayer, EMvpuoOpenComplete);
  1449 				break;
  1450 				}
  1451 			case EStateOpenVideoPlayer:
  1452 				{
  1453 				// Prepare iTestVideoPlayer
  1454 				iTestVideoPlayer->Prepare();
  1455 				INFO_PRINTF1(_L("iTestVideoPlayer->Prepare()"));
  1456 				StateChange(EStatePrepareVideoPlayer, EMvpuoPrepareComplete);
  1457 				break;
  1458 				}
  1459 			case EStatePrepareVideoPlayer:
  1460 				{
  1461 				// Play iTestVideoPlayer
  1462 				iTestVideoPlayer->Play();
  1463 				INFO_PRINTF1(_L("iTestVideoPlayer->Play()"));
  1464 				// Open iTestAudioPlayer1
  1465 				TRAP(iError, iTestAudioPlayer1->OpenFileL(iFilename2));
  1466 				INFO_PRINTF2(_L("iTestAudioPlayer1->OpenFileL(), returned %d"), iError);
  1467 				if( iError != KErrNone )
  1468 					{
  1469 					iTestStepResult = EFail;
  1470 					CActiveScheduler::Stop();
  1471 					break;
  1472 					}				
  1473 				// Set ExpectedEvent and change the State
  1474 				StateChange(EStateOpenAudioPlayer1, EMapcInitComplete1);
  1475 				break;
  1476 				}
  1477 			case EStateOpenAudioPlayer1:
  1478 				{
  1479 				// Play iTestAudioPlayer#1
  1480 				iTestAudioPlayer1->Play();
  1481 				INFO_PRINTF1(_L("iTestAudioPlayer1->Play()"));
  1482 				// Set ExpectedEvent and change the State
  1483 				StateChange(EStateErrInUseVideoPlayer, EMvpuoPlayComplete, KErrInUse);
  1484 				break;
  1485 				}
  1486 			case EStateErrInUseVideoPlayer:
  1487 				{
  1488 				// Register iTestVideoPlayer for Notification
  1489 				retErr = iTestVideoPlayer->RegisterAudioResourceNotification(*iVideoPlayerCallbackSupport1, KMMFEventCategoryAudioResourceAvailable);
  1490 				INFO_PRINTF1(_L("iTestVideoPlayer->RegisterAudioResourceNotification()"));
  1491 				if( retErr != KErrNone )
  1492 					{
  1493 					ERR_PRINTF2(_L("iTestVideoPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), retErr);
  1494 					iTestStepResult = EFail;
  1495 					CActiveScheduler::Stop();
  1496 					break;
  1497 					}
  1498 				retErr1 = iTestVideoPlayer->CancelRegisterAudioResourceNotification(KMMFEventCategoryAudioResourceAvailable);
  1499 				INFO_PRINTF1(_L("iTestVideoPlayer->CancelRegisterAudioResourceNotification()"));
  1500 				if (retErr1 == KErrNone)
  1501 					{
  1502 					INFO_PRINTF1(_L("iTestVideoPlayer should not receive Notification as registration is cancelled."));
  1503 					}
  1504 				else
  1505 					{
  1506 					ERR_PRINTF2(_L("iTestVideoPlayer->CancelRegisterAudioResourceNotification - Failed with Error : %d"), retErr);
  1507 					iTestStepResult = EFail;
  1508 					CActiveScheduler::Stop();
  1509 					break;
  1510 					}
  1511 				// Set ExpectedEvent and change the State
  1512 				StateChange(EStateEndAudioPlay1, EMapcPlayComplete1);
  1513 				break;
  1514 				}
  1515 			case EStateEndAudioPlay1:
  1516 				{
  1517 				// Timer to check if Notification Event Occurs.
  1518 				iCallBackTimer->After(2000000);
  1519 				iTestStepResult = EPass;
  1520 				// Set ExpectedEvent and change the State
  1521 				StateChange(EStateNotifiedVideoPlayer, EMarncResourceAvailable1);
  1522 				break;
  1523 				}
  1524 			case EStateNotifiedVideoPlayer:
  1525 				{
  1526 				iCallBackTimer->Cancel(); // in case something else stopped the AS
  1527 				// we have received the notification event (unexpected), so fail the test
  1528 				INFO_PRINTF1(_L("iTestVideoPlayer->NotificationReceived"));
  1529 				iTestStepResult = EFail;
  1530 				CActiveScheduler::Stop();
  1531 				break;
  1532 				}
  1533 			}
  1534 		}
  1535 	}
  1536 		
  1537 	
  1538 /**
  1539  * PerformTestL
  1540  */
  1541 TVerdict RTestVclntAprRegAtPlayAndCancelNfn::PerformTestL()
  1542 	{
  1543 	INFO_PRINTF1(_L("Cancellation of the notification request"));
  1544 	iTestStepResult = EFail;
  1545 	
  1546 	// Initialise the state variables
  1547 	StateInit();
  1548 	
  1549 	// Begin the process
  1550 	Fsm(EIdlePlayer, KErrNone);
  1551 	
  1552 	// Start the scheduler - Done only once !
  1553 	CActiveScheduler::Start();
  1554 	
  1555 	User::LeaveIfError(iError);
  1556 	
  1557 	return iTestStepResult;
  1558 	}
  1559 
  1560 //
  1561 //RTestVclntAprTestWillResumePlay (MM-MMF-VCLNTAVIAPR-I-0007-HP)
  1562 //
  1563 
  1564 /**
  1565  * Constructor
  1566  */
  1567 RTestVclntAprTestWillResumePlay::RTestVclntAprTestWillResumePlay(const TDesC& aTestName, const TDesC& aSectName)
  1568 	: RTestMmfVclntVideoPlayerAPR(aTestName, aSectName)
  1569 	{}
  1570 
  1571 /**
  1572  * NewL
  1573  */
  1574 RTestVclntAprTestWillResumePlay* RTestVclntAprTestWillResumePlay::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1575 	{
  1576 	RTestVclntAprTestWillResumePlay* self = new (ELeave) RTestVclntAprTestWillResumePlay(aTestName, aSectName);
  1577 	return self;
  1578 	}
  1579 
  1580 /**
  1581  * DoTestL
  1582  */
  1583 TVerdict RTestVclntAprTestWillResumePlay::DoTestL()
  1584 	{
  1585 	TVerdict testResult = EFail;
  1586 	TRAPD(err, testResult = PerformTestL());
  1587 	User::LeaveIfError(err);
  1588 	return testResult;
  1589 	}
  1590 
  1591 /**
  1592  * FsmL
  1593  */
  1594 void RTestVclntAprTestWillResumePlay::Fsm(TAVPlayerAPREvents aEventCode, TInt aError)
  1595 	{
  1596 	if ((FsmCheck(aEventCode, aError)) && iCanStateChange)
  1597 		{
  1598 		TInt retErr = KErrNone;
  1599 		TInt retErr1 = KErrNone;
  1600 		switch (iState)
  1601 			{
  1602 			case EStateBegin:
  1603 				{
  1604 				// Open iTestAudioPlayer2 - Low priority
  1605 				TRAP(iError, iTestAudioPlayer2->OpenFileL(iFilename3));
  1606 				if( iError != KErrNone )
  1607 					{
  1608 					ERR_PRINTF2(_L("iTestAudioPlayer2->OpenFileL - Failed with Error : %d"), iError);
  1609 					iTestStepResult = EFail;
  1610 					CActiveScheduler::Stop();
  1611 					break;
  1612 					}
  1613 				// Set ExpectedEvent and change the State
  1614 				StateChange(EStateOpenAudioPlayer2, EMapcInitComplete2);
  1615 				break;
  1616 				}
  1617 			case EStateOpenAudioPlayer2:
  1618 				{
  1619 			 	// Play iTestAudioPlayer#2
  1620 				iTestAudioPlayer2->Play();
  1621 				INFO_PRINTF1(_L("iTestAudioPlayer2->Play()"));
  1622 				// Open iTestVideoPlayer
  1623 				if (iBinaryCompatibility)
  1624 					{
  1625 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1, ControllerUid()));
  1626 					}
  1627 				else
  1628 					{
  1629 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1));
  1630 					}
  1631 				
  1632 				INFO_PRINTF2(_L("iTestVideoPlayer->OpenFileL(), returned %d"), iError);
  1633 				if( iError != KErrNone )
  1634 					{
  1635 					iTestStepResult = EFail;
  1636 					CActiveScheduler::Stop();
  1637 					break;
  1638 					}	
  1639 				StateChange(EStateOpenVideoPlayer, EMvpuoOpenComplete);
  1640 				break;
  1641 				}
  1642 			case EStateOpenVideoPlayer:
  1643 				{
  1644 				// Prepare iTestVideoPlayer
  1645 				iTestVideoPlayer->Prepare();
  1646 				INFO_PRINTF1(_L("iTestVideoPlayer->Prepare()"));
  1647 				StateChange(EStatePrepareVideoPlayer, EMvpuoPrepareComplete);
  1648 				break;
  1649 				}
  1650 			case EStatePrepareVideoPlayer:
  1651 				{
  1652 				// Play iTestVideoPlayer
  1653 				iTestVideoPlayer->Play();
  1654 				INFO_PRINTF1(_L("iTestVideoPlayer->Play()"));
  1655 				// Set ExpectedEvent and change the State
  1656 				StateChange(EStateErrInUseAudioPlayer2, EMapcPlayComplete2, KErrInUse);
  1657 				break;
  1658 				}
  1659 			case EStateErrInUseAudioPlayer2:
  1660 				{
  1661 				// Register iTestAudioPlayer2 for Notification
  1662 				retErr = iTestAudioPlayer2->RegisterAudioResourceNotification(*iAudioPlayerCallbackSupport2, KMMFEventCategoryAudioResourceAvailable);
  1663 				INFO_PRINTF1(_L("iTestAudioPlayer2->RegisterAudioResourceNotification()"));
  1664 				if( retErr != KErrNone )
  1665 					{
  1666 					ERR_PRINTF2(_L("iTestAudioPlayer2->RegisterAudioResourceNotification - Failed with Error : %d"), retErr);
  1667 					iTestStepResult = EFail;
  1668 					CActiveScheduler::Stop();
  1669 					break;
  1670 					}
  1671 				// Open iTestAudioPlayer1
  1672 				TRAP(iError, iTestAudioPlayer1->OpenFileL(iFilename2));
  1673 				INFO_PRINTF2(_L("iTestAudioPlayer1->OpenFileL(), returned %d"), iError);
  1674 				if( iError != KErrNone )
  1675 					{
  1676 					iTestStepResult = EFail;
  1677 					CActiveScheduler::Stop();
  1678 					break;
  1679 					}				
  1680 				// Set ExpectedEvent and change the State
  1681 				StateChange(EStateOpenAudioPlayer1, EMapcInitComplete1);
  1682 				break;
  1683 				}
  1684 			case EStateOpenAudioPlayer1:
  1685 				{
  1686 				// Play iTestAudioPlayer#1
  1687 				iTestAudioPlayer1->Play();
  1688 				INFO_PRINTF1(_L("iTestAudioPlayer1->Play()"));
  1689 				// Set ExpectedEvent and change the State
  1690 				StateChange(EStateErrInUseVideoPlayer, EMvpuoPlayComplete, KErrInUse);
  1691 				break;
  1692 				}
  1693 			case EStateErrInUseVideoPlayer:
  1694 				{
  1695 				// Register iTestVideoPlayer for Notification
  1696 				retErr1 = iTestVideoPlayer->RegisterAudioResourceNotification(*iVideoPlayerCallbackSupport1, KMMFEventCategoryAudioResourceAvailable);
  1697 				INFO_PRINTF1(_L("iTestVideoPlayer->RegisterAudioResourceNotification()"));
  1698 				if( retErr1 != KErrNone )
  1699 					{
  1700 					ERR_PRINTF2(_L("iTestVideoPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), retErr1);
  1701 					iTestStepResult = EFail;
  1702 					CActiveScheduler::Stop();
  1703 					break;
  1704 					}
  1705 				// Set ExpectedEvent and change the State
  1706 				iExpEventCount = 2;
  1707 				StateChange(EStateNotifiedVideoPlayer, EMarncResourceAvailable1, KErrNone, 1);
  1708 				StateChange(EStateEndAudioPlay1, EMapcPlayComplete1, KErrNone, 2);
  1709 				break;
  1710 				}
  1711 			case EStateEndAudioPlay1:
  1712 				{
  1713 				iCallBackTimer->Cancel(); // in case something else stopped the AS
  1714 				INFO_PRINTF1(_L("iTestVideoPlayer->NotificationReceived"));
  1715 				retErr = iTestVideoPlayer->WillResumePlay();
  1716 				INFO_PRINTF1(_L("iTestVideoPlayer->WillResumePlay()"));
  1717 				if( retErr != KErrNone )
  1718 					{
  1719 					ERR_PRINTF2(_L("iTestVideoPlayer->WillResumePlay() - Failed with Error : %d"), retErr);
  1720 					iTestStepResult = EFail;
  1721 					CActiveScheduler::Stop();
  1722 					break;
  1723 					}
  1724 				// initialise and start the timer (5 Sec), just to check if no other event occurs.
  1725                 TRAPD(err, iWillResumePlayTimer = CVclntAviAprWillResumeTimer::NewL(this, 5000000));
  1726                 if (err != KErrNone)
  1727                     {
  1728                     ERR_PRINTF2(_L("CVclntAviAprWillResumeTimer::NewL left with error = %d"), err);
  1729                     iTestStepResult = EFail;
  1730 					CActiveScheduler::Stop();
  1731                     break;
  1732                     }
  1733                 iWillResumePlayTimer->Start();
  1734 				// Check if No other client is notified in 5 seconds.
  1735 				StateChange(EStateNoOtherPlayerNotified, EIdlePlayer);
  1736 				break;
  1737 				}
  1738 			case EStateNoOtherPlayerNotified:
  1739 				{
  1740 				INFO_PRINTF1(_L("No other client has been notified in 5 seconds after calling WillResumePlay()"));
  1741 				iTestVideoPlayer->Play(); // directly calling play, without setting position.
  1742 				iExpEventCount = 2;
  1743 				StateChange(EStateNotifiedAudioPlayer2, EMarncResourceAvailable3, KErrNone, 1);
  1744 				StateChange(EStateEndVideoPlay, EMvpuoPlayComplete, KErrNone, 2);
  1745 				break;
  1746 				}
  1747 			case EStateEndVideoPlay:
  1748 				{
  1749 				INFO_PRINTF1(_L("iTestAudioPlayer2->NotificationReceived"));
  1750 				iTestStepResult = EPass;
  1751 				CActiveScheduler::Stop();
  1752 				break;
  1753 				}
  1754 			}
  1755 		}
  1756 	}
  1757 		
  1758 	
  1759 /**
  1760  * PerformTestL
  1761  */
  1762 TVerdict RTestVclntAprTestWillResumePlay::PerformTestL()
  1763 	{
  1764 	INFO_PRINTF1(_L("WillResumePlay Implementation with three clients"));
  1765 	iTestStepResult = EFail;
  1766 	
  1767 	// Initialise the state variables
  1768 	StateInit();
  1769 	
  1770 	// Begin the process
  1771 	Fsm(EIdlePlayer, KErrNone);
  1772 	
  1773 	// Start the scheduler - Done only once !
  1774 	CActiveScheduler::Start();
  1775 	
  1776 	User::LeaveIfError(iError);
  1777 	
  1778 	return iTestStepResult;
  1779 	}
  1780 
  1781 /**
  1782  * set finished on callback from a timer
  1783  */
  1784 void RTestVclntAprTestWillResumePlay::FinishedL()
  1785     {
  1786     // say that no events have occured after calling WillResumePlay()
  1787     // and can proceed to the next step
  1788     Fsm(EIdlePlayer, KErrNone);
  1789     }
  1790 
  1791 //
  1792 // CVclntAviAprWillResumeTimer
  1793 //
  1794 
  1795 /**
  1796  * NewL
  1797  */
  1798 CVclntAviAprWillResumeTimer* CVclntAviAprWillResumeTimer::NewL(RTestVclntAprTestWillResumePlay* aParent, TTimeIntervalMicroSeconds32 aWaitTime)
  1799     {
  1800     CVclntAviAprWillResumeTimer* self = new (ELeave) CVclntAviAprWillResumeTimer(aParent, aWaitTime);
  1801     CleanupStack::PushL(self);
  1802     self->ConstructL();
  1803     CleanupStack::Pop(self);
  1804     return self;    
  1805     }
  1806     
  1807 /**
  1808  * Constructor
  1809  */
  1810 CVclntAviAprWillResumeTimer::CVclntAviAprWillResumeTimer(RTestVclntAprTestWillResumePlay* aParent, TTimeIntervalMicroSeconds32 aWaitTime)
  1811     : CTimer(EPriorityNormal), iParent(aParent), iWaitTime(aWaitTime)
  1812     {    
  1813     CActiveScheduler::Add(this);
  1814     }    
  1815     
  1816 /**
  1817  * Start() - Start the timer
  1818  */
  1819 void CVclntAviAprWillResumeTimer::Start()
  1820     {
  1821     After(iWaitTime);
  1822     }
  1823 
  1824 /**
  1825  * RunL() - see CActive class for more info
  1826  */
  1827 void CVclntAviAprWillResumeTimer::RunL()
  1828     {        
  1829     // (iParent->Finished() should call Stop() or not, as we decide)    
  1830     iParent->FinishedL();
  1831     }
  1832 
  1833 /**
  1834  * RunError() - see CActive class for more info
  1835  */
  1836 TInt CVclntAviAprWillResumeTimer::RunError(TInt aError)
  1837     {
  1838     CActiveScheduler::Stop();
  1839     return aError;
  1840     }
  1841 
  1842 //
  1843 //RTestVclntAprAllocUsingSharedHeap (MM-MMF-VCLNTAVIAPR-I-0008-HP)
  1844 //
  1845 
  1846 /**
  1847  * Constructor
  1848  */
  1849 RTestVclntAprAllocUsingSharedHeap::RTestVclntAprAllocUsingSharedHeap(const TDesC& aTestName, const TDesC& aSectName)
  1850 	: RTestMmfVclntVideoPlayerAPR(aTestName, aSectName)
  1851 	{
  1852 	}
  1853 
  1854 /**
  1855  * NewL
  1856  */
  1857 RTestVclntAprAllocUsingSharedHeap* RTestVclntAprAllocUsingSharedHeap::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1858 	{
  1859 	RTestVclntAprAllocUsingSharedHeap* self = new (ELeave) RTestVclntAprAllocUsingSharedHeap(aTestName, aSectName);
  1860 	return self;
  1861 	}
  1862 
  1863 /**
  1864  * DoTestStepL
  1865  */
  1866 TVerdict RTestVclntAprAllocUsingSharedHeap::DoTestStepL()
  1867 	{
  1868 	TVerdict ret = EPass;
  1869 	ret = DoTestL();
  1870 	return ret;
  1871 	}
  1872 
  1873 /**
  1874  * DoTestL
  1875  */
  1876 TVerdict RTestVclntAprAllocUsingSharedHeap::DoTestL()
  1877 	{
  1878 	TVerdict testResult = EFail;
  1879 	TRAPD(err, testResult = PerformTestL());
  1880 	User::LeaveIfError(err);
  1881 	return testResult;
  1882 	}
  1883 
  1884 /**
  1885  * FsmL
  1886  */
  1887 
  1888 void RTestVclntAprAllocUsingSharedHeap::Fsm(TAVPlayerAPREvents aEventCode, TInt aError)
  1889 	{
  1890 	if ((FsmCheck(aEventCode, aError)) && iCanStateChange)
  1891 		{
  1892 		TInt retErr = KErrNone;
  1893 		switch (iState)
  1894 			{
  1895 			case EStateBegin:
  1896 				{
  1897 				// Open iTestVideoPlayer
  1898 				if (iBinaryCompatibility)
  1899 					{
  1900 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1, ControllerUid()));
  1901 					}
  1902 				else
  1903 					{
  1904 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1));
  1905 					}
  1906 				
  1907 				if( iError != KErrNone )
  1908 					{
  1909 					ERR_PRINTF2(_L("iTestVideoPlayer->OpenFileL - Failed with Error : %d"), iError);
  1910 					iTestStepResult = EFail;
  1911 					CActiveScheduler::Stop();
  1912 					break;
  1913 					}
  1914 				StateChange(EStateOpenVideoPlayer, EMvpuoOpenComplete);
  1915 				break;
  1916 				}
  1917 			case EStateOpenVideoPlayer:
  1918 				{
  1919 				// Prepare iTestVideoPlayer
  1920 				iTestVideoPlayer->Prepare();
  1921 				StateChange(EStatePrepareVideoPlayer, EMvpuoPrepareComplete);
  1922 				break;
  1923 				}
  1924 			case EStatePrepareVideoPlayer:
  1925 				{
  1926 				// Play iTestVideoPlayer
  1927 				iTestVideoPlayer->Play();
  1928 				INFO_PRINTF1(_L("iTestVideoPlayer->Play()"));		
  1929 				// Open iTestAudioPlayer1
  1930 				TRAP(iError, iTestAudioPlayer1->OpenFileL(iFilename2));
  1931 				if( iError != KErrNone )
  1932 					{
  1933 					iTestStepResult = EFail;
  1934 					CActiveScheduler::Stop();
  1935 					break;
  1936 					}
  1937 				// Set ExpectedEvent and change the State
  1938 				StateChange(EStateOpenAudioPlayer1, EMapcInitComplete1);
  1939 				break;
  1940 				}
  1941 			case EStateOpenAudioPlayer1:
  1942 				{
  1943 				// Play iTestAudioPlayer#1
  1944 				iTestAudioPlayer1->Play();
  1945 				// Set ExpectedEvent and change the State
  1946 				StateChange(EStateErrInUseVideoPlayer, EMvpuoPlayComplete, KErrInUse);
  1947 				break;
  1948 				}
  1949 			case EStateErrInUseVideoPlayer:
  1950 				{
  1951 				// Register iTestVideoPlayer for Notification
  1952 				retErr = iTestVideoPlayer->RegisterAudioResourceNotification(*iVideoPlayerCallbackSupport1, KMMFEventCategoryAudioResourceAvailable);
  1953 				if( retErr != KErrNone )
  1954 					{
  1955 					ERR_PRINTF2(_L("iTestVideoPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), retErr);
  1956 					iTestStepResult = EFail;
  1957 					CActiveScheduler::Stop();
  1958 					break;
  1959 					}
  1960 				// Set ExpectedEvent and change the State
  1961 				iExpEventCount = 2;
  1962 				StateChange(EStateNotifiedVideoPlayer, EMarncResourceAvailable1, KErrNone, 1);
  1963 				StateChange(EStateEndAudioPlay1, EMapcPlayComplete1, KErrNone, 2);
  1964 				break;
  1965 				}
  1966 			case EStateEndAudioPlay1:
  1967 				{
  1968 				iCallBackTimer->Cancel(); // in case something else stopped the AS
  1969 				iTestVideoPlayer->Play();
  1970 				INFO_PRINTF1(_L("iTestVideoPlayer->Play() - Again"));
  1971 				iTestAudioPlayer1->Play();
  1972 				StateChange(EStateErrInUseVideoPlayer1A, EMvpuoPlayComplete, KErrInUse);
  1973 				break;
  1974 				}
  1975 			case EStateErrInUseVideoPlayer1A:
  1976 				{
  1977 				// Set ExpectedEvent and change the State
  1978 				iExpEventCount = 2;
  1979 				StateChange(EStateNotifiedVideoPlayer1A, EMarncResourceAvailable1, KErrNone, 1);
  1980 				StateChange(EStateEndAudioPlay1A, EMapcPlayComplete1, KErrNone, 2);
  1981 				break;
  1982 				}
  1983 			case EStateEndAudioPlay1A:
  1984 				{
  1985 				iCallBackTimer->Cancel(); // in case something else stopped the AS
  1986 				iTestStepResult = EPass;
  1987 				CActiveScheduler::Stop();
  1988 				break;
  1989 				}
  1990 			}
  1991 		}
  1992 	}
  1993 		
  1994 /**
  1995  *
  1996  * Play video by marking heap.
  1997  *
  1998  */ 
  1999 void RTestVclntAprAllocUsingSharedHeap::VideoPlayAllocL()
  2000     {
  2001     __MM_HEAP_MARK;
  2002     // create new instance of video player
  2003     TInt startAllocCount = User::CountAllocCells();
  2004     
  2005 	DoTestStepCreateL();
  2006 	
  2007 	// call the state handler and start the test
  2008     iError = KErrNone;
  2009    	// Initialise the state variables
  2010 	StateInit();
  2011 	
  2012 	// Begin the process
  2013 	Fsm(EIdlePlayer, KErrNone);
  2014 	
  2015 	// Start the scheduler - Done only once !
  2016 	CActiveScheduler::Start();
  2017 
  2018 	DoTestStepDeleteL();
  2019 	
  2020     // check for errors
  2021     if (iError != KErrNone)
  2022         {
  2023         ERR_PRINTF2(_L("Opening/playing the video file failed, unexpected error : %d."), iError);
  2024         User::Leave(iError);
  2025         }
  2026     
  2027     TInt endAllocCount = User::CountAllocCells();
  2028     __MM_HEAP_MARKEND;
  2029     }
  2030 
  2031 /**
  2032  *
  2033  * PerformTestL()
  2034  *
  2035  */
  2036 TVerdict RTestVclntAprAllocUsingSharedHeap::PerformTestL()
  2037     {
  2038     INFO_PRINTF1(_L("<<< APR alloc test using VideoPlayer utility.>>>"));
  2039     iTestStepResult = EFail;
  2040     
  2041     TRAPD(err, VideoPlayAllocL());
  2042 	if ((err != KErrNone) || (iTestStepResult != EPass))
  2043         {
  2044         return iTestStepResult;
  2045         }
  2046 	
  2047     iTestStepResult = EFail;
  2048 
  2049     TInt failCount = 1;
  2050     TBool completed = EFalse;
  2051     TBool badResult = EFalse;
  2052     TBool reachedEnd = EFalse;
  2053 
  2054     for(;;)
  2055         {
  2056         INFO_PRINTF2(_L("ALLOC Test Loop #%d."), failCount);
  2057         __UHEAP_SETFAIL(RHeap::EFailNext, failCount);
  2058         __MM_HEAP_MARK;
  2059 
  2060         TInt err = KErrNone;
  2061         TRAP(err, VideoPlayAllocL());
  2062         ERR_PRINTF2(_L("Tracing the  error = %d."), err);
  2063 
  2064         completed = EFalse;
  2065         if (err == KErrNone)
  2066             {
  2067             TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
  2068             if (!testAlloc)
  2069                 {
  2070                 reachedEnd = ETrue;
  2071                 failCount--;
  2072                 }
  2073             else
  2074                 {
  2075                 User::Free(testAlloc);
  2076                 testAlloc = NULL;
  2077                 }
  2078 
  2079             if (iTestStepResult != EPass)
  2080                 {
  2081                 badResult = ETrue;
  2082                 }
  2083 
  2084             completed = reachedEnd || badResult;
  2085             }
  2086         else if (err != KErrNoMemory)
  2087             {
  2088             __UHEAP_SETFAIL(RHeap::ENone, 0);
  2089             ERR_PRINTF2(_L("Bad error code %d"), err);
  2090             completed = ETrue;
  2091             badResult = EFail;
  2092             }
  2093 
  2094         __MM_HEAP_MARKEND;
  2095         __UHEAP_SETFAIL(RHeap::ENone, 0);
  2096 
  2097         if (completed)
  2098             {
  2099             break;
  2100             }
  2101 
  2102         failCount++;
  2103         }
  2104 
  2105     if (err != KErrNone || badResult)
  2106         {
  2107         if (badResult)
  2108             {
  2109             ERR_PRINTF3(_L("Bad result with %d memory allocations tested. The Error returned is %d."), failCount, err);
  2110             }
  2111         else
  2112             {
  2113             ERR_PRINTF3(_L("Error(%d) with %d memory allocations tested."), failCount, err);
  2114             }
  2115 
  2116         iTestStepResult = EFail;
  2117         }
  2118     else
  2119         {
  2120         INFO_PRINTF2(_L("Completed OK with %d memory allocations tested.\n"), failCount);
  2121         iTestStepResult = EPass;
  2122         }
  2123 
  2124     return iTestStepResult;
  2125     }
  2126 
  2127 //
  2128 //RTestVclntAprMultRegAtPlay (MM-MMF-VCLNTAVIAPR-I-0101-HP)
  2129 //
  2130 
  2131 /**
  2132  * Constructor
  2133  */
  2134 RTestVclntAprMultRegAtPlay::RTestVclntAprMultRegAtPlay(const TDesC& aTestName, const TDesC& aSectName)
  2135 	: RTestMmfVclntVideoPlayerAPR(aTestName, aSectName)
  2136 	{}
  2137 
  2138 /**
  2139  * NewL
  2140  */
  2141 RTestVclntAprMultRegAtPlay* RTestVclntAprMultRegAtPlay::NewL(const TDesC& aTestName, const TDesC& aSectName)
  2142 	{
  2143 	RTestVclntAprMultRegAtPlay* self = new (ELeave) RTestVclntAprMultRegAtPlay(aTestName, aSectName);
  2144 	return self;
  2145 	}
  2146 
  2147 /**
  2148  * DoTestL
  2149  */
  2150 TVerdict RTestVclntAprMultRegAtPlay::DoTestL()
  2151 	{
  2152 	TVerdict testResult = EFail;
  2153 	TRAPD(err, testResult = PerformTestL());
  2154 	User::LeaveIfError(err);
  2155 	return testResult;
  2156 	}
  2157 
  2158 /**
  2159  * FsmL
  2160  */
  2161 void RTestVclntAprMultRegAtPlay::Fsm(TAVPlayerAPREvents aEventCode, TInt aError)
  2162 	{
  2163 	if (FsmCheck(aEventCode, aError))
  2164 		{
  2165 		TInt retErr = KErrNone;
  2166 		switch (iState)
  2167 			{
  2168 			case EStateBegin:
  2169 				{
  2170 				// Open iTestVideoPlayer
  2171 				if (iBinaryCompatibility)
  2172 					{
  2173 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1, ControllerUid()));
  2174 					}
  2175 				else
  2176 					{
  2177 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1));
  2178 					}
  2179 				
  2180 				if( iError != KErrNone )
  2181 					{
  2182 					ERR_PRINTF2(_L("iTestVideoPlayer->OpenFileL - Failed with Error : %d"), iError);
  2183 					iTestStepResult = EFail;
  2184 					CActiveScheduler::Stop();
  2185 					break;
  2186 					}
  2187 				StateChange(EStateOpenVideoPlayer, EMvpuoOpenComplete);
  2188 				break;
  2189 				}
  2190 			case EStateOpenVideoPlayer:
  2191 				{
  2192 				// Prepare iTestVideoPlayer
  2193 				iTestVideoPlayer->Prepare();
  2194 				INFO_PRINTF1(_L("iTestVideoPlayer->Prepare()"));
  2195 				StateChange(EStatePrepareVideoPlayer, EMvpuoPrepareComplete);
  2196 				break;
  2197 				}
  2198 			case EStatePrepareVideoPlayer:
  2199 				{
  2200 				// Play iTestVideoPlayer
  2201 				iTestVideoPlayer->Play();
  2202 				INFO_PRINTF1(_L("iTestVideoPlayer->Play()"));
  2203 				// Register iTestVideoPlayer for Notification
  2204 				retErr = iTestVideoPlayer->RegisterAudioResourceNotification(*iVideoPlayerCallbackSupport1, KMMFEventCategoryAudioResourceAvailable);
  2205 				INFO_PRINTF1(_L("iTestVideoPlayer->RegisterAudioResourceNotification() - First Regn"));
  2206 				if( retErr != KErrNone )
  2207 					{
  2208 					ERR_PRINTF2(_L("iTestVideoPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), retErr);
  2209 					iTestStepResult = EFail;
  2210 					CActiveScheduler::Stop();
  2211 					break;
  2212 					}		
  2213 				// Open iTestAudioPlayer1
  2214 				TRAP(iError, iTestAudioPlayer1->OpenFileL(iFilename2));
  2215 				INFO_PRINTF2(_L("iTestAudioPlayer1->OpenFileL(), returned %d"), iError);
  2216 				if( iError != KErrNone )
  2217 					{
  2218 					iTestStepResult = EFail;
  2219 					CActiveScheduler::Stop();
  2220 					break;
  2221 					}				
  2222 				// Set ExpectedEvent and change the State
  2223 				StateChange(EStateOpenAudioPlayer1, EMapcInitComplete1);
  2224 				break;
  2225 				}
  2226 			case EStateOpenAudioPlayer1:
  2227 				{
  2228 				// Play iTestAudioPlayer#1
  2229 				iTestAudioPlayer1->Play();
  2230 				INFO_PRINTF1(_L("iTestAudioPlayer1->Play()"));
  2231 				// Set ExpectedEvent and change the State
  2232 				StateChange(EStateErrInUseVideoPlayer, EMvpuoPlayComplete, KErrInUse);
  2233 				break; 
  2234 				}
  2235 			case EStateErrInUseVideoPlayer:
  2236 				{
  2237 				// Register iTestVideoPlayer for Notification
  2238 				retErr = iTestVideoPlayer->RegisterAudioResourceNotification(*iVideoPlayerCallbackSupport1, KMMFEventCategoryAudioResourceAvailable);
  2239 				INFO_PRINTF1(_L("iTestVideoPlayer->RegisterAudioResourceNotification() - Second Regn"));
  2240 				if( retErr == KErrAlreadyExists )
  2241 					{
  2242 					ERR_PRINTF2(_L("iTestVideoPlayer->RegisterAudioResourceNotification (2nd Time) - Failed with Error : %d"), retErr);
  2243 					iTestStepResult = EPass;
  2244 					}
  2245 				else if( retErr != KErrNone )
  2246 					{
  2247 					ERR_PRINTF2(_L("iTestVideoPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), retErr);
  2248 					iTestStepResult = EFail;
  2249 					}
  2250 				CActiveScheduler::Stop();
  2251 				break;
  2252 				}
  2253 			}
  2254 		}
  2255 	}
  2256 		
  2257 	
  2258 /**
  2259  * PerformTestL
  2260  */
  2261 TVerdict RTestVclntAprMultRegAtPlay::PerformTestL()
  2262 	{
  2263 	INFO_PRINTF1(_L("Multiple registration at the time of play"));
  2264 	iTestStepResult = EFail;
  2265 	
  2266 	// Initialise the state variables
  2267 	StateInit();
  2268 	
  2269 	// Begin the process
  2270 	Fsm(EIdlePlayer, KErrNone);
  2271 	
  2272 	// Start the scheduler - Done only once !
  2273 	CActiveScheduler::Start();
  2274 	
  2275 	User::LeaveIfError(iError);
  2276 	
  2277 	return iTestStepResult;
  2278 	}
  2279 
  2280 
  2281 //
  2282 //RTestVclntAprCancelNoResourceNfn (MM-MMF-VCLNTAVIAPR-I-0102-HP)
  2283 //
  2284 
  2285 /**
  2286  * Constructor
  2287  */
  2288 RTestVclntAprCancelNoResourceNfn::RTestVclntAprCancelNoResourceNfn(const TDesC& aTestName, const TDesC& aSectName)
  2289 	: RTestMmfVclntVideoPlayerAPR(aTestName, aSectName)
  2290 	{}
  2291 
  2292 /**
  2293  * NewL
  2294  */
  2295 RTestVclntAprCancelNoResourceNfn* RTestVclntAprCancelNoResourceNfn::NewL(const TDesC& aTestName, const TDesC& aSectName)
  2296 	{
  2297 	RTestVclntAprCancelNoResourceNfn* self = new (ELeave) RTestVclntAprCancelNoResourceNfn(aTestName, aSectName);
  2298 	return self;
  2299 	}
  2300 
  2301 /**
  2302  * DoTestL
  2303  */
  2304 TVerdict RTestVclntAprCancelNoResourceNfn::DoTestL()
  2305 	{
  2306 	TVerdict testResult = EFail;
  2307 	TRAPD(err, testResult = PerformTestL());
  2308 	User::LeaveIfError(err);
  2309 	return testResult;
  2310 	}
  2311 
  2312 /**
  2313  * FsmL
  2314  */
  2315 void RTestVclntAprCancelNoResourceNfn::Fsm(TAVPlayerAPREvents aEventCode, TInt aError)
  2316 	{
  2317 	if (FsmCheck(aEventCode, aError))
  2318 		{
  2319 		TInt retErr = KErrNone;
  2320 		switch (iState)
  2321 			{
  2322 			case EStateBegin:
  2323 				{
  2324 				// Open iTestVideoPlayer
  2325 				if (iBinaryCompatibility)
  2326 					{
  2327 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1, ControllerUid()));
  2328 					}
  2329 				else
  2330 					{
  2331 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1));
  2332 					}
  2333 				
  2334 				INFO_PRINTF2(_L("iTestVideoPlayer->OpenFileL(), returned %d"), iError);
  2335 				if( iError != KErrNone )
  2336 					{
  2337 					iTestStepResult = EFail;
  2338 					CActiveScheduler::Stop();
  2339 					break;
  2340 					}	
  2341 				StateChange(EStateOpenVideoPlayer, EMvpuoOpenComplete);
  2342 				break;
  2343 				}
  2344 			case EStateOpenVideoPlayer:
  2345 				{
  2346 				// Prepare iTestVideoPlayer
  2347 				iTestVideoPlayer->Prepare();
  2348 				INFO_PRINTF1(_L("iTestVideoPlayer->Prepare()"));
  2349 				StateChange(EStatePrepareVideoPlayer, EMvpuoPrepareComplete);
  2350 				break;
  2351 				}
  2352 			case EStatePrepareVideoPlayer:
  2353 				{
  2354 				// Play iTestVideoPlayer
  2355 				iTestVideoPlayer->Play();
  2356 				INFO_PRINTF1(_L("iTestVideoPlayer->Play()"));
  2357 				retErr = iTestVideoPlayer->CancelRegisterAudioResourceNotification(KMMFEventCategoryAudioResourceAvailable);
  2358 				if (retErr == KErrCancel)
  2359 					{
  2360 					INFO_PRINTF1(_L("iTestVideoPlayer->CancelRegisterAudioResourceNotification() returned KErrCancel - Successful"));
  2361 					iTestStepResult = EPass;
  2362 					}
  2363 				else
  2364 					{
  2365 					ERR_PRINTF2(_L("iTestVideoPlayer->CancelRegisterAudioResourceNotification - Failed with Error : %d"), retErr);
  2366 					iTestStepResult = EFail;
  2367 					}
  2368 				CActiveScheduler::Stop();
  2369 				break;
  2370 				}
  2371 			}
  2372 		}
  2373 	}
  2374 		
  2375 	
  2376 /**
  2377  * PerformTestL
  2378  */
  2379 TVerdict RTestVclntAprCancelNoResourceNfn::PerformTestL()
  2380 	{
  2381 	INFO_PRINTF1(_L("Cancel when no resource Notification is requested"));
  2382 	iTestStepResult = EFail;
  2383 	
  2384 	// Initialise the state variables
  2385 	StateInit();
  2386 	
  2387 	// Begin the process
  2388 	Fsm(EIdlePlayer, KErrNone);
  2389 	
  2390 	// Start the scheduler - Done only once !
  2391 	CActiveScheduler::Start();
  2392 	
  2393 	User::LeaveIfError(iError);
  2394 	
  2395 	return iTestStepResult;
  2396 	}
  2397 
  2398 //
  2399 //RTestVclntAprRegUnsupportedEvent (MM-MMF-VCLNTAVIAPR-I-0103-HP)
  2400 //
  2401 
  2402 /**
  2403  * Constructor
  2404  */
  2405 RTestVclntAprRegUnsupportedEvent::RTestVclntAprRegUnsupportedEvent(const TDesC& aTestName, const TDesC& aSectName)
  2406 	: RTestMmfVclntVideoPlayerAPR(aTestName, aSectName)
  2407 	{}
  2408 
  2409 /**
  2410  * NewL
  2411  */
  2412 RTestVclntAprRegUnsupportedEvent* RTestVclntAprRegUnsupportedEvent::NewL(const TDesC& aTestName, const TDesC& aSectName)
  2413 	{
  2414 	RTestVclntAprRegUnsupportedEvent* self = new (ELeave) RTestVclntAprRegUnsupportedEvent(aTestName, aSectName);
  2415 	return self;
  2416 	}
  2417 
  2418 /**
  2419  * DoTestL
  2420  */
  2421 TVerdict RTestVclntAprRegUnsupportedEvent::DoTestL()
  2422 	{
  2423 	TVerdict testResult = EFail;
  2424 	TRAPD(err, testResult = PerformTestL());
  2425 	User::LeaveIfError(err);
  2426 	return testResult;
  2427 	}
  2428 
  2429 /**
  2430  * FsmL
  2431  */
  2432 void RTestVclntAprRegUnsupportedEvent::Fsm(TAVPlayerAPREvents aEventCode, TInt aError)
  2433 	{
  2434 	if (FsmCheck(aEventCode, aError))
  2435 		{
  2436 		TInt retErr = KErrNone;
  2437 		switch (iState)
  2438 			{
  2439 			case EStateBegin:
  2440 				{
  2441 				// Open iTestVideoPlayer
  2442 				if (iBinaryCompatibility)
  2443 					{
  2444 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1, ControllerUid()));
  2445 					}
  2446 				else
  2447 					{
  2448 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1));
  2449 					}
  2450 				
  2451 				INFO_PRINTF2(_L("iTestVideoPlayer->OpenFileL(), returned %d"), iError);
  2452 				if( iError != KErrNone )
  2453 					{
  2454 					iTestStepResult = EFail;
  2455 					CActiveScheduler::Stop();
  2456 					break;
  2457 					}	
  2458 				StateChange(EStateOpenVideoPlayer, EMvpuoOpenComplete);
  2459 				break;
  2460 				}
  2461 			case EStateOpenVideoPlayer:
  2462 				{
  2463 				// Prepare iTestVideoPlayer
  2464 				iTestVideoPlayer->Prepare();
  2465 				INFO_PRINTF1(_L("iTestVideoPlayer->Prepare()"));
  2466 				StateChange(EStatePrepareVideoPlayer, EMvpuoPrepareComplete);
  2467 				break;
  2468 				}
  2469 			case EStatePrepareVideoPlayer:
  2470 				{
  2471 				// Play iTestVideoPlayer
  2472 				iTestVideoPlayer->Play();
  2473 				INFO_PRINTF1(_L("iTestVideoPlayer->Play()"));
  2474 				// Register iTestVideoPlayer for Notification
  2475 				retErr = iTestVideoPlayer->RegisterAudioResourceNotification(*iVideoPlayerCallbackSupport1, KMMFEventCategoryVideoPrepareComplete);
  2476 				INFO_PRINTF1(_L("iTestVideoPlayer->RegisterAudioResourceNotification()"));
  2477 				if( retErr == KErrNotSupported )
  2478 					{
  2479 					INFO_PRINTF1(_L("iTestVideoPlayer->RegisterAudioResourceNotification() with an Unsupported Event"));
  2480 					iTestStepResult = EPass;
  2481 					}
  2482 					else
  2483 					{
  2484 					ERR_PRINTF2(_L("iTestVideoPlayer->RegisterAudioResourceNotification with Error : %d"), retErr);
  2485 					iTestStepResult = EFail;
  2486 					}
  2487 				CActiveScheduler::Stop();
  2488 				break;
  2489 				}
  2490 			}
  2491 		}
  2492 	}
  2493 		
  2494 	
  2495 /**
  2496  * PerformTestL
  2497  */
  2498 TVerdict RTestVclntAprRegUnsupportedEvent::PerformTestL()
  2499 	{
  2500 	INFO_PRINTF1(_L("Register with Unsupported event"));
  2501 	iTestStepResult = EFail;
  2502 	
  2503 	// Initialise the state variables
  2504 	StateInit();
  2505 	
  2506 	// Begin the process
  2507 	Fsm(EIdlePlayer, KErrNone);
  2508 	
  2509 	// Start the scheduler - Done only once !
  2510 	CActiveScheduler::Start();
  2511 	
  2512 	User::LeaveIfError(iError);
  2513 	
  2514 	return iTestStepResult;
  2515 	}
  2516 	
  2517 //
  2518 //RTestVclntAprCancelUnsupportedEvent (MM-MMF-VCLNTAVIAPR-I-0104-HP)
  2519 //
  2520 
  2521 /**
  2522  * Constructor
  2523  */
  2524 RTestVclntAprCancelUnsupportedEvent::RTestVclntAprCancelUnsupportedEvent(const TDesC& aTestName, const TDesC& aSectName)
  2525 	: RTestMmfVclntVideoPlayerAPR(aTestName, aSectName)
  2526 	{}
  2527 
  2528 /**
  2529  * NewL
  2530  */
  2531 RTestVclntAprCancelUnsupportedEvent* RTestVclntAprCancelUnsupportedEvent::NewL(const TDesC& aTestName, const TDesC& aSectName)
  2532 	{
  2533 	RTestVclntAprCancelUnsupportedEvent* self = new (ELeave) RTestVclntAprCancelUnsupportedEvent(aTestName, aSectName);
  2534 	return self;
  2535 	}
  2536 
  2537 /**
  2538  * DoTestL
  2539  */
  2540 TVerdict RTestVclntAprCancelUnsupportedEvent::DoTestL()
  2541 	{
  2542 	TVerdict testResult = EFail;
  2543 	TRAPD(err, testResult = PerformTestL());
  2544 	User::LeaveIfError(err);
  2545 	return testResult;
  2546 	}
  2547 
  2548 /**
  2549  * FsmL
  2550  */
  2551 void RTestVclntAprCancelUnsupportedEvent::Fsm(TAVPlayerAPREvents aEventCode, TInt aError)
  2552 	{
  2553 	if (FsmCheck(aEventCode, aError))
  2554 		{
  2555 		TInt retErr = KErrNone;
  2556 		TInt retErr1 = KErrNone;
  2557 		switch (iState)
  2558 			{
  2559 			case EStateBegin:
  2560 				{
  2561 				// Open iTestVideoPlayer
  2562 				if (iBinaryCompatibility)
  2563 					{
  2564 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1, ControllerUid()));
  2565 					}
  2566 				else
  2567 					{
  2568 					TRAP(iError, iTestVideoPlayer->OpenFileL(iFilename1));
  2569 					}
  2570 				
  2571 				INFO_PRINTF2(_L("iTestVideoPlayer->OpenFileL(), returned %d"), iError);
  2572 				if( iError != KErrNone )
  2573 					{
  2574 					iTestStepResult = EFail;
  2575 					CActiveScheduler::Stop();
  2576 					break;
  2577 					}	
  2578 				StateChange(EStateOpenVideoPlayer, EMvpuoOpenComplete);
  2579 				break;
  2580 				}
  2581 			case EStateOpenVideoPlayer:
  2582 				{
  2583 				// Prepare iTestVideoPlayer
  2584 				iTestVideoPlayer->Prepare();
  2585 				INFO_PRINTF1(_L("iTestVideoPlayer->Prepare()"));
  2586 				StateChange(EStatePrepareVideoPlayer, EMvpuoPrepareComplete);
  2587 				break;
  2588 				}
  2589 			case EStatePrepareVideoPlayer:
  2590 				{
  2591 				// Play iTestVideoPlayer
  2592 				iTestVideoPlayer->Play();
  2593 				INFO_PRINTF1(_L("iTestVideoPlayer->Play()"));
  2594 				// Register iTestVideoPlayer for Notification
  2595 				retErr = iTestVideoPlayer->RegisterAudioResourceNotification(*iVideoPlayerCallbackSupport1, KMMFEventCategoryAudioResourceAvailable);
  2596 				INFO_PRINTF1(_L("iTestVideoPlayer->RegisterAudioResourceNotification()"));
  2597 				if( retErr != KErrNone )
  2598 					{
  2599 					ERR_PRINTF2(_L("iTestVideoPlayer->RegisterAudioResourceNotification - Failed with Error : %d"), retErr1);
  2600 					iTestStepResult = EFail;
  2601 					CActiveScheduler::Stop();
  2602 					break;
  2603 					}
  2604 				retErr1 = iTestVideoPlayer->CancelRegisterAudioResourceNotification(KMMFEventCategoryVideoRecorderGeneralError);
  2605 				if (retErr1 == KErrNotSupported)
  2606 					{
  2607 					INFO_PRINTF1(_L("iTestVideoPlayer->CancelRegisterAudioResourceNotification - Unsuccessful due to Unsupported event"));
  2608 					iTestStepResult = EPass;
  2609 					}
  2610 				else
  2611 					{
  2612 					ERR_PRINTF2(_L("iTestVideoPlayer->CancelRegisterAudioResourceNotification - Failed with Error : %d"), retErr1);
  2613 					iTestStepResult = EFail;
  2614 					}
  2615 				CActiveScheduler::Stop();
  2616 				break;
  2617 				}
  2618 			}
  2619 		}
  2620 	}
  2621 		
  2622 	
  2623 /**
  2624  * PerformTestL
  2625  */
  2626 TVerdict RTestVclntAprCancelUnsupportedEvent::PerformTestL()
  2627 	{
  2628 	INFO_PRINTF1(_L("Cancel registration with unsupported event type"));
  2629 	iTestStepResult = EFail;
  2630 	
  2631 	// Initialise the state variables
  2632 	StateInit();
  2633 	
  2634 	// Begin the process
  2635 	Fsm(EIdlePlayer, KErrNone);
  2636 	
  2637 	// Start the scheduler - Done only once !
  2638 	CActiveScheduler::Start();
  2639 	
  2640 	User::LeaveIfError(iError);
  2641 		
  2642 	return iTestStepResult;
  2643 	}