os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/src/CapTestStep0006.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/src/CapTestStep0006.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,154 @@
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 "CapTestStep0006.h"
1.20 +
1.21 +CSecDevSndTS0006* CSecDevSndTS0006::NewL()
1.22 + {
1.23 + CSecDevSndTS0006* self = new (ELeave) CSecDevSndTS0006;
1.24 + CleanupStack::PushL(self);
1.25 + self->ConstructL();
1.26 + CleanupStack::Pop();
1.27 + return self;
1.28 + }
1.29 +
1.30 +void CSecDevSndTS0006::ConstructL()
1.31 + {
1.32 + iIsFirstPlayed = EFalse;
1.33 + }
1.34 +
1.35 +
1.36 +void CSecDevSndTS0006::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 = DoPlayDualTone();
1.44 + }
1.45 + }
1.46 +
1.47 +
1.48 +CSecDevSndTS0006::~CSecDevSndTS0006()
1.49 + {
1.50 + }
1.51 +
1.52 +/******************************************************************************
1.53 + *
1.54 + * DevSound methods
1.55 + *
1.56 + *****************************************************************************/
1.57 +
1.58 +/**
1.59 + *
1.60 + * DoTestStepL
1.61 + * @result TVerdict
1.62 + *
1.63 + */
1.64 +
1.65 +const TInt KShortTimeInterval = 1000000;
1.66 +const TInt KLongTimeInterval = 10000000;
1.67 +
1.68 +TVerdict CSecDevSndTS0006::DoPlayDualTone()
1.69 + {
1.70 + TInt freq1a = 1000;
1.71 + TInt freq1b = 500;
1.72 + TTimeIntervalMicroSeconds dur1(KShortTimeInterval);
1.73 + TInt freq2a = 2000;
1.74 + TInt freq2b = 750;
1.75 + TTimeIntervalMicroSeconds dur2(KLongTimeInterval);
1.76 +
1.77 + //Initialize
1.78 + TVerdict initOK = TestInitialize(EMMFStateTonePlaying);
1.79 + if (initOK != EPass)
1.80 + {
1.81 + return EInconclusive;
1.82 + }
1.83 +
1.84 + TestSetPriority(KDevSoundPriorityHigh);
1.85 + TestSetVolume(iMMFDevSound->MaxVolume());
1.86 +
1.87 + iExpectedValue = KErrUnderflow;
1.88 + TestPlayTone(freq1a, freq1b, dur1);
1.89 + iExpectedValue = KErrInUse;
1.90 + return TestPlayTone(freq2a, freq2b, dur2);
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 CSecDevSndTS0006::TestPlayTone(TInt aFreq1, TInt aFreq2, TTimeIntervalMicroSeconds aDur)
1.102 + {
1.103 + iCallbackError = KErrNone;
1.104 +
1.105 + ResetCallbacks();
1.106 +
1.107 + TRAPD(err, iMMFDevSound->PlayDualToneL(aFreq1, aFreq2, 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 CSecDevSndTS0006::ToneFinished (TInt aError)
1.147 + {
1.148 + if( !iIsFirstPlayed )
1.149 + {
1.150 + // after first tone played inform client so we can be interrupted during second play
1.151 + iIsFirstPlayed = ETrue;
1.152 + User::RequestComplete(iStatus, aError);
1.153 + }
1.154 + iCallbackArray[EToneFinished] ++;
1.155 + iCallbackError = aError;
1.156 + CActiveScheduler::Stop();
1.157 + }