os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepcigettimestamps.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/teststepcigettimestamps.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,192 @@
     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 "teststepcigettimestamps.h"
    1.21 +#include "cidefine.h"
    1.22 +
    1.23 +/*****************************************************************************/
    1.24 +CTestStepCICreateGetTimestamps::CTestStepCICreateGetTimestamps()
    1.25 +	{
    1.26 +	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0085-HP");
    1.27 +	}
    1.28 +
    1.29 +/*****************************************************************************/
    1.30 +TVerdict CTestStepCICreateGetTimestamps::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 = {KUidGetTimestampsTestDevice}; 
    1.39 +	#else
    1.40 +	TFourCC testUID('T','0','0','6');
    1.41 +	#endif
    1.42 +	
    1.43 +	MMMFGetTimestamps* interface = NULL;
    1.44 +	interface = static_cast<MMMFGetTimestamps*>(
    1.45 +							InitializeAndInstantiateInterfaceL(testUID, KUidGetTimestamps));
    1.46 +
    1.47 +	if (interface)
    1.48 +		{
    1.49 +		iTestStepResult = EPass;
    1.50 +		INFO_PRINTF1(_L("Successfully retrieved the interface."));
    1.51 +		}
    1.52 +	else
    1.53 +		{
    1.54 +		iTestStepResult = EFail;
    1.55 +		ERR_PRINTF1(_L("Failed to retrieve the interface"));
    1.56 +		}
    1.57 +
    1.58 +	return iTestStepResult;
    1.59 +	}
    1.60 +
    1.61 +/*****************************************************************************/
    1.62 +CTestStepCIGetTimestampsEnable::CTestStepCIGetTimestampsEnable()
    1.63 +	{
    1.64 +	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0086-HP");
    1.65 +	}
    1.66 +
    1.67 +/*****************************************************************************/
    1.68 +TVerdict CTestStepCIGetTimestampsEnable::DoTestStepL()
    1.69 +	{
    1.70 +	iTestStepResult = EFail;
    1.71 +
    1.72 +	INFO_PRINTF1(_L("Initializing test CI device"));
    1.73 +	
    1.74 +	//Initialize - with the UID of our test HwDevice
    1.75 +	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
    1.76 +	TUid testUID = {KUidGetTimestampsTestDevice}; 
    1.77 +	#else
    1.78 +	TFourCC testUID('T','0','0','6');
    1.79 +	#endif
    1.80 +	
    1.81 +	MMMFGetTimestamps* interface = NULL;
    1.82 +	interface = static_cast<MMMFGetTimestamps*>(InitializeAndInstantiateInterfaceL(testUID, KUidGetTimestamps));
    1.83 +
    1.84 +	if (interface)
    1.85 +		{
    1.86 +		TBool enabled = ETrue;
    1.87 +		INFO_PRINTF1(_L("Calling test CI method"));
    1.88 +		TInt err = interface->MmgtSetRecordSystemTimestampsEnabled(enabled);
    1.89 +		TBool flag = EFalse;
    1.90 +		// Reset test result in case we leave...
    1.91 +		iTestStepResult = EFail;
    1.92 +		DoReadFromFileL(flag);
    1.93 +		if ((err == KErrNone) && (flag == enabled))
    1.94 +			{
    1.95 +			INFO_PRINTF1(_L("Test CI method call was successful"));
    1.96 +			iTestStepResult = EPass;
    1.97 +			}
    1.98 +		else
    1.99 +			{
   1.100 +			INFO_PRINTF4(_L("Test CI method call failed, error: %d, expected value: %d, \
   1.101 +								actual value: %d"), err, enabled, flag);
   1.102 +			}
   1.103 +		}
   1.104 +	else
   1.105 +		{
   1.106 +		INFO_PRINTF1(_L("Failed to retrieve the custom interface."));
   1.107 +		iTestStepResult = EInconclusive;
   1.108 +		}
   1.109 +			
   1.110 +	return iTestStepResult;
   1.111 +	}
   1.112 +
   1.113 +void CTestStepCIGetTimestampsEnable::DoReadFromFileL(TBool& aFlag)
   1.114 +	{
   1.115 +	RFs fs;
   1.116 +	CleanupClosePushL(fs);
   1.117 +	User::LeaveIfError(fs.Connect());
   1.118 +	
   1.119 +	RFile file;
   1.120 +	CleanupClosePushL(file);
   1.121 +	
   1.122 +	// File should already exist
   1.123 +	User::LeaveIfError(file.Open(fs, KCITestFileName, EFileRead));
   1.124 +	// Size should be 1!
   1.125 +	TInt fileSize = 0;
   1.126 +	User::LeaveIfError(file.Size(fileSize));
   1.127 +	if (fileSize != KMaxCITestFileDataLength)
   1.128 +		{
   1.129 +		User::Leave(KErrCorrupt);
   1.130 +		}
   1.131 +	TBuf8<KMaxCITestFileDataLength> inputBuf;
   1.132 +	User::LeaveIfError(file.Read(inputBuf));
   1.133 +	TChar val = inputBuf[0];
   1.134 +	aFlag = val.GetNumericValue();
   1.135 +
   1.136 +	CleanupStack::PopAndDestroy(); // file	
   1.137 +
   1.138 +	// This function is responsible for the deletion of the file after use
   1.139 +	User::LeaveIfError(fs.Delete(KCITestFileName));
   1.140 +
   1.141 +	CleanupStack::PopAndDestroy(); // fs
   1.142 +	}
   1.143 +
   1.144 +/*****************************************************************************/
   1.145 +CTestStepCIGetTimestampsForBuffer::CTestStepCIGetTimestampsForBuffer()
   1.146 +	{
   1.147 +	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0087-HP");
   1.148 +	}
   1.149 +
   1.150 +/*****************************************************************************/
   1.151 +TVerdict CTestStepCIGetTimestampsForBuffer::DoTestStepL()
   1.152 +	{
   1.153 +	iTestStepResult = EFail;
   1.154 +
   1.155 +	INFO_PRINTF1(_L("Initializing test CI device"));
   1.156 +	
   1.157 +	//Initialize - with the UID of our test HwDevice
   1.158 +	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
   1.159 +	TUid testUID = {KUidGetTimestampsTestDevice}; 
   1.160 +	#else
   1.161 +	TFourCC testUID('T','0','0','6');
   1.162 +	#endif
   1.163 +	
   1.164 +	MMMFGetTimestamps* interface = NULL;
   1.165 +	interface = static_cast<MMMFGetTimestamps*>(InitializeAndInstantiateInterfaceL(testUID, KUidGetTimestamps));
   1.166 +
   1.167 +	if (interface)
   1.168 +		{
   1.169 +		INFO_PRINTF1(_L("Calling test CI method"));
   1.170 +		// Test device implementation expects this value:
   1.171 +		TTimeIntervalMicroSeconds bufferPosition(KTimestampPosition);
   1.172 +		TTime timestamp;
   1.173 +		TInt err = interface->MmgtGetSystemTimestampForBuffer(bufferPosition, timestamp);
   1.174 +		// and it should return this value:
   1.175 +		TTime testTimestamp(KTimestampValue);
   1.176 +		if ((err == KErrNone) && (testTimestamp == timestamp))
   1.177 +			{
   1.178 +			INFO_PRINTF1(_L("Test CI method call was successful"));
   1.179 +			iTestStepResult = EPass;
   1.180 +			}
   1.181 +		else
   1.182 +			{
   1.183 +			INFO_PRINTF3(_L("Expected timestamp: %d, actual timestamp: %d"), \
   1.184 +							timestamp.Int64(), testTimestamp.Int64());
   1.185 +			iTestStepResult = EFail;
   1.186 +			}				
   1.187 +		}
   1.188 +	else
   1.189 +		{
   1.190 +		INFO_PRINTF1(_L("Failed to retrieve the custom interface."));
   1.191 +		iTestStepResult = EInconclusive;
   1.192 +		}
   1.193 +					
   1.194 +	return iTestStepResult;
   1.195 +	}