os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/src/CapTestStep0002.cpp
Update contrib.
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "CapTestStep0002.h"
18 CSecDevSndTS0002* CSecDevSndTS0002::NewL()
20 CSecDevSndTS0002* self = new (ELeave) CSecDevSndTS0002;
21 CleanupStack::PushL(self);
27 void CSecDevSndTS0002::ConstructL()
29 iIsFirstPlayed = EFalse;
33 void CSecDevSndTS0002::StartProcessing(TRequestStatus& aStatus)
38 if( (iVerdict = DoTestStepPreambleL() ) == EPass )
40 iVerdict = DoPlaySimpleTone();
44 CSecDevSndTS0002::~CSecDevSndTS0002()
48 /******************************************************************************
52 *****************************************************************************/
61 const TInt KShortTimeInterval = 1000000;
62 const TInt KLongTimeInterval = 10000000;
64 TVerdict CSecDevSndTS0002::DoPlaySimpleTone()
66 TInt freq1 = 500; // arbitrary freq
67 TTimeIntervalMicroSeconds dur1(KShortTimeInterval);
68 TInt freq2 = 1000; // arbitrary freq (different from #1)
69 TTimeIntervalMicroSeconds dur2(KLongTimeInterval);
72 TVerdict initOK = TestInitialize(EMMFStateTonePlaying);
78 TestSetPriority(KDevSoundPriorityHigh);
79 TestSetVolume(iMMFDevSound->MaxVolume());
81 iExpectedValue = KErrUnderflow;
82 TestPlayTone(freq1, dur1);
83 iExpectedValue = KErrInUse;
84 return TestPlayTone(freq2, dur2);
95 TVerdict CSecDevSndTS0002::TestPlayTone(TInt aFreq, TTimeIntervalMicroSeconds aDur)
97 iCallbackError = KErrNone;
101 TRAPD(err, iMMFDevSound->PlayToneL(aFreq, aDur));
104 iCallbackError = err;
109 // Start the active scheduler and catch the callback
110 CActiveScheduler::Start();
111 if (iCallbackError != iExpectedValue)
115 if (iCallbackArray[EToneFinished] != 1)
119 TInt tot = GetCallbackTotal();
128 /******************************************************************************
130 * DevSound mixin methods
132 *****************************************************************************/
140 void CSecDevSndTS0002::ToneFinished (TInt aError)
142 if( !iIsFirstPlayed )
144 // after first tone played inform client so we can be interrupted during second play
145 iIsFirstPlayed = ETrue;
146 User::RequestComplete(iStatus, aError);
148 iCallbackArray[EToneFinished] ++;
149 iCallbackError = aError;
150 CActiveScheduler::Stop();