os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepcisetdrmprotected.cpp
Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include "teststepcisetdrmprotected.h"
20 /*****************************************************************************/
21 CTestStepCICreateSetDRMProtected::CTestStepCICreateSetDRMProtected()
23 iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0080-HP");
26 /*****************************************************************************/
27 TVerdict CTestStepCICreateSetDRMProtected::DoTestStepL()
29 iTestStepResult = EFail;
31 INFO_PRINTF1(_L("Initializing test CI device"));
33 //Initialize - with the UID of our test HwDevice
34 #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
35 TUid testUID = {KUidSetDrmProtectedTestDevice};
37 TFourCC testUID('T','0','0','4');
40 MMMFSetDRMProtected* interface = NULL;
41 interface = static_cast<MMMFSetDRMProtected*>(InitializeAndInstantiateInterfaceL(testUID, KUidSetDRMProtected));
45 iTestStepResult = EPass;
46 INFO_PRINTF1(_L("Successfully retrieved the interface."));
50 iTestStepResult = EFail;
51 ERR_PRINTF1(_L("Failed to retrieve the interface"));
54 return iTestStepResult;
57 /*****************************************************************************/
58 CTestStepCISetDRMProtected::CTestStepCISetDRMProtected()
60 iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0081-HP");
63 /*****************************************************************************/
64 TVerdict CTestStepCISetDRMProtected::DoTestStepL()
66 iTestStepResult = EFail;
68 INFO_PRINTF1(_L("Initializing test CI device"));
70 //Initialize - with the UID of our test HwDevice
71 #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
72 TUid testUID = {KUidSetDrmProtectedTestDevice};
74 TFourCC testUID('T','0','0','4');
77 MMMFSetDRMProtected* interface = NULL;
78 interface = static_cast<MMMFSetDRMProtected*>(InitializeAndInstantiateInterfaceL(testUID, KUidSetDRMProtected));
82 TBool DRMProtected = ETrue;
83 INFO_PRINTF1(_L("Calling test CI method"));
84 TInt err = interface->MmsdpMarkDataAsDRMProtected(DRMProtected);
86 // Reset test result in case we leave...
87 iTestStepResult = EFail;
88 DoReadFromFileL(flag);
89 if ((err == KErrNone) && (flag == DRMProtected))
91 INFO_PRINTF1(_L("Test CI method call was successful"));
92 iTestStepResult = EPass;
96 ERR_PRINTF4(_L("Test CI method failed, error: %d, expected value: %d, actual value: %d"), \
97 err, DRMProtected, flag);
102 WARN_PRINTF1(_L("Failed to retrieve the custom interface."));
103 iTestStepResult = EInconclusive;
106 return iTestStepResult;
109 void CTestStepCISetDRMProtected::DoReadFromFileL(TBool& aFlag)
112 CleanupClosePushL(fs);
113 User::LeaveIfError(fs.Connect());
116 CleanupClosePushL(file);
118 // File should already exist
119 User::LeaveIfError(file.Open(fs, KCITestFileName, EFileRead));
122 User::LeaveIfError(file.Size(fileSize));
123 if (fileSize != KMaxCITestFileDataLength)
125 User::Leave(KErrCorrupt);
127 TBuf8<KMaxCITestFileDataLength> inputBuf;
128 User::LeaveIfError(file.Read(inputBuf));
129 TChar val = inputBuf[0];
130 aFlag = val.GetNumericValue();
132 CleanupStack::PopAndDestroy(); // file
134 // It is the responsibility of this function to delete the file after use
135 User::LeaveIfError(fs.Delete(KCITestFileName));
137 CleanupStack::PopAndDestroy(); // fs