sl@0
|
1 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// TSIMmfCtlfrmStep.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
// EPOC includes
|
sl@0
|
19 |
#include <e32base.h>
|
sl@0
|
20 |
|
sl@0
|
21 |
// Test system includes
|
sl@0
|
22 |
#include <testframework.h>
|
sl@0
|
23 |
#include "TSI_MmfCtlfrmStep.h"
|
sl@0
|
24 |
#include "TSI_MmfCtlfrmSuite.h"
|
sl@0
|
25 |
#include "TSI_MmfCodes.h"
|
sl@0
|
26 |
#include "TSI_MmfEventIds.h"
|
sl@0
|
27 |
#include "ActrlTestUids.h"
|
sl@0
|
28 |
|
sl@0
|
29 |
#include <mmf/common/mmfcontroller.h>
|
sl@0
|
30 |
#include <mmf/plugin/mmfcontrollerimplementationuids.hrh>
|
sl@0
|
31 |
|
sl@0
|
32 |
const TUid KTestControllerUid = {KTSIMmfControllerUid};
|
sl@0
|
33 |
const TUid KTestController2Uid = {KTSIMmfController2Uid};
|
sl@0
|
34 |
//const TUid KTestDataSourceUid = {KTSIMmfDataSourceUid};
|
sl@0
|
35 |
//const TUid KTestDataSinkUid = {KTSIMmfDataSinkUid};
|
sl@0
|
36 |
|
sl@0
|
37 |
// audio controller, from mmfControllerImplementationUIDs.hrh
|
sl@0
|
38 |
//const TUid KTestAudioControllerUid = {KMmfUidControllerAudio};
|
sl@0
|
39 |
|
sl@0
|
40 |
// event values for audio controller testing
|
sl@0
|
41 |
const TInt KDelay = 1000000;
|
sl@0
|
42 |
const TInt KMaxRetries = 12;
|
sl@0
|
43 |
|
sl@0
|
44 |
|
sl@0
|
45 |
// ---------------------------
|
sl@0
|
46 |
// RTestStepMmfCtlfrm
|
sl@0
|
47 |
// base class
|
sl@0
|
48 |
|
sl@0
|
49 |
RTestStepMmfCtlfrm::RTestStepMmfCtlfrm()
|
sl@0
|
50 |
{
|
sl@0
|
51 |
}
|
sl@0
|
52 |
|
sl@0
|
53 |
// ---------------------------
|
sl@0
|
54 |
// RTestStepMmfCtlfrmTest1
|
sl@0
|
55 |
// base class with preamble / postamble to open and close the test controller
|
sl@0
|
56 |
|
sl@0
|
57 |
TVerdict RTestStepMmfCtlfrmTest1::OpenL()
|
sl@0
|
58 |
{
|
sl@0
|
59 |
TInt error = KErrNone;
|
sl@0
|
60 |
|
sl@0
|
61 |
iSettings.iPriority = ETSIMmfPriorityLow;
|
sl@0
|
62 |
iSettings.iPref = EMdaPriorityPreferenceTime;
|
sl@0
|
63 |
iSettings.iState = EMMFStateIdle;
|
sl@0
|
64 |
|
sl@0
|
65 |
// Open a controller
|
sl@0
|
66 |
error = iController.Open(KTestControllerUid, iSettings);
|
sl@0
|
67 |
if (error)
|
sl@0
|
68 |
{
|
sl@0
|
69 |
ERR_PRINTF2(_L("controller failed to open, error %d"), error);
|
sl@0
|
70 |
return iTestStepResult = EInconclusive;
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
return iTestStepResult = EPass;
|
sl@0
|
74 |
}
|
sl@0
|
75 |
|
sl@0
|
76 |
void RTestStepMmfCtlfrmTest1::Close()
|
sl@0
|
77 |
{
|
sl@0
|
78 |
iController.Close();
|
sl@0
|
79 |
|
sl@0
|
80 |
// close controller delay - ensure it has time to finish
|
sl@0
|
81 |
// (so we don't get access violation from something trying to dequeue it before it's closed)
|
sl@0
|
82 |
const TTimeIntervalMicroSeconds32 KCloseControllerDelay = 500000L;
|
sl@0
|
83 |
User::After(KCloseControllerDelay);
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
// ---------------------------
|
sl@0
|
87 |
// RTestStepMmfCtlfrmTest2
|
sl@0
|
88 |
// base class with preamble / postamble to open and close the test controller 2
|
sl@0
|
89 |
|
sl@0
|
90 |
TVerdict RTestStepMmfCtlfrmTest2::OpenL()
|
sl@0
|
91 |
{
|
sl@0
|
92 |
TInt error = KErrNone;
|
sl@0
|
93 |
|
sl@0
|
94 |
iSettings.iPriority = ETSIMmfPriorityLow;
|
sl@0
|
95 |
iSettings.iPref = EMdaPriorityPreferenceTime;
|
sl@0
|
96 |
iSettings.iState = EMMFStateIdle;
|
sl@0
|
97 |
|
sl@0
|
98 |
// Open a controller
|
sl@0
|
99 |
error = iController.Open(KTestController2Uid, iSettings);
|
sl@0
|
100 |
if (error)
|
sl@0
|
101 |
{
|
sl@0
|
102 |
ERR_PRINTF2(_L("controller failed to open, error %d"), error);
|
sl@0
|
103 |
return iTestStepResult = EInconclusive;
|
sl@0
|
104 |
}
|
sl@0
|
105 |
|
sl@0
|
106 |
return iTestStepResult = EPass;
|
sl@0
|
107 |
}
|
sl@0
|
108 |
|
sl@0
|
109 |
void RTestStepMmfCtlfrmTest2::Close()
|
sl@0
|
110 |
{
|
sl@0
|
111 |
iController.Close();
|
sl@0
|
112 |
// close controller delay - ensure it has time to finish
|
sl@0
|
113 |
// (so we don't get access violation from something trying to dequeue it before it's closed)
|
sl@0
|
114 |
const TTimeIntervalMicroSeconds32 KCloseControllerDelay = 500000L;
|
sl@0
|
115 |
User::After(KCloseControllerDelay);
|
sl@0
|
116 |
}
|
sl@0
|
117 |
|
sl@0
|
118 |
// ---------------------------
|
sl@0
|
119 |
// RTestStepMmfCtlfrmAudio
|
sl@0
|
120 |
// base class with preamble / postamble to open and close the audio controller
|
sl@0
|
121 |
|
sl@0
|
122 |
TVerdict RTestStepMmfCtlfrmAudio::OpenL()
|
sl@0
|
123 |
{
|
sl@0
|
124 |
TInt error = KErrNone;
|
sl@0
|
125 |
|
sl@0
|
126 |
iSettings.iPriority = ETSIMmfPriorityHigh;
|
sl@0
|
127 |
iSettings.iPref = EMdaPriorityPreferenceQuality;
|
sl@0
|
128 |
iSettings.iState = EMMFStateIdle;
|
sl@0
|
129 |
|
sl@0
|
130 |
// Open a controller
|
sl@0
|
131 |
error = iController.Open(KUidCustomTestAudioPlugin, iSettings);
|
sl@0
|
132 |
// error = iController.Open(KTestAudioControllerUid, iSettings);
|
sl@0
|
133 |
if (error)
|
sl@0
|
134 |
{
|
sl@0
|
135 |
ERR_PRINTF2(_L("controller failed to open, error %d"), error);
|
sl@0
|
136 |
return iTestStepResult = EInconclusive;
|
sl@0
|
137 |
}
|
sl@0
|
138 |
|
sl@0
|
139 |
INFO_PRINTF2(_L("Opened Custom Audio Controller, UID 0x%8x"), KUidCustomTestAudioPlugin);
|
sl@0
|
140 |
// Add a source and sink
|
sl@0
|
141 |
_LIT(KTestWavFile, "c:\\TsiMmfCtlfrmData\\test.wav");
|
sl@0
|
142 |
iFileConfig().iPath = KTestWavFile;
|
sl@0
|
143 |
error = iController.AddDataSource(KUidMmfFileSource, iFileConfig);
|
sl@0
|
144 |
if (error)
|
sl@0
|
145 |
{
|
sl@0
|
146 |
ERR_PRINTF2(_L("failed to add a data source, error %d"), error);
|
sl@0
|
147 |
Close();
|
sl@0
|
148 |
return iTestStepResult = EInconclusive;
|
sl@0
|
149 |
}
|
sl@0
|
150 |
error = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
|
sl@0
|
151 |
if (error)
|
sl@0
|
152 |
{
|
sl@0
|
153 |
ERR_PRINTF2(_L("failed to add a data sink, error %d"), error);
|
sl@0
|
154 |
Close();
|
sl@0
|
155 |
return iTestStepResult = EInconclusive;
|
sl@0
|
156 |
}
|
sl@0
|
157 |
|
sl@0
|
158 |
return iTestStepResult = EPass;
|
sl@0
|
159 |
}
|
sl@0
|
160 |
|
sl@0
|
161 |
void RTestStepMmfCtlfrmAudio::Close()
|
sl@0
|
162 |
{
|
sl@0
|
163 |
iController.Stop();
|
sl@0
|
164 |
iController.Reset();
|
sl@0
|
165 |
iController.Close();
|
sl@0
|
166 |
// close controller delay - ensure it has time to finish
|
sl@0
|
167 |
// (so we don't get access violation from something trying to dequeue it before it's closed)
|
sl@0
|
168 |
const TTimeIntervalMicroSeconds32 KCloseControllerDelay = 500000L;
|
sl@0
|
169 |
User::After(KCloseControllerDelay);
|
sl@0
|
170 |
}
|
sl@0
|
171 |
|
sl@0
|
172 |
// Searches for an event
|
sl@0
|
173 |
TVerdict RTestStepMmfCtlfrmAudio::SearchForEvent( TMMFEvent& aEvent )
|
sl@0
|
174 |
{
|
sl@0
|
175 |
#ifdef EVENT_SEARCH_DISABLED
|
sl@0
|
176 |
WARN_PRINTF1(_L("Warning : SearchForEvent disabled"));
|
sl@0
|
177 |
TMMFEvent dummyEvent; // JS
|
sl@0
|
178 |
aEvent = dummyEvent; // to get rid of compiler warning
|
sl@0
|
179 |
return EPass;
|
sl@0
|
180 |
#else
|
sl@0
|
181 |
|
sl@0
|
182 |
TVerdict result = EFail;
|
sl@0
|
183 |
|
sl@0
|
184 |
// status of events
|
sl@0
|
185 |
TRequestStatus timerStatus;
|
sl@0
|
186 |
TRequestStatus eventStatus;
|
sl@0
|
187 |
|
sl@0
|
188 |
// due to problems with the timer as a member variable
|
sl@0
|
189 |
// added a local timer here
|
sl@0
|
190 |
RTimer myTimer ;
|
sl@0
|
191 |
myTimer.CreateLocal();
|
sl@0
|
192 |
|
sl@0
|
193 |
// create an event and initialise with unknown marker
|
sl@0
|
194 |
|
sl@0
|
195 |
TMMFEventPckg receivedEvent;
|
sl@0
|
196 |
|
sl@0
|
197 |
// for KMaxRetries attempt to find the event
|
sl@0
|
198 |
for( TInt retries = 0; retries < KMaxRetries; retries++ )
|
sl@0
|
199 |
{
|
sl@0
|
200 |
// post receive event to controller
|
sl@0
|
201 |
iController.ReceiveEvents( receivedEvent, eventStatus );
|
sl@0
|
202 |
// start breakout timer to escape
|
sl@0
|
203 |
myTimer.After(timerStatus, KDelay);
|
sl@0
|
204 |
|
sl@0
|
205 |
// wait for an event to mature
|
sl@0
|
206 |
User::WaitForRequest( eventStatus, timerStatus );
|
sl@0
|
207 |
|
sl@0
|
208 |
// check if the command is the event
|
sl@0
|
209 |
// and that a timeout did not occur
|
sl@0
|
210 |
if( IsTimeOut( eventStatus ))
|
sl@0
|
211 |
{
|
sl@0
|
212 |
// cancel the receive events
|
sl@0
|
213 |
CancelReceivedEvents();
|
sl@0
|
214 |
}
|
sl@0
|
215 |
else if( IsSoughtEvent( aEvent, receivedEvent ) )
|
sl@0
|
216 |
{
|
sl@0
|
217 |
// cancel the outstanding timer
|
sl@0
|
218 |
User::Check();
|
sl@0
|
219 |
myTimer.Cancel();
|
sl@0
|
220 |
// set status to pass since we have found the event
|
sl@0
|
221 |
result = EPass;
|
sl@0
|
222 |
break;
|
sl@0
|
223 |
}
|
sl@0
|
224 |
else
|
sl@0
|
225 |
{
|
sl@0
|
226 |
// We rx'd an event other than expected
|
sl@0
|
227 |
myTimer.Cancel();
|
sl@0
|
228 |
}
|
sl@0
|
229 |
}
|
sl@0
|
230 |
return result;
|
sl@0
|
231 |
#endif // EVENT_SEARCH_DISABLED
|
sl@0
|
232 |
}
|
sl@0
|
233 |
|
sl@0
|
234 |
TBool RTestStepMmfCtlfrmAudio::IsTimeOut( TRequestStatus& aEventStatus )
|
sl@0
|
235 |
{
|
sl@0
|
236 |
return ( aEventStatus == KRequestPending);
|
sl@0
|
237 |
}
|
sl@0
|
238 |
|
sl@0
|
239 |
TBool RTestStepMmfCtlfrmAudio::IsSoughtEvent( TMMFEvent& aExpectedEvent, TMMFEventPckg& aReceivedEvent )
|
sl@0
|
240 |
{
|
sl@0
|
241 |
|
sl@0
|
242 |
TInt expectedUid = aExpectedEvent.iEventType.iUid;
|
sl@0
|
243 |
TInt receivedUid = aReceivedEvent().iEventType.iUid;
|
sl@0
|
244 |
|
sl@0
|
245 |
// display any events we get
|
sl@0
|
246 |
INFO_PRINTF3(_L("Event received : 0x%08x %d"),
|
sl@0
|
247 |
aReceivedEvent().iEventType.iUid, aReceivedEvent().iErrorCode);
|
sl@0
|
248 |
|
sl@0
|
249 |
return ((expectedUid == receivedUid) &&
|
sl@0
|
250 |
(aExpectedEvent.iErrorCode == aReceivedEvent().iErrorCode));
|
sl@0
|
251 |
}
|
sl@0
|
252 |
|
sl@0
|
253 |
void RTestStepMmfCtlfrmAudio::CancelReceivedEvents()
|
sl@0
|
254 |
{
|
sl@0
|
255 |
iController.CancelReceiveEvents();
|
sl@0
|
256 |
}
|
sl@0
|
257 |
|
sl@0
|
258 |
// ---------------------------
|
sl@0
|
259 |
// RTestStepMmfCtlfrmAudioPrimed
|
sl@0
|
260 |
// as above, with source / sink handles, primed in preamble
|
sl@0
|
261 |
|
sl@0
|
262 |
TVerdict RTestStepMmfCtlfrmAudioPrimed::OpenL()
|
sl@0
|
263 |
{
|
sl@0
|
264 |
// initialise the controller, including adding source and sink; prime it.
|
sl@0
|
265 |
// retain handles to the source and sink so we can verify them after reset
|
sl@0
|
266 |
TInt error = KErrNone;
|
sl@0
|
267 |
TVerdict result = EPass;
|
sl@0
|
268 |
|
sl@0
|
269 |
iSourceHandlePtr = NULL;
|
sl@0
|
270 |
iSinkHandlePtr = NULL;
|
sl@0
|
271 |
|
sl@0
|
272 |
iSettings.iPriority = ETSIMmfPriorityHigh;
|
sl@0
|
273 |
iSettings.iPref = EMdaPriorityPreferenceQuality;
|
sl@0
|
274 |
iSettings.iState = EMMFStateIdle;
|
sl@0
|
275 |
|
sl@0
|
276 |
// Open a controller
|
sl@0
|
277 |
error = iController.Open(KUidCustomTestAudioPlugin, iSettings);
|
sl@0
|
278 |
if (error)
|
sl@0
|
279 |
{
|
sl@0
|
280 |
ERR_PRINTF2(_L("controller failed to open, error %d"), error);
|
sl@0
|
281 |
return iTestStepResult = EInconclusive;
|
sl@0
|
282 |
}
|
sl@0
|
283 |
|
sl@0
|
284 |
INFO_PRINTF2(_L("Opened Custom Audio Controller, UID 0x%8x"), KUidCustomTestAudioPlugin);
|
sl@0
|
285 |
// Add a source and sink
|
sl@0
|
286 |
_LIT(KTestWavFile, "c:\\TsiMmfCtlfrmData\\test.wav");
|
sl@0
|
287 |
iFileConfig().iPath = KTestWavFile;
|
sl@0
|
288 |
|
sl@0
|
289 |
// add a data source with a handle
|
sl@0
|
290 |
iSourceHandlePtr = new (ELeave) TMMFMessageDestination();
|
sl@0
|
291 |
TMMFMessageDestination& sourceHandle = *iSourceHandlePtr;
|
sl@0
|
292 |
error = iController.AddDataSource(KUidMmfFileSource, iFileConfig, sourceHandle);
|
sl@0
|
293 |
if (error)
|
sl@0
|
294 |
{
|
sl@0
|
295 |
ERR_PRINTF2(_L("AddDataSource failed, error %d"), error);
|
sl@0
|
296 |
Close();
|
sl@0
|
297 |
return iTestStepResult = EInconclusive;
|
sl@0
|
298 |
}
|
sl@0
|
299 |
|
sl@0
|
300 |
// add a data sink with a handle
|
sl@0
|
301 |
iSinkHandlePtr = new (ELeave) TMMFMessageDestination();
|
sl@0
|
302 |
TMMFMessageDestination& sinkHandle = *iSinkHandlePtr;
|
sl@0
|
303 |
|
sl@0
|
304 |
error = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8, sinkHandle);
|
sl@0
|
305 |
if (error)
|
sl@0
|
306 |
{
|
sl@0
|
307 |
ERR_PRINTF2(_L("AddDataSink failed, error %d"), error);
|
sl@0
|
308 |
Close();
|
sl@0
|
309 |
return iTestStepResult = EInconclusive;
|
sl@0
|
310 |
}
|
sl@0
|
311 |
|
sl@0
|
312 |
// prime it
|
sl@0
|
313 |
error = iController.Prime();
|
sl@0
|
314 |
if(error)
|
sl@0
|
315 |
{
|
sl@0
|
316 |
ERR_PRINTF2(_L("Prime failed, error %d"), error);
|
sl@0
|
317 |
Close();
|
sl@0
|
318 |
return iTestStepResult = EInconclusive;
|
sl@0
|
319 |
}
|
sl@0
|
320 |
|
sl@0
|
321 |
// wait for and process the return event from the custom audio controller
|
sl@0
|
322 |
TMMFEvent primeEvent( KPrimeTestId, KErrNone);
|
sl@0
|
323 |
result = SearchForEvent( primeEvent );
|
sl@0
|
324 |
if( result == EFail )
|
sl@0
|
325 |
{
|
sl@0
|
326 |
ERR_PRINTF1(_L("Custom audio controller did not return a prime event"));
|
sl@0
|
327 |
Close();
|
sl@0
|
328 |
return iTestStepResult = EInconclusive;
|
sl@0
|
329 |
}
|
sl@0
|
330 |
|
sl@0
|
331 |
return iTestStepResult = EPass;
|
sl@0
|
332 |
}
|
sl@0
|
333 |
|
sl@0
|
334 |
void RTestStepMmfCtlfrmAudioPrimed::Close()
|
sl@0
|
335 |
{
|
sl@0
|
336 |
iController.Stop();
|
sl@0
|
337 |
iController.Reset();
|
sl@0
|
338 |
delete iSinkHandlePtr;
|
sl@0
|
339 |
delete iSourceHandlePtr;
|
sl@0
|
340 |
iController.Close();
|
sl@0
|
341 |
// close controller delay - ensure it has time to finish
|
sl@0
|
342 |
// (so we don't get access violation from something trying to dequeue it before it's closed)
|
sl@0
|
343 |
const TTimeIntervalMicroSeconds32 KCloseControllerDelay = 500000L;
|
sl@0
|
344 |
User::After(KCloseControllerDelay);
|
sl@0
|
345 |
}
|
sl@0
|
346 |
|
sl@0
|
347 |
|
sl@0
|
348 |
// ---------------------------
|
sl@0
|
349 |
// RTestStepMmfCtlfrmAudioNoSource
|
sl@0
|
350 |
// same as RTestStepMmfCtlfrmAudio, but has no source or sink loaded yet
|
sl@0
|
351 |
TVerdict RTestStepMmfCtlfrmAudioNoSource::OpenL()
|
sl@0
|
352 |
{
|
sl@0
|
353 |
// preamble - load a controller but give it no data source
|
sl@0
|
354 |
TInt error = KErrNone;
|
sl@0
|
355 |
|
sl@0
|
356 |
iSettings.iPriority = ETSIMmfPriorityHigh;
|
sl@0
|
357 |
iSettings.iPref = EMdaPriorityPreferenceQuality;
|
sl@0
|
358 |
iSettings.iState = EMMFStateIdle;
|
sl@0
|
359 |
|
sl@0
|
360 |
// Open a controller
|
sl@0
|
361 |
error = iController.Open(KUidCustomTestAudioPlugin, iSettings);
|
sl@0
|
362 |
if (error)
|
sl@0
|
363 |
{
|
sl@0
|
364 |
ERR_PRINTF2(_L("controller failed to open, error %d"), error);
|
sl@0
|
365 |
return iTestStepResult = EInconclusive;
|
sl@0
|
366 |
}
|
sl@0
|
367 |
|
sl@0
|
368 |
INFO_PRINTF2(_L("Opened Custom Audio Controller, UID 0x%8x"), KUidCustomTestAudioPlugin);
|
sl@0
|
369 |
return iTestStepResult = EPass;
|
sl@0
|
370 |
}
|
sl@0
|
371 |
|
sl@0
|
372 |
// ---------------------------
|
sl@0
|
373 |
// RTestStepMmfCtlfrmDualAudio
|
sl@0
|
374 |
// same as RTestStepMmfCtlfrmAudio, with 2 identical controllers
|
sl@0
|
375 |
|
sl@0
|
376 |
TVerdict RTestStepMmfCtlfrmDualAudio::OpenL()
|
sl@0
|
377 |
{
|
sl@0
|
378 |
TInt error = KErrNone;
|
sl@0
|
379 |
|
sl@0
|
380 |
iSettings.iPriority = ETSIMmfPriorityHigh;
|
sl@0
|
381 |
iSettings.iPref = EMdaPriorityPreferenceTime;
|
sl@0
|
382 |
iSettings.iState = EMMFStateIdle;
|
sl@0
|
383 |
|
sl@0
|
384 |
// Open both controllers
|
sl@0
|
385 |
error = iController1.Open(KUidCustomTestAudioPlugin, iSettings);
|
sl@0
|
386 |
if (error)
|
sl@0
|
387 |
{
|
sl@0
|
388 |
ERR_PRINTF2(_L("iController1 failed to open, error %d"), error);
|
sl@0
|
389 |
return iTestStepResult = EInconclusive;
|
sl@0
|
390 |
}
|
sl@0
|
391 |
INFO_PRINTF2(_L("Controller 1 : Opened Custom Audio Controller, UID 0x%8x"), KUidCustomTestAudioPlugin);
|
sl@0
|
392 |
error = iController2.Open(KUidCustomTestAudioPlugin, iSettings);
|
sl@0
|
393 |
if (error)
|
sl@0
|
394 |
{
|
sl@0
|
395 |
ERR_PRINTF2(_L("iController2 failed to open, error %d"), error);
|
sl@0
|
396 |
Close();
|
sl@0
|
397 |
return iTestStepResult = EInconclusive;
|
sl@0
|
398 |
}
|
sl@0
|
399 |
INFO_PRINTF2(_L("Controller 2 : Opened Custom Audio Controller, UID 0x%8x"), KUidCustomTestAudioPlugin);
|
sl@0
|
400 |
|
sl@0
|
401 |
// Add source and sink
|
sl@0
|
402 |
// Use two different files to avoid conflict
|
sl@0
|
403 |
_LIT(KTestWavFile1, "c:\\TsiMmfCtlfrmData\\test.wav");
|
sl@0
|
404 |
_LIT(KTestWavFile2, "c:\\TsiMmfCtlfrmData\\test2.wav");
|
sl@0
|
405 |
iFileConfig1().iPath = KTestWavFile1;
|
sl@0
|
406 |
iFileConfig2().iPath = KTestWavFile2;
|
sl@0
|
407 |
error = iController1.AddDataSource(KUidMmfFileSource, iFileConfig1);
|
sl@0
|
408 |
if (error)
|
sl@0
|
409 |
{
|
sl@0
|
410 |
ERR_PRINTF2(_L("iController1 failed to add a data source, error %d"), error);
|
sl@0
|
411 |
return iTestStepResult = EInconclusive;
|
sl@0
|
412 |
}
|
sl@0
|
413 |
error = iController1.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
|
sl@0
|
414 |
if (error)
|
sl@0
|
415 |
{
|
sl@0
|
416 |
ERR_PRINTF2(_L("iController1 failed to add a data sink, error %d"), error);
|
sl@0
|
417 |
Close();
|
sl@0
|
418 |
return iTestStepResult = EInconclusive;
|
sl@0
|
419 |
}
|
sl@0
|
420 |
error = iController2.AddDataSource(KUidMmfFileSource, iFileConfig2);
|
sl@0
|
421 |
if (error)
|
sl@0
|
422 |
{
|
sl@0
|
423 |
ERR_PRINTF2(_L("iController2 failed to add a data source, error %d"), error);
|
sl@0
|
424 |
Close();
|
sl@0
|
425 |
return iTestStepResult = EInconclusive;
|
sl@0
|
426 |
}
|
sl@0
|
427 |
error = iController2.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
|
sl@0
|
428 |
if (error)
|
sl@0
|
429 |
{
|
sl@0
|
430 |
ERR_PRINTF2(_L("iController2 failed to add a data sink, error %d"), error);
|
sl@0
|
431 |
Close();
|
sl@0
|
432 |
return iTestStepResult = EInconclusive;
|
sl@0
|
433 |
}
|
sl@0
|
434 |
|
sl@0
|
435 |
return iTestStepResult = EPass;
|
sl@0
|
436 |
}
|
sl@0
|
437 |
|
sl@0
|
438 |
void RTestStepMmfCtlfrmDualAudio::Close()
|
sl@0
|
439 |
{
|
sl@0
|
440 |
iController1.Stop();
|
sl@0
|
441 |
iController1.Reset();
|
sl@0
|
442 |
iController1.Close();
|
sl@0
|
443 |
|
sl@0
|
444 |
iController2.Stop();
|
sl@0
|
445 |
iController2.Reset();
|
sl@0
|
446 |
iController2.Close();
|
sl@0
|
447 |
|
sl@0
|
448 |
// close controller delay - ensure it has time to finish
|
sl@0
|
449 |
// (so we don't get access violation from something trying to dequeue it before it's closed)
|
sl@0
|
450 |
const TTimeIntervalMicroSeconds32 KCloseControllerDelay = 500000L;
|
sl@0
|
451 |
User::After(KCloseControllerDelay);
|
sl@0
|
452 |
}
|
sl@0
|
453 |
|
sl@0
|
454 |
// Searches for an event
|
sl@0
|
455 |
TVerdict RTestStepMmfCtlfrmDualAudio::SearchForEvent( TMMFEvent& aEvent, TInt aWhichController )
|
sl@0
|
456 |
{
|
sl@0
|
457 |
// NB don't worry about EVENT_SEARCH_DISABLED here,
|
sl@0
|
458 |
// as generally we'll be looking for events from the Controller Framework here,
|
sl@0
|
459 |
// not from the custom Audio Controller
|
sl@0
|
460 |
|
sl@0
|
461 |
TVerdict result = EFail;
|
sl@0
|
462 |
|
sl@0
|
463 |
// status of events
|
sl@0
|
464 |
TRequestStatus timerStatus ;
|
sl@0
|
465 |
TRequestStatus eventStatus ;
|
sl@0
|
466 |
|
sl@0
|
467 |
RMMFController* theController;
|
sl@0
|
468 |
// which controller are we searching on?
|
sl@0
|
469 |
if(aWhichController == 1)
|
sl@0
|
470 |
theController = &iController1;
|
sl@0
|
471 |
else if(aWhichController == 2)
|
sl@0
|
472 |
theController = &iController2;
|
sl@0
|
473 |
else
|
sl@0
|
474 |
{
|
sl@0
|
475 |
ERR_PRINTF1(_L("SearchForEvent error : controller must be 1 or 2"));
|
sl@0
|
476 |
return result = EFail;
|
sl@0
|
477 |
}
|
sl@0
|
478 |
|
sl@0
|
479 |
// due to problems with the timer as a member variable
|
sl@0
|
480 |
// added a local timer here
|
sl@0
|
481 |
RTimer myTimer ;
|
sl@0
|
482 |
myTimer.CreateLocal();
|
sl@0
|
483 |
|
sl@0
|
484 |
// create an event and initialise with unknown marker
|
sl@0
|
485 |
|
sl@0
|
486 |
TMMFEventPckg receivedEvent;
|
sl@0
|
487 |
|
sl@0
|
488 |
// for KMaxRetries attempt to find the event
|
sl@0
|
489 |
for( TInt retries = 0; retries < KMaxRetries; retries++ )
|
sl@0
|
490 |
{
|
sl@0
|
491 |
// post receive event to controller
|
sl@0
|
492 |
(*theController).ReceiveEvents( receivedEvent, eventStatus );
|
sl@0
|
493 |
// start breakout timer to escape
|
sl@0
|
494 |
myTimer.After( timerStatus, KDelay );
|
sl@0
|
495 |
|
sl@0
|
496 |
// wait for an event to mature
|
sl@0
|
497 |
User::WaitForRequest( eventStatus, timerStatus );
|
sl@0
|
498 |
|
sl@0
|
499 |
// check if the command is the event
|
sl@0
|
500 |
// and that a timeout did not occur
|
sl@0
|
501 |
if( IsTimeOut( eventStatus ))
|
sl@0
|
502 |
{
|
sl@0
|
503 |
// cancel the receive events
|
sl@0
|
504 |
CancelReceivedEvents(aWhichController);
|
sl@0
|
505 |
}
|
sl@0
|
506 |
else if( IsSoughtEvent( aEvent, receivedEvent ) )
|
sl@0
|
507 |
{
|
sl@0
|
508 |
// cancel the outstanding timer
|
sl@0
|
509 |
User::Check();
|
sl@0
|
510 |
myTimer.Cancel();
|
sl@0
|
511 |
// set status to pass since we have found the event
|
sl@0
|
512 |
result = EPass;
|
sl@0
|
513 |
break;
|
sl@0
|
514 |
}
|
sl@0
|
515 |
else
|
sl@0
|
516 |
{
|
sl@0
|
517 |
// We rx'd an event other than expected
|
sl@0
|
518 |
myTimer.Cancel();
|
sl@0
|
519 |
}
|
sl@0
|
520 |
}
|
sl@0
|
521 |
return result;
|
sl@0
|
522 |
}
|
sl@0
|
523 |
|
sl@0
|
524 |
TBool RTestStepMmfCtlfrmDualAudio::IsTimeOut( TRequestStatus& aEventStatus )
|
sl@0
|
525 |
{
|
sl@0
|
526 |
return (aEventStatus == KRequestPending);
|
sl@0
|
527 |
}
|
sl@0
|
528 |
|
sl@0
|
529 |
TBool RTestStepMmfCtlfrmDualAudio::IsSoughtEvent( TMMFEvent& aExpectedEvent, TMMFEventPckg& aReceivedEvent )
|
sl@0
|
530 |
{
|
sl@0
|
531 |
|
sl@0
|
532 |
TInt expectedUid = aExpectedEvent.iEventType.iUid;
|
sl@0
|
533 |
TInt receivedUid = aReceivedEvent().iEventType.iUid;
|
sl@0
|
534 |
|
sl@0
|
535 |
// display any events we get
|
sl@0
|
536 |
INFO_PRINTF3(_L("Event expected : 0x%08x %d"),
|
sl@0
|
537 |
expectedUid, aExpectedEvent.iErrorCode);
|
sl@0
|
538 |
INFO_PRINTF3(_L("Event received : 0x%08x %d"),
|
sl@0
|
539 |
aReceivedEvent().iEventType.iUid, aReceivedEvent().iErrorCode);
|
sl@0
|
540 |
|
sl@0
|
541 |
return ((expectedUid == receivedUid) &&
|
sl@0
|
542 |
(aExpectedEvent.iErrorCode == aReceivedEvent().iErrorCode));
|
sl@0
|
543 |
}
|
sl@0
|
544 |
|
sl@0
|
545 |
void RTestStepMmfCtlfrmDualAudio::CancelReceivedEvents(TInt aWhichController)
|
sl@0
|
546 |
{
|
sl@0
|
547 |
RMMFController* theController;
|
sl@0
|
548 |
// which controller are we searching on?
|
sl@0
|
549 |
if(aWhichController == 1)
|
sl@0
|
550 |
theController = &iController1;
|
sl@0
|
551 |
else if(aWhichController == 2)
|
sl@0
|
552 |
theController = &iController2;
|
sl@0
|
553 |
else
|
sl@0
|
554 |
{
|
sl@0
|
555 |
ERR_PRINTF1(_L("CancelReceivedEvents error : controller must be 1 or 2"));
|
sl@0
|
556 |
return;
|
sl@0
|
557 |
}
|
sl@0
|
558 |
(*theController).CancelReceiveEvents();
|
sl@0
|
559 |
}
|
sl@0
|
560 |
|
sl@0
|
561 |
// ---------------------------
|
sl@0
|
562 |
// RTestStepMmfCtlfrmVideo
|
sl@0
|
563 |
// base class with preamble / postamble to open and close the video controller
|
sl@0
|
564 |
// NB we're only actually using this to test custom commands
|
sl@0
|
565 |
|
sl@0
|
566 |
TVerdict RTestStepMmfCtlfrmVideo::OpenL()
|
sl@0
|
567 |
{
|
sl@0
|
568 |
TInt error = KErrNone;
|
sl@0
|
569 |
|
sl@0
|
570 |
iSettings.iPriority = ETSIMmfPriorityHigh;
|
sl@0
|
571 |
iSettings.iPref = EMdaPriorityPreferenceQuality;
|
sl@0
|
572 |
iSettings.iState = EMMFStateIdle;
|
sl@0
|
573 |
|
sl@0
|
574 |
// Open a controller
|
sl@0
|
575 |
error = iController.Open(KMmfVideoTestControllerUid, iSettings);
|
sl@0
|
576 |
if (error)
|
sl@0
|
577 |
{
|
sl@0
|
578 |
ERR_PRINTF2(_L("controller failed to open, error %d"), error);
|
sl@0
|
579 |
return iTestStepResult = EInconclusive;
|
sl@0
|
580 |
}
|
sl@0
|
581 |
|
sl@0
|
582 |
INFO_PRINTF2(_L("Opened Custom Video Controller, UID 0x%8x"), KMmfVideoTestControllerUid);
|
sl@0
|
583 |
// Add a source and sink
|
sl@0
|
584 |
_LIT(KTestAviFile, "c:\\VclntITestData\\LongVideo.avi");
|
sl@0
|
585 |
iFileConfig().iPath = KTestAviFile;
|
sl@0
|
586 |
error = iController.AddDataSource(KUidMmfFileSource, iFileConfig);
|
sl@0
|
587 |
if (error)
|
sl@0
|
588 |
{
|
sl@0
|
589 |
ERR_PRINTF2(_L("failed to add a data source, error %d"), error);
|
sl@0
|
590 |
Close();
|
sl@0
|
591 |
return iTestStepResult = EInconclusive;
|
sl@0
|
592 |
}
|
sl@0
|
593 |
error = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
|
sl@0
|
594 |
if (error)
|
sl@0
|
595 |
{
|
sl@0
|
596 |
ERR_PRINTF2(_L("failed to add a data sink, error %d"), error);
|
sl@0
|
597 |
Close();
|
sl@0
|
598 |
return iTestStepResult = EInconclusive;
|
sl@0
|
599 |
}
|
sl@0
|
600 |
|
sl@0
|
601 |
return iTestStepResult = EPass;
|
sl@0
|
602 |
}
|
sl@0
|
603 |
|
sl@0
|
604 |
void RTestStepMmfCtlfrmVideo::Close()
|
sl@0
|
605 |
{
|
sl@0
|
606 |
iController.Stop();
|
sl@0
|
607 |
iController.Reset();
|
sl@0
|
608 |
iController.Close();
|
sl@0
|
609 |
// close controller delay - ensure it has time to finish
|
sl@0
|
610 |
// (so we don't get access violation from something trying to dequeue it before it's closed)
|
sl@0
|
611 |
const TTimeIntervalMicroSeconds32 KCloseControllerDelay = 500000L;
|
sl@0
|
612 |
User::After(KCloseControllerDelay);
|
sl@0
|
613 |
}
|
sl@0
|
614 |
|