os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepcisetdrmprotected.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepcisetdrmprotected.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,138 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <f32file.h>
    1.20 +#include "teststepcisetdrmprotected.h"
    1.21 +#include "cidefine.h"
    1.22 +
    1.23 +/*****************************************************************************/
    1.24 +CTestStepCICreateSetDRMProtected::CTestStepCICreateSetDRMProtected()
    1.25 +	{
    1.26 +	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0080-HP");
    1.27 +	}
    1.28 +
    1.29 +/*****************************************************************************/
    1.30 +TVerdict CTestStepCICreateSetDRMProtected::DoTestStepL()
    1.31 +	{
    1.32 +	iTestStepResult = EFail;
    1.33 +
    1.34 +	INFO_PRINTF1(_L("Initializing test CI device"));
    1.35 +	
    1.36 +	//Initialize - with the UID of our test HwDevice
    1.37 +	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
    1.38 +	TUid testUID = {KUidSetDrmProtectedTestDevice};
    1.39 +	#else
    1.40 +	TFourCC testUID('T','0','0','4');
    1.41 +	#endif
    1.42 +	
    1.43 +	MMMFSetDRMProtected* interface = NULL;
    1.44 +	interface = static_cast<MMMFSetDRMProtected*>(InitializeAndInstantiateInterfaceL(testUID, KUidSetDRMProtected));
    1.45 +
    1.46 +	if (interface)
    1.47 +		{
    1.48 +		iTestStepResult = EPass;
    1.49 +		INFO_PRINTF1(_L("Successfully retrieved the interface."));
    1.50 +		}
    1.51 +	else
    1.52 +		{
    1.53 +		iTestStepResult = EFail;
    1.54 +		ERR_PRINTF1(_L("Failed to retrieve the interface"));
    1.55 +		}
    1.56 +
    1.57 +	return iTestStepResult;
    1.58 +	}
    1.59 +
    1.60 +/*****************************************************************************/
    1.61 +CTestStepCISetDRMProtected::CTestStepCISetDRMProtected()
    1.62 +	{
    1.63 +	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0081-HP");
    1.64 +	}
    1.65 +
    1.66 +/*****************************************************************************/
    1.67 +TVerdict CTestStepCISetDRMProtected::DoTestStepL()
    1.68 +	{
    1.69 +	iTestStepResult = EFail;
    1.70 +
    1.71 +	INFO_PRINTF1(_L("Initializing test CI device"));
    1.72 +	
    1.73 +	//Initialize - with the UID of our test HwDevice
    1.74 +	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
    1.75 +	TUid testUID = {KUidSetDrmProtectedTestDevice};
    1.76 +	#else
    1.77 +	TFourCC testUID('T','0','0','4');
    1.78 +	#endif
    1.79 +	
    1.80 +	MMMFSetDRMProtected* interface = NULL;
    1.81 +	interface = static_cast<MMMFSetDRMProtected*>(InitializeAndInstantiateInterfaceL(testUID, KUidSetDRMProtected));
    1.82 +
    1.83 +	if (interface)
    1.84 +		{
    1.85 +		TBool DRMProtected = ETrue;
    1.86 +		INFO_PRINTF1(_L("Calling test CI method"));
    1.87 +		TInt err = interface->MmsdpMarkDataAsDRMProtected(DRMProtected);
    1.88 +		TBool flag = EFalse;
    1.89 +		// Reset test result in case we leave...
    1.90 +		iTestStepResult = EFail;
    1.91 +		DoReadFromFileL(flag);
    1.92 +		if ((err == KErrNone) && (flag == DRMProtected))
    1.93 +			{
    1.94 +			INFO_PRINTF1(_L("Test CI method call was successful"));
    1.95 +			iTestStepResult = EPass;
    1.96 +			}
    1.97 +		else
    1.98 +			{
    1.99 +			ERR_PRINTF4(_L("Test CI method failed, error: %d, expected value: %d, actual value: %d"), \
   1.100 +							err, DRMProtected, flag);
   1.101 +			}
   1.102 +		}
   1.103 +	else
   1.104 +		{
   1.105 +		WARN_PRINTF1(_L("Failed to retrieve the custom interface."));
   1.106 +		iTestStepResult = EInconclusive;
   1.107 +		}
   1.108 +
   1.109 +	return iTestStepResult;
   1.110 +	}
   1.111 +
   1.112 +void CTestStepCISetDRMProtected::DoReadFromFileL(TBool& aFlag)
   1.113 +	{
   1.114 +	RFs fs;
   1.115 +	CleanupClosePushL(fs);
   1.116 +	User::LeaveIfError(fs.Connect());
   1.117 +	
   1.118 +	RFile file;
   1.119 +	CleanupClosePushL(file);
   1.120 +	
   1.121 +	// File should already exist
   1.122 +	User::LeaveIfError(file.Open(fs, KCITestFileName, EFileRead));
   1.123 +	// Size should be 1!
   1.124 +	TInt fileSize = 0;
   1.125 +	User::LeaveIfError(file.Size(fileSize));
   1.126 +	if (fileSize != KMaxCITestFileDataLength)
   1.127 +		{
   1.128 +		User::Leave(KErrCorrupt);
   1.129 +		}
   1.130 +	TBuf8<KMaxCITestFileDataLength> inputBuf;
   1.131 +	User::LeaveIfError(file.Read(inputBuf));
   1.132 +	TChar val = inputBuf[0];
   1.133 +	aFlag = val.GetNumericValue();
   1.134 +
   1.135 +	CleanupStack::PopAndDestroy(); // file	
   1.136 +
   1.137 +	// It is the responsibility of this function to delete the file after use	
   1.138 +	User::LeaveIfError(fs.Delete(KCITestFileName));
   1.139 +
   1.140 +	CleanupStack::PopAndDestroy(); // fs
   1.141 +	}