sl@0
|
1 |
// Copyright (c) 2004-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 |
// Integration tests.
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "TestAudioPlayerDRM.h"
|
sl@0
|
19 |
|
sl@0
|
20 |
// CTestMmfDRMAudioPlayerBase implementation
|
sl@0
|
21 |
|
sl@0
|
22 |
/**
|
sl@0
|
23 |
*
|
sl@0
|
24 |
* CTestMmfDRMAudioPlayerBase()
|
sl@0
|
25 |
*
|
sl@0
|
26 |
* Constructor to set the Test step name, section name and key names.
|
sl@0
|
27 |
*
|
sl@0
|
28 |
*/
|
sl@0
|
29 |
CTestMmfDRMAudioPlayerBase::CTestMmfDRMAudioPlayerBase(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, const TDesC& aUniqueId)
|
sl@0
|
30 |
{
|
sl@0
|
31 |
iTestStepName = aTestName;
|
sl@0
|
32 |
iSectName = aSectName;
|
sl@0
|
33 |
iKeyName = aKeyName;
|
sl@0
|
34 |
iUniqueId = aUniqueId;
|
sl@0
|
35 |
}
|
sl@0
|
36 |
|
sl@0
|
37 |
/**
|
sl@0
|
38 |
*
|
sl@0
|
39 |
* FsmL()
|
sl@0
|
40 |
*
|
sl@0
|
41 |
* @param TMmfAudioEvents aEvent
|
sl@0
|
42 |
*
|
sl@0
|
43 |
*/
|
sl@0
|
44 |
void CTestMmfDRMAudioPlayerBase::FsmL(TMmfAudioEvents aEvent, TInt aError)
|
sl@0
|
45 |
{
|
sl@0
|
46 |
switch (aEvent)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
case EAudioOpen:
|
sl@0
|
49 |
INFO_PRINTF3(_L("Opening the file for PLAY intent : %S, UniqueID : %S"), &iFileName, &iUniqueId);
|
sl@0
|
50 |
iAudioPlayer->OpenFileL(TMMFileSource(iFileName, iUniqueId, ContentAccess::EPlay));
|
sl@0
|
51 |
break;
|
sl@0
|
52 |
|
sl@0
|
53 |
case EAudioPlay:
|
sl@0
|
54 |
if (aError != KErrNone) // Check if there's error while opening the file
|
sl@0
|
55 |
{
|
sl@0
|
56 |
ERR_PRINTF2(_L("Opening the audio file failed, unexpected error %d."), aError);
|
sl@0
|
57 |
CActiveScheduler::Stop();
|
sl@0
|
58 |
}
|
sl@0
|
59 |
else
|
sl@0
|
60 |
{
|
sl@0
|
61 |
INFO_PRINTF1(_L("Playing the audio file..."));
|
sl@0
|
62 |
AfterOpenL();
|
sl@0
|
63 |
iAudioPlayer->Play();
|
sl@0
|
64 |
}
|
sl@0
|
65 |
break;
|
sl@0
|
66 |
|
sl@0
|
67 |
case EAudioPlayEnd:
|
sl@0
|
68 |
if (aError != KErrNone) // Check if there's error while playing the file
|
sl@0
|
69 |
{
|
sl@0
|
70 |
ERR_PRINTF2(_L("Playing the audio file failed, unexpected error %d."), aError);
|
sl@0
|
71 |
}
|
sl@0
|
72 |
else
|
sl@0
|
73 |
{
|
sl@0
|
74 |
INFO_PRINTF1(_L("Audio file opened and played."));
|
sl@0
|
75 |
iTestStepResult = EPass;
|
sl@0
|
76 |
}
|
sl@0
|
77 |
CActiveScheduler::Stop();
|
sl@0
|
78 |
break;
|
sl@0
|
79 |
|
sl@0
|
80 |
default:
|
sl@0
|
81 |
INFO_PRINTF1(_L("Invalid Audio event!"));
|
sl@0
|
82 |
}
|
sl@0
|
83 |
};
|
sl@0
|
84 |
|
sl@0
|
85 |
void CTestMmfDRMAudioPlayerBase::AfterOpenL()
|
sl@0
|
86 |
{
|
sl@0
|
87 |
}
|
sl@0
|
88 |
|
sl@0
|
89 |
/**
|
sl@0
|
90 |
*
|
sl@0
|
91 |
* Test step Preamble.
|
sl@0
|
92 |
*
|
sl@0
|
93 |
* @return TVerdict: The result of the test step.
|
sl@0
|
94 |
*
|
sl@0
|
95 |
*/
|
sl@0
|
96 |
TVerdict CTestMmfDRMAudioPlayerBase::DoTestStepPreambleL()
|
sl@0
|
97 |
{
|
sl@0
|
98 |
// Install the scheduler
|
sl@0
|
99 |
TVerdict verdict = CTestMmfAclntStep::DoTestStepPreambleL();
|
sl@0
|
100 |
|
sl@0
|
101 |
iError = KErrNone;
|
sl@0
|
102 |
|
sl@0
|
103 |
// Get the filename
|
sl@0
|
104 |
TPtrC filename1;
|
sl@0
|
105 |
if (!GetStringFromConfig(iSectName, iKeyName, filename1))
|
sl@0
|
106 |
{
|
sl@0
|
107 |
return EInconclusive;
|
sl@0
|
108 |
}
|
sl@0
|
109 |
GetDriveName(iFileName);
|
sl@0
|
110 |
iFileName.Append(filename1);
|
sl@0
|
111 |
|
sl@0
|
112 |
// Create an audio player
|
sl@0
|
113 |
iAudioPlayer = CMdaAudioPlayerUtility::NewL(*this);
|
sl@0
|
114 |
if (iAudioPlayer == NULL)
|
sl@0
|
115 |
{
|
sl@0
|
116 |
return EInconclusive;
|
sl@0
|
117 |
}
|
sl@0
|
118 |
|
sl@0
|
119 |
return verdict;
|
sl@0
|
120 |
}
|
sl@0
|
121 |
|
sl@0
|
122 |
/**
|
sl@0
|
123 |
*
|
sl@0
|
124 |
* Test step Postamble.
|
sl@0
|
125 |
*
|
sl@0
|
126 |
* @return TVerdict: The result of the test step.
|
sl@0
|
127 |
*
|
sl@0
|
128 |
*/
|
sl@0
|
129 |
TVerdict CTestMmfDRMAudioPlayerBase::DoTestStepPostambleL()
|
sl@0
|
130 |
{
|
sl@0
|
131 |
delete iAudioPlayer;
|
sl@0
|
132 |
iAudioPlayer = NULL;
|
sl@0
|
133 |
User::After(KOneSecond); // wait for deletion to shut down devsound
|
sl@0
|
134 |
return CTestMmfAclntStep::DoTestStepPostambleL(); // Destroy the scheduler
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
/**
|
sl@0
|
138 |
*
|
sl@0
|
139 |
* Implementation of the MMdaAudioPlayerCallback interface function.
|
sl@0
|
140 |
*
|
sl@0
|
141 |
* @param TInt aError
|
sl@0
|
142 |
*
|
sl@0
|
143 |
*/
|
sl@0
|
144 |
void CTestMmfDRMAudioPlayerBase::MapcInitComplete(TInt aError,
|
sl@0
|
145 |
const TTimeIntervalMicroSeconds& /*aDuration*/)
|
sl@0
|
146 |
{
|
sl@0
|
147 |
INFO_PRINTF2(_L("MMdaAudioPlayerCallback Init Complete. Error = %d"), aError);
|
sl@0
|
148 |
iError = aError;
|
sl@0
|
149 |
if (iError != KErrNone)
|
sl@0
|
150 |
{
|
sl@0
|
151 |
ERR_PRINTF2(_L("Opening the audio file failed, unexpected error %d."), aError);
|
sl@0
|
152 |
iAudioPlayer->Close();
|
sl@0
|
153 |
CActiveScheduler::Stop();
|
sl@0
|
154 |
}
|
sl@0
|
155 |
else
|
sl@0
|
156 |
{
|
sl@0
|
157 |
TRAP(iError, FsmL(EAudioPlay, aError)); // Call to play audio
|
sl@0
|
158 |
if (iError != KErrNone)
|
sl@0
|
159 |
{
|
sl@0
|
160 |
ERR_PRINTF2(_L("Got an error from the FsmL(EAudioPlay) %d."), iError);
|
sl@0
|
161 |
iAudioPlayer->Close();
|
sl@0
|
162 |
CActiveScheduler::Stop();
|
sl@0
|
163 |
}
|
sl@0
|
164 |
}
|
sl@0
|
165 |
}
|
sl@0
|
166 |
|
sl@0
|
167 |
/**
|
sl@0
|
168 |
*
|
sl@0
|
169 |
* Implementation of the MMdaAudioPlayerCallback interface function.
|
sl@0
|
170 |
*
|
sl@0
|
171 |
* @param TInt aError
|
sl@0
|
172 |
*
|
sl@0
|
173 |
*/
|
sl@0
|
174 |
void CTestMmfDRMAudioPlayerBase::MapcPlayComplete(TInt aError)
|
sl@0
|
175 |
{
|
sl@0
|
176 |
INFO_PRINTF2(_L("MMdaAudioPlayerCallback Play Complete. Error = %d"), aError);
|
sl@0
|
177 |
iError = aError;
|
sl@0
|
178 |
if (iError != KErrNone)
|
sl@0
|
179 |
{
|
sl@0
|
180 |
ERR_PRINTF2(_L("Opening the audio file failed, unexpected error %d."), aError);
|
sl@0
|
181 |
iAudioPlayer->Close();
|
sl@0
|
182 |
CActiveScheduler::Stop();
|
sl@0
|
183 |
}
|
sl@0
|
184 |
else
|
sl@0
|
185 |
{
|
sl@0
|
186 |
TRAP(iError, FsmL(EAudioPlayEnd, aError));
|
sl@0
|
187 |
if (iError != KErrNone)
|
sl@0
|
188 |
{
|
sl@0
|
189 |
ERR_PRINTF2(_L("Got an error from the FsmL(EAudioPlayEnd) %d."), iError);
|
sl@0
|
190 |
iAudioPlayer->Close();
|
sl@0
|
191 |
CActiveScheduler::Stop();
|
sl@0
|
192 |
}
|
sl@0
|
193 |
}
|
sl@0
|
194 |
}
|
sl@0
|
195 |
|
sl@0
|
196 |
|
sl@0
|
197 |
// Positive Tests
|
sl@0
|
198 |
|
sl@0
|
199 |
/**
|
sl@0
|
200 |
*
|
sl@0
|
201 |
* NewL()
|
sl@0
|
202 |
*
|
sl@0
|
203 |
* @param const TDesC& aTestName
|
sl@0
|
204 |
*
|
sl@0
|
205 |
* @return CTestMmfAudioPlayDRMEnableAgentUI*
|
sl@0
|
206 |
* Constructed CTestMmfAudioPlayDRMEnableAgentUI object
|
sl@0
|
207 |
*
|
sl@0
|
208 |
*/
|
sl@0
|
209 |
CTestMmfAudioPlayDRMEnableAgentUI* CTestMmfAudioPlayDRMEnableAgentUI::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, const TDesC& aUniqueId)
|
sl@0
|
210 |
{
|
sl@0
|
211 |
return new (ELeave) CTestMmfAudioPlayDRMEnableAgentUI(aTestName, aSectName, aKeyName, aUniqueId);
|
sl@0
|
212 |
}
|
sl@0
|
213 |
|
sl@0
|
214 |
/**
|
sl@0
|
215 |
*
|
sl@0
|
216 |
* Test step constructor.
|
sl@0
|
217 |
* Ctor for CTestMmfAudioPlayDRMEnableAgentUI.
|
sl@0
|
218 |
*
|
sl@0
|
219 |
* @param const TDesC& aTestName
|
sl@0
|
220 |
*
|
sl@0
|
221 |
*/
|
sl@0
|
222 |
CTestMmfAudioPlayDRMEnableAgentUI::CTestMmfAudioPlayDRMEnableAgentUI(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, const TDesC& aUniqueId)
|
sl@0
|
223 |
:CTestMmfDRMAudioPlayerBase(aTestName, aSectName, aKeyName, aUniqueId)
|
sl@0
|
224 |
{
|
sl@0
|
225 |
}
|
sl@0
|
226 |
|
sl@0
|
227 |
void CTestMmfAudioPlayDRMEnableAgentUI::AfterOpenL()
|
sl@0
|
228 |
{
|
sl@0
|
229 |
// Create DRM custom command
|
sl@0
|
230 |
MMMFDRMCustomCommand* drmCustomCommand;
|
sl@0
|
231 |
drmCustomCommand = iAudioPlayer->GetDRMCustomCommand();
|
sl@0
|
232 |
if (drmCustomCommand == NULL)
|
sl@0
|
233 |
{
|
sl@0
|
234 |
ERR_PRINTF1(_L("MMMFDRMCustomCommand is NULL."));
|
sl@0
|
235 |
iError = KErrUnknown;
|
sl@0
|
236 |
User::Leave(KErrUnknown);
|
sl@0
|
237 |
}
|
sl@0
|
238 |
|
sl@0
|
239 |
INFO_PRINTF1(_L("Enabling Agent's user interface for errors and confirmation requests..."));
|
sl@0
|
240 |
iError = drmCustomCommand->SetAgentProperty(ContentAccess::EAgentPropertyAgentUI, 3);
|
sl@0
|
241 |
// After DevCR JFOT-6EMFVL (which changes the CContentFile::SetAgentProperty to call
|
sl@0
|
242 |
// SetProperty on a member of CData instead of CContent), the underlying reference test
|
sl@0
|
243 |
// agent returns a different error value (KErrCANotSupported instead of KErrNone).
|
sl@0
|
244 |
if (iError == KErrCANotSupported)
|
sl@0
|
245 |
{
|
sl@0
|
246 |
// Reset the error code as it's not really an error :)
|
sl@0
|
247 |
iError = KErrNone;
|
sl@0
|
248 |
}
|
sl@0
|
249 |
else
|
sl@0
|
250 |
{
|
sl@0
|
251 |
ERR_PRINTF2(_L("Enabling Agent's user interface failed, unexpected error %d."), iError);
|
sl@0
|
252 |
User::Leave(iError);
|
sl@0
|
253 |
}
|
sl@0
|
254 |
}
|
sl@0
|
255 |
|
sl@0
|
256 |
/**
|
sl@0
|
257 |
*
|
sl@0
|
258 |
* Do the test step.
|
sl@0
|
259 |
* Each test step must supply an implementation for DoTestStepL.
|
sl@0
|
260 |
*
|
sl@0
|
261 |
* @return TVerdict: The result of the test step.
|
sl@0
|
262 |
*
|
sl@0
|
263 |
*/
|
sl@0
|
264 |
TVerdict CTestMmfAudioPlayDRMEnableAgentUI::DoTestStepL()
|
sl@0
|
265 |
{
|
sl@0
|
266 |
INFO_PRINTF1(_L("Enable agent's user interface for errors and confirmation requests property. Open and play a protected audio clip from a file for PLAY intent."));
|
sl@0
|
267 |
|
sl@0
|
268 |
iTestStepResult = EFail;
|
sl@0
|
269 |
|
sl@0
|
270 |
TRAPD(err,FsmL(EAudioOpen)); // Call to open the audio file
|
sl@0
|
271 |
if (err == KErrNone)
|
sl@0
|
272 |
{
|
sl@0
|
273 |
CActiveScheduler::Start(); // ActiveScheduler started ONLY once
|
sl@0
|
274 |
if (iError == KErrNone)
|
sl@0
|
275 |
{
|
sl@0
|
276 |
iTestStepResult=EPass;
|
sl@0
|
277 |
}
|
sl@0
|
278 |
}
|
sl@0
|
279 |
return iTestStepResult;
|
sl@0
|
280 |
}
|
sl@0
|
281 |
|
sl@0
|
282 |
|
sl@0
|
283 |
/**
|
sl@0
|
284 |
*
|
sl@0
|
285 |
* NewL()
|
sl@0
|
286 |
*
|
sl@0
|
287 |
* @param const TDesC& aTestName
|
sl@0
|
288 |
*
|
sl@0
|
289 |
* @return CTestMmfAudioPlayDRMDisableAutoIntent*
|
sl@0
|
290 |
* Constructed CTestMmfAudioPlayDRMDisableAutoIntent object
|
sl@0
|
291 |
*
|
sl@0
|
292 |
*/
|
sl@0
|
293 |
CTestMmfAudioPlayDRMDisableAutoIntent* CTestMmfAudioPlayDRMDisableAutoIntent::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, const TDesC& aUniqueId)
|
sl@0
|
294 |
{
|
sl@0
|
295 |
return new (ELeave) CTestMmfAudioPlayDRMDisableAutoIntent(aTestName, aSectName, aKeyName, aUniqueId);
|
sl@0
|
296 |
}
|
sl@0
|
297 |
|
sl@0
|
298 |
/**
|
sl@0
|
299 |
*
|
sl@0
|
300 |
* Test step constructor.
|
sl@0
|
301 |
* Ctor for CTestMmfAudioPlayDRMDisableAutoIntent.
|
sl@0
|
302 |
*
|
sl@0
|
303 |
* @param const TDesC& aTestName
|
sl@0
|
304 |
*
|
sl@0
|
305 |
*/
|
sl@0
|
306 |
CTestMmfAudioPlayDRMDisableAutoIntent::CTestMmfAudioPlayDRMDisableAutoIntent(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, const TDesC& aUniqueId)
|
sl@0
|
307 |
:CTestMmfDRMAudioPlayerBase(aTestName, aSectName, aKeyName, aUniqueId)
|
sl@0
|
308 |
{
|
sl@0
|
309 |
}
|
sl@0
|
310 |
|
sl@0
|
311 |
void CTestMmfAudioPlayDRMDisableAutoIntent::AfterOpenL()
|
sl@0
|
312 |
{
|
sl@0
|
313 |
// Create DRM custom command
|
sl@0
|
314 |
MMMFDRMCustomCommand* drmCustomCommand;
|
sl@0
|
315 |
drmCustomCommand = iAudioPlayer->GetDRMCustomCommand();
|
sl@0
|
316 |
|
sl@0
|
317 |
if (drmCustomCommand == NULL)
|
sl@0
|
318 |
{
|
sl@0
|
319 |
ERR_PRINTF1(_L("MMMFDRMCustomCommand is NULL."));
|
sl@0
|
320 |
iError = KErrUnknown;
|
sl@0
|
321 |
User::Leave(KErrUnknown);
|
sl@0
|
322 |
}
|
sl@0
|
323 |
|
sl@0
|
324 |
INFO_PRINTF1(_L("Disabling automatic intent..."));
|
sl@0
|
325 |
iError = drmCustomCommand->DisableAutomaticIntent(EFalse);
|
sl@0
|
326 |
if (iError != KErrNone)
|
sl@0
|
327 |
{
|
sl@0
|
328 |
ERR_PRINTF2(_L("Disabling the automatic intent failed, unexpected error %d."), iError);
|
sl@0
|
329 |
User::Leave(iError);
|
sl@0
|
330 |
}
|
sl@0
|
331 |
}
|
sl@0
|
332 |
|
sl@0
|
333 |
/**
|
sl@0
|
334 |
*
|
sl@0
|
335 |
* Do the test step.
|
sl@0
|
336 |
* Each test step must supply an implementation for DoTestStepL.
|
sl@0
|
337 |
*
|
sl@0
|
338 |
* @return TVerdict: The result of the test step.
|
sl@0
|
339 |
*
|
sl@0
|
340 |
*/
|
sl@0
|
341 |
TVerdict CTestMmfAudioPlayDRMDisableAutoIntent::DoTestStepL()
|
sl@0
|
342 |
{
|
sl@0
|
343 |
|
sl@0
|
344 |
INFO_PRINTF1(_L("Open a protected audio file and disable automatic intent. Play."));
|
sl@0
|
345 |
|
sl@0
|
346 |
iTestStepResult = EFail;
|
sl@0
|
347 |
|
sl@0
|
348 |
TRAPD(err,FsmL(EAudioOpen)); // Call to open the audio file
|
sl@0
|
349 |
|
sl@0
|
350 |
if(err == KErrNone)
|
sl@0
|
351 |
{
|
sl@0
|
352 |
|
sl@0
|
353 |
CActiveScheduler::Start(); // ActiveScheduler started ONLY once
|
sl@0
|
354 |
|
sl@0
|
355 |
if (iError == KErrNone)
|
sl@0
|
356 |
{
|
sl@0
|
357 |
INFO_PRINTF1(_L("Executing intent..."));
|
sl@0
|
358 |
MMMFDRMCustomCommand* drmCustomCommand;
|
sl@0
|
359 |
drmCustomCommand = iAudioPlayer->GetDRMCustomCommand();
|
sl@0
|
360 |
|
sl@0
|
361 |
if (drmCustomCommand == NULL)
|
sl@0
|
362 |
{
|
sl@0
|
363 |
ERR_PRINTF1(_L("MMMFDRMCustomCommand is NULL."));
|
sl@0
|
364 |
User::Leave(KErrUnknown);
|
sl@0
|
365 |
}
|
sl@0
|
366 |
|
sl@0
|
367 |
iError = drmCustomCommand->ExecuteIntent(ContentAccess::EPlay);
|
sl@0
|
368 |
if (iError != KErrNone)
|
sl@0
|
369 |
{
|
sl@0
|
370 |
ERR_PRINTF2(_L("Executing the intent failed, unexpected error %d."), iError);
|
sl@0
|
371 |
}
|
sl@0
|
372 |
}
|
sl@0
|
373 |
|
sl@0
|
374 |
if (iError == KErrNone)
|
sl@0
|
375 |
{
|
sl@0
|
376 |
iTestStepResult = EPass;
|
sl@0
|
377 |
}
|
sl@0
|
378 |
|
sl@0
|
379 |
}
|
sl@0
|
380 |
return iTestStepResult;
|
sl@0
|
381 |
}
|