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