os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/src/CapTestStep.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 "CapTestStep.h"
19 CTestStep1* CTestStep1::NewL()
21 CTestStep1* self = new (ELeave) CTestStep1;
22 CleanupStack::PushL(self);
28 void CTestStep1::ConstructL()
30 iIsFirstPlayed = EFalse;
34 void CTestStep1::StartProcessing(TRequestStatus& aStatus)
40 iVerdictDS = DoTestStepPreambleL();
41 iVerdictDS = DoPlaySimpleTone();
45 TVerdict CTestStep1::EndProcessingAndReturnResult(TDes8& aMessage)
47 aMessage.Copy(_L("Done"));
51 CTestStep1::~CTestStep1()
55 /******************************************************************************
59 *****************************************************************************/
68 TVerdict CTestStep1::DoPlaySimpleTone()
70 // INFO_PRINTF1(_L("Testing Simple Tone Playback"));
72 TTimeIntervalMicroSeconds dur(10000000);
75 TVerdict initOK = TestInitialize(EMMFStateTonePlaying);
83 TestSetVolume(iMMFDevSound->MaxVolume());
84 iExpectedValue = KErrUnderflow;
85 TestPlayTone(freq, dur);
86 return TestPlayTone(freq, dur);
97 TVerdict CTestStep1::TestInitialize(TMMFState aMode)
99 iCallbackError = KErrNone;
100 iExpectedValue = KErrNone;
101 // INFO_PRINTF1(_L("Initializing DevSound"));
106 TRAPD(err, iMMFDevSound->InitializeL(*this, aMode));
109 // WARN_PRINTF2 (_L("DevSound InitializeL left with error = %d"), err);
110 return EInconclusive;
114 if (iCallbackError != iExpectedValue)
116 // ERR_PRINTF3 (_L("DevSound InitializeComplete returned %d, expected %d"), iCallbackError, iExpectedValue);
119 if (iCallbackArray[EInitComplete] != 1)
121 // ERR_PRINTF2 (_L("DevSound InitializeComplete was called %d times, expected 1"), iCallbackArray[EInitComplete]);
136 TVerdict CTestStep1::TestPlayTone(TInt aFreq, TTimeIntervalMicroSeconds aDur)
138 iCallbackError = KErrNone;
139 //iExpectedValue = KErrUnderflow;
143 // INFO_PRINTF1(_L("Playing Simple Tone"));
144 TRAPD(err, iMMFDevSound->PlayToneL(aFreq, aDur));
147 // WARN_PRINTF2 (_L("DevSound PlayToneL left with error = %d"), err);
148 iCallbackError = err;
153 // iAL->InitialiseActiveListener();
154 // Start the active scheduler and catch the callback
155 CActiveScheduler::Start();
156 if (iCallbackError != iExpectedValue)
158 // ERR_PRINTF3 (_L("DevSound ToneFinished returned %d, expected %d"), iCallbackError, iExpectedValue);
161 if (iCallbackArray[EToneFinished] != 1)
163 // ERR_PRINTF2 (_L("DevSound ToneFinished was called %d times, expected 1"), iCallbackArray[EToneFinished]);
166 TInt tot = GetCallbackTotal();
169 // ERR_PRINTF2 (_L("DevSound called %d callbacks, expected 1"), tot);
176 /******************************************************************************
178 * DevSound mixin methods
180 *****************************************************************************/
188 void CTestStep1::InitializeComplete (TInt aError)
190 // INFO_PRINTF2(_L("DevSound called InitializeComplete with aError = %d"), aError);
191 iCallbackArray[EInitComplete] ++;
192 iCallbackError = aError;
201 void CTestStep1::ToneFinished (TInt aError)
203 // INFO_PRINTF2(_L("DevSound called ToneFinished with aError = %d"), aError);
204 // TRequestStatus* stat = &(iAL->iStatus);
205 // User::RequestComplete(stat, aError);
207 if( !iIsFirstPlayed )
209 // after first tone played inform client so we can be interrupted during second play
210 iIsFirstPlayed = ETrue;
211 User::RequestComplete(iStatus, aError);
213 iCallbackArray[EToneFinished] ++;
214 iCallbackError = aError;
215 CActiveScheduler::Stop();