Update contrib.
1 // Copyright (c) 2004-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 #include "TestAudioPlayerDRM.h"
20 // CTestMmfDRMAudioPlayerBase implementation
24 * CTestMmfDRMAudioPlayerBase()
26 * Constructor to set the Test step name, section name and key names.
29 CTestMmfDRMAudioPlayerBase::CTestMmfDRMAudioPlayerBase(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, const TDesC& aUniqueId)
31 iTestStepName = aTestName;
32 iSectName = aSectName;
34 iUniqueId = aUniqueId;
41 * @param TMmfAudioEvents aEvent
44 void CTestMmfDRMAudioPlayerBase::FsmL(TMmfAudioEvents aEvent, TInt aError)
49 INFO_PRINTF3(_L("Opening the file for PLAY intent : %S, UniqueID : %S"), &iFileName, &iUniqueId);
50 iAudioPlayer->OpenFileL(TMMFileSource(iFileName, iUniqueId, ContentAccess::EPlay));
54 if (aError != KErrNone) // Check if there's error while opening the file
56 ERR_PRINTF2(_L("Opening the audio file failed, unexpected error %d."), aError);
57 CActiveScheduler::Stop();
61 INFO_PRINTF1(_L("Playing the audio file..."));
68 if (aError != KErrNone) // Check if there's error while playing the file
70 ERR_PRINTF2(_L("Playing the audio file failed, unexpected error %d."), aError);
74 INFO_PRINTF1(_L("Audio file opened and played."));
75 iTestStepResult = EPass;
77 CActiveScheduler::Stop();
81 INFO_PRINTF1(_L("Invalid Audio event!"));
85 void CTestMmfDRMAudioPlayerBase::AfterOpenL()
93 * @return TVerdict: The result of the test step.
96 TVerdict CTestMmfDRMAudioPlayerBase::DoTestStepPreambleL()
98 // Install the scheduler
99 TVerdict verdict = CTestMmfAclntStep::DoTestStepPreambleL();
105 if (!GetStringFromConfig(iSectName, iKeyName, filename1))
107 return EInconclusive;
109 GetDriveName(iFileName);
110 iFileName.Append(filename1);
112 // Create an audio player
113 iAudioPlayer = CMdaAudioPlayerUtility::NewL(*this);
114 if (iAudioPlayer == NULL)
116 return EInconclusive;
124 * Test step Postamble.
126 * @return TVerdict: The result of the test step.
129 TVerdict CTestMmfDRMAudioPlayerBase::DoTestStepPostambleL()
133 User::After(KOneSecond); // wait for deletion to shut down devsound
134 return CTestMmfAclntStep::DoTestStepPostambleL(); // Destroy the scheduler
139 * Implementation of the MMdaAudioPlayerCallback interface function.
144 void CTestMmfDRMAudioPlayerBase::MapcInitComplete(TInt aError,
145 const TTimeIntervalMicroSeconds& /*aDuration*/)
147 INFO_PRINTF2(_L("MMdaAudioPlayerCallback Init Complete. Error = %d"), aError);
149 if (iError != KErrNone)
151 ERR_PRINTF2(_L("Opening the audio file failed, unexpected error %d."), aError);
152 iAudioPlayer->Close();
153 CActiveScheduler::Stop();
157 TRAP(iError, FsmL(EAudioPlay, aError)); // Call to play audio
158 if (iError != KErrNone)
160 ERR_PRINTF2(_L("Got an error from the FsmL(EAudioPlay) %d."), iError);
161 iAudioPlayer->Close();
162 CActiveScheduler::Stop();
169 * Implementation of the MMdaAudioPlayerCallback interface function.
174 void CTestMmfDRMAudioPlayerBase::MapcPlayComplete(TInt aError)
176 INFO_PRINTF2(_L("MMdaAudioPlayerCallback Play Complete. Error = %d"), aError);
178 if (iError != KErrNone)
180 ERR_PRINTF2(_L("Opening the audio file failed, unexpected error %d."), aError);
181 iAudioPlayer->Close();
182 CActiveScheduler::Stop();
186 TRAP(iError, FsmL(EAudioPlayEnd, aError));
187 if (iError != KErrNone)
189 ERR_PRINTF2(_L("Got an error from the FsmL(EAudioPlayEnd) %d."), iError);
190 iAudioPlayer->Close();
191 CActiveScheduler::Stop();
203 * @param const TDesC& aTestName
205 * @return CTestMmfAudioPlayDRMEnableAgentUI*
206 * Constructed CTestMmfAudioPlayDRMEnableAgentUI object
209 CTestMmfAudioPlayDRMEnableAgentUI* CTestMmfAudioPlayDRMEnableAgentUI::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, const TDesC& aUniqueId)
211 return new (ELeave) CTestMmfAudioPlayDRMEnableAgentUI(aTestName, aSectName, aKeyName, aUniqueId);
216 * Test step constructor.
217 * Ctor for CTestMmfAudioPlayDRMEnableAgentUI.
219 * @param const TDesC& aTestName
222 CTestMmfAudioPlayDRMEnableAgentUI::CTestMmfAudioPlayDRMEnableAgentUI(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, const TDesC& aUniqueId)
223 :CTestMmfDRMAudioPlayerBase(aTestName, aSectName, aKeyName, aUniqueId)
227 void CTestMmfAudioPlayDRMEnableAgentUI::AfterOpenL()
229 // Create DRM custom command
230 MMMFDRMCustomCommand* drmCustomCommand;
231 drmCustomCommand = iAudioPlayer->GetDRMCustomCommand();
232 if (drmCustomCommand == NULL)
234 ERR_PRINTF1(_L("MMMFDRMCustomCommand is NULL."));
235 iError = KErrUnknown;
236 User::Leave(KErrUnknown);
239 INFO_PRINTF1(_L("Enabling Agent's user interface for errors and confirmation requests..."));
240 iError = drmCustomCommand->SetAgentProperty(ContentAccess::EAgentPropertyAgentUI, 3);
241 // After DevCR JFOT-6EMFVL (which changes the CContentFile::SetAgentProperty to call
242 // SetProperty on a member of CData instead of CContent), the underlying reference test
243 // agent returns a different error value (KErrCANotSupported instead of KErrNone).
244 if (iError == KErrCANotSupported)
246 // Reset the error code as it's not really an error :)
251 ERR_PRINTF2(_L("Enabling Agent's user interface failed, unexpected error %d."), iError);
259 * Each test step must supply an implementation for DoTestStepL.
261 * @return TVerdict: The result of the test step.
264 TVerdict CTestMmfAudioPlayDRMEnableAgentUI::DoTestStepL()
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."));
268 iTestStepResult = EFail;
270 TRAPD(err,FsmL(EAudioOpen)); // Call to open the audio file
273 CActiveScheduler::Start(); // ActiveScheduler started ONLY once
274 if (iError == KErrNone)
276 iTestStepResult=EPass;
279 return iTestStepResult;
287 * @param const TDesC& aTestName
289 * @return CTestMmfAudioPlayDRMDisableAutoIntent*
290 * Constructed CTestMmfAudioPlayDRMDisableAutoIntent object
293 CTestMmfAudioPlayDRMDisableAutoIntent* CTestMmfAudioPlayDRMDisableAutoIntent::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, const TDesC& aUniqueId)
295 return new (ELeave) CTestMmfAudioPlayDRMDisableAutoIntent(aTestName, aSectName, aKeyName, aUniqueId);
300 * Test step constructor.
301 * Ctor for CTestMmfAudioPlayDRMDisableAutoIntent.
303 * @param const TDesC& aTestName
306 CTestMmfAudioPlayDRMDisableAutoIntent::CTestMmfAudioPlayDRMDisableAutoIntent(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, const TDesC& aUniqueId)
307 :CTestMmfDRMAudioPlayerBase(aTestName, aSectName, aKeyName, aUniqueId)
311 void CTestMmfAudioPlayDRMDisableAutoIntent::AfterOpenL()
313 // Create DRM custom command
314 MMMFDRMCustomCommand* drmCustomCommand;
315 drmCustomCommand = iAudioPlayer->GetDRMCustomCommand();
317 if (drmCustomCommand == NULL)
319 ERR_PRINTF1(_L("MMMFDRMCustomCommand is NULL."));
320 iError = KErrUnknown;
321 User::Leave(KErrUnknown);
324 INFO_PRINTF1(_L("Disabling automatic intent..."));
325 iError = drmCustomCommand->DisableAutomaticIntent(EFalse);
326 if (iError != KErrNone)
328 ERR_PRINTF2(_L("Disabling the automatic intent failed, unexpected error %d."), iError);
336 * Each test step must supply an implementation for DoTestStepL.
338 * @return TVerdict: The result of the test step.
341 TVerdict CTestMmfAudioPlayDRMDisableAutoIntent::DoTestStepL()
344 INFO_PRINTF1(_L("Open a protected audio file and disable automatic intent. Play."));
346 iTestStepResult = EFail;
348 TRAPD(err,FsmL(EAudioOpen)); // Call to open the audio file
353 CActiveScheduler::Start(); // ActiveScheduler started ONLY once
355 if (iError == KErrNone)
357 INFO_PRINTF1(_L("Executing intent..."));
358 MMMFDRMCustomCommand* drmCustomCommand;
359 drmCustomCommand = iAudioPlayer->GetDRMCustomCommand();
361 if (drmCustomCommand == NULL)
363 ERR_PRINTF1(_L("MMMFDRMCustomCommand is NULL."));
364 User::Leave(KErrUnknown);
367 iError = drmCustomCommand->ExecuteIntent(ContentAccess::EPlay);
368 if (iError != KErrNone)
370 ERR_PRINTF2(_L("Executing the intent failed, unexpected error %d."), iError);
374 if (iError == KErrNone)
376 iTestStepResult = EPass;
380 return iTestStepResult;