os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepcigettimestamps.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.
17 #include "teststepcigettimestamps.h"
20 /*****************************************************************************/
21 CTestStepCICreateGetTimestamps::CTestStepCICreateGetTimestamps()
23 iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0085-HP");
26 /*****************************************************************************/
27 TVerdict CTestStepCICreateGetTimestamps::DoTestStepL()
29 iTestStepResult = EFail;
31 INFO_PRINTF1(_L("Initializing test CI device"));
33 //Initialize - with the UID of our test HwDevice
34 #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
35 TUid testUID = {KUidGetTimestampsTestDevice};
37 TFourCC testUID('T','0','0','6');
40 MMMFGetTimestamps* interface = NULL;
41 interface = static_cast<MMMFGetTimestamps*>(
42 InitializeAndInstantiateInterfaceL(testUID, KUidGetTimestamps));
46 iTestStepResult = EPass;
47 INFO_PRINTF1(_L("Successfully retrieved the interface."));
51 iTestStepResult = EFail;
52 ERR_PRINTF1(_L("Failed to retrieve the interface"));
55 return iTestStepResult;
58 /*****************************************************************************/
59 CTestStepCIGetTimestampsEnable::CTestStepCIGetTimestampsEnable()
61 iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0086-HP");
64 /*****************************************************************************/
65 TVerdict CTestStepCIGetTimestampsEnable::DoTestStepL()
67 iTestStepResult = EFail;
69 INFO_PRINTF1(_L("Initializing test CI device"));
71 //Initialize - with the UID of our test HwDevice
72 #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
73 TUid testUID = {KUidGetTimestampsTestDevice};
75 TFourCC testUID('T','0','0','6');
78 MMMFGetTimestamps* interface = NULL;
79 interface = static_cast<MMMFGetTimestamps*>(InitializeAndInstantiateInterfaceL(testUID, KUidGetTimestamps));
83 TBool enabled = ETrue;
84 INFO_PRINTF1(_L("Calling test CI method"));
85 TInt err = interface->MmgtSetRecordSystemTimestampsEnabled(enabled);
87 // Reset test result in case we leave...
88 iTestStepResult = EFail;
89 DoReadFromFileL(flag);
90 if ((err == KErrNone) && (flag == enabled))
92 INFO_PRINTF1(_L("Test CI method call was successful"));
93 iTestStepResult = EPass;
97 INFO_PRINTF4(_L("Test CI method call failed, error: %d, expected value: %d, \
98 actual value: %d"), err, enabled, flag);
103 INFO_PRINTF1(_L("Failed to retrieve the custom interface."));
104 iTestStepResult = EInconclusive;
107 return iTestStepResult;
110 void CTestStepCIGetTimestampsEnable::DoReadFromFileL(TBool& aFlag)
113 CleanupClosePushL(fs);
114 User::LeaveIfError(fs.Connect());
117 CleanupClosePushL(file);
119 // File should already exist
120 User::LeaveIfError(file.Open(fs, KCITestFileName, EFileRead));
123 User::LeaveIfError(file.Size(fileSize));
124 if (fileSize != KMaxCITestFileDataLength)
126 User::Leave(KErrCorrupt);
128 TBuf8<KMaxCITestFileDataLength> inputBuf;
129 User::LeaveIfError(file.Read(inputBuf));
130 TChar val = inputBuf[0];
131 aFlag = val.GetNumericValue();
133 CleanupStack::PopAndDestroy(); // file
135 // This function is responsible for the deletion of the file after use
136 User::LeaveIfError(fs.Delete(KCITestFileName));
138 CleanupStack::PopAndDestroy(); // fs
141 /*****************************************************************************/
142 CTestStepCIGetTimestampsForBuffer::CTestStepCIGetTimestampsForBuffer()
144 iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0087-HP");
147 /*****************************************************************************/
148 TVerdict CTestStepCIGetTimestampsForBuffer::DoTestStepL()
150 iTestStepResult = EFail;
152 INFO_PRINTF1(_L("Initializing test CI device"));
154 //Initialize - with the UID of our test HwDevice
155 #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
156 TUid testUID = {KUidGetTimestampsTestDevice};
158 TFourCC testUID('T','0','0','6');
161 MMMFGetTimestamps* interface = NULL;
162 interface = static_cast<MMMFGetTimestamps*>(InitializeAndInstantiateInterfaceL(testUID, KUidGetTimestamps));
166 INFO_PRINTF1(_L("Calling test CI method"));
167 // Test device implementation expects this value:
168 TTimeIntervalMicroSeconds bufferPosition(KTimestampPosition);
170 TInt err = interface->MmgtGetSystemTimestampForBuffer(bufferPosition, timestamp);
171 // and it should return this value:
172 TTime testTimestamp(KTimestampValue);
173 if ((err == KErrNone) && (testTimestamp == timestamp))
175 INFO_PRINTF1(_L("Test CI method call was successful"));
176 iTestStepResult = EPass;
180 INFO_PRINTF3(_L("Expected timestamp: %d, actual timestamp: %d"), \
181 timestamp.Int64(), testTimestamp.Int64());
182 iTestStepResult = EFail;
187 INFO_PRINTF1(_L("Failed to retrieve the custom interface."));
188 iTestStepResult = EInconclusive;
191 return iTestStepResult;