os/security/contentmgmt/cafstreamingsupport/test/tscaf/source/tkeystreamdecoderconstruct.cpp
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // tkeystreamdecoderconstruct.h
15 // Implements the Key Stream Decoder Construction Test Case
19 #include "tkeystreamdecoderconstruct.h"
21 #include "testprotstrdesc.h"
22 #include <caf/streaming/keystreamdecoder.h>
24 using namespace StreamAccess;
26 CScafKeyStreamDecoderConstruct::CScafKeyStreamDecoderConstruct(CScafServer& aParent): CScafStep(aParent)
31 SetTestStepName(KScafKeyStreamDecoderConstruct);
34 CScafKeyStreamDecoderConstruct::~CScafKeyStreamDecoderConstruct()
41 TVerdict CScafKeyStreamDecoderConstruct::doTestL()
43 // Assume the test has failed if the test step result hasn't been otherwise set to EPass
44 SetTestStepResult(EFail);
46 //Create an SDP document object and set the created key stream field object
47 CSdpDocument* sdpDoc = CreateSdpDocumentLC();
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);
54 // Generate a protected key stream description.
57 if(iDecoderConfigurationArray[0]->iPrivateFolderPath.Length())
59 filePath = GetFullPathLC(iDecoderConfigurationArray[0]->iPrivateFolderPath, KNullDesC);
63 filePath = GetFullPathLC(KStaPrivateFolder, KNullDesC);
66 CTestProtectedStreamDesc* protectStreamDesc = CTestProtectedStreamDesc::NewL(*filePath);
67 CleanupStack::PopAndDestroy(filePath);
68 CleanupStack::PushL(protectStreamDesc);
70 // Create a key stream decoder
71 CKeyStreamDecoder* decoder = NULL;
73 TRAPD(err,decoder = CKeyStreamDecoder::NewL(*protectStreamDesc, *sdp, *sdpDoc));
75 if(decoder && (err == KErrNone))
78 INFO_PRINTF1(_L("*** SUCCESS: Key Stream Decoder Successfully Constructed ***"));
79 SetTestStepResult(EPass);
83 ERR_PRINTF1(_L("*** FAIL: Unsuccessful Construction of Key Stream Decoder ***"));
87 // Delete the protected stream descriptor
88 CleanupStack::PopAndDestroy(2, sdpDoc); //< protectStreamDesc, sdpDoc
89 return TestStepResult();