os/mm/mmlibs/mmfw/tsrc/mmfunittest/Actrl/TestStepsGetSet.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) 2002-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
// TestStepsGetSet
sl@0
    15
//
sl@0
    16
sl@0
    17
#include <e32std.h>
sl@0
    18
#include <e32base.h>
sl@0
    19
#include <mmf/common/mmfcontroller.h>
sl@0
    20
#include <mmf/server/mmffile.h>
sl@0
    21
#include <mmf/server/mmfdes.h>
sl@0
    22
#include <mmf/plugin/mmfcontrollerimplementationuids.hrh>
sl@0
    23
#include <mmf/common/mmfstandardcustomcommands.h>
sl@0
    24
sl@0
    25
//const TInt KPlayDelayNewMail = 100000000;  //arbitrary delay
sl@0
    26
sl@0
    27
// Test system includes
sl@0
    28
#include <testframework.h>
sl@0
    29
sl@0
    30
#include "ActrlTestUids.h"
sl@0
    31
sl@0
    32
// Specific includes for this test suite
sl@0
    33
#include "TS_MMF_ACTRL_TestStep.h"
sl@0
    34
#include "TS_MMF_ACTRL_TestSuite.h"
sl@0
    35
sl@0
    36
// Specific includes for these test steps
sl@0
    37
#include "TestStepsGetSet.h"
sl@0
    38
sl@0
    39
/**
sl@0
    40
*
sl@0
    41
* Test step constructor.
sl@0
    42
* Each test step initialises its own name.
sl@0
    43
*
sl@0
    44
*/
sl@0
    45
CTestStepGetSetVolumeInPrimed::CTestStepGetSetVolumeInPrimed()
sl@0
    46
	{
sl@0
    47
	// store the name of this test case
sl@0
    48
	// this is the name that is used by the script file
sl@0
    49
	iTestStepName = _L("MM-MMF-ACTRL-U-0001-HP");
sl@0
    50
	}
sl@0
    51
sl@0
    52
/**
sl@0
    53
*
sl@0
    54
* Test step destructor.
sl@0
    55
* 
sl@0
    56
*/
sl@0
    57
CTestStepGetSetVolumeInPrimed::~CTestStepGetSetVolumeInPrimed()
sl@0
    58
	{
sl@0
    59
	}
sl@0
    60
sl@0
    61
/**
sl@0
    62
* 
sl@0
    63
* Do the test step.
sl@0
    64
* Each test step must supply an implementation for DoTestStepL.
sl@0
    65
* This test does nothing more than exercise the rotate & scale code
sl@0
    66
* @return	"TVerdict" the status of the test
sl@0
    67
*			The result of the test step 
sl@0
    68
*/
sl@0
    69
TVerdict CTestStepGetSetVolumeInPrimed::DoTestStepL( void )
sl@0
    70
	{
sl@0
    71
    __MM_HEAP_MARK;
sl@0
    72
	
sl@0
    73
	TVerdict result = EPass;
sl@0
    74
	
sl@0
    75
	_LIT( KTestPlay, "Play Test");
sl@0
    76
	Log( KTestPlay );
sl@0
    77
	
sl@0
    78
	_LIT( KTestStepPlay, "This test checks getting/setting volume in primed");
sl@0
    79
	Log( KTestStepPlay );
sl@0
    80
	
sl@0
    81
	// [ audio file to play ]
sl@0
    82
	_LIT(KTestWavFile, "newmail.wav");
sl@0
    83
	SetReadFileNameL( KTestWavFile );
sl@0
    84
   	
sl@0
    85
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
    86
	User::LeaveIfError( errorCode );
sl@0
    87
		
sl@0
    88
	//[ add data source and sink and prime the controller ]
sl@0
    89
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
    90
	User::LeaveIfError( errorCode );
sl@0
    91
	
sl@0
    92
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
    93
    User::LeaveIfError( errorCode );
sl@0
    94
	
sl@0
    95
	errorCode =	iController.Prime();
sl@0
    96
	User::LeaveIfError( errorCode );
sl@0
    97
	
sl@0
    98
	// [ wait for and process the return event from the audio output ]
sl@0
    99
	
sl@0
   100
	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
sl@0
   101
	result = SearchForEvent( primeEvent );
sl@0
   102
	if( result == EFail )
sl@0
   103
		{
sl@0
   104
		return result;
sl@0
   105
		}
sl@0
   106
sl@0
   107
   //[ set up audio commands utility ]	
sl@0
   108
   RMMFAudioPlayDeviceCustomCommands theCommander( iController );	
sl@0
   109
sl@0
   110
    // [ get the maximum volume ]
sl@0
   111
	TInt maxVolume = 0;
sl@0
   112
    errorCode =theCommander.GetMaxVolume( maxVolume );
sl@0
   113
	User::LeaveIfError( errorCode );
sl@0
   114
sl@0
   115
	//[ set the volume to 1/2 max volume ]
sl@0
   116
	TInt theVolume = maxVolume /2;
sl@0
   117
sl@0
   118
	//[ set the volume ]
sl@0
   119
	errorCode =theCommander.SetVolume( theVolume );
sl@0
   120
	User::LeaveIfError( errorCode );
sl@0
   121
	
sl@0
   122
	//[ get the volume ]
sl@0
   123
	TInt theNewVolume (0);
sl@0
   124
	errorCode =theCommander.GetVolume( theNewVolume );
sl@0
   125
	User::LeaveIfError( errorCode );
sl@0
   126
sl@0
   127
	// [ if set volume = got volume  and 
sl@0
   128
	//   rx'd event was ok then we are fine ]
sl@0
   129
	if( theNewVolume == theVolume )
sl@0
   130
		{
sl@0
   131
         result = EPass ;
sl@0
   132
		}
sl@0
   133
	//[ ensure the controller is unloaded so that it does 
sl@0
   134
	// not interfere with the following test ]
sl@0
   135
	// There is an error in this code and the stop followed by reset
sl@0
   136
	// ensure the controller resources are released.
sl@0
   137
	iController.Stop();
sl@0
   138
	iController.Reset();
sl@0
   139
	iController.Close();  
sl@0
   140
	
sl@0
   141
	__MM_HEAP_MARKEND;
sl@0
   142
	   
sl@0
   143
	// test steps return a result
sl@0
   144
	return result;
sl@0
   145
	}
sl@0
   146
sl@0
   147
sl@0
   148
/**
sl@0
   149
*
sl@0
   150
*
sl@0
   151
*
sl@0
   152
*/
sl@0
   153
CTestStepGetSetVolumeInPlay::CTestStepGetSetVolumeInPlay()
sl@0
   154
	{
sl@0
   155
	// store the name of this test case
sl@0
   156
	// this is the name that is used by the script file
sl@0
   157
	iTestStepName = _L("MM-MMF-ACTRL-U-0002-HP");
sl@0
   158
	}
sl@0
   159
sl@0
   160
/**
sl@0
   161
*
sl@0
   162
* ~CTestStepGetSetVolumeInPlay
sl@0
   163
*
sl@0
   164
*/
sl@0
   165
CTestStepGetSetVolumeInPlay::~CTestStepGetSetVolumeInPlay()
sl@0
   166
	{
sl@0
   167
	}
sl@0
   168
sl@0
   169
/**
sl@0
   170
*
sl@0
   171
* DoTestStepL
sl@0
   172
*
sl@0
   173
*/
sl@0
   174
TVerdict CTestStepGetSetVolumeInPlay::DoTestStepL( void )
sl@0
   175
	{
sl@0
   176
     __MM_HEAP_MARK;
sl@0
   177
	
sl@0
   178
	TVerdict result = EFail;
sl@0
   179
	
sl@0
   180
	_LIT( KTestPlay, "Play Test");
sl@0
   181
	Log( KTestPlay );
sl@0
   182
	
sl@0
   183
	_LIT( KTestStepPlay, "This test checks playing an audio clip");
sl@0
   184
	Log( KTestStepPlay );
sl@0
   185
	
sl@0
   186
	// [ audio file to play ]
sl@0
   187
	_LIT(KTestWavFile, "newmail.wav");
sl@0
   188
	SetReadFileNameL( KTestWavFile );
sl@0
   189
   	
sl@0
   190
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
   191
	User::LeaveIfError( errorCode );
sl@0
   192
sl@0
   193
	//[ add data source and sink and prime the controller ]
sl@0
   194
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
   195
	User::LeaveIfError( errorCode );
sl@0
   196
	
sl@0
   197
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
   198
    User::LeaveIfError( errorCode );
sl@0
   199
	
sl@0
   200
	errorCode =	iController.Prime();
sl@0
   201
	User::LeaveIfError( errorCode );
sl@0
   202
	
sl@0
   203
	// [ wait for and process the return event from the audio output ]
sl@0
   204
	
sl@0
   205
	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
sl@0
   206
	TVerdict searchResult = SearchForEvent( primeEvent );
sl@0
   207
	if( searchResult == EFail )
sl@0
   208
		{
sl@0
   209
		return searchResult;
sl@0
   210
		}
sl@0
   211
sl@0
   212
	 User::LeaveIfError( iController.Play() );
sl@0
   213
sl@0
   214
	// note this test does not wait around 
sl@0
   215
	// to detect that the audio has been played
sl@0
   216
	// [ now process the confirmation event that play has reached audio output
sl@0
   217
	//   this is the raison detre of the test ]
sl@0
   218
	TMMFEvent playEvent( KPlayTestId, KErrNone );
sl@0
   219
	
sl@0
   220
	searchResult = SearchForEvent( playEvent );
sl@0
   221
	if( searchResult == EFail )
sl@0
   222
		{
sl@0
   223
		return searchResult;
sl@0
   224
		}
sl@0
   225
	
sl@0
   226
	   //[ set up audio commands utility ]	
sl@0
   227
   RMMFAudioPlayDeviceCustomCommands theCommander( iController );	
sl@0
   228
sl@0
   229
    // [ get the maximum volume ]
sl@0
   230
	TInt maxVolume = 0;
sl@0
   231
    errorCode =theCommander.GetMaxVolume( maxVolume );
sl@0
   232
	User::LeaveIfError( errorCode );
sl@0
   233
sl@0
   234
	//[ set the volume to 1/2 max volume ]
sl@0
   235
	TInt theVolume = maxVolume /2;
sl@0
   236
sl@0
   237
	//[ set the volume ]
sl@0
   238
	errorCode =theCommander.SetVolume( theVolume );
sl@0
   239
	User::LeaveIfError( errorCode );
sl@0
   240
	//[ get the volume ]
sl@0
   241
	TInt theNewVolume (0);
sl@0
   242
	errorCode =theCommander.GetVolume( theNewVolume );
sl@0
   243
	User::LeaveIfError( errorCode );
sl@0
   244
sl@0
   245
	// [ if set volume = got volume, setVolume2 != got volume
sl@0
   246
	// and  rx'd event was ok then we are fine ]
sl@0
   247
    TInt overVolume  = maxVolume+1;
sl@0
   248
 
sl@0
   249
	//[ set the volume ]
sl@0
   250
	TInt overVolumeErrorCode =theCommander.SetVolume( overVolume );
sl@0
   251
	//[ get the volume ]
sl@0
   252
	TInt overVolumeResult (-100); // arbitrary initial value
sl@0
   253
	errorCode =theCommander.GetVolume( overVolumeResult );
sl@0
   254
	User::LeaveIfError( errorCode );
sl@0
   255
sl@0
   256
	TInt underVolume = -1;
sl@0
   257
sl@0
   258
	//[ set the volume ]
sl@0
   259
	TInt underVolumeErrorCode =theCommander.SetVolume( underVolume );
sl@0
   260
	//[ get the volume ]
sl@0
   261
	TInt underVolumeResult (0); //arbitrary initial value
sl@0
   262
	errorCode =theCommander.GetVolume( underVolumeResult );
sl@0
   263
	User::LeaveIfError( errorCode );
sl@0
   264
sl@0
   265
    //[ set the status of the test ]
sl@0
   266
    if( ( theVolume == theNewVolume ) &&       // volume has been set correctly
sl@0
   267
		( overVolumeErrorCode != KErrNone) &&  // over volume detected
sl@0
   268
		(theVolume == overVolumeResult) &&    // volume remains unchanged
sl@0
   269
		(underVolumeErrorCode != KErrNone) && // under volume detected
sl@0
   270
		( theVolume == underVolumeResult))    // volume remains unchanged
sl@0
   271
		{
sl@0
   272
		result = EPass;
sl@0
   273
		}
sl@0
   274
		
sl@0
   275
	//[ ensure the controller is unloaded so that it does 
sl@0
   276
	// not interfere with the following test ]
sl@0
   277
	// There is error in this code and the stop followed by reset
sl@0
   278
	// ensure the controller resources are released.
sl@0
   279
	iController.Stop();
sl@0
   280
	iController.Reset();
sl@0
   281
	iController.Close();  
sl@0
   282
	
sl@0
   283
	__MM_HEAP_MARKEND;
sl@0
   284
	   
sl@0
   285
	// test steps return a result
sl@0
   286
	return result;
sl@0
   287
	}
sl@0
   288
sl@0
   289
/**
sl@0
   290
CTestStepGetSetVolumeInStopped
sl@0
   291
sl@0
   292
*/
sl@0
   293
CTestStepGetSetVolumeInStopped::CTestStepGetSetVolumeInStopped()
sl@0
   294
	{
sl@0
   295
	iTestStepName = _L("MM-MMF-ACTRL-U-0003-HP");
sl@0
   296
	}
sl@0
   297
sl@0
   298
/**
sl@0
   299
~CTestStepGetSetVolumeInStopped
sl@0
   300
*/
sl@0
   301
CTestStepGetSetVolumeInStopped::~CTestStepGetSetVolumeInStopped()
sl@0
   302
	{
sl@0
   303
	}
sl@0
   304
sl@0
   305
/**
sl@0
   306
*
sl@0
   307
*DoTestStepL
sl@0
   308
*
sl@0
   309
*/
sl@0
   310
TVerdict CTestStepGetSetVolumeInStopped::DoTestStepL( void )
sl@0
   311
	{
sl@0
   312
	__MM_HEAP_MARK;
sl@0
   313
	TVerdict result = EFail;
sl@0
   314
sl@0
   315
	_LIT( KTestPlay, "Get/Set Volume while stopped");
sl@0
   316
	Log( KTestPlay );
sl@0
   317
	
sl@0
   318
	_LIT( KTestStepPlay, "This test checks get/set volume while stopped");
sl@0
   319
	Log( KTestStepPlay );
sl@0
   320
	
sl@0
   321
	// [ audio file to play ]
sl@0
   322
	_LIT(KTestWavFile, "newmail.wav");
sl@0
   323
   	SetReadFileNameL( KTestWavFile );
sl@0
   324
sl@0
   325
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
   326
	User::LeaveIfError( errorCode );
sl@0
   327
sl@0
   328
	//[ add data source and sink and prime the controller ]
sl@0
   329
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
   330
	User::LeaveIfError( errorCode );
sl@0
   331
	
sl@0
   332
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
   333
    User::LeaveIfError( errorCode );
sl@0
   334
sl@0
   335
	//[ set up audio commands utility ]	
sl@0
   336
	RMMFAudioPlayDeviceCustomCommands theCommander( iController );	
sl@0
   337
sl@0
   338
	// [ get the maximum volume ]
sl@0
   339
	TInt maxVolume = 0;
sl@0
   340
    errorCode =theCommander.GetMaxVolume( maxVolume );
sl@0
   341
	User::LeaveIfError( errorCode );
sl@0
   342
sl@0
   343
	//[ set the volume to 1/2 max volume ]
sl@0
   344
	TInt theVolume = maxVolume /2;
sl@0
   345
sl@0
   346
	//[ set the volume ]
sl@0
   347
	errorCode =theCommander.SetVolume( theVolume );
sl@0
   348
	User::LeaveIfError( errorCode );
sl@0
   349
	//[ get the volume ]
sl@0
   350
	TInt theNewVolume (0);
sl@0
   351
	errorCode =theCommander.GetVolume( theNewVolume );
sl@0
   352
	User::LeaveIfError( errorCode );
sl@0
   353
sl@0
   354
	// [ if set volume = got volume, setVolume2 != got volume
sl@0
   355
	// and  rx'd event was ok then we are fine ]
sl@0
   356
    TInt overVolume  = maxVolume+1;
sl@0
   357
 
sl@0
   358
	//[ set the volume ]
sl@0
   359
	TInt overVolumeErrorCode =theCommander.SetVolume( overVolume );
sl@0
   360
	//[ get the volume ]
sl@0
   361
	TInt overVolumeResult (-100); //arbitrary initial value
sl@0
   362
	errorCode =theCommander.GetVolume( overVolumeResult );
sl@0
   363
	User::LeaveIfError( errorCode );
sl@0
   364
sl@0
   365
	TInt underVolume = -1; //arbitrary initial value
sl@0
   366
sl@0
   367
	//[ set the volume ]
sl@0
   368
	TInt underVolumeErrorCode =theCommander.SetVolume( underVolume );
sl@0
   369
	//[ get the volume ]
sl@0
   370
	TInt underVolumeResult (0);
sl@0
   371
	errorCode =theCommander.GetVolume( underVolumeResult );
sl@0
   372
	User::LeaveIfError( errorCode );
sl@0
   373
sl@0
   374
    //[ set the status of the test ]
sl@0
   375
    if( ( theVolume == theNewVolume ) &&       // volume has been set correctly
sl@0
   376
		( overVolumeErrorCode != KErrNone) &&  // over volume detected
sl@0
   377
		(theVolume == overVolumeResult) &&    // volume remains unchanged
sl@0
   378
		(underVolumeErrorCode != KErrNone) && // under volume detected
sl@0
   379
		( theVolume == underVolumeResult))    // volume remains unchanged
sl@0
   380
		{
sl@0
   381
		result = EPass;
sl@0
   382
		}
sl@0
   383
	
sl@0
   384
	//[ ensure the controller is unloaded so that it does 
sl@0
   385
	// not interfere with the following test ]
sl@0
   386
	// There is error in this code and the stop followed by reset
sl@0
   387
	// ensure the controller resources are released.
sl@0
   388
	iController.Stop();
sl@0
   389
	iController.Reset();
sl@0
   390
	iController.Close();  
sl@0
   391
	
sl@0
   392
	__MM_HEAP_MARKEND;
sl@0
   393
	return result;
sl@0
   394
	}
sl@0
   395
sl@0
   396
/**
sl@0
   397
*
sl@0
   398
* CTestStepGetSetBalanceInPrimed
sl@0
   399
*
sl@0
   400
*/
sl@0
   401
CTestStepGetSetBalanceInPrimed::CTestStepGetSetBalanceInPrimed()
sl@0
   402
	{
sl@0
   403
	iTestStepName = _L("MM-MMF-ACTRL-U-0005-HP");
sl@0
   404
	}
sl@0
   405
sl@0
   406
/**
sl@0
   407
*
sl@0
   408
* ~CTestStepGetSetBalanceInPrimed
sl@0
   409
*/
sl@0
   410
CTestStepGetSetBalanceInPrimed::~CTestStepGetSetBalanceInPrimed()
sl@0
   411
	{
sl@0
   412
	}
sl@0
   413
sl@0
   414
/**
sl@0
   415
*
sl@0
   416
* DoTestStepL
sl@0
   417
*
sl@0
   418
*/
sl@0
   419
TVerdict  CTestStepGetSetBalanceInPrimed::DoTestStepL( void )
sl@0
   420
	{
sl@0
   421
	__MM_HEAP_MARK;
sl@0
   422
	TVerdict result = EFail;
sl@0
   423
sl@0
   424
	_LIT( KTestPlay, "Get/Set Balance while primed");
sl@0
   425
	Log( KTestPlay );
sl@0
   426
	
sl@0
   427
	_LIT( KTestStepPlay, "This test checks get/set balance while primed");
sl@0
   428
	Log( KTestStepPlay );
sl@0
   429
	
sl@0
   430
	// [ audio file to play ]
sl@0
   431
	_LIT(KTestWavFile, "newmail.wav");
sl@0
   432
	SetReadFileNameL( KTestWavFile );
sl@0
   433
   	
sl@0
   434
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
   435
	User::LeaveIfError( errorCode );
sl@0
   436
	
sl@0
   437
	//[ add data source and sink and prime the controller ]
sl@0
   438
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
   439
	User::LeaveIfError( errorCode );
sl@0
   440
	
sl@0
   441
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
   442
    User::LeaveIfError( errorCode );
sl@0
   443
sl@0
   444
	errorCode =	iController.Prime();
sl@0
   445
	User::LeaveIfError( errorCode );
sl@0
   446
	
sl@0
   447
	// [ wait for and process the return event from the audio output ]
sl@0
   448
	
sl@0
   449
	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
sl@0
   450
	TVerdict searchResult = SearchForEvent( primeEvent );
sl@0
   451
	if( searchResult == EFail )
sl@0
   452
		{
sl@0
   453
		return searchResult;
sl@0
   454
		}
sl@0
   455
	
sl@0
   456
	//[ set up audio commands utility ]	
sl@0
   457
	RMMFAudioPlayDeviceCustomCommands theCommander( iController );	
sl@0
   458
sl@0
   459
	// [ set the balance to an arbitrary value within the range -100 , 100 ]
sl@0
   460
	TInt theBalance = (30 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;
sl@0
   461
	//[ set the Balance, we are expecting failure ]
sl@0
   462
	TInt setErrorCode =theCommander.SetBalance( theBalance );
sl@0
   463
sl@0
   464
	//[ get the balance, we are expecting failure ]
sl@0
   465
	TInt theNewBalance (0);
sl@0
   466
	TInt getErrorCode =theCommander.GetBalance( theNewBalance );
sl@0
   467
sl@0
   468
	//[ set the status of the test ]
sl@0
   469
    if( ( getErrorCode ==  KErrNone) &&
sl@0
   470
		( setErrorCode ==  KErrNone) )
sl@0
   471
		{
sl@0
   472
		result = EPass;
sl@0
   473
		}
sl@0
   474
sl@0
   475
	//[ ensure the controller is unloaded so that it does 
sl@0
   476
	// not interfere with the following test ]
sl@0
   477
	// There is error in this code and the stop followed by reset
sl@0
   478
	// ensure the controller resources are released.
sl@0
   479
	iController.Stop();
sl@0
   480
	iController.Reset();
sl@0
   481
	iController.Close();  
sl@0
   482
	
sl@0
   483
	__MM_HEAP_MARKEND;
sl@0
   484
	return result;
sl@0
   485
	}
sl@0
   486
sl@0
   487
/**
sl@0
   488
*
sl@0
   489
* CTestStepGetSetBalanceInPlay
sl@0
   490
*/
sl@0
   491
CTestStepGetSetBalanceInPlay::CTestStepGetSetBalanceInPlay()
sl@0
   492
	{
sl@0
   493
   	iTestStepName = _L("MM-MMF-ACTRL-U-0007-HP");
sl@0
   494
	}
sl@0
   495
sl@0
   496
/**
sl@0
   497
*
sl@0
   498
* ~CTestStepGetSetBalanceInPlay
sl@0
   499
*/
sl@0
   500
CTestStepGetSetBalanceInPlay::~CTestStepGetSetBalanceInPlay()
sl@0
   501
	{
sl@0
   502
	}
sl@0
   503
sl@0
   504
/**
sl@0
   505
*
sl@0
   506
* DoTestStepL
sl@0
   507
*
sl@0
   508
*/
sl@0
   509
TVerdict CTestStepGetSetBalanceInPlay::DoTestStepL( void )
sl@0
   510
	{
sl@0
   511
	__MM_HEAP_MARK;
sl@0
   512
	TVerdict result = EFail;
sl@0
   513
sl@0
   514
	_LIT( KTestPlay, "Get/Set Balance while in Play");
sl@0
   515
	Log( KTestPlay );
sl@0
   516
	
sl@0
   517
	_LIT( KTestStepPlay, "This test checks get/set balance while playing");
sl@0
   518
	Log( KTestStepPlay );
sl@0
   519
	
sl@0
   520
	// [ audio file to play ]
sl@0
   521
	_LIT(KTestWavFile, "newmail.wav");
sl@0
   522
	SetReadFileNameL( KTestWavFile );
sl@0
   523
   	
sl@0
   524
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
   525
	User::LeaveIfError( errorCode );
sl@0
   526
sl@0
   527
	//[ add data source and sink and prime the controller ]
sl@0
   528
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
   529
	User::LeaveIfError( errorCode );
sl@0
   530
	
sl@0
   531
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
   532
    User::LeaveIfError( errorCode );
sl@0
   533
sl@0
   534
	errorCode =	iController.Prime();
sl@0
   535
	User::LeaveIfError( errorCode );
sl@0
   536
	
sl@0
   537
	// [ wait for and process the return event from the audio output ]
sl@0
   538
	
sl@0
   539
	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
sl@0
   540
	TVerdict searchResult = SearchForEvent( primeEvent );
sl@0
   541
	if( searchResult == EFail )
sl@0
   542
		{
sl@0
   543
		return searchResult;
sl@0
   544
		}
sl@0
   545
	
sl@0
   546
	//[ set the controller to play ]
sl@0
   547
	User::LeaveIfError( iController.Play() );
sl@0
   548
	
sl@0
   549
	//[ set up audio commands utility ]	
sl@0
   550
	RMMFAudioPlayDeviceCustomCommands theCommander( iController );	
sl@0
   551
sl@0
   552
	// [ set the balance to an arbitrary value between 0,100 and map to the range -100,100 ]
sl@0
   553
	TInt theBalance = (30 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;;
sl@0
   554
	//[ set the Balance ]
sl@0
   555
	TInt setErrorCode =theCommander.SetBalance( theBalance );
sl@0
   556
	
sl@0
   557
	//[ get the balance ]
sl@0
   558
	TInt theNewBalance (0);
sl@0
   559
	TInt getErrorCode =theCommander.GetBalance( theNewBalance );
sl@0
   560
sl@0
   561
	//[ set the status of the test ]
sl@0
   562
    if( 
sl@0
   563
		( getErrorCode != KErrNone) && // under volume detected
sl@0
   564
		( setErrorCode != KErrNone))    // volume remains unchanged
sl@0
   565
		{
sl@0
   566
		result = EPass;
sl@0
   567
		}
sl@0
   568
sl@0
   569
    TMMFEvent playEvent( KPlayTestId, KErrNone );
sl@0
   570
	searchResult = SearchForEvent( playEvent );
sl@0
   571
	if( searchResult != EFail )
sl@0
   572
		{
sl@0
   573
		result = EPass;
sl@0
   574
		}
sl@0
   575
sl@0
   576
	//[ ensure the controller is unloaded so that it does 
sl@0
   577
	// not interfere with the following test ]
sl@0
   578
	// There is error in this code and the stop followed by reset
sl@0
   579
	// ensure the controller resources are released.
sl@0
   580
	iController.Stop();
sl@0
   581
	iController.Reset();
sl@0
   582
	iController.Close();  
sl@0
   583
	
sl@0
   584
	__MM_HEAP_MARKEND;
sl@0
   585
	return result;
sl@0
   586
	}
sl@0
   587
sl@0
   588
/**
sl@0
   589
*
sl@0
   590
* CTestStepGetSetBalanceInStopped
sl@0
   591
*
sl@0
   592
*/
sl@0
   593
CTestStepGetSetBalanceInStopped::CTestStepGetSetBalanceInStopped()
sl@0
   594
	{
sl@0
   595
	iTestStepName = _L("MM-MMF-ACTRL-U-0006-HP");
sl@0
   596
	}
sl@0
   597
sl@0
   598
/**
sl@0
   599
*
sl@0
   600
* CTestStepGetSetBalanceInStopped
sl@0
   601
*
sl@0
   602
*/
sl@0
   603
CTestStepGetSetBalanceInStopped::~CTestStepGetSetBalanceInStopped()
sl@0
   604
	{
sl@0
   605
	}
sl@0
   606
sl@0
   607
/**
sl@0
   608
*
sl@0
   609
* DoTestStepL
sl@0
   610
*
sl@0
   611
*/
sl@0
   612
TVerdict CTestStepGetSetBalanceInStopped::DoTestStepL( void )
sl@0
   613
	{
sl@0
   614
	__MM_HEAP_MARK;
sl@0
   615
	TVerdict result = EFail;
sl@0
   616
sl@0
   617
	_LIT( KTestPlay, "Get/Set Balance while stopped");
sl@0
   618
	Log( KTestPlay );
sl@0
   619
	
sl@0
   620
	_LIT( KTestStepPlay, "This test checks get/set balance while stopped");
sl@0
   621
	Log( KTestStepPlay );
sl@0
   622
	
sl@0
   623
	// [ audio file to play ]
sl@0
   624
	_LIT(KTestWavFile, "newmail.wav");
sl@0
   625
	SetReadFileNameL( KTestWavFile );
sl@0
   626
   	
sl@0
   627
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
   628
	User::LeaveIfError( errorCode );
sl@0
   629
sl@0
   630
	//[ add data source and sink and prime the controller ]
sl@0
   631
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
   632
	User::LeaveIfError( errorCode );
sl@0
   633
	
sl@0
   634
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
   635
    User::LeaveIfError( errorCode );
sl@0
   636
sl@0
   637
	//[ set up audio commands utility ]	
sl@0
   638
	RMMFAudioPlayDeviceCustomCommands theCommander( iController );	
sl@0
   639
sl@0
   640
	// [ set the balance ]
sl@0
   641
	TInt theBalance = (30 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;;
sl@0
   642
	//[ set the Balance ]
sl@0
   643
	errorCode =theCommander.SetBalance( theBalance );
sl@0
   644
	User::LeaveIfError( errorCode );
sl@0
   645
sl@0
   646
	//[ get the balance ]
sl@0
   647
	TInt theNewBalance (0);
sl@0
   648
	errorCode =theCommander.GetBalance( theNewBalance );
sl@0
   649
	User::LeaveIfError( errorCode );
sl@0
   650
sl@0
   651
	// [ if set balance = got balance, setbalance2 != got balance
sl@0
   652
	// and  rx'd event was ok then we are fine 
sl@0
   653
	// set the balance to an arbitrary value in the range 0..100 and map to the soundev range]
sl@0
   654
    TInt overBalance  = (300 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;
sl@0
   655
 
sl@0
   656
	//[ set the volume ]
sl@0
   657
	TInt overBalanceErrorCode =theCommander.SetBalance( overBalance );
sl@0
   658
	//[ get the volume ]
sl@0
   659
	TInt overBalanceResult (-106); // set to an arbitrary value
sl@0
   660
	errorCode =theCommander.GetBalance( overBalanceResult );
sl@0
   661
	User::LeaveIfError( errorCode );
sl@0
   662
sl@0
   663
	// [ set the under balance to a value < 0 and map to the correct range]
sl@0
   664
	TInt underBalance = (-50 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;
sl@0
   665
sl@0
   666
	//[ set the volume ]
sl@0
   667
	TInt underBalanceErrorCode =theCommander.SetBalance( underBalance );
sl@0
   668
	//[ get the volume ]
sl@0
   669
	TInt underBalanceResult (0);
sl@0
   670
	errorCode =theCommander.GetBalance( underBalanceResult );
sl@0
   671
	User::LeaveIfError( errorCode );
sl@0
   672
sl@0
   673
	// Set the test result
sl@0
   674
	if ((theBalance == theNewBalance) &&				// balance set correctly
sl@0
   675
		(overBalanceErrorCode == KErrNone) &&			// no error setting over balance
sl@0
   676
		(overBalanceResult == KMMFBalanceMaxRight) &&	// over balance is set to KMMFBalanceMaxRight
sl@0
   677
		(underBalanceErrorCode == KErrNone) &&			// no error setting under balance
sl@0
   678
		(underBalanceResult == KMMFBalanceMaxLeft))		// under balance is set to KMMFBalanceMaxLeft
sl@0
   679
		{
sl@0
   680
		result = EPass;
sl@0
   681
		}
sl@0
   682
sl@0
   683
	//[ ensure the controller is unloaded so that it does 
sl@0
   684
	// not interfere with the following test ]
sl@0
   685
	// There is error in this code and the stop followed by reset
sl@0
   686
	// ensure the controller resources are released.
sl@0
   687
	iController.Stop();
sl@0
   688
	iController.Reset();
sl@0
   689
	iController.Close();  
sl@0
   690
	
sl@0
   691
	__MM_HEAP_MARKEND;
sl@0
   692
	return result;
sl@0
   693
	}
sl@0
   694
//
sl@0
   695
/**
sl@0
   696
*
sl@0
   697
* CTestStepGetSetPositionInPaused
sl@0
   698
*
sl@0
   699
*/
sl@0
   700
CTestStepGetSetPositionInPaused::CTestStepGetSetPositionInPaused()
sl@0
   701
	{
sl@0
   702
	iTestStepName = _L("MM-MMF-ACTRL-U-0070-HP");
sl@0
   703
	}
sl@0
   704
sl@0
   705
/**
sl@0
   706
*
sl@0
   707
* ~CTestStepGetSetPositionInPaused
sl@0
   708
*
sl@0
   709
*/
sl@0
   710
CTestStepGetSetPositionInPaused::~CTestStepGetSetPositionInPaused()
sl@0
   711
	{
sl@0
   712
	}
sl@0
   713
sl@0
   714
/**
sl@0
   715
*
sl@0
   716
* DoTestStepL
sl@0
   717
*
sl@0
   718
*/
sl@0
   719
TVerdict CTestStepGetSetPositionInPaused::DoTestStepL( void )
sl@0
   720
	{
sl@0
   721
	 __MM_HEAP_MARK;
sl@0
   722
	
sl@0
   723
	TVerdict result = EPass;
sl@0
   724
	TTimeIntervalMicroSeconds position(0);
sl@0
   725
	
sl@0
   726
	_LIT( KTestPause, "Pause Test");
sl@0
   727
	Log( KTestPause );
sl@0
   728
	
sl@0
   729
	_LIT( KTestStepPause, "This test checks set/get position whilst paused: Play->Pause->Rewind->Play (Proper verification requires headphones)");
sl@0
   730
	Log( KTestStepPause );
sl@0
   731
	
sl@0
   732
	// [ audio file to play ]
sl@0
   733
	// At time of writing, this file is approx 8s duration.
sl@0
   734
	_LIT(KTestWavFile, "mainTst.wav");
sl@0
   735
	SetReadFileNameL( KTestWavFile );
sl@0
   736
   	
sl@0
   737
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
   738
	User::LeaveIfError( errorCode );
sl@0
   739
sl@0
   740
	//[ add data source and sink and prime the controller ]
sl@0
   741
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
   742
	User::LeaveIfError( errorCode );
sl@0
   743
	
sl@0
   744
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
   745
    User::LeaveIfError( errorCode );
sl@0
   746
	
sl@0
   747
	User::LeaveIfError( iController.Prime() );
sl@0
   748
	
sl@0
   749
	// [ wait for and process the return event from the audio output ]
sl@0
   750
	
sl@0
   751
	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
sl@0
   752
	TVerdict searchResult = SearchForEvent( primeEvent );
sl@0
   753
	if( searchResult == EFail )
sl@0
   754
		{
sl@0
   755
		return searchResult;
sl@0
   756
		}
sl@0
   757
sl@0
   758
	User::LeaveIfError( iController.GetPosition( position ) );
sl@0
   759
	INFO_PRINTF2(_L("Position at start is %d"), position.Int64());
sl@0
   760
sl@0
   761
sl@0
   762
	// note this test does not wait around 
sl@0
   763
	// to detect that the audio has been played
sl@0
   764
	User::LeaveIfError( iController.Play() );
sl@0
   765
sl@0
   766
	// [ now process the confirmation event that play has reached audio output
sl@0
   767
	//   this is the raison detre of the test ]
sl@0
   768
	TMMFEvent playEvent1( KPlayTestId, KErrNone );
sl@0
   769
	searchResult = SearchForEvent( playEvent1 );
sl@0
   770
	if( searchResult == EFail )
sl@0
   771
		{
sl@0
   772
		return searchResult;
sl@0
   773
		}	
sl@0
   774
sl@0
   775
	// [ play for two seconds ]
sl@0
   776
	User::After(2000000); 
sl@0
   777
sl@0
   778
	User::LeaveIfError( iController.GetPosition( position ) );
sl@0
   779
	INFO_PRINTF2(_L("Position before pause is %d"), position.Int64());
sl@0
   780
sl@0
   781
sl@0
   782
    // [ The controller is in the play state and
sl@0
   783
	//   should not return an error if pause is called ]
sl@0
   784
	User::LeaveIfError( iController.Pause() );
sl@0
   785
sl@0
   786
	TMMFEvent pauseEvent( KPauseTestId, KErrNone );
sl@0
   787
	result = SearchForEvent( pauseEvent );
sl@0
   788
	if( result == EFail )
sl@0
   789
		{
sl@0
   790
		return result;
sl@0
   791
		}
sl@0
   792
sl@0
   793
	User::LeaveIfError( iController.GetPosition( position ) );
sl@0
   794
	INFO_PRINTF2(_L("Position after pause is %d"), position.Int64());
sl@0
   795
sl@0
   796
	//[ ok lets reset to the beginning ]
sl@0
   797
	User::LeaveIfError( iController.SetPosition( TTimeIntervalMicroSeconds(0) ) );
sl@0
   798
	
sl@0
   799
	User::LeaveIfError( iController.GetPosition( position ) );
sl@0
   800
	INFO_PRINTF2(_L("Position after rewind is %d"), position.Int64());
sl@0
   801
sl@0
   802
sl@0
   803
	// [ Now let's start to play again ]
sl@0
   804
sl@0
   805
	// note this test does not wait around 
sl@0
   806
	// to detect that the audio has been played
sl@0
   807
	User::LeaveIfError( iController.Play() );
sl@0
   808
sl@0
   809
	// [ now process the confirmation event that play has reached audio output
sl@0
   810
	//   this is the raison detre of the test ]
sl@0
   811
	TMMFEvent playEvent2( KPlayTestId, KErrNone );
sl@0
   812
	searchResult = SearchForEvent( playEvent2 );
sl@0
   813
	if( searchResult == EFail )
sl@0
   814
		{
sl@0
   815
		return searchResult;
sl@0
   816
		}	
sl@0
   817
sl@0
   818
	// [ play for 10s (approx entire file) ]
sl@0
   819
	User::After(10000000); 
sl@0
   820
sl@0
   821
	//[ ensure the controller is unloaded so that it does 
sl@0
   822
	// not interfere with the following test ]
sl@0
   823
	// There is error in this code and the stop followed by reset
sl@0
   824
	// ensure the controller resources are released.
sl@0
   825
	iController.Stop();
sl@0
   826
	iController.Reset();
sl@0
   827
	iController.Close();  
sl@0
   828
	
sl@0
   829
	__MM_HEAP_MARKEND;
sl@0
   830
	return result;
sl@0
   831
	}
sl@0
   832
//
sl@0
   833
/**
sl@0
   834
*
sl@0
   835
* CTestStepGetSetPositionInPlay
sl@0
   836
*
sl@0
   837
*/
sl@0
   838
CTestStepGetSetPositionInPlay::CTestStepGetSetPositionInPlay()
sl@0
   839
	{
sl@0
   840
	iTestStepName = _L("MM-MMF-ACTRL-U-0008-HP");
sl@0
   841
	}
sl@0
   842
sl@0
   843
/**
sl@0
   844
*
sl@0
   845
* ~CTestStepGetSetPositionInPlay
sl@0
   846
*
sl@0
   847
*/
sl@0
   848
CTestStepGetSetPositionInPlay::~CTestStepGetSetPositionInPlay()
sl@0
   849
	{
sl@0
   850
	}
sl@0
   851
sl@0
   852
/**
sl@0
   853
*
sl@0
   854
* DoTestStepL
sl@0
   855
*
sl@0
   856
*/
sl@0
   857
TVerdict CTestStepGetSetPositionInPlay::DoTestStepL( void )
sl@0
   858
	{
sl@0
   859
	 __MM_HEAP_MARK;
sl@0
   860
	
sl@0
   861
	TVerdict result = EPass;
sl@0
   862
	
sl@0
   863
	_LIT( KTestPlay, "Play Test");
sl@0
   864
	Log( KTestPlay );
sl@0
   865
	
sl@0
   866
	_LIT( KTestStepPlay, "This test checks set/get position whilst playing");
sl@0
   867
	Log( KTestStepPlay );
sl@0
   868
	
sl@0
   869
	// [ audio file to play ]
sl@0
   870
	_LIT(KTestWavFile, "newmail.wav");
sl@0
   871
	SetReadFileNameL( KTestWavFile );
sl@0
   872
   	
sl@0
   873
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
   874
	User::LeaveIfError( errorCode );
sl@0
   875
sl@0
   876
	//[ add data source and sink and prime the controller ]
sl@0
   877
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
   878
	User::LeaveIfError( errorCode );
sl@0
   879
	
sl@0
   880
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
   881
    User::LeaveIfError( errorCode );
sl@0
   882
	
sl@0
   883
	errorCode =	iController.Prime();
sl@0
   884
	User::LeaveIfError( errorCode );
sl@0
   885
	
sl@0
   886
	// [ wait for and process the return event from the audio output ]
sl@0
   887
	
sl@0
   888
	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
sl@0
   889
	TVerdict searchResult = SearchForEvent( primeEvent );
sl@0
   890
	if( searchResult == EFail )
sl@0
   891
		{
sl@0
   892
		return searchResult;
sl@0
   893
		}
sl@0
   894
sl@0
   895
	 User::LeaveIfError( iController.Play() );
sl@0
   896
sl@0
   897
	// note this test does not wait around 
sl@0
   898
	// to detect that the audio has been played
sl@0
   899
	// [ now process the confirmation event that play has reached audio output
sl@0
   900
	//   this is the raison detre of the test ]
sl@0
   901
	TMMFEvent playEvent( KPlayTestId, KErrNone );
sl@0
   902
	
sl@0
   903
	searchResult = SearchForEvent( playEvent );
sl@0
   904
	if( searchResult == EFail )
sl@0
   905
		{
sl@0
   906
		return searchResult;
sl@0
   907
		}	
sl@0
   908
sl@0
   909
	//[ ok lets set/get the position ]
sl@0
   910
	TTimeIntervalMicroSeconds theStartPosition(0);
sl@0
   911
	TInt posSetError = iController.SetPosition( theStartPosition );
sl@0
   912
	
sl@0
   913
	// [get the position ]
sl@0
   914
	TTimeIntervalMicroSeconds theCurrentPosition;
sl@0
   915
	TInt posGetError = iController.GetPosition( theCurrentPosition );
sl@0
   916
sl@0
   917
	// [ the test has passed if we have no errors in both cases ]
sl@0
   918
	if( (posGetError != KErrNone ) &&
sl@0
   919
		(posSetError != KErrNone ) )
sl@0
   920
		{
sl@0
   921
		result = EFail ;
sl@0
   922
		}
sl@0
   923
sl@0
   924
	//[ ensure the controller is unloaded so that it does 
sl@0
   925
	// not interfere with the following test ]
sl@0
   926
	// There is error in this code and the stop followed by reset
sl@0
   927
	// ensure the controller resources are released.
sl@0
   928
	iController.Stop();
sl@0
   929
	iController.Reset();
sl@0
   930
	iController.Close();  
sl@0
   931
	
sl@0
   932
	__MM_HEAP_MARKEND;
sl@0
   933
	return result;
sl@0
   934
	}
sl@0
   935
sl@0
   936
/**
sl@0
   937
*
sl@0
   938
*
sl@0
   939
* CTestStepGetSetPositionInStopped
sl@0
   940
*
sl@0
   941
*/
sl@0
   942
CTestStepGetSetPositionInStopped::CTestStepGetSetPositionInStopped()
sl@0
   943
	{
sl@0
   944
	iTestStepName = _L("MM-MMF-ACTRL-U-0009-HP");
sl@0
   945
	}
sl@0
   946
sl@0
   947
/**
sl@0
   948
*
sl@0
   949
* ~CTestStepGetSetPositionInStopped
sl@0
   950
*/
sl@0
   951
CTestStepGetSetPositionInStopped::~CTestStepGetSetPositionInStopped()
sl@0
   952
	{
sl@0
   953
	}
sl@0
   954
sl@0
   955
/**
sl@0
   956
*
sl@0
   957
* DoTestStepL
sl@0
   958
*
sl@0
   959
*/
sl@0
   960
TVerdict CTestStepGetSetPositionInStopped::DoTestStepL( void )
sl@0
   961
	{
sl@0
   962
	__MM_HEAP_MARK;
sl@0
   963
	TVerdict result = EPass ;
sl@0
   964
	//[ In this state it should not be possible to set the positio]
sl@0
   965
sl@0
   966
	_LIT( KTestPlay, "Set/Get Position while stopped");
sl@0
   967
	Log( KTestPlay );
sl@0
   968
	
sl@0
   969
	_LIT( KTestStepPlay, "This test checks get/set position while stopped");
sl@0
   970
	Log( KTestStepPlay );
sl@0
   971
	
sl@0
   972
	// [ audio file to play ]
sl@0
   973
	_LIT(KTestWavFile, "newmail.wav");
sl@0
   974
	SetReadFileNameL( KTestWavFile );
sl@0
   975
   	
sl@0
   976
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
   977
	User::LeaveIfError( errorCode );
sl@0
   978
sl@0
   979
	
sl@0
   980
	//[ add data source and sink and prime the controller ]
sl@0
   981
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
   982
	User::LeaveIfError( errorCode );
sl@0
   983
	
sl@0
   984
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
   985
    User::LeaveIfError( errorCode );
sl@0
   986
sl@0
   987
    //[ set the position to the start ]
sl@0
   988
	TTimeIntervalMicroSeconds theStartPosition(0);
sl@0
   989
	TInt posSetError = iController.SetPosition( theStartPosition );
sl@0
   990
	
sl@0
   991
	// [get the position ]
sl@0
   992
	TTimeIntervalMicroSeconds theCurrentPosition;
sl@0
   993
	TInt posGetError = iController.GetPosition( theCurrentPosition );
sl@0
   994
sl@0
   995
	// [ the test has passed if we have errors in both cases ]
sl@0
   996
	if( (posGetError == KErrNone ) ||
sl@0
   997
		(posSetError == KErrNone ) )
sl@0
   998
		{
sl@0
   999
		result = EFail ;
sl@0
  1000
		}
sl@0
  1001
sl@0
  1002
	//[ ensure the controller is unloaded so that it does 
sl@0
  1003
	// not interfere with the following test ]
sl@0
  1004
	// There is error in this code and the stop followed by reset
sl@0
  1005
	// ensure the controller resources are released.
sl@0
  1006
	iController.Stop();
sl@0
  1007
	iController.Reset();
sl@0
  1008
	iController.Close();  
sl@0
  1009
	
sl@0
  1010
	__MM_HEAP_MARKEND;
sl@0
  1011
	return result ;
sl@0
  1012
	}
sl@0
  1013
sl@0
  1014
/**
sl@0
  1015
*
sl@0
  1016
* CTestStepGetSetPositionInPrimed
sl@0
  1017
*/
sl@0
  1018
CTestStepGetSetPositionInPrimed::CTestStepGetSetPositionInPrimed()
sl@0
  1019
	{
sl@0
  1020
	iTestStepName = _L("MM-MMF-ACTRL-U-0010-HP");
sl@0
  1021
	}
sl@0
  1022
sl@0
  1023
/**
sl@0
  1024
*
sl@0
  1025
* ~CTestStepGetSetPositionInStopped
sl@0
  1026
*/
sl@0
  1027
CTestStepGetSetPositionInPrimed::~CTestStepGetSetPositionInPrimed()
sl@0
  1028
	{
sl@0
  1029
	}
sl@0
  1030
sl@0
  1031
/**
sl@0
  1032
*
sl@0
  1033
* DoTestStepL
sl@0
  1034
*
sl@0
  1035
*/
sl@0
  1036
TVerdict CTestStepGetSetPositionInPrimed::DoTestStepL( void )
sl@0
  1037
	{
sl@0
  1038
	__MM_HEAP_MARK;
sl@0
  1039
	TVerdict result = EPass ;
sl@0
  1040
sl@0
  1041
	_LIT( KTestStepPlay, "GetSet Position In Primed");
sl@0
  1042
	Log( KTestStepPlay );
sl@0
  1043
	
sl@0
  1044
	// [ audio file to play ]
sl@0
  1045
	_LIT(KTestWavFile, "newmail.wav");
sl@0
  1046
	SetReadFileNameL( KTestWavFile );
sl@0
  1047
   	
sl@0
  1048
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
  1049
	User::LeaveIfError( errorCode );
sl@0
  1050
sl@0
  1051
	//[ add data source and sink and prime the controller ]
sl@0
  1052
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
  1053
	User::LeaveIfError( errorCode );
sl@0
  1054
	
sl@0
  1055
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
  1056
    User::LeaveIfError( errorCode );
sl@0
  1057
sl@0
  1058
	errorCode =	iController.Prime();
sl@0
  1059
	User::LeaveIfError( errorCode );
sl@0
  1060
	
sl@0
  1061
	// [ wait for and process the return event from the audio output ]
sl@0
  1062
	
sl@0
  1063
	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
sl@0
  1064
	TVerdict searchResult = SearchForEvent( primeEvent );
sl@0
  1065
	if( searchResult == EFail )
sl@0
  1066
		{
sl@0
  1067
		return searchResult;
sl@0
  1068
		}
sl@0
  1069
sl@0
  1070
	// [get the duration of the file]
sl@0
  1071
	TTimeIntervalMicroSeconds theDuration;
sl@0
  1072
	TInt durationError = iController.GetDuration(theDuration);
sl@0
  1073
	User::LeaveIfError( durationError );
sl@0
  1074
sl@0
  1075
	//[ set the position to the end ]
sl@0
  1076
	TInt posError = iController.SetPosition( theDuration );
sl@0
  1077
	User::LeaveIfError( posError );
sl@0
  1078
sl@0
  1079
	// [get the position ]
sl@0
  1080
	TTimeIntervalMicroSeconds theEndPosition;
sl@0
  1081
	TInt positionError = iController.GetPosition( theEndPosition );
sl@0
  1082
	User::LeaveIfError( positionError );
sl@0
  1083
	  
sl@0
  1084
	// [ set the position beyond the end ]
sl@0
  1085
    TInt64 beyondTheEnd = theDuration.Int64();
sl@0
  1086
	beyondTheEnd *= 1000000;
sl@0
  1087
	TTimeIntervalMicroSeconds beyondTheEndPosition( beyondTheEnd);
sl@0
  1088
sl@0
  1089
	// [get the position ]
sl@0
  1090
	TTimeIntervalMicroSeconds theCurrentPosition;
sl@0
  1091
	TInt currentPositionError = iController.GetPosition( theCurrentPosition );
sl@0
  1092
	User::LeaveIfError( currentPositionError );
sl@0
  1093
sl@0
  1094
	//[ set the position beyond the end ]
sl@0
  1095
	TInt beyondEndError = iController.SetPosition( beyondTheEndPosition );
sl@0
  1096
sl@0
  1097
	//[ get the position ]
sl@0
  1098
	TTimeIntervalMicroSeconds theCurrentPosition2;
sl@0
  1099
	currentPositionError = iController.GetPosition( theCurrentPosition2 );
sl@0
  1100
	User::LeaveIfError( currentPositionError );
sl@0
  1101
     
sl@0
  1102
	if( (theCurrentPosition2 != theCurrentPosition ) && 
sl@0
  1103
		( beyondEndError == KErrNone ))
sl@0
  1104
		{
sl@0
  1105
		// altered position when wrong position was sent
sl@0
  1106
		// assumes this violation does not corrupt the current position
sl@0
  1107
		return EFail;
sl@0
  1108
		}
sl@0
  1109
   
sl@0
  1110
	// [ set the position before the start ]
sl@0
  1111
	currentPositionError = iController.GetPosition( theCurrentPosition );
sl@0
  1112
	User::LeaveIfError( currentPositionError );
sl@0
  1113
sl@0
  1114
	//[ set the position to a time < 0 ]
sl@0
  1115
	TTimeIntervalMicroSeconds beforeTheStart( -10000 );
sl@0
  1116
	//[ set the position beyond the end ]
sl@0
  1117
	TInt beforeStartError = iController.SetPosition( beforeTheStart );
sl@0
  1118
sl@0
  1119
	//[ get the position ]
sl@0
  1120
	currentPositionError = iController.GetPosition( theCurrentPosition2 );
sl@0
  1121
	User::LeaveIfError( currentPositionError );
sl@0
  1122
sl@0
  1123
	// [determine the results of the test]
sl@0
  1124
	if( (theCurrentPosition2 != theCurrentPosition ) && 
sl@0
  1125
		( beforeStartError == KErrNone ))
sl@0
  1126
		{
sl@0
  1127
		// altered position when wrong position was sent
sl@0
  1128
		// assumes this violation does not corrupt the current position
sl@0
  1129
		return EFail;
sl@0
  1130
		}
sl@0
  1131
sl@0
  1132
	//[ ensure the controller is unloaded so that it does 
sl@0
  1133
	// not interfere with the following test ]
sl@0
  1134
	// There is error in this code and the stop followed by reset
sl@0
  1135
	// ensure the controller resources are released.
sl@0
  1136
	iController.Stop();
sl@0
  1137
	iController.Reset();
sl@0
  1138
	iController.Close();  
sl@0
  1139
	
sl@0
  1140
	__MM_HEAP_MARKEND;
sl@0
  1141
	return result;
sl@0
  1142
	}
sl@0
  1143
sl@0
  1144
/**
sl@0
  1145
*
sl@0
  1146
* CTestStepGetSetNumChannelsOnSource
sl@0
  1147
*
sl@0
  1148
*/
sl@0
  1149
CTestStepGetSetNumChannelsOnSource::CTestStepGetSetNumChannelsOnSource()
sl@0
  1150
	{
sl@0
  1151
	iTestStepName = _L("MM-MMF-ACTRL-U-0021-HP");
sl@0
  1152
	}
sl@0
  1153
sl@0
  1154
/**
sl@0
  1155
*
sl@0
  1156
* ~CTestStepGetSetNumChannelsOnSource
sl@0
  1157
*
sl@0
  1158
*/
sl@0
  1159
CTestStepGetSetNumChannelsOnSource::~CTestStepGetSetNumChannelsOnSource()
sl@0
  1160
	{
sl@0
  1161
	}
sl@0
  1162
sl@0
  1163
/**
sl@0
  1164
*
sl@0
  1165
* DoTestStepL
sl@0
  1166
*
sl@0
  1167
*/
sl@0
  1168
TVerdict CTestStepGetSetNumChannelsOnSource::DoTestStepL( void )
sl@0
  1169
	{
sl@0
  1170
	__MM_HEAP_MARK;
sl@0
  1171
	TVerdict result = EPass;
sl@0
  1172
	
sl@0
  1173
	_LIT( KTestSourceNumChannels, "GetSet Num Channels on the Source");
sl@0
  1174
	Log( KTestSourceNumChannels);
sl@0
  1175
	
sl@0
  1176
	_LIT( KTestSinkBitRateReason, "This test checks the set/get num channels on the source");
sl@0
  1177
	Log( KTestSinkBitRateReason );
sl@0
  1178
	
sl@0
  1179
	// [ audio file to play ]
sl@0
  1180
	_LIT(KTestWavFile, "newmail.wav");
sl@0
  1181
	SetReadFileNameL( KTestWavFile );
sl@0
  1182
   	
sl@0
  1183
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
  1184
	User::LeaveIfError( errorCode );
sl@0
  1185
sl@0
  1186
	// [ attempt to get the source num channels ]
sl@0
  1187
    RMMFAudioControllerCustomCommands theCommander( iController );
sl@0
  1188
sl@0
  1189
	TUint theRate = 0;
sl@0
  1190
	errorCode = theCommander.GetSourceNumChannels(theRate);
sl@0
  1191
	if( errorCode == KErrNone )
sl@0
  1192
		{
sl@0
  1193
		result = EFail;
sl@0
  1194
		return result;
sl@0
  1195
		}
sl@0
  1196
sl@0
  1197
	//[ ok lets add the source and sink ]
sl@0
  1198
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
  1199
	User::LeaveIfError( errorCode );
sl@0
  1200
sl@0
  1201
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
  1202
    User::LeaveIfError( errorCode );
sl@0
  1203
sl@0
  1204
	theRate = 0;
sl@0
  1205
	errorCode = theCommander.GetSourceNumChannels(theRate);
sl@0
  1206
	User::LeaveIfError( errorCode );
sl@0
  1207
sl@0
  1208
	//[ get the format ]
sl@0
  1209
	TUid theFormatUID;
sl@0
  1210
	errorCode = theCommander.GetSourceFormat(theFormatUID);
sl@0
  1211
	User::LeaveIfError( errorCode );
sl@0
  1212
sl@0
  1213
	//[ ensure we are in are not a raw format because 
sl@0
  1214
	//  this functionality is only supported in raw format]
sl@0
  1215
	if( theFormatUID == KFormatRAWRead )
sl@0
  1216
		{
sl@0
  1217
		result = EFail;
sl@0
  1218
		return result;
sl@0
  1219
		}
sl@0
  1220
	
sl@0
  1221
	// lets set the num of channels to 2
sl@0
  1222
	errorCode = theCommander.SetSourceNumChannels(theRate);
sl@0
  1223
	if( errorCode != KErrNone )
sl@0
  1224
		{
sl@0
  1225
		result = EFail;
sl@0
  1226
		return result ;
sl@0
  1227
		}
sl@0
  1228
sl@0
  1229
	//[ ensure the controller is unloaded so that it does 
sl@0
  1230
	// not interfere with the following test ]
sl@0
  1231
	// There is error in this code and the stop followed by reset
sl@0
  1232
	// ensure the controller resources are released.
sl@0
  1233
	iController.Stop();
sl@0
  1234
	iController.Reset();
sl@0
  1235
	iController.Close();  
sl@0
  1236
	
sl@0
  1237
	__MM_HEAP_MARKEND;
sl@0
  1238
	return EPass;
sl@0
  1239
	}
sl@0
  1240
sl@0
  1241
/**
sl@0
  1242
*
sl@0
  1243
* CTestStepGetSetNumChannelsOnSink
sl@0
  1244
*
sl@0
  1245
*/
sl@0
  1246
CTestStepGetSetNumChannelsOnSink::CTestStepGetSetNumChannelsOnSink()
sl@0
  1247
	{
sl@0
  1248
	iTestStepName = _L("MM-MMF-ACTRL-U-0022-HP");
sl@0
  1249
	}
sl@0
  1250
sl@0
  1251
/**
sl@0
  1252
*
sl@0
  1253
* ~CTestStepGetSetNumChannelsOnSink
sl@0
  1254
*
sl@0
  1255
*/
sl@0
  1256
CTestStepGetSetNumChannelsOnSink::~CTestStepGetSetNumChannelsOnSink()
sl@0
  1257
	{
sl@0
  1258
	}
sl@0
  1259
sl@0
  1260
/**
sl@0
  1261
*
sl@0
  1262
* DoTestStepL
sl@0
  1263
*
sl@0
  1264
*/
sl@0
  1265
TVerdict CTestStepGetSetNumChannelsOnSink::DoTestStepL( void )
sl@0
  1266
	{
sl@0
  1267
	__MM_HEAP_MARK;
sl@0
  1268
	TVerdict result = EPass;
sl@0
  1269
	
sl@0
  1270
	_LIT( KTestSourceNumChannels, "GetSet Num Channels on the Sink");
sl@0
  1271
	Log( KTestSourceNumChannels);
sl@0
  1272
	
sl@0
  1273
	_LIT( KTestSinkBitRateReason, "This test checks the set/get num channels on the sink");
sl@0
  1274
	Log( KTestSinkBitRateReason );
sl@0
  1275
	
sl@0
  1276
	// [ audio file to play ]
sl@0
  1277
	_LIT(KTestWavFile, "newmail.wav");
sl@0
  1278
	SetReadFileNameL( KTestWavFile );
sl@0
  1279
sl@0
  1280
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
  1281
	User::LeaveIfError( errorCode );
sl@0
  1282
sl@0
  1283
	//[ attempt to get the sink num channels ]
sl@0
  1284
    RMMFAudioControllerCustomCommands theCommander( iController );
sl@0
  1285
sl@0
  1286
	TUint theRate = 0;
sl@0
  1287
	errorCode = theCommander.GetSinkNumChannels(theRate);
sl@0
  1288
	if( errorCode == KErrNone )
sl@0
  1289
		{
sl@0
  1290
		result = EFail;
sl@0
  1291
		return result;
sl@0
  1292
		}
sl@0
  1293
sl@0
  1294
	//[ ok lets add the source and sink ]
sl@0
  1295
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
  1296
	User::LeaveIfError( errorCode );
sl@0
  1297
sl@0
  1298
	//[ add data source and sink and prime the controller ]
sl@0
  1299
    errorCode = iController.AddDataSink(KUidMmfFileSink, ReadFileConfig());
sl@0
  1300
	User::LeaveIfError( errorCode );
sl@0
  1301
sl@0
  1302
	//[ ok lets try to set the sink format to raw]
sl@0
  1303
	errorCode = theCommander.SetSinkFormat(KFormatRAWWrite);
sl@0
  1304
	User::LeaveIfError( errorCode );
sl@0
  1305
sl@0
  1306
	//[ ok lets set the number of channels ]
sl@0
  1307
	// lets set the num of channels to 2
sl@0
  1308
	TUint theNumChannels = 2;
sl@0
  1309
	errorCode = theCommander.SetSinkNumChannels(theNumChannels);
sl@0
  1310
	User::LeaveIfError( errorCode );
sl@0
  1311
sl@0
  1312
	// [ get the number of channels and see if it is the same ]
sl@0
  1313
	TUint theNewNumChannels = 0;
sl@0
  1314
	errorCode = theCommander.GetSinkNumChannels(theNewNumChannels);
sl@0
  1315
	User::LeaveIfError( errorCode );
sl@0
  1316
sl@0
  1317
	if( theNumChannels != theNewNumChannels )
sl@0
  1318
		{
sl@0
  1319
		result = EFail;
sl@0
  1320
		return result;
sl@0
  1321
		}
sl@0
  1322
sl@0
  1323
	//[ ensure the controller is unloaded so that it does 
sl@0
  1324
	// not interfere with the following test ]
sl@0
  1325
	// There is error in this code and the stop followed by reset
sl@0
  1326
	// ensure the controller resources are released.
sl@0
  1327
	iController.Stop();
sl@0
  1328
	iController.Reset();
sl@0
  1329
	iController.Close();  
sl@0
  1330
	
sl@0
  1331
	__MM_HEAP_MARKEND;
sl@0
  1332
	return result;
sl@0
  1333
	}
sl@0
  1334
sl@0
  1335
/**
sl@0
  1336
*
sl@0
  1337
* CTestStepGetSetSinkFormat
sl@0
  1338
*
sl@0
  1339
*/
sl@0
  1340
CTestStepGetSetSinkFormat::CTestStepGetSetSinkFormat()
sl@0
  1341
	{
sl@0
  1342
	iTestStepName = _L("MM-MMF-ACTRL-U-0023-HP");
sl@0
  1343
	}
sl@0
  1344
sl@0
  1345
/**
sl@0
  1346
*
sl@0
  1347
* ~CTestStepGetSetSinkFormat
sl@0
  1348
*
sl@0
  1349
*/
sl@0
  1350
CTestStepGetSetSinkFormat::~CTestStepGetSetSinkFormat()
sl@0
  1351
	{
sl@0
  1352
	}
sl@0
  1353
sl@0
  1354
/**
sl@0
  1355
*
sl@0
  1356
* DoTestStepL
sl@0
  1357
*
sl@0
  1358
*/
sl@0
  1359
TVerdict CTestStepGetSetSinkFormat::DoTestStepL( void )
sl@0
  1360
	{
sl@0
  1361
	__MM_HEAP_MARK;
sl@0
  1362
	TVerdict result = EPass ;
sl@0
  1363
sl@0
  1364
	_LIT( KTestSinkFormat, "Test Step Get/Set sink format");
sl@0
  1365
	Log( KTestSinkFormat );
sl@0
  1366
	
sl@0
  1367
	_LIT( KTestStepSinkFormat, "This test checks the set/get sink format");
sl@0
  1368
	Log( KTestStepSinkFormat );
sl@0
  1369
	
sl@0
  1370
	// [ audio file to play ]
sl@0
  1371
	_LIT(KTestWavFileRecord, "TempW.wav");
sl@0
  1372
	SetWriteFileNameL( KTestWavFileRecord );
sl@0
  1373
 	
sl@0
  1374
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
  1375
	User::LeaveIfError( errorCode );
sl@0
  1376
sl@0
  1377
    RMMFAudioControllerCustomCommands theCommander( iController );
sl@0
  1378
sl@0
  1379
sl@0
  1380
	//[ add sink format when no sink exists ]
sl@0
  1381
	errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
sl@0
  1382
	if( errorCode == KErrNone )
sl@0
  1383
	   {
sl@0
  1384
	   result = EFail;
sl@0
  1385
	   return result;
sl@0
  1386
	   }
sl@0
  1387
sl@0
  1388
	//[ ok lets add the source and sink ]
sl@0
  1389
    errorCode = iController.AddDataSource(KUidMmfAudioInput, KNullDesC8);
sl@0
  1390
	User::LeaveIfError( errorCode );
sl@0
  1391
sl@0
  1392
    errorCode = iController.AddDataSink(KUidMmfFileSink, WriteFileConfig());
sl@0
  1393
	User::LeaveIfError( errorCode );
sl@0
  1394
	
sl@0
  1395
    errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
sl@0
  1396
    User::LeaveIfError( errorCode );
sl@0
  1397
sl@0
  1398
	// [ add the format where the uid == the uid of the format ]
sl@0
  1399
    errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
sl@0
  1400
    User::LeaveIfError( errorCode );
sl@0
  1401
sl@0
  1402
	//[ ok lets try to set the sink format to au]
sl@0
  1403
    errorCode = theCommander.SetSinkFormat( KFormatAUWrite );
sl@0
  1404
    User::LeaveIfError( errorCode );
sl@0
  1405
sl@0
  1406
    errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
sl@0
  1407
    User::LeaveIfError( errorCode );
sl@0
  1408
sl@0
  1409
	// [ wait for and process the return event from the audio output ]
sl@0
  1410
	errorCode =	iController.Prime();
sl@0
  1411
	User::LeaveIfError( errorCode );
sl@0
  1412
	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
sl@0
  1413
	result = SearchForEvent( primeEvent );
sl@0
  1414
	if( result == EFail )
sl@0
  1415
		{
sl@0
  1416
		return result;
sl@0
  1417
		}
sl@0
  1418
sl@0
  1419
    errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
sl@0
  1420
    if( errorCode == KErrNone )
sl@0
  1421
	   {
sl@0
  1422
	   result = EFail;
sl@0
  1423
	   return result;
sl@0
  1424
	   }
sl@0
  1425
	
sl@0
  1426
	//[ lets do some recording ]
sl@0
  1427
	// note this test does not wait around 
sl@0
  1428
	// to detect that the audio has been played
sl@0
  1429
	// [ now process the confirmation event that play has reached audio output
sl@0
  1430
	//   this is the raison detre of the test ]
sl@0
  1431
	errorCode =	iController.Play();
sl@0
  1432
    User::LeaveIfError( errorCode );
sl@0
  1433
	TMMFEvent playEvent( KPlayTestId, KErrNone );
sl@0
  1434
	result = SearchForEvent( playEvent );
sl@0
  1435
	if( result == EFail )
sl@0
  1436
		{
sl@0
  1437
		return result;
sl@0
  1438
		}
sl@0
  1439
sl@0
  1440
	// [ check that we cannot set the sink format when 
sl@0
  1441
	// no data sink has been added to the controller ]
sl@0
  1442
   errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
sl@0
  1443
   if( errorCode == KErrNone )
sl@0
  1444
	   {
sl@0
  1445
	   result = EFail;
sl@0
  1446
	   return result;
sl@0
  1447
	   }
sl@0
  1448
sl@0
  1449
	// [ lets wait a few seconds for record to write its data ]
sl@0
  1450
	RTimer  myTimer ;
sl@0
  1451
	User::LeaveIfError( myTimer.CreateLocal());
sl@0
  1452
	TRequestStatus timerStatus    ;
sl@0
  1453
    const TInt KDelay   = 1000000 ; // arbitrary delay
sl@0
  1454
	myTimer.After( timerStatus, KDelay );
sl@0
  1455
	User::WaitForRequest( timerStatus );
sl@0
  1456
sl@0
  1457
	//[ ensure the controller is unloaded so that it does 
sl@0
  1458
	// not interfere with the following test ]
sl@0
  1459
	// There is error in this code and the stop followed by reset
sl@0
  1460
	// ensure the controller resources are released.
sl@0
  1461
	iController.Stop();
sl@0
  1462
	iController.Reset();
sl@0
  1463
	iController.Close();  
sl@0
  1464
	
sl@0
  1465
	__MM_HEAP_MARKEND;
sl@0
  1466
	return result;
sl@0
  1467
	}
sl@0
  1468
sl@0
  1469
/**
sl@0
  1470
*
sl@0
  1471
* CTestStepGetSetSourceFormat
sl@0
  1472
*
sl@0
  1473
*/
sl@0
  1474
CTestStepGetSetSourceFormat::CTestStepGetSetSourceFormat()
sl@0
  1475
	{
sl@0
  1476
	iTestStepName = _L("MM-MMF-ACTRL-U-0024-HP");
sl@0
  1477
	}
sl@0
  1478
sl@0
  1479
/**
sl@0
  1480
*
sl@0
  1481
* CTestStepGetSetSourceFormat
sl@0
  1482
*
sl@0
  1483
*/
sl@0
  1484
CTestStepGetSetSourceFormat::~CTestStepGetSetSourceFormat()
sl@0
  1485
	{
sl@0
  1486
	}
sl@0
  1487
sl@0
  1488
/**
sl@0
  1489
*
sl@0
  1490
* DoTestStepL
sl@0
  1491
*
sl@0
  1492
*/
sl@0
  1493
TVerdict CTestStepGetSetSourceFormat::DoTestStepL( void )
sl@0
  1494
	{
sl@0
  1495
	__MM_HEAP_MARK;
sl@0
  1496
	TVerdict result = EPass;
sl@0
  1497
	
sl@0
  1498
	_LIT( KTestSourceNumChannels, "Test Step GetSet Source Format");
sl@0
  1499
	Log( KTestSourceNumChannels);
sl@0
  1500
	
sl@0
  1501
	_LIT( KTestSinkBitRateReason, "This test checks the set/get source format");
sl@0
  1502
	Log( KTestSinkBitRateReason );
sl@0
  1503
	
sl@0
  1504
	// [ audio file to play ]
sl@0
  1505
	_LIT(KTestWavFile, "newmail.wav");
sl@0
  1506
	SetReadFileNameL( KTestWavFile );
sl@0
  1507
   	
sl@0
  1508
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
  1509
	User::LeaveIfError( errorCode );
sl@0
  1510
sl@0
  1511
    RMMFAudioControllerCustomCommands theCommander( iController );
sl@0
  1512
sl@0
  1513
	//[ add source format when no source exists ]
sl@0
  1514
	errorCode = theCommander.SetSourceFormat( KFormatWAVRead );
sl@0
  1515
	if( errorCode == KErrNone )
sl@0
  1516
	   {
sl@0
  1517
	   result = EFail;
sl@0
  1518
	   return result;
sl@0
  1519
	   }
sl@0
  1520
sl@0
  1521
	//[ ok lets add the source and sink ]
sl@0
  1522
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
  1523
	User::LeaveIfError( errorCode );
sl@0
  1524
sl@0
  1525
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
  1526
    User::LeaveIfError( errorCode );
sl@0
  1527
	
sl@0
  1528
	//errorCode = theCommander.SetSourceFormat( KWavUid );
sl@0
  1529
	errorCode = theCommander.SetSourceFormat( KFormatWAVRead );
sl@0
  1530
	User::LeaveIfError( errorCode );
sl@0
  1531
sl@0
  1532
	// [ add the format where the uid == the uid of the format ]
sl@0
  1533
	errorCode = theCommander.SetSourceFormat(  KFormatWAVRead );
sl@0
  1534
	User::LeaveIfError( errorCode );
sl@0
  1535
sl@0
  1536
	//[ ok lets try to set the source format to raw]
sl@0
  1537
	errorCode = theCommander.SetSourceFormat(KFormatRAWRead);
sl@0
  1538
	User::LeaveIfError( errorCode );
sl@0
  1539
sl@0
  1540
	// [ add the format where the uid == the uid of the format ]
sl@0
  1541
	errorCode = theCommander.SetSourceFormat( KFormatWAVRead );
sl@0
  1542
	User::LeaveIfError( errorCode );
sl@0
  1543
sl@0
  1544
sl@0
  1545
	// [ wait for and process the return event from the audio output ]
sl@0
  1546
	errorCode =	iController.Prime();
sl@0
  1547
	User::LeaveIfError( errorCode );
sl@0
  1548
	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
sl@0
  1549
	result = SearchForEvent( primeEvent );
sl@0
  1550
	if( result == EFail )
sl@0
  1551
		{
sl@0
  1552
		return result;
sl@0
  1553
		}
sl@0
  1554
sl@0
  1555
	// [ check that we cannot set the sink format when 
sl@0
  1556
	// no data sink has been added to the controller ]
sl@0
  1557
   errorCode = theCommander.SetSourceFormat( KFormatWAVRead );
sl@0
  1558
   if( errorCode == KErrNone )
sl@0
  1559
	   {
sl@0
  1560
	   result = EFail;
sl@0
  1561
	   return result;
sl@0
  1562
	   }
sl@0
  1563
	
sl@0
  1564
	// [ lets do some recording ]
sl@0
  1565
	// note this test does not wait around 
sl@0
  1566
	// to detect that the audio has been played
sl@0
  1567
	// [ now process the confirmation event that play has reached audio output
sl@0
  1568
	// this is the raison detre of the test ]
sl@0
  1569
	errorCode =	iController.Play();
sl@0
  1570
    User::LeaveIfError( errorCode );
sl@0
  1571
	TMMFEvent playEvent( KPlayTestId, KErrNone );
sl@0
  1572
	result = SearchForEvent( playEvent );
sl@0
  1573
	if( result == EFail )
sl@0
  1574
		{
sl@0
  1575
		return result;
sl@0
  1576
		}
sl@0
  1577
sl@0
  1578
sl@0
  1579
	// [ check that we cannot set the sink format when 
sl@0
  1580
	// no data sink has been added to the controller ]
sl@0
  1581
   errorCode = theCommander.SetSourceFormat( KFormatWAVRead );
sl@0
  1582
   if( errorCode == KErrNone )
sl@0
  1583
	   {
sl@0
  1584
	   result = EFail;
sl@0
  1585
	   return result;
sl@0
  1586
	   }
sl@0
  1587
sl@0
  1588
	// [ lets wait a few seconds for record to write its data ]
sl@0
  1589
	RTimer  myTimer ;
sl@0
  1590
	User::LeaveIfError( myTimer.CreateLocal());
sl@0
  1591
	TRequestStatus timerStatus    ;
sl@0
  1592
    const TInt KDelay   = 1000000 ; // arbitrary delay
sl@0
  1593
	myTimer.After( timerStatus, KDelay );
sl@0
  1594
	User::WaitForRequest( timerStatus );
sl@0
  1595
sl@0
  1596
	//[ ensure the controller is unloaded so that it does 
sl@0
  1597
	// not interfere with the following test ]
sl@0
  1598
	// There is error in this code and the stop followed by reset
sl@0
  1599
	// ensure the controller resources are released.
sl@0
  1600
	iController.Stop();
sl@0
  1601
	iController.Reset();
sl@0
  1602
	iController.Close();  
sl@0
  1603
	
sl@0
  1604
	__MM_HEAP_MARKEND;
sl@0
  1605
	return result;
sl@0
  1606
	}
sl@0
  1607
sl@0
  1608
/**
sl@0
  1609
*
sl@0
  1610
* CTestStepGetSetSourceSampleRate
sl@0
  1611
*
sl@0
  1612
*/
sl@0
  1613
CTestStepGetSetSourceSampleRate::CTestStepGetSetSourceSampleRate()
sl@0
  1614
	{
sl@0
  1615
	iTestStepName = _L("MM-MMF-ACTRL-U-0025-HP");
sl@0
  1616
	}
sl@0
  1617
sl@0
  1618
/**
sl@0
  1619
*
sl@0
  1620
* ~CTestStepGetSetSourceSampleRate
sl@0
  1621
*
sl@0
  1622
*/
sl@0
  1623
CTestStepGetSetSourceSampleRate::~CTestStepGetSetSourceSampleRate()
sl@0
  1624
	{
sl@0
  1625
	}
sl@0
  1626
sl@0
  1627
/**
sl@0
  1628
*
sl@0
  1629
* CTestStepGetSetSourceSampleRate
sl@0
  1630
*
sl@0
  1631
*/
sl@0
  1632
TVerdict  CTestStepGetSetSourceSampleRate::DoTestStepL( void )
sl@0
  1633
	{
sl@0
  1634
	__MM_HEAP_MARK;
sl@0
  1635
	TVerdict result = EPass;
sl@0
  1636
	
sl@0
  1637
	_LIT( KTestSourceNumChannels, "GetSet Source Sample Rate");
sl@0
  1638
	Log( KTestSourceNumChannels);
sl@0
  1639
	
sl@0
  1640
	_LIT( KTestSinkBitRateReason, "This test checks the set/get source sample rate");
sl@0
  1641
	Log( KTestSinkBitRateReason );
sl@0
  1642
	
sl@0
  1643
	// [ audio file to play ]
sl@0
  1644
	_LIT(KTestWavFile, "newmail.wav");
sl@0
  1645
	SetReadFileNameL( KTestWavFile );
sl@0
  1646
   	
sl@0
  1647
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
  1648
	User::LeaveIfError( errorCode );
sl@0
  1649
sl@0
  1650
	//[ attempt to get the sink num channels ]
sl@0
  1651
    RMMFAudioControllerCustomCommands theCommander( iController );
sl@0
  1652
sl@0
  1653
	RArray<TUint> supportedRates;
sl@0
  1654
	CleanupClosePushL(supportedRates);
sl@0
  1655
	TRAPD(errorCode2, theCommander.GetSupportedSourceSampleRatesL(supportedRates));
sl@0
  1656
	if ((errorCode2 == KErrNone ) || supportedRates.Count())
sl@0
  1657
		{
sl@0
  1658
		// should have failed with either an error code or non zero supported rates
sl@0
  1659
		result = EFail;
sl@0
  1660
		return result;
sl@0
  1661
		}
sl@0
  1662
sl@0
  1663
	TUint theRate = 0;
sl@0
  1664
	errorCode = theCommander.GetSourceSampleRate(theRate);
sl@0
  1665
	if( errorCode == KErrNone )
sl@0
  1666
		{
sl@0
  1667
		result = EFail;
sl@0
  1668
		return result;
sl@0
  1669
		}
sl@0
  1670
sl@0
  1671
	//[ ok lets add the source and sink ]
sl@0
  1672
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
  1673
	User::LeaveIfError( errorCode );
sl@0
  1674
sl@0
  1675
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
  1676
    User::LeaveIfError( errorCode );
sl@0
  1677
sl@0
  1678
	// Store the original sample rate
sl@0
  1679
	TUint origRate = 0;
sl@0
  1680
	errorCode = theCommander.GetSourceSampleRate(origRate);
sl@0
  1681
	if (errorCode != KErrNone)
sl@0
  1682
		{
sl@0
  1683
		INFO_PRINTF2(_L("Error getting original source sample rate %d"), errorCode);
sl@0
  1684
		return EFail;
sl@0
  1685
		}
sl@0
  1686
sl@0
  1687
	// Ensure the array is empty
sl@0
  1688
	supportedRates.Reset();
sl@0
  1689
	TRAPD( errorCode3,theCommander.GetSupportedSourceSampleRatesL(supportedRates));
sl@0
  1690
	User::LeaveIfError( errorCode3 );
sl@0
  1691
sl@0
  1692
	TUint theNewRate = 0;
sl@0
  1693
sl@0
  1694
	for (TInt index = 0; index < supportedRates.Count(); index++)
sl@0
  1695
		{
sl@0
  1696
		theRate = supportedRates[index];
sl@0
  1697
		// SetSourceSampleRate
sl@0
  1698
		errorCode = theCommander.SetSourceSampleRate(theRate);
sl@0
  1699
		if (theRate == origRate)
sl@0
  1700
			{
sl@0
  1701
			if (errorCode != KErrNone)
sl@0
  1702
				{
sl@0
  1703
				INFO_PRINTF2(_L("SetSourceSampleRate returned unexpected error %d"), errorCode);
sl@0
  1704
				result = EFail;
sl@0
  1705
				break;
sl@0
  1706
				}
sl@0
  1707
			}
sl@0
  1708
		else
sl@0
  1709
			{
sl@0
  1710
			// Setting source sample rate to a different value 
sl@0
  1711
			// is tolerated (INC038043) to preserve BC with 6.1
sl@0
  1712
			if (errorCode != KErrNone)
sl@0
  1713
				{
sl@0
  1714
				INFO_PRINTF3(_L("SetSourceDataType returned %d, expecting %d"), errorCode, KErrAlreadyExists);
sl@0
  1715
				result = EFail;
sl@0
  1716
				break;
sl@0
  1717
				}
sl@0
  1718
			}
sl@0
  1719
		// GetSourceSampleRate
sl@0
  1720
		errorCode = theCommander.GetSourceSampleRate(theNewRate);
sl@0
  1721
		if (theNewRate != origRate)
sl@0
  1722
			{
sl@0
  1723
			INFO_PRINTF3(_L("GetSourceSampleRate rate %d did not match expected %d"), theNewRate, origRate);
sl@0
  1724
			result = EFail;
sl@0
  1725
			break;
sl@0
  1726
			}
sl@0
  1727
sl@0
  1728
		if (errorCode != KErrNone)
sl@0
  1729
			{
sl@0
  1730
			INFO_PRINTF3(_L("GetSourceSampleRate returned unexpected error %d, expected %d"), errorCode, KErrNone);
sl@0
  1731
			result = EFail;
sl@0
  1732
			break;
sl@0
  1733
			}
sl@0
  1734
		}
sl@0
  1735
sl@0
  1736
	CleanupStack::PopAndDestroy(1);		// supportedRates
sl@0
  1737
	
sl@0
  1738
	//[ ensure the controller is unloaded so that it does 
sl@0
  1739
	// not interfere with the following test ]
sl@0
  1740
	// There is error in this code and the stop followed by reset
sl@0
  1741
	// ensure the controller resources are released.
sl@0
  1742
	iController.Stop();
sl@0
  1743
	iController.Reset();
sl@0
  1744
	iController.Close();  
sl@0
  1745
	
sl@0
  1746
	__MM_HEAP_MARKEND;
sl@0
  1747
	return result ;	
sl@0
  1748
	}
sl@0
  1749
sl@0
  1750
/**
sl@0
  1751
*
sl@0
  1752
* CTestStepGetSetSinkSampleRate
sl@0
  1753
*
sl@0
  1754
*/
sl@0
  1755
CTestStepGetSetSinkSampleRate::CTestStepGetSetSinkSampleRate()
sl@0
  1756
	{
sl@0
  1757
	iTestStepName = _L("MM-MMF-ACTRL-U-0026-HP");
sl@0
  1758
	}
sl@0
  1759
sl@0
  1760
/**
sl@0
  1761
*
sl@0
  1762
* ~CTestStepGetSetSinkSampleRate
sl@0
  1763
*
sl@0
  1764
*/
sl@0
  1765
CTestStepGetSetSinkSampleRate::~CTestStepGetSetSinkSampleRate()
sl@0
  1766
	{
sl@0
  1767
	}
sl@0
  1768
sl@0
  1769
/**
sl@0
  1770
*
sl@0
  1771
* DoTestStepL
sl@0
  1772
*
sl@0
  1773
*/
sl@0
  1774
TVerdict  CTestStepGetSetSinkSampleRate::DoTestStepL( void )
sl@0
  1775
	{
sl@0
  1776
	__MM_HEAP_MARK;
sl@0
  1777
	TVerdict result = EPass;
sl@0
  1778
	
sl@0
  1779
	_LIT( KTestSourceNumChannels, "GetSet Sink Sample Rate");
sl@0
  1780
	Log( KTestSourceNumChannels);
sl@0
  1781
	
sl@0
  1782
	_LIT( KTestSinkBitRateReason, "This test checks the set/get sink sample rate");
sl@0
  1783
	Log( KTestSinkBitRateReason );
sl@0
  1784
	
sl@0
  1785
	// [ audio file to play ]
sl@0
  1786
	_LIT(KTestWavFile, "newmail.wav");
sl@0
  1787
	SetReadFileNameL( KTestWavFile );
sl@0
  1788
   	
sl@0
  1789
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
  1790
	User::LeaveIfError( errorCode );
sl@0
  1791
sl@0
  1792
	//[ attempt to get the sink num channels ]
sl@0
  1793
    RMMFAudioControllerCustomCommands theCommander( iController );
sl@0
  1794
	
sl@0
  1795
	TUint theRate = 0;
sl@0
  1796
	errorCode = theCommander.GetSinkSampleRate(theRate);
sl@0
  1797
	if( errorCode == KErrNone )
sl@0
  1798
		{
sl@0
  1799
		result = EFail;
sl@0
  1800
		}
sl@0
  1801
sl@0
  1802
	//[ ok lets add the source and sink ]
sl@0
  1803
    if(result==EPass)
sl@0
  1804
    	{
sl@0
  1805
    	errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
  1806
    	if(errorCode!=KErrNone)
sl@0
  1807
    		{
sl@0
  1808
    		result=EFail;
sl@0
  1809
    		}
sl@0
  1810
    	}
sl@0
  1811
    
sl@0
  1812
    if(result==EPass)
sl@0
  1813
    	{
sl@0
  1814
		errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
  1815
    	if(errorCode!=KErrNone)
sl@0
  1816
    		{
sl@0
  1817
    		result=EFail;
sl@0
  1818
    		}
sl@0
  1819
    	}
sl@0
  1820
	
sl@0
  1821
	if(result==EPass)
sl@0
  1822
		{
sl@0
  1823
		theRate = 0;
sl@0
  1824
		errorCode = theCommander.GetSinkSampleRate(theRate);
sl@0
  1825
	    if(errorCode!=KErrNotSupported)
sl@0
  1826
	    	{
sl@0
  1827
	    	INFO_PRINTF2(_L("GetSinkSampleRate returned %d when KErrNotSupported is expected"), errorCode);
sl@0
  1828
	    	result = EFail;
sl@0
  1829
	    	}
sl@0
  1830
		}
sl@0
  1831
	
sl@0
  1832
	if(result==EPass)
sl@0
  1833
		{
sl@0
  1834
		//[ set the sample rate ]
sl@0
  1835
		errorCode = theCommander.SetSinkSampleRate(theRate);
sl@0
  1836
		if(errorCode!=KErrNotSupported)
sl@0
  1837
	    	{
sl@0
  1838
	    	INFO_PRINTF2(_L("SetSinkSampleRate returned %d when KErrNotSupported is expected"), errorCode);
sl@0
  1839
	    	result = EFail;
sl@0
  1840
	    	}
sl@0
  1841
		}
sl@0
  1842
	
sl@0
  1843
	if(result==EPass)
sl@0
  1844
		{
sl@0
  1845
		TUint theSampleRate( 8000); // set sample rate to 8khz arbitrary value
sl@0
  1846
		//[ set the sample rate ]
sl@0
  1847
		theRate = theSampleRate; // known reasonable value
sl@0
  1848
		errorCode = theCommander.SetSinkSampleRate(theRate);
sl@0
  1849
		if(errorCode!=KErrNotSupported)
sl@0
  1850
	    	{
sl@0
  1851
	    	INFO_PRINTF2(_L("SetSinkSampleRate returned %d when KErrNotSupported is expected"), errorCode);
sl@0
  1852
	    	result = EFail;
sl@0
  1853
	    	}
sl@0
  1854
		}
sl@0
  1855
	
sl@0
  1856
	if(result==EPass)
sl@0
  1857
		{
sl@0
  1858
		theRate = 0;
sl@0
  1859
		errorCode = theCommander.GetSinkSampleRate(theRate);
sl@0
  1860
	    if(errorCode!=KErrNotSupported)
sl@0
  1861
	    	{
sl@0
  1862
	    	INFO_PRINTF2(_L("GetSinkSampleRate returned %d when KErrNotSupported is expected"), errorCode);
sl@0
  1863
	    	result = EFail;
sl@0
  1864
	    	}
sl@0
  1865
		}
sl@0
  1866
    
sl@0
  1867
	//[ ensure the controller is unloaded so that it does 
sl@0
  1868
	// not interfere with the following test ]
sl@0
  1869
	// There is error in this code and the stop followed by reset
sl@0
  1870
	// ensure the controller resources are released.
sl@0
  1871
	iController.Stop();
sl@0
  1872
	iController.Reset();
sl@0
  1873
	iController.Close();  
sl@0
  1874
	
sl@0
  1875
	__MM_HEAP_MARKEND;
sl@0
  1876
	return result;
sl@0
  1877
	}
sl@0
  1878
sl@0
  1879
/**
sl@0
  1880
*
sl@0
  1881
* CTestStepGetSetSourceBitRate
sl@0
  1882
*
sl@0
  1883
*/
sl@0
  1884
CTestStepGetSetSourceBitRate::CTestStepGetSetSourceBitRate()
sl@0
  1885
	{
sl@0
  1886
	iTestStepName = _L("MM-MMF-ACTRL-U-0027-HP");
sl@0
  1887
	}
sl@0
  1888
sl@0
  1889
/**
sl@0
  1890
*
sl@0
  1891
* ~CTestStepGetSetSourceBitRate
sl@0
  1892
*
sl@0
  1893
*/
sl@0
  1894
CTestStepGetSetSourceBitRate::~CTestStepGetSetSourceBitRate()
sl@0
  1895
	{
sl@0
  1896
	}
sl@0
  1897
sl@0
  1898
/**
sl@0
  1899
*
sl@0
  1900
* DoTestStepL
sl@0
  1901
*
sl@0
  1902
*/
sl@0
  1903
TVerdict CTestStepGetSetSourceBitRate::DoTestStepL( void )
sl@0
  1904
	{
sl@0
  1905
	__MM_HEAP_MARK;
sl@0
  1906
	TVerdict result = EPass;
sl@0
  1907
	
sl@0
  1908
	_LIT( KTestSourceNumChannels, "GetSet Source Bit Rate");
sl@0
  1909
	Log( KTestSourceNumChannels);
sl@0
  1910
	
sl@0
  1911
	_LIT( KTestSinkBitRateReason, "This test checks the set/get source bit rate");
sl@0
  1912
	Log( KTestSinkBitRateReason );
sl@0
  1913
	
sl@0
  1914
	// [ audio file to play ]
sl@0
  1915
	_LIT(KTestWavFile, "newmail.wav");
sl@0
  1916
	SetReadFileNameL( KTestWavFile );
sl@0
  1917
   	
sl@0
  1918
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
  1919
	User::LeaveIfError( errorCode );
sl@0
  1920
sl@0
  1921
	//[ attempt to get the sink num channels ]
sl@0
  1922
    RMMFAudioControllerCustomCommands theCommander( iController );
sl@0
  1923
sl@0
  1924
	TUint theRate = 0;
sl@0
  1925
	errorCode = theCommander.GetSourceBitRate(theRate);
sl@0
  1926
	if( errorCode == KErrNone )
sl@0
  1927
		{
sl@0
  1928
		result = EFail;
sl@0
  1929
		return result;
sl@0
  1930
		}
sl@0
  1931
sl@0
  1932
	//[ ok lets add the source and sink ]
sl@0
  1933
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
  1934
	User::LeaveIfError( errorCode );
sl@0
  1935
sl@0
  1936
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
  1937
    User::LeaveIfError( errorCode );
sl@0
  1938
sl@0
  1939
	theRate = 0;
sl@0
  1940
	errorCode = theCommander.GetSourceBitRate(theRate);
sl@0
  1941
    User::LeaveIfError( errorCode );
sl@0
  1942
sl@0
  1943
	// check to see if the bitrate is greater than zero
sl@0
  1944
	// (it should exactly be samplerate*bitspersample)
sl@0
  1945
	if (theRate == 0)
sl@0
  1946
		{
sl@0
  1947
		result = EFail;
sl@0
  1948
		return result;
sl@0
  1949
		}
sl@0
  1950
sl@0
  1951
	//[ this is currently not supported ]
sl@0
  1952
	errorCode = theCommander.SetSourceBitRate(theRate);
sl@0
  1953
	if( errorCode == KErrNone )
sl@0
  1954
	{
sl@0
  1955
	result = EFail;
sl@0
  1956
	return result;
sl@0
  1957
	}
sl@0
  1958
sl@0
  1959
	//[ ensure the controller is unloaded so that it does 
sl@0
  1960
	// not interfere with the following test ]
sl@0
  1961
	// There is error in this code and the stop followed by reset
sl@0
  1962
	// ensure the controller resources are released.
sl@0
  1963
	iController.Stop();
sl@0
  1964
	iController.Reset();
sl@0
  1965
	iController.Close();  
sl@0
  1966
	
sl@0
  1967
	__MM_HEAP_MARKEND;
sl@0
  1968
	return result;
sl@0
  1969
	}
sl@0
  1970
sl@0
  1971
/**
sl@0
  1972
*
sl@0
  1973
* CTestStepGetSetSourceDataType
sl@0
  1974
*
sl@0
  1975
*/
sl@0
  1976
CTestStepGetSetSourceDataType::CTestStepGetSetSourceDataType()
sl@0
  1977
	{
sl@0
  1978
	iTestStepName = _L("MM-MMF-ACTRL-U-0028-HP");
sl@0
  1979
	}
sl@0
  1980
sl@0
  1981
/**
sl@0
  1982
*
sl@0
  1983
* ~CTestStepGetSetSourceDataType
sl@0
  1984
*
sl@0
  1985
*/
sl@0
  1986
CTestStepGetSetSourceDataType::~CTestStepGetSetSourceDataType()
sl@0
  1987
	{
sl@0
  1988
	}
sl@0
  1989
sl@0
  1990
/**
sl@0
  1991
*
sl@0
  1992
* DoTestStepL
sl@0
  1993
*
sl@0
  1994
*/
sl@0
  1995
TVerdict  CTestStepGetSetSourceDataType::DoTestStepL( void )
sl@0
  1996
	{
sl@0
  1997
	__MM_HEAP_MARK;
sl@0
  1998
	TVerdict result = EPass;
sl@0
  1999
	
sl@0
  2000
	_LIT( KTestSourceNumChannels, "GetSet Source Data type");
sl@0
  2001
	Log( KTestSourceNumChannels);
sl@0
  2002
	
sl@0
  2003
	_LIT( KTestSinkBitRateReason, "This test checks the set/get source data type");
sl@0
  2004
	Log( KTestSinkBitRateReason );
sl@0
  2005
	
sl@0
  2006
	// [ audio file to play ]
sl@0
  2007
	_LIT(KTestWavFile, "newmail.wav");
sl@0
  2008
	SetReadFileNameL( KTestWavFile );
sl@0
  2009
   	
sl@0
  2010
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
  2011
	User::LeaveIfError( errorCode );
sl@0
  2012
sl@0
  2013
	//[ attempt to get the sink num channels ]
sl@0
  2014
    RMMFAudioControllerCustomCommands theCommander( iController );
sl@0
  2015
sl@0
  2016
	TFourCC theFCC;
sl@0
  2017
	errorCode = theCommander.GetSourceDataType( theFCC );
sl@0
  2018
	if( errorCode == KErrNone )
sl@0
  2019
		{
sl@0
  2020
		result = EFail;
sl@0
  2021
		return result;
sl@0
  2022
		}
sl@0
  2023
sl@0
  2024
	//[ ok lets add the source and sink ]
sl@0
  2025
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
  2026
	User::LeaveIfError( errorCode );
sl@0
  2027
sl@0
  2028
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
  2029
    User::LeaveIfError( errorCode );
sl@0
  2030
sl@0
  2031
	errorCode = theCommander.GetSourceDataType( theFCC );
sl@0
  2032
	User::LeaveIfError( errorCode );
sl@0
  2033
sl@0
  2034
	TFourCC theNewFCC;
sl@0
  2035
	errorCode = theCommander.SetSourceDataType( theFCC );
sl@0
  2036
	User::LeaveIfError( errorCode );
sl@0
  2037
sl@0
  2038
	errorCode = theCommander.GetSourceDataType( theNewFCC );
sl@0
  2039
	User::LeaveIfError( errorCode );
sl@0
  2040
sl@0
  2041
	if( theNewFCC != theFCC )
sl@0
  2042
		{
sl@0
  2043
		result = EFail;
sl@0
  2044
		}
sl@0
  2045
sl@0
  2046
	//[ ensure the controller is unloaded so that it does 
sl@0
  2047
	// not interfere with the following test ]
sl@0
  2048
	// There is error in this code and the stop followed by reset
sl@0
  2049
	// ensure the controller resources are released.
sl@0
  2050
	iController.Stop();
sl@0
  2051
	iController.Reset();
sl@0
  2052
	iController.Close();  
sl@0
  2053
	
sl@0
  2054
	__MM_HEAP_MARKEND;
sl@0
  2055
	return result;
sl@0
  2056
	}
sl@0
  2057
sl@0
  2058
/**
sl@0
  2059
*
sl@0
  2060
* CTestStepGetSetSinkDataType
sl@0
  2061
*
sl@0
  2062
*/
sl@0
  2063
CTestStepGetSetSinkDataType::CTestStepGetSetSinkDataType()
sl@0
  2064
	{
sl@0
  2065
	iTestStepName = _L("MM-MMF-ACTRL-U-0029-HP");
sl@0
  2066
	}
sl@0
  2067
sl@0
  2068
/**
sl@0
  2069
*
sl@0
  2070
* ~CTestStepGetSetSinkDataType
sl@0
  2071
*
sl@0
  2072
*/
sl@0
  2073
CTestStepGetSetSinkDataType::~CTestStepGetSetSinkDataType()
sl@0
  2074
	{
sl@0
  2075
	}
sl@0
  2076
sl@0
  2077
/**
sl@0
  2078
*
sl@0
  2079
* DoTestStepL
sl@0
  2080
*
sl@0
  2081
*/
sl@0
  2082
TVerdict CTestStepGetSetSinkDataType::DoTestStepL( void )
sl@0
  2083
	{
sl@0
  2084
	__MM_HEAP_MARK;
sl@0
  2085
	TVerdict result = EPass;
sl@0
  2086
	
sl@0
  2087
	_LIT( KTestSourceNumChannels, "GetSet Sink Data type");
sl@0
  2088
	Log( KTestSourceNumChannels);
sl@0
  2089
	
sl@0
  2090
	_LIT( KTestSinkBitRateReason, "This test checks the set/get sink data type");
sl@0
  2091
	Log( KTestSinkBitRateReason );
sl@0
  2092
	
sl@0
  2093
	// [ audio file to play ]
sl@0
  2094
	_LIT(KTestWavFile, "newmail.wav");
sl@0
  2095
	SetReadFileNameL( KTestWavFile );
sl@0
  2096
   	
sl@0
  2097
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
  2098
	User::LeaveIfError( errorCode );
sl@0
  2099
sl@0
  2100
	//[ attempt to get the sink num channels ]
sl@0
  2101
    RMMFAudioControllerCustomCommands theCommander( iController );
sl@0
  2102
	
sl@0
  2103
	TFourCC theFCC;
sl@0
  2104
	errorCode = theCommander.GetSinkDataType( theFCC );
sl@0
  2105
	if( errorCode == KErrNone )
sl@0
  2106
		{
sl@0
  2107
		result = EFail;
sl@0
  2108
		}
sl@0
  2109
sl@0
  2110
	//[ ok lets add the source and sink ]
sl@0
  2111
    if(result==EPass)
sl@0
  2112
    	{
sl@0
  2113
    	errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
  2114
    	if(errorCode!=KErrNone)
sl@0
  2115
    		{
sl@0
  2116
    		result=EFail;
sl@0
  2117
    		}
sl@0
  2118
    	}
sl@0
  2119
    
sl@0
  2120
    if(result==EPass)
sl@0
  2121
    	{
sl@0
  2122
		errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
  2123
    	if(errorCode!=KErrNone)
sl@0
  2124
    		{
sl@0
  2125
    		result=EFail;
sl@0
  2126
    		}
sl@0
  2127
    	}
sl@0
  2128
    	
sl@0
  2129
	if(result==EPass)
sl@0
  2130
		{
sl@0
  2131
		errorCode = theCommander.GetSinkDataType( theFCC );
sl@0
  2132
		if(errorCode!=KErrNotSupported)
sl@0
  2133
	    	{
sl@0
  2134
	    	INFO_PRINTF2(_L("GetSinkDataType returned %d when KErrNotSupported is expected"), errorCode);
sl@0
  2135
	    	result = EFail;
sl@0
  2136
	    	}
sl@0
  2137
		}
sl@0
  2138
	
sl@0
  2139
	if(result==EPass)
sl@0
  2140
		{
sl@0
  2141
		errorCode = theCommander.SetSinkDataType( theFCC );
sl@0
  2142
		if(errorCode!=KErrNotSupported)
sl@0
  2143
	    	{
sl@0
  2144
	    	INFO_PRINTF2(_L("SetSinkDataType returned %d when KErrNotSupported is expected"), errorCode);
sl@0
  2145
	    	result = EFail;
sl@0
  2146
	    	}
sl@0
  2147
		}
sl@0
  2148
	
sl@0
  2149
	if(result==EPass)
sl@0
  2150
		{
sl@0
  2151
		TFourCC theNewFCC;
sl@0
  2152
		errorCode = theCommander.GetSinkDataType( theNewFCC );
sl@0
  2153
		if(errorCode!=KErrNotSupported)
sl@0
  2154
	    	{
sl@0
  2155
	    	INFO_PRINTF2(_L("GetSinkDataType returned %d when KErrNotSupported is expected"), errorCode);
sl@0
  2156
	    	result = EFail;
sl@0
  2157
	    	}
sl@0
  2158
		}
sl@0
  2159
sl@0
  2160
	//[ ensure the controller is unloaded so that it does 
sl@0
  2161
	// not interfere with the following test ]
sl@0
  2162
	// There is error in this code and the stop followed by reset
sl@0
  2163
	// ensure the controller resources are released.
sl@0
  2164
	iController.Stop();
sl@0
  2165
	iController.Reset();
sl@0
  2166
	iController.Close();  
sl@0
  2167
	
sl@0
  2168
	__MM_HEAP_MARKEND;
sl@0
  2169
	return result;
sl@0
  2170
	}
sl@0
  2171
sl@0
  2172
/**
sl@0
  2173
*
sl@0
  2174
* CTestStepGetSetSinkBitRate
sl@0
  2175
*
sl@0
  2176
*/
sl@0
  2177
sl@0
  2178
CTestStepGetSetSinkBitRate::CTestStepGetSetSinkBitRate()
sl@0
  2179
	{
sl@0
  2180
	iTestStepName = _L("MM-MMF-ACTRL-U-0030-HP");
sl@0
  2181
	}
sl@0
  2182
sl@0
  2183
/**
sl@0
  2184
*
sl@0
  2185
* ~CTestStepGetSetSinkDataType
sl@0
  2186
*
sl@0
  2187
*/
sl@0
  2188
sl@0
  2189
CTestStepGetSetSinkBitRate::~CTestStepGetSetSinkBitRate()
sl@0
  2190
	{
sl@0
  2191
	}
sl@0
  2192
sl@0
  2193
/**
sl@0
  2194
*
sl@0
  2195
* DoTestStepL
sl@0
  2196
*
sl@0
  2197
*/
sl@0
  2198
sl@0
  2199
TVerdict CTestStepGetSetSinkBitRate::DoTestStepL( void )
sl@0
  2200
	{
sl@0
  2201
	__MM_HEAP_MARK;
sl@0
  2202
	TVerdict result = EPass;
sl@0
  2203
	
sl@0
  2204
	_LIT( KTestSourceNumChannels, "GetSetSinkBitRate");
sl@0
  2205
	Log( KTestSourceNumChannels);
sl@0
  2206
	
sl@0
  2207
	_LIT( KTestSinkBitRateReason, "This test checks setting and getting a sinks bit rate");
sl@0
  2208
	Log( KTestSinkBitRateReason );
sl@0
  2209
	
sl@0
  2210
	// [ audio file to play ]
sl@0
  2211
	_LIT(KTestWavFile, "newmail.wav");
sl@0
  2212
	SetReadFileNameL( KTestWavFile );
sl@0
  2213
   	
sl@0
  2214
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
  2215
	User::LeaveIfError( errorCode );
sl@0
  2216
sl@0
  2217
	// [ attempt to get the bit rate with out a sink]
sl@0
  2218
    RMMFAudioControllerCustomCommands theCommander( iController );
sl@0
  2219
sl@0
  2220
	TUint theRate = 0;
sl@0
  2221
	errorCode = theCommander.GetSinkBitRate(theRate);
sl@0
  2222
	if( errorCode == KErrNone )
sl@0
  2223
		{
sl@0
  2224
		result = EFail;
sl@0
  2225
		return result;
sl@0
  2226
		}
sl@0
  2227
sl@0
  2228
	//[ add data source and sink and prime the controller ]
sl@0
  2229
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
  2230
	User::LeaveIfError( errorCode );
sl@0
  2231
	
sl@0
  2232
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
  2233
    User::LeaveIfError( errorCode );
sl@0
  2234
sl@0
  2235
	errorCode = theCommander.GetSinkBitRate(theRate);
sl@0
  2236
	if( errorCode == KErrNone )
sl@0
  2237
		{
sl@0
  2238
		result = EFail;
sl@0
  2239
		return result;
sl@0
  2240
		}
sl@0
  2241
	
sl@0
  2242
	errorCode =	iController.Prime();
sl@0
  2243
	User::LeaveIfError( errorCode );
sl@0
  2244
sl@0
  2245
	// [ wait for and process the return event from the audio output ]
sl@0
  2246
	
sl@0
  2247
	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
sl@0
  2248
	result = SearchForEvent( primeEvent );
sl@0
  2249
	if( result == EFail )
sl@0
  2250
		{
sl@0
  2251
		return result;
sl@0
  2252
		}
sl@0
  2253
sl@0
  2254
	//[ check when we are primed ]
sl@0
  2255
	errorCode = theCommander.GetSinkBitRate(theRate);
sl@0
  2256
	if( errorCode == KErrNone )
sl@0
  2257
		{
sl@0
  2258
		result = EFail;
sl@0
  2259
		return result;
sl@0
  2260
		}
sl@0
  2261
   
sl@0
  2262
	// [ lets reset and add a data sink and source that will
sl@0
  2263
	//   exercise the happy day scenario ]
sl@0
  2264
	errorCode =	iController.Reset();
sl@0
  2265
	User::LeaveIfError( errorCode );
sl@0
  2266
sl@0
  2267
	// [ check when recording ]
sl@0
  2268
	_LIT(KTestWavFileRecord, "16bitmpcm.wav");
sl@0
  2269
	
sl@0
  2270
   	SetReadFileNameL( KTestWavFileRecord );
sl@0
  2271
   	// check if record file already exists
sl@0
  2272
   	TEntry fileEntry;
sl@0
  2273
   	TInt fileErr = iFs.Entry(ReadFileConfig()().iPath, fileEntry);
sl@0
  2274
   	if (fileErr != KErrNotFound)
sl@0
  2275
   		{
sl@0
  2276
   		User::LeaveIfError(fileErr);
sl@0
  2277
   		}
sl@0
  2278
sl@0
  2279
	//[ add data source and sink and prime the controller ]
sl@0
  2280
    errorCode = iController.AddDataSource(KUidMmfAudioInput, KNullDesC8);
sl@0
  2281
	User::LeaveIfError( errorCode );
sl@0
  2282
	
sl@0
  2283
	//[ add data source and sink and prime the controller ]
sl@0
  2284
    errorCode = iController.AddDataSink(KUidMmfFileSink, ReadFileConfig());
sl@0
  2285
	User::LeaveIfError( errorCode );
sl@0
  2286
	
sl@0
  2287
	//[lets get the sink bit rate]
sl@0
  2288
	errorCode = theCommander.GetSinkBitRate(theRate);
sl@0
  2289
	User::LeaveIfError( errorCode );
sl@0
  2290
sl@0
  2291
	// check to see if the bitrate is greater than zero
sl@0
  2292
	// (it should exactly be samplerate*bitspersample)
sl@0
  2293
	// fail if the bitrate returned is zero and the record file exists
sl@0
  2294
	if ((theRate == 0) && (fileErr != KErrNotFound))
sl@0
  2295
		{
sl@0
  2296
		result = EFail;
sl@0
  2297
		return result;
sl@0
  2298
		}
sl@0
  2299
sl@0
  2300
	const TUint KArbitraryBitRate = 1000; // 1 Khz
sl@0
  2301
	//[lets get the sink bit rate]
sl@0
  2302
	errorCode = theCommander.SetSinkBitRate( KArbitraryBitRate );
sl@0
  2303
	if( errorCode == KErrNone )
sl@0
  2304
		{
sl@0
  2305
		result = EFail;
sl@0
  2306
		return result;
sl@0
  2307
		}
sl@0
  2308
sl@0
  2309
	errorCode =	iController.Prime();
sl@0
  2310
	User::LeaveIfError( errorCode );
sl@0
  2311
sl@0
  2312
	// [ wait for and process the return event from the audio output ]
sl@0
  2313
	result = SearchForEvent( primeEvent );
sl@0
  2314
	if( result == EFail )
sl@0
  2315
		{
sl@0
  2316
		return result;
sl@0
  2317
		}
sl@0
  2318
sl@0
  2319
    //[ get the bit rate while playing ]
sl@0
  2320
	User::LeaveIfError( iController.Play() );
sl@0
  2321
	TMMFEvent playEvent( KPlayTestId, KErrNone );
sl@0
  2322
sl@0
  2323
    result = SearchForEvent( playEvent );
sl@0
  2324
	if( result == EFail )
sl@0
  2325
		{
sl@0
  2326
		return result;
sl@0
  2327
		}
sl@0
  2328
sl@0
  2329
	//[lets get the sink bit rate]
sl@0
  2330
	errorCode = theCommander.GetSinkBitRate(theRate);
sl@0
  2331
	User::LeaveIfError( errorCode );
sl@0
  2332
sl@0
  2333
	// check to see if the bitrate is greater than zero
sl@0
  2334
	// (it should exactly be samplerate*bitspersample)
sl@0
  2335
	if (theRate == 0)
sl@0
  2336
		{
sl@0
  2337
		result = EFail;
sl@0
  2338
		return result;
sl@0
  2339
		}
sl@0
  2340
sl@0
  2341
    //[lets get the sink bit rate]
sl@0
  2342
	errorCode = theCommander.SetSinkBitRate(1000);
sl@0
  2343
	if( errorCode == KErrNone )
sl@0
  2344
		{
sl@0
  2345
		result = EFail;
sl@0
  2346
		return result;
sl@0
  2347
		}
sl@0
  2348
sl@0
  2349
	//[ ensure the controller is unloaded so that it does 
sl@0
  2350
	// not interfere with the following test ]
sl@0
  2351
	// There is error in this code and the stop followed by reset
sl@0
  2352
	// ensure the controller resources are released.
sl@0
  2353
	iController.Stop();
sl@0
  2354
	iController.Reset();
sl@0
  2355
	iController.Close();  
sl@0
  2356
	
sl@0
  2357
	__MM_HEAP_MARKEND;
sl@0
  2358
	   
sl@0
  2359
	// test steps return a result
sl@0
  2360
	return result;
sl@0
  2361
	}
sl@0
  2362
sl@0
  2363
/**
sl@0
  2364
*
sl@0
  2365
* CTestStepGetSetMetaData
sl@0
  2366
*/
sl@0
  2367
CTestStepGetSetMetaData::CTestStepGetSetMetaData()
sl@0
  2368
	{
sl@0
  2369
	iTestStepName = _L("MM-MMF-ACTRL-U-0031-HP");
sl@0
  2370
	}
sl@0
  2371
sl@0
  2372
/**
sl@0
  2373
*
sl@0
  2374
* ~CTestStepGetSetMetaData
sl@0
  2375
*/
sl@0
  2376
CTestStepGetSetMetaData::~CTestStepGetSetMetaData()
sl@0
  2377
	{
sl@0
  2378
	}
sl@0
  2379
sl@0
  2380
/**
sl@0
  2381
*
sl@0
  2382
* DoTestStepL
sl@0
  2383
*/
sl@0
  2384
TVerdict CTestStepGetSetMetaData::DoTestStepL( void )
sl@0
  2385
	{
sl@0
  2386
	__MM_HEAP_MARK;
sl@0
  2387
	
sl@0
  2388
	TVerdict result = EFail;
sl@0
  2389
	
sl@0
  2390
	_LIT( KTestPlay, "Meta data test with play scenario Test");
sl@0
  2391
	Log( KTestPlay );
sl@0
  2392
	
sl@0
  2393
	_LIT( KTestStepPlay, "This test checks setting/getting meta data");
sl@0
  2394
	Log( KTestStepPlay );
sl@0
  2395
	
sl@0
  2396
	// [ audio file to play ]
sl@0
  2397
	_LIT(KTestWavFile, "newmail.wav");
sl@0
  2398
	SetReadFileNameL( KTestWavFile );
sl@0
  2399
   	
sl@0
  2400
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
  2401
	User::LeaveIfError( errorCode );
sl@0
  2402
sl@0
  2403
	//[ add data source and sink and prime the controller ]
sl@0
  2404
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
  2405
	User::LeaveIfError( errorCode );
sl@0
  2406
	
sl@0
  2407
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
  2408
    User::LeaveIfError( errorCode );
sl@0
  2409
sl@0
  2410
	// [ lets get the number of meta data entries 
sl@0
  2411
	// for this format the meta data is unsupported ]
sl@0
  2412
	TInt numEntries = 0;
sl@0
  2413
	errorCode = iController.GetNumberOfMetaDataEntries( numEntries ); 
sl@0
  2414
	if( errorCode != KErrNotSupported )
sl@0
  2415
		{
sl@0
  2416
		User::LeaveIfError( errorCode );
sl@0
  2417
		}
sl@0
  2418
sl@0
  2419
	// [ lets get a meta data entry ]
sl@0
  2420
	const TInt KIndex = 0;
sl@0
  2421
	TRAP( errorCode, iController.GetMetaDataEntryL( KIndex ));
sl@0
  2422
	if( errorCode != KErrNotSupported )
sl@0
  2423
		{
sl@0
  2424
		User::LeaveIfError( errorCode );
sl@0
  2425
		}
sl@0
  2426
		
sl@0
  2427
	errorCode =	iController.Prime();
sl@0
  2428
	User::LeaveIfError( errorCode );
sl@0
  2429
	
sl@0
  2430
	// [ wait for and process the return event from the audio output ]
sl@0
  2431
	
sl@0
  2432
	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
sl@0
  2433
	result = SearchForEvent( primeEvent );
sl@0
  2434
	if( result == EFail )
sl@0
  2435
		{
sl@0
  2436
		return result;
sl@0
  2437
		}
sl@0
  2438
	
sl@0
  2439
	// [ lets get the number of meta data entries 
sl@0
  2440
	// for this format the meta data is unsupported ]
sl@0
  2441
	numEntries = 0;
sl@0
  2442
	errorCode = iController.GetNumberOfMetaDataEntries( numEntries ); 
sl@0
  2443
	if( errorCode != KErrNotSupported )
sl@0
  2444
		{
sl@0
  2445
		User::LeaveIfError( errorCode );
sl@0
  2446
		}
sl@0
  2447
sl@0
  2448
	// [ lets get a meta data entry ]
sl@0
  2449
	TRAP( errorCode, iController.GetMetaDataEntryL( KIndex ));
sl@0
  2450
	if( errorCode != KErrNotSupported )
sl@0
  2451
		{
sl@0
  2452
		User::LeaveIfError( errorCode );
sl@0
  2453
		}
sl@0
  2454
	
sl@0
  2455
    User::LeaveIfError( iController.Play() );
sl@0
  2456
	
sl@0
  2457
	// note this test does not wait around 
sl@0
  2458
	// to detect that the audio has been played
sl@0
  2459
	// [ now process the confirmation event that play has reached audio output
sl@0
  2460
	//   this is the raison detre of the test ]
sl@0
  2461
	TMMFEvent playEvent( KPlayTestId, KErrNone );
sl@0
  2462
	
sl@0
  2463
	result = SearchForEvent( playEvent );
sl@0
  2464
sl@0
  2465
	// [ lets try to get the meta data when playing ]
sl@0
  2466
sl@0
  2467
	errorCode = iController.GetNumberOfMetaDataEntries( numEntries ); 
sl@0
  2468
	if( errorCode != KErrNotReady )
sl@0
  2469
		{
sl@0
  2470
		User::LeaveIfError( errorCode );
sl@0
  2471
		}
sl@0
  2472
sl@0
  2473
	// [ lets get a meta data entry ]
sl@0
  2474
	// This kills the thread and is under investigation
sl@0
  2475
	TRAP( errorCode, iController.GetMetaDataEntryL( KIndex ));
sl@0
  2476
	if( errorCode != KErrNotReady )
sl@0
  2477
		{
sl@0
  2478
		User::LeaveIfError( errorCode );
sl@0
  2479
		}
sl@0
  2480
sl@0
  2481
	//[ ensure the controller is unloaded so that it does 
sl@0
  2482
	// not interfere with the following test ]
sl@0
  2483
	// There is error in this code and the stop followed by reset
sl@0
  2484
	// ensure the controller resources are released.
sl@0
  2485
	iController.Stop();
sl@0
  2486
	iController.Reset();
sl@0
  2487
	iController.Close();  
sl@0
  2488
	
sl@0
  2489
	__MM_HEAP_MARKEND;
sl@0
  2490
	   
sl@0
  2491
	// test steps return a result
sl@0
  2492
	return EPass;
sl@0
  2493
	}
sl@0
  2494
sl@0
  2495
/**
sl@0
  2496
*
sl@0
  2497
* CTestStepGetSupportedSinkDataTypes
sl@0
  2498
*
sl@0
  2499
*/
sl@0
  2500
CTestStepGetSupportedSinkDataTypes::CTestStepGetSupportedSinkDataTypes()
sl@0
  2501
	{
sl@0
  2502
	iTestStepName = _L("MM-MMF-ACTRL-U-0034-HP");
sl@0
  2503
	}
sl@0
  2504
sl@0
  2505
/**
sl@0
  2506
*
sl@0
  2507
* ~CTestStepGetSupportedSinkDataTypes
sl@0
  2508
*
sl@0
  2509
*/
sl@0
  2510
CTestStepGetSupportedSinkDataTypes::~CTestStepGetSupportedSinkDataTypes()
sl@0
  2511
	{
sl@0
  2512
	}
sl@0
  2513
sl@0
  2514
/**
sl@0
  2515
*
sl@0
  2516
* DoTestStepL
sl@0
  2517
* This test gets the supported sink data types
sl@0
  2518
*
sl@0
  2519
*/
sl@0
  2520
TVerdict CTestStepGetSupportedSinkDataTypes::DoTestStepL( void )
sl@0
  2521
	{
sl@0
  2522
	__MM_HEAP_MARK;
sl@0
  2523
	TVerdict result = EPass;
sl@0
  2524
	_LIT( KTestSourceNumChannels, "GetSupported Sink Data types");
sl@0
  2525
	Log( KTestSourceNumChannels);
sl@0
  2526
	
sl@0
  2527
	_LIT( KTestSinkBitRateReason, "This test checks the get supported sink data types method");
sl@0
  2528
	Log( KTestSinkBitRateReason );
sl@0
  2529
	
sl@0
  2530
	// [ audio file to play ]
sl@0
  2531
	_LIT(KTestWavFile, "newmail.wav");
sl@0
  2532
	SetReadFileNameL( KTestWavFile );
sl@0
  2533
   	
sl@0
  2534
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
  2535
	User::LeaveIfError( errorCode );
sl@0
  2536
sl@0
  2537
	//[ attempt to get the sink num channels ]
sl@0
  2538
    RMMFAudioControllerCustomCommands theCommander( iController );
sl@0
  2539
sl@0
  2540
	RArray<TFourCC> supportedDataTypes;
sl@0
  2541
	CleanupClosePushL(supportedDataTypes);
sl@0
  2542
sl@0
  2543
	TRAPD( errorCode2, theCommander.GetSupportedSinkDataTypesL( supportedDataTypes ));
sl@0
  2544
	if( ( errorCode2 == KErrNone ) || supportedDataTypes.Count() )
sl@0
  2545
		{
sl@0
  2546
		//[ should have failed with either an error code or non zero supported types ]
sl@0
  2547
		result = EFail;
sl@0
  2548
		}
sl@0
  2549
sl@0
  2550
	//[ ok lets add the source and sink ]
sl@0
  2551
    if(result==EPass)
sl@0
  2552
    	{
sl@0
  2553
    	errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
  2554
    	if(errorCode!=KErrNone)
sl@0
  2555
    		{
sl@0
  2556
    		result=EFail;
sl@0
  2557
    		}
sl@0
  2558
    	}
sl@0
  2559
    
sl@0
  2560
    if(result==EPass)
sl@0
  2561
    	{
sl@0
  2562
		errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
  2563
    	if(errorCode!=KErrNone)
sl@0
  2564
    		{
sl@0
  2565
    		result=EFail;
sl@0
  2566
    		}
sl@0
  2567
    	}
sl@0
  2568
    
sl@0
  2569
    if(result==EPass)
sl@0
  2570
    	{
sl@0
  2571
    	//[ ensure the array is empty ]
sl@0
  2572
		supportedDataTypes.Reset();
sl@0
  2573
		TRAPD( errorCode3,theCommander.GetSupportedSinkDataTypesL( supportedDataTypes ));
sl@0
  2574
		if(errorCode3!=KErrNotSupported)
sl@0
  2575
	    	{
sl@0
  2576
	    	INFO_PRINTF2(_L("GetSupportedSinkDataTypesL left with %d when KErrNotSupported is expected"), errorCode);
sl@0
  2577
	    	result = EFail;
sl@0
  2578
	    	}
sl@0
  2579
    	}
sl@0
  2580
	
sl@0
  2581
sl@0
  2582
	//[ pop supportedDataTypes ]
sl@0
  2583
	CleanupStack::PopAndDestroy(1);//supportedDataTypes
sl@0
  2584
	
sl@0
  2585
	//[ ensure the controller is unloaded so that it does 
sl@0
  2586
	// not interfere with the following test ]
sl@0
  2587
	// There is error in this code and the stop followed by reset
sl@0
  2588
	// ensure the controller resources are released.
sl@0
  2589
	iController.Stop();
sl@0
  2590
	iController.Reset();
sl@0
  2591
	iController.Close();  
sl@0
  2592
	
sl@0
  2593
	__MM_HEAP_MARKEND;
sl@0
  2594
	return result;
sl@0
  2595
	}
sl@0
  2596
sl@0
  2597
/**
sl@0
  2598
*
sl@0
  2599
* CTestStepGetSupportedSourceDataTypes
sl@0
  2600
*
sl@0
  2601
*/
sl@0
  2602
CTestStepGetSupportedSourceDataTypes::CTestStepGetSupportedSourceDataTypes()
sl@0
  2603
	{
sl@0
  2604
	iTestStepName = _L("MM-MMF-ACTRL-U-0035-HP");
sl@0
  2605
	}
sl@0
  2606
sl@0
  2607
/**
sl@0
  2608
*
sl@0
  2609
* ~CTestStepGetSupportedSourceDataTypes
sl@0
  2610
*
sl@0
  2611
*/
sl@0
  2612
CTestStepGetSupportedSourceDataTypes::~CTestStepGetSupportedSourceDataTypes()
sl@0
  2613
	{
sl@0
  2614
	}
sl@0
  2615
sl@0
  2616
/**
sl@0
  2617
*
sl@0
  2618
* DoTestStepL
sl@0
  2619
*
sl@0
  2620
*/
sl@0
  2621
TVerdict CTestStepGetSupportedSourceDataTypes::DoTestStepL( void )
sl@0
  2622
	{
sl@0
  2623
	__MM_HEAP_MARK;
sl@0
  2624
	TVerdict result = EPass;
sl@0
  2625
	
sl@0
  2626
	_LIT( KTestSourceNumChannels, "GetSupported Source Data types");
sl@0
  2627
	Log( KTestSourceNumChannels);
sl@0
  2628
	
sl@0
  2629
	_LIT( KTestSinkBitRateReason, "This test checks the get supported source data types method");
sl@0
  2630
	Log( KTestSinkBitRateReason );
sl@0
  2631
	
sl@0
  2632
	// [ audio file to play ]
sl@0
  2633
	_LIT(KTestWavFile, "newmail.wav");
sl@0
  2634
	SetReadFileNameL( KTestWavFile );
sl@0
  2635
   	
sl@0
  2636
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
  2637
	User::LeaveIfError( errorCode );
sl@0
  2638
	
sl@0
  2639
	//[ attempt to get the sink num channels ]
sl@0
  2640
    RMMFAudioControllerCustomCommands theCommander( iController );
sl@0
  2641
	
sl@0
  2642
	RArray<TFourCC> supportedDataTypes;
sl@0
  2643
	CleanupClosePushL(supportedDataTypes);
sl@0
  2644
	
sl@0
  2645
	TRAPD( errorCode2, theCommander.GetSupportedSourceDataTypesL( supportedDataTypes ));
sl@0
  2646
	if( ( errorCode2 == KErrNone ) || supportedDataTypes.Count() )
sl@0
  2647
		{
sl@0
  2648
		//[ should have failed with either an error code or non zero supported types ]
sl@0
  2649
		result = EFail;
sl@0
  2650
		return result;
sl@0
  2651
		}
sl@0
  2652
	
sl@0
  2653
	//[ ok lets add the source and sink ]
sl@0
  2654
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
  2655
	User::LeaveIfError( errorCode );
sl@0
  2656
	
sl@0
  2657
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
  2658
    User::LeaveIfError( errorCode );
sl@0
  2659
	
sl@0
  2660
	//[ ensure the array is empty ]
sl@0
  2661
	supportedDataTypes.Reset();
sl@0
  2662
	TRAPD( errorCode3,theCommander.GetSupportedSourceDataTypesL( supportedDataTypes ));
sl@0
  2663
	User::LeaveIfError( errorCode3 );
sl@0
  2664
	
sl@0
  2665
	// Store the original FCC
sl@0
  2666
	TFourCC origFCC;
sl@0
  2667
	errorCode = theCommander.GetSourceDataType(origFCC);
sl@0
  2668
	if (errorCode != KErrNone)
sl@0
  2669
		{
sl@0
  2670
		INFO_PRINTF2(_L("GetSourceDataType returned error %d"), errorCode);
sl@0
  2671
		return EFail;
sl@0
  2672
		}
sl@0
  2673
sl@0
  2674
	TFourCC theNewFCC;
sl@0
  2675
	TFourCC theFCC;
sl@0
  2676
	
sl@0
  2677
	//[ loop over the possible set of data types that are supported ]
sl@0
  2678
	for( TInt index = 0; index < supportedDataTypes.Count(); index++ )
sl@0
  2679
		{
sl@0
  2680
		theFCC = supportedDataTypes[ index];
sl@0
  2681
		errorCode = theCommander.SetSourceDataType( theFCC );
sl@0
  2682
sl@0
  2683
		if (theFCC == origFCC)
sl@0
  2684
			{
sl@0
  2685
			// Trying to set the correct FCC
sl@0
  2686
			if (errorCode != KErrNone)
sl@0
  2687
				{
sl@0
  2688
				INFO_PRINTF2(_L("SetSourceDataType returned unexpected error %d"), errorCode);
sl@0
  2689
				result = EFail;
sl@0
  2690
				break;
sl@0
  2691
				}
sl@0
  2692
			}
sl@0
  2693
		else
sl@0
  2694
			{
sl@0
  2695
			if (errorCode != KErrAlreadyExists)
sl@0
  2696
				{
sl@0
  2697
				INFO_PRINTF3(_L("SetSourceDataType returned %d, expecting %d"), errorCode, KErrAlreadyExists);
sl@0
  2698
				result = EFail;
sl@0
  2699
				break;
sl@0
  2700
				}
sl@0
  2701
			}
sl@0
  2702
sl@0
  2703
		errorCode = theCommander.GetSourceDataType( theNewFCC );
sl@0
  2704
		if (theNewFCC != origFCC)
sl@0
  2705
			{
sl@0
  2706
			INFO_PRINTF1(_L("GetSourceDataType returned incorrect FCC"));
sl@0
  2707
			result = EFail;
sl@0
  2708
			break;
sl@0
  2709
			}
sl@0
  2710
sl@0
  2711
		if (errorCode != KErrNone)
sl@0
  2712
			{
sl@0
  2713
			INFO_PRINTF2(_L("GetSourceDataType returned unexpected error %d"), errorCode);
sl@0
  2714
			result = EFail;
sl@0
  2715
			break;
sl@0
  2716
			}
sl@0
  2717
		}
sl@0
  2718
	
sl@0
  2719
	//[ pop supportedDataTypes ]
sl@0
  2720
	CleanupStack::PopAndDestroy(1);//supportedDataTypes
sl@0
  2721
	
sl@0
  2722
	//[ ensure the controller is unloaded so that it does 
sl@0
  2723
	// not interfere with the following test ]
sl@0
  2724
	// There is error in this code and the stop followed by reset
sl@0
  2725
	// ensure the controller resources are released.
sl@0
  2726
	iController.Stop();
sl@0
  2727
	iController.Reset();
sl@0
  2728
	iController.Close();  
sl@0
  2729
	
sl@0
  2730
	__MM_HEAP_MARKEND;
sl@0
  2731
	return result;
sl@0
  2732
	}
sl@0
  2733
sl@0
  2734
/**
sl@0
  2735
*
sl@0
  2736
* CTestStepGetSupportedSourceNumChannels
sl@0
  2737
* 
sl@0
  2738
*/
sl@0
  2739
CTestStepGetSupportedSourceNumChannels::CTestStepGetSupportedSourceNumChannels()
sl@0
  2740
	{
sl@0
  2741
	iTestStepName = _L("MM-MMF-ACTRL-U-0036-HP");
sl@0
  2742
	}
sl@0
  2743
sl@0
  2744
/**
sl@0
  2745
*
sl@0
  2746
* ~CTestStepGetSupportedSourceNumChannels
sl@0
  2747
*
sl@0
  2748
*/
sl@0
  2749
CTestStepGetSupportedSourceNumChannels::~CTestStepGetSupportedSourceNumChannels()
sl@0
  2750
	{
sl@0
  2751
	}
sl@0
  2752
sl@0
  2753
/**
sl@0
  2754
*
sl@0
  2755
* DoTestStepL
sl@0
  2756
* This test  tests the number of channels supported by a source
sl@0
  2757
*
sl@0
  2758
*/
sl@0
  2759
TVerdict CTestStepGetSupportedSourceNumChannels::DoTestStepL( void )
sl@0
  2760
	{
sl@0
  2761
	__MM_HEAP_MARK;
sl@0
  2762
	TVerdict result = EPass;
sl@0
  2763
	
sl@0
  2764
	_LIT( KTestSourceNumChannels, "GetSupported Source Num Channels");
sl@0
  2765
	Log( KTestSourceNumChannels);
sl@0
  2766
	
sl@0
  2767
	_LIT( KTestSinkBitRateReason, "This test checks the get supported source channels");
sl@0
  2768
	Log( KTestSinkBitRateReason );
sl@0
  2769
	
sl@0
  2770
	// [ audio file to play ]
sl@0
  2771
	_LIT(KTestWavFile, "newmail.wav");
sl@0
  2772
	SetReadFileNameL( KTestWavFile );
sl@0
  2773
   	
sl@0
  2774
	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
sl@0
  2775
	User::LeaveIfError( errorCode );
sl@0
  2776
	
sl@0
  2777
	//[ attempt to get the sink num channels ]
sl@0
  2778
    RMMFAudioControllerCustomCommands theCommander( iController );
sl@0
  2779
			
sl@0
  2780
	RArray<TUint> supportedChannels;
sl@0
  2781
	CleanupClosePushL(supportedChannels);
sl@0
  2782
sl@0
  2783
	TRAPD( errorCode2, theCommander.GetSupportedSourceNumChannelsL( supportedChannels));
sl@0
  2784
	if( errorCode2 == KErrNone ) 
sl@0
  2785
		{
sl@0
  2786
		//[ should have failed with either an error code or non zero supported types ]
sl@0
  2787
		result = EFail;
sl@0
  2788
		return result;
sl@0
  2789
		}
sl@0
  2790
	
sl@0
  2791
	//[ ok lets add the source and sink ]
sl@0
  2792
    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
sl@0
  2793
	User::LeaveIfError( errorCode );
sl@0
  2794
	
sl@0
  2795
	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
sl@0
  2796
    User::LeaveIfError( errorCode );
sl@0
  2797
sl@0
  2798
	//[ ensure the array is empty ]
sl@0
  2799
	supportedChannels.Reset();
sl@0
  2800
	TRAPD( errorCode3, theCommander.GetSupportedSourceNumChannelsL( supportedChannels));	
sl@0
  2801
	User::LeaveIfError( errorCode3 );
sl@0
  2802
	
sl@0
  2803
	TUint orgNumChannels = 0;
sl@0
  2804
	errorCode = theCommander.GetSourceNumChannels( orgNumChannels);
sl@0
  2805
	User::LeaveIfError( errorCode );
sl@0
  2806
sl@0
  2807
	//[ loop over the possible set of data types that are supported ]
sl@0
  2808
	for( TInt index = 0; index < supportedChannels.Count(); index++ )
sl@0
  2809
		{
sl@0
  2810
		TUint oldNumChannels = supportedChannels[ index];
sl@0
  2811
		TUint numChannels    = 0;
sl@0
  2812
		//[ wav files currently do not support a variable num source channels]
sl@0
  2813
		errorCode = theCommander.SetSourceNumChannels( oldNumChannels);
sl@0
  2814
		if (oldNumChannels == orgNumChannels)
sl@0
  2815
			{
sl@0
  2816
			// We tried to set the right number of channels for clip
sl@0
  2817
			if (errorCode != KErrNone)
sl@0
  2818
				{
sl@0
  2819
				INFO_PRINTF2(_L("Error calling SetSourceNumChannels %d"), errorCode);
sl@0
  2820
				result = EFail;
sl@0
  2821
				break;
sl@0
  2822
				}
sl@0
  2823
			}
sl@0
  2824
		else
sl@0
  2825
			{
sl@0
  2826
			// Setting source sample rate to a different value 
sl@0
  2827
			// is tolerated (INC038043) to preserve BC with 6.1
sl@0
  2828
			if (errorCode != KErrNone)
sl@0
  2829
				{
sl@0
  2830
				INFO_PRINTF2(_L("Unexpected error code returned by SetSourceNumChannels %d"), errorCode);
sl@0
  2831
				result = EFail;
sl@0
  2832
				break;
sl@0
  2833
				}
sl@0
  2834
			}
sl@0
  2835
		
sl@0
  2836
		//[ check the set operation resulted in no change of the
sl@0
  2837
		// number of channels ]
sl@0
  2838
		errorCode = theCommander.GetSourceNumChannels( numChannels);
sl@0
  2839
		User::LeaveIfError( errorCode );
sl@0
  2840
		if( orgNumChannels != numChannels )
sl@0
  2841
			{
sl@0
  2842
			INFO_PRINTF3(_L("GetSourceNumChannels returned %d, expecting %d"), numChannels, orgNumChannels);
sl@0
  2843
			result = EFail;
sl@0
  2844
			break;
sl@0
  2845
			}
sl@0
  2846
		}
sl@0
  2847
sl@0
  2848
	//[ pop supportedChannels ]
sl@0
  2849
	CleanupStack::PopAndDestroy(1);//supportedChannels
sl@0
  2850
	
sl@0
  2851
	//[ ensure the controller is unloaded so that it does 
sl@0
  2852
	// not interfere with the following test ]
sl@0
  2853
	// There is error in this code and the stop followed by reset
sl@0
  2854
	// ensure the controller resources are released.
sl@0
  2855
	iController.Stop();
sl@0
  2856
	iController.Reset();
sl@0
  2857
	iController.Close();  
sl@0
  2858
	
sl@0
  2859
	__MM_HEAP_MARKEND;
sl@0
  2860
	return result;
sl@0
  2861
	}