os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/src/CapTestStep0004.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/CapTestStep0004.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,143 @@
     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 "CapTestStep0004.h"
    1.20 +
    1.21 +CSecDevSndTS0004* CSecDevSndTS0004::NewL()
    1.22 +	{
    1.23 +	CSecDevSndTS0004* self = new (ELeave) CSecDevSndTS0004;
    1.24 +	CleanupStack::PushL(self);
    1.25 +	self->ConstructL();
    1.26 +	CleanupStack::Pop();
    1.27 +	return self;
    1.28 +	}
    1.29 +	
    1.30 +void CSecDevSndTS0004::ConstructL()
    1.31 +	{
    1.32 +	iIsFirstPlayed = EFalse;
    1.33 +	}
    1.34 +	
    1.35 +void CSecDevSndTS0004::StartProcessing(TRequestStatus& aStatus)
    1.36 +	{
    1.37 +	iStatus = &aStatus;
    1.38 +
    1.39 +	if( (iVerdict = DoTestStepPreambleL() ) == EPass )
    1.40 +		{
    1.41 +		iVerdict = DoPlayDTMFTone();
    1.42 +		}
    1.43 +	}
    1.44 +
    1.45 +CSecDevSndTS0004::~CSecDevSndTS0004()
    1.46 +	{
    1.47 +	}
    1.48 +
    1.49 +/******************************************************************************
    1.50 + *
    1.51 + * DevSound methods
    1.52 + *
    1.53 + *****************************************************************************/
    1.54 + 
    1.55 +/**
    1.56 + *
    1.57 + * DoTestStepL
    1.58 + * @result TVerdict
    1.59 + *
    1.60 + */
    1.61 +
    1.62 +TVerdict CSecDevSndTS0004::DoPlayDTMFTone()
    1.63 +	{
    1.64 +	_LIT(KDTMFStringShort,"0");
    1.65 +	_LIT(KDTMFString,"11111, 11111, 11111111");
    1.66 +
    1.67 +	//Initialize
    1.68 +	TVerdict initOK = TestInitialize(EMMFStateTonePlaying);
    1.69 +	if (initOK != EPass)
    1.70 +		{
    1.71 +		return EInconclusive;
    1.72 +		}
    1.73 +
    1.74 +	TestSetPriority(KDevSoundPriorityHigh);
    1.75 +	TestSetVolume(iMMFDevSound->MaxVolume());
    1.76 +
    1.77 +	iExpectedValue = KErrUnderflow;
    1.78 +	TestPlayDTMFString(KDTMFStringShort);
    1.79 +	iExpectedValue = KErrInUse;
    1.80 +	return TestPlayDTMFString(KDTMFString);
    1.81 +	}
    1.82 +
    1.83 +/**
    1.84 + *
    1.85 + * TestPlayDTMFString
    1.86 + * @param aDTMFString
    1.87 + * @result TVerdict
    1.88 + *
    1.89 + */
    1.90 +TVerdict CSecDevSndTS0004::TestPlayDTMFString(const TDesC &aDTMFString)
    1.91 +	{
    1.92 +	iCallbackError = KErrNone;
    1.93 +
    1.94 +	ResetCallbacks();
    1.95 +
    1.96 +	TRAPD(err, iMMFDevSound->PlayDTMFStringL(aDTMFString));
    1.97 +	if (err)
    1.98 +		{
    1.99 +		iCallbackError = err;
   1.100 +		return EFail;
   1.101 +		}
   1.102 +	else
   1.103 +		{
   1.104 +		// Start the active scheduler and catch the callback
   1.105 + 		CActiveScheduler::Start();
   1.106 +		if (iCallbackError != iExpectedValue)
   1.107 +			{
   1.108 +			return EFail;
   1.109 +			}
   1.110 +		if (iCallbackArray[EToneFinished] != 1)
   1.111 +			{
   1.112 +			return EFail;
   1.113 +			}
   1.114 +		TInt tot = GetCallbackTotal();
   1.115 +		if (tot > 1)
   1.116 +			{
   1.117 +			return EFail;
   1.118 +			}
   1.119 +		}
   1.120 +	return EPass;
   1.121 +	}
   1.122 +
   1.123 +/******************************************************************************
   1.124 + *
   1.125 + * DevSound mixin methods
   1.126 + *
   1.127 + *****************************************************************************/
   1.128 + 
   1.129 +/**
   1.130 + *
   1.131 + * ToneFinished
   1.132 + * @param aError
   1.133 + *
   1.134 + */
   1.135 +void CSecDevSndTS0004::ToneFinished (TInt aError)
   1.136 +	{
   1.137 +	if( !iIsFirstPlayed )
   1.138 +		{
   1.139 +		// after first tone played inform client so we can be interrupted during second play
   1.140 +		iIsFirstPlayed = ETrue;
   1.141 +		User::RequestComplete(iStatus, aError);
   1.142 +		}
   1.143 +	iCallbackArray[EToneFinished] ++;
   1.144 +	iCallbackError = aError;
   1.145 +	CActiveScheduler::Stop();
   1.146 +	}