os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepciplaybackstatus.cpp
Update contrib.
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 "teststepciplaybackstatus.h"
19 /*****************************************************************************/
20 CTestStepCIPlaybackStatus::CTestStepCIPlaybackStatus()
22 iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0074-HP");
25 /*****************************************************************************/
26 TVerdict CTestStepCIPlaybackStatus::DoTestStepL()
28 iTestStepResult = EFail;
30 INFO_PRINTF1(_L("Initializing test CI device"));
32 //Initialize - with the UID of our test HwDevice
33 #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
34 TUid testUID = {KUidPlayBackStatusTestDevice};
36 TFourCC testUID('T','0','0','1');
39 MMMFPlaybackStatus* interface = NULL;
40 interface = static_cast<MMMFPlaybackStatus*>(InitializeAndInstantiateInterfaceL(testUID, KUidPlaybackStatus));
44 iTestStepResult = EPass;
45 INFO_PRINTF1(_L("Successfully retrieved the interface."));
49 iTestStepResult = EFail;
50 ERR_PRINTF1(_L("Failed to retrieve the interface"));
53 return iTestStepResult;
56 /*****************************************************************************/
57 CTestStepCIPlaybackStatusInfo::CTestStepCIPlaybackStatusInfo()
59 iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0075-HP");
62 /*****************************************************************************/
63 TVerdict CTestStepCIPlaybackStatusInfo::DoTestStepL()
65 iTestStepResult = EFail;
67 INFO_PRINTF1(_L("Initializing test CI device"));
69 //Initialize - with the UID of our test HwDevice
70 #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
71 TUid testUID = {KUidPlayBackStatusTestDevice};
73 TFourCC testUID('T','0','0','1');
76 MMMFPlaybackStatus* interface = NULL;
77 interface = static_cast<MMMFPlaybackStatus*>(InitializeAndInstantiateInterfaceL(testUID, KUidPlaybackStatus));
81 INFO_PRINTF1(_L("Successfully retrieved the interface."));
83 MMMFPlaybackStatus::TMMFPlaybackStatus status;
85 // Set values before call.
86 status.aInputBytes = 0;
87 status.aDecodedSamples = 0;
88 status.aDecodedSamplesPlayed = 0;
89 status.aSystemTime = 0;
90 status.aTotalSamplesPlayed = 0;
92 interface->MmpsGetPlaybackStatusInformation(status); // call method
94 if(status.aInputBytes == 999 &&
95 status.aDecodedSamples == 999 &&
96 status.aDecodedSamplesPlayed == 999 &&
97 status.aSystemTime == 999 &&
98 status.aTotalSamplesPlayed == 999)
100 iTestStepResult = EPass;
101 INFO_PRINTF1(_L("Successfully got the status information."));
105 iTestStepResult = EFail;
106 ERR_PRINTF1(_L("Failed to retrieve the status information"));
111 ERR_PRINTF1(_L("Failed to retrieve the interface"));
114 return iTestStepResult;
118 /*****************************************************************************/
119 CTestStepCIPlaybackStatusRequestNotification::CTestStepCIPlaybackStatusRequestNotification(TBool aIsCancelTest)
120 : iIsCancelTest(aIsCancelTest)
124 iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0098-HP");
128 iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0097-HP");
132 /*****************************************************************************/
133 TVerdict CTestStepCIPlaybackStatusRequestNotification::DoTestStepL()
135 iTestStepResult = EFail;
137 INFO_PRINTF1(_L("Initializing test CI device"));
139 //Initialize - with the UID of our test HwDevice
140 #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
141 TUid testUID = {KUidPlayBackStatusTestDevice};
143 TFourCC testUID('T','0','0','1');
146 MMMFPlaybackStatus* interface = NULL;
147 interface = static_cast<MMMFPlaybackStatus*>(InitializeAndInstantiateInterfaceL(testUID, KUidPlaybackStatus));
151 INFO_PRINTF1(_L("Successfully retrieved the interface."));
153 iTestStepResult = EFail;
156 DoCancelTestL(*interface);
160 DoRequestTestL(*interface);
165 ERR_PRINTF1(_L("Failed to retrieve the interface"));
168 return iTestStepResult;
171 void CTestStepCIPlaybackStatusRequestNotification::DoRequestTestL(MMMFPlaybackStatus& aInterface)
174 TInt err = aInterface.MmpsRequestLossOfSyncNotification();
179 TBool testResult = EFalse;
180 DoReadFromFileL(testResult);
184 // Value should be ETrue!
185 iTestStepResult = EPass;
186 INFO_PRINTF1(_L("Successfully requested the notification."));
190 ERR_PRINTF2(_L("Failed to request the notification"), err);
195 ERR_PRINTF2(_L("Failed to request the notification"), err);
199 void CTestStepCIPlaybackStatusRequestNotification::DoCancelTestL(MMMFPlaybackStatus& aInterface)
202 TInt err = aInterface.MmpsCancelLossOfSyncNotification();
207 TBool testResult = ETrue;
208 DoReadFromFileL(testResult);
212 // Value should be EFalse!
213 iTestStepResult = EPass;
214 INFO_PRINTF1(_L("Successfully cancelled the notification."));
218 ERR_PRINTF2(_L("Failed to cancel the notification"), err);
223 ERR_PRINTF2(_L("Failed to cancel the notification"), err);
227 void CTestStepCIPlaybackStatusRequestNotification::DoReadFromFileL(TBool& aFlag)
230 CleanupClosePushL(fs);
231 User::LeaveIfError(fs.Connect());
234 CleanupClosePushL(file);
236 // File should already exist
237 User::LeaveIfError(file.Open(fs, KCITestFileName, EFileRead));
240 User::LeaveIfError(file.Size(fileSize));
241 if (fileSize != KMaxCITestFileDataLength)
243 User::Leave(KErrCorrupt);
245 TBuf8<KMaxCITestFileDataLength> inputBuf;
246 User::LeaveIfError(file.Read(inputBuf));
247 TChar val = inputBuf[0];
248 aFlag = val.GetNumericValue();
250 CleanupStack::PopAndDestroy(); // file
252 // It is the responsibility of this function to delete the file after use
253 User::LeaveIfError(fs.Delete(KCITestFileName));
255 CleanupStack::PopAndDestroy(); // fs