sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include "teststepcigettimestamps.h" sl@0: #include "cidefine.h" sl@0: sl@0: /*****************************************************************************/ sl@0: CTestStepCICreateGetTimestamps::CTestStepCICreateGetTimestamps() sl@0: { sl@0: iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0085-HP"); sl@0: } sl@0: sl@0: /*****************************************************************************/ sl@0: TVerdict CTestStepCICreateGetTimestamps::DoTestStepL() sl@0: { sl@0: iTestStepResult = EFail; sl@0: sl@0: INFO_PRINTF1(_L("Initializing test CI device")); sl@0: sl@0: //Initialize - with the UID of our test HwDevice sl@0: #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND sl@0: TUid testUID = {KUidGetTimestampsTestDevice}; sl@0: #else sl@0: TFourCC testUID('T','0','0','6'); sl@0: #endif sl@0: sl@0: MMMFGetTimestamps* interface = NULL; sl@0: interface = static_cast( sl@0: InitializeAndInstantiateInterfaceL(testUID, KUidGetTimestamps)); sl@0: sl@0: if (interface) sl@0: { sl@0: iTestStepResult = EPass; sl@0: INFO_PRINTF1(_L("Successfully retrieved the interface.")); sl@0: } sl@0: else sl@0: { sl@0: iTestStepResult = EFail; sl@0: ERR_PRINTF1(_L("Failed to retrieve the interface")); sl@0: } sl@0: sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: /*****************************************************************************/ sl@0: CTestStepCIGetTimestampsEnable::CTestStepCIGetTimestampsEnable() sl@0: { sl@0: iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0086-HP"); sl@0: } sl@0: sl@0: /*****************************************************************************/ sl@0: TVerdict CTestStepCIGetTimestampsEnable::DoTestStepL() sl@0: { sl@0: iTestStepResult = EFail; sl@0: sl@0: INFO_PRINTF1(_L("Initializing test CI device")); sl@0: sl@0: //Initialize - with the UID of our test HwDevice sl@0: #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND sl@0: TUid testUID = {KUidGetTimestampsTestDevice}; sl@0: #else sl@0: TFourCC testUID('T','0','0','6'); sl@0: #endif sl@0: sl@0: MMMFGetTimestamps* interface = NULL; sl@0: interface = static_cast(InitializeAndInstantiateInterfaceL(testUID, KUidGetTimestamps)); sl@0: sl@0: if (interface) sl@0: { sl@0: TBool enabled = ETrue; sl@0: INFO_PRINTF1(_L("Calling test CI method")); sl@0: TInt err = interface->MmgtSetRecordSystemTimestampsEnabled(enabled); sl@0: TBool flag = EFalse; sl@0: // Reset test result in case we leave... sl@0: iTestStepResult = EFail; sl@0: DoReadFromFileL(flag); sl@0: if ((err == KErrNone) && (flag == enabled)) sl@0: { sl@0: INFO_PRINTF1(_L("Test CI method call was successful")); sl@0: iTestStepResult = EPass; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF4(_L("Test CI method call failed, error: %d, expected value: %d, \ sl@0: actual value: %d"), err, enabled, flag); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Failed to retrieve the custom interface.")); sl@0: iTestStepResult = EInconclusive; sl@0: } sl@0: sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: void CTestStepCIGetTimestampsEnable::DoReadFromFileL(TBool& aFlag) sl@0: { sl@0: RFs fs; sl@0: CleanupClosePushL(fs); sl@0: User::LeaveIfError(fs.Connect()); sl@0: sl@0: RFile file; sl@0: CleanupClosePushL(file); sl@0: sl@0: // File should already exist sl@0: User::LeaveIfError(file.Open(fs, KCITestFileName, EFileRead)); sl@0: // Size should be 1! sl@0: TInt fileSize = 0; sl@0: User::LeaveIfError(file.Size(fileSize)); sl@0: if (fileSize != KMaxCITestFileDataLength) sl@0: { sl@0: User::Leave(KErrCorrupt); sl@0: } sl@0: TBuf8 inputBuf; sl@0: User::LeaveIfError(file.Read(inputBuf)); sl@0: TChar val = inputBuf[0]; sl@0: aFlag = val.GetNumericValue(); sl@0: sl@0: CleanupStack::PopAndDestroy(); // file sl@0: sl@0: // This function is responsible for the deletion of the file after use sl@0: User::LeaveIfError(fs.Delete(KCITestFileName)); sl@0: sl@0: CleanupStack::PopAndDestroy(); // fs sl@0: } sl@0: sl@0: /*****************************************************************************/ sl@0: CTestStepCIGetTimestampsForBuffer::CTestStepCIGetTimestampsForBuffer() sl@0: { sl@0: iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0087-HP"); sl@0: } sl@0: sl@0: /*****************************************************************************/ sl@0: TVerdict CTestStepCIGetTimestampsForBuffer::DoTestStepL() sl@0: { sl@0: iTestStepResult = EFail; sl@0: sl@0: INFO_PRINTF1(_L("Initializing test CI device")); sl@0: sl@0: //Initialize - with the UID of our test HwDevice sl@0: #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND sl@0: TUid testUID = {KUidGetTimestampsTestDevice}; sl@0: #else sl@0: TFourCC testUID('T','0','0','6'); sl@0: #endif sl@0: sl@0: MMMFGetTimestamps* interface = NULL; sl@0: interface = static_cast(InitializeAndInstantiateInterfaceL(testUID, KUidGetTimestamps)); sl@0: sl@0: if (interface) sl@0: { sl@0: INFO_PRINTF1(_L("Calling test CI method")); sl@0: // Test device implementation expects this value: sl@0: TTimeIntervalMicroSeconds bufferPosition(KTimestampPosition); sl@0: TTime timestamp; sl@0: TInt err = interface->MmgtGetSystemTimestampForBuffer(bufferPosition, timestamp); sl@0: // and it should return this value: sl@0: TTime testTimestamp(KTimestampValue); sl@0: if ((err == KErrNone) && (testTimestamp == timestamp)) sl@0: { sl@0: INFO_PRINTF1(_L("Test CI method call was successful")); sl@0: iTestStepResult = EPass; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF3(_L("Expected timestamp: %d, actual timestamp: %d"), \ sl@0: timestamp.Int64(), testTimestamp.Int64()); sl@0: iTestStepResult = EFail; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Failed to retrieve the custom interface.")); sl@0: iTestStepResult = EInconclusive; sl@0: } sl@0: sl@0: return iTestStepResult; sl@0: }