|
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 Multiple Key Stream Decoder Test Case |
|
15 // |
|
16 // |
|
17 |
|
18 #include "tmultikeystreamdecoders.h" |
|
19 |
|
20 #include "testprotstrdesc.h" |
|
21 |
|
22 using namespace StreamAccess; |
|
23 |
|
24 CScafMultiKeyStreamDecoders::CScafMultiKeyStreamDecoders(CScafServer& aParent): CScafStep(aParent) |
|
25 /** |
|
26 * Constructor |
|
27 */ |
|
28 { |
|
29 SetTestStepName(KScafMultiKeyStreamDecoders); |
|
30 } |
|
31 |
|
32 CScafMultiKeyStreamDecoders::~CScafMultiKeyStreamDecoders() |
|
33 /** |
|
34 * Destructor |
|
35 */ |
|
36 { |
|
37 } |
|
38 |
|
39 TVerdict CScafMultiKeyStreamDecoders::doTestStepPreambleL() |
|
40 { |
|
41 __UHEAP_MARK; |
|
42 |
|
43 // Reads the Thread ID |
|
44 RThread thread; |
|
45 iThreadId = thread.Id(); |
|
46 thread.Close(); |
|
47 |
|
48 INFO_PRINTF3(_L("Thread %d - HEAP CELLS: %d"),iThreadId,User::CountAllocCells()); |
|
49 |
|
50 ReadTestConfigurationL(); |
|
51 |
|
52 return TestStepResult(); |
|
53 } |
|
54 |
|
55 TVerdict CScafMultiKeyStreamDecoders::doTestL() |
|
56 { |
|
57 #ifdef INTERNALLY_ENABLE_UPWARD_DEPENDENCY |
|
58 // Assume the test has failed if the test step result hasn't been otherwise set to EPass |
|
59 SetTestStepResult(EFail); |
|
60 |
|
61 // Retrieval of expected values for Key stream Decoder "A" |
|
62 TExpectedKeyStreamDecoderAttributes expectedAttributesA = iExpectedKeyStreamDecoderData[0]; |
|
63 |
|
64 // Retrieval of expected values for Key stream Decoder "B" |
|
65 TExpectedKeyStreamDecoderAttributes expectedAttributesB = iExpectedKeyStreamDecoderData[1]; |
|
66 |
|
67 //Create an SDP document object and set the created key stream field object |
|
68 CSdpDocument* sdpDoc = CreateSdpDocumentLC(); |
|
69 |
|
70 // Generate the 2 SDP media field objects from the attributes with the INI configuration |
|
71 CSdpMediaField* sdpA = CreateSdpLC(0); |
|
72 AddMediaFieldL(*sdpDoc, sdpA); |
|
73 CleanupStack::Pop(sdpA); |
|
74 |
|
75 CSdpMediaField* sdpB = CreateSdpLC(1); |
|
76 AddMediaFieldL(*sdpDoc, sdpB); |
|
77 CleanupStack::Pop(sdpB); |
|
78 |
|
79 // Generate the 2 protected key stream description objects for each of the key stream decoders. |
|
80 HBufC* filePathA; |
|
81 if(iDecoderConfigurationArray[0]->iPrivateFolderPath.Length()) |
|
82 { |
|
83 filePathA = GetFullPathLC(iDecoderConfigurationArray[0]->iPrivateFolderPath, KNullDesC); |
|
84 } |
|
85 else |
|
86 { |
|
87 filePathA = GetFullPathLC(KStaPrivateFolder, KNullDesC); |
|
88 } |
|
89 CTestProtectedStreamDesc* protectStreamDescA = CTestProtectedStreamDesc::NewL(*filePathA); |
|
90 CleanupStack::PopAndDestroy(filePathA); |
|
91 CleanupStack::PushL(protectStreamDescA); |
|
92 |
|
93 HBufC* filePathB; |
|
94 if(iDecoderConfigurationArray[1]->iPrivateFolderPath.Length()) |
|
95 { |
|
96 filePathB = GetFullPathLC(iDecoderConfigurationArray[1]->iPrivateFolderPath, KNullDesC); |
|
97 } |
|
98 else |
|
99 { |
|
100 filePathB = GetFullPathLC(KStaPrivateFolder, KNullDesC); |
|
101 } |
|
102 CTestProtectedStreamDesc* protectStreamDescB = CTestProtectedStreamDesc::NewL(*filePathB); |
|
103 CleanupStack::PopAndDestroy(filePathB); |
|
104 CleanupStack::PushL(protectStreamDescB); |
|
105 |
|
106 /* Create key stream decoder A using the generated protected key stream description |
|
107 * and SDP media description A |
|
108 */ |
|
109 CKeyStreamDecoder* decoderA = NULL; |
|
110 |
|
111 TRAPD(err,decoderA = CKeyStreamDecoder::NewL(*protectStreamDescA, *sdpA, *sdpDoc)); |
|
112 |
|
113 if(!decoderA || err != KErrNone) |
|
114 { |
|
115 ERR_PRINTF3(_L("*** Thread %d: FAIL - Unsuccessful Construction of Key Stream Decoder A - %d ***"),iThreadId,err); |
|
116 User::Leave(err); |
|
117 } |
|
118 |
|
119 CleanupStack::PushL(decoderA); |
|
120 |
|
121 |
|
122 /* Create key stream decoder B using the generated protected key stream description |
|
123 * and SDP media description B |
|
124 */ |
|
125 CKeyStreamDecoder* decoderB = NULL; |
|
126 |
|
127 TRAP(err,decoderB = CKeyStreamDecoder::NewL(*protectStreamDescB, *sdpB, *sdpDoc)); |
|
128 |
|
129 if(!decoderB || err != KErrNone) |
|
130 { |
|
131 ERR_PRINTF3(_L("*** Thread %d: FAIL - Unsuccessful Construction of Key Stream Decoder B - %d ***"),iThreadId,err); |
|
132 User::Leave(err); |
|
133 } |
|
134 |
|
135 CleanupStack::PushL(decoderB); |
|
136 |
|
137 |
|
138 /* Check that the retrieved attribute values from either key stream decoder |
|
139 * match the expected results stated within the configuration file |
|
140 */ |
|
141 TBool attributeCheckResult = ETrue; |
|
142 |
|
143 |
|
144 INFO_PRINTF2(_L("Thread %d: Checking Attributes for Key Stream Decoder A..."),iThreadId); |
|
145 if(!CheckKeyStreamDecoderAttributesL(*decoderA, expectedAttributesA)) |
|
146 { |
|
147 ERR_PRINTF2(_L("*** Thread %d: FAIL - Key Stream Decoder A attributes mismatch expected values ***"),iThreadId); |
|
148 attributeCheckResult = EFalse; |
|
149 } |
|
150 |
|
151 |
|
152 INFO_PRINTF2(_L("Thread %d: Checking Attributes for Key Stream Decoder B..."),iThreadId); |
|
153 if(!CheckKeyStreamDecoderAttributesL(*decoderB, expectedAttributesB)) |
|
154 { |
|
155 ERR_PRINTF2(_L("*** Thread %d: FAIL - Key Stream Decoder B attributes mismatch expected values ***"),iThreadId); |
|
156 attributeCheckResult = EFalse; |
|
157 } |
|
158 |
|
159 if(attributeCheckResult) |
|
160 { |
|
161 INFO_PRINTF2(_L("*** Thread %d: SUCCESS - Attributes associated with Key Stream Decoders A & B match expected values ***"),iThreadId); |
|
162 SetTestStepResult(EPass); |
|
163 } |
|
164 |
|
165 CleanupStack::PopAndDestroy(5, sdpDoc); //< decoderB, decoderA, protectStreamDescB, protectStreamDescA, sdpDoc |
|
166 #endif |
|
167 return TestStepResult(); |
|
168 } |
|
169 |
|
170 TVerdict CScafMultiKeyStreamDecoders::doTestStepPostambleL() |
|
171 { |
|
172 iDecoderConfigurationArray.ResetAndDestroy(); |
|
173 iExpectedKeyStreamDecoderData.Close(); |
|
174 |
|
175 INFO_PRINTF3(_L("Thread %d - HEAP CELLS: %d"),iThreadId,User::CountAllocCells()); |
|
176 __UHEAP_MARKEND; |
|
177 |
|
178 return TestStepResult(); |
|
179 } |