os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepcigettimestamps.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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 "teststepcigettimestamps.h"
sl@0
    18
#include "cidefine.h"
sl@0
    19
sl@0
    20
/*****************************************************************************/
sl@0
    21
CTestStepCICreateGetTimestamps::CTestStepCICreateGetTimestamps()
sl@0
    22
	{
sl@0
    23
	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0085-HP");
sl@0
    24
	}
sl@0
    25
sl@0
    26
/*****************************************************************************/
sl@0
    27
TVerdict CTestStepCICreateGetTimestamps::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 = {KUidGetTimestampsTestDevice}; 
sl@0
    36
	#else
sl@0
    37
	TFourCC testUID('T','0','0','6');
sl@0
    38
	#endif
sl@0
    39
	
sl@0
    40
	MMMFGetTimestamps* interface = NULL;
sl@0
    41
	interface = static_cast<MMMFGetTimestamps*>(
sl@0
    42
							InitializeAndInstantiateInterfaceL(testUID, KUidGetTimestamps));
sl@0
    43
sl@0
    44
	if (interface)
sl@0
    45
		{
sl@0
    46
		iTestStepResult = EPass;
sl@0
    47
		INFO_PRINTF1(_L("Successfully retrieved the interface."));
sl@0
    48
		}
sl@0
    49
	else
sl@0
    50
		{
sl@0
    51
		iTestStepResult = EFail;
sl@0
    52
		ERR_PRINTF1(_L("Failed to retrieve the interface"));
sl@0
    53
		}
sl@0
    54
sl@0
    55
	return iTestStepResult;
sl@0
    56
	}
sl@0
    57
sl@0
    58
/*****************************************************************************/
sl@0
    59
CTestStepCIGetTimestampsEnable::CTestStepCIGetTimestampsEnable()
sl@0
    60
	{
sl@0
    61
	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0086-HP");
sl@0
    62
	}
sl@0
    63
sl@0
    64
/*****************************************************************************/
sl@0
    65
TVerdict CTestStepCIGetTimestampsEnable::DoTestStepL()
sl@0
    66
	{
sl@0
    67
	iTestStepResult = EFail;
sl@0
    68
sl@0
    69
	INFO_PRINTF1(_L("Initializing test CI device"));
sl@0
    70
	
sl@0
    71
	//Initialize - with the UID of our test HwDevice
sl@0
    72
	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
sl@0
    73
	TUid testUID = {KUidGetTimestampsTestDevice}; 
sl@0
    74
	#else
sl@0
    75
	TFourCC testUID('T','0','0','6');
sl@0
    76
	#endif
sl@0
    77
	
sl@0
    78
	MMMFGetTimestamps* interface = NULL;
sl@0
    79
	interface = static_cast<MMMFGetTimestamps*>(InitializeAndInstantiateInterfaceL(testUID, KUidGetTimestamps));
sl@0
    80
sl@0
    81
	if (interface)
sl@0
    82
		{
sl@0
    83
		TBool enabled = ETrue;
sl@0
    84
		INFO_PRINTF1(_L("Calling test CI method"));
sl@0
    85
		TInt err = interface->MmgtSetRecordSystemTimestampsEnabled(enabled);
sl@0
    86
		TBool flag = EFalse;
sl@0
    87
		// Reset test result in case we leave...
sl@0
    88
		iTestStepResult = EFail;
sl@0
    89
		DoReadFromFileL(flag);
sl@0
    90
		if ((err == KErrNone) && (flag == enabled))
sl@0
    91
			{
sl@0
    92
			INFO_PRINTF1(_L("Test CI method call was successful"));
sl@0
    93
			iTestStepResult = EPass;
sl@0
    94
			}
sl@0
    95
		else
sl@0
    96
			{
sl@0
    97
			INFO_PRINTF4(_L("Test CI method call failed, error: %d, expected value: %d, \
sl@0
    98
								actual value: %d"), err, enabled, flag);
sl@0
    99
			}
sl@0
   100
		}
sl@0
   101
	else
sl@0
   102
		{
sl@0
   103
		INFO_PRINTF1(_L("Failed to retrieve the custom interface."));
sl@0
   104
		iTestStepResult = EInconclusive;
sl@0
   105
		}
sl@0
   106
			
sl@0
   107
	return iTestStepResult;
sl@0
   108
	}
sl@0
   109
sl@0
   110
void CTestStepCIGetTimestampsEnable::DoReadFromFileL(TBool& aFlag)
sl@0
   111
	{
sl@0
   112
	RFs fs;
sl@0
   113
	CleanupClosePushL(fs);
sl@0
   114
	User::LeaveIfError(fs.Connect());
sl@0
   115
	
sl@0
   116
	RFile file;
sl@0
   117
	CleanupClosePushL(file);
sl@0
   118
	
sl@0
   119
	// File should already exist
sl@0
   120
	User::LeaveIfError(file.Open(fs, KCITestFileName, EFileRead));
sl@0
   121
	// Size should be 1!
sl@0
   122
	TInt fileSize = 0;
sl@0
   123
	User::LeaveIfError(file.Size(fileSize));
sl@0
   124
	if (fileSize != KMaxCITestFileDataLength)
sl@0
   125
		{
sl@0
   126
		User::Leave(KErrCorrupt);
sl@0
   127
		}
sl@0
   128
	TBuf8<KMaxCITestFileDataLength> inputBuf;
sl@0
   129
	User::LeaveIfError(file.Read(inputBuf));
sl@0
   130
	TChar val = inputBuf[0];
sl@0
   131
	aFlag = val.GetNumericValue();
sl@0
   132
sl@0
   133
	CleanupStack::PopAndDestroy(); // file	
sl@0
   134
sl@0
   135
	// This function is responsible for the deletion of the file after use
sl@0
   136
	User::LeaveIfError(fs.Delete(KCITestFileName));
sl@0
   137
sl@0
   138
	CleanupStack::PopAndDestroy(); // fs
sl@0
   139
	}
sl@0
   140
sl@0
   141
/*****************************************************************************/
sl@0
   142
CTestStepCIGetTimestampsForBuffer::CTestStepCIGetTimestampsForBuffer()
sl@0
   143
	{
sl@0
   144
	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0087-HP");
sl@0
   145
	}
sl@0
   146
sl@0
   147
/*****************************************************************************/
sl@0
   148
TVerdict CTestStepCIGetTimestampsForBuffer::DoTestStepL()
sl@0
   149
	{
sl@0
   150
	iTestStepResult = EFail;
sl@0
   151
sl@0
   152
	INFO_PRINTF1(_L("Initializing test CI device"));
sl@0
   153
	
sl@0
   154
	//Initialize - with the UID of our test HwDevice
sl@0
   155
	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
sl@0
   156
	TUid testUID = {KUidGetTimestampsTestDevice}; 
sl@0
   157
	#else
sl@0
   158
	TFourCC testUID('T','0','0','6');
sl@0
   159
	#endif
sl@0
   160
	
sl@0
   161
	MMMFGetTimestamps* interface = NULL;
sl@0
   162
	interface = static_cast<MMMFGetTimestamps*>(InitializeAndInstantiateInterfaceL(testUID, KUidGetTimestamps));
sl@0
   163
sl@0
   164
	if (interface)
sl@0
   165
		{
sl@0
   166
		INFO_PRINTF1(_L("Calling test CI method"));
sl@0
   167
		// Test device implementation expects this value:
sl@0
   168
		TTimeIntervalMicroSeconds bufferPosition(KTimestampPosition);
sl@0
   169
		TTime timestamp;
sl@0
   170
		TInt err = interface->MmgtGetSystemTimestampForBuffer(bufferPosition, timestamp);
sl@0
   171
		// and it should return this value:
sl@0
   172
		TTime testTimestamp(KTimestampValue);
sl@0
   173
		if ((err == KErrNone) && (testTimestamp == timestamp))
sl@0
   174
			{
sl@0
   175
			INFO_PRINTF1(_L("Test CI method call was successful"));
sl@0
   176
			iTestStepResult = EPass;
sl@0
   177
			}
sl@0
   178
		else
sl@0
   179
			{
sl@0
   180
			INFO_PRINTF3(_L("Expected timestamp: %d, actual timestamp: %d"), \
sl@0
   181
							timestamp.Int64(), testTimestamp.Int64());
sl@0
   182
			iTestStepResult = EFail;
sl@0
   183
			}				
sl@0
   184
		}
sl@0
   185
	else
sl@0
   186
		{
sl@0
   187
		INFO_PRINTF1(_L("Failed to retrieve the custom interface."));
sl@0
   188
		iTestStepResult = EInconclusive;
sl@0
   189
		}
sl@0
   190
					
sl@0
   191
	return iTestStepResult;
sl@0
   192
	}