os/security/contentmgmt/cafstreamingsupport/test/tscaf/source/tkeystreamdecoderattributes.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 // Implements the Key Stream Decoder Query Attribute Test Case
18 #include "tkeystreamdecoderattributes.h"
20 #include "testprotstrdesc.h"
21 #include <caf/streaming/keystreamdecoder.h>
23 using namespace StreamAccess;
25 CScafKeyStreamDecoderAttributes::CScafKeyStreamDecoderAttributes(CScafServer& aParent) : CScafStep(aParent)
30 SetTestStepName(KScafKeyStreamDecoderAttributes);
33 CScafKeyStreamDecoderAttributes::~CScafKeyStreamDecoderAttributes()
40 TVerdict CScafKeyStreamDecoderAttributes::doTestStepPreambleL()
44 // Reads the Thread ID
46 iThreadId = thread.Id();
49 INFO_PRINTF3(_L("Thread %d - HEAP CELLS: %d"),iThreadId,User::CountAllocCells());
51 ReadTestConfigurationL();
53 return TestStepResult();
56 TVerdict CScafKeyStreamDecoderAttributes::doTestL()
58 // Assume faliure, unless all is successful
59 SetTestStepResult(EFail);
61 // Retrieve the expected values from the array constructed using ini configuration data
62 TExpectedKeyStreamDecoderAttributes expectedAttributes = iExpectedKeyStreamDecoderData[0];
64 //Create an SDP document object and set the created key stream field object
65 CSdpDocument* sdpDoc = CreateSdpDocumentLC();
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);
72 // Generate a protected key stream description.
75 if(iDecoderConfigurationArray[0]->iPrivateFolderPath.Length())
77 filePath = GetFullPathLC(iDecoderConfigurationArray[0]->iPrivateFolderPath, KNullDesC);
81 filePath = GetFullPathLC(KStaPrivateFolder, KNullDesC);
84 CTestProtectedStreamDesc* protectStreamDesc = CTestProtectedStreamDesc::NewL(*filePath);
85 CleanupStack::PopAndDestroy(filePath);
86 CleanupStack::PushL(protectStreamDesc);
88 // Create a key stream decoder
89 CKeyStreamDecoder* decoder = NULL;
91 TRAPD(err,decoder = CKeyStreamDecoder::NewL(*protectStreamDesc, *sdp, *sdpDoc));
93 if(!decoder || err != KErrNone)
95 ERR_PRINTF3(_L("*** Thread %d: FAIL - Unsuccessful Construction of Key Stream Decoder - %d ***"),iThreadId,err);
99 CleanupStack::PushL(decoder);
101 if(CheckKeyStreamDecoderAttributesL(*decoder, expectedAttributes))
103 INFO_PRINTF2(_L("*** Thread %d: SUCCESS - Key Stream Decoder Attributes Match Expected Values ***"),iThreadId);
104 SetTestStepResult(EPass);
107 CleanupStack::PopAndDestroy(3, sdpDoc); //< decoder, protectStreamDesc, sdpDoc
108 return TestStepResult();
111 TVerdict CScafKeyStreamDecoderAttributes::doTestStepPostambleL()
113 iDecoderConfigurationArray.ResetAndDestroy();
114 iExpectedKeyStreamDecoderData.Close();
116 INFO_PRINTF3(_L("Thread %d - HEAP CELLS: %d"),iThreadId,User::CountAllocCells());
119 return TestStepResult();