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