os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepciaudiobufferprefill.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepciaudiobufferprefill.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,348 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "teststepciaudiobufferprefill.h"
1.20 +
1.21 +const TInt32 KAfterThreeSeconds = 3000000; // Three seconds
1.22 +const TInt32 KEveryNinetySeconds = 90000000; // Ninety seconds
1.23 +
1.24 +
1.25 +TVerdict CTestStepCISampleBuffering::DoTestStepL()
1.26 + {
1.27 + iTestStepResult = ETestSuiteError;
1.28 +
1.29 + INFO_PRINTF1(_L("Initializing test CI device"));
1.30 +
1.31 + if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0069-HP")) == 0)
1.32 + {
1.33 + iTestStepResult = DoTestStep0069L();
1.34 + }
1.35 + else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0070-HP")) == 0)
1.36 + {
1.37 + iTestStepResult = DoTestStep0070L();
1.38 + }
1.39 + else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0071-HP")) == 0)
1.40 + {
1.41 + iTestStepResult = DoTestStep0071L();
1.42 + }
1.43 + else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0072-HP")) == 0)
1.44 + {
1.45 + iTestStepResult = DoTestStep0072L();
1.46 + }
1.47 + else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0073-HP")) == 0)
1.48 + {
1.49 + iTestStepResult = DoTestStep0073L();
1.50 + }
1.51 +
1.52 + return iTestStepResult;
1.53 + }
1.54 +
1.55 +
1.56 +TVerdict CTestStepCISampleBuffering::DoTestStep0069L()
1.57 + {
1.58 + iTestStepResult = EFail;
1.59 +
1.60 + INFO_PRINTF1(_L("SampleBuffering - Instantiating"));
1.61 +
1.62 + //Initialize - with the UID of our test HwDevice
1.63 + #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
1.64 + TUid testUID = {KUidSampleBufferingTestDevice};
1.65 + #else
1.66 + TFourCC testUID('T','0','1','2');
1.67 + #endif
1.68 +
1.69 + iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
1.70 +
1.71 + if (iTestStepResult != EPass)
1.72 + {
1.73 + INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
1.74 + return EInconclusive;
1.75 + }
1.76 +
1.77 + // reset the value as previous test is pass
1.78 + iTestStepResult = EFail;
1.79 +
1.80 + // KUidMMMFSampleBuffering
1.81 + MMMFSampleBuffering* ptr = static_cast <MMMFSampleBuffering*> (iMMFDevSound->CustomInterface(KUidSampleBuffering));
1.82 +
1.83 + if (ptr)
1.84 + {
1.85 + INFO_PRINTF1(_L("MMMFSampleBuffering instantiated successfully"));
1.86 +
1.87 + iTestStepResult = EPass;
1.88 + }
1.89 + else
1.90 + {
1.91 + ERR_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface"));
1.92 + }
1.93 +
1.94 + return iTestStepResult;
1.95 + }
1.96 +
1.97 +
1.98 +TVerdict CTestStepCISampleBuffering::DoTestStep0070L()
1.99 + {
1.100 + iTestStepResult = EFail;
1.101 + TInt result = KErrGeneral;
1.102 +
1.103 + INFO_PRINTF1(_L("SampleBuffering - MmsbEnableSampleBufferingBeforePlayback"));
1.104 +
1.105 + //Initialize - with the UID of our test HwDevice
1.106 + #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
1.107 + TUid testUID = {KUidSampleBufferingTestDevice};
1.108 + #else
1.109 + TFourCC testUID('T','0','1','2');
1.110 + #endif
1.111 +
1.112 + iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
1.113 +
1.114 + if (iTestStepResult != EPass)
1.115 + {
1.116 + INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
1.117 + return EInconclusive;
1.118 + }
1.119 +
1.120 + // reset the value as previous test is pass
1.121 + iTestStepResult = EFail;
1.122 +
1.123 + // KUidMMMFSampleBuffering
1.124 + MMMFSampleBuffering* ptr = static_cast <MMMFSampleBuffering*> (iMMFDevSound->CustomInterface(KUidSampleBuffering));
1.125 +
1.126 + if (ptr)
1.127 + {
1.128 + result = ptr->MmsbEnableSampleBufferingBeforePlayback(); // call method
1.129 +
1.130 + if (result == KErrNone)
1.131 + {
1.132 + INFO_PRINTF1(_L("MMMFSampleBuffering::MmsbEnableSampleBufferingBeforePlayback finished successfully"));
1.133 +
1.134 + iTestStepResult = EPass;
1.135 + }
1.136 + else
1.137 + {
1.138 + ERR_PRINTF2(_L("MMMFSampleBuffering::MmsbEnableSampleBufferingBeforePlayback failed with result %d"), result);
1.139 + }
1.140 + }
1.141 + else
1.142 + {
1.143 + INFO_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface"));
1.144 + iTestStepResult = EInconclusive;
1.145 + }
1.146 +
1.147 + return iTestStepResult;
1.148 + }
1.149 +
1.150 +
1.151 +TVerdict CTestStepCISampleBuffering::DoTestStep0071L()
1.152 + {
1.153 + iTestStepResult = EFail;
1.154 + TInt result = KErrGeneral;
1.155 +
1.156 + INFO_PRINTF1(_L("SampleBuffering - MmsbDisableSampleBufferingBeforePlayback"));
1.157 +
1.158 + //Initialize - with the UID of our test HwDevice
1.159 + #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
1.160 + TUid testUID = {KUidSampleBufferingTestDevice};
1.161 + #else
1.162 + TFourCC testUID('T','0','1','2');
1.163 + #endif
1.164 +
1.165 + iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
1.166 +
1.167 + if (iTestStepResult != EPass)
1.168 + {
1.169 + INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
1.170 + return EInconclusive;
1.171 + }
1.172 +
1.173 + // reset the value as previous test is pass
1.174 + iTestStepResult = EFail;
1.175 +
1.176 + // KUidMMMFSampleBuffering
1.177 + MMMFSampleBuffering* ptr = static_cast <MMMFSampleBuffering*> (iMMFDevSound->CustomInterface(KUidSampleBuffering));
1.178 +
1.179 + if (ptr)
1.180 + {
1.181 +
1.182 + result = ptr->MmsbDisableSampleBufferingBeforePlayback(); // call method
1.183 +
1.184 + if (result == KErrNone)
1.185 + {
1.186 + INFO_PRINTF1(_L("MMMFSampleBuffering::MmsbDisableSampleBufferingBeforePlayback finished successfully"));
1.187 +
1.188 + iTestStepResult = EPass;
1.189 + }
1.190 + else
1.191 + {
1.192 + ERR_PRINTF2(_L("MMMFSampleBuffering::MmsbDisableSampleBufferingBeforePlayback failed with result %d"), result);
1.193 + }
1.194 + }
1.195 + else
1.196 + {
1.197 + INFO_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface"));
1.198 + iTestStepResult = EInconclusive;
1.199 + }
1.200 +
1.201 + return iTestStepResult;
1.202 + }
1.203 +
1.204 +
1.205 +TVerdict CTestStepCISampleBuffering::DoTestStep0072L()
1.206 + {
1.207 + iTestStepResult = EFail;
1.208 + TInt err;
1.209 +
1.210 + INFO_PRINTF1(_L("SampleBuffering - MmsbNotifyPlayStarted"));
1.211 +
1.212 + //Initialize - with the UID of our test HwDevice
1.213 + #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
1.214 + TUid testUID = {KUidSampleBufferingTestDevice};
1.215 + #else
1.216 + TFourCC testUID('T','0','1','2');
1.217 + #endif
1.218 +
1.219 + iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
1.220 + if (iTestStepResult != EPass)
1.221 + {
1.222 + INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
1.223 + return EInconclusive;
1.224 + }
1.225 +
1.226 + // reset the value as previous test is pass
1.227 + iTestStepResult = EFail;
1.228 +
1.229 + // KUidMMMFSampleBuffering
1.230 + MMMFSampleBuffering* ptr = static_cast <MMMFSampleBuffering*> (iMMFDevSound->CustomInterface(KUidSampleBuffering));
1.231 +
1.232 + if (ptr)
1.233 + {
1.234 + CActiveListener* listener = new(ELeave)CActiveListener;
1.235 +
1.236 + listener->InitialiseActiveListener();
1.237 +
1.238 + ptr->MmsbNotifyPlayStarted(listener->iStatus); // call method
1.239 +
1.240 + CActiveScheduler::Start();
1.241 +
1.242 + err = listener->iStatus.Int();
1.243 +
1.244 + delete listener;
1.245 +
1.246 + if (err == KErrNotSupported)
1.247 + {
1.248 + INFO_PRINTF1(_L("MMMFSampleBuffering::MmsbNotifyPlayStarted finished successfully"));
1.249 +
1.250 + iTestStepResult = EPass;
1.251 + }
1.252 + else
1.253 + {
1.254 + ERR_PRINTF2(_L("MMMFSampleBuffering::MmsbNotifyPlayStarted failed with err %d"), err);
1.255 + }
1.256 + }
1.257 + else
1.258 + {
1.259 + INFO_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface"));
1.260 + iTestStepResult = EInconclusive;
1.261 + }
1.262 +
1.263 + return iTestStepResult;
1.264 + }
1.265 +
1.266 +
1.267 +TVerdict CTestStepCISampleBuffering::DoTestStep0073L()
1.268 + {
1.269 + iTestStepResult = EFail;
1.270 + TInt err;
1.271 +
1.272 + INFO_PRINTF1(_L("SampleBuffering - MmsbCancelNotifyPlayStarted"));
1.273 +
1.274 + TCallBack callback(CTestStepCISampleBuffering::Callback, this);
1.275 +
1.276 + iTimer = CPeriodic::NewL(EPriorityNormal);
1.277 +
1.278 + // Here we use periodic timer to enable us to call MmsbCancelNotifyPlayStarted() after three
1.279 + // seconds of issuing MmsbNotifyPlayStarted(). Ninety seconds is long enough to stop the timer
1.280 + // before sending a second MmsbCancelNotifyPlayStarted() .
1.281 + iTimer->Start(KAfterThreeSeconds, KEveryNinetySeconds, callback);
1.282 +
1.283 + //Initialize - with the UID of our test HwDevice
1.284 + #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
1.285 + TUid testUID = {KUidSampleBufferingTestDevice};
1.286 + #else
1.287 + TFourCC testUID('T','0','1','2');
1.288 + #endif
1.289 +
1.290 + iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
1.291 +
1.292 + if (iTestStepResult != EPass)
1.293 + {
1.294 + INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
1.295 + return EInconclusive;
1.296 + }
1.297 +
1.298 + // reset the value as previous test is pass
1.299 + iTestStepResult = EFail;
1.300 +
1.301 + // KUidMMMFSampleBuffering
1.302 + iInterfacePtr = static_cast <MMMFSampleBuffering*> (iMMFDevSound->CustomInterface(KUidSampleBuffering));
1.303 +
1.304 + if (iInterfacePtr)
1.305 + {
1.306 + CActiveListener* listener = new(ELeave) CActiveListener;
1.307 + listener->InitialiseActiveListener();
1.308 +
1.309 + iInterfacePtr->MmsbNotifyPlayStarted(listener->iStatus); // call method
1.310 +
1.311 + CActiveScheduler::Start();
1.312 +
1.313 + err = listener->iStatus.Int();
1.314 +
1.315 + delete listener;
1.316 +
1.317 + if (err == KErrCancel)
1.318 + {
1.319 + INFO_PRINTF1(_L("MMMFSampleBuffering::MmsbCancelNotifyPlayStarted Successfully completed"));
1.320 +
1.321 + iTestStepResult = EPass;
1.322 + }
1.323 + else
1.324 + {
1.325 + ERR_PRINTF2(_L("Device didn't wait for the expected duration err %d"), err);
1.326 + }
1.327 + }
1.328 + else
1.329 + {
1.330 + INFO_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface"));
1.331 + iTestStepResult = EInconclusive;
1.332 + }
1.333 +
1.334 + delete iTimer;
1.335 +
1.336 + return iTestStepResult;
1.337 + }
1.338 +
1.339 +
1.340 +TInt CTestStepCISampleBuffering::Callback(TAny* aAny)
1.341 + {
1.342 + CTestStepCISampleBuffering* me = reinterpret_cast<CTestStepCISampleBuffering*>(aAny);
1.343 + me->DoCallback();
1.344 + return KErrNone;
1.345 + }
1.346 +
1.347 +void CTestStepCISampleBuffering::DoCallback()
1.348 + {
1.349 + iTimer->Cancel();
1.350 + iInterfacePtr->MmsbCancelNotifyPlayStarted(); // call method
1.351 + }