os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepciaudiobufferprefill.cpp
First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "teststepciaudiobufferprefill.h"
18 const TInt32 KAfterThreeSeconds = 3000000; // Three seconds
19 const TInt32 KEveryNinetySeconds = 90000000; // Ninety seconds
22 TVerdict CTestStepCISampleBuffering::DoTestStepL()
24 iTestStepResult = ETestSuiteError;
26 INFO_PRINTF1(_L("Initializing test CI device"));
28 if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0069-HP")) == 0)
30 iTestStepResult = DoTestStep0069L();
32 else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0070-HP")) == 0)
34 iTestStepResult = DoTestStep0070L();
36 else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0071-HP")) == 0)
38 iTestStepResult = DoTestStep0071L();
40 else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0072-HP")) == 0)
42 iTestStepResult = DoTestStep0072L();
44 else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0073-HP")) == 0)
46 iTestStepResult = DoTestStep0073L();
49 return iTestStepResult;
53 TVerdict CTestStepCISampleBuffering::DoTestStep0069L()
55 iTestStepResult = EFail;
57 INFO_PRINTF1(_L("SampleBuffering - Instantiating"));
59 //Initialize - with the UID of our test HwDevice
60 #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
61 TUid testUID = {KUidSampleBufferingTestDevice};
63 TFourCC testUID('T','0','1','2');
66 iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
68 if (iTestStepResult != EPass)
70 INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
74 // reset the value as previous test is pass
75 iTestStepResult = EFail;
77 // KUidMMMFSampleBuffering
78 MMMFSampleBuffering* ptr = static_cast <MMMFSampleBuffering*> (iMMFDevSound->CustomInterface(KUidSampleBuffering));
82 INFO_PRINTF1(_L("MMMFSampleBuffering instantiated successfully"));
84 iTestStepResult = EPass;
88 ERR_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface"));
91 return iTestStepResult;
95 TVerdict CTestStepCISampleBuffering::DoTestStep0070L()
97 iTestStepResult = EFail;
98 TInt result = KErrGeneral;
100 INFO_PRINTF1(_L("SampleBuffering - MmsbEnableSampleBufferingBeforePlayback"));
102 //Initialize - with the UID of our test HwDevice
103 #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
104 TUid testUID = {KUidSampleBufferingTestDevice};
106 TFourCC testUID('T','0','1','2');
109 iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
111 if (iTestStepResult != EPass)
113 INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
114 return EInconclusive;
117 // reset the value as previous test is pass
118 iTestStepResult = EFail;
120 // KUidMMMFSampleBuffering
121 MMMFSampleBuffering* ptr = static_cast <MMMFSampleBuffering*> (iMMFDevSound->CustomInterface(KUidSampleBuffering));
125 result = ptr->MmsbEnableSampleBufferingBeforePlayback(); // call method
127 if (result == KErrNone)
129 INFO_PRINTF1(_L("MMMFSampleBuffering::MmsbEnableSampleBufferingBeforePlayback finished successfully"));
131 iTestStepResult = EPass;
135 ERR_PRINTF2(_L("MMMFSampleBuffering::MmsbEnableSampleBufferingBeforePlayback failed with result %d"), result);
140 INFO_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface"));
141 iTestStepResult = EInconclusive;
144 return iTestStepResult;
148 TVerdict CTestStepCISampleBuffering::DoTestStep0071L()
150 iTestStepResult = EFail;
151 TInt result = KErrGeneral;
153 INFO_PRINTF1(_L("SampleBuffering - MmsbDisableSampleBufferingBeforePlayback"));
155 //Initialize - with the UID of our test HwDevice
156 #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
157 TUid testUID = {KUidSampleBufferingTestDevice};
159 TFourCC testUID('T','0','1','2');
162 iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
164 if (iTestStepResult != EPass)
166 INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
167 return EInconclusive;
170 // reset the value as previous test is pass
171 iTestStepResult = EFail;
173 // KUidMMMFSampleBuffering
174 MMMFSampleBuffering* ptr = static_cast <MMMFSampleBuffering*> (iMMFDevSound->CustomInterface(KUidSampleBuffering));
179 result = ptr->MmsbDisableSampleBufferingBeforePlayback(); // call method
181 if (result == KErrNone)
183 INFO_PRINTF1(_L("MMMFSampleBuffering::MmsbDisableSampleBufferingBeforePlayback finished successfully"));
185 iTestStepResult = EPass;
189 ERR_PRINTF2(_L("MMMFSampleBuffering::MmsbDisableSampleBufferingBeforePlayback failed with result %d"), result);
194 INFO_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface"));
195 iTestStepResult = EInconclusive;
198 return iTestStepResult;
202 TVerdict CTestStepCISampleBuffering::DoTestStep0072L()
204 iTestStepResult = EFail;
207 INFO_PRINTF1(_L("SampleBuffering - MmsbNotifyPlayStarted"));
209 //Initialize - with the UID of our test HwDevice
210 #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
211 TUid testUID = {KUidSampleBufferingTestDevice};
213 TFourCC testUID('T','0','1','2');
216 iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
217 if (iTestStepResult != EPass)
219 INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
220 return EInconclusive;
223 // reset the value as previous test is pass
224 iTestStepResult = EFail;
226 // KUidMMMFSampleBuffering
227 MMMFSampleBuffering* ptr = static_cast <MMMFSampleBuffering*> (iMMFDevSound->CustomInterface(KUidSampleBuffering));
231 CActiveListener* listener = new(ELeave)CActiveListener;
233 listener->InitialiseActiveListener();
235 ptr->MmsbNotifyPlayStarted(listener->iStatus); // call method
237 CActiveScheduler::Start();
239 err = listener->iStatus.Int();
243 if (err == KErrNotSupported)
245 INFO_PRINTF1(_L("MMMFSampleBuffering::MmsbNotifyPlayStarted finished successfully"));
247 iTestStepResult = EPass;
251 ERR_PRINTF2(_L("MMMFSampleBuffering::MmsbNotifyPlayStarted failed with err %d"), err);
256 INFO_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface"));
257 iTestStepResult = EInconclusive;
260 return iTestStepResult;
264 TVerdict CTestStepCISampleBuffering::DoTestStep0073L()
266 iTestStepResult = EFail;
269 INFO_PRINTF1(_L("SampleBuffering - MmsbCancelNotifyPlayStarted"));
271 TCallBack callback(CTestStepCISampleBuffering::Callback, this);
273 iTimer = CPeriodic::NewL(EPriorityNormal);
275 // Here we use periodic timer to enable us to call MmsbCancelNotifyPlayStarted() after three
276 // seconds of issuing MmsbNotifyPlayStarted(). Ninety seconds is long enough to stop the timer
277 // before sending a second MmsbCancelNotifyPlayStarted() .
278 iTimer->Start(KAfterThreeSeconds, KEveryNinetySeconds, callback);
280 //Initialize - with the UID of our test HwDevice
281 #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
282 TUid testUID = {KUidSampleBufferingTestDevice};
284 TFourCC testUID('T','0','1','2');
287 iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
289 if (iTestStepResult != EPass)
291 INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
292 return EInconclusive;
295 // reset the value as previous test is pass
296 iTestStepResult = EFail;
298 // KUidMMMFSampleBuffering
299 iInterfacePtr = static_cast <MMMFSampleBuffering*> (iMMFDevSound->CustomInterface(KUidSampleBuffering));
303 CActiveListener* listener = new(ELeave) CActiveListener;
304 listener->InitialiseActiveListener();
306 iInterfacePtr->MmsbNotifyPlayStarted(listener->iStatus); // call method
308 CActiveScheduler::Start();
310 err = listener->iStatus.Int();
314 if (err == KErrCancel)
316 INFO_PRINTF1(_L("MMMFSampleBuffering::MmsbCancelNotifyPlayStarted Successfully completed"));
318 iTestStepResult = EPass;
322 ERR_PRINTF2(_L("Device didn't wait for the expected duration err %d"), err);
327 INFO_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface"));
328 iTestStepResult = EInconclusive;
333 return iTestStepResult;
337 TInt CTestStepCISampleBuffering::Callback(TAny* aAny)
339 CTestStepCISampleBuffering* me = reinterpret_cast<CTestStepCISampleBuffering*>(aAny);
344 void CTestStepCISampleBuffering::DoCallback()
347 iInterfacePtr->MmsbCancelNotifyPlayStarted(); // call method