os/security/contentmgmt/cafstreamingsupport/test/tscaf/source/tmultikeystreamdecoders.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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 the License "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 // Implements the Multiple Key Stream Decoder Test Case
    15 // 
    16 //
    17 
    18 #include "tmultikeystreamdecoders.h"
    19 
    20 #include "testprotstrdesc.h"
    21 
    22 using namespace StreamAccess;
    23 
    24 CScafMultiKeyStreamDecoders::CScafMultiKeyStreamDecoders(CScafServer& aParent): CScafStep(aParent)
    25 /**
    26  * Constructor
    27  */
    28 	{
    29 	SetTestStepName(KScafMultiKeyStreamDecoders);
    30 	}
    31 
    32 CScafMultiKeyStreamDecoders::~CScafMultiKeyStreamDecoders()
    33 /**
    34  * Destructor
    35  */
    36 	{
    37 	}
    38 
    39 TVerdict CScafMultiKeyStreamDecoders::doTestStepPreambleL()
    40 	{
    41 	__UHEAP_MARK;
    42 	
    43 	// Reads the Thread ID
    44 	RThread thread;
    45 	iThreadId = thread.Id();
    46 	thread.Close();
    47 	
    48 	INFO_PRINTF3(_L("Thread %d - HEAP CELLS: %d"),iThreadId,User::CountAllocCells());
    49 	
    50 	ReadTestConfigurationL();
    51 	
    52 	return TestStepResult();
    53 	}
    54 
    55 TVerdict CScafMultiKeyStreamDecoders::doTestL()
    56 	{
    57 	// Assume the test has failed if the test step result hasn't been otherwise set to EPass
    58 	SetTestStepResult(EFail);
    59 	
    60 	// Retrieval of expected values for Key stream Decoder "A"
    61 	TExpectedKeyStreamDecoderAttributes expectedAttributesA = iExpectedKeyStreamDecoderData[0];
    62 	
    63 	// Retrieval of expected values for Key stream Decoder "B"	
    64 	TExpectedKeyStreamDecoderAttributes expectedAttributesB = iExpectedKeyStreamDecoderData[1];
    65 	
    66 	//Create an SDP document object and set the created key stream field object
    67 	CSdpDocument* sdpDoc = CreateSdpDocumentLC();
    68 	
    69 	// Generate the 2 SDP media field objects from the attributes with the INI configuration
    70 	CSdpMediaField* sdpA = CreateSdpLC(0);
    71 	AddMediaFieldL(*sdpDoc, sdpA);
    72 	CleanupStack::Pop(sdpA);
    73 	
    74 	CSdpMediaField* sdpB = CreateSdpLC(1);
    75 	AddMediaFieldL(*sdpDoc, sdpB);
    76 	CleanupStack::Pop(sdpB);
    77 	
    78 	// Generate the 2 protected key stream description objects for each of the key stream decoders. 
    79 	HBufC* filePathA;
    80 	if(iDecoderConfigurationArray[0]->iPrivateFolderPath.Length())
    81 		{
    82 		filePathA = GetFullPathLC(iDecoderConfigurationArray[0]->iPrivateFolderPath, KNullDesC);
    83 		}
    84 	else
    85 		{
    86 		filePathA = GetFullPathLC(KStaPrivateFolder, KNullDesC);
    87 		}
    88 	CTestProtectedStreamDesc* protectStreamDescA = CTestProtectedStreamDesc::NewL(*filePathA);
    89 	CleanupStack::PopAndDestroy(filePathA);
    90 	CleanupStack::PushL(protectStreamDescA);
    91 	
    92 	HBufC* filePathB;
    93 	if(iDecoderConfigurationArray[1]->iPrivateFolderPath.Length())
    94 		{
    95 		filePathB = GetFullPathLC(iDecoderConfigurationArray[1]->iPrivateFolderPath, KNullDesC);
    96 		}
    97 	else
    98 		{
    99 		filePathB = GetFullPathLC(KStaPrivateFolder, KNullDesC);
   100 		}
   101 	CTestProtectedStreamDesc* protectStreamDescB = CTestProtectedStreamDesc::NewL(*filePathB);
   102 	CleanupStack::PopAndDestroy(filePathB);
   103 	CleanupStack::PushL(protectStreamDescB);
   104 	
   105 	/* Create key stream decoder A using the generated protected key stream description
   106 	 * and SDP media description A
   107 	 */
   108 	CKeyStreamDecoder* decoderA = NULL;
   109 	
   110 	TRAPD(err,decoderA = CKeyStreamDecoder::NewL(*protectStreamDescA, *sdpA, *sdpDoc)); 
   111 	
   112 	if(!decoderA || err != KErrNone)
   113 		{
   114 		ERR_PRINTF3(_L("*** Thread %d: FAIL - Unsuccessful Construction of Key Stream Decoder A - %d ***"),iThreadId,err);
   115 		User::Leave(err);
   116 		}
   117 	
   118 	CleanupStack::PushL(decoderA);
   119 	
   120 	
   121 	/* Create key stream decoder B using the generated protected key stream description
   122 	 * and SDP media description B
   123 	 */
   124 	CKeyStreamDecoder* decoderB = NULL;
   125 	
   126 	TRAP(err,decoderB = CKeyStreamDecoder::NewL(*protectStreamDescB, *sdpB, *sdpDoc)); 
   127 	
   128 	if(!decoderB || err != KErrNone)
   129 		{
   130 		ERR_PRINTF3(_L("*** Thread %d: FAIL - Unsuccessful Construction of Key Stream Decoder B - %d ***"),iThreadId,err);
   131 		User::Leave(err);
   132 		}
   133 	
   134 	CleanupStack::PushL(decoderB);
   135 	
   136 		
   137 	/* Check that the retrieved attribute values from either key stream decoder
   138 	 * match the expected results stated within the configuration file
   139 	 */
   140 	TBool attributeCheckResult = ETrue;
   141 	
   142 	
   143 	INFO_PRINTF2(_L("Thread %d: Checking Attributes for Key Stream Decoder A..."),iThreadId);
   144 	if(!CheckKeyStreamDecoderAttributesL(*decoderA, expectedAttributesA))
   145 		{
   146 		ERR_PRINTF2(_L("*** Thread %d: FAIL - Key Stream Decoder A attributes mismatch expected values ***"),iThreadId);
   147 		attributeCheckResult = EFalse;
   148 		}
   149 	
   150 	
   151 	INFO_PRINTF2(_L("Thread %d: Checking Attributes for Key Stream Decoder B..."),iThreadId);
   152 	if(!CheckKeyStreamDecoderAttributesL(*decoderB, expectedAttributesB))
   153 		{
   154 		ERR_PRINTF2(_L("*** Thread %d: FAIL - Key Stream Decoder B attributes mismatch expected values ***"),iThreadId);
   155 		attributeCheckResult = EFalse;
   156 		}
   157 	
   158 	if(attributeCheckResult)
   159 		{
   160 		INFO_PRINTF2(_L("*** Thread %d: SUCCESS - Attributes associated with Key Stream Decoders A & B match expected values ***"),iThreadId);
   161 		SetTestStepResult(EPass);
   162 		}
   163 	
   164 	CleanupStack::PopAndDestroy(5, sdpDoc); //< decoderB, decoderA, protectStreamDescB, protectStreamDescA, sdpDoc
   165 	return TestStepResult();	
   166 	}
   167 
   168 TVerdict CScafMultiKeyStreamDecoders::doTestStepPostambleL()
   169 	{
   170 	iDecoderConfigurationArray.ResetAndDestroy();
   171 	iExpectedKeyStreamDecoderData.Close();
   172 	
   173 	INFO_PRINTF3(_L("Thread %d - HEAP CELLS: %d"),iThreadId,User::CountAllocCells());
   174 	__UHEAP_MARKEND;
   175 	
   176 	return TestStepResult();
   177 	}