os/boardsupport/haitest/bspsvs/suite/bsp/sound/src/t_soundformatssupporteddata.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description:
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
/**
sl@0
    19
@test
sl@0
    20
@internalComponent
sl@0
    21
sl@0
    22
This contains CT_SoundFormatsSupportedData
sl@0
    23
*/
sl@0
    24
sl@0
    25
//	User includes
sl@0
    26
#include "t_soundformatssupporteddata.h"
sl@0
    27
#include "sound_util.h"
sl@0
    28
sl@0
    29
/*@{*/
sl@0
    30
///	Commands
sl@0
    31
_LIT(KCmdNew,						"new");
sl@0
    32
_LIT(KCmdDestructor,				"~");
sl@0
    33
_LIT(KCmd_iMinRate_get,				"imin_rate_get");
sl@0
    34
_LIT(KCmd_iMaxRate_get,				"imax_rate_get");
sl@0
    35
_LIT(KCmd_iChannels_get,			"ichannels_get");
sl@0
    36
_LIT(KCmd_iMinBufferSize_get,		"imin_buffer_size_get");
sl@0
    37
_LIT(KCmd_iMaxBufferSize_get,		"imax_buffer_size_get");
sl@0
    38
_LIT(KCmd_iMinVolume_get,			"imin_volume_get");
sl@0
    39
_LIT(KCmd_iMaxVolume_get,			"imax_volume_get");
sl@0
    40
_LIT(KCmd_iEncodings_get,			"iencodings_get");
sl@0
    41
sl@0
    42
/*@{*/
sl@0
    43
///	Parameters
sl@0
    44
_LIT(KMinRateExpected,				"min_rate_expected");
sl@0
    45
_LIT(KMaxRateExpected,				"max_rate_expected");
sl@0
    46
_LIT(KChannelsExpected,				"channels_expected");
sl@0
    47
_LIT(KMinBufferSizeExpected,		"min_buffer_size_expected");
sl@0
    48
_LIT(KMaxBufferSizeExpected,		"max_buffer_size_expected");
sl@0
    49
_LIT(KMinVolumeExpected,			"min_volume_expected");
sl@0
    50
_LIT(KMaxVolumeExpected,			"max_volume_expected");
sl@0
    51
_LIT(KEncodingsExpected,			"encodings_expected");
sl@0
    52
sl@0
    53
///	Logging
sl@0
    54
_LIT(KLogNew,						"New object created successfully");
sl@0
    55
_LIT(KLogNewError,					"Error creating new object, error code=%d");
sl@0
    56
sl@0
    57
/**
sl@0
    58
 * Two phase constructor
sl@0
    59
 */
sl@0
    60
CT_SoundFormatsSupportedData* CT_SoundFormatsSupportedData::NewL()
sl@0
    61
	{
sl@0
    62
	CT_SoundFormatsSupportedData*	ret=new (ELeave) CT_SoundFormatsSupportedData();
sl@0
    63
	CleanupStack::PushL(ret);
sl@0
    64
	ret->ConstructL();
sl@0
    65
	CleanupStack::Pop(ret);
sl@0
    66
	return ret;
sl@0
    67
	}
sl@0
    68
sl@0
    69
/**
sl@0
    70
* Constructor. First phase construction
sl@0
    71
*/
sl@0
    72
CT_SoundFormatsSupportedData::CT_SoundFormatsSupportedData()
sl@0
    73
:	CDataWrapperBase()
sl@0
    74
,	iFormatsSupported(NULL)
sl@0
    75
	{
sl@0
    76
	}
sl@0
    77
sl@0
    78
/**
sl@0
    79
 * Second phase construction
sl@0
    80
 */
sl@0
    81
void CT_SoundFormatsSupportedData::ConstructL()
sl@0
    82
	{	
sl@0
    83
	}
sl@0
    84
sl@0
    85
/**
sl@0
    86
* Destructor
sl@0
    87
*/
sl@0
    88
CT_SoundFormatsSupportedData::~CT_SoundFormatsSupportedData()
sl@0
    89
	{
sl@0
    90
	DoCleanup();
sl@0
    91
	}
sl@0
    92
sl@0
    93
/**
sl@0
    94
 * Helper for cleanup operation
sl@0
    95
 */
sl@0
    96
void CT_SoundFormatsSupportedData::DoCleanup()
sl@0
    97
	{
sl@0
    98
	delete iFormatsSupported;
sl@0
    99
	iFormatsSupported=NULL;	
sl@0
   100
	}
sl@0
   101
sl@0
   102
/**
sl@0
   103
 * Return a pointer to the object that the data wraps
sl@0
   104
 *
sl@0
   105
 * @return pointer to the object that the data wraps
sl@0
   106
 */
sl@0
   107
TAny* CT_SoundFormatsSupportedData::GetObject()
sl@0
   108
	{
sl@0
   109
	return iFormatsSupported;
sl@0
   110
	}
sl@0
   111
sl@0
   112
/**
sl@0
   113
 * Set the wrapped data object with new value
sl@0
   114
 */
sl@0
   115
void CT_SoundFormatsSupportedData::SetObjectL(TAny* aAny)
sl@0
   116
	{
sl@0
   117
	DoCleanup();
sl@0
   118
	iFormatsSupported=static_cast<RMdaDevSound::TSoundFormatsSupported*>(aAny);
sl@0
   119
	}
sl@0
   120
sl@0
   121
/**
sl@0
   122
 * Clear the wrapped data object pointer w/o de-initialization
sl@0
   123
 */
sl@0
   124
void CT_SoundFormatsSupportedData::DisownObjectL()
sl@0
   125
	{
sl@0
   126
	iFormatsSupported=NULL;
sl@0
   127
	}
sl@0
   128
sl@0
   129
/**
sl@0
   130
 * Return static cleanup function
sl@0
   131
 */
sl@0
   132
inline TCleanupOperation CT_SoundFormatsSupportedData::CleanupOperation()
sl@0
   133
	{
sl@0
   134
	return CleanupOperation;
sl@0
   135
	}
sl@0
   136
sl@0
   137
/**
sl@0
   138
 * Static cleanup function
sl@0
   139
 */
sl@0
   140
void CT_SoundFormatsSupportedData::CleanupOperation( TAny* aAny )
sl@0
   141
	{
sl@0
   142
	RMdaDevSound::TSoundFormatsSupported* format = static_cast<RMdaDevSound::TSoundFormatsSupported*> ( aAny );
sl@0
   143
	delete format;
sl@0
   144
	}
sl@0
   145
sl@0
   146
/**
sl@0
   147
* Process a command read from the ini file
sl@0
   148
*
sl@0
   149
* @param aDataWrapper	test step requiring command to be processed
sl@0
   150
* @param aCommand	the command to process
sl@0
   151
* @param aSection		the entry in the ini file requiring the command to be processed
sl@0
   152
*
sl@0
   153
* @return ETrue if the command is processed
sl@0
   154
*/
sl@0
   155
TBool CT_SoundFormatsSupportedData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
sl@0
   156
	{
sl@0
   157
	TBool	ret=ETrue;
sl@0
   158
	if ( aCommand==KCmdNew )
sl@0
   159
		{
sl@0
   160
		DoCmdNew();
sl@0
   161
		}
sl@0
   162
	else if ( aCommand==KCmdDestructor )
sl@0
   163
		{
sl@0
   164
		DoCmdDestructor();
sl@0
   165
		}
sl@0
   166
	else if ( aCommand==KCmd_iMinRate_get )
sl@0
   167
		{
sl@0
   168
		DoCmd_iMinRate_get(aSection);
sl@0
   169
		}
sl@0
   170
	else if ( aCommand==KCmd_iMaxRate_get )
sl@0
   171
		{
sl@0
   172
		DoCmd_iMaxRate_get(aSection);
sl@0
   173
		}
sl@0
   174
	else if ( aCommand==KCmd_iChannels_get )
sl@0
   175
		{
sl@0
   176
		DoCmd_iChannels_get(aSection);
sl@0
   177
		}
sl@0
   178
	else if ( aCommand==KCmd_iMinBufferSize_get )
sl@0
   179
		{
sl@0
   180
		DoCmd_iMinBufferSize_get(aSection);
sl@0
   181
		}
sl@0
   182
	else if ( aCommand==KCmd_iMaxBufferSize_get )
sl@0
   183
		{
sl@0
   184
		DoCmd_iMaxBufferSize_get(aSection);
sl@0
   185
		}
sl@0
   186
	else if ( aCommand==KCmd_iMinVolume_get )
sl@0
   187
		{
sl@0
   188
		DoCmd_iMinVolume_get(aSection);
sl@0
   189
		}
sl@0
   190
	else if ( aCommand==KCmd_iMaxVolume_get )
sl@0
   191
		{
sl@0
   192
		DoCmd_iMaxVolume_get(aSection);
sl@0
   193
		}
sl@0
   194
	else if ( aCommand==KCmd_iEncodings_get )
sl@0
   195
		{
sl@0
   196
		DoCmd_iEncodings_getL(aSection);
sl@0
   197
		}
sl@0
   198
	else
sl@0
   199
		{
sl@0
   200
		ret=CDataWrapperBase::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
sl@0
   201
		}
sl@0
   202
sl@0
   203
	return ret;
sl@0
   204
	}
sl@0
   205
sl@0
   206
/**
sl@0
   207
 * Creates new instance of TSoundFormatsSupported
sl@0
   208
 */
sl@0
   209
void CT_SoundFormatsSupportedData::DoCmdNew()
sl@0
   210
	{
sl@0
   211
	DoCleanup();
sl@0
   212
	TRAPD(err, iFormatsSupported = new (ELeave) RMdaDevSound::TSoundFormatsSupported());
sl@0
   213
	if ( err!=KErrNone )
sl@0
   214
		{
sl@0
   215
		ERR_PRINTF2(KLogNewError, err);
sl@0
   216
		SetError(err);
sl@0
   217
		}
sl@0
   218
	else
sl@0
   219
		{
sl@0
   220
		INFO_PRINTF1(KLogNew);
sl@0
   221
		}
sl@0
   222
	}
sl@0
   223
sl@0
   224
/**
sl@0
   225
 * Performs cleanup operation
sl@0
   226
 */
sl@0
   227
void CT_SoundFormatsSupportedData::DoCmdDestructor()
sl@0
   228
	{
sl@0
   229
	DoCleanup();
sl@0
   230
	}
sl@0
   231
sl@0
   232
/**
sl@0
   233
 * Gets iMinRate
sl@0
   234
 * 
sl@0
   235
 * @param aSection 			section name where expected value can be read
sl@0
   236
 * 							KMinRateExpected - min rate expected
sl@0
   237
 *
sl@0
   238
 * @return					void
sl@0
   239
 *
sl@0
   240
 * @leave					no
sl@0
   241
 */
sl@0
   242
void CT_SoundFormatsSupportedData::DoCmd_iMinRate_get(const TDesC& aSection)
sl@0
   243
	{
sl@0
   244
	TInt	expected;
sl@0
   245
	if (GET_OPTIONAL_INT_PARAMETER(KMinRateExpected(), aSection, expected))
sl@0
   246
		{
sl@0
   247
		if(iFormatsSupported->iMinRate != expected)
sl@0
   248
			{
sl@0
   249
			ERR_PRINTF3(_L("Expected result != iMinRate, expected=%d, iMinRate=%d"), expected, iFormatsSupported->iMinRate);
sl@0
   250
			SetBlockResult(EFail);
sl@0
   251
			}
sl@0
   252
		else
sl@0
   253
			{
sl@0
   254
			INFO_PRINTF3(_L("iMinRate == expected, iMinRate=%d, expected=%d"), iFormatsSupported->iMinRate, expected);
sl@0
   255
			}
sl@0
   256
		}
sl@0
   257
	else
sl@0
   258
		{
sl@0
   259
		INFO_PRINTF2(_L("iMinRate=%d"), iFormatsSupported->iMinRate);
sl@0
   260
		}
sl@0
   261
	}
sl@0
   262
sl@0
   263
/**
sl@0
   264
 * Gets iMaxRate
sl@0
   265
 * 
sl@0
   266
 * @param aSection 			section name where expected value can be read
sl@0
   267
 * 							KMaxRateExpected - max rate expected
sl@0
   268
 *
sl@0
   269
 * @return					void
sl@0
   270
 *
sl@0
   271
 * @leave					no
sl@0
   272
 */
sl@0
   273
void CT_SoundFormatsSupportedData::DoCmd_iMaxRate_get(const TDesC& aSection)
sl@0
   274
	{
sl@0
   275
	TInt	expected;
sl@0
   276
	if (GET_OPTIONAL_INT_PARAMETER(KMaxRateExpected(), aSection, expected))
sl@0
   277
		{
sl@0
   278
		if(iFormatsSupported->iMaxRate != expected)
sl@0
   279
			{
sl@0
   280
			ERR_PRINTF3(_L("Expected result != iMaxRate, expected=%d, iMaxRate=%d"), expected, iFormatsSupported->iMaxRate);
sl@0
   281
			SetBlockResult(EFail);
sl@0
   282
			}
sl@0
   283
		else
sl@0
   284
			{
sl@0
   285
			INFO_PRINTF3(_L("iMaxRate == expected, iMaxRate=%d, expected=%d"), iFormatsSupported->iMaxRate, expected);
sl@0
   286
			}
sl@0
   287
		}
sl@0
   288
	else
sl@0
   289
		{
sl@0
   290
		INFO_PRINTF2(_L("iMaxRate=%d"), iFormatsSupported->iMaxRate);
sl@0
   291
		}
sl@0
   292
	}
sl@0
   293
sl@0
   294
/**
sl@0
   295
 * Gets iMinBufferSize
sl@0
   296
 * 
sl@0
   297
 * @param aSection 			section name where expected value can be read
sl@0
   298
 * 							KMinBufferSizeExpected - min buffer size expected
sl@0
   299
 *
sl@0
   300
 * @return					void
sl@0
   301
 *
sl@0
   302
 * @leave					no
sl@0
   303
 */
sl@0
   304
void CT_SoundFormatsSupportedData::DoCmd_iMinBufferSize_get(const TDesC& aSection)
sl@0
   305
	{
sl@0
   306
	TInt	expected;
sl@0
   307
	if (GET_OPTIONAL_INT_PARAMETER(KMinBufferSizeExpected(), aSection, expected))
sl@0
   308
		{
sl@0
   309
		if(iFormatsSupported->iMinBufferSize != expected)
sl@0
   310
			{
sl@0
   311
			ERR_PRINTF3(_L("Expected result != iMinBufferSize, expected=%d, iMinBufferSize=%d"), expected, iFormatsSupported->iMinBufferSize);
sl@0
   312
			SetBlockResult(EFail);
sl@0
   313
			}
sl@0
   314
		else
sl@0
   315
			{
sl@0
   316
			INFO_PRINTF3(_L("iMinBufferSize == expected, iMinBufferSize=%d, expected=%d"), iFormatsSupported->iMinBufferSize, expected);
sl@0
   317
			}
sl@0
   318
		}
sl@0
   319
	else
sl@0
   320
		{
sl@0
   321
		INFO_PRINTF2(_L("iMinBufferSize=%d"), iFormatsSupported->iMinBufferSize);
sl@0
   322
		}
sl@0
   323
	}
sl@0
   324
sl@0
   325
/**
sl@0
   326
 * Gets iMaxBufferSize
sl@0
   327
 * 
sl@0
   328
 * @param aSection 			section name where expected value can be read
sl@0
   329
 * 							KMaxBufferSizeExpected - max buffer size expected
sl@0
   330
 *
sl@0
   331
 * @return					void
sl@0
   332
 *
sl@0
   333
 * @leave					no
sl@0
   334
 */
sl@0
   335
void CT_SoundFormatsSupportedData::DoCmd_iMaxBufferSize_get(const TDesC& aSection)
sl@0
   336
	{
sl@0
   337
	TInt	expected;
sl@0
   338
	if (GET_OPTIONAL_INT_PARAMETER(KMaxBufferSizeExpected(), aSection, expected))
sl@0
   339
		{
sl@0
   340
		if(iFormatsSupported->iMaxBufferSize != expected)
sl@0
   341
			{
sl@0
   342
			ERR_PRINTF3(_L("Expected result != iMaxBufferSize, expected=%d, iMaxBufferSize=%d"), expected, iFormatsSupported->iMaxBufferSize);
sl@0
   343
			SetBlockResult(EFail);
sl@0
   344
			}
sl@0
   345
		else
sl@0
   346
			{
sl@0
   347
			INFO_PRINTF3(_L("iMaxBufferSize == expected, iMaxBufferSize=%d, expected=%d"), iFormatsSupported->iMaxBufferSize, expected);
sl@0
   348
			}
sl@0
   349
		}
sl@0
   350
	else
sl@0
   351
		{
sl@0
   352
		INFO_PRINTF2(_L("iMaxBufferSize=%d"), iFormatsSupported->iMaxBufferSize);
sl@0
   353
		}
sl@0
   354
	}
sl@0
   355
sl@0
   356
/**
sl@0
   357
 * Gets iMinVolume
sl@0
   358
 * 
sl@0
   359
 * @param aSection 			section name where expected value can be read
sl@0
   360
 * 							KMinVolumeExpected - min volume expected
sl@0
   361
 *
sl@0
   362
 * @return					void
sl@0
   363
 *
sl@0
   364
 * @leave					no
sl@0
   365
 */
sl@0
   366
void CT_SoundFormatsSupportedData::DoCmd_iMinVolume_get(const TDesC& aSection)
sl@0
   367
	{
sl@0
   368
	TInt expected;
sl@0
   369
	if (GET_OPTIONAL_INT_PARAMETER(KMinVolumeExpected(), aSection, expected))
sl@0
   370
		{
sl@0
   371
		if(iFormatsSupported->iMinVolume != expected)
sl@0
   372
			{
sl@0
   373
			ERR_PRINTF3(_L("Expected result != iMinVolume, expected=%d, iMinVolume=%d"), expected, iFormatsSupported->iMinVolume);
sl@0
   374
			SetBlockResult(EFail);
sl@0
   375
			}
sl@0
   376
		else
sl@0
   377
			{
sl@0
   378
			INFO_PRINTF3(_L("iMinVolume == expected, iMinVolume=%d, expected=%d"), iFormatsSupported->iMinVolume, expected);
sl@0
   379
			}
sl@0
   380
		}
sl@0
   381
	else
sl@0
   382
		{
sl@0
   383
		INFO_PRINTF2(_L("iMinVolume=%d"), iFormatsSupported->iMinVolume);
sl@0
   384
		}
sl@0
   385
	}
sl@0
   386
sl@0
   387
/**
sl@0
   388
 * Gets iMaxVolume
sl@0
   389
 * 
sl@0
   390
 * @param aSection 			section name where expected value can be read
sl@0
   391
 * 							KMaxVolumeExpected - max volume expected
sl@0
   392
 *
sl@0
   393
 * @return					void
sl@0
   394
 *
sl@0
   395
 * @leave					no
sl@0
   396
 */
sl@0
   397
void CT_SoundFormatsSupportedData::DoCmd_iMaxVolume_get(const TDesC& aSection)
sl@0
   398
	{
sl@0
   399
	TInt	expected;
sl@0
   400
	if (GET_OPTIONAL_INT_PARAMETER(KMaxVolumeExpected(), aSection, expected))
sl@0
   401
		{
sl@0
   402
		if(iFormatsSupported->iMaxVolume != expected)
sl@0
   403
			{
sl@0
   404
			ERR_PRINTF3(_L("Expected result != iMaxVolume, expected=%d, iMaxVolume=%d"), expected, iFormatsSupported->iMaxVolume);
sl@0
   405
			SetBlockResult(EFail);
sl@0
   406
			}
sl@0
   407
		else
sl@0
   408
			{
sl@0
   409
			INFO_PRINTF3(_L("iMaxVolume == expected, iMaxVolume=%d, expected=%d"), iFormatsSupported->iMaxVolume, expected);
sl@0
   410
			}
sl@0
   411
		}
sl@0
   412
	else
sl@0
   413
		{
sl@0
   414
		INFO_PRINTF2(_L("iMaxVolume=%d"), iFormatsSupported->iMaxVolume);
sl@0
   415
		}
sl@0
   416
	}
sl@0
   417
sl@0
   418
/**
sl@0
   419
 * Gets iChannels
sl@0
   420
 * 
sl@0
   421
 * @param aSection 			section name where expected value can be read
sl@0
   422
 * 							KChannelsExpected - channels expected
sl@0
   423
 *
sl@0
   424
 * @return					void
sl@0
   425
 *
sl@0
   426
 * @leave					no
sl@0
   427
 */
sl@0
   428
void CT_SoundFormatsSupportedData::DoCmd_iChannels_get(const TDesC& aSection)
sl@0
   429
	{
sl@0
   430
	TInt	expected;	
sl@0
   431
	if (GET_OPTIONAL_INT_PARAMETER(KChannelsExpected(), aSection, expected))
sl@0
   432
		{
sl@0
   433
		if(iFormatsSupported->iChannels != expected)
sl@0
   434
			{
sl@0
   435
			ERR_PRINTF3(_L("Expected result != iChannels, expected=%d, iChannels=%d"), expected, iFormatsSupported->iChannels);
sl@0
   436
			SetBlockResult(EFail);
sl@0
   437
			}
sl@0
   438
		else
sl@0
   439
			{
sl@0
   440
			INFO_PRINTF3(_L("iChannels == expected, iChannels=%d, expected=%d"), iFormatsSupported->iChannels, expected);
sl@0
   441
			}
sl@0
   442
		}
sl@0
   443
	else
sl@0
   444
		{
sl@0
   445
		INFO_PRINTF2(_L("iChannels=%d"), iFormatsSupported->iChannels);
sl@0
   446
		}
sl@0
   447
	}
sl@0
   448
sl@0
   449
/**
sl@0
   450
 * Gets iEncodings
sl@0
   451
 * 
sl@0
   452
 * @param aSection 			section name where expected value can be read
sl@0
   453
 * 							KEncodingsExpected - encodings expected
sl@0
   454
 *
sl@0
   455
 * @return					void
sl@0
   456
 *
sl@0
   457
 * @leave					System wide error
sl@0
   458
 */
sl@0
   459
void CT_SoundFormatsSupportedData::DoCmd_iEncodings_getL(const TDesC& aSection)
sl@0
   460
	{
sl@0
   461
	TUint expEncoding;
sl@0
   462
	if(GetOrFromConfig(aSection, KEncodingsExpected(), TSoundUtil::iEnumTableSoundEncoding, expEncoding ))
sl@0
   463
		{
sl@0
   464
		TUint encodings = iFormatsSupported->iEncodings;
sl@0
   465
		if(encodings != expEncoding)
sl@0
   466
			{
sl@0
   467
			ERR_PRINTF3(_L("iEncodings != expected result! iEncodings=0x%x, expected result=0x%x"), encodings, expEncoding);
sl@0
   468
			SetBlockResult(EFail);
sl@0
   469
			}
sl@0
   470
		else
sl@0
   471
			{
sl@0
   472
			INFO_PRINTF3(_L("iEncodings == expected result!, iEncodings=0x%x, expected=0x%x"), encodings, expEncoding);
sl@0
   473
			}
sl@0
   474
		}
sl@0
   475
	else
sl@0
   476
		{
sl@0
   477
		INFO_PRINTF2(_L("iEncodings=%d"), iFormatsSupported->iEncodings);
sl@0
   478
		}
sl@0
   479
	}