0
|
1 |
// Copyright (c) 2007-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 |
//
|
|
15 |
|
|
16 |
// Custom interface definitions
|
|
17 |
#include <mmf/server/devsoundstandardcustominterfaces.h>
|
|
18 |
#include <mmf/plugin/mmfdevsoundcustominterface.hrh>
|
|
19 |
|
|
20 |
// Test system includes
|
|
21 |
#include "tsu_mmf_devsound_ciu_step.h"
|
|
22 |
#include "tsu_mmf_devsound_ciu_suite.h"
|
|
23 |
|
|
24 |
|
|
25 |
/**
|
|
26 |
CTestStepCustominterfaceUnificationUnit constructor
|
|
27 |
*/
|
|
28 |
CTestStepCustominterfaceUnificationUnit::CTestStepCustominterfaceUnificationUnit() :
|
|
29 |
iScheduler(NULL)
|
|
30 |
{
|
|
31 |
iRes = &iSourceFileName;
|
|
32 |
}
|
|
33 |
|
|
34 |
CTestStepCustominterfaceUnificationUnit::CTestStepCustominterfaceUnificationUnit(const TDesC& aTestName) :
|
|
35 |
iScheduler(NULL)
|
|
36 |
{
|
|
37 |
iRes = &iSourceFileName;
|
|
38 |
iTestStepName = aTestName;
|
|
39 |
}
|
|
40 |
|
|
41 |
/**
|
|
42 |
CTestStepCustominterfaceUnificationUnit destructor
|
|
43 |
*/
|
|
44 |
CTestStepCustominterfaceUnificationUnit::~CTestStepCustominterfaceUnificationUnit()
|
|
45 |
{
|
|
46 |
if (iMMFDevSound)
|
|
47 |
{
|
|
48 |
delete iMMFDevSound;
|
|
49 |
}
|
|
50 |
if (iActiveListener)
|
|
51 |
{
|
|
52 |
delete iActiveListener;
|
|
53 |
}
|
|
54 |
if (iScheduler)
|
|
55 |
{
|
|
56 |
delete iScheduler;
|
|
57 |
}
|
|
58 |
}
|
|
59 |
|
|
60 |
/**
|
|
61 |
CTestStepCustominterfaceUnificationUnit accessor : set suite
|
|
62 |
|
|
63 |
@param CTestSuiteCustominterfaceUnificationUnit*
|
|
64 |
The test suite.
|
|
65 |
*/
|
|
66 |
void CTestStepCustominterfaceUnificationUnit::SetSuite(CTestSuiteCustomInterfaceUnificationUnit* aSuite)
|
|
67 |
{
|
|
68 |
iTestSuite = aSuite;
|
|
69 |
}
|
|
70 |
|
|
71 |
/**
|
|
72 |
CTestStepCustominterfaceUnificationUnit accessor : get suite
|
|
73 |
*
|
|
74 |
* @return "CTestSuiteCustominterfaceUnificationUnit*"
|
|
75 |
* The test suite.
|
|
76 |
*/
|
|
77 |
CTestSuiteCustomInterfaceUnificationUnit* CTestStepCustominterfaceUnificationUnit::TestSuite() const
|
|
78 |
{
|
|
79 |
return iTestSuite;
|
|
80 |
}
|
|
81 |
|
|
82 |
/**
|
|
83 |
DoTestStepPreambleL is the preamble function for test steps
|
|
84 |
It creates an active scheduler and installs it. This is necessary
|
|
85 |
since we are multithreading and each test step runs in a separate thread.
|
|
86 |
@return TVerdict which is either EPass or Efail
|
|
87 |
|
|
88 |
The function can leave if there is insufficient memeory
|
|
89 |
*/
|
|
90 |
enum TVerdict CTestStepCustominterfaceUnificationUnit::DoTestStepPreambleL(void)
|
|
91 |
{
|
|
92 |
iScheduler = new(ELeave)CActiveScheduler;
|
|
93 |
CleanupStack::PushL( iScheduler );
|
|
94 |
|
|
95 |
CActiveScheduler::Install( iScheduler );
|
|
96 |
|
|
97 |
CleanupStack::Pop();
|
|
98 |
|
|
99 |
iActiveListener= new(ELeave)CActiveListener;
|
|
100 |
|
|
101 |
INFO_PRINTF1(_L("Creating DevSound Object"));
|
|
102 |
TRAPD(err, iMMFDevSound = CMMFDevSound::NewL());
|
|
103 |
if (err)
|
|
104 |
{
|
|
105 |
return EInconclusive;
|
|
106 |
}
|
|
107 |
else
|
|
108 |
{
|
|
109 |
return EPass;
|
|
110 |
}
|
|
111 |
}
|
|
112 |
|
|
113 |
/**
|
|
114 |
The post amble step cleans up the allocated memory in the preamble
|
|
115 |
@return TVerdict EPass or EFail
|
|
116 |
@leave can leave due to insufficient memory
|
|
117 |
*/
|
|
118 |
enum TVerdict CTestStepCustominterfaceUnificationUnit::DoTestStepPostambleL(void)
|
|
119 |
{
|
|
120 |
INFO_PRINTF1(_L("Deleting DevSound Object"));
|
|
121 |
|
|
122 |
if (iMMFDevSound)
|
|
123 |
{
|
|
124 |
delete iMMFDevSound;
|
|
125 |
iMMFDevSound = NULL;
|
|
126 |
}
|
|
127 |
if (iActiveListener)
|
|
128 |
{
|
|
129 |
delete iActiveListener;
|
|
130 |
iActiveListener = NULL;
|
|
131 |
}
|
|
132 |
if (iScheduler)
|
|
133 |
{
|
|
134 |
delete iScheduler;
|
|
135 |
iScheduler = NULL;
|
|
136 |
}
|
|
137 |
|
|
138 |
return EPass;
|
|
139 |
}
|
|
140 |
|
|
141 |
|
|
142 |
//
|
|
143 |
// start Callback methods from MDevSoundObserver mixin
|
|
144 |
//
|
|
145 |
|
|
146 |
/**
|
|
147 |
InitializeComplete
|
|
148 |
@param aError
|
|
149 |
*/
|
|
150 |
void CTestStepCustominterfaceUnificationUnit::InitializeComplete (TInt aError)
|
|
151 |
{
|
|
152 |
INFO_PRINTF2(_L("DevSound called InitializeComplete with aError = %d"), aError);
|
|
153 |
TRequestStatus* stat = &(iActiveListener->iStatus);
|
|
154 |
User::RequestComplete(stat, aError);
|
|
155 |
iCallbackArray[EInitComplete] ++;
|
|
156 |
iCallbackError = aError;
|
|
157 |
}
|
|
158 |
|
|
159 |
/**
|
|
160 |
ToneFinished
|
|
161 |
@param aError
|
|
162 |
*/
|
|
163 |
void CTestStepCustominterfaceUnificationUnit::ToneFinished (TInt aError)
|
|
164 |
{
|
|
165 |
INFO_PRINTF2(_L("DevSound called ToneFinished with aError = %d"), aError);
|
|
166 |
TRequestStatus* stat = &(iActiveListener->iStatus);
|
|
167 |
User::RequestComplete(stat, aError);
|
|
168 |
iCallbackArray[EToneFinished] ++;
|
|
169 |
iCallbackError = aError;
|
|
170 |
}
|
|
171 |
|
|
172 |
/**
|
|
173 |
BufferToBeFilled
|
|
174 |
@param aBuffer
|
|
175 |
*/
|
|
176 |
void CTestStepCustominterfaceUnificationUnit::BufferToBeFilled (CMMFBuffer* aBuffer)
|
|
177 |
{
|
|
178 |
iBuffer = aBuffer;
|
|
179 |
TRequestStatus* stat = &(iActiveListener->iStatus);
|
|
180 |
if (aBuffer != NULL)
|
|
181 |
{
|
|
182 |
User::RequestComplete(stat, KErrNone);
|
|
183 |
iCallbackError = KErrNone;
|
|
184 |
}
|
|
185 |
else
|
|
186 |
{
|
|
187 |
User::RequestComplete(stat, KErrNotFound);
|
|
188 |
iCallbackError = KErrNotFound;
|
|
189 |
}
|
|
190 |
iCallbackArray[EBuffToFill] ++;
|
|
191 |
}
|
|
192 |
|
|
193 |
/**
|
|
194 |
PlayError
|
|
195 |
@param aError
|
|
196 |
*/
|
|
197 |
void CTestStepCustominterfaceUnificationUnit::PlayError (TInt aError)
|
|
198 |
{
|
|
199 |
INFO_PRINTF2(_L("DevSound called PlayError with aError = %d"), aError);
|
|
200 |
TRequestStatus* stat = &(iActiveListener->iStatus);
|
|
201 |
User::RequestComplete (stat, aError);
|
|
202 |
iCallbackError = aError;
|
|
203 |
iCallbackArray[EPlayError] ++;
|
|
204 |
}
|
|
205 |
|
|
206 |
/**
|
|
207 |
BufferToBeEmptied
|
|
208 |
@param aBuffer
|
|
209 |
*/
|
|
210 |
void CTestStepCustominterfaceUnificationUnit::BufferToBeEmptied (CMMFBuffer* aBuffer)
|
|
211 |
{
|
|
212 |
INFO_PRINTF1(_L("DevSound called BufferToBeEmptied"));
|
|
213 |
iBuffer = aBuffer;
|
|
214 |
TRequestStatus* stat = &(iActiveListener->iStatus);
|
|
215 |
if (aBuffer != NULL)
|
|
216 |
{
|
|
217 |
User::RequestComplete(stat, KErrNone);
|
|
218 |
iCallbackError = KErrNone;
|
|
219 |
}
|
|
220 |
else
|
|
221 |
{
|
|
222 |
User::RequestComplete(stat, KErrNotFound);
|
|
223 |
iCallbackError = KErrNotFound;
|
|
224 |
}
|
|
225 |
iCallbackArray[EBuffToEmpty] ++;
|
|
226 |
}
|
|
227 |
|
|
228 |
/**
|
|
229 |
RecordError
|
|
230 |
@param aError
|
|
231 |
*/
|
|
232 |
void CTestStepCustominterfaceUnificationUnit::RecordError (TInt aError)
|
|
233 |
{
|
|
234 |
INFO_PRINTF2(_L("DevSound called RecordError with aError = %d"), aError);
|
|
235 |
TRequestStatus* stat = &(iActiveListener->iStatus);
|
|
236 |
User::RequestComplete (stat, aError);
|
|
237 |
iCallbackError = aError;
|
|
238 |
iCallbackArray[ERecError] ++;
|
|
239 |
}
|
|
240 |
|
|
241 |
/**
|
|
242 |
ConvertError
|
|
243 |
*/
|
|
244 |
void CTestStepCustominterfaceUnificationUnit::ConvertError (TInt /*aError*/)
|
|
245 |
{
|
|
246 |
}
|
|
247 |
|
|
248 |
/**
|
|
249 |
DeviceMessage
|
|
250 |
*/
|
|
251 |
void CTestStepCustominterfaceUnificationUnit::DeviceMessage(TUid, const TDesC8& /*aMsg*/)
|
|
252 |
{
|
|
253 |
}
|
|
254 |
|
|
255 |
|
|
256 |
//
|
|
257 |
// start Test methods (called by test cases)
|
|
258 |
//
|
|
259 |
|
|
260 |
/**
|
|
261 |
TestInitialize
|
|
262 |
@param aMode
|
|
263 |
@return TVerdict
|
|
264 |
*/
|
|
265 |
TVerdict CTestStepCustominterfaceUnificationUnit::TestInitialize(TMMFState aMode)
|
|
266 |
{
|
|
267 |
iCallbackError = KErrNone;
|
|
268 |
iExpectedValue = KErrNone;
|
|
269 |
INFO_PRINTF1(_L("Initializing DevSound"));
|
|
270 |
|
|
271 |
ResetCallbacks();
|
|
272 |
iActiveListener->InitialiseActiveListener();
|
|
273 |
// Initialize
|
|
274 |
TRAPD(err, iMMFDevSound->InitializeL(*this, aMode));
|
|
275 |
if (err)
|
|
276 |
{
|
|
277 |
WARN_PRINTF2 (_L("DevSound InitializeL left with error = %d"), err);
|
|
278 |
return EInconclusive;
|
|
279 |
}
|
|
280 |
else
|
|
281 |
{
|
|
282 |
CActiveScheduler::Start();
|
|
283 |
if (iCallbackError != iExpectedValue)
|
|
284 |
{
|
|
285 |
ERR_PRINTF3 (_L("DevSound InitializeComplete returned %d, expected %d"), iCallbackError, iExpectedValue);
|
|
286 |
return EFail;
|
|
287 |
}
|
|
288 |
if (iCallbackArray[EInitComplete] != 1)
|
|
289 |
{
|
|
290 |
ERR_PRINTF2 (_L("DevSound InitializeComplete was called %d times, expected 1"), iCallbackArray[EInitComplete]);
|
|
291 |
return EFail;
|
|
292 |
}
|
|
293 |
}
|
|
294 |
return EPass;
|
|
295 |
}
|
|
296 |
|
|
297 |
/**
|
|
298 |
TestInitialize
|
|
299 |
@param aHwDeviceUid
|
|
300 |
@param aMode
|
|
301 |
@return TVerdict
|
|
302 |
*/
|
|
303 |
TVerdict CTestStepCustominterfaceUnificationUnit::TestInitialize(TUid aHwDeviceUid, TMMFState aMode)
|
|
304 |
{
|
|
305 |
iCallbackError = KErrNone;
|
|
306 |
iExpectedValue = KErrNone;
|
|
307 |
INFO_PRINTF1(_L("Initializing DevSound"));
|
|
308 |
|
|
309 |
ResetCallbacks();
|
|
310 |
iActiveListener->InitialiseActiveListener();
|
|
311 |
// Initialize
|
|
312 |
TRAPD(err, iMMFDevSound->InitializeL(*this, aHwDeviceUid, aMode));
|
|
313 |
if (err)
|
|
314 |
{
|
|
315 |
WARN_PRINTF2 (_L("DevSound InitializeL left with error = %d"), err);
|
|
316 |
return EInconclusive;
|
|
317 |
}
|
|
318 |
else
|
|
319 |
{
|
|
320 |
CActiveScheduler::Start();
|
|
321 |
if (iCallbackError != iExpectedValue)
|
|
322 |
{
|
|
323 |
ERR_PRINTF3 (_L("DevSound InitializeComplete returned %d, expected %d"), iCallbackError, iExpectedValue);
|
|
324 |
return EFail;
|
|
325 |
}
|
|
326 |
if (iCallbackArray[EInitComplete] != 1)
|
|
327 |
{
|
|
328 |
ERR_PRINTF2 (_L("DevSound InitializeComplete was called %d times, expected 1"), iCallbackArray[EInitComplete]);
|
|
329 |
return EFail;
|
|
330 |
}
|
|
331 |
}
|
|
332 |
return EPass;
|
|
333 |
}
|
|
334 |
|
|
335 |
/**
|
|
336 |
TestInitialize
|
|
337 |
@param aDataType
|
|
338 |
@param aMode
|
|
339 |
@return TVerdict
|
|
340 |
*/
|
|
341 |
TVerdict CTestStepCustominterfaceUnificationUnit::TestInitialize(TFourCC& aDataType, TMMFState aMode)
|
|
342 |
{
|
|
343 |
iCallbackError = KErrNone;
|
|
344 |
iExpectedValue = KErrNone;
|
|
345 |
INFO_PRINTF1(_L("Initializing DevSound"));
|
|
346 |
|
|
347 |
ResetCallbacks();
|
|
348 |
iActiveListener->InitialiseActiveListener();
|
|
349 |
// Initialize
|
|
350 |
TRAPD(err, iMMFDevSound->InitializeL(*this, aDataType, aMode));
|
|
351 |
if (err)
|
|
352 |
{
|
|
353 |
WARN_PRINTF2 (_L("DevSound InitializeL left with error = %d"), err);
|
|
354 |
return EInconclusive;
|
|
355 |
}
|
|
356 |
else
|
|
357 |
{
|
|
358 |
CActiveScheduler::Start();
|
|
359 |
if (iCallbackError != iExpectedValue)
|
|
360 |
{
|
|
361 |
ERR_PRINTF3 (_L("DevSound InitializeComplete returned %d, expected %d"), iCallbackError, iExpectedValue);
|
|
362 |
return EFail;
|
|
363 |
}
|
|
364 |
if (iCallbackArray[EInitComplete] != 1)
|
|
365 |
{
|
|
366 |
ERR_PRINTF2 (_L("DevSound InitializeComplete was called %d times, expected 1"), iCallbackArray[EInitComplete]);
|
|
367 |
return EFail;
|
|
368 |
}
|
|
369 |
}
|
|
370 |
return EPass;
|
|
371 |
}
|
|
372 |
|
|
373 |
/**
|
|
374 |
* Initialises dev sound for the given HwDevice uid and tries to instantiate the given interface.
|
|
375 |
*/
|
|
376 |
TAny* CTestStepCustominterfaceUnificationUnit::InitializeAndInstantiateInterfaceL(const TUid aHwDeviceUid, const TUid aInterfaceUid)
|
|
377 |
{
|
|
378 |
TAny* interface = NULL;
|
|
379 |
|
|
380 |
iTestStepResult = TestInitialize(aHwDeviceUid, EMMFStatePlaying);
|
|
381 |
|
|
382 |
if (iTestStepResult == EPass)
|
|
383 |
{
|
|
384 |
INFO_PRINTF1(_L("Successfully initialized DevSound"));
|
|
385 |
interface = iMMFDevSound->CustomInterface(aInterfaceUid);
|
|
386 |
}
|
|
387 |
else
|
|
388 |
{
|
|
389 |
ERR_PRINTF1(_L("Failed to initialize DevSound"));
|
|
390 |
}
|
|
391 |
|
|
392 |
return interface;
|
|
393 |
}
|
|
394 |
|
|
395 |
/**
|
|
396 |
* Initialises dev sound for the given FourCC and tries to instantiate the given interface.
|
|
397 |
*/
|
|
398 |
TAny* CTestStepCustominterfaceUnificationUnit::InitializeAndInstantiateInterfaceL(TFourCC& aDataType, const TUid aInterfaceUid)
|
|
399 |
{
|
|
400 |
TAny* interface = NULL;
|
|
401 |
|
|
402 |
iTestStepResult = TestInitialize(aDataType, EMMFStatePlaying);
|
|
403 |
|
|
404 |
if (iTestStepResult == EPass)
|
|
405 |
{
|
|
406 |
INFO_PRINTF1(_L("Successfully initialized DevSound"));
|
|
407 |
interface = iMMFDevSound->CustomInterface(aInterfaceUid);
|
|
408 |
}
|
|
409 |
else
|
|
410 |
{
|
|
411 |
ERR_PRINTF1(_L("Failed to initialize DevSound"));
|
|
412 |
}
|
|
413 |
|
|
414 |
return interface;
|
|
415 |
}
|
|
416 |
|
|
417 |
/**
|
|
418 |
ReadFileL
|
|
419 |
@param aName
|
|
420 |
@param aData
|
|
421 |
*/
|
|
422 |
void CTestStepCustominterfaceUnificationUnit::ReadFileL(const TDesC &aName, TInt& aData)
|
|
423 |
{
|
|
424 |
User::LeaveIfError(iFs.Connect());
|
|
425 |
|
|
426 |
User::LeaveIfError(iFile.Open(iFs, aName, EFileRead));
|
|
427 |
|
|
428 |
TBuf8<4> data;
|
|
429 |
|
|
430 |
User::LeaveIfError(iFile.Read(data));
|
|
431 |
iFile.Close();
|
|
432 |
|
|
433 |
iFs.Delete(aName);
|
|
434 |
iFs.Close();
|
|
435 |
|
|
436 |
TLex8 lex(data);
|
|
437 |
lex.Val(aData);
|
|
438 |
}
|
|
439 |
|
|
440 |
/**
|
|
441 |
WriteFileL
|
|
442 |
@param aName
|
|
443 |
@param aData
|
|
444 |
*/
|
|
445 |
void CTestStepCustominterfaceUnificationUnit::WriteFileL(const TDesC &aName, TInt aData)
|
|
446 |
{
|
|
447 |
User::LeaveIfError(iFs.Connect());
|
|
448 |
|
|
449 |
iFs.MkDirAll(aName);
|
|
450 |
|
|
451 |
User::LeaveIfError(iFile.Replace(iFs, aName, EFileWrite));
|
|
452 |
|
|
453 |
TBuf8<4> data;
|
|
454 |
data.Format(_L8("%d"), aData);
|
|
455 |
|
|
456 |
User::LeaveIfError(iFile.Write(data));
|
|
457 |
iFile.Close();
|
|
458 |
iFs.Close();
|
|
459 |
}
|
|
460 |
|
|
461 |
/**
|
|
462 |
ResetCallbacks
|
|
463 |
*/
|
|
464 |
void CTestStepCustominterfaceUnificationUnit::ResetCallbacks()
|
|
465 |
{
|
|
466 |
//Initialize callback array
|
|
467 |
iCallbackArray.Reset();
|
|
468 |
}
|