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