os/boardsupport/haitest/bspsvs/suite/bsp/sound/src/t_soundformatssupporteddata.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/boardsupport/haitest/bspsvs/suite/bsp/sound/src/t_soundformatssupporteddata.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,479 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +/**
1.22 +@test
1.23 +@internalComponent
1.24 +
1.25 +This contains CT_SoundFormatsSupportedData
1.26 +*/
1.27 +
1.28 +// User includes
1.29 +#include "t_soundformatssupporteddata.h"
1.30 +#include "sound_util.h"
1.31 +
1.32 +/*@{*/
1.33 +/// Commands
1.34 +_LIT(KCmdNew, "new");
1.35 +_LIT(KCmdDestructor, "~");
1.36 +_LIT(KCmd_iMinRate_get, "imin_rate_get");
1.37 +_LIT(KCmd_iMaxRate_get, "imax_rate_get");
1.38 +_LIT(KCmd_iChannels_get, "ichannels_get");
1.39 +_LIT(KCmd_iMinBufferSize_get, "imin_buffer_size_get");
1.40 +_LIT(KCmd_iMaxBufferSize_get, "imax_buffer_size_get");
1.41 +_LIT(KCmd_iMinVolume_get, "imin_volume_get");
1.42 +_LIT(KCmd_iMaxVolume_get, "imax_volume_get");
1.43 +_LIT(KCmd_iEncodings_get, "iencodings_get");
1.44 +
1.45 +/*@{*/
1.46 +/// Parameters
1.47 +_LIT(KMinRateExpected, "min_rate_expected");
1.48 +_LIT(KMaxRateExpected, "max_rate_expected");
1.49 +_LIT(KChannelsExpected, "channels_expected");
1.50 +_LIT(KMinBufferSizeExpected, "min_buffer_size_expected");
1.51 +_LIT(KMaxBufferSizeExpected, "max_buffer_size_expected");
1.52 +_LIT(KMinVolumeExpected, "min_volume_expected");
1.53 +_LIT(KMaxVolumeExpected, "max_volume_expected");
1.54 +_LIT(KEncodingsExpected, "encodings_expected");
1.55 +
1.56 +/// Logging
1.57 +_LIT(KLogNew, "New object created successfully");
1.58 +_LIT(KLogNewError, "Error creating new object, error code=%d");
1.59 +
1.60 +/**
1.61 + * Two phase constructor
1.62 + */
1.63 +CT_SoundFormatsSupportedData* CT_SoundFormatsSupportedData::NewL()
1.64 + {
1.65 + CT_SoundFormatsSupportedData* ret=new (ELeave) CT_SoundFormatsSupportedData();
1.66 + CleanupStack::PushL(ret);
1.67 + ret->ConstructL();
1.68 + CleanupStack::Pop(ret);
1.69 + return ret;
1.70 + }
1.71 +
1.72 +/**
1.73 +* Constructor. First phase construction
1.74 +*/
1.75 +CT_SoundFormatsSupportedData::CT_SoundFormatsSupportedData()
1.76 +: CDataWrapperBase()
1.77 +, iFormatsSupported(NULL)
1.78 + {
1.79 + }
1.80 +
1.81 +/**
1.82 + * Second phase construction
1.83 + */
1.84 +void CT_SoundFormatsSupportedData::ConstructL()
1.85 + {
1.86 + }
1.87 +
1.88 +/**
1.89 +* Destructor
1.90 +*/
1.91 +CT_SoundFormatsSupportedData::~CT_SoundFormatsSupportedData()
1.92 + {
1.93 + DoCleanup();
1.94 + }
1.95 +
1.96 +/**
1.97 + * Helper for cleanup operation
1.98 + */
1.99 +void CT_SoundFormatsSupportedData::DoCleanup()
1.100 + {
1.101 + delete iFormatsSupported;
1.102 + iFormatsSupported=NULL;
1.103 + }
1.104 +
1.105 +/**
1.106 + * Return a pointer to the object that the data wraps
1.107 + *
1.108 + * @return pointer to the object that the data wraps
1.109 + */
1.110 +TAny* CT_SoundFormatsSupportedData::GetObject()
1.111 + {
1.112 + return iFormatsSupported;
1.113 + }
1.114 +
1.115 +/**
1.116 + * Set the wrapped data object with new value
1.117 + */
1.118 +void CT_SoundFormatsSupportedData::SetObjectL(TAny* aAny)
1.119 + {
1.120 + DoCleanup();
1.121 + iFormatsSupported=static_cast<RMdaDevSound::TSoundFormatsSupported*>(aAny);
1.122 + }
1.123 +
1.124 +/**
1.125 + * Clear the wrapped data object pointer w/o de-initialization
1.126 + */
1.127 +void CT_SoundFormatsSupportedData::DisownObjectL()
1.128 + {
1.129 + iFormatsSupported=NULL;
1.130 + }
1.131 +
1.132 +/**
1.133 + * Return static cleanup function
1.134 + */
1.135 +inline TCleanupOperation CT_SoundFormatsSupportedData::CleanupOperation()
1.136 + {
1.137 + return CleanupOperation;
1.138 + }
1.139 +
1.140 +/**
1.141 + * Static cleanup function
1.142 + */
1.143 +void CT_SoundFormatsSupportedData::CleanupOperation( TAny* aAny )
1.144 + {
1.145 + RMdaDevSound::TSoundFormatsSupported* format = static_cast<RMdaDevSound::TSoundFormatsSupported*> ( aAny );
1.146 + delete format;
1.147 + }
1.148 +
1.149 +/**
1.150 +* Process a command read from the ini file
1.151 +*
1.152 +* @param aDataWrapper test step requiring command to be processed
1.153 +* @param aCommand the command to process
1.154 +* @param aSection the entry in the ini file requiring the command to be processed
1.155 +*
1.156 +* @return ETrue if the command is processed
1.157 +*/
1.158 +TBool CT_SoundFormatsSupportedData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
1.159 + {
1.160 + TBool ret=ETrue;
1.161 + if ( aCommand==KCmdNew )
1.162 + {
1.163 + DoCmdNew();
1.164 + }
1.165 + else if ( aCommand==KCmdDestructor )
1.166 + {
1.167 + DoCmdDestructor();
1.168 + }
1.169 + else if ( aCommand==KCmd_iMinRate_get )
1.170 + {
1.171 + DoCmd_iMinRate_get(aSection);
1.172 + }
1.173 + else if ( aCommand==KCmd_iMaxRate_get )
1.174 + {
1.175 + DoCmd_iMaxRate_get(aSection);
1.176 + }
1.177 + else if ( aCommand==KCmd_iChannels_get )
1.178 + {
1.179 + DoCmd_iChannels_get(aSection);
1.180 + }
1.181 + else if ( aCommand==KCmd_iMinBufferSize_get )
1.182 + {
1.183 + DoCmd_iMinBufferSize_get(aSection);
1.184 + }
1.185 + else if ( aCommand==KCmd_iMaxBufferSize_get )
1.186 + {
1.187 + DoCmd_iMaxBufferSize_get(aSection);
1.188 + }
1.189 + else if ( aCommand==KCmd_iMinVolume_get )
1.190 + {
1.191 + DoCmd_iMinVolume_get(aSection);
1.192 + }
1.193 + else if ( aCommand==KCmd_iMaxVolume_get )
1.194 + {
1.195 + DoCmd_iMaxVolume_get(aSection);
1.196 + }
1.197 + else if ( aCommand==KCmd_iEncodings_get )
1.198 + {
1.199 + DoCmd_iEncodings_getL(aSection);
1.200 + }
1.201 + else
1.202 + {
1.203 + ret=CDataWrapperBase::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
1.204 + }
1.205 +
1.206 + return ret;
1.207 + }
1.208 +
1.209 +/**
1.210 + * Creates new instance of TSoundFormatsSupported
1.211 + */
1.212 +void CT_SoundFormatsSupportedData::DoCmdNew()
1.213 + {
1.214 + DoCleanup();
1.215 + TRAPD(err, iFormatsSupported = new (ELeave) RMdaDevSound::TSoundFormatsSupported());
1.216 + if ( err!=KErrNone )
1.217 + {
1.218 + ERR_PRINTF2(KLogNewError, err);
1.219 + SetError(err);
1.220 + }
1.221 + else
1.222 + {
1.223 + INFO_PRINTF1(KLogNew);
1.224 + }
1.225 + }
1.226 +
1.227 +/**
1.228 + * Performs cleanup operation
1.229 + */
1.230 +void CT_SoundFormatsSupportedData::DoCmdDestructor()
1.231 + {
1.232 + DoCleanup();
1.233 + }
1.234 +
1.235 +/**
1.236 + * Gets iMinRate
1.237 + *
1.238 + * @param aSection section name where expected value can be read
1.239 + * KMinRateExpected - min rate expected
1.240 + *
1.241 + * @return void
1.242 + *
1.243 + * @leave no
1.244 + */
1.245 +void CT_SoundFormatsSupportedData::DoCmd_iMinRate_get(const TDesC& aSection)
1.246 + {
1.247 + TInt expected;
1.248 + if (GET_OPTIONAL_INT_PARAMETER(KMinRateExpected(), aSection, expected))
1.249 + {
1.250 + if(iFormatsSupported->iMinRate != expected)
1.251 + {
1.252 + ERR_PRINTF3(_L("Expected result != iMinRate, expected=%d, iMinRate=%d"), expected, iFormatsSupported->iMinRate);
1.253 + SetBlockResult(EFail);
1.254 + }
1.255 + else
1.256 + {
1.257 + INFO_PRINTF3(_L("iMinRate == expected, iMinRate=%d, expected=%d"), iFormatsSupported->iMinRate, expected);
1.258 + }
1.259 + }
1.260 + else
1.261 + {
1.262 + INFO_PRINTF2(_L("iMinRate=%d"), iFormatsSupported->iMinRate);
1.263 + }
1.264 + }
1.265 +
1.266 +/**
1.267 + * Gets iMaxRate
1.268 + *
1.269 + * @param aSection section name where expected value can be read
1.270 + * KMaxRateExpected - max rate expected
1.271 + *
1.272 + * @return void
1.273 + *
1.274 + * @leave no
1.275 + */
1.276 +void CT_SoundFormatsSupportedData::DoCmd_iMaxRate_get(const TDesC& aSection)
1.277 + {
1.278 + TInt expected;
1.279 + if (GET_OPTIONAL_INT_PARAMETER(KMaxRateExpected(), aSection, expected))
1.280 + {
1.281 + if(iFormatsSupported->iMaxRate != expected)
1.282 + {
1.283 + ERR_PRINTF3(_L("Expected result != iMaxRate, expected=%d, iMaxRate=%d"), expected, iFormatsSupported->iMaxRate);
1.284 + SetBlockResult(EFail);
1.285 + }
1.286 + else
1.287 + {
1.288 + INFO_PRINTF3(_L("iMaxRate == expected, iMaxRate=%d, expected=%d"), iFormatsSupported->iMaxRate, expected);
1.289 + }
1.290 + }
1.291 + else
1.292 + {
1.293 + INFO_PRINTF2(_L("iMaxRate=%d"), iFormatsSupported->iMaxRate);
1.294 + }
1.295 + }
1.296 +
1.297 +/**
1.298 + * Gets iMinBufferSize
1.299 + *
1.300 + * @param aSection section name where expected value can be read
1.301 + * KMinBufferSizeExpected - min buffer size expected
1.302 + *
1.303 + * @return void
1.304 + *
1.305 + * @leave no
1.306 + */
1.307 +void CT_SoundFormatsSupportedData::DoCmd_iMinBufferSize_get(const TDesC& aSection)
1.308 + {
1.309 + TInt expected;
1.310 + if (GET_OPTIONAL_INT_PARAMETER(KMinBufferSizeExpected(), aSection, expected))
1.311 + {
1.312 + if(iFormatsSupported->iMinBufferSize != expected)
1.313 + {
1.314 + ERR_PRINTF3(_L("Expected result != iMinBufferSize, expected=%d, iMinBufferSize=%d"), expected, iFormatsSupported->iMinBufferSize);
1.315 + SetBlockResult(EFail);
1.316 + }
1.317 + else
1.318 + {
1.319 + INFO_PRINTF3(_L("iMinBufferSize == expected, iMinBufferSize=%d, expected=%d"), iFormatsSupported->iMinBufferSize, expected);
1.320 + }
1.321 + }
1.322 + else
1.323 + {
1.324 + INFO_PRINTF2(_L("iMinBufferSize=%d"), iFormatsSupported->iMinBufferSize);
1.325 + }
1.326 + }
1.327 +
1.328 +/**
1.329 + * Gets iMaxBufferSize
1.330 + *
1.331 + * @param aSection section name where expected value can be read
1.332 + * KMaxBufferSizeExpected - max buffer size expected
1.333 + *
1.334 + * @return void
1.335 + *
1.336 + * @leave no
1.337 + */
1.338 +void CT_SoundFormatsSupportedData::DoCmd_iMaxBufferSize_get(const TDesC& aSection)
1.339 + {
1.340 + TInt expected;
1.341 + if (GET_OPTIONAL_INT_PARAMETER(KMaxBufferSizeExpected(), aSection, expected))
1.342 + {
1.343 + if(iFormatsSupported->iMaxBufferSize != expected)
1.344 + {
1.345 + ERR_PRINTF3(_L("Expected result != iMaxBufferSize, expected=%d, iMaxBufferSize=%d"), expected, iFormatsSupported->iMaxBufferSize);
1.346 + SetBlockResult(EFail);
1.347 + }
1.348 + else
1.349 + {
1.350 + INFO_PRINTF3(_L("iMaxBufferSize == expected, iMaxBufferSize=%d, expected=%d"), iFormatsSupported->iMaxBufferSize, expected);
1.351 + }
1.352 + }
1.353 + else
1.354 + {
1.355 + INFO_PRINTF2(_L("iMaxBufferSize=%d"), iFormatsSupported->iMaxBufferSize);
1.356 + }
1.357 + }
1.358 +
1.359 +/**
1.360 + * Gets iMinVolume
1.361 + *
1.362 + * @param aSection section name where expected value can be read
1.363 + * KMinVolumeExpected - min volume expected
1.364 + *
1.365 + * @return void
1.366 + *
1.367 + * @leave no
1.368 + */
1.369 +void CT_SoundFormatsSupportedData::DoCmd_iMinVolume_get(const TDesC& aSection)
1.370 + {
1.371 + TInt expected;
1.372 + if (GET_OPTIONAL_INT_PARAMETER(KMinVolumeExpected(), aSection, expected))
1.373 + {
1.374 + if(iFormatsSupported->iMinVolume != expected)
1.375 + {
1.376 + ERR_PRINTF3(_L("Expected result != iMinVolume, expected=%d, iMinVolume=%d"), expected, iFormatsSupported->iMinVolume);
1.377 + SetBlockResult(EFail);
1.378 + }
1.379 + else
1.380 + {
1.381 + INFO_PRINTF3(_L("iMinVolume == expected, iMinVolume=%d, expected=%d"), iFormatsSupported->iMinVolume, expected);
1.382 + }
1.383 + }
1.384 + else
1.385 + {
1.386 + INFO_PRINTF2(_L("iMinVolume=%d"), iFormatsSupported->iMinVolume);
1.387 + }
1.388 + }
1.389 +
1.390 +/**
1.391 + * Gets iMaxVolume
1.392 + *
1.393 + * @param aSection section name where expected value can be read
1.394 + * KMaxVolumeExpected - max volume expected
1.395 + *
1.396 + * @return void
1.397 + *
1.398 + * @leave no
1.399 + */
1.400 +void CT_SoundFormatsSupportedData::DoCmd_iMaxVolume_get(const TDesC& aSection)
1.401 + {
1.402 + TInt expected;
1.403 + if (GET_OPTIONAL_INT_PARAMETER(KMaxVolumeExpected(), aSection, expected))
1.404 + {
1.405 + if(iFormatsSupported->iMaxVolume != expected)
1.406 + {
1.407 + ERR_PRINTF3(_L("Expected result != iMaxVolume, expected=%d, iMaxVolume=%d"), expected, iFormatsSupported->iMaxVolume);
1.408 + SetBlockResult(EFail);
1.409 + }
1.410 + else
1.411 + {
1.412 + INFO_PRINTF3(_L("iMaxVolume == expected, iMaxVolume=%d, expected=%d"), iFormatsSupported->iMaxVolume, expected);
1.413 + }
1.414 + }
1.415 + else
1.416 + {
1.417 + INFO_PRINTF2(_L("iMaxVolume=%d"), iFormatsSupported->iMaxVolume);
1.418 + }
1.419 + }
1.420 +
1.421 +/**
1.422 + * Gets iChannels
1.423 + *
1.424 + * @param aSection section name where expected value can be read
1.425 + * KChannelsExpected - channels expected
1.426 + *
1.427 + * @return void
1.428 + *
1.429 + * @leave no
1.430 + */
1.431 +void CT_SoundFormatsSupportedData::DoCmd_iChannels_get(const TDesC& aSection)
1.432 + {
1.433 + TInt expected;
1.434 + if (GET_OPTIONAL_INT_PARAMETER(KChannelsExpected(), aSection, expected))
1.435 + {
1.436 + if(iFormatsSupported->iChannels != expected)
1.437 + {
1.438 + ERR_PRINTF3(_L("Expected result != iChannels, expected=%d, iChannels=%d"), expected, iFormatsSupported->iChannels);
1.439 + SetBlockResult(EFail);
1.440 + }
1.441 + else
1.442 + {
1.443 + INFO_PRINTF3(_L("iChannels == expected, iChannels=%d, expected=%d"), iFormatsSupported->iChannels, expected);
1.444 + }
1.445 + }
1.446 + else
1.447 + {
1.448 + INFO_PRINTF2(_L("iChannels=%d"), iFormatsSupported->iChannels);
1.449 + }
1.450 + }
1.451 +
1.452 +/**
1.453 + * Gets iEncodings
1.454 + *
1.455 + * @param aSection section name where expected value can be read
1.456 + * KEncodingsExpected - encodings expected
1.457 + *
1.458 + * @return void
1.459 + *
1.460 + * @leave System wide error
1.461 + */
1.462 +void CT_SoundFormatsSupportedData::DoCmd_iEncodings_getL(const TDesC& aSection)
1.463 + {
1.464 + TUint expEncoding;
1.465 + if(GetOrFromConfig(aSection, KEncodingsExpected(), TSoundUtil::iEnumTableSoundEncoding, expEncoding ))
1.466 + {
1.467 + TUint encodings = iFormatsSupported->iEncodings;
1.468 + if(encodings != expEncoding)
1.469 + {
1.470 + ERR_PRINTF3(_L("iEncodings != expected result! iEncodings=0x%x, expected result=0x%x"), encodings, expEncoding);
1.471 + SetBlockResult(EFail);
1.472 + }
1.473 + else
1.474 + {
1.475 + INFO_PRINTF3(_L("iEncodings == expected result!, iEncodings=0x%x, expected=0x%x"), encodings, expEncoding);
1.476 + }
1.477 + }
1.478 + else
1.479 + {
1.480 + INFO_PRINTF2(_L("iEncodings=%d"), iFormatsSupported->iEncodings);
1.481 + }
1.482 + }