os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepcibufferframesconfig.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <f32file.h>
sl@0
    17
#include "teststepcibufferframesconfig.h"
sl@0
    18
#include "cidefine.h"
sl@0
    19
sl@0
    20
/*****************************************************************************/
sl@0
    21
CTestStepCICreateBufferFramesConfig::CTestStepCICreateBufferFramesConfig()
sl@0
    22
	{
sl@0
    23
	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0082-HP");
sl@0
    24
	}
sl@0
    25
sl@0
    26
/*****************************************************************************/
sl@0
    27
TVerdict CTestStepCICreateBufferFramesConfig::DoTestStepL()
sl@0
    28
	{
sl@0
    29
	iTestStepResult = EFail;
sl@0
    30
sl@0
    31
	INFO_PRINTF1(_L("Initializing test CI device"));
sl@0
    32
	
sl@0
    33
	//Initialize - with the UID of our test HwDevice
sl@0
    34
	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
sl@0
    35
	TUid testUID = {KUidBufferFramesConfigTestDevice};
sl@0
    36
	#else
sl@0
    37
	TFourCC testUID('T','0','0','7');
sl@0
    38
	#endif
sl@0
    39
	
sl@0
    40
	MMMFBufferFramesConfig* interface = NULL;
sl@0
    41
	interface = static_cast<MMMFBufferFramesConfig*>(InitializeAndInstantiateInterfaceL(testUID, KUidBufferFramesConfig));
sl@0
    42
	
sl@0
    43
	if (interface)
sl@0
    44
		{
sl@0
    45
		iTestStepResult = EPass;
sl@0
    46
		INFO_PRINTF1(_L("Successfully retrieved the interface."));
sl@0
    47
		}
sl@0
    48
	else
sl@0
    49
		{
sl@0
    50
		iTestStepResult = EFail;
sl@0
    51
		ERR_PRINTF1(_L("Failed to retrieve the interface"));
sl@0
    52
		}
sl@0
    53
sl@0
    54
	return iTestStepResult;
sl@0
    55
	}
sl@0
    56
sl@0
    57
/*****************************************************************************/
sl@0
    58
CTestStepCIBufferFramesConfigSetBase::CTestStepCIBufferFramesConfigSetBase()
sl@0
    59
	{
sl@0
    60
	}
sl@0
    61
	
sl@0
    62
TVerdict CTestStepCIBufferFramesConfigSetBase::DoTestStepL()
sl@0
    63
	{
sl@0
    64
	return EPass;	
sl@0
    65
	}
sl@0
    66
sl@0
    67
void CTestStepCIBufferFramesConfigSetBase::DoReadFromFileL(TInt& aFrames, TInt& aSamples)
sl@0
    68
	{
sl@0
    69
	RFs fs;
sl@0
    70
	CleanupClosePushL(fs);
sl@0
    71
	User::LeaveIfError(fs.Connect());
sl@0
    72
	
sl@0
    73
	RFile file;
sl@0
    74
	CleanupClosePushL(file);
sl@0
    75
	
sl@0
    76
	// File should already exist
sl@0
    77
	User::LeaveIfError(file.Open(fs, KCITestFileName, EFileRead));
sl@0
    78
	TBuf8<KMaxCITestFileTimeDataLength> inputBuf;
sl@0
    79
	User::LeaveIfError(file.Read(inputBuf));
sl@0
    80
	// Do some lexical analysis
sl@0
    81
	TLex8 input(inputBuf);
sl@0
    82
	input.Mark();
sl@0
    83
	input.SkipCharacters();
sl@0
    84
	if (input.TokenLength() != 0)
sl@0
    85
		{
sl@0
    86
		TInt value;
sl@0
    87
		TLex8 temp(input.MarkedToken());
sl@0
    88
		User::LeaveIfError(temp.Val(value));
sl@0
    89
		// succesfully read the first value (the frames count)
sl@0
    90
		aFrames = value;
sl@0
    91
		
sl@0
    92
		input.SkipSpaceAndMark();
sl@0
    93
		input.SkipCharacters();
sl@0
    94
		if (input.TokenLength() != 0)
sl@0
    95
			{
sl@0
    96
			temp = input.MarkedToken();
sl@0
    97
			User::LeaveIfError(temp.Val(value));
sl@0
    98
			// succesfully read the seconde value (the samples count)
sl@0
    99
			aSamples = value;
sl@0
   100
			}
sl@0
   101
		}
sl@0
   102
sl@0
   103
	CleanupStack::PopAndDestroy(); // file	
sl@0
   104
sl@0
   105
	// It is the responsibility of this function to delete the file after use	
sl@0
   106
	User::LeaveIfError(fs.Delete(KCITestFileName));
sl@0
   107
sl@0
   108
	CleanupStack::PopAndDestroy(); // fs
sl@0
   109
	}
sl@0
   110
sl@0
   111
sl@0
   112
/*****************************************************************************/
sl@0
   113
CTestStepCIBufferFramesConfigSetInput::CTestStepCIBufferFramesConfigSetInput()
sl@0
   114
	{
sl@0
   115
	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0083-HP");
sl@0
   116
	}
sl@0
   117
sl@0
   118
/*****************************************************************************/
sl@0
   119
TVerdict CTestStepCIBufferFramesConfigSetInput::DoTestStepL()
sl@0
   120
	{
sl@0
   121
	iTestStepResult = EFail;
sl@0
   122
sl@0
   123
	INFO_PRINTF1(_L("Initializing test CI device"));
sl@0
   124
	
sl@0
   125
	//Initialize - with the UID of our test HwDevice
sl@0
   126
	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
sl@0
   127
	TUid testUID = {KUidBufferFramesConfigTestDevice};
sl@0
   128
	#else
sl@0
   129
	TFourCC testUID('T','0','0','7');
sl@0
   130
	#endif
sl@0
   131
	
sl@0
   132
	MMMFBufferFramesConfig* interface = NULL;
sl@0
   133
	interface = static_cast<MMMFBufferFramesConfig*>(InitializeAndInstantiateInterfaceL(testUID, KUidBufferFramesConfig));
sl@0
   134
	
sl@0
   135
	if (interface)
sl@0
   136
		{
sl@0
   137
		TInt frameCount = 6;
sl@0
   138
		TInt samplesPerFrame = 66;
sl@0
   139
		INFO_PRINTF1(_L("Calling test CI method"));
sl@0
   140
		TInt err = interface->MmbfcSetNumberOfFramesPerInputBuffer(frameCount, samplesPerFrame);
sl@0
   141
		TInt testCount = 0;
sl@0
   142
		TInt testSamples = 0;
sl@0
   143
		// Reset test result in case we leave...
sl@0
   144
		iTestStepResult = EFail;
sl@0
   145
		DoReadFromFileL(testCount, testSamples);
sl@0
   146
		if ((err == KErrNone) && (frameCount == testCount) && (samplesPerFrame == testSamples))
sl@0
   147
			{
sl@0
   148
			INFO_PRINTF1(_L("Test CI method call was successful"));
sl@0
   149
			iTestStepResult = EPass;
sl@0
   150
			}
sl@0
   151
		else
sl@0
   152
			{
sl@0
   153
			INFO_PRINTF4(_L("Test CI method call failed, error: %d, expected frames: %d, \
sl@0
   154
							 expected samples: %d"), err, frameCount, samplesPerFrame);
sl@0
   155
			INFO_PRINTF3(_L("Actual values: frames: %d, samplesPerFrame: %d"), testCount, testSamples);
sl@0
   156
			}
sl@0
   157
		}
sl@0
   158
	else
sl@0
   159
		{
sl@0
   160
		INFO_PRINTF1(_L("Failed to retrieve the custom interface"));
sl@0
   161
		iTestStepResult = EInconclusive;
sl@0
   162
		}
sl@0
   163
sl@0
   164
	return iTestStepResult;
sl@0
   165
	}
sl@0
   166
sl@0
   167
/*****************************************************************************/
sl@0
   168
CTestStepCIBufferFramesConfigSetOutput::CTestStepCIBufferFramesConfigSetOutput()
sl@0
   169
	{
sl@0
   170
	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0084-HP");
sl@0
   171
	}
sl@0
   172
sl@0
   173
/*****************************************************************************/
sl@0
   174
TVerdict CTestStepCIBufferFramesConfigSetOutput::DoTestStepL()
sl@0
   175
	{
sl@0
   176
	iTestStepResult = EFail;
sl@0
   177
sl@0
   178
	INFO_PRINTF1(_L("Initializing test CI device"));
sl@0
   179
	
sl@0
   180
	//Initialize - with the UID of our test HwDevice
sl@0
   181
	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
sl@0
   182
	TUid testUID = {KUidBufferFramesConfigTestDevice};
sl@0
   183
	#else
sl@0
   184
	TFourCC testUID('T','0','0','7');
sl@0
   185
	#endif
sl@0
   186
	
sl@0
   187
	MMMFBufferFramesConfig* interface = NULL;
sl@0
   188
	interface = static_cast<MMMFBufferFramesConfig*>(InitializeAndInstantiateInterfaceL(testUID, KUidBufferFramesConfig));
sl@0
   189
	
sl@0
   190
	if (interface)
sl@0
   191
		{
sl@0
   192
		TInt frameCount = 9;
sl@0
   193
		TInt samplesPerFrame = 99;
sl@0
   194
		INFO_PRINTF1(_L("Calling test CI method"));
sl@0
   195
		TInt err = interface->MmbfcSetNumberOfFramesPerOutputBuffer(frameCount, samplesPerFrame);
sl@0
   196
		TInt testCount = 0;
sl@0
   197
		TInt testSamples = 0;
sl@0
   198
		// Reset test result in case we leave...
sl@0
   199
		iTestStepResult = EFail;
sl@0
   200
		DoReadFromFileL(testCount, testSamples);
sl@0
   201
		if ((err == KErrNone) && (frameCount == testCount) && (samplesPerFrame == testSamples))
sl@0
   202
			{
sl@0
   203
			INFO_PRINTF1(_L("Test CI method call was successful"));
sl@0
   204
			iTestStepResult = EPass;
sl@0
   205
			}
sl@0
   206
		else
sl@0
   207
			{
sl@0
   208
			INFO_PRINTF4(_L("Test CI method call failed, error: %d, expected frames: %d, \
sl@0
   209
							 expected samples: %d"), err, frameCount, samplesPerFrame);
sl@0
   210
			INFO_PRINTF3(_L("Actual values: frames: %d, samplesPerFrame: %d"), testCount, testSamples);
sl@0
   211
			}
sl@0
   212
		}
sl@0
   213
	else
sl@0
   214
		{
sl@0
   215
		INFO_PRINTF1(_L("Failed to retrieve the custom interface"));
sl@0
   216
		iTestStepResult = EInconclusive;
sl@0
   217
		}
sl@0
   218
					
sl@0
   219
	return iTestStepResult;
sl@0
   220
	}
sl@0
   221