os/security/contentmgmt/cafstreamingsupport/test/tscaf/source/tkeystreamdecoderconstruct.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 // tkeystreamdecoderconstruct.h
    15 // Implements the Key Stream Decoder Construction Test Case
    16 // 
    17 //
    18 
    19 #include "tkeystreamdecoderconstruct.h"
    20 
    21 #include "testprotstrdesc.h"
    22 #include <caf/streaming/keystreamdecoder.h>
    23 
    24 using namespace StreamAccess;
    25 
    26 CScafKeyStreamDecoderConstruct::CScafKeyStreamDecoderConstruct(CScafServer& aParent): CScafStep(aParent)
    27 /**
    28  * Constructor
    29  */
    30 	{
    31 	SetTestStepName(KScafKeyStreamDecoderConstruct);
    32 	}
    33 
    34 CScafKeyStreamDecoderConstruct::~CScafKeyStreamDecoderConstruct()
    35 /**
    36  * Destructor
    37  */
    38 	{
    39 	}
    40 
    41 TVerdict CScafKeyStreamDecoderConstruct::doTestL()
    42 	{
    43 	// Assume the test has failed if the test step result hasn't been otherwise set to EPass
    44 	SetTestStepResult(EFail);
    45 	
    46 	//Create an SDP document object and set the created key stream field object
    47 	CSdpDocument* sdpDoc = CreateSdpDocumentLC();
    48 	
    49 	// Create an SDP media field object from the attributes with the INI configuration section
    50 	CSdpMediaField* sdp = CreateSdpLC(0);
    51 	AddMediaFieldL(*sdpDoc, sdp);
    52 	CleanupStack::Pop(sdp);
    53 	
    54 	// Generate a protected key stream description. 
    55 	HBufC* filePath;
    56 	
    57 	if(iDecoderConfigurationArray[0]->iPrivateFolderPath.Length())
    58 		{
    59 		filePath = GetFullPathLC(iDecoderConfigurationArray[0]->iPrivateFolderPath, KNullDesC);
    60 		}
    61 	else
    62 		{
    63 		filePath = GetFullPathLC(KStaPrivateFolder, KNullDesC);
    64 		}
    65 	
    66 	CTestProtectedStreamDesc* protectStreamDesc = CTestProtectedStreamDesc::NewL(*filePath);
    67 	CleanupStack::PopAndDestroy(filePath);
    68 	CleanupStack::PushL(protectStreamDesc);
    69 	
    70 	// Create a key stream decoder
    71 	CKeyStreamDecoder* decoder = NULL;
    72 	
    73 	TRAPD(err,decoder = CKeyStreamDecoder::NewL(*protectStreamDesc, *sdp, *sdpDoc)); 
    74 	
    75 	if(decoder && (err == KErrNone))
    76 		{
    77 		delete decoder;
    78 		INFO_PRINTF1(_L("*** SUCCESS: Key Stream Decoder Successfully Constructed ***"));
    79 		SetTestStepResult(EPass);
    80 		}
    81 	else
    82 		{
    83 		ERR_PRINTF1(_L("*** FAIL: Unsuccessful Construction of Key Stream Decoder ***"));
    84 		User::Leave(err);
    85 		}
    86 	
    87 	// Delete the protected stream descriptor
    88 	CleanupStack::PopAndDestroy(2, sdpDoc);	//< protectStreamDesc, sdpDoc
    89 	return TestStepResult();
    90 	}