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 "teststepcisetdrmprotected.h" sl@0: #include "cidefine.h" sl@0: sl@0: /*****************************************************************************/ sl@0: CTestStepCICreateSetDRMProtected::CTestStepCICreateSetDRMProtected() sl@0: { sl@0: iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0080-HP"); sl@0: } sl@0: sl@0: /*****************************************************************************/ sl@0: TVerdict CTestStepCICreateSetDRMProtected::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 = {KUidSetDrmProtectedTestDevice}; sl@0: #else sl@0: TFourCC testUID('T','0','0','4'); sl@0: #endif sl@0: sl@0: MMMFSetDRMProtected* interface = NULL; sl@0: interface = static_cast(InitializeAndInstantiateInterfaceL(testUID, KUidSetDRMProtected)); 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: CTestStepCISetDRMProtected::CTestStepCISetDRMProtected() sl@0: { sl@0: iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0081-HP"); sl@0: } sl@0: sl@0: /*****************************************************************************/ sl@0: TVerdict CTestStepCISetDRMProtected::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 = {KUidSetDrmProtectedTestDevice}; sl@0: #else sl@0: TFourCC testUID('T','0','0','4'); sl@0: #endif sl@0: sl@0: MMMFSetDRMProtected* interface = NULL; sl@0: interface = static_cast(InitializeAndInstantiateInterfaceL(testUID, KUidSetDRMProtected)); sl@0: sl@0: if (interface) sl@0: { sl@0: TBool DRMProtected = ETrue; sl@0: INFO_PRINTF1(_L("Calling test CI method")); sl@0: TInt err = interface->MmsdpMarkDataAsDRMProtected(DRMProtected); 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 == DRMProtected)) 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: ERR_PRINTF4(_L("Test CI method failed, error: %d, expected value: %d, actual value: %d"), \ sl@0: err, DRMProtected, flag); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: WARN_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 CTestStepCISetDRMProtected::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: }