os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/src/mmddteststep0036.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/mmddteststep0036.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,149 @@
     1.4 +// Copyright (c) 2008-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 "mmddteststep0036.h"
    1.20 +
    1.21 +CSecDevSndTS0036* CSecDevSndTS0036::NewL(TThreadId aClientTid)
    1.22 +	{
    1.23 +	CSecDevSndTS0036* self = new (ELeave) CSecDevSndTS0036(aClientTid);
    1.24 +	CleanupStack::PushL(self);
    1.25 +	self->ConstructL();
    1.26 +	CleanupStack::Pop();
    1.27 +	return self;
    1.28 +	}
    1.29 +
    1.30 +CSecDevSndTS0036::CSecDevSndTS0036(TThreadId aClientTid)
    1.31 +	{
    1.32 +	iClientTid = aClientTid;
    1.33 +	}
    1.34 +
    1.35 +void CSecDevSndTS0036::ConstructL()
    1.36 +	{
    1.37 +	}
    1.38 +	
    1.39 +void CSecDevSndTS0036::StartProcessing(TRequestStatus& aStatus)
    1.40 +	{
    1.41 +	iStatus = &aStatus;
    1.42 +	
    1.43 +	User::After(3000000);	// allow client side devsound to play for 3sec
    1.44 +	if( (iVerdict = DoTestStepPreambleL() ) == EPass )
    1.45 +		{
    1.46 +		iVerdict = DoPlaySimpleTone();
    1.47 +		}
    1.48 +	}
    1.49 +
    1.50 +CSecDevSndTS0036::~CSecDevSndTS0036()
    1.51 +	{
    1.52 +	}
    1.53 +
    1.54 +/******************************************************************************
    1.55 + *
    1.56 + * DevSound methods
    1.57 + *
    1.58 + *****************************************************************************/
    1.59 + 
    1.60 +TVerdict CSecDevSndTS0036::DoPlaySimpleTone()
    1.61 +	{
    1.62 +	TInt freq = 100;	// arbitrary freq
    1.63 +	TTimeIntervalMicroSeconds dur(2000000);	//play for 2sec
    1.64 +	TVerdict verdict;
    1.65 +	
    1.66 +	TInt err = iMMFDevSound->SetClientThreadInfo(iClientTid);
    1.67 +	if (err != KErrNone)
    1.68 +		{
    1.69 +		verdict = EInconclusive;
    1.70 +		}
    1.71 +	else
    1.72 +		{
    1.73 +		verdict = TestInitialize(EMMFStateTonePlaying);
    1.74 +		if (verdict != EPass)
    1.75 +			{
    1.76 +			verdict = EInconclusive;
    1.77 +			}
    1.78 +		else
    1.79 +			{
    1.80 +			TestSetPriority(KDevSoundPriorityLow);
    1.81 +			TestSetVolume(iMMFDevSound->MaxVolume());
    1.82 +			iExpectedValue = KErrUnderflow;
    1.83 +			verdict = TestPlayTone(freq, dur);
    1.84 +			}
    1.85 +		}
    1.86 +	if (verdict == EInconclusive)
    1.87 +		{
    1.88 +		User::RequestComplete(iStatus, KErrGeneral);
    1.89 +		}
    1.90 +	return verdict;	
    1.91 +	}
    1.92 +
    1.93 +/**
    1.94 + *
    1.95 + * TestPlayTone
    1.96 + * @param aFreq
    1.97 + * @param aDur
    1.98 + * @result TVerdict
    1.99 + *
   1.100 + */
   1.101 +TVerdict CSecDevSndTS0036::TestPlayTone(TInt aFreq, TTimeIntervalMicroSeconds aDur)
   1.102 +	{
   1.103 +	iCallbackError = KErrNone;
   1.104 +
   1.105 +	ResetCallbacks();
   1.106 +
   1.107 +	TRAPD(err, iMMFDevSound->PlayToneL(aFreq, aDur));
   1.108 +	if (err)
   1.109 +		{
   1.110 +		iCallbackError = err;
   1.111 +		return EFail;
   1.112 +		}
   1.113 +	else
   1.114 +		{
   1.115 +		// Start the active scheduler and catch the callback
   1.116 + 		CActiveScheduler::Start();
   1.117 +		if (iCallbackError != iExpectedValue)
   1.118 +			{
   1.119 +			return EFail;
   1.120 +			}
   1.121 +		if (iCallbackArray[EToneFinished] != 1)
   1.122 +			{
   1.123 +			return EFail;
   1.124 +			}
   1.125 +		TInt tot = GetCallbackTotal();
   1.126 +		if (tot > 1)
   1.127 +			{
   1.128 +			return EFail;
   1.129 +			}
   1.130 +		}
   1.131 +	return EPass;
   1.132 +	}
   1.133 +
   1.134 +/******************************************************************************
   1.135 + *
   1.136 + * DevSound mixin methods
   1.137 + *
   1.138 + *****************************************************************************/
   1.139 + 
   1.140 +/**
   1.141 + *
   1.142 + * ToneFinished
   1.143 + * @param aError
   1.144 + *
   1.145 + */
   1.146 +void CSecDevSndTS0036::ToneFinished (TInt aError)
   1.147 +	{
   1.148 +	User::RequestComplete(iStatus, aError);
   1.149 +	iCallbackArray[EToneFinished] ++;
   1.150 +	iCallbackError = aError;
   1.151 +	CActiveScheduler::Stop();
   1.152 +	}