os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepcibufferframesconfig.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepcibufferframesconfig.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,221 @@
     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 <f32file.h>
    1.20 +#include "teststepcibufferframesconfig.h"
    1.21 +#include "cidefine.h"
    1.22 +
    1.23 +/*****************************************************************************/
    1.24 +CTestStepCICreateBufferFramesConfig::CTestStepCICreateBufferFramesConfig()
    1.25 +	{
    1.26 +	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0082-HP");
    1.27 +	}
    1.28 +
    1.29 +/*****************************************************************************/
    1.30 +TVerdict CTestStepCICreateBufferFramesConfig::DoTestStepL()
    1.31 +	{
    1.32 +	iTestStepResult = EFail;
    1.33 +
    1.34 +	INFO_PRINTF1(_L("Initializing test CI device"));
    1.35 +	
    1.36 +	//Initialize - with the UID of our test HwDevice
    1.37 +	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
    1.38 +	TUid testUID = {KUidBufferFramesConfigTestDevice};
    1.39 +	#else
    1.40 +	TFourCC testUID('T','0','0','7');
    1.41 +	#endif
    1.42 +	
    1.43 +	MMMFBufferFramesConfig* interface = NULL;
    1.44 +	interface = static_cast<MMMFBufferFramesConfig*>(InitializeAndInstantiateInterfaceL(testUID, KUidBufferFramesConfig));
    1.45 +	
    1.46 +	if (interface)
    1.47 +		{
    1.48 +		iTestStepResult = EPass;
    1.49 +		INFO_PRINTF1(_L("Successfully retrieved the interface."));
    1.50 +		}
    1.51 +	else
    1.52 +		{
    1.53 +		iTestStepResult = EFail;
    1.54 +		ERR_PRINTF1(_L("Failed to retrieve the interface"));
    1.55 +		}
    1.56 +
    1.57 +	return iTestStepResult;
    1.58 +	}
    1.59 +
    1.60 +/*****************************************************************************/
    1.61 +CTestStepCIBufferFramesConfigSetBase::CTestStepCIBufferFramesConfigSetBase()
    1.62 +	{
    1.63 +	}
    1.64 +	
    1.65 +TVerdict CTestStepCIBufferFramesConfigSetBase::DoTestStepL()
    1.66 +	{
    1.67 +	return EPass;	
    1.68 +	}
    1.69 +
    1.70 +void CTestStepCIBufferFramesConfigSetBase::DoReadFromFileL(TInt& aFrames, TInt& aSamples)
    1.71 +	{
    1.72 +	RFs fs;
    1.73 +	CleanupClosePushL(fs);
    1.74 +	User::LeaveIfError(fs.Connect());
    1.75 +	
    1.76 +	RFile file;
    1.77 +	CleanupClosePushL(file);
    1.78 +	
    1.79 +	// File should already exist
    1.80 +	User::LeaveIfError(file.Open(fs, KCITestFileName, EFileRead));
    1.81 +	TBuf8<KMaxCITestFileTimeDataLength> inputBuf;
    1.82 +	User::LeaveIfError(file.Read(inputBuf));
    1.83 +	// Do some lexical analysis
    1.84 +	TLex8 input(inputBuf);
    1.85 +	input.Mark();
    1.86 +	input.SkipCharacters();
    1.87 +	if (input.TokenLength() != 0)
    1.88 +		{
    1.89 +		TInt value;
    1.90 +		TLex8 temp(input.MarkedToken());
    1.91 +		User::LeaveIfError(temp.Val(value));
    1.92 +		// succesfully read the first value (the frames count)
    1.93 +		aFrames = value;
    1.94 +		
    1.95 +		input.SkipSpaceAndMark();
    1.96 +		input.SkipCharacters();
    1.97 +		if (input.TokenLength() != 0)
    1.98 +			{
    1.99 +			temp = input.MarkedToken();
   1.100 +			User::LeaveIfError(temp.Val(value));
   1.101 +			// succesfully read the seconde value (the samples count)
   1.102 +			aSamples = value;
   1.103 +			}
   1.104 +		}
   1.105 +
   1.106 +	CleanupStack::PopAndDestroy(); // file	
   1.107 +
   1.108 +	// It is the responsibility of this function to delete the file after use	
   1.109 +	User::LeaveIfError(fs.Delete(KCITestFileName));
   1.110 +
   1.111 +	CleanupStack::PopAndDestroy(); // fs
   1.112 +	}
   1.113 +
   1.114 +
   1.115 +/*****************************************************************************/
   1.116 +CTestStepCIBufferFramesConfigSetInput::CTestStepCIBufferFramesConfigSetInput()
   1.117 +	{
   1.118 +	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0083-HP");
   1.119 +	}
   1.120 +
   1.121 +/*****************************************************************************/
   1.122 +TVerdict CTestStepCIBufferFramesConfigSetInput::DoTestStepL()
   1.123 +	{
   1.124 +	iTestStepResult = EFail;
   1.125 +
   1.126 +	INFO_PRINTF1(_L("Initializing test CI device"));
   1.127 +	
   1.128 +	//Initialize - with the UID of our test HwDevice
   1.129 +	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
   1.130 +	TUid testUID = {KUidBufferFramesConfigTestDevice};
   1.131 +	#else
   1.132 +	TFourCC testUID('T','0','0','7');
   1.133 +	#endif
   1.134 +	
   1.135 +	MMMFBufferFramesConfig* interface = NULL;
   1.136 +	interface = static_cast<MMMFBufferFramesConfig*>(InitializeAndInstantiateInterfaceL(testUID, KUidBufferFramesConfig));
   1.137 +	
   1.138 +	if (interface)
   1.139 +		{
   1.140 +		TInt frameCount = 6;
   1.141 +		TInt samplesPerFrame = 66;
   1.142 +		INFO_PRINTF1(_L("Calling test CI method"));
   1.143 +		TInt err = interface->MmbfcSetNumberOfFramesPerInputBuffer(frameCount, samplesPerFrame);
   1.144 +		TInt testCount = 0;
   1.145 +		TInt testSamples = 0;
   1.146 +		// Reset test result in case we leave...
   1.147 +		iTestStepResult = EFail;
   1.148 +		DoReadFromFileL(testCount, testSamples);
   1.149 +		if ((err == KErrNone) && (frameCount == testCount) && (samplesPerFrame == testSamples))
   1.150 +			{
   1.151 +			INFO_PRINTF1(_L("Test CI method call was successful"));
   1.152 +			iTestStepResult = EPass;
   1.153 +			}
   1.154 +		else
   1.155 +			{
   1.156 +			INFO_PRINTF4(_L("Test CI method call failed, error: %d, expected frames: %d, \
   1.157 +							 expected samples: %d"), err, frameCount, samplesPerFrame);
   1.158 +			INFO_PRINTF3(_L("Actual values: frames: %d, samplesPerFrame: %d"), testCount, testSamples);
   1.159 +			}
   1.160 +		}
   1.161 +	else
   1.162 +		{
   1.163 +		INFO_PRINTF1(_L("Failed to retrieve the custom interface"));
   1.164 +		iTestStepResult = EInconclusive;
   1.165 +		}
   1.166 +
   1.167 +	return iTestStepResult;
   1.168 +	}
   1.169 +
   1.170 +/*****************************************************************************/
   1.171 +CTestStepCIBufferFramesConfigSetOutput::CTestStepCIBufferFramesConfigSetOutput()
   1.172 +	{
   1.173 +	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0084-HP");
   1.174 +	}
   1.175 +
   1.176 +/*****************************************************************************/
   1.177 +TVerdict CTestStepCIBufferFramesConfigSetOutput::DoTestStepL()
   1.178 +	{
   1.179 +	iTestStepResult = EFail;
   1.180 +
   1.181 +	INFO_PRINTF1(_L("Initializing test CI device"));
   1.182 +	
   1.183 +	//Initialize - with the UID of our test HwDevice
   1.184 +	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
   1.185 +	TUid testUID = {KUidBufferFramesConfigTestDevice};
   1.186 +	#else
   1.187 +	TFourCC testUID('T','0','0','7');
   1.188 +	#endif
   1.189 +	
   1.190 +	MMMFBufferFramesConfig* interface = NULL;
   1.191 +	interface = static_cast<MMMFBufferFramesConfig*>(InitializeAndInstantiateInterfaceL(testUID, KUidBufferFramesConfig));
   1.192 +	
   1.193 +	if (interface)
   1.194 +		{
   1.195 +		TInt frameCount = 9;
   1.196 +		TInt samplesPerFrame = 99;
   1.197 +		INFO_PRINTF1(_L("Calling test CI method"));
   1.198 +		TInt err = interface->MmbfcSetNumberOfFramesPerOutputBuffer(frameCount, samplesPerFrame);
   1.199 +		TInt testCount = 0;
   1.200 +		TInt testSamples = 0;
   1.201 +		// Reset test result in case we leave...
   1.202 +		iTestStepResult = EFail;
   1.203 +		DoReadFromFileL(testCount, testSamples);
   1.204 +		if ((err == KErrNone) && (frameCount == testCount) && (samplesPerFrame == testSamples))
   1.205 +			{
   1.206 +			INFO_PRINTF1(_L("Test CI method call was successful"));
   1.207 +			iTestStepResult = EPass;
   1.208 +			}
   1.209 +		else
   1.210 +			{
   1.211 +			INFO_PRINTF4(_L("Test CI method call failed, error: %d, expected frames: %d, \
   1.212 +							 expected samples: %d"), err, frameCount, samplesPerFrame);
   1.213 +			INFO_PRINTF3(_L("Actual values: frames: %d, samplesPerFrame: %d"), testCount, testSamples);
   1.214 +			}
   1.215 +		}
   1.216 +	else
   1.217 +		{
   1.218 +		INFO_PRINTF1(_L("Failed to retrieve the custom interface"));
   1.219 +		iTestStepResult = EInconclusive;
   1.220 +		}
   1.221 +					
   1.222 +	return iTestStepResult;
   1.223 +	}
   1.224 +