os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepcibufferframesconfig.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include <f32file.h>
    17 #include "teststepcibufferframesconfig.h"
    18 #include "cidefine.h"
    19 
    20 /*****************************************************************************/
    21 CTestStepCICreateBufferFramesConfig::CTestStepCICreateBufferFramesConfig()
    22 	{
    23 	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0082-HP");
    24 	}
    25 
    26 /*****************************************************************************/
    27 TVerdict CTestStepCICreateBufferFramesConfig::DoTestStepL()
    28 	{
    29 	iTestStepResult = EFail;
    30 
    31 	INFO_PRINTF1(_L("Initializing test CI device"));
    32 	
    33 	//Initialize - with the UID of our test HwDevice
    34 	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
    35 	TUid testUID = {KUidBufferFramesConfigTestDevice};
    36 	#else
    37 	TFourCC testUID('T','0','0','7');
    38 	#endif
    39 	
    40 	MMMFBufferFramesConfig* interface = NULL;
    41 	interface = static_cast<MMMFBufferFramesConfig*>(InitializeAndInstantiateInterfaceL(testUID, KUidBufferFramesConfig));
    42 	
    43 	if (interface)
    44 		{
    45 		iTestStepResult = EPass;
    46 		INFO_PRINTF1(_L("Successfully retrieved the interface."));
    47 		}
    48 	else
    49 		{
    50 		iTestStepResult = EFail;
    51 		ERR_PRINTF1(_L("Failed to retrieve the interface"));
    52 		}
    53 
    54 	return iTestStepResult;
    55 	}
    56 
    57 /*****************************************************************************/
    58 CTestStepCIBufferFramesConfigSetBase::CTestStepCIBufferFramesConfigSetBase()
    59 	{
    60 	}
    61 	
    62 TVerdict CTestStepCIBufferFramesConfigSetBase::DoTestStepL()
    63 	{
    64 	return EPass;	
    65 	}
    66 
    67 void CTestStepCIBufferFramesConfigSetBase::DoReadFromFileL(TInt& aFrames, TInt& aSamples)
    68 	{
    69 	RFs fs;
    70 	CleanupClosePushL(fs);
    71 	User::LeaveIfError(fs.Connect());
    72 	
    73 	RFile file;
    74 	CleanupClosePushL(file);
    75 	
    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);
    82 	input.Mark();
    83 	input.SkipCharacters();
    84 	if (input.TokenLength() != 0)
    85 		{
    86 		TInt value;
    87 		TLex8 temp(input.MarkedToken());
    88 		User::LeaveIfError(temp.Val(value));
    89 		// succesfully read the first value (the frames count)
    90 		aFrames = value;
    91 		
    92 		input.SkipSpaceAndMark();
    93 		input.SkipCharacters();
    94 		if (input.TokenLength() != 0)
    95 			{
    96 			temp = input.MarkedToken();
    97 			User::LeaveIfError(temp.Val(value));
    98 			// succesfully read the seconde value (the samples count)
    99 			aSamples = value;
   100 			}
   101 		}
   102 
   103 	CleanupStack::PopAndDestroy(); // file	
   104 
   105 	// It is the responsibility of this function to delete the file after use	
   106 	User::LeaveIfError(fs.Delete(KCITestFileName));
   107 
   108 	CleanupStack::PopAndDestroy(); // fs
   109 	}
   110 
   111 
   112 /*****************************************************************************/
   113 CTestStepCIBufferFramesConfigSetInput::CTestStepCIBufferFramesConfigSetInput()
   114 	{
   115 	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0083-HP");
   116 	}
   117 
   118 /*****************************************************************************/
   119 TVerdict CTestStepCIBufferFramesConfigSetInput::DoTestStepL()
   120 	{
   121 	iTestStepResult = EFail;
   122 
   123 	INFO_PRINTF1(_L("Initializing test CI device"));
   124 	
   125 	//Initialize - with the UID of our test HwDevice
   126 	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
   127 	TUid testUID = {KUidBufferFramesConfigTestDevice};
   128 	#else
   129 	TFourCC testUID('T','0','0','7');
   130 	#endif
   131 	
   132 	MMMFBufferFramesConfig* interface = NULL;
   133 	interface = static_cast<MMMFBufferFramesConfig*>(InitializeAndInstantiateInterfaceL(testUID, KUidBufferFramesConfig));
   134 	
   135 	if (interface)
   136 		{
   137 		TInt frameCount = 6;
   138 		TInt samplesPerFrame = 66;
   139 		INFO_PRINTF1(_L("Calling test CI method"));
   140 		TInt err = interface->MmbfcSetNumberOfFramesPerInputBuffer(frameCount, samplesPerFrame);
   141 		TInt testCount = 0;
   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))
   147 			{
   148 			INFO_PRINTF1(_L("Test CI method call was successful"));
   149 			iTestStepResult = EPass;
   150 			}
   151 		else
   152 			{
   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);
   156 			}
   157 		}
   158 	else
   159 		{
   160 		INFO_PRINTF1(_L("Failed to retrieve the custom interface"));
   161 		iTestStepResult = EInconclusive;
   162 		}
   163 
   164 	return iTestStepResult;
   165 	}
   166 
   167 /*****************************************************************************/
   168 CTestStepCIBufferFramesConfigSetOutput::CTestStepCIBufferFramesConfigSetOutput()
   169 	{
   170 	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0084-HP");
   171 	}
   172 
   173 /*****************************************************************************/
   174 TVerdict CTestStepCIBufferFramesConfigSetOutput::DoTestStepL()
   175 	{
   176 	iTestStepResult = EFail;
   177 
   178 	INFO_PRINTF1(_L("Initializing test CI device"));
   179 	
   180 	//Initialize - with the UID of our test HwDevice
   181 	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
   182 	TUid testUID = {KUidBufferFramesConfigTestDevice};
   183 	#else
   184 	TFourCC testUID('T','0','0','7');
   185 	#endif
   186 	
   187 	MMMFBufferFramesConfig* interface = NULL;
   188 	interface = static_cast<MMMFBufferFramesConfig*>(InitializeAndInstantiateInterfaceL(testUID, KUidBufferFramesConfig));
   189 	
   190 	if (interface)
   191 		{
   192 		TInt frameCount = 9;
   193 		TInt samplesPerFrame = 99;
   194 		INFO_PRINTF1(_L("Calling test CI method"));
   195 		TInt err = interface->MmbfcSetNumberOfFramesPerOutputBuffer(frameCount, samplesPerFrame);
   196 		TInt testCount = 0;
   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))
   202 			{
   203 			INFO_PRINTF1(_L("Test CI method call was successful"));
   204 			iTestStepResult = EPass;
   205 			}
   206 		else
   207 			{
   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);
   211 			}
   212 		}
   213 	else
   214 		{
   215 		INFO_PRINTF1(_L("Failed to retrieve the custom interface"));
   216 		iTestStepResult = EInconclusive;
   217 		}
   218 					
   219 	return iTestStepResult;
   220 	}
   221