os/security/contentmgmt/cafstreamingsupport/test/tscaf/source/tkeystreamdecoderattributes.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 Key Stream Decoder Query Attribute Test Case
    15 // 
    16 //
    17 
    18 #include "tkeystreamdecoderattributes.h"
    19 
    20 #include "testprotstrdesc.h"
    21 #include <caf/streaming/keystreamdecoder.h>
    22 
    23 using namespace StreamAccess;
    24 
    25 CScafKeyStreamDecoderAttributes::CScafKeyStreamDecoderAttributes(CScafServer& aParent) : CScafStep(aParent)
    26 /**
    27  * Constructor
    28  */
    29 	{
    30 	SetTestStepName(KScafKeyStreamDecoderAttributes);
    31 	}
    32 
    33 CScafKeyStreamDecoderAttributes::~CScafKeyStreamDecoderAttributes()
    34 /**
    35  * Destructor
    36  */
    37 	{
    38 	}
    39 
    40 TVerdict CScafKeyStreamDecoderAttributes::doTestStepPreambleL()
    41 	{
    42 	__UHEAP_MARK;
    43 	
    44 	// Reads the Thread ID
    45 	RThread thread;
    46 	iThreadId = thread.Id();
    47 	thread.Close();
    48 	
    49 	INFO_PRINTF3(_L("Thread %d - HEAP CELLS: %d"),iThreadId,User::CountAllocCells());
    50 	
    51 	ReadTestConfigurationL();
    52 	
    53 	return TestStepResult();
    54 	}
    55 
    56 TVerdict CScafKeyStreamDecoderAttributes::doTestL()
    57 	{
    58 	// Assume faliure, unless all is successful
    59 	SetTestStepResult(EFail);
    60 	
    61 	// Retrieve the expected values from the array constructed using ini configuration data
    62 	TExpectedKeyStreamDecoderAttributes expectedAttributes = iExpectedKeyStreamDecoderData[0];
    63 	
    64 	//Create an SDP document object and set the created key stream field object
    65 	CSdpDocument* sdpDoc = CreateSdpDocumentLC();
    66 	
    67 	// Create an SDP media field object from the attributes with the INI configuration section
    68 	CSdpMediaField* sdp = CreateSdpLC(0);
    69 	AddMediaFieldL(*sdpDoc, sdp);
    70 	CleanupStack::Pop(sdp);
    71 	
    72 	// Generate a protected key stream description. 
    73 	HBufC* filePath;
    74 	
    75 	if(iDecoderConfigurationArray[0]->iPrivateFolderPath.Length())
    76 		{
    77 		filePath = GetFullPathLC(iDecoderConfigurationArray[0]->iPrivateFolderPath, KNullDesC);
    78 		}
    79 	else
    80 		{
    81 		filePath = GetFullPathLC(KStaPrivateFolder, KNullDesC);
    82 		}
    83 	
    84 	CTestProtectedStreamDesc* protectStreamDesc = CTestProtectedStreamDesc::NewL(*filePath);
    85 	CleanupStack::PopAndDestroy(filePath);
    86 	CleanupStack::PushL(protectStreamDesc);
    87 	
    88 	// Create a key stream decoder
    89 	CKeyStreamDecoder* decoder = NULL;
    90 	
    91 	TRAPD(err,decoder = CKeyStreamDecoder::NewL(*protectStreamDesc, *sdp, *sdpDoc)); 
    92 	
    93 	if(!decoder || err != KErrNone)
    94 		{
    95 		ERR_PRINTF3(_L("*** Thread %d: FAIL - Unsuccessful Construction of Key Stream Decoder - %d ***"),iThreadId,err);
    96 		User::Leave(err);
    97 		}
    98 		
    99 	CleanupStack::PushL(decoder);
   100 	
   101 	if(CheckKeyStreamDecoderAttributesL(*decoder, expectedAttributes))
   102 		{
   103 		INFO_PRINTF2(_L("*** Thread %d: SUCCESS - Key Stream Decoder Attributes Match Expected Values ***"),iThreadId);
   104 		SetTestStepResult(EPass);
   105 		}
   106 	
   107 	CleanupStack::PopAndDestroy(3, sdpDoc); //< decoder, protectStreamDesc, sdpDoc
   108 	return TestStepResult();
   109 	}
   110 
   111 TVerdict CScafKeyStreamDecoderAttributes::doTestStepPostambleL()
   112 	{
   113 	iDecoderConfigurationArray.ResetAndDestroy();
   114 	iExpectedKeyStreamDecoderData.Close();
   115 	
   116 	INFO_PRINTF3(_L("Thread %d - HEAP CELLS: %d"),iThreadId,User::CountAllocCells());
   117 	__UHEAP_MARKEND;
   118 	
   119 	return TestStepResult();
   120 	}