os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/src/CapTestStep.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/SDevSound/SDSCapTestServer/src/CapTestStep.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,218 @@
     1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "CapTestStep.h"
    1.20 +
    1.21 +#ifdef Required
    1.22 +CTestStep1* CTestStep1::NewL()
    1.23 +	{
    1.24 +	CTestStep1* self = new (ELeave) CTestStep1;
    1.25 +	CleanupStack::PushL(self);
    1.26 +	self->ConstructL();
    1.27 +	CleanupStack::Pop();
    1.28 +	return self;
    1.29 +	}
    1.30 +	
    1.31 +void CTestStep1::ConstructL()
    1.32 +	{
    1.33 +	iIsFirstPlayed = EFalse;
    1.34 +	}
    1.35 +	
    1.36 +
    1.37 +void CTestStep1::StartProcessing(TRequestStatus& aStatus)
    1.38 +	{
    1.39 +	iStatus = &aStatus;
    1.40 +
    1.41 +	iVerdict = EFail;
    1.42 +	
    1.43 +	iVerdictDS = DoTestStepPreambleL();
    1.44 +	iVerdictDS = DoPlaySimpleTone();
    1.45 +	}
    1.46 +		
    1.47 +		
    1.48 +TVerdict CTestStep1::EndProcessingAndReturnResult(TDes8& aMessage)
    1.49 +	{
    1.50 +	aMessage.Copy(_L("Done"));
    1.51 +	return EPass;
    1.52 +	}
    1.53 +	
    1.54 +CTestStep1::~CTestStep1()
    1.55 +	{
    1.56 +	}
    1.57 +
    1.58 +/******************************************************************************
    1.59 + *
    1.60 + * DevSound methods
    1.61 + *
    1.62 + *****************************************************************************/
    1.63 + 
    1.64 +/**
    1.65 + *
    1.66 + * DoTestStepL
    1.67 + * @result TVerdict
    1.68 + *
    1.69 + */
    1.70 +
    1.71 +TVerdict CTestStep1::DoPlaySimpleTone()
    1.72 +	{
    1.73 +//	INFO_PRINTF1(_L("Testing Simple Tone Playback"));
    1.74 +	TInt freq = 1000;
    1.75 +	TTimeIntervalMicroSeconds dur(10000000);
    1.76 +
    1.77 +	//Initialize
    1.78 +	TVerdict initOK = TestInitialize(EMMFStateTonePlaying);
    1.79 +	if (initOK != EPass)
    1.80 +		{
    1.81 +		return EInconclusive;
    1.82 +		}
    1.83 +
    1.84 +	TestSetPriority(0);
    1.85 +
    1.86 +	TestSetVolume(iMMFDevSound->MaxVolume());
    1.87 +	iExpectedValue = KErrUnderflow;
    1.88 +	TestPlayTone(freq, dur);
    1.89 +	return TestPlayTone(freq, dur);
    1.90 +	}
    1.91 +
    1.92 +/**
    1.93 + *
    1.94 + * TestInitialize
    1.95 + * @param aMode
    1.96 + * @result TVerdict
    1.97 + *
    1.98 + */
    1.99 +
   1.100 +TVerdict CTestStep1::TestInitialize(TMMFState aMode)
   1.101 +	{
   1.102 +	iCallbackError = KErrNone;
   1.103 +	iExpectedValue = KErrNone;
   1.104 +//	INFO_PRINTF1(_L("Initializing DevSound"));
   1.105 +
   1.106 +	ResetCallbacks();
   1.107 +
   1.108 +	// Initialize
   1.109 +	TRAPD(err, iMMFDevSound->InitializeL(*this, aMode));
   1.110 +	if (err)
   1.111 +		{
   1.112 +//		WARN_PRINTF2 (_L("DevSound InitializeL left with error = %d"), err);
   1.113 +		return EInconclusive;
   1.114 +		}
   1.115 +	else
   1.116 +		{
   1.117 +		if (iCallbackError != iExpectedValue)
   1.118 +			{
   1.119 +//			ERR_PRINTF3 (_L("DevSound InitializeComplete returned %d, expected %d"), iCallbackError, iExpectedValue);
   1.120 +			return EFail;
   1.121 +			}
   1.122 +		if (iCallbackArray[EInitComplete] != 1)
   1.123 +			{
   1.124 +//			ERR_PRINTF2 (_L("DevSound InitializeComplete was called %d times, expected 1"), iCallbackArray[EInitComplete]);
   1.125 +			return EFail;
   1.126 +			}
   1.127 +		}
   1.128 +	return EPass;
   1.129 +	}
   1.130 +
   1.131 +/**
   1.132 + *
   1.133 + * TestPlayTone
   1.134 + * @param aFreq
   1.135 + * @param aDur
   1.136 + * @result TVerdict
   1.137 + *
   1.138 + */
   1.139 +TVerdict CTestStep1::TestPlayTone(TInt aFreq, TTimeIntervalMicroSeconds aDur)
   1.140 +	{
   1.141 +	iCallbackError = KErrNone;
   1.142 +	//iExpectedValue = KErrUnderflow;
   1.143 +
   1.144 +	ResetCallbacks();
   1.145 +
   1.146 +//	INFO_PRINTF1(_L("Playing Simple Tone"));
   1.147 +	TRAPD(err, iMMFDevSound->PlayToneL(aFreq, aDur));
   1.148 +	if (err)
   1.149 +		{
   1.150 +//		WARN_PRINTF2 (_L("DevSound PlayToneL left with error = %d"), err);
   1.151 +		iCallbackError = err;
   1.152 +		return EFail;
   1.153 +		}
   1.154 +	else
   1.155 +		{
   1.156 +//		iAL->InitialiseActiveListener();
   1.157 +		// Start the active scheduler and catch the callback
   1.158 + 		CActiveScheduler::Start();
   1.159 +		if (iCallbackError != iExpectedValue)
   1.160 +			{
   1.161 +//			ERR_PRINTF3 (_L("DevSound ToneFinished returned %d, expected %d"), iCallbackError, iExpectedValue);
   1.162 +			return EFail;
   1.163 +			}
   1.164 +		if (iCallbackArray[EToneFinished] != 1)
   1.165 +			{
   1.166 +//			ERR_PRINTF2 (_L("DevSound ToneFinished was called %d times, expected 1"), iCallbackArray[EToneFinished]);
   1.167 +			return EFail;
   1.168 +			}
   1.169 +		TInt tot = GetCallbackTotal();
   1.170 +		if (tot > 1)
   1.171 +			{
   1.172 +//			ERR_PRINTF2 (_L("DevSound called %d callbacks, expected 1"), tot);
   1.173 +			return EFail;
   1.174 +			}
   1.175 +		}
   1.176 +	return EPass;
   1.177 +	}
   1.178 +
   1.179 +/******************************************************************************
   1.180 + *
   1.181 + * DevSound mixin methods
   1.182 + *
   1.183 + *****************************************************************************/
   1.184 + 
   1.185 +/**
   1.186 + *
   1.187 + * InitializeComplete
   1.188 + * @param aError
   1.189 + *
   1.190 + */
   1.191 +void CTestStep1::InitializeComplete (TInt aError)
   1.192 +	{
   1.193 +//	INFO_PRINTF2(_L("DevSound called InitializeComplete with aError = %d"), aError);
   1.194 +	iCallbackArray[EInitComplete] ++;
   1.195 +	iCallbackError = aError;
   1.196 +	}
   1.197 +
   1.198 +/**
   1.199 + *
   1.200 + * ToneFinished
   1.201 + * @param aError
   1.202 + *
   1.203 + */
   1.204 +void CTestStep1::ToneFinished (TInt aError)
   1.205 +	{
   1.206 +//	INFO_PRINTF2(_L("DevSound called ToneFinished with aError = %d"), aError);
   1.207 +//	TRequestStatus* stat = &(iAL->iStatus);
   1.208 +//	User::RequestComplete(stat, aError);
   1.209 +
   1.210 +	if( !iIsFirstPlayed )
   1.211 +		{
   1.212 +		// after first tone played inform client so we can be interrupted during second play
   1.213 +		iIsFirstPlayed = ETrue;
   1.214 +		User::RequestComplete(iStatus, aError);
   1.215 +		}
   1.216 +	iCallbackArray[EToneFinished] ++;
   1.217 +	iCallbackError = aError;
   1.218 +	CActiveScheduler::Stop();
   1.219 +	}
   1.220 +#endif // Required
   1.221 +