|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // CLASS HEADER |
|
20 #include "UT_CMusAvaCapability.h" |
|
21 |
|
22 // EXTERNAL INCLUDES |
|
23 #include <digia/eunit/eunitmacros.h> |
|
24 #include <sdpmediafield.h> |
|
25 |
|
26 |
|
27 // INTERNAL INCLUDES |
|
28 #include "sipprofile.h" |
|
29 #include "sipconnection.h" |
|
30 |
|
31 #include "musavaCapabilityExchange.h" |
|
32 #include "musavaavailabilityobserver.h" |
|
33 #include "musavaavailabilityobserverimp.h" |
|
34 #include "musavaoptionhandler.h" |
|
35 #include "musavasettingsimp.h" |
|
36 #include "musavaobserverimp.h" |
|
37 #include "musavaterminal.h" |
|
38 #include "MusAvaCapability.h" |
|
39 #include "musavacapabilitytesthelper.h" |
|
40 #include "CSipSseTestTls.h" |
|
41 #include "musavacapabilitycontext.h" |
|
42 #include "musavacapabilityqueryobserverimp.h" |
|
43 #include "mussettings.h" |
|
44 |
|
45 _LIT8( KTestTerminalId, "TestTerminalID" ); |
|
46 |
|
47 // CONSTRUCTION |
|
48 UT_CMusAvaCapability* UT_CMusAvaCapability::NewL() |
|
49 { |
|
50 UT_CMusAvaCapability* self = UT_CMusAvaCapability::NewLC(); |
|
51 CleanupStack::Pop(); |
|
52 |
|
53 return self; |
|
54 } |
|
55 |
|
56 UT_CMusAvaCapability* UT_CMusAvaCapability::NewLC() |
|
57 { |
|
58 UT_CMusAvaCapability* self = new( ELeave ) UT_CMusAvaCapability(); |
|
59 CleanupStack::PushL( self ); |
|
60 |
|
61 self->ConstructL(); |
|
62 |
|
63 return self; |
|
64 } |
|
65 |
|
66 // Destructor (virtual by CBase) |
|
67 UT_CMusAvaCapability::~UT_CMusAvaCapability() |
|
68 { |
|
69 } |
|
70 |
|
71 // Default constructor |
|
72 UT_CMusAvaCapability::UT_CMusAvaCapability() |
|
73 { |
|
74 } |
|
75 |
|
76 // Second phase construct |
|
77 void UT_CMusAvaCapability::ConstructL() |
|
78 { |
|
79 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
80 // It generates the test case table. |
|
81 CEUnitTestSuiteClass::ConstructL(); |
|
82 } |
|
83 |
|
84 // METHODS |
|
85 |
|
86 |
|
87 |
|
88 void UT_CMusAvaCapability::SetupL( ) |
|
89 { |
|
90 MSIPObserver* dummyObserver = NULL; |
|
91 CSIPProfileRegistry* dummyRegistry = NULL; |
|
92 MSIPConnectionObserver* dummyConnectionObserver = NULL; |
|
93 |
|
94 TUid uid = TUid::Uid( 1 ); |
|
95 TUint32 iapId = 32; |
|
96 |
|
97 iSIP = CSIP::NewL( uid, *dummyObserver ); |
|
98 iProfile = CSIPProfile::NewL( dummyRegistry ); |
|
99 iSIPConnection = CSIPConnection::NewL( *iSIP, |
|
100 iapId, |
|
101 *dummyConnectionObserver ); |
|
102 |
|
103 iAvailabilityObserver = CMusAvaAvailabilityObserverImp::NewL(); |
|
104 iConcreteSettings = CMusAvaSettingsImp::NewL(); |
|
105 iOptionHandler = CMusAvaOptionHandler::NewL( *iAvailabilityObserver, |
|
106 *iConcreteSettings ); |
|
107 |
|
108 iExchange = iOptionHandler->iCapabilityExchange; |
|
109 |
|
110 iCapability = iOptionHandler->iSwisCapability; |
|
111 |
|
112 CSipSseTestTls::OpenL(); |
|
113 |
|
114 } |
|
115 |
|
116 void UT_CMusAvaCapability::Teardown( ) |
|
117 { |
|
118 delete iOptionHandler; |
|
119 delete iAvailabilityObserver; |
|
120 delete iConcreteSettings; |
|
121 CSipSseTestTls::Close(); |
|
122 |
|
123 delete iSIPConnection; |
|
124 delete iProfile; |
|
125 delete iSIP; |
|
126 |
|
127 } |
|
128 |
|
129 void UT_CMusAvaCapability::UT_CMusAvaCapability_NewLL( ) |
|
130 { |
|
131 |
|
132 EUNIT_ASSERT( &iCapability->Exchange() == iExchange ); |
|
133 EUNIT_ASSERT( iCapability->Feature().DesC().Compare( KCapabilitySwisFeature ) == 0 ); |
|
134 EUNIT_ASSERT( iCapability->Enabled() ); |
|
135 iCapability->Enabled() = EFalse; |
|
136 EUNIT_ASSERT( !iCapability->Enabled() ); |
|
137 |
|
138 CSIPAcceptContactHeader* acceptContact = NULL; |
|
139 |
|
140 // create accept contact with feature tag, check if accept-contact-header has |
|
141 // feature tag defined in iCapability |
|
142 acceptContact = MusAvaCapabilityContext::AcceptContactHeaderLC( iCapability->Feature() ); |
|
143 EUNIT_ASSERT( iCapability->Supports( *acceptContact ) ); |
|
144 // check if feature tag is the "right one" |
|
145 EUNIT_ASSERT( iCapability->Feature().DesC().Compare( KCapabilitySwisFeature ) == 0 ); |
|
146 |
|
147 // remove the feature tag from accept-contact header, add test-feature-tag |
|
148 // check that iCapability does not support the test feature tag |
|
149 // check also that iCapability feature tag is the 'right one' |
|
150 acceptContact->DeleteParam( iCapability->Feature() ); |
|
151 RStringF newParam = MusAvaCapabilityContext::SIPStringL( KCapabilityTestDataFeature ); |
|
152 CleanupClosePushL( newParam ); |
|
153 acceptContact->SetParamL( newParam ); |
|
154 CleanupStack::PopAndDestroy();//newParam |
|
155 EUNIT_ASSERT( !iCapability->Supports( *acceptContact ) ); |
|
156 EUNIT_ASSERT( iCapability->Feature().DesC().Compare( KCapabilitySwisFeature ) == 0 ); |
|
157 |
|
158 CleanupStack::PopAndDestroy( acceptContact ); |
|
159 |
|
160 } |
|
161 |
|
162 void UT_CMusAvaCapability::UT_CMusAvaCapability_DoPopulateResponseLL( ) |
|
163 { |
|
164 CSIPServerTransaction* options = NULL; |
|
165 |
|
166 iCapability->Enabled() = ETrue; |
|
167 |
|
168 options = CapabilityTestHelper::OptionsRequestL( KCapabilityTestAddress_A, |
|
169 KCapabilityTestAddress_B, |
|
170 KCapabilitySwisFeature, |
|
171 KCapabilitySwisFeature, |
|
172 KCapabilityTestAcceptHeader, |
|
173 KCapabilityTestTerminalID_B ); |
|
174 CleanupStack::PushL( options ); |
|
175 |
|
176 // Test : AVC enabled => H263 & H264 |
|
177 TInt32 KMusDisableAVC = 0x0ffffff1; // some value other than disable magic value |
|
178 MultimediaSharingSettings::SetPropertyValueL(MusSettingsKeys::KEncodingDevice, |
|
179 KMusDisableAVC ); |
|
180 CSdpDocument* sdpContent = CMusAvaCapability::ResponseContentLC( *options ); |
|
181 RPointerArray<CSIPHeaderBase> responseHeaders; |
|
182 CSIPHeaderBase::PushLC( &responseHeaders ); |
|
183 |
|
184 iCapability->PopulateResponseL( *options, responseHeaders, *sdpContent ); |
|
185 |
|
186 EUNIT_ASSERT( responseHeaders.Count() == 1 ); |
|
187 EUNIT_ASSERT( sdpContent->AttributeFields().Count() == 2 ); |
|
188 EUNIT_ASSERT( sdpContent->MediaFields().Count() == 1 ); |
|
189 EUNIT_ASSERT( sdpContent->MediaFields()[0]->FormatAttributeFields().Count() == 2 ); |
|
190 CleanupStack::PopAndDestroy( &responseHeaders ); |
|
191 CleanupStack::PopAndDestroy( sdpContent ); |
|
192 |
|
193 // Test : AVC disabled => H263 |
|
194 KMusDisableAVC = 0x0fffffff; // disable magic value |
|
195 MultimediaSharingSettings::SetPropertyValueL(MusSettingsKeys::KEncodingDevice, |
|
196 KMusDisableAVC ); |
|
197 sdpContent = CMusAvaCapability::ResponseContentLC( *options ); |
|
198 CSIPHeaderBase::PushLC( &responseHeaders ); |
|
199 iCapability->PopulateResponseL( *options, responseHeaders, *sdpContent ); |
|
200 EUNIT_ASSERT( responseHeaders.Count() == 1 ); |
|
201 EUNIT_ASSERT( sdpContent->AttributeFields().Count() == 2 ); |
|
202 EUNIT_ASSERT( sdpContent->MediaFields().Count() == 1 ); |
|
203 EUNIT_ASSERT( sdpContent->MediaFields()[0]->FormatAttributeFields().Count() == 1 ); |
|
204 CleanupStack::PopAndDestroy( &responseHeaders ); |
|
205 CleanupStack::PopAndDestroy( sdpContent ); |
|
206 CleanupStack::PopAndDestroy( options ); |
|
207 |
|
208 } |
|
209 |
|
210 |
|
211 void UT_CMusAvaCapability::Setup1L() |
|
212 { |
|
213 // save operator variant setting type to be able to set it back to original value in teardown |
|
214 iOpVariantSetting = MultimediaSharingSettings::OperatorVariantSettingL(); |
|
215 iCapabQueryObserver = new ( ELeave ) CMusAvaCapabilityQueryObserverImp(); |
|
216 iExchange = CMusAvaCapabilityExchange::NewL( KTestTerminalId, *iCapabQueryObserver ); |
|
217 iCapability = CMusAvaCapability::NewL( *iExchange ); |
|
218 CSipSseTestTls::OpenL(); |
|
219 } |
|
220 |
|
221 void UT_CMusAvaCapability::Teardown1( ) |
|
222 { |
|
223 CSipSseTestTls::Close(); |
|
224 delete iCapability; |
|
225 delete iExchange; |
|
226 delete iCapabQueryObserver; |
|
227 } |
|
228 |
|
229 |
|
230 void UT_CMusAvaCapability::UT_CMusAvaCapability_SupportsL() |
|
231 { |
|
232 |
|
233 CSIPAcceptContactHeader* contactHeader = CSIPAcceptContactHeader::NewLC(); |
|
234 |
|
235 RStringF str = MusAvaCapabilityContext::SDPStringL( KCapabilitySwisFeature ); |
|
236 CleanupClosePushL( str ); |
|
237 |
|
238 contactHeader->SetParamL( str ); |
|
239 |
|
240 EUNIT_ASSERT( iCapability->Supports( *contactHeader ) ); |
|
241 |
|
242 CleanupStack::PopAndDestroy( &str ); |
|
243 CleanupStack::PopAndDestroy( contactHeader ); |
|
244 |
|
245 } |
|
246 |
|
247 |
|
248 void UT_CMusAvaCapability::UT_CMusAvaCapability_ResolveCodecsLL() |
|
249 { |
|
250 _LIT( KTest263, "H263-2000/90000"); |
|
251 _LIT( KTest264, "H264/90000"); |
|
252 |
|
253 // Find H.263 codec |
|
254 CSdpDocument* sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDP ); |
|
255 CDesCArrayFlat* codecs = iCapability->ResolveCodecsL( *sdpContent ); |
|
256 CleanupStack::PushL( codecs ); |
|
257 EUNIT_ASSERT( codecs->MdcaCount() == 1 ); |
|
258 EUNIT_ASSERT_EQUALS( (*codecs)[0], KTest263 ); |
|
259 CleanupStack::PopAndDestroy( codecs ); |
|
260 CleanupStack::PopAndDestroy( sdpContent ); |
|
261 |
|
262 // Find H.264 codec |
|
263 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDP264 ); |
|
264 codecs = iCapability->ResolveCodecsL( *sdpContent ); |
|
265 CleanupStack::PushL( codecs ); |
|
266 EUNIT_ASSERT( codecs->MdcaCount() == 1 ); |
|
267 EUNIT_ASSERT_EQUALS( (*codecs)[0], KTest264 ); |
|
268 CleanupStack::PopAndDestroy( codecs ); |
|
269 CleanupStack::PopAndDestroy( sdpContent ); |
|
270 |
|
271 // Find H.263 or H.264 codec |
|
272 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDP264And263 ); |
|
273 codecs = iCapability->ResolveCodecsL( *sdpContent ); |
|
274 CleanupStack::PushL( codecs ); |
|
275 EUNIT_ASSERT( codecs->MdcaCount() == 2 ); |
|
276 EUNIT_ASSERT_EQUALS( (*codecs)[0], KTest264 ); |
|
277 EUNIT_ASSERT_EQUALS( (*codecs)[1], KTest263 ); |
|
278 CleanupStack::PopAndDestroy( codecs ); |
|
279 CleanupStack::PopAndDestroy( sdpContent ); |
|
280 |
|
281 // Do NOT find an invalid codec |
|
282 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDPWrongCodec ); |
|
283 codecs = iCapability->ResolveCodecsL( *sdpContent ); |
|
284 CleanupStack::PushL( codecs ); |
|
285 EUNIT_ASSERT( codecs->MdcaCount() == 0 ); |
|
286 CleanupStack::PopAndDestroy( codecs ); |
|
287 CleanupStack::PopAndDestroy( sdpContent ); |
|
288 |
|
289 } |
|
290 |
|
291 void UT_CMusAvaCapability::UT_CMusAvaCapability_AttributeL() |
|
292 { |
|
293 |
|
294 CSdpDocument* sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDP ); |
|
295 |
|
296 // give an attribute which can be found |
|
297 RStringF attribute = MusAvaCapabilityContext::SDPStringL( _L8("type") ); |
|
298 CleanupClosePushL( attribute ); |
|
299 EUNIT_ASSERT( iCapability->Attribute( attribute, *sdpContent ) ); |
|
300 CleanupStack::PopAndDestroy( &attribute ); |
|
301 |
|
302 // give an attribute which can be not found |
|
303 attribute = MusAvaCapabilityContext::SDPStringL( _L8("xxx") ); |
|
304 CleanupClosePushL( attribute ); |
|
305 EUNIT_ASSERT( !iCapability->Attribute( attribute, *sdpContent ) ); |
|
306 CleanupStack::PopAndDestroy( &attribute ); |
|
307 |
|
308 CleanupStack::PopAndDestroy( sdpContent ); |
|
309 } |
|
310 |
|
311 |
|
312 void UT_CMusAvaCapability::UT_CMusAvaCapability_PopulateResponseL_OpSpecificL() |
|
313 { |
|
314 |
|
315 MultimediaSharingSettings::SetOperatorVariantSettingL( MusSettingsKeys::EOperatorSpecific ); |
|
316 iCapabQueryObserver->iCapabilitiesResolvedForCingular = ETrue; |
|
317 |
|
318 CSIPServerTransaction* options = |
|
319 CapabilityTestHelper::OptionsRequestL( KCapabilityTestAddress_A, |
|
320 KCapabilityTestAddress_B, |
|
321 KCapabilitySwisFeature, |
|
322 KCapabilitySwisFeature, |
|
323 KCapabilityTestAcceptHeader, |
|
324 KCapabilityTestTerminalID_B ); |
|
325 CleanupStack::PushL( options ); |
|
326 |
|
327 CSdpDocument* sdpContent = |
|
328 CMusAvaCapability::ResponseContentLC( *options ); |
|
329 |
|
330 RPointerArray<CSIPHeaderBase> responseHeaders; |
|
331 CSIPHeaderBase::PushLC( &responseHeaders ); |
|
332 |
|
333 iCapability->PopulateResponseL( *options, responseHeaders, *sdpContent ); |
|
334 |
|
335 EUNIT_ASSERT( responseHeaders.Count() == 1 ); |
|
336 HBufC8* headerValue = responseHeaders[0]->ToTextValueL(); |
|
337 // header value contains just one field |
|
338 EUNIT_ASSERT_EQUALS( KErrNotFound, headerValue->Find(_L8(";") ) ); |
|
339 delete headerValue; |
|
340 |
|
341 CleanupStack::PopAndDestroy( &responseHeaders ); |
|
342 CleanupStack::PopAndDestroy( sdpContent ); |
|
343 CleanupStack::PopAndDestroy( options ); |
|
344 } |
|
345 |
|
346 |
|
347 // TEST TABLE |
|
348 |
|
349 EUNIT_BEGIN_TEST_TABLE( |
|
350 UT_CMusAvaCapability, |
|
351 "CMusAvaCapability", |
|
352 "UNIT" ) |
|
353 |
|
354 EUNIT_TEST( |
|
355 "NewL - test ", |
|
356 "CMusAvaCapability", |
|
357 "NewL", |
|
358 "FUNCTIONALITY", |
|
359 SetupL, UT_CMusAvaCapability_NewLL, Teardown) |
|
360 |
|
361 EUNIT_TEST( |
|
362 "DoPopulateResponseL - test ", |
|
363 "CMusAvaCapability", |
|
364 "DoPopulateResponseL", |
|
365 "FUNCTIONALITY", |
|
366 SetupL, UT_CMusAvaCapability_DoPopulateResponseLL, Teardown) |
|
367 |
|
368 EUNIT_TEST( |
|
369 "Supports - test ", |
|
370 "CMusAvaCapability", |
|
371 "Supports", |
|
372 "FUNCTIONALITY", |
|
373 Setup1L, UT_CMusAvaCapability_SupportsL, Teardown1 ) |
|
374 |
|
375 EUNIT_TEST( |
|
376 "ResolveCodecsL - test ", |
|
377 "CMusAvaCapability", |
|
378 "ResolveCodecsL", |
|
379 "FUNCTIONALITY", |
|
380 Setup1L, UT_CMusAvaCapability_ResolveCodecsLL, Teardown1 ) |
|
381 |
|
382 EUNIT_TEST( |
|
383 "Attribute - test ", |
|
384 "CMusAvaCapability", |
|
385 "Attribute", |
|
386 "FUNCTIONALITY", |
|
387 Setup1L, UT_CMusAvaCapability_AttributeL, Teardown1 ) |
|
388 |
|
389 EUNIT_TEST( |
|
390 "PopulateResponseL Operator Specific - test ", |
|
391 "CMusAvaCapability", |
|
392 "PopulateResponseL", |
|
393 "FUNCTIONALITY", |
|
394 Setup1L, UT_CMusAvaCapability_PopulateResponseL_OpSpecificL, Teardown1 ) |
|
395 |
|
396 |
|
397 EUNIT_END_TEST_TABLE |
|
398 |
|
399 // END OF FILE |