devsound/devsoundrefplugin/tsrc/CIPlugins/src/teststepcisetdrmprotected.cpp
changeset 0 79dd3e2336a0
equal deleted inserted replaced
-1:000000000000 0:79dd3e2336a0
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <f32file.h>
       
    17 #include "teststepcisetdrmprotected.h"
       
    18 #include "cidefine.h"
       
    19 
       
    20 /*****************************************************************************/
       
    21 CTestStepCICreateSetDRMProtected::CTestStepCICreateSetDRMProtected()
       
    22 	{
       
    23 	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0080-HP");
       
    24 	}
       
    25 
       
    26 /*****************************************************************************/
       
    27 TVerdict CTestStepCICreateSetDRMProtected::DoTestStepL()
       
    28 	{
       
    29 	iTestStepResult = EFail;
       
    30 
       
    31 	INFO_PRINTF1(_L("Initializing test CI device"));
       
    32 	
       
    33 	//Initialize - with the UID of our test HwDevice
       
    34 	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
       
    35 	TUid testUID = {KUidSetDrmProtectedTestDevice};
       
    36 	#else
       
    37 	TFourCC testUID('T','0','0','4');
       
    38 	#endif
       
    39 	
       
    40 	MMMFSetDRMProtected* interface = NULL;
       
    41 	interface = static_cast<MMMFSetDRMProtected*>(InitializeAndInstantiateInterfaceL(testUID, KUidSetDRMProtected));
       
    42 
       
    43 	if (interface)
       
    44 		{
       
    45 		iTestStepResult = EPass;
       
    46 		INFO_PRINTF1(_L("Successfully retrieved the interface."));
       
    47 		}
       
    48 	else
       
    49 		{
       
    50 		iTestStepResult = EFail;
       
    51 		ERR_PRINTF1(_L("Failed to retrieve the interface"));
       
    52 		}
       
    53 
       
    54 	return iTestStepResult;
       
    55 	}
       
    56 
       
    57 /*****************************************************************************/
       
    58 CTestStepCISetDRMProtected::CTestStepCISetDRMProtected()
       
    59 	{
       
    60 	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0081-HP");
       
    61 	}
       
    62 
       
    63 /*****************************************************************************/
       
    64 TVerdict CTestStepCISetDRMProtected::DoTestStepL()
       
    65 	{
       
    66 	iTestStepResult = EFail;
       
    67 
       
    68 	INFO_PRINTF1(_L("Initializing test CI device"));
       
    69 	
       
    70 	//Initialize - with the UID of our test HwDevice
       
    71 	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
       
    72 	TUid testUID = {KUidSetDrmProtectedTestDevice};
       
    73 	#else
       
    74 	TFourCC testUID('T','0','0','4');
       
    75 	#endif
       
    76 	
       
    77 	MMMFSetDRMProtected* interface = NULL;
       
    78 	interface = static_cast<MMMFSetDRMProtected*>(InitializeAndInstantiateInterfaceL(testUID, KUidSetDRMProtected));
       
    79 
       
    80 	if (interface)
       
    81 		{
       
    82 		TBool DRMProtected = ETrue;
       
    83 		INFO_PRINTF1(_L("Calling test CI method"));
       
    84 		TInt err = interface->MmsdpMarkDataAsDRMProtected(DRMProtected);
       
    85 		TBool flag = EFalse;
       
    86 		// Reset test result in case we leave...
       
    87 		iTestStepResult = EFail;
       
    88 		DoReadFromFileL(flag);
       
    89 		if ((err == KErrNone) && (flag == DRMProtected))
       
    90 			{
       
    91 			INFO_PRINTF1(_L("Test CI method call was successful"));
       
    92 			iTestStepResult = EPass;
       
    93 			}
       
    94 		else
       
    95 			{
       
    96 			ERR_PRINTF4(_L("Test CI method failed, error: %d, expected value: %d, actual value: %d"), \
       
    97 							err, DRMProtected, flag);
       
    98 			}
       
    99 		}
       
   100 	else
       
   101 		{
       
   102 		WARN_PRINTF1(_L("Failed to retrieve the custom interface."));
       
   103 		iTestStepResult = EInconclusive;
       
   104 		}
       
   105 
       
   106 	return iTestStepResult;
       
   107 	}
       
   108 
       
   109 void CTestStepCISetDRMProtected::DoReadFromFileL(TBool& aFlag)
       
   110 	{
       
   111 	RFs fs;
       
   112 	CleanupClosePushL(fs);
       
   113 	User::LeaveIfError(fs.Connect());
       
   114 	
       
   115 	RFile file;
       
   116 	CleanupClosePushL(file);
       
   117 	
       
   118 	// File should already exist
       
   119 	User::LeaveIfError(file.Open(fs, KCITestFileName, EFileRead));
       
   120 	// Size should be 1!
       
   121 	TInt fileSize = 0;
       
   122 	User::LeaveIfError(file.Size(fileSize));
       
   123 	if (fileSize != KMaxCITestFileDataLength)
       
   124 		{
       
   125 		User::Leave(KErrCorrupt);
       
   126 		}
       
   127 	TBuf8<KMaxCITestFileDataLength> inputBuf;
       
   128 	User::LeaveIfError(file.Read(inputBuf));
       
   129 	TChar val = inputBuf[0];
       
   130 	aFlag = val.GetNumericValue();
       
   131 
       
   132 	CleanupStack::PopAndDestroy(); // file	
       
   133 
       
   134 	// It is the responsibility of this function to delete the file after use	
       
   135 	User::LeaveIfError(fs.Delete(KCITestFileName));
       
   136 
       
   137 	CleanupStack::PopAndDestroy(); // fs
       
   138 	}