sl@0
|
1 |
// Copyright (c) 2005-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 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <testframework.h>
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "TSU_MMFMIDICLNT.h"
|
sl@0
|
19 |
#include "TS_MMFMIDICLNTsuite.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
#include "TestMidiClientUtility.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
_LIT(KDrmSectName, "SectionDRM");
|
sl@0
|
24 |
_LIT(KDrmFileKey, "MidiDrmContent");
|
sl@0
|
25 |
|
sl@0
|
26 |
const TInt K1Second =1000000;
|
sl@0
|
27 |
const TInt K5Seconds = 5 * K1Second;
|
sl@0
|
28 |
const TInt K30Seconds =30 * K1Second;
|
sl@0
|
29 |
|
sl@0
|
30 |
class CCallbackTimer : public CTimer
|
sl@0
|
31 |
{
|
sl@0
|
32 |
public:
|
sl@0
|
33 |
static CCallbackTimer* NewL();
|
sl@0
|
34 |
~CCallbackTimer();
|
sl@0
|
35 |
void SetCb(TCallBack aCallback)
|
sl@0
|
36 |
{
|
sl@0
|
37 |
iCallback = aCallback;
|
sl@0
|
38 |
}
|
sl@0
|
39 |
void After(TTimeIntervalMicroSeconds32 aCancelDelay)
|
sl@0
|
40 |
{
|
sl@0
|
41 |
CTimer::After(aCancelDelay);
|
sl@0
|
42 |
}
|
sl@0
|
43 |
void After(TTimeIntervalMicroSeconds32 aCancelDelay, TCallBack aCallback);
|
sl@0
|
44 |
|
sl@0
|
45 |
private:
|
sl@0
|
46 |
CCallbackTimer();
|
sl@0
|
47 |
// from CActive
|
sl@0
|
48 |
void RunL();
|
sl@0
|
49 |
|
sl@0
|
50 |
private:
|
sl@0
|
51 |
TCallBack iCallback;
|
sl@0
|
52 |
};
|
sl@0
|
53 |
|
sl@0
|
54 |
CCallbackTimer* CCallbackTimer::NewL()
|
sl@0
|
55 |
{
|
sl@0
|
56 |
CCallbackTimer* self=new (ELeave) CCallbackTimer();
|
sl@0
|
57 |
CleanupStack::PushL(self);
|
sl@0
|
58 |
self->ConstructL();
|
sl@0
|
59 |
CleanupStack::Pop();
|
sl@0
|
60 |
return self;
|
sl@0
|
61 |
}
|
sl@0
|
62 |
|
sl@0
|
63 |
CCallbackTimer::CCallbackTimer():CTimer(EPriorityHigh)
|
sl@0
|
64 |
{
|
sl@0
|
65 |
CActiveScheduler::Add(this);
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
CCallbackTimer::~CCallbackTimer()
|
sl@0
|
69 |
{
|
sl@0
|
70 |
Cancel();
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
|
sl@0
|
74 |
void CCallbackTimer::After(TTimeIntervalMicroSeconds32 aCancelDelay, TCallBack aCallback)
|
sl@0
|
75 |
{
|
sl@0
|
76 |
iCallback = aCallback;
|
sl@0
|
77 |
CTimer::After(aCancelDelay);
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|
sl@0
|
80 |
/**
|
sl@0
|
81 |
*
|
sl@0
|
82 |
* RunL
|
sl@0
|
83 |
*
|
sl@0
|
84 |
**/
|
sl@0
|
85 |
void CCallbackTimer::RunL()
|
sl@0
|
86 |
{
|
sl@0
|
87 |
iCallback.CallBack();
|
sl@0
|
88 |
}
|
sl@0
|
89 |
|
sl@0
|
90 |
|
sl@0
|
91 |
|
sl@0
|
92 |
CTestStepDrm::CTestStepDrm(const TDesC& aTestName, const TTestStepType aTestType, const TDrmTestParams& aDrmParams):
|
sl@0
|
93 |
CTestMmfMidiClntStep(aTestName, aTestType),
|
sl@0
|
94 |
iDrmParams(aDrmParams)
|
sl@0
|
95 |
{
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
TVerdict CTestStepDrm::DoTestStepPreambleL()
|
sl@0
|
99 |
{
|
sl@0
|
100 |
if (EPass==CTestMmfMidiClntStep::DoTestStepPreambleL())
|
sl@0
|
101 |
{
|
sl@0
|
102 |
iTimer = CCallbackTimer::NewL();
|
sl@0
|
103 |
iTimer->SetCb(TCallBack(TimerGate, this));
|
sl@0
|
104 |
User::LeaveIfError( iFs.Connect() );
|
sl@0
|
105 |
return EPass;
|
sl@0
|
106 |
}
|
sl@0
|
107 |
return EFail;
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
TVerdict CTestStepDrm::DoTestStepPostambleL()
|
sl@0
|
111 |
{
|
sl@0
|
112 |
delete iTimer;
|
sl@0
|
113 |
iTimer = NULL;
|
sl@0
|
114 |
|
sl@0
|
115 |
iFile.Close();
|
sl@0
|
116 |
iFs.Close();
|
sl@0
|
117 |
return CTestMmfMidiClntStep::DoTestStepPostambleL();
|
sl@0
|
118 |
}
|
sl@0
|
119 |
|
sl@0
|
120 |
TVerdict CTestStepDrm::DoTestStepL()
|
sl@0
|
121 |
{
|
sl@0
|
122 |
if (iDrmParams.iTestMode != TDrmTestParams::EAlloc)
|
sl@0
|
123 |
{
|
sl@0
|
124 |
return CTestMmfMidiClntStep::DoTestStepL();
|
sl@0
|
125 |
}
|
sl@0
|
126 |
TVerdict result=EPass;
|
sl@0
|
127 |
TInt failCount = 1;
|
sl@0
|
128 |
TBool completed = EFalse;
|
sl@0
|
129 |
CMidiClientUtility* midiClnt = NULL;
|
sl@0
|
130 |
TInt err;
|
sl@0
|
131 |
while(!completed)
|
sl@0
|
132 |
{
|
sl@0
|
133 |
iError = KErrNone;
|
sl@0
|
134 |
__UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
|
sl@0
|
135 |
__MM_HEAP_MARK;
|
sl@0
|
136 |
|
sl@0
|
137 |
TRAP( err,
|
sl@0
|
138 |
midiClnt = CMidiClientUtility::NewL(*this);
|
sl@0
|
139 |
result=DoTestL(midiClnt);
|
sl@0
|
140 |
);
|
sl@0
|
141 |
iTimer->Cancel();
|
sl@0
|
142 |
|
sl@0
|
143 |
completed = EFalse;
|
sl@0
|
144 |
if (err == KErrNone)
|
sl@0
|
145 |
{
|
sl@0
|
146 |
TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
|
sl@0
|
147 |
if (testAlloc==NULL)
|
sl@0
|
148 |
{
|
sl@0
|
149 |
completed = ETrue;
|
sl@0
|
150 |
}
|
sl@0
|
151 |
else
|
sl@0
|
152 |
{
|
sl@0
|
153 |
completed = ETrue;
|
sl@0
|
154 |
User::Free(testAlloc);
|
sl@0
|
155 |
}
|
sl@0
|
156 |
}
|
sl@0
|
157 |
else if (err != KErrNoMemory) // bad error code
|
sl@0
|
158 |
{
|
sl@0
|
159 |
completed = ETrue;
|
sl@0
|
160 |
result = EFail;
|
sl@0
|
161 |
}
|
sl@0
|
162 |
else
|
sl@0
|
163 |
{
|
sl@0
|
164 |
++failCount;
|
sl@0
|
165 |
}
|
sl@0
|
166 |
|
sl@0
|
167 |
delete midiClnt;
|
sl@0
|
168 |
midiClnt = NULL;
|
sl@0
|
169 |
|
sl@0
|
170 |
__UHEAP_RESET;
|
sl@0
|
171 |
__MM_HEAP_MARKEND;
|
sl@0
|
172 |
}
|
sl@0
|
173 |
return result;
|
sl@0
|
174 |
}
|
sl@0
|
175 |
|
sl@0
|
176 |
/*static*/
|
sl@0
|
177 |
TInt CTestStepDrm::TimerGate(TAny* aPtr)
|
sl@0
|
178 |
{
|
sl@0
|
179 |
reinterpret_cast<CTestStepDrm*>(aPtr)->OnTimer();
|
sl@0
|
180 |
return KErrNone;
|
sl@0
|
181 |
}
|
sl@0
|
182 |
|
sl@0
|
183 |
void CTestStepDrm::OnTimer()
|
sl@0
|
184 |
{
|
sl@0
|
185 |
iTimer->Cancel();
|
sl@0
|
186 |
CActiveScheduler::Stop();
|
sl@0
|
187 |
iError = KErrTimedOut;
|
sl@0
|
188 |
}
|
sl@0
|
189 |
|
sl@0
|
190 |
TVerdict CTestStepDrm::OpenFileL(CMidiClientUtility* aMidi)
|
sl@0
|
191 |
{
|
sl@0
|
192 |
TPtrC fileName;
|
sl@0
|
193 |
if (iDrmParams.iFileNameKey==NULL)
|
sl@0
|
194 |
{
|
sl@0
|
195 |
if(!GetStringFromConfig(KDrmSectName,KDrmFileKey,fileName))
|
sl@0
|
196 |
{
|
sl@0
|
197 |
return EInconclusive;
|
sl@0
|
198 |
}
|
sl@0
|
199 |
}
|
sl@0
|
200 |
else
|
sl@0
|
201 |
{
|
sl@0
|
202 |
if(!GetStringFromConfig(KDrmSectName,TPtrC(iDrmParams.iFileNameKey), fileName))
|
sl@0
|
203 |
{
|
sl@0
|
204 |
return EInconclusive;
|
sl@0
|
205 |
}
|
sl@0
|
206 |
}
|
sl@0
|
207 |
if (iDrmParams.iSourceType==TDrmTestParams::EFileName)
|
sl@0
|
208 |
{
|
sl@0
|
209 |
TPtrC uniqueId(ContentAccess::KDefaultContentObject);
|
sl@0
|
210 |
if (iDrmParams.iUniqueId)
|
sl@0
|
211 |
{
|
sl@0
|
212 |
uniqueId.Set(TPtrC(iDrmParams.iUniqueId));
|
sl@0
|
213 |
}
|
sl@0
|
214 |
if (iDrmParams.iUniqueId==NULL && iDrmParams.iIntent==TDrmTestParams::KNoIntent)
|
sl@0
|
215 |
{
|
sl@0
|
216 |
aMidi->OpenFile(TMMFileSource(fileName));
|
sl@0
|
217 |
}
|
sl@0
|
218 |
else if (iDrmParams.iIntent==TDrmTestParams::KNoIntent)
|
sl@0
|
219 |
{
|
sl@0
|
220 |
aMidi->OpenFile(TMMFileSource(fileName, uniqueId));
|
sl@0
|
221 |
}
|
sl@0
|
222 |
else
|
sl@0
|
223 |
{
|
sl@0
|
224 |
aMidi->OpenFile(TMMFileSource(fileName, uniqueId, iDrmParams.iIntent));
|
sl@0
|
225 |
}
|
sl@0
|
226 |
}
|
sl@0
|
227 |
else
|
sl@0
|
228 |
{
|
sl@0
|
229 |
iFile.Close();
|
sl@0
|
230 |
User::LeaveIfError( iFs.ShareProtected() );
|
sl@0
|
231 |
User::LeaveIfError( iFile.Open(iFs, fileName, EFileRead | EFileShareExclusive) );
|
sl@0
|
232 |
|
sl@0
|
233 |
TPtrC uniqueId(ContentAccess::KDefaultContentObject);
|
sl@0
|
234 |
if (iDrmParams.iUniqueId)
|
sl@0
|
235 |
{
|
sl@0
|
236 |
uniqueId.Set(TPtrC(iDrmParams.iUniqueId));
|
sl@0
|
237 |
}
|
sl@0
|
238 |
if (iDrmParams.iUniqueId==NULL && iDrmParams.iIntent==TDrmTestParams::KNoIntent)
|
sl@0
|
239 |
{
|
sl@0
|
240 |
aMidi->OpenFile(TMMFileHandleSource(iFile));
|
sl@0
|
241 |
}
|
sl@0
|
242 |
else if (iDrmParams.iIntent==TDrmTestParams::KNoIntent)
|
sl@0
|
243 |
{
|
sl@0
|
244 |
aMidi->OpenFile(TMMFileHandleSource(iFile, uniqueId));
|
sl@0
|
245 |
}
|
sl@0
|
246 |
else
|
sl@0
|
247 |
{
|
sl@0
|
248 |
aMidi->OpenFile(TMMFileHandleSource(iFile, uniqueId, iDrmParams.iIntent));
|
sl@0
|
249 |
}
|
sl@0
|
250 |
}
|
sl@0
|
251 |
|
sl@0
|
252 |
return EPass;
|
sl@0
|
253 |
}
|
sl@0
|
254 |
|
sl@0
|
255 |
|
sl@0
|
256 |
/*static*/
|
sl@0
|
257 |
CTestDrmNegative* CTestDrmNegative::NewL(const TDesC& aTestName, const TTestStepType aTestType, const TDrmTestParams& aDrmParams)
|
sl@0
|
258 |
{
|
sl@0
|
259 |
return new (ELeave) CTestDrmNegative(aTestName, aTestType, aDrmParams);
|
sl@0
|
260 |
}
|
sl@0
|
261 |
|
sl@0
|
262 |
CTestDrmNegative::CTestDrmNegative(const TDesC& aTestName, const TTestStepType aTestType, const TDrmTestParams& aDrmParams):
|
sl@0
|
263 |
CTestStepDrm(aTestName, aTestType, aDrmParams)
|
sl@0
|
264 |
{
|
sl@0
|
265 |
}
|
sl@0
|
266 |
|
sl@0
|
267 |
void CTestDrmNegative::MmcuoStateChanged(TMidiState /*aOldState*/,TMidiState /*aNewState*/, const TTimeIntervalMicroSeconds& /*aTime*/,TInt aError)
|
sl@0
|
268 |
{
|
sl@0
|
269 |
iError = aError;
|
sl@0
|
270 |
CActiveScheduler::Stop();
|
sl@0
|
271 |
}
|
sl@0
|
272 |
|
sl@0
|
273 |
TVerdict CTestDrmNegative::DoTestL(CMidiClientUtility* aMidi)
|
sl@0
|
274 |
{
|
sl@0
|
275 |
iTimer->After( TTimeIntervalMicroSeconds32(K5Seconds) );
|
sl@0
|
276 |
TVerdict result=OpenFileL(aMidi);
|
sl@0
|
277 |
if (result!=EPass)
|
sl@0
|
278 |
{
|
sl@0
|
279 |
iTimer->Cancel();
|
sl@0
|
280 |
return result;
|
sl@0
|
281 |
}
|
sl@0
|
282 |
CActiveScheduler::Start();
|
sl@0
|
283 |
|
sl@0
|
284 |
if (iError!=iDrmParams.iExpectedError)
|
sl@0
|
285 |
{
|
sl@0
|
286 |
result=EFail;
|
sl@0
|
287 |
ERR_PRINTF3(_L("Open() gave error %d (expected %d)"),iError, iDrmParams.iExpectedError);
|
sl@0
|
288 |
}
|
sl@0
|
289 |
iTimer->Cancel();
|
sl@0
|
290 |
return result;
|
sl@0
|
291 |
}
|
sl@0
|
292 |
|
sl@0
|
293 |
|
sl@0
|
294 |
/*static*/
|
sl@0
|
295 |
CTestDrmPlay* CTestDrmPlay::NewL(const TDesC& aTestName, const TTestStepType aTestType, const TDrmTestParams& aDrmParams)
|
sl@0
|
296 |
{
|
sl@0
|
297 |
return new (ELeave) CTestDrmPlay(aTestName, aTestType, aDrmParams);
|
sl@0
|
298 |
}
|
sl@0
|
299 |
|
sl@0
|
300 |
CTestDrmPlay::CTestDrmPlay(const TDesC& aTestName, const TTestStepType aTestType, const TDrmTestParams& aDrmParams):
|
sl@0
|
301 |
CTestStepDrm(aTestName, aTestType, aDrmParams)
|
sl@0
|
302 |
{
|
sl@0
|
303 |
}
|
sl@0
|
304 |
|
sl@0
|
305 |
void CTestDrmPlay::MmcuoStateChanged(TMidiState /*aOldState*/,TMidiState aNewState, const TTimeIntervalMicroSeconds& /*aTime*/,TInt aError)
|
sl@0
|
306 |
{
|
sl@0
|
307 |
iError = aError;
|
sl@0
|
308 |
iLatestState= aNewState;
|
sl@0
|
309 |
CActiveScheduler::Stop();
|
sl@0
|
310 |
}
|
sl@0
|
311 |
|
sl@0
|
312 |
TVerdict CTestDrmPlay::PlayL(CMidiClientUtility* aMidi, TTimeIntervalMicroSeconds32 aStopAfter)
|
sl@0
|
313 |
{
|
sl@0
|
314 |
iTimer->Cancel();
|
sl@0
|
315 |
iTimer->After(aStopAfter);
|
sl@0
|
316 |
|
sl@0
|
317 |
TVerdict result=OpenFileL(aMidi);
|
sl@0
|
318 |
if (result!=EPass)
|
sl@0
|
319 |
{
|
sl@0
|
320 |
iTimer->Cancel();
|
sl@0
|
321 |
return result;
|
sl@0
|
322 |
}
|
sl@0
|
323 |
CActiveScheduler::Start();
|
sl@0
|
324 |
User::LeaveIfError(iError);
|
sl@0
|
325 |
|
sl@0
|
326 |
aMidi->Play();
|
sl@0
|
327 |
CActiveScheduler::Start();
|
sl@0
|
328 |
User::LeaveIfError(iError);
|
sl@0
|
329 |
if (iLatestState != EMidiStateOpenPlaying)
|
sl@0
|
330 |
{
|
sl@0
|
331 |
iTimer->Cancel();
|
sl@0
|
332 |
ERR_PRINTF3(_L("Play() got state %d (expected %d)"),iLatestState, EMidiStateOpenPlaying);
|
sl@0
|
333 |
return EFail;
|
sl@0
|
334 |
}
|
sl@0
|
335 |
|
sl@0
|
336 |
CActiveScheduler::Start();
|
sl@0
|
337 |
|
sl@0
|
338 |
iTimer->Cancel();
|
sl@0
|
339 |
if (iError==KErrNoMemory && iDrmParams.iTestMode==TDrmTestParams::EAlloc)
|
sl@0
|
340 |
{
|
sl@0
|
341 |
User::Leave(iError);
|
sl@0
|
342 |
}
|
sl@0
|
343 |
|
sl@0
|
344 |
return result;
|
sl@0
|
345 |
}
|
sl@0
|
346 |
|
sl@0
|
347 |
TVerdict CTestDrmPlay::DoTestL(CMidiClientUtility* aMidi)
|
sl@0
|
348 |
{
|
sl@0
|
349 |
TVerdict res=EPass;
|
sl@0
|
350 |
TInt i=iDrmParams.iNumPlayLoops > 0 ? iDrmParams.iNumPlayLoops : 1;
|
sl@0
|
351 |
for (; i && res==EPass && iError==KErrNone; --i)
|
sl@0
|
352 |
{
|
sl@0
|
353 |
TRAP( iError,
|
sl@0
|
354 |
res=PlayL(aMidi, TTimeIntervalMicroSeconds32(K30Seconds));
|
sl@0
|
355 |
);
|
sl@0
|
356 |
}
|
sl@0
|
357 |
if (iError==KErrNoMemory && iDrmParams.iTestMode==TDrmTestParams::EAlloc)
|
sl@0
|
358 |
{
|
sl@0
|
359 |
User::Leave(iError);
|
sl@0
|
360 |
}
|
sl@0
|
361 |
if (res==EPass)
|
sl@0
|
362 |
{
|
sl@0
|
363 |
res=(i==0 && iDrmParams.iExpectedError==iError)? EPass : EFail;
|
sl@0
|
364 |
}
|
sl@0
|
365 |
|
sl@0
|
366 |
if (iError!=iDrmParams.iExpectedError)
|
sl@0
|
367 |
{
|
sl@0
|
368 |
ERR_PRINTF4(_L("Play() gave error %d (expected %d) loops left=%d"),iError, iDrmParams.iExpectedError, i);
|
sl@0
|
369 |
}
|
sl@0
|
370 |
return res;
|
sl@0
|
371 |
}
|
sl@0
|
372 |
|
sl@0
|
373 |
/*
|
sl@0
|
374 |
***** Play() -> Stop()
|
sl@0
|
375 |
*/
|
sl@0
|
376 |
CTestDrmPlayStop* CTestDrmPlayStop::NewL(const TDesC& aTestName, const TTestStepType aTestType, const TDrmTestParams& aDrmParams)
|
sl@0
|
377 |
{
|
sl@0
|
378 |
return new (ELeave) CTestDrmPlayStop(aTestName, aTestType, aDrmParams);
|
sl@0
|
379 |
}
|
sl@0
|
380 |
|
sl@0
|
381 |
|
sl@0
|
382 |
CTestDrmPlayStop::CTestDrmPlayStop(const TDesC& aTestName, const TTestStepType aTestType, const TDrmTestParams& aDrmParams):
|
sl@0
|
383 |
CTestDrmPlay(aTestName, aTestType, aDrmParams)
|
sl@0
|
384 |
{
|
sl@0
|
385 |
}
|
sl@0
|
386 |
|
sl@0
|
387 |
void CTestDrmPlayStop::OnTimer()
|
sl@0
|
388 |
{
|
sl@0
|
389 |
if (iLatestState != EMidiStateOpenPlaying || iStopping)
|
sl@0
|
390 |
{
|
sl@0
|
391 |
iError = KErrGeneral;
|
sl@0
|
392 |
CActiveScheduler::Stop();
|
sl@0
|
393 |
ERR_PRINTF3(_L("CTestDrmPlayStop::OnTimer() got err %d stopping %d"),iError, iStopping);
|
sl@0
|
394 |
}
|
sl@0
|
395 |
else
|
sl@0
|
396 |
{
|
sl@0
|
397 |
iMidi->Stop(TTimeIntervalMicroSeconds(100000));
|
sl@0
|
398 |
iStopping=ETrue;
|
sl@0
|
399 |
iTimer->After(K5Seconds);
|
sl@0
|
400 |
}
|
sl@0
|
401 |
}
|
sl@0
|
402 |
|
sl@0
|
403 |
TVerdict CTestDrmPlayStop::DoTestL(CMidiClientUtility* aMidi)
|
sl@0
|
404 |
{
|
sl@0
|
405 |
iMidi = aMidi;
|
sl@0
|
406 |
TVerdict res=PlayL(aMidi, TTimeIntervalMicroSeconds32(K5Seconds));
|
sl@0
|
407 |
iTimer->Cancel();
|
sl@0
|
408 |
if (res!=EPass)
|
sl@0
|
409 |
{
|
sl@0
|
410 |
return res;
|
sl@0
|
411 |
}
|
sl@0
|
412 |
return iError==iDrmParams.iExpectedError ? EPass : EFail;
|
sl@0
|
413 |
}
|
sl@0
|
414 |
|
sl@0
|
415 |
/*
|
sl@0
|
416 |
***** Play() -> Stop()
|
sl@0
|
417 |
*/
|
sl@0
|
418 |
|
sl@0
|
419 |
/*static*/
|
sl@0
|
420 |
CTestDrmPlayWithUI* CTestDrmPlayWithUI::NewL(const TDesC& aTestName, const TTestStepType aTestType, const TDrmTestParams& aDrmParams)
|
sl@0
|
421 |
{
|
sl@0
|
422 |
return new (ELeave) CTestDrmPlayWithUI(aTestName, aTestType, aDrmParams);
|
sl@0
|
423 |
}
|
sl@0
|
424 |
|
sl@0
|
425 |
CTestDrmPlayWithUI::CTestDrmPlayWithUI(const TDesC& aTestName, const TTestStepType aTestType, const TDrmTestParams& aDrmParams):
|
sl@0
|
426 |
CTestStepDrm(aTestName, aTestType, aDrmParams)
|
sl@0
|
427 |
{
|
sl@0
|
428 |
}
|
sl@0
|
429 |
|
sl@0
|
430 |
void CTestDrmPlayWithUI::MmcuoStateChanged(TMidiState /*aOldState*/,TMidiState aNewState, const TTimeIntervalMicroSeconds& /*aTime*/,TInt aError)
|
sl@0
|
431 |
{
|
sl@0
|
432 |
iError = aError;
|
sl@0
|
433 |
iLatestState= aNewState;
|
sl@0
|
434 |
CActiveScheduler::Stop();
|
sl@0
|
435 |
}
|
sl@0
|
436 |
|
sl@0
|
437 |
TVerdict CTestDrmPlayWithUI::PlayL(CMidiClientUtility* aMidi, TTimeIntervalMicroSeconds32 aStopAfter)
|
sl@0
|
438 |
{
|
sl@0
|
439 |
iTimer->Cancel();
|
sl@0
|
440 |
iTimer->After(aStopAfter);
|
sl@0
|
441 |
|
sl@0
|
442 |
TVerdict result=OpenFileL(aMidi);
|
sl@0
|
443 |
if (result!=EPass)
|
sl@0
|
444 |
{
|
sl@0
|
445 |
iTimer->Cancel();
|
sl@0
|
446 |
return result;
|
sl@0
|
447 |
}
|
sl@0
|
448 |
CActiveScheduler::Start();
|
sl@0
|
449 |
User::LeaveIfError(iError);
|
sl@0
|
450 |
|
sl@0
|
451 |
MMMFDRMCustomCommand* cmd=aMidi->GetDRMCustomCommand();
|
sl@0
|
452 |
if (cmd==NULL)
|
sl@0
|
453 |
{
|
sl@0
|
454 |
ERR_PRINTF1(_L("GetDRMCustomCommand() returned NULL"));
|
sl@0
|
455 |
return EFail;
|
sl@0
|
456 |
}
|
sl@0
|
457 |
iError=cmd->SetAgentProperty(ContentAccess::EAgentPropertyAgentUI, ETrue);
|
sl@0
|
458 |
// The test agent should return KErrCANotSupported...
|
sl@0
|
459 |
if (iError != KErrCANotSupported)
|
sl@0
|
460 |
{
|
sl@0
|
461 |
ERR_PRINTF2(_L("SetAgentProperty() Error=%d"),iError);
|
sl@0
|
462 |
return EFail;
|
sl@0
|
463 |
}
|
sl@0
|
464 |
else
|
sl@0
|
465 |
{
|
sl@0
|
466 |
// ..it has, so flag that there's no error!
|
sl@0
|
467 |
iError = KErrNone;
|
sl@0
|
468 |
}
|
sl@0
|
469 |
User::LeaveIfError(iError);
|
sl@0
|
470 |
|
sl@0
|
471 |
aMidi->Play();
|
sl@0
|
472 |
CActiveScheduler::Start();
|
sl@0
|
473 |
User::LeaveIfError(iError);
|
sl@0
|
474 |
|
sl@0
|
475 |
if (iLatestState != EMidiStateOpenPlaying)
|
sl@0
|
476 |
{
|
sl@0
|
477 |
iTimer->Cancel();
|
sl@0
|
478 |
ERR_PRINTF3(_L("Play() got state %d (expected %d)"),iLatestState, EMidiStateOpenPlaying);
|
sl@0
|
479 |
return EFail;
|
sl@0
|
480 |
}
|
sl@0
|
481 |
|
sl@0
|
482 |
CActiveScheduler::Start();
|
sl@0
|
483 |
|
sl@0
|
484 |
iTimer->Cancel();
|
sl@0
|
485 |
if (iError==KErrNoMemory && iDrmParams.iTestMode==TDrmTestParams::EAlloc)
|
sl@0
|
486 |
{
|
sl@0
|
487 |
User::Leave(iError);
|
sl@0
|
488 |
}
|
sl@0
|
489 |
|
sl@0
|
490 |
return EPass;
|
sl@0
|
491 |
}
|
sl@0
|
492 |
|
sl@0
|
493 |
TVerdict CTestDrmPlayWithUI::DoTestL(CMidiClientUtility* aMidi)
|
sl@0
|
494 |
{
|
sl@0
|
495 |
TVerdict res=EPass;
|
sl@0
|
496 |
TInt i=iDrmParams.iNumPlayLoops > 0 ? iDrmParams.iNumPlayLoops : 1;
|
sl@0
|
497 |
for (; i && res==EPass; --i)
|
sl@0
|
498 |
{
|
sl@0
|
499 |
res=PlayL(aMidi, TTimeIntervalMicroSeconds32(K30Seconds));
|
sl@0
|
500 |
}
|
sl@0
|
501 |
if (res==EFail)
|
sl@0
|
502 |
{
|
sl@0
|
503 |
return res;
|
sl@0
|
504 |
}
|
sl@0
|
505 |
if (iError!=iDrmParams.iExpectedError)
|
sl@0
|
506 |
{
|
sl@0
|
507 |
res=EFail;
|
sl@0
|
508 |
ERR_PRINTF3(_L("Play() gave error %d (expected %d)"),iError, iDrmParams.iExpectedError);
|
sl@0
|
509 |
}
|
sl@0
|
510 |
return res;
|
sl@0
|
511 |
}
|
sl@0
|
512 |
|