os/security/contentmgmt/cafstreamingsupport/test/tscaf/source/tmultikeystreamdecoders.cpp
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Implements the Multiple Key Stream Decoder Test Case
18 #include "tmultikeystreamdecoders.h"
20 #include "testprotstrdesc.h"
22 using namespace StreamAccess;
24 CScafMultiKeyStreamDecoders::CScafMultiKeyStreamDecoders(CScafServer& aParent): CScafStep(aParent)
29 SetTestStepName(KScafMultiKeyStreamDecoders);
32 CScafMultiKeyStreamDecoders::~CScafMultiKeyStreamDecoders()
39 TVerdict CScafMultiKeyStreamDecoders::doTestStepPreambleL()
43 // Reads the Thread ID
45 iThreadId = thread.Id();
48 INFO_PRINTF3(_L("Thread %d - HEAP CELLS: %d"),iThreadId,User::CountAllocCells());
50 ReadTestConfigurationL();
52 return TestStepResult();
55 TVerdict CScafMultiKeyStreamDecoders::doTestL()
57 // Assume the test has failed if the test step result hasn't been otherwise set to EPass
58 SetTestStepResult(EFail);
60 // Retrieval of expected values for Key stream Decoder "A"
61 TExpectedKeyStreamDecoderAttributes expectedAttributesA = iExpectedKeyStreamDecoderData[0];
63 // Retrieval of expected values for Key stream Decoder "B"
64 TExpectedKeyStreamDecoderAttributes expectedAttributesB = iExpectedKeyStreamDecoderData[1];
66 //Create an SDP document object and set the created key stream field object
67 CSdpDocument* sdpDoc = CreateSdpDocumentLC();
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);
74 CSdpMediaField* sdpB = CreateSdpLC(1);
75 AddMediaFieldL(*sdpDoc, sdpB);
76 CleanupStack::Pop(sdpB);
78 // Generate the 2 protected key stream description objects for each of the key stream decoders.
80 if(iDecoderConfigurationArray[0]->iPrivateFolderPath.Length())
82 filePathA = GetFullPathLC(iDecoderConfigurationArray[0]->iPrivateFolderPath, KNullDesC);
86 filePathA = GetFullPathLC(KStaPrivateFolder, KNullDesC);
88 CTestProtectedStreamDesc* protectStreamDescA = CTestProtectedStreamDesc::NewL(*filePathA);
89 CleanupStack::PopAndDestroy(filePathA);
90 CleanupStack::PushL(protectStreamDescA);
93 if(iDecoderConfigurationArray[1]->iPrivateFolderPath.Length())
95 filePathB = GetFullPathLC(iDecoderConfigurationArray[1]->iPrivateFolderPath, KNullDesC);
99 filePathB = GetFullPathLC(KStaPrivateFolder, KNullDesC);
101 CTestProtectedStreamDesc* protectStreamDescB = CTestProtectedStreamDesc::NewL(*filePathB);
102 CleanupStack::PopAndDestroy(filePathB);
103 CleanupStack::PushL(protectStreamDescB);
105 /* Create key stream decoder A using the generated protected key stream description
106 * and SDP media description A
108 CKeyStreamDecoder* decoderA = NULL;
110 TRAPD(err,decoderA = CKeyStreamDecoder::NewL(*protectStreamDescA, *sdpA, *sdpDoc));
112 if(!decoderA || err != KErrNone)
114 ERR_PRINTF3(_L("*** Thread %d: FAIL - Unsuccessful Construction of Key Stream Decoder A - %d ***"),iThreadId,err);
118 CleanupStack::PushL(decoderA);
121 /* Create key stream decoder B using the generated protected key stream description
122 * and SDP media description B
124 CKeyStreamDecoder* decoderB = NULL;
126 TRAP(err,decoderB = CKeyStreamDecoder::NewL(*protectStreamDescB, *sdpB, *sdpDoc));
128 if(!decoderB || err != KErrNone)
130 ERR_PRINTF3(_L("*** Thread %d: FAIL - Unsuccessful Construction of Key Stream Decoder B - %d ***"),iThreadId,err);
134 CleanupStack::PushL(decoderB);
137 /* Check that the retrieved attribute values from either key stream decoder
138 * match the expected results stated within the configuration file
140 TBool attributeCheckResult = ETrue;
143 INFO_PRINTF2(_L("Thread %d: Checking Attributes for Key Stream Decoder A..."),iThreadId);
144 if(!CheckKeyStreamDecoderAttributesL(*decoderA, expectedAttributesA))
146 ERR_PRINTF2(_L("*** Thread %d: FAIL - Key Stream Decoder A attributes mismatch expected values ***"),iThreadId);
147 attributeCheckResult = EFalse;
151 INFO_PRINTF2(_L("Thread %d: Checking Attributes for Key Stream Decoder B..."),iThreadId);
152 if(!CheckKeyStreamDecoderAttributesL(*decoderB, expectedAttributesB))
154 ERR_PRINTF2(_L("*** Thread %d: FAIL - Key Stream Decoder B attributes mismatch expected values ***"),iThreadId);
155 attributeCheckResult = EFalse;
158 if(attributeCheckResult)
160 INFO_PRINTF2(_L("*** Thread %d: SUCCESS - Attributes associated with Key Stream Decoders A & B match expected values ***"),iThreadId);
161 SetTestStepResult(EPass);
164 CleanupStack::PopAndDestroy(5, sdpDoc); //< decoderB, decoderA, protectStreamDescB, protectStreamDescA, sdpDoc
165 return TestStepResult();
168 TVerdict CScafMultiKeyStreamDecoders::doTestStepPostambleL()
170 iDecoderConfigurationArray.ResetAndDestroy();
171 iExpectedKeyStreamDecoderData.Close();
173 INFO_PRINTF3(_L("Thread %d - HEAP CELLS: %d"),iThreadId,User::CountAllocCells());
176 return TestStepResult();