0
|
1 |
// Copyright (c) 2008-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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// CTestStepTonePlayDualToneInvalidFreq.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
// EPOC includes
|
|
19 |
#include <e32base.h>
|
|
20 |
#include <e32test.h>
|
|
21 |
#include <e32keys.h>
|
|
22 |
#include <c32comm.h>
|
|
23 |
#include <f32file.h>
|
|
24 |
#include <etel.h>
|
|
25 |
#include <etelmm.h>
|
|
26 |
#include <testframework.h>
|
|
27 |
|
|
28 |
#include <mdaaudiotoneplayer.h>
|
|
29 |
|
|
30 |
// Test system includes
|
|
31 |
#include <testframework.h>
|
|
32 |
|
|
33 |
// Specific includes for this test suite
|
|
34 |
#include "TestStepUnitMMFAudClient.h"
|
|
35 |
#include "TestSuiteUnitMMFAudClient.h"
|
|
36 |
|
|
37 |
// Specific includes for these test steps
|
|
38 |
#include "TestStepTone.h"
|
|
39 |
|
|
40 |
|
|
41 |
#include "mmfclienttoneplayer.h"
|
|
42 |
|
|
43 |
|
|
44 |
CTestStepTonePlayDualToneInvalidFreq* CTestStepTonePlayDualToneInvalidFreq::NewL(const TDesC& aName)
|
|
45 |
{
|
|
46 |
CTestStepTonePlayDualToneInvalidFreq* self = new(ELeave) CTestStepTonePlayDualToneInvalidFreq(aName);
|
|
47 |
return self;
|
|
48 |
}
|
|
49 |
|
|
50 |
|
|
51 |
CTestStepTonePlayDualToneInvalidFreq::CTestStepTonePlayDualToneInvalidFreq(const TDesC& aName) : iPrepareError(KErrNone), iPlayError(KErrNone)
|
|
52 |
{
|
|
53 |
iTestStepName = aName;
|
|
54 |
// need a bigger heap size on EKA2 HW
|
|
55 |
#if !defined __WINS__
|
|
56 |
iHeapSize = KHeapSizeToneTestEKA2;
|
|
57 |
#endif // EKA2
|
|
58 |
}
|
|
59 |
|
|
60 |
|
|
61 |
void CTestStepTonePlayDualToneInvalidFreq::MatoPrepareComplete(TInt aError)
|
|
62 |
{
|
|
63 |
iPrepareError = aError;
|
|
64 |
INFO_PRINTF2(_L("PrepareToPlayDualTone() completed with error %i"), aError);
|
|
65 |
CActiveScheduler::Stop(); //To resume DoTestStepL()
|
|
66 |
}
|
|
67 |
|
|
68 |
|
|
69 |
void CTestStepTonePlayDualToneInvalidFreq::MatoPlayComplete(TInt aError)
|
|
70 |
{
|
|
71 |
iPlayError = aError;
|
|
72 |
INFO_PRINTF2(_L("Play() completed with error %i"), aError);
|
|
73 |
CActiveScheduler::Stop(); //To resume DoTestStepL()
|
|
74 |
}
|
|
75 |
|
|
76 |
|
|
77 |
/**
|
|
78 |
*
|
|
79 |
* Creates the tone utility and active scheduler.
|
|
80 |
*
|
|
81 |
*/
|
|
82 |
enum TVerdict CTestStepTonePlayDualToneInvalidFreq::DoTestStepPreambleL(void)
|
|
83 |
{
|
|
84 |
//install the scheduler
|
|
85 |
TVerdict result = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
86 |
if (result != EPass)
|
|
87 |
{
|
|
88 |
return result;
|
|
89 |
}
|
|
90 |
|
|
91 |
INFO_PRINTF1(_L("Creating tone utility..."));
|
|
92 |
|
|
93 |
__MM_HEAP_MARK;
|
|
94 |
// create the Tone utility
|
|
95 |
TRAPD( err, (iTone = CMMFMdaAudioToneUtility::NewL(*this)) );
|
|
96 |
if ( err != KErrNone ||
|
|
97 |
iTone->State() != EMdaAudioToneUtilityNotReady )
|
|
98 |
result = EInconclusive;
|
|
99 |
|
|
100 |
return result;
|
|
101 |
}
|
|
102 |
|
|
103 |
|
|
104 |
/**
|
|
105 |
*
|
|
106 |
* Cleans up the tone utility and the active scheduler.
|
|
107 |
*
|
|
108 |
*/
|
|
109 |
enum TVerdict CTestStepTonePlayDualToneInvalidFreq::DoTestStepPostambleL(void)
|
|
110 |
{
|
|
111 |
delete iTone;
|
|
112 |
iTone = NULL;
|
|
113 |
|
|
114 |
__MM_HEAP_MARKEND;
|
|
115 |
|
|
116 |
//destroy the scheduler
|
|
117 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
118 |
}
|
|
119 |
|
|
120 |
|
|
121 |
/**
|
|
122 |
*
|
|
123 |
* Prior to the fix the tone utility would stall, this is caught here.
|
|
124 |
*
|
|
125 |
*/
|
|
126 |
void CTestStepTonePlayDualToneInvalidFreq::TimeoutExpired()
|
|
127 |
{
|
|
128 |
iTestStepResult = EFail; //Original behaviour prior to the introduction of this test had DevSound dropping the play request quietly resulting in the thread timing out.
|
|
129 |
INFO_PRINTF1(_L("ERROR: Audio Tone Utility call timed out."));
|
|
130 |
CActiveScheduler::Stop(); //To resume DoTestStepL()
|
|
131 |
}
|
|
132 |
|
|
133 |
|
|
134 |
/**
|
|
135 |
*
|
|
136 |
* Static function used by the TCallBack object.
|
|
137 |
* @param aPtr A pointer to the test object that is running.
|
|
138 |
*
|
|
139 |
*/
|
|
140 |
TInt CTestStepTonePlayDualToneInvalidFreq::TimeoutExpiredStaticCallback(TAny* aPtr)
|
|
141 |
{
|
|
142 |
CTestStepTonePlayDualToneInvalidFreq* self = static_cast<CTestStepTonePlayDualToneInvalidFreq*>(aPtr);
|
|
143 |
self->TimeoutExpired();
|
|
144 |
return 0; //This is a one off event, do not want periodic behaviour.
|
|
145 |
}
|
|
146 |
|
|
147 |
|
|
148 |
/**
|
|
149 |
*
|
|
150 |
* Each test step must supply an implementation for DoTestStepL.
|
|
151 |
*
|
|
152 |
* @return "TVerdict"
|
|
153 |
* The result of the test step
|
|
154 |
*
|
|
155 |
*/
|
|
156 |
TVerdict CTestStepTonePlayDualToneInvalidFreq::DoTestStepL()
|
|
157 |
{
|
|
158 |
iTestStepResult = EInconclusive;
|
|
159 |
|
|
160 |
TInt freq1, freq2, duration;
|
|
161 |
|
|
162 |
User::LeaveIfError(GetIntFromConfig(iTestStepName, _L("Frequency1"), freq1));
|
|
163 |
User::LeaveIfError(GetIntFromConfig(iTestStepName, _L("Frequency2"), freq2));
|
|
164 |
User::LeaveIfError(GetIntFromConfig(iTestStepName, _L("Duration"), duration));
|
|
165 |
|
|
166 |
iTestStepResult = EPass;
|
|
167 |
|
|
168 |
INFO_PRINTF4(_L("Playing dual tone with frequencies of %d Hz & %d Hz for %d microseconds."),
|
|
169 |
freq1, freq2, duration);
|
|
170 |
|
|
171 |
INFO_PRINTF1(_L("Calling PrepareToPlayDualTone()..."));
|
|
172 |
iTone->PrepareToPlayDualTone(freq1, freq2, TTimeIntervalMicroSeconds(duration));
|
|
173 |
CActiveScheduler::Start();
|
|
174 |
|
|
175 |
if (iPrepareError != KErrNone || iTone->State() != EMdaAudioToneUtilityPrepared )
|
|
176 |
{
|
|
177 |
return EFail;
|
|
178 |
}
|
|
179 |
|
|
180 |
INFO_PRINTF1(_L("Calling Play()..."));
|
|
181 |
iTone->Play();
|
|
182 |
|
|
183 |
//The test case was originally introduced as part of DEF125377 where the Tone Utility was hanging and we use a timer here to catch this.
|
|
184 |
TCallBack testTimedOutCallback(TimeoutExpiredStaticCallback, this);
|
|
185 |
CPeriodic* timeoutTimer = CPeriodic::NewL(CActive::EPriorityHigh);
|
|
186 |
CleanupStack::PushL(timeoutTimer);
|
|
187 |
timeoutTimer->Start(KTestTimeout, KTestTimeout, testTimedOutCallback);
|
|
188 |
|
|
189 |
CActiveScheduler::Start();
|
|
190 |
|
|
191 |
timeoutTimer->Cancel();
|
|
192 |
CleanupStack::PopAndDestroy(1, timeoutTimer);
|
|
193 |
|
|
194 |
if (iPlayError != KErrArgument)
|
|
195 |
{
|
|
196 |
iTone->CancelPrepare();
|
|
197 |
INFO_PRINTF1(_L("ERROR: KErrArgument expected."));
|
|
198 |
return EFail;
|
|
199 |
}
|
|
200 |
|
|
201 |
// test steps return a result
|
|
202 |
return iTestStepResult;
|
|
203 |
}
|