os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/TSI_MMFACLNT.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/TSI_MMFACLNT.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,287 @@
     1.4 +
     1.5 +// Copyright (c) 2002-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 +// This program is designed to test the MMF_ACLNT.
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +/**
    1.23 + @file TSI_MMFACLNT.cpp
    1.24 +*/
    1.25 +#include <mda/common/audio.h>
    1.26 +#include <mda/common/gsmaudio.h>
    1.27 +#include "TSI_MMFACLNT.h"
    1.28 +#include "TSI_MMFACLNT.inl"
    1.29 +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    1.30 +#include <mda/common/mdagsmwavcodec.h>
    1.31 +#endif
    1.32 +
    1.33 +void CPlayerCallbackHandler::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/) 
    1.34 +	{ 
    1.35 +	iMchObserver->MchoComplete(ID(),aError); 
    1.36 +	}
    1.37 +
    1.38 +void CPlayerCallbackHandler::MapcPlayComplete(TInt aError)
    1.39 +	{
    1.40 +	iMchObserver->MchoComplete(ID(),aError); 
    1.41 +	}
    1.42 +
    1.43 +void CStateCallbackHandler::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt aErrorCode)
    1.44 +	{
    1.45 +	iMchObserver->MchoComplete(ID(),aErrorCode); 
    1.46 +	}
    1.47 +
    1.48 +void CToneCallbackHandler::MatoPrepareComplete(TInt aError)
    1.49 +	{ 
    1.50 +	iMchObserver->MchoComplete(ID(),aError); 
    1.51 +	}
    1.52 +
    1.53 +void CToneCallbackHandler::MatoPlayComplete(TInt aError)
    1.54 +	{ 
    1.55 +	iMchObserver->MchoComplete(ID(),aError); 
    1.56 +	}
    1.57 +
    1.58 +/**
    1.59 + * Timeout function
    1.60 + */
    1.61 +void CTestMmfAclntStep::WaitWithTimeout(TRequestStatus& aStatus, TInt aNumberOfMicroSeconds)
    1.62 +	{
    1.63 +	TRequestStatus timerStatus;
    1.64 +	RTimer timer ;
    1.65 +	timer.CreateLocal() ;
    1.66 +	timer.After(timerStatus,aNumberOfMicroSeconds);
    1.67 +
    1.68 +	User::WaitForRequest(aStatus, timerStatus);
    1.69 +	if (timerStatus == KRequestPending)
    1.70 +		{
    1.71 +		timer.Cancel();
    1.72 +		User::WaitForRequest(timerStatus);
    1.73 +		}
    1.74 +	else
    1.75 +		{
    1.76 +		INFO_PRINTF1(_L("Time is over!!!")) ;
    1.77 +		}
    1.78 +	timer.Close() ;
    1.79 +	}
    1.80 +
    1.81 +/**
    1.82 + * Time comparison utility function
    1.83 + *
    1.84 + * @param	"const TUint aActual"
    1.85 + *			The actual timer value produced
    1.86 + * @param	"const TUint aExpected"
    1.87 + *			Expected timer value
    1.88 + * @param	"const TUint aDeviation"
    1.89 + *			Allowed deviation of the expected value
    1.90 + *			from the actual value.
    1.91 + * @return	"TBool"
    1.92 + *			Did actual timed value fall within deviation limits
    1.93 + */ 
    1.94 +TBool CTestMmfAclntStep::TimeComparison(const TUint aActual, const TUint aExpected, const TUint aDeviation)
    1.95 +	{
    1.96 +	// save unnessary conditions
    1.97 +	if(aActual == aExpected)
    1.98 +		return ETrue;	
    1.99 +
   1.100 +	// Prevent unsigned wrapping errors 
   1.101 +	TUint difference;
   1.102 +	if(aActual > aExpected)
   1.103 +		difference = aActual - aExpected;
   1.104 +	else
   1.105 +		difference = aExpected - aActual;
   1.106 +
   1.107 +	// comapare
   1.108 +	if(difference < aDeviation)
   1.109 +		return ETrue;
   1.110 +	return EFalse;
   1.111 +	}
   1.112 +
   1.113 +/**
   1.114 + * Test Preample routines.
   1.115 + *
   1.116 + * Creates our own Active Scheduler.
   1.117 + *
   1.118 + * @return	"TVerdict"
   1.119 + *			Did Preamble complete.
   1.120 + */
   1.121 +TVerdict CTestMmfAclntStep::DoTestStepPreambleL()
   1.122 +	{
   1.123 +
   1.124 +	iActiveScheduler = new(ELeave) CActiveScheduler;
   1.125 +	CActiveScheduler::Install(iActiveScheduler);
   1.126 +	
   1.127 +	
   1.128 +	return EPass;
   1.129 +	}
   1.130 +
   1.131 +/**
   1.132 + * Test Postamble routines.
   1.133 + *
   1.134 + * Destroys our Active Scheduler.
   1.135 + *
   1.136 + * @return	"TVerdict"
   1.137 + *			Did Postamble complete.
   1.138 + */
   1.139 +TVerdict CTestMmfAclntStep::DoTestStepPostambleL()
   1.140 +	{
   1.141 +	delete iActiveScheduler;
   1.142 +	iActiveScheduler = NULL;
   1.143 +
   1.144 +	return EPass;
   1.145 +	}
   1.146 +
   1.147 +/**
   1.148 + * CTestMMFACLNTStep Implementation
   1.149 + *
   1.150 + * @parameter	"const CTestSuite* aTestSuite"
   1.151 + *				Sets test suite pointer
   1.152 + */
   1.153 +void CTestMmfAclntStep::SetTestSuite(const CTestSuite* aTestSuite )
   1.154 +	{
   1.155 +	iTestSuite = aTestSuite; 
   1.156 +	}  
   1.157 +
   1.158 +/**
   1.159 + * CTestMMFACLNTStep Implementation
   1.160 + */
   1.161 +CTestMmfAclntStep::CTestMmfAclntStep()
   1.162 +	:iActiveScheduler( NULL )
   1.163 +	{}
   1.164 +
   1.165 +//------------------------------------------------------
   1.166 +
   1.167 +/**
   1.168 + * Deconstructors destroys iFormat and iCodec
   1.169 + *
   1.170 + */
   1.171 +TVerdict CTestMmfAclntCodecTest::DoTestStepPostambleL()
   1.172 +	{
   1.173 +	if(iFormat != NULL)
   1.174 +		{
   1.175 +		delete iFormat;
   1.176 +		iFormat = NULL;
   1.177 +		}
   1.178 +	if(iCodec != NULL)
   1.179 +		{
   1.180 +		delete iCodec;
   1.181 +		iCodec = NULL;
   1.182 +		}
   1.183 +	return CTestMmfAclntStep::DoTestStepPostambleL();
   1.184 +	}
   1.185 +
   1.186 +/**
   1.187 + * Setup codec and format to test
   1.188 + *
   1.189 + * @parameter	"const TTestFormat aFormat"
   1.190 + *				enum of format to use
   1.191 + */
   1.192 +void CTestMmfAclntCodecTest::SetupFormatL(const TTestFormat aFormat)
   1.193 +	{
   1.194 +	if(iFormat)
   1.195 +		delete iFormat;
   1.196 +	if(iCodec)
   1.197 +		delete iCodec;
   1.198 +	iFormat = NULL;
   1.199 +	iCodec = NULL;
   1.200 +
   1.201 +	switch(aFormat)
   1.202 +		{
   1.203 +	case EPcm16Wav:
   1.204 +		iFormat = new (ELeave) TMdaWavClipFormat;
   1.205 +		CleanupStack::PushL(iFormat);
   1.206 +		iCodec = new (ELeave) TMdaPcmWavCodec;
   1.207 +		CleanupStack::PushL(iCodec);
   1.208 +		break;
   1.209 +	case EMulawRaw:
   1.210 +		iFormat = new (ELeave) TMdaRawAudioClipFormat;
   1.211 +		CleanupStack::PushL(iFormat);
   1.212 +		iCodec = new (ELeave) TMdaAlawRawAudioCodec;
   1.213 +		CleanupStack::PushL(iCodec);
   1.214 +		break;
   1.215 +	case E16BitAu:
   1.216 +		iFormat = new (ELeave) TMdaAuClipFormat;
   1.217 +		CleanupStack::PushL(iFormat);
   1.218 +		iCodec = new (ELeave) TMdaAuCodec;
   1.219 +		CleanupStack::PushL(iCodec);
   1.220 +		break;
   1.221 +	case EAlawAu:
   1.222 +		iFormat = new (ELeave) TMdaAuClipFormat;
   1.223 +		CleanupStack::PushL(iFormat);
   1.224 +		iCodec = new (ELeave) TMdaAlawAuCodec;
   1.225 +		CleanupStack::PushL(iCodec);
   1.226 +		break;
   1.227 +	case EPcm16Au:
   1.228 +		iFormat = new (ELeave) TMdaAuClipFormat;
   1.229 +		CleanupStack::PushL(iFormat);
   1.230 +		iCodec = new (ELeave) TMdaPcm16BitAuCodec;
   1.231 +		CleanupStack::PushL(iCodec);
   1.232 +		break;
   1.233 +	case EImaAdpcmWav:
   1.234 +		iFormat = new (ELeave) TMdaWavClipFormat;
   1.235 +		CleanupStack::PushL(iFormat);
   1.236 +		iCodec = new (ELeave) TMdaImaAdpcmWavCodec;
   1.237 +		CleanupStack::PushL(iCodec);
   1.238 +		break;
   1.239 +	case EAlawWav:
   1.240 +		iFormat = new (ELeave) TMdaWavClipFormat;
   1.241 +		CleanupStack::PushL(iFormat);
   1.242 +		iCodec = new (ELeave) TMdaAlawWavCodec;
   1.243 +		CleanupStack::PushL(iCodec);
   1.244 +		break;
   1.245 +	case EPcmU16:
   1.246 +		iFormat = new (ELeave) TMdaRawAudioClipFormat();
   1.247 +		CleanupStack::PushL(iFormat);
   1.248 +		iCodec = new (ELeave) TMdaUB16RawAudioCodec();
   1.249 +		CleanupStack::PushL(iCodec);
   1.250 +		break;
   1.251 +	case EPcmU8:
   1.252 +		iFormat = new (ELeave) TMdaRawAudioClipFormat();
   1.253 +		CleanupStack::PushL(iFormat);
   1.254 +		iCodec = new (ELeave) TMdaU8PcmRawAudioCodec();
   1.255 +		CleanupStack::PushL(iCodec);
   1.256 +		break;
   1.257 +	case EImasPcmWav:
   1.258 +		iFormat = new (ELeave) TMdaWavClipFormat();
   1.259 +		CleanupStack::PushL(iFormat);
   1.260 +		iCodec = new (ELeave) TMdaImaAdpcmWavCodec();
   1.261 +		CleanupStack::PushL(iCodec);
   1.262 +		break;
   1.263 +	case EPcm8:
   1.264 +		iFormat = new (ELeave) TMdaWavClipFormat();
   1.265 +		CleanupStack::PushL(iFormat);
   1.266 +		iCodec = new (ELeave) TMdaPcmWavCodec(TMdaPcmWavCodec::E8BitPcm);
   1.267 +		CleanupStack::PushL(iCodec);
   1.268 +		break;
   1.269 +	case EGsmWav:
   1.270 +		iFormat = new (ELeave) TMdaWavClipFormat;
   1.271 +		CleanupStack::PushL(iFormat);
   1.272 +		iCodec = new (ELeave) TMdaGsmWavCodec;
   1.273 +		CleanupStack::PushL(iCodec);
   1.274 +		break;
   1.275 +	case EEpocWve:
   1.276 +	case ENone:
   1.277 +	default:
   1.278 +		// will create an inconlusive result as preamble leaves.
   1.279 +		iFormat = NULL;
   1.280 +		iCodec = NULL;
   1.281 +		break;
   1.282 +		}
   1.283 +
   1.284 +	if((iFormat != NULL) && (iCodec != NULL))
   1.285 +		{
   1.286 +		CleanupStack::Pop(); // iFormat
   1.287 +		CleanupStack::Pop(); // iCodec
   1.288 +		}		
   1.289 +	}
   1.290 +