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 "teststepciplaybackstatus.h" sl@0: #include "cidefine.h" sl@0: sl@0: /*****************************************************************************/ sl@0: CTestStepCIPlaybackStatus::CTestStepCIPlaybackStatus() sl@0: { sl@0: iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0074-HP"); sl@0: } sl@0: sl@0: /*****************************************************************************/ sl@0: TVerdict CTestStepCIPlaybackStatus::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 = {KUidPlayBackStatusTestDevice}; sl@0: #else sl@0: TFourCC testUID('T','0','0','1'); sl@0: #endif sl@0: sl@0: MMMFPlaybackStatus* interface = NULL; sl@0: interface = static_cast(InitializeAndInstantiateInterfaceL(testUID, KUidPlaybackStatus)); 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: CTestStepCIPlaybackStatusInfo::CTestStepCIPlaybackStatusInfo() sl@0: { sl@0: iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0075-HP"); sl@0: } sl@0: sl@0: /*****************************************************************************/ sl@0: TVerdict CTestStepCIPlaybackStatusInfo::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 = {KUidPlayBackStatusTestDevice}; sl@0: #else sl@0: TFourCC testUID('T','0','0','1'); sl@0: #endif sl@0: sl@0: MMMFPlaybackStatus* interface = NULL; sl@0: interface = static_cast(InitializeAndInstantiateInterfaceL(testUID, KUidPlaybackStatus)); sl@0: sl@0: if (interface) sl@0: { sl@0: INFO_PRINTF1(_L("Successfully retrieved the interface.")); sl@0: sl@0: MMMFPlaybackStatus::TMMFPlaybackStatus status; sl@0: sl@0: // Set values before call. sl@0: status.aInputBytes = 0; sl@0: status.aDecodedSamples = 0; sl@0: status.aDecodedSamplesPlayed = 0; sl@0: status.aSystemTime = 0; sl@0: status.aTotalSamplesPlayed = 0; sl@0: sl@0: interface->MmpsGetPlaybackStatusInformation(status); // call method sl@0: sl@0: if(status.aInputBytes == 999 && sl@0: status.aDecodedSamples == 999 && sl@0: status.aDecodedSamplesPlayed == 999 && sl@0: status.aSystemTime == 999 && sl@0: status.aTotalSamplesPlayed == 999) sl@0: { sl@0: iTestStepResult = EPass; sl@0: INFO_PRINTF1(_L("Successfully got the status information.")); sl@0: } sl@0: else sl@0: { sl@0: iTestStepResult = EFail; sl@0: ERR_PRINTF1(_L("Failed to retrieve the status information")); sl@0: } sl@0: } sl@0: else sl@0: { 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: /*****************************************************************************/ sl@0: CTestStepCIPlaybackStatusRequestNotification::CTestStepCIPlaybackStatusRequestNotification(TBool aIsCancelTest) sl@0: : iIsCancelTest(aIsCancelTest) sl@0: { sl@0: if (iIsCancelTest) sl@0: { sl@0: iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0098-HP"); sl@0: } sl@0: else sl@0: { sl@0: iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0097-HP"); sl@0: } sl@0: } sl@0: sl@0: /*****************************************************************************/ sl@0: TVerdict CTestStepCIPlaybackStatusRequestNotification::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 = {KUidPlayBackStatusTestDevice}; sl@0: #else sl@0: TFourCC testUID('T','0','0','1'); sl@0: #endif sl@0: sl@0: MMMFPlaybackStatus* interface = NULL; sl@0: interface = static_cast(InitializeAndInstantiateInterfaceL(testUID, KUidPlaybackStatus)); sl@0: sl@0: if (interface) sl@0: { sl@0: INFO_PRINTF1(_L("Successfully retrieved the interface.")); sl@0: sl@0: iTestStepResult = EFail; sl@0: if (iIsCancelTest) sl@0: { sl@0: DoCancelTestL(*interface); sl@0: } sl@0: else sl@0: { sl@0: DoRequestTestL(*interface); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF1(_L("Failed to retrieve the interface")); sl@0: } sl@0: sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: void CTestStepCIPlaybackStatusRequestNotification::DoRequestTestL(MMMFPlaybackStatus& aInterface) sl@0: { sl@0: // Make the request. sl@0: TInt err = aInterface.MmpsRequestLossOfSyncNotification(); sl@0: sl@0: if (err == KErrNone) sl@0: { sl@0: // Get the result sl@0: TBool testResult = EFalse; sl@0: DoReadFromFileL(testResult); sl@0: sl@0: if (testResult) sl@0: { sl@0: // Value should be ETrue! sl@0: iTestStepResult = EPass; sl@0: INFO_PRINTF1(_L("Successfully requested the notification.")); sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Failed to request the notification"), err); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Failed to request the notification"), err); sl@0: } sl@0: } sl@0: sl@0: void CTestStepCIPlaybackStatusRequestNotification::DoCancelTestL(MMMFPlaybackStatus& aInterface) sl@0: { sl@0: // Make the request. sl@0: TInt err = aInterface.MmpsCancelLossOfSyncNotification(); sl@0: sl@0: if (err == KErrNone) sl@0: { sl@0: // Get the result sl@0: TBool testResult = ETrue; sl@0: DoReadFromFileL(testResult); sl@0: sl@0: if (!testResult) sl@0: { sl@0: // Value should be EFalse! sl@0: iTestStepResult = EPass; sl@0: INFO_PRINTF1(_L("Successfully cancelled the notification.")); sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Failed to cancel the notification"), err); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Failed to cancel the notification"), err); sl@0: } sl@0: } sl@0: sl@0: void CTestStepCIPlaybackStatusRequestNotification::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: // It is the responsibility of this function to delete the file after use sl@0: User::LeaveIfError(fs.Delete(KCITestFileName)); sl@0: sl@0: CleanupStack::PopAndDestroy(); // fs sl@0: } sl@0: