mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/TSI_MMFACLNT.cpp
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 
       
     2 // Copyright (c) 2002-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 // This program is designed to test the MMF_ACLNT.
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file TSI_MMFACLNT.cpp
       
    21 */
       
    22 #include <mda/common/audio.h>
       
    23 #include <mda/common/gsmaudio.h>
       
    24 #include "TSI_MMFACLNT.h"
       
    25 #include "TSI_MMFACLNT.inl"
       
    26 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    27 #include <mda/common/mdagsmwavcodec.h>
       
    28 #endif
       
    29 
       
    30 void CPlayerCallbackHandler::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/) 
       
    31 	{ 
       
    32 	iMchObserver->MchoComplete(ID(),aError); 
       
    33 	}
       
    34 
       
    35 void CPlayerCallbackHandler::MapcPlayComplete(TInt aError)
       
    36 	{
       
    37 	iMchObserver->MchoComplete(ID(),aError); 
       
    38 	}
       
    39 
       
    40 void CStateCallbackHandler::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt aErrorCode)
       
    41 	{
       
    42 	iMchObserver->MchoComplete(ID(),aErrorCode); 
       
    43 	}
       
    44 
       
    45 void CToneCallbackHandler::MatoPrepareComplete(TInt aError)
       
    46 	{ 
       
    47 	iMchObserver->MchoComplete(ID(),aError); 
       
    48 	}
       
    49 
       
    50 void CToneCallbackHandler::MatoPlayComplete(TInt aError)
       
    51 	{ 
       
    52 	iMchObserver->MchoComplete(ID(),aError); 
       
    53 	}
       
    54 
       
    55 /**
       
    56  * Timeout function
       
    57  */
       
    58 void CTestMmfAclntStep::WaitWithTimeout(TRequestStatus& aStatus, TInt aNumberOfMicroSeconds)
       
    59 	{
       
    60 	TRequestStatus timerStatus;
       
    61 	RTimer timer ;
       
    62 	timer.CreateLocal() ;
       
    63 	timer.After(timerStatus,aNumberOfMicroSeconds);
       
    64 
       
    65 	User::WaitForRequest(aStatus, timerStatus);
       
    66 	if (timerStatus == KRequestPending)
       
    67 		{
       
    68 		timer.Cancel();
       
    69 		User::WaitForRequest(timerStatus);
       
    70 		}
       
    71 	else
       
    72 		{
       
    73 		INFO_PRINTF1(_L("Time is over!!!")) ;
       
    74 		}
       
    75 	timer.Close() ;
       
    76 	}
       
    77 
       
    78 /**
       
    79  * Time comparison utility function
       
    80  *
       
    81  * @param	"const TUint aActual"
       
    82  *			The actual timer value produced
       
    83  * @param	"const TUint aExpected"
       
    84  *			Expected timer value
       
    85  * @param	"const TUint aDeviation"
       
    86  *			Allowed deviation of the expected value
       
    87  *			from the actual value.
       
    88  * @return	"TBool"
       
    89  *			Did actual timed value fall within deviation limits
       
    90  */ 
       
    91 TBool CTestMmfAclntStep::TimeComparison(const TUint aActual, const TUint aExpected, const TUint aDeviation)
       
    92 	{
       
    93 	// save unnessary conditions
       
    94 	if(aActual == aExpected)
       
    95 		return ETrue;	
       
    96 
       
    97 	// Prevent unsigned wrapping errors 
       
    98 	TUint difference;
       
    99 	if(aActual > aExpected)
       
   100 		difference = aActual - aExpected;
       
   101 	else
       
   102 		difference = aExpected - aActual;
       
   103 
       
   104 	// comapare
       
   105 	if(difference < aDeviation)
       
   106 		return ETrue;
       
   107 	return EFalse;
       
   108 	}
       
   109 
       
   110 /**
       
   111  * Test Preample routines.
       
   112  *
       
   113  * Creates our own Active Scheduler.
       
   114  *
       
   115  * @return	"TVerdict"
       
   116  *			Did Preamble complete.
       
   117  */
       
   118 TVerdict CTestMmfAclntStep::DoTestStepPreambleL()
       
   119 	{
       
   120 
       
   121 	iActiveScheduler = new(ELeave) CActiveScheduler;
       
   122 	CActiveScheduler::Install(iActiveScheduler);
       
   123 	
       
   124 	
       
   125 	return EPass;
       
   126 	}
       
   127 
       
   128 /**
       
   129  * Test Postamble routines.
       
   130  *
       
   131  * Destroys our Active Scheduler.
       
   132  *
       
   133  * @return	"TVerdict"
       
   134  *			Did Postamble complete.
       
   135  */
       
   136 TVerdict CTestMmfAclntStep::DoTestStepPostambleL()
       
   137 	{
       
   138 	delete iActiveScheduler;
       
   139 	iActiveScheduler = NULL;
       
   140 
       
   141 	return EPass;
       
   142 	}
       
   143 
       
   144 /**
       
   145  * CTestMMFACLNTStep Implementation
       
   146  *
       
   147  * @parameter	"const CTestSuite* aTestSuite"
       
   148  *				Sets test suite pointer
       
   149  */
       
   150 void CTestMmfAclntStep::SetTestSuite(const CTestSuite* aTestSuite )
       
   151 	{
       
   152 	iTestSuite = aTestSuite; 
       
   153 	}  
       
   154 
       
   155 /**
       
   156  * CTestMMFACLNTStep Implementation
       
   157  */
       
   158 CTestMmfAclntStep::CTestMmfAclntStep()
       
   159 	:iActiveScheduler( NULL )
       
   160 	{}
       
   161 
       
   162 //------------------------------------------------------
       
   163 
       
   164 /**
       
   165  * Deconstructors destroys iFormat and iCodec
       
   166  *
       
   167  */
       
   168 TVerdict CTestMmfAclntCodecTest::DoTestStepPostambleL()
       
   169 	{
       
   170 	if(iFormat != NULL)
       
   171 		{
       
   172 		delete iFormat;
       
   173 		iFormat = NULL;
       
   174 		}
       
   175 	if(iCodec != NULL)
       
   176 		{
       
   177 		delete iCodec;
       
   178 		iCodec = NULL;
       
   179 		}
       
   180 	return CTestMmfAclntStep::DoTestStepPostambleL();
       
   181 	}
       
   182 
       
   183 /**
       
   184  * Setup codec and format to test
       
   185  *
       
   186  * @parameter	"const TTestFormat aFormat"
       
   187  *				enum of format to use
       
   188  */
       
   189 void CTestMmfAclntCodecTest::SetupFormatL(const TTestFormat aFormat)
       
   190 	{
       
   191 	if(iFormat)
       
   192 		delete iFormat;
       
   193 	if(iCodec)
       
   194 		delete iCodec;
       
   195 	iFormat = NULL;
       
   196 	iCodec = NULL;
       
   197 
       
   198 	switch(aFormat)
       
   199 		{
       
   200 	case EPcm16Wav:
       
   201 		iFormat = new (ELeave) TMdaWavClipFormat;
       
   202 		CleanupStack::PushL(iFormat);
       
   203 		iCodec = new (ELeave) TMdaPcmWavCodec;
       
   204 		CleanupStack::PushL(iCodec);
       
   205 		break;
       
   206 	case EMulawRaw:
       
   207 		iFormat = new (ELeave) TMdaRawAudioClipFormat;
       
   208 		CleanupStack::PushL(iFormat);
       
   209 		iCodec = new (ELeave) TMdaAlawRawAudioCodec;
       
   210 		CleanupStack::PushL(iCodec);
       
   211 		break;
       
   212 	case E16BitAu:
       
   213 		iFormat = new (ELeave) TMdaAuClipFormat;
       
   214 		CleanupStack::PushL(iFormat);
       
   215 		iCodec = new (ELeave) TMdaAuCodec;
       
   216 		CleanupStack::PushL(iCodec);
       
   217 		break;
       
   218 	case EAlawAu:
       
   219 		iFormat = new (ELeave) TMdaAuClipFormat;
       
   220 		CleanupStack::PushL(iFormat);
       
   221 		iCodec = new (ELeave) TMdaAlawAuCodec;
       
   222 		CleanupStack::PushL(iCodec);
       
   223 		break;
       
   224 	case EPcm16Au:
       
   225 		iFormat = new (ELeave) TMdaAuClipFormat;
       
   226 		CleanupStack::PushL(iFormat);
       
   227 		iCodec = new (ELeave) TMdaPcm16BitAuCodec;
       
   228 		CleanupStack::PushL(iCodec);
       
   229 		break;
       
   230 	case EImaAdpcmWav:
       
   231 		iFormat = new (ELeave) TMdaWavClipFormat;
       
   232 		CleanupStack::PushL(iFormat);
       
   233 		iCodec = new (ELeave) TMdaImaAdpcmWavCodec;
       
   234 		CleanupStack::PushL(iCodec);
       
   235 		break;
       
   236 	case EAlawWav:
       
   237 		iFormat = new (ELeave) TMdaWavClipFormat;
       
   238 		CleanupStack::PushL(iFormat);
       
   239 		iCodec = new (ELeave) TMdaAlawWavCodec;
       
   240 		CleanupStack::PushL(iCodec);
       
   241 		break;
       
   242 	case EPcmU16:
       
   243 		iFormat = new (ELeave) TMdaRawAudioClipFormat();
       
   244 		CleanupStack::PushL(iFormat);
       
   245 		iCodec = new (ELeave) TMdaUB16RawAudioCodec();
       
   246 		CleanupStack::PushL(iCodec);
       
   247 		break;
       
   248 	case EPcmU8:
       
   249 		iFormat = new (ELeave) TMdaRawAudioClipFormat();
       
   250 		CleanupStack::PushL(iFormat);
       
   251 		iCodec = new (ELeave) TMdaU8PcmRawAudioCodec();
       
   252 		CleanupStack::PushL(iCodec);
       
   253 		break;
       
   254 	case EImasPcmWav:
       
   255 		iFormat = new (ELeave) TMdaWavClipFormat();
       
   256 		CleanupStack::PushL(iFormat);
       
   257 		iCodec = new (ELeave) TMdaImaAdpcmWavCodec();
       
   258 		CleanupStack::PushL(iCodec);
       
   259 		break;
       
   260 	case EPcm8:
       
   261 		iFormat = new (ELeave) TMdaWavClipFormat();
       
   262 		CleanupStack::PushL(iFormat);
       
   263 		iCodec = new (ELeave) TMdaPcmWavCodec(TMdaPcmWavCodec::E8BitPcm);
       
   264 		CleanupStack::PushL(iCodec);
       
   265 		break;
       
   266 	case EGsmWav:
       
   267 		iFormat = new (ELeave) TMdaWavClipFormat;
       
   268 		CleanupStack::PushL(iFormat);
       
   269 		iCodec = new (ELeave) TMdaGsmWavCodec;
       
   270 		CleanupStack::PushL(iCodec);
       
   271 		break;
       
   272 	case EEpocWve:
       
   273 	case ENone:
       
   274 	default:
       
   275 		// will create an inconlusive result as preamble leaves.
       
   276 		iFormat = NULL;
       
   277 		iCodec = NULL;
       
   278 		break;
       
   279 		}
       
   280 
       
   281 	if((iFormat != NULL) && (iCodec != NULL))
       
   282 		{
       
   283 		CleanupStack::Pop(); // iFormat
       
   284 		CleanupStack::Pop(); // iCodec
       
   285 		}		
       
   286 	}
       
   287