os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepcibufferframesconfig.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.
17 #include "teststepcibufferframesconfig.h"
20 /*****************************************************************************/
21 CTestStepCICreateBufferFramesConfig::CTestStepCICreateBufferFramesConfig()
23 iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0082-HP");
26 /*****************************************************************************/
27 TVerdict CTestStepCICreateBufferFramesConfig::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 = {KUidBufferFramesConfigTestDevice};
37 TFourCC testUID('T','0','0','7');
40 MMMFBufferFramesConfig* interface = NULL;
41 interface = static_cast<MMMFBufferFramesConfig*>(InitializeAndInstantiateInterfaceL(testUID, KUidBufferFramesConfig));
45 iTestStepResult = EPass;
46 INFO_PRINTF1(_L("Successfully retrieved the interface."));
50 iTestStepResult = EFail;
51 ERR_PRINTF1(_L("Failed to retrieve the interface"));
54 return iTestStepResult;
57 /*****************************************************************************/
58 CTestStepCIBufferFramesConfigSetBase::CTestStepCIBufferFramesConfigSetBase()
62 TVerdict CTestStepCIBufferFramesConfigSetBase::DoTestStepL()
67 void CTestStepCIBufferFramesConfigSetBase::DoReadFromFileL(TInt& aFrames, TInt& aSamples)
70 CleanupClosePushL(fs);
71 User::LeaveIfError(fs.Connect());
74 CleanupClosePushL(file);
76 // File should already exist
77 User::LeaveIfError(file.Open(fs, KCITestFileName, EFileRead));
78 TBuf8<KMaxCITestFileTimeDataLength> inputBuf;
79 User::LeaveIfError(file.Read(inputBuf));
80 // Do some lexical analysis
81 TLex8 input(inputBuf);
83 input.SkipCharacters();
84 if (input.TokenLength() != 0)
87 TLex8 temp(input.MarkedToken());
88 User::LeaveIfError(temp.Val(value));
89 // succesfully read the first value (the frames count)
92 input.SkipSpaceAndMark();
93 input.SkipCharacters();
94 if (input.TokenLength() != 0)
96 temp = input.MarkedToken();
97 User::LeaveIfError(temp.Val(value));
98 // succesfully read the seconde value (the samples count)
103 CleanupStack::PopAndDestroy(); // file
105 // It is the responsibility of this function to delete the file after use
106 User::LeaveIfError(fs.Delete(KCITestFileName));
108 CleanupStack::PopAndDestroy(); // fs
112 /*****************************************************************************/
113 CTestStepCIBufferFramesConfigSetInput::CTestStepCIBufferFramesConfigSetInput()
115 iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0083-HP");
118 /*****************************************************************************/
119 TVerdict CTestStepCIBufferFramesConfigSetInput::DoTestStepL()
121 iTestStepResult = EFail;
123 INFO_PRINTF1(_L("Initializing test CI device"));
125 //Initialize - with the UID of our test HwDevice
126 #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
127 TUid testUID = {KUidBufferFramesConfigTestDevice};
129 TFourCC testUID('T','0','0','7');
132 MMMFBufferFramesConfig* interface = NULL;
133 interface = static_cast<MMMFBufferFramesConfig*>(InitializeAndInstantiateInterfaceL(testUID, KUidBufferFramesConfig));
138 TInt samplesPerFrame = 66;
139 INFO_PRINTF1(_L("Calling test CI method"));
140 TInt err = interface->MmbfcSetNumberOfFramesPerInputBuffer(frameCount, samplesPerFrame);
142 TInt testSamples = 0;
143 // Reset test result in case we leave...
144 iTestStepResult = EFail;
145 DoReadFromFileL(testCount, testSamples);
146 if ((err == KErrNone) && (frameCount == testCount) && (samplesPerFrame == testSamples))
148 INFO_PRINTF1(_L("Test CI method call was successful"));
149 iTestStepResult = EPass;
153 INFO_PRINTF4(_L("Test CI method call failed, error: %d, expected frames: %d, \
154 expected samples: %d"), err, frameCount, samplesPerFrame);
155 INFO_PRINTF3(_L("Actual values: frames: %d, samplesPerFrame: %d"), testCount, testSamples);
160 INFO_PRINTF1(_L("Failed to retrieve the custom interface"));
161 iTestStepResult = EInconclusive;
164 return iTestStepResult;
167 /*****************************************************************************/
168 CTestStepCIBufferFramesConfigSetOutput::CTestStepCIBufferFramesConfigSetOutput()
170 iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0084-HP");
173 /*****************************************************************************/
174 TVerdict CTestStepCIBufferFramesConfigSetOutput::DoTestStepL()
176 iTestStepResult = EFail;
178 INFO_PRINTF1(_L("Initializing test CI device"));
180 //Initialize - with the UID of our test HwDevice
181 #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
182 TUid testUID = {KUidBufferFramesConfigTestDevice};
184 TFourCC testUID('T','0','0','7');
187 MMMFBufferFramesConfig* interface = NULL;
188 interface = static_cast<MMMFBufferFramesConfig*>(InitializeAndInstantiateInterfaceL(testUID, KUidBufferFramesConfig));
193 TInt samplesPerFrame = 99;
194 INFO_PRINTF1(_L("Calling test CI method"));
195 TInt err = interface->MmbfcSetNumberOfFramesPerOutputBuffer(frameCount, samplesPerFrame);
197 TInt testSamples = 0;
198 // Reset test result in case we leave...
199 iTestStepResult = EFail;
200 DoReadFromFileL(testCount, testSamples);
201 if ((err == KErrNone) && (frameCount == testCount) && (samplesPerFrame == testSamples))
203 INFO_PRINTF1(_L("Test CI method call was successful"));
204 iTestStepResult = EPass;
208 INFO_PRINTF4(_L("Test CI method call failed, error: %d, expected frames: %d, \
209 expected samples: %d"), err, frameCount, samplesPerFrame);
210 INFO_PRINTF3(_L("Actual values: frames: %d, samplesPerFrame: %d"), testCount, testSamples);
215 INFO_PRINTF1(_L("Failed to retrieve the custom interface"));
216 iTestStepResult = EInconclusive;
219 return iTestStepResult;