os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/src/CapTestStepBase.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/CapTestStepBase.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,323 @@
     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 +CDevSoundTestStepBase* CDevSoundTestStepBase::NewL()
    1.22 +	{
    1.23 +	CDevSoundTestStepBase* self = new (ELeave) CDevSoundTestStepBase;
    1.24 +	CleanupStack::PushL(self);
    1.25 +
    1.26 +	self->ConstructL();
    1.27 +
    1.28 +	CleanupStack::Pop();
    1.29 +	return self;
    1.30 +	}
    1.31 +	
    1.32 +void CDevSoundTestStepBase::ConstructL()
    1.33 +	{
    1.34 +	}
    1.35 +	
    1.36 +CDevSoundTestStepBase::CDevSoundTestStepBase()
    1.37 +	{
    1.38 +	ResetCallbacks();
    1.39 +	}
    1.40 +
    1.41 +CDevSoundTestStepBase::~CDevSoundTestStepBase()
    1.42 +	{
    1.43 +	delete iMMFDevSound;
    1.44 +	}
    1.45 +
    1.46 +void CDevSoundTestStepBase::StartProcessing(TRequestStatus& /*aStatus*/)
    1.47 +	{
    1.48 +	}
    1.49 +
    1.50 +TVerdict CDevSoundTestStepBase::EndProcessingAndReturnResult(TDes8& aMessage)
    1.51 +	{
    1.52 +	aMessage.Copy(_L("Done"));
    1.53 +
    1.54 +	return iVerdict;
    1.55 +	}
    1.56 +	
    1.57 +/******************************************************************************
    1.58 + *
    1.59 + * DevSound methods
    1.60 + *
    1.61 + *****************************************************************************/
    1.62 + 
    1.63 + TVerdict CDevSoundTestStepBase::ConstructDevSound()
    1.64 +	{
    1.65 +	TRAPD(err, iMMFDevSound = CMMFDevSound::NewL());
    1.66 +	if (err)
    1.67 +		{
    1.68 +		return EInconclusive;
    1.69 +		}
    1.70 +	else
    1.71 +		{
    1.72 +		return EPass;
    1.73 +		}
    1.74 +	}
    1.75 +
    1.76 + TVerdict CDevSoundTestStepBase::DoTestStepPreambleL()
    1.77 +	{
    1.78 +	return( ConstructDevSound() );
    1.79 +	}
    1.80 +
    1.81 +/**
    1.82 + *
    1.83 + * T`estInitialize
    1.84 + * @param aMode
    1.85 + * @result TVerdict
    1.86 + *
    1.87 + */
    1.88 +
    1.89 +TVerdict CDevSoundTestStepBase::TestInitialize(TMMFState aMode)
    1.90 +	{
    1.91 +	iCallbackError = KErrNone;
    1.92 +	iExpectedValue = KErrNone;
    1.93 +
    1.94 +	ResetCallbacks();
    1.95 +	
    1.96 +	// Initialize
    1.97 +	TRAPD(err, iMMFDevSound->InitializeL(*this, aMode));
    1.98 +	
    1.99 +	if (err)
   1.100 +		{
   1.101 +		return EInconclusive;
   1.102 +		}
   1.103 +	else
   1.104 +		{
   1.105 +		CActiveScheduler::Start();
   1.106 +		if (iCallbackError != iExpectedValue)
   1.107 +			{
   1.108 +			return EFail;
   1.109 +			}
   1.110 +		if (iCallbackArray[EInitComplete] != 1)
   1.111 +			{
   1.112 +			return EFail;
   1.113 +			}
   1.114 +		}
   1.115 +	return EPass;
   1.116 +	}
   1.117 +
   1.118 +/**
   1.119 + *
   1.120 + * TestSetVolume
   1.121 + * @param aVol
   1.122 + *
   1.123 + */
   1.124 +void CDevSoundTestStepBase::TestSetVolume(TInt aVol)
   1.125 +	{
   1.126 +	iMMFDevSound->SetVolume(aVol);
   1.127 +	}
   1.128 +
   1.129 +/**
   1.130 + *
   1.131 + * TestSetPriority
   1.132 + * @param aPriority
   1.133 + *
   1.134 + */
   1.135 +void CDevSoundTestStepBase::TestSetPriority(TInt aPriority)
   1.136 +	{
   1.137 +	TMMFPrioritySettings	prioritySettings;
   1.138 +
   1.139 +	prioritySettings.iPref = EMdaPriorityPreferenceNone;
   1.140 +	prioritySettings.iPriority = aPriority;
   1.141 +
   1.142 +	iMMFDevSound->SetPrioritySettings( prioritySettings );
   1.143 +	}
   1.144 +
   1.145 +/**
   1.146 + *
   1.147 + * TestSetGain
   1.148 + * @param aGain
   1.149 + *
   1.150 + */
   1.151 +void CDevSoundTestStepBase::TestSetGain(TInt aGain)
   1.152 +	{
   1.153 +	iMMFDevSound->SetGain(aGain);
   1.154 +	}
   1.155 +
   1.156 +/**
   1.157 + *
   1.158 + * TestPlayTone
   1.159 + * @param aFreq
   1.160 + * @param aDur
   1.161 + * @result TVerdict
   1.162 + *
   1.163 + */
   1.164 +TVerdict CDevSoundTestStepBase::TestPlayTone(TInt aFreq, TTimeIntervalMicroSeconds aDur)
   1.165 +	{
   1.166 +	iCallbackError = KErrNone;
   1.167 +
   1.168 +	ResetCallbacks();
   1.169 +
   1.170 +	TRAPD(err, iMMFDevSound->PlayToneL(aFreq, aDur));
   1.171 +	if (err)
   1.172 +		{
   1.173 +		iCallbackError = err;
   1.174 +		return EFail;
   1.175 +		}
   1.176 +	else
   1.177 +		{
   1.178 +		// Start the active scheduler and catch the callback
   1.179 + 		CActiveScheduler::Start();
   1.180 +		if (iCallbackError != iExpectedValue)
   1.181 +			{
   1.182 +			return EFail;
   1.183 +			}
   1.184 +		if (iCallbackArray[EToneFinished] != 1)
   1.185 +			{
   1.186 +			return EFail;
   1.187 +			}
   1.188 +		TInt tot = GetCallbackTotal();
   1.189 +		if (tot > 1)
   1.190 +			{
   1.191 +			return EFail;
   1.192 +			}
   1.193 +		}
   1.194 +	return EPass;
   1.195 +	}
   1.196 +
   1.197 +/**
   1.198 + *
   1.199 + * ResetCallbacks
   1.200 + *
   1.201 + */
   1.202 +void CDevSoundTestStepBase::ResetCallbacks()
   1.203 +	{
   1.204 +	//Initialize callback array
   1.205 +	iCallbackArray.Reset();
   1.206 +	}
   1.207 +
   1.208 +/**
   1.209 + *
   1.210 + * GetCallbackTotal
   1.211 + * @result TInt
   1.212 + *
   1.213 + */
   1.214 +TInt CDevSoundTestStepBase::GetCallbackTotal()
   1.215 +	{
   1.216 +	TInt total = 0;
   1.217 +	for (TInt i = EInitComplete; i < EDeviceMsg; i++)
   1.218 +		{
   1.219 +		total += iCallbackArray[i];
   1.220 +		}
   1.221 +	return total;
   1.222 +	}
   1.223 +
   1.224 +/******************************************************************************
   1.225 + *
   1.226 + * DevSound mixin methods
   1.227 + *
   1.228 + *****************************************************************************/
   1.229 + 
   1.230 +/**
   1.231 + *
   1.232 + * InitializeComplete
   1.233 + * @param aError
   1.234 + *
   1.235 + */
   1.236 +void CDevSoundTestStepBase::InitializeComplete (TInt aError)
   1.237 +	{
   1.238 +	iCallbackArray[EInitComplete] ++;
   1.239 +	iCallbackError = aError;
   1.240 +	CActiveScheduler::Stop();
   1.241 +	}
   1.242 +
   1.243 +/**
   1.244 + *
   1.245 + * ToneFinished
   1.246 + * @param aError
   1.247 + *
   1.248 + */
   1.249 +void CDevSoundTestStepBase::ToneFinished (TInt aError)
   1.250 +	{
   1.251 +	iCallbackArray[EToneFinished] ++;
   1.252 +	iCallbackError = aError;
   1.253 +	}
   1.254 +
   1.255 +/**
   1.256 + *
   1.257 + * BufferToBeFilled
   1.258 + * @param aBuffer
   1.259 + *
   1.260 + */
   1.261 +void CDevSoundTestStepBase::BufferToBeFilled (CMMFBuffer* aBuffer)
   1.262 +	{
   1.263 +	iBuffer = aBuffer;
   1.264 +	if (aBuffer != NULL) 
   1.265 +		{
   1.266 +		iCallbackError = KErrNone;
   1.267 +		}
   1.268 +	else 
   1.269 +		{
   1.270 +		iCallbackError = KErrNotFound;
   1.271 +		}
   1.272 +	iCallbackArray[EBuffToFill] ++;
   1.273 +	CActiveScheduler::Stop();
   1.274 +	}
   1.275 +
   1.276 +/**
   1.277 + *
   1.278 + * PlayError
   1.279 + * @param aError
   1.280 + *
   1.281 + */
   1.282 +void CDevSoundTestStepBase::PlayError (TInt aError)
   1.283 +	{
   1.284 +	iCallbackError = aError;
   1.285 +	iCallbackArray[EPlayError] ++;
   1.286 +	CActiveScheduler::Stop();
   1.287 +	}
   1.288 +
   1.289 +/**
   1.290 + * 
   1.291 + * BufferToBeEmptied
   1.292 + * @param aBuffer
   1.293 + *
   1.294 + */
   1.295 +void CDevSoundTestStepBase::BufferToBeEmptied (CMMFBuffer* /*aBuffer*/)
   1.296 +	{
   1.297 +	iCallbackArray[EBuffToEmpty] ++;
   1.298 +	}
   1.299 +
   1.300 +/**
   1.301 + *
   1.302 + * RecordError
   1.303 + * @param aError
   1.304 + *
   1.305 + */
   1.306 +void CDevSoundTestStepBase::RecordError (TInt aError)
   1.307 +	{
   1.308 +	iCallbackError = aError;
   1.309 +	iCallbackArray[ERecError] ++;
   1.310 +	}
   1.311 +
   1.312 +/**
   1.313 + *
   1.314 + * ConvertError
   1.315 + *
   1.316 + */
   1.317 +void CDevSoundTestStepBase::ConvertError (TInt /*aError*/)
   1.318 +	{}
   1.319 +
   1.320 +/**
   1.321 + *
   1.322 + * DeviceMessage
   1.323 + *
   1.324 + */
   1.325 +void CDevSoundTestStepBase::DeviceMessage (TUid, const TDesC8& /*aMsg*/)
   1.326 +	{}