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