sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include "teststepcibufferframesconfig.h" sl@0: #include "cidefine.h" sl@0: sl@0: /*****************************************************************************/ sl@0: CTestStepCICreateBufferFramesConfig::CTestStepCICreateBufferFramesConfig() sl@0: { sl@0: iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0082-HP"); sl@0: } sl@0: sl@0: /*****************************************************************************/ sl@0: TVerdict CTestStepCICreateBufferFramesConfig::DoTestStepL() sl@0: { sl@0: iTestStepResult = EFail; sl@0: sl@0: INFO_PRINTF1(_L("Initializing test CI device")); sl@0: sl@0: //Initialize - with the UID of our test HwDevice sl@0: #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND sl@0: TUid testUID = {KUidBufferFramesConfigTestDevice}; sl@0: #else sl@0: TFourCC testUID('T','0','0','7'); sl@0: #endif sl@0: sl@0: MMMFBufferFramesConfig* interface = NULL; sl@0: interface = static_cast(InitializeAndInstantiateInterfaceL(testUID, KUidBufferFramesConfig)); sl@0: sl@0: if (interface) sl@0: { sl@0: iTestStepResult = EPass; sl@0: INFO_PRINTF1(_L("Successfully retrieved the interface.")); sl@0: } sl@0: else sl@0: { sl@0: iTestStepResult = EFail; sl@0: ERR_PRINTF1(_L("Failed to retrieve the interface")); sl@0: } sl@0: sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: /*****************************************************************************/ sl@0: CTestStepCIBufferFramesConfigSetBase::CTestStepCIBufferFramesConfigSetBase() sl@0: { sl@0: } sl@0: sl@0: TVerdict CTestStepCIBufferFramesConfigSetBase::DoTestStepL() sl@0: { sl@0: return EPass; sl@0: } sl@0: sl@0: void CTestStepCIBufferFramesConfigSetBase::DoReadFromFileL(TInt& aFrames, TInt& aSamples) sl@0: { sl@0: RFs fs; sl@0: CleanupClosePushL(fs); sl@0: User::LeaveIfError(fs.Connect()); sl@0: sl@0: RFile file; sl@0: CleanupClosePushL(file); sl@0: sl@0: // File should already exist sl@0: User::LeaveIfError(file.Open(fs, KCITestFileName, EFileRead)); sl@0: TBuf8 inputBuf; sl@0: User::LeaveIfError(file.Read(inputBuf)); sl@0: // Do some lexical analysis sl@0: TLex8 input(inputBuf); sl@0: input.Mark(); sl@0: input.SkipCharacters(); sl@0: if (input.TokenLength() != 0) sl@0: { sl@0: TInt value; sl@0: TLex8 temp(input.MarkedToken()); sl@0: User::LeaveIfError(temp.Val(value)); sl@0: // succesfully read the first value (the frames count) sl@0: aFrames = value; sl@0: sl@0: input.SkipSpaceAndMark(); sl@0: input.SkipCharacters(); sl@0: if (input.TokenLength() != 0) sl@0: { sl@0: temp = input.MarkedToken(); sl@0: User::LeaveIfError(temp.Val(value)); sl@0: // succesfully read the seconde value (the samples count) sl@0: aSamples = value; sl@0: } sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(); // file sl@0: sl@0: // It is the responsibility of this function to delete the file after use sl@0: User::LeaveIfError(fs.Delete(KCITestFileName)); sl@0: sl@0: CleanupStack::PopAndDestroy(); // fs sl@0: } sl@0: sl@0: sl@0: /*****************************************************************************/ sl@0: CTestStepCIBufferFramesConfigSetInput::CTestStepCIBufferFramesConfigSetInput() sl@0: { sl@0: iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0083-HP"); sl@0: } sl@0: sl@0: /*****************************************************************************/ sl@0: TVerdict CTestStepCIBufferFramesConfigSetInput::DoTestStepL() sl@0: { sl@0: iTestStepResult = EFail; sl@0: sl@0: INFO_PRINTF1(_L("Initializing test CI device")); sl@0: sl@0: //Initialize - with the UID of our test HwDevice sl@0: #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND sl@0: TUid testUID = {KUidBufferFramesConfigTestDevice}; sl@0: #else sl@0: TFourCC testUID('T','0','0','7'); sl@0: #endif sl@0: sl@0: MMMFBufferFramesConfig* interface = NULL; sl@0: interface = static_cast(InitializeAndInstantiateInterfaceL(testUID, KUidBufferFramesConfig)); sl@0: sl@0: if (interface) sl@0: { sl@0: TInt frameCount = 6; sl@0: TInt samplesPerFrame = 66; sl@0: INFO_PRINTF1(_L("Calling test CI method")); sl@0: TInt err = interface->MmbfcSetNumberOfFramesPerInputBuffer(frameCount, samplesPerFrame); sl@0: TInt testCount = 0; sl@0: TInt testSamples = 0; sl@0: // Reset test result in case we leave... sl@0: iTestStepResult = EFail; sl@0: DoReadFromFileL(testCount, testSamples); sl@0: if ((err == KErrNone) && (frameCount == testCount) && (samplesPerFrame == testSamples)) sl@0: { sl@0: INFO_PRINTF1(_L("Test CI method call was successful")); sl@0: iTestStepResult = EPass; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF4(_L("Test CI method call failed, error: %d, expected frames: %d, \ sl@0: expected samples: %d"), err, frameCount, samplesPerFrame); sl@0: INFO_PRINTF3(_L("Actual values: frames: %d, samplesPerFrame: %d"), testCount, testSamples); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Failed to retrieve the custom interface")); sl@0: iTestStepResult = EInconclusive; sl@0: } sl@0: sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: /*****************************************************************************/ sl@0: CTestStepCIBufferFramesConfigSetOutput::CTestStepCIBufferFramesConfigSetOutput() sl@0: { sl@0: iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0084-HP"); sl@0: } sl@0: sl@0: /*****************************************************************************/ sl@0: TVerdict CTestStepCIBufferFramesConfigSetOutput::DoTestStepL() sl@0: { sl@0: iTestStepResult = EFail; sl@0: sl@0: INFO_PRINTF1(_L("Initializing test CI device")); sl@0: sl@0: //Initialize - with the UID of our test HwDevice sl@0: #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND sl@0: TUid testUID = {KUidBufferFramesConfigTestDevice}; sl@0: #else sl@0: TFourCC testUID('T','0','0','7'); sl@0: #endif sl@0: sl@0: MMMFBufferFramesConfig* interface = NULL; sl@0: interface = static_cast(InitializeAndInstantiateInterfaceL(testUID, KUidBufferFramesConfig)); sl@0: sl@0: if (interface) sl@0: { sl@0: TInt frameCount = 9; sl@0: TInt samplesPerFrame = 99; sl@0: INFO_PRINTF1(_L("Calling test CI method")); sl@0: TInt err = interface->MmbfcSetNumberOfFramesPerOutputBuffer(frameCount, samplesPerFrame); sl@0: TInt testCount = 0; sl@0: TInt testSamples = 0; sl@0: // Reset test result in case we leave... sl@0: iTestStepResult = EFail; sl@0: DoReadFromFileL(testCount, testSamples); sl@0: if ((err == KErrNone) && (frameCount == testCount) && (samplesPerFrame == testSamples)) sl@0: { sl@0: INFO_PRINTF1(_L("Test CI method call was successful")); sl@0: iTestStepResult = EPass; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF4(_L("Test CI method call failed, error: %d, expected frames: %d, \ sl@0: expected samples: %d"), err, frameCount, samplesPerFrame); sl@0: INFO_PRINTF3(_L("Actual values: frames: %d, samplesPerFrame: %d"), testCount, testSamples); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Failed to retrieve the custom interface")); sl@0: iTestStepResult = EInconclusive; sl@0: } sl@0: sl@0: return iTestStepResult; sl@0: } sl@0: