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