|
1 /* |
|
2 * Copyright (c) 2007 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_CMusAvaCapabilityQuery.h" |
|
21 #include "musavasettingsimp.h" |
|
22 #include "musavaobserverimp.h" |
|
23 #include "musavaavailabilityobserver.h" |
|
24 #include "musavaavailabilityobserverimp.h" |
|
25 #include "muslogger.h" |
|
26 #include "mussesseioninformationapi.h" |
|
27 |
|
28 // EXTERNAL INCLUDES |
|
29 #include <EscapeUtils.h> |
|
30 #include <digia/eunit/eunitmacros.h> |
|
31 #include <sipstrings.h> |
|
32 #include <sipstrconsts.h> |
|
33 #include <stringpool.h> |
|
34 #include <sipservertransaction.h> |
|
35 #include <siptransactionbase.h> |
|
36 #include <sdpfmtattributefield.h> |
|
37 #include <SdpMediaField.h> |
|
38 #include <SdpRtpmapValue.h> |
|
39 |
|
40 #include <e32debug.h> |
|
41 |
|
42 // INTERNAL INCLUDES |
|
43 #include "musavaoptionhandler.h" |
|
44 #include "musavacapabilitytesthelper.h" |
|
45 #include "CSipSseTestTls.h" |
|
46 #include "musavaCapabilityExchange.h" |
|
47 #include "musavacapabilitysipagent.h" |
|
48 #include "MusAvaCapabilityQuery.h" |
|
49 #include "musavaterminal.h" |
|
50 #include "sipprofile.h" |
|
51 #include "musavasharedobject.h" |
|
52 #include "mussettingskeys.h" |
|
53 #include "mussettings.h" |
|
54 #include "musavasip.h" |
|
55 #include "musavacapabilityqueryobserverimp.h" |
|
56 |
|
57 _LIT8( KRTPCapabilitySDPAttributeClockrate, "90000" ); |
|
58 _LIT8( KRTPCapabilitySDPAttributePayloadTypeH264, "98" ); |
|
59 _LIT8( KRTPCapabilitySDPAttributeCodec, "H264" ); |
|
60 |
|
61 _LIT8( KRTPCapabilitySDPAttributePayloadTypeH263, "96" ); |
|
62 _LIT8( KRTPCapabilitySDPAttributeCodecH263, "H263-2000" ); |
|
63 |
|
64 // CONSTRUCTION |
|
65 UT_CMusAvaCapabilityQuery* UT_CMusAvaCapabilityQuery::NewL() |
|
66 { |
|
67 UT_CMusAvaCapabilityQuery* self = UT_CMusAvaCapabilityQuery::NewLC(); |
|
68 CleanupStack::Pop(); |
|
69 |
|
70 return self; |
|
71 } |
|
72 |
|
73 UT_CMusAvaCapabilityQuery* UT_CMusAvaCapabilityQuery::NewLC() |
|
74 { |
|
75 UT_CMusAvaCapabilityQuery* self = new( ELeave ) UT_CMusAvaCapabilityQuery(); |
|
76 CleanupStack::PushL( self ); |
|
77 self->ConstructL(); |
|
78 |
|
79 return self; |
|
80 } |
|
81 |
|
82 // Destructor (virtual by CBase) |
|
83 UT_CMusAvaCapabilityQuery::~UT_CMusAvaCapabilityQuery() |
|
84 { |
|
85 } |
|
86 |
|
87 // Default constructor |
|
88 UT_CMusAvaCapabilityQuery::UT_CMusAvaCapabilityQuery() |
|
89 { |
|
90 } |
|
91 |
|
92 // Second phase construct |
|
93 void UT_CMusAvaCapabilityQuery::ConstructL() |
|
94 { |
|
95 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
96 // It generates the test case table. |
|
97 CEUnitTestSuiteClass::ConstructL(); |
|
98 } |
|
99 |
|
100 // METHODS |
|
101 |
|
102 void UT_CMusAvaCapabilityQuery::SetupL( ) |
|
103 { |
|
104 iSharedObject = CMusAvaSharedObject::GetSingletonL(); |
|
105 iAvailabilityObserver = CMusAvaAvailabilityObserverImp::NewL(); |
|
106 iConcreteSettings = CMusAvaSettingsImp::NewL(); |
|
107 iOptionHandler = CMusAvaOptionHandler::NewL( *iAvailabilityObserver, |
|
108 *iConcreteSettings ); |
|
109 iExchange = iOptionHandler->iCapabilityExchange; |
|
110 iSipAgent = CMusAvaCapabilitySipAgent::NewL( *iExchange, |
|
111 *iOptionHandler->iSharedObj, |
|
112 iOptionHandler->iObserver ); |
|
113 |
|
114 iCapability = iOptionHandler->iSwisCapability; |
|
115 |
|
116 MSIPConnectionObserver& connectionObserver = |
|
117 iSharedObject->MusAvaSip().ConnectionObserver(); |
|
118 |
|
119 CSIP& sip = iSharedObject->MusAvaSip().Sip(); |
|
120 iSharedObject->MusAvaSip().CreateProfileL(); |
|
121 iProfile = iSharedObject->MusAvaSip().Profile(); |
|
122 if ( !iProfile->iArray ) |
|
123 { |
|
124 iProfile->iArray = new ( ELeave ) CDesC8ArrayFlat( 1 ); |
|
125 iProfile->iArray->AppendL( _L8("sip:user@domain.com") ); |
|
126 } |
|
127 if ( !iProfile->iRegisteredContact ) |
|
128 { |
|
129 iProfile->iRegisteredContact = KRegisteredContact().AllocL(); |
|
130 } |
|
131 |
|
132 TUint32 iapId; |
|
133 TInt err = iProfile->GetParameter( KSIPAccessPointId, iapId ); |
|
134 iSIPConnection = CSIPConnection::NewL( sip, |
|
135 iapId, |
|
136 connectionObserver ); |
|
137 |
|
138 iQuery = CMusAvaCapabilityQuery::NewL( *iCapability, |
|
139 *iSIPConnection, |
|
140 *iProfile, |
|
141 KCapabilityTestSIPAddressUri_B ); |
|
142 |
|
143 CSipSseTestTls::OpenL(); |
|
144 iStorage = CSipSseTestTls::Storage(); |
|
145 iOpVariantSetting = MultimediaSharingSettings::OperatorVariantSettingL(); |
|
146 } |
|
147 |
|
148 void UT_CMusAvaCapabilityQuery::Teardown( ) |
|
149 { |
|
150 delete HelpFlags::iTestSipAddress; |
|
151 HelpFlags::iTestSipAddress = NULL; |
|
152 delete iQuery; |
|
153 CMusAvaSharedObject::DeleteSingleton(); |
|
154 if ( iStorage ) |
|
155 { |
|
156 iStorage->Clear(); |
|
157 CSipSseTestTls::Close(); |
|
158 iStorage = NULL; |
|
159 } |
|
160 |
|
161 delete iSipAgent; |
|
162 delete iOptionHandler; |
|
163 delete iConcreteSettings; |
|
164 delete iAvailabilityObserver; |
|
165 delete iSIPConnection; |
|
166 PropertyHelper::Close(); |
|
167 } |
|
168 |
|
169 void UT_CMusAvaCapabilityQuery::UT_CMusAvaCapabilityQuery_NewLL( ) |
|
170 { |
|
171 // 1.basic test and iQuery is constructed already. Check it |
|
172 EUNIT_ASSERT( iQuery ); |
|
173 |
|
174 // 2.test for sipaddress is empty,should leave |
|
175 delete iQuery; |
|
176 iQuery = NULL; // clean the previous one |
|
177 TRAPD( error, iQuery = CMusAvaCapabilityQuery::NewL( *iCapability, |
|
178 *iSIPConnection, |
|
179 *iProfile, |
|
180 KNullDesC ) ); |
|
181 EUNIT_ASSERT( error == KErrNoMemory || error == KErrArgument ); |
|
182 if ( error == KErrNoMemory ) User::Leave( error ); |
|
183 EUNIT_ASSERT( !iQuery ); // iQuery Should be empty. |
|
184 |
|
185 // 3.Contact user part tests, getting KSIPRegisteredContact leaves |
|
186 delete iProfile->iRegisteredContact; |
|
187 iProfile->iRegisteredContact = NULL; |
|
188 TRAP( error, iQuery = CMusAvaCapabilityQuery::NewL( *iCapability, |
|
189 *iSIPConnection, |
|
190 *iProfile, |
|
191 KCapabilityTestSIPAddressUri_B ) ); |
|
192 if ( error == KErrNoMemory ) User::Leave( error ); |
|
193 EUNIT_ASSERT( error == KErrNotFound ); |
|
194 EUNIT_ASSERT( !iQuery ); // iQuery Should be empty. |
|
195 |
|
196 // 4.Contact user part tests, CSIPContactHeader::DecodeL has less than 1. |
|
197 iProfile->iRegisteredContact = KRegisteredContact().AllocL(); |
|
198 HelpFlags::iEmptyContactHeader = ETrue; |
|
199 TRAP( error, iQuery = CMusAvaCapabilityQuery::NewL( *iCapability, |
|
200 *iSIPConnection, |
|
201 *iProfile, |
|
202 KCapabilityTestSIPAddressUri_B ) ); |
|
203 HelpFlags::iEmptyContactHeader = EFalse; |
|
204 if ( error == KErrNoMemory ) User::Leave( error ); |
|
205 EUNIT_ASSERT( error == KErrNotFound ); |
|
206 EUNIT_ASSERT( !iQuery ); // iQuery Should be empty. |
|
207 |
|
208 // 5.Contact user part tests ,CSIPContactHeader::DecodeL has 1 contact |
|
209 delete iQuery; |
|
210 iQuery = NULL; // clean the previous one |
|
211 delete iProfile->iRegisteredContact; |
|
212 iProfile->iRegisteredContact = NULL; |
|
213 iProfile->iRegisteredContact = KRegisteredContact().AllocL(); |
|
214 |
|
215 HelpFlags::iTestSipAddress = CSIPAddress::DecodeL( KRegisteredContact ); |
|
216 HelpFlags::iUseTestSipAddress = ETrue; |
|
217 |
|
218 TRAP( error, iQuery = CMusAvaCapabilityQuery::NewL( *iCapability, |
|
219 *iSIPConnection, |
|
220 *iProfile, |
|
221 KCapabilityTestSIPAddressUri_B ) ); |
|
222 HelpFlags::iUseTestSipAddress = EFalse; |
|
223 if ( error == KErrNoMemory ) User::Leave( error ); |
|
224 delete HelpFlags::iTestSipAddress; |
|
225 HelpFlags::iTestSipAddress = NULL; |
|
226 |
|
227 EUNIT_ASSERT( error == KErrNone ); |
|
228 EUNIT_ASSERT( iQuery ); |
|
229 |
|
230 // 6.Contact user part tests ,CSIPContactHeader::DecodeL has 1 contact but |
|
231 // sip address empty |
|
232 delete iQuery; |
|
233 iQuery = NULL; // clean the previous one |
|
234 |
|
235 delete iProfile->iRegisteredContact; |
|
236 iProfile->iRegisteredContact = NULL; |
|
237 iProfile->iRegisteredContact = KRegisteredContact().AllocL(); |
|
238 |
|
239 HelpFlags::iUseTestSipAddress = ETrue; |
|
240 TRAP(error,iQuery = CMusAvaCapabilityQuery::NewL( *iCapability, |
|
241 *iSIPConnection, |
|
242 *iProfile, |
|
243 KCapabilityTestSIPAddressUri_B )); |
|
244 HelpFlags::iUseTestSipAddress = EFalse; |
|
245 if ( error == KErrNoMemory ) User::Leave( error ); |
|
246 EUNIT_ASSERT( error == KErrNotFound ); |
|
247 EUNIT_ASSERT( !iQuery ); // iQuery Should be empty. |
|
248 |
|
249 } |
|
250 |
|
251 void UT_CMusAvaCapabilityQuery::UT_CMusAvaCapabilityQuery_ExecuteLL( ) |
|
252 { |
|
253 /* includes testing of functions: |
|
254 * Prepare(), |
|
255 * DoCompletedL() case KMUSAVASIP200 |
|
256 * DoCompleted200OKL() |
|
257 * ValidateCodecL() |
|
258 * ValidateAttributesL() |
|
259 * ValidateContactL(), |
|
260 * Retrying() |
|
261 * Capability() |
|
262 * SetState() |
|
263 * Terminal() |
|
264 * ExecuteL() |
|
265 * CompletedL() |
|
266 * State() |
|
267 * Result() |
|
268 * AddAcceptContactHeaderL() |
|
269 * AddContactHeaderL() |
|
270 * ResetAndDestroyTrx() |
|
271 * LocalAddress() |
|
272 */ |
|
273 |
|
274 EUNIT_ASSERT( iExchange->Terminals().Count() == 1 ); |
|
275 |
|
276 CMusAvaTerminal& terminal = iQuery->Terminal(); |
|
277 EUNIT_ASSERT( terminal.iQueries == 1 ); |
|
278 EUNIT_ASSERT( terminal.iQuery == NULL ); |
|
279 |
|
280 EUNIT_ASSERT( iQuery->Terminal().Uri().Compare( KCapabilityTestSIPAddressUri8_B ) == 0 ); |
|
281 |
|
282 iQuery->SetState( CMusAvaCapabilityQueryBase::ECapabilityQueryPrepared ); |
|
283 TRAPD( error, iQuery->ExecuteL() ); |
|
284 if ( error == KErrNoMemory ) User::Leave( error ); |
|
285 EUNIT_ASSERT( error != KErrNone ); |
|
286 |
|
287 iQuery->SetState( CMusAvaCapabilityQueryBase::ECapabilityQueryCreated ); |
|
288 iQuery->ExecuteL( ); |
|
289 |
|
290 EUNIT_ASSERT( iQuery->State() == |
|
291 CMusAvaCapabilityQueryBase::ECapabilityQueryExecuting ); |
|
292 EUNIT_ASSERT( !iQuery->iTimer ); |
|
293 EUNIT_ASSERT( iQuery->iTrx ); |
|
294 |
|
295 EUNIT_ASSERT( iStorage->iClientRequest->Method() == |
|
296 SIPStrings::StringF( SipStrConsts::EOptions ) ); |
|
297 EUNIT_ASSERT( iStorage->iClientRequest->MessageElements().Content().Length() |
|
298 != 0 ); |
|
299 _LIT8(contentType,"application/sdp"); |
|
300 EUNIT_ASSERT( |
|
301 iStorage->iClientRequest->MessageElements().ContentType() ); |
|
302 EUNIT_ASSERT( |
|
303 iStorage->iClientRequest->MessageElements().UserHeaders().Count() |
|
304 == 6 ); |
|
305 MUS_HEADER_ASSERT( iStorage->iClientRequest, 0, |
|
306 KCapabilityTestAcceptContactHeader ); |
|
307 MUS_HEADER_ASSERT( iStorage->iClientRequest, 5, |
|
308 KCapabilityTestContactHeader_A1Updated ); |
|
309 MUS_HEADER_ASSERT( iStorage->iClientRequest, 3, |
|
310 KCapabilityTestAcceptHeader ); |
|
311 EUNIT_ASSERT( iOptionHandler->State() == |
|
312 MMusAvaObserver::EMusAvaStatusNotExecuted ); |
|
313 |
|
314 // set response 200 OK FT |
|
315 CapabilityTestHelper::SetResponseL( *iQuery->iTrx, KMUSAVASIP200, |
|
316 SipStrConsts::EPhraseOk, |
|
317 KCapabilityTestAddress_B, |
|
318 KCapabilitySwisFeature, |
|
319 KCapabilityTestTerminalID_B, |
|
320 KPAssertedIdentity_B, |
|
321 KCapabilityTestSDP ); |
|
322 iQuery->CompletedL( *iQuery->iTrx ); |
|
323 |
|
324 MusSettingsKeys::TOperatorVariant op = MultimediaSharingSettings::OperatorVariantSettingL(); |
|
325 EUNIT_ASSERT( op == MusSettingsKeys::EStandard ); |
|
326 |
|
327 EUNIT_ASSERT( iQuery->iState == |
|
328 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
329 EUNIT_ASSERT( !iQuery->Retrying() ); |
|
330 EUNIT_ASSERT( iQuery->iTimer == NULL ); |
|
331 |
|
332 EUNIT_ASSERT( iStorage->iClientRequest->Method() == |
|
333 SIPStrings::StringF( SipStrConsts::EOptions ) ); |
|
334 |
|
335 EUNIT_ASSERT( iStorage->iClientRequest->MessageElements().Content().Length() |
|
336 > 0 ); |
|
337 EUNIT_ASSERT( iStorage->iClientRequest->MessageElements().ContentType() ); |
|
338 EUNIT_ASSERT( iStorage->iClientRequest->RemoteUri().Uri().UriDes().Compare( |
|
339 KCapabilityTestSIPAddressUri8_B ) == 0); |
|
340 EUNIT_ASSERT( iStorage->iClientRequest->MessageElements().UserHeaders(). |
|
341 Count() == 6 ); |
|
342 MUS_HEADER_ASSERT( iStorage->iClientRequest, |
|
343 0, |
|
344 KCapabilityTestAcceptContactHeader ); |
|
345 MUS_HEADER_ASSERT( iStorage->iClientRequest, |
|
346 5, |
|
347 KCapabilityTestContactHeader_A1Updated ); |
|
348 MUS_HEADER_ASSERT( iStorage->iClientRequest, 3, |
|
349 KCapabilityTestAcceptHeader ); |
|
350 EUNIT_ASSERT( iOptionHandler->State() == |
|
351 MMusAvaObserver::EMusAvaStatusAvailable ); |
|
352 |
|
353 |
|
354 iQuery->SetState( CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
355 TRAP( error, iQuery->ExecuteL() ); |
|
356 if ( error == KErrNoMemory ) User::Leave( error ); |
|
357 EUNIT_ASSERT ( error == KErrNone ); |
|
358 |
|
359 iQuery->DoRetryL(); |
|
360 TRAP( error, iQuery->ExecuteL() ); |
|
361 if ( error == KErrNoMemory ) User::Leave( error ); |
|
362 EUNIT_ASSERT ( error == KErrNone ); |
|
363 iQuery->DoRetryL(); |
|
364 |
|
365 // set TerminalId for CMusAvaCapabilityExchange, terminal Id will be added to headers |
|
366 CMusAvaCapabilityQueryObserverImp* capabQueryObserver = |
|
367 new ( ELeave ) CMusAvaCapabilityQueryObserverImp(); |
|
368 CleanupStack::PushL( capabQueryObserver ); |
|
369 CMusAvaCapabilityExchange* exchange = |
|
370 CMusAvaCapabilityExchange::NewL( |
|
371 KCapabilityTestTerminalID_A, |
|
372 *capabQueryObserver ); |
|
373 CleanupStack::PushL( exchange ); |
|
374 CMusAvaCapability* capability = CMusAvaCapability::NewL( *exchange ); |
|
375 CleanupStack::PushL( capability ); |
|
376 |
|
377 CMusAvaCapabilityQuery* query = CMusAvaCapabilityQuery::NewL( *capability, |
|
378 *iSIPConnection, |
|
379 *iProfile, |
|
380 KCapabilityTestSIPAddressUri_B ); |
|
381 CleanupStack::PushL( query ); |
|
382 |
|
383 query->SetState( CMusAvaCapabilityQueryBase::ECapabilityQueryCreated ); |
|
384 query->ExecuteL(); |
|
385 EUNIT_ASSERT_EQUALS( iStorage->iClientRequest->MessageElements().UserHeaders().Count(), 7 ); |
|
386 MUS_HEADER_ASSERT( iStorage->iClientRequest, 6, |
|
387 KCapabilityTestUserAgent_A ); |
|
388 |
|
389 CleanupStack::PopAndDestroy( query ); |
|
390 CleanupStack::PopAndDestroy( capability ); |
|
391 CleanupStack::PopAndDestroy( exchange ); |
|
392 CleanupStack::PopAndDestroy( capabQueryObserver ); |
|
393 } |
|
394 |
|
395 void UT_CMusAvaCapabilityQuery::UT_CMusAvaCapabilityQuery_CanceledL( ) |
|
396 { |
|
397 |
|
398 iQuery->ExecuteL( ); |
|
399 |
|
400 |
|
401 EUNIT_ASSERT( iQuery->State() == |
|
402 CMusAvaCapabilityQueryBase::ECapabilityQueryExecuting ); |
|
403 |
|
404 // set response 200 OK FT |
|
405 CapabilityTestHelper::SetResponseL( *iQuery->iTrx, |
|
406 KMUSAVASIP200, |
|
407 SipStrConsts::EPhraseOk, |
|
408 KCapabilityTestAddress_B, |
|
409 KCapabilitySwisFeature, |
|
410 KCapabilityTestTerminalID_B, |
|
411 KPAssertedIdentity_B, |
|
412 KCapabilityTestSDP ); |
|
413 |
|
414 iQuery->Canceled( *iQuery->iTrx ); |
|
415 EUNIT_ASSERT( iQuery->State() == |
|
416 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
417 EUNIT_ASSERT( iQuery->Result() == KCapabilityCapabilitesNotFound ); |
|
418 EUNIT_ASSERT( iOptionHandler->State() == |
|
419 MMusAvaObserver::EMusAvaOptionNotAvailable ); |
|
420 |
|
421 |
|
422 // give different response than iTrx |
|
423 iQuery->SetState( CMusAvaCapabilityQueryBase::ECapabilityQueryCreated ); |
|
424 iQuery->ExecuteL(); |
|
425 CSIPClientTransaction* cliTransaction = NULL; |
|
426 cliTransaction = CSIPClientTransaction::NewL( iQuery->iTrx->Type() ); |
|
427 CleanupStack::PushL( cliTransaction ); |
|
428 |
|
429 CapabilityTestHelper::SetResponseL( *cliTransaction, |
|
430 KMUSAVASIPForbidden, |
|
431 SipStrConsts::EPhraseOk, |
|
432 KCapabilityTestAddress_B, |
|
433 KCapabilitySwisFeature, |
|
434 KCapabilityTestTerminalID_B, |
|
435 KPAssertedIdentity_B, |
|
436 KCapabilityTestSDP ); |
|
437 iQuery->Canceled( *cliTransaction ); |
|
438 EUNIT_ASSERT_NOT_EQUALS( iQuery->State(), CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
439 iQuery->ResetAndDestroyTrx(); |
|
440 iQuery->Canceled( *cliTransaction ); |
|
441 EUNIT_ASSERT_NOT_EQUALS( iQuery->State(), CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
442 CleanupStack::PopAndDestroy( cliTransaction ); |
|
443 } |
|
444 |
|
445 void UT_CMusAvaCapabilityQuery::UT_CMusAvaCapabilityQuery_CompletedLL( ) |
|
446 { |
|
447 TRAPD( error, RProperty::Define( |
|
448 NMusSessionInformationApi::KCategoryUid, |
|
449 NMusSessionInformationApi::KMUSForbidden, |
|
450 RProperty::EInt, |
|
451 0 ) ); |
|
452 if ( error == KErrNoMemory ) User::Leave( error ); |
|
453 EUNIT_ASSERT ( error == KErrNone ); |
|
454 |
|
455 TRAP( error, RProperty::Set( |
|
456 NMusSessionInformationApi::KCategoryUid, |
|
457 NMusSessionInformationApi::KMUSForbidden, |
|
458 ( TInt ) NMusSessionInformationApi::EMUSAllowed ) ); |
|
459 if ( error == KErrNoMemory ) User::Leave( error ); |
|
460 EUNIT_ASSERT ( error == KErrNone ); |
|
461 |
|
462 // Test for forbidden response (403) |
|
463 |
|
464 //Cingular specific case && 403 Forbidden |
|
465 MultimediaSharingSettings::SetOperatorVariantSettingL( |
|
466 MusSettingsKeys::EOperatorSpecific ); |
|
467 iQuery->ExecuteL( ); |
|
468 |
|
469 EUNIT_ASSERT( iQuery->State() == |
|
470 CMusAvaCapabilityQueryBase::ECapabilityQueryExecuting ); |
|
471 |
|
472 // set response 200 OK FT |
|
473 CapabilityTestHelper::SetResponseL( *iQuery->iTrx, |
|
474 KMUSAVASIPForbidden, |
|
475 SipStrConsts::EPhraseOk, |
|
476 KCapabilityTestAddress_B, |
|
477 KCapabilitySwisFeature, |
|
478 KCapabilityTestTerminalID_B, |
|
479 KPAssertedIdentity_B, |
|
480 KCapabilityTestSDP ); |
|
481 |
|
482 iQuery->CompletedL( *iQuery->iTrx ); |
|
483 EUNIT_ASSERT( iQuery->State() == |
|
484 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
485 EUNIT_ASSERT( iQuery->Result() == KCapabilityCapabilitiesForbidden ); |
|
486 EUNIT_ASSERT( iOptionHandler->State() == |
|
487 MMusAvaObserver::EMusAvaFailureCode ); |
|
488 // check if it is "forbidden" |
|
489 TInt forbidden; |
|
490 TRAP( error, RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
491 NMusSessionInformationApi::KMUSForbidden, |
|
492 forbidden ) ); |
|
493 if ( error == KErrNoMemory ) User::Leave( error ); |
|
494 EUNIT_ASSERT ( error == KErrNone ); |
|
495 |
|
496 EUNIT_ASSERT_EQUALS( NMusSessionInformationApi::EMUSForbidden, forbidden ); |
|
497 // set back the forbidden flag to allowed |
|
498 TRAP( error, RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
499 NMusSessionInformationApi::KMUSForbidden, |
|
500 ( TInt ) NMusSessionInformationApi::EMUSAllowed ) ); |
|
501 if ( error == KErrNoMemory ) User::Leave( error ); |
|
502 EUNIT_ASSERT ( error == KErrNone ); |
|
503 |
|
504 MultimediaSharingSettings::SetOperatorVariantSettingL( |
|
505 MusSettingsKeys::EStandard ); |
|
506 |
|
507 // give different response than iTrx |
|
508 iQuery->SetState( CMusAvaCapabilityQueryBase::ECapabilityQueryCreated ); |
|
509 iQuery->ExecuteL( ); |
|
510 CSIPClientTransaction* cliTransaction = NULL; |
|
511 cliTransaction = CSIPClientTransaction::NewL( iQuery->iTrx->Type() ); |
|
512 CleanupStack::PushL( cliTransaction ); |
|
513 |
|
514 CapabilityTestHelper::SetResponseL( *cliTransaction, |
|
515 KMUSAVASIPForbidden, |
|
516 SipStrConsts::EPhraseOk, |
|
517 KCapabilityTestAddress_B, |
|
518 KCapabilitySwisFeature, |
|
519 KCapabilityTestTerminalID_B, |
|
520 KPAssertedIdentity_B, |
|
521 KCapabilityTestSDP ); |
|
522 iQuery->CompletedL( *cliTransaction ); |
|
523 EUNIT_ASSERT_NOT_EQUALS( iQuery->State(), CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
524 iQuery->ResetAndDestroyTrx(); |
|
525 iQuery->CompletedL( *cliTransaction ); |
|
526 EUNIT_ASSERT_NOT_EQUALS( iQuery->State(), CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
527 CleanupStack::PopAndDestroy( cliTransaction ); |
|
528 |
|
529 // set response 199 |
|
530 iQuery->SetState( CMusAvaCapabilityQueryBase::ECapabilityQueryCreated ); |
|
531 iQuery->ExecuteL( ); |
|
532 CapabilityTestHelper::SetResponseL( *iQuery->iTrx, |
|
533 KMUSAVASIP200-1, |
|
534 SipStrConsts::EPhraseOk, |
|
535 KCapabilityTestAddress_B, |
|
536 KCapabilitySwisFeature, |
|
537 KCapabilityTestTerminalID_B, |
|
538 KPAssertedIdentity_B, |
|
539 KCapabilityTestSDP ); |
|
540 |
|
541 |
|
542 iQuery->CompletedL( *iQuery->iTrx ); |
|
543 EUNIT_ASSERT_NOT_EQUALS( iQuery->State(), CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
544 iQuery->ResetAndDestroyTrx(); |
|
545 |
|
546 // set response <100 |
|
547 iQuery->SetState( CMusAvaCapabilityQueryBase::ECapabilityQueryCreated ); |
|
548 iQuery->ExecuteL( ); |
|
549 CapabilityTestHelper::SetResponseL( *iQuery->iTrx, |
|
550 KMUSAVASIP200-150, |
|
551 SipStrConsts::EPhraseOk, |
|
552 KCapabilityTestAddress_B, |
|
553 KCapabilitySwisFeature, |
|
554 KCapabilityTestTerminalID_B, |
|
555 KPAssertedIdentity_B, |
|
556 KCapabilityTestSDP ); |
|
557 iQuery->CompletedL( *iQuery->iTrx ); |
|
558 EUNIT_ASSERT_EQUALS( iQuery->State(), CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
559 } |
|
560 |
|
561 void UT_CMusAvaCapabilityQuery::UT_CMusAvaCapabilityQuery_CompletedL1L( ) |
|
562 { |
|
563 //Standard case && 403 Forbidden |
|
564 iQuery->ExecuteL( ); |
|
565 |
|
566 EUNIT_ASSERT( iQuery->State() == |
|
567 CMusAvaCapabilityQueryBase::ECapabilityQueryExecuting ); |
|
568 |
|
569 // set response 200 OK FT |
|
570 CapabilityTestHelper::SetResponseL( *iQuery->iTrx, |
|
571 KMUSAVASIPForbidden, |
|
572 SipStrConsts::EPhraseOk, |
|
573 KCapabilityTestAddress_B, |
|
574 KCapabilitySwisFeature, |
|
575 KCapabilityTestTerminalID_B, |
|
576 KPAssertedIdentity_B, |
|
577 KCapabilityTestSDP ); |
|
578 |
|
579 iQuery->CompletedL( *iQuery->iTrx ); |
|
580 EUNIT_ASSERT( iQuery->State() == |
|
581 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
582 EUNIT_ASSERT( iQuery->Result() == KCapabilityCapabilitesNotFound ); |
|
583 EUNIT_ASSERT( iOptionHandler->State() == |
|
584 MMusAvaObserver::EMusAvaOptionNotAvailable ); |
|
585 |
|
586 } |
|
587 |
|
588 void UT_CMusAvaCapabilityQuery::UT_CMusAvaCapabilityQuery_CompletedL2L( ) |
|
589 { |
|
590 //Standard case |
|
591 iQuery->ExecuteL( ); |
|
592 |
|
593 EUNIT_ASSERT( iQuery->State() == |
|
594 CMusAvaCapabilityQueryBase::ECapabilityQueryExecuting ); |
|
595 |
|
596 // set response 200 OK FT |
|
597 CapabilityTestHelper::SetResponse2L( *iQuery->iTrx, |
|
598 KMUSAVASIP200, |
|
599 SipStrConsts::EPhraseOk, |
|
600 KCapabilityTestAddress_B, |
|
601 KCapabilitySwisFeature, |
|
602 KCapabilityTestTerminalID_B, |
|
603 KPAssertedIdentity_B, |
|
604 KPAssertedIdentity_B1, |
|
605 KCapabilityTestSDP ); |
|
606 |
|
607 iQuery->CompletedL( *iQuery->iTrx ); |
|
608 EUNIT_ASSERT( iQuery->State() == |
|
609 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
610 EUNIT_ASSERT( iQuery->Result() == KCapabilityCapabilitesReady ); |
|
611 EUNIT_ASSERT( iOptionHandler->State() == |
|
612 MMusAvaObserver::EMusAvaStatusAvailable ); |
|
613 const MDesCArray& sipAddresses = iOptionHandler->iSettings.SipAddresses(); |
|
614 EUNIT_ASSERT( sipAddresses.MdcaCount() == 1); |
|
615 EUNIT_ASSERT( sipAddresses.MdcaPoint( 0 ).Compare( KPAssertedIdentity_B_16() ) |
|
616 == KErrNone ); |
|
617 } |
|
618 |
|
619 void UT_CMusAvaCapabilityQuery::UT_CMusAvaCapabilityQuery_ValidateAndStoreCodecsLL() |
|
620 { |
|
621 |
|
622 // OK - H.263 codec |
|
623 TBool ret = EFalse; |
|
624 CSdpDocument* sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDP ); |
|
625 TRAPD( error, ret = iQuery->ValidateAndStoreCodecsL( *sdpContent ) ); |
|
626 if ( error == KErrNoMemory ) User::Leave( error ); |
|
627 EUNIT_ASSERT( ret ); |
|
628 CleanupStack::PopAndDestroy( sdpContent ); |
|
629 |
|
630 // OK - H.264 codec |
|
631 ret = EFalse; |
|
632 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDP264 ); |
|
633 TRAP( error, ret = iQuery->ValidateAndStoreCodecsL( *sdpContent ) ); |
|
634 if ( error == KErrNoMemory ) User::Leave( error ); |
|
635 EUNIT_ASSERT( ret ); |
|
636 CleanupStack::PopAndDestroy( sdpContent ); |
|
637 |
|
638 // OK - both H.263 and H.264 codec |
|
639 ret = EFalse; |
|
640 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDP264And263 ); |
|
641 TRAP( error, ret = iQuery->ValidateAndStoreCodecsL( *sdpContent ) ); |
|
642 if ( error == KErrNoMemory ) User::Leave( error ); |
|
643 EUNIT_ASSERT( ret ); |
|
644 CleanupStack::PopAndDestroy( sdpContent ); |
|
645 |
|
646 // NOK - invalid codec |
|
647 ret = ETrue; |
|
648 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDPWrongCodec ); |
|
649 TRAP( error, ret = iQuery->ValidateAndStoreCodecsL( *sdpContent ) ); |
|
650 if ( error == KErrNoMemory ) User::Leave( error ); |
|
651 EUNIT_ASSERT( !ret ); |
|
652 CleanupStack::PopAndDestroy( sdpContent ); |
|
653 } |
|
654 |
|
655 void UT_CMusAvaCapabilityQuery::UT_CMusAvaCapabilityQuery_ValidateAttributesLL() |
|
656 { |
|
657 |
|
658 // set operator specific |
|
659 MultimediaSharingSettings::SetOperatorVariantSettingL( MusSettingsKeys::EOperatorSpecific ); |
|
660 |
|
661 // operator specific OK |
|
662 CSdpDocument* sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDP ); |
|
663 TBool ret = EFalse; |
|
664 TRAPD( error, ret = iQuery->ValidateAttributesL( *sdpContent ) ); |
|
665 if ( error == KErrNoMemory ) User::Leave( error ); |
|
666 EUNIT_ASSERT( ret ); |
|
667 CleanupStack::PopAndDestroy( sdpContent ); |
|
668 |
|
669 // operator specific no application |
|
670 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDPNoApplication ); |
|
671 TRAP( error, ret = iQuery->ValidateAttributesL( *sdpContent ) ); |
|
672 if ( error == KErrNoMemory ) User::Leave( error ); |
|
673 EUNIT_ASSERT( !ret ); |
|
674 CleanupStack::PopAndDestroy( sdpContent ); |
|
675 |
|
676 // operator specific wrong application |
|
677 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDPWrongApplication ); |
|
678 TRAP( error, ret = iQuery->ValidateAttributesL( *sdpContent ) ); |
|
679 if ( error == KErrNoMemory ) User::Leave( error ); |
|
680 EUNIT_ASSERT( !ret ); |
|
681 CleanupStack::PopAndDestroy( sdpContent ); |
|
682 |
|
683 // operator specific no type |
|
684 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDPNoType ); |
|
685 TRAP( error, ret = iQuery->ValidateAttributesL( *sdpContent ) ); |
|
686 if ( error == KErrNoMemory ) User::Leave( error ); |
|
687 EUNIT_ASSERT( !ret ); |
|
688 CleanupStack::PopAndDestroy( sdpContent ); |
|
689 |
|
690 // operator specific wrong type |
|
691 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDPWrongType ); |
|
692 TRAP( error, ret = iQuery->ValidateAttributesL( *sdpContent ) ); |
|
693 if ( error == KErrNoMemory ) User::Leave( error ); |
|
694 EUNIT_ASSERT( !ret ); |
|
695 CleanupStack::PopAndDestroy( sdpContent ); |
|
696 |
|
697 // set standard |
|
698 MultimediaSharingSettings::SetOperatorVariantSettingL( MusSettingsKeys::EStandard ); |
|
699 |
|
700 // OK |
|
701 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDP ); |
|
702 TRAP( error, ret = iQuery->ValidateAttributesL( *sdpContent ) ); |
|
703 if ( error == KErrNoMemory ) User::Leave( error ); |
|
704 EUNIT_ASSERT( ret ); |
|
705 CleanupStack::PopAndDestroy( sdpContent ); |
|
706 |
|
707 // no application, good type |
|
708 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDPNoApplication ); |
|
709 TRAP( error, ret = iQuery->ValidateAttributesL( *sdpContent ) ); |
|
710 if ( error == KErrNoMemory ) User::Leave( error ); |
|
711 EUNIT_ASSERT( ret ); |
|
712 CleanupStack::PopAndDestroy( sdpContent ); |
|
713 |
|
714 // wrong application, good type |
|
715 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDPWrongApplication ); |
|
716 TRAP( error, ret = iQuery->ValidateAttributesL( *sdpContent ) ); |
|
717 if ( error == KErrNoMemory ) User::Leave( error ); |
|
718 EUNIT_ASSERT( ret ); |
|
719 CleanupStack::PopAndDestroy( sdpContent ); |
|
720 |
|
721 // no type, good application |
|
722 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDPNoType ); |
|
723 TRAP( error, ret = iQuery->ValidateAttributesL( *sdpContent ) ); |
|
724 if ( error == KErrNoMemory ) User::Leave( error ); |
|
725 EUNIT_ASSERT( ret ); |
|
726 CleanupStack::PopAndDestroy( sdpContent ); |
|
727 |
|
728 // wrong type, good application |
|
729 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDPWrongType ); |
|
730 TRAP( error, ret = iQuery->ValidateAttributesL( *sdpContent ) ); |
|
731 if ( error == KErrNoMemory ) User::Leave( error ); |
|
732 EUNIT_ASSERT( ret ); |
|
733 CleanupStack::PopAndDestroy( sdpContent ); |
|
734 |
|
735 // no application, no type |
|
736 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDPNoAppNoType ); |
|
737 TRAP( error, ret = iQuery->ValidateAttributesL( *sdpContent ) ); |
|
738 if ( error == KErrNoMemory ) User::Leave( error ); |
|
739 EUNIT_ASSERT( !ret ); |
|
740 CleanupStack::PopAndDestroy( sdpContent ); |
|
741 |
|
742 // no application, wrong type |
|
743 sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDPNoAppWrongType ); |
|
744 TRAP( error, ret = iQuery->ValidateAttributesL( *sdpContent ) ); |
|
745 if ( error == KErrNoMemory ) User::Leave( error ); |
|
746 EUNIT_ASSERT( !ret ); |
|
747 CleanupStack::PopAndDestroy( sdpContent ); |
|
748 } |
|
749 |
|
750 |
|
751 void UT_CMusAvaCapabilityQuery::UT_CMusAvaCapabilityQuery_ValidateContactLL() |
|
752 { |
|
753 |
|
754 // no contact header |
|
755 CSIPClientTransaction* optionResp = CapabilityTestHelper::OptionsResponseL( |
|
756 KMUSAVASIP200, |
|
757 SipStrConsts::EPhraseOk, |
|
758 KCapabilityTestAddress_B, |
|
759 KNullDesC8, |
|
760 KCapabilityTestTerminalID_B, |
|
761 KPAssertedIdentity_B, |
|
762 KCapabilityTestSDP ); |
|
763 CleanupStack::PushL( optionResp ); |
|
764 TBool ret = EFalse; |
|
765 TRAPD( error, ret = iQuery->ValidateContactL( *optionResp ) ); |
|
766 if ( error == KErrNoMemory ) User::Leave( error ); |
|
767 EUNIT_ASSERT( !ret ); |
|
768 CleanupStack::PopAndDestroy( optionResp ); |
|
769 |
|
770 // valid contact header |
|
771 optionResp = CapabilityTestHelper::OptionsResponseL( KMUSAVASIP200, |
|
772 SipStrConsts::EPhraseOk, |
|
773 KCapabilityTestAddress_B, |
|
774 KCapabilitySwisFeature, |
|
775 KCapabilityTestTerminalID_B, |
|
776 KPAssertedIdentity_B, |
|
777 KCapabilityTestSDP ); |
|
778 CleanupStack::PushL( optionResp ); |
|
779 |
|
780 TRAP( error, ret = iQuery->ValidateContactL( *optionResp ) ); |
|
781 if ( error == KErrNoMemory ) User::Leave( error ); |
|
782 EUNIT_ASSERT( ret ); |
|
783 CleanupStack::PopAndDestroy( optionResp ); |
|
784 |
|
785 // false contact header |
|
786 optionResp = CapabilityTestHelper::OptionsResponseL( KMUSAVASIP200, |
|
787 SipStrConsts::EPhraseOk, |
|
788 KCapabilityTestAddress_B, |
|
789 KCapabilitySwisFeatureFalse, |
|
790 KCapabilityTestTerminalID_B, |
|
791 KPAssertedIdentity_B, |
|
792 KCapabilityTestSDP ); |
|
793 CleanupStack::PushL( optionResp ); |
|
794 TRAP( error, ret = iQuery->ValidateContactL( *optionResp ) ); |
|
795 if ( error == KErrNoMemory ) User::Leave( error ); |
|
796 EUNIT_ASSERT( !ret ); |
|
797 CleanupStack::PopAndDestroy( optionResp ); |
|
798 |
|
799 // wrong contact header |
|
800 optionResp = CapabilityTestHelper::OptionsResponseL( KMUSAVASIP200, |
|
801 SipStrConsts::EPhraseOk, |
|
802 KCapabilityTestAddress_B, |
|
803 KCapabilityTestDataFeature, |
|
804 KCapabilityTestTerminalID_B, |
|
805 KPAssertedIdentity_B, |
|
806 KCapabilityTestSDP ); |
|
807 CleanupStack::PushL( optionResp ); |
|
808 TRAP( error, ret = iQuery->ValidateContactL( *optionResp ) ); |
|
809 if ( error == KErrNoMemory ) User::Leave( error ); |
|
810 EUNIT_ASSERT( !ret ); |
|
811 CleanupStack::PopAndDestroy( optionResp ); |
|
812 } |
|
813 |
|
814 |
|
815 void UT_CMusAvaCapabilityQuery::UT_CMusAvaCapabilityQuery_PrepareL() |
|
816 { |
|
817 RPointerArray<CSIPHeaderBase> headers; |
|
818 CleanupClosePushL(headers); |
|
819 |
|
820 iQuery->Prepare( headers ); |
|
821 EUNIT_ASSERT_EQUALS( iQuery->State(), CMusAvaCapabilityQueryBase::ECapabilityQueryPrepared ); |
|
822 |
|
823 iQuery->DoRetryL(); |
|
824 |
|
825 EUNIT_ASSERT_EQUALS( iQuery->State(), CMusAvaCapabilityQueryBase::ECapabilityQueryCreated ); |
|
826 iQuery->Prepare( headers ); |
|
827 EUNIT_ASSERT_EQUALS( iQuery->State(), CMusAvaCapabilityQueryBase::ECapabilityQueryCreated ); |
|
828 iQuery->DoRetryL(); |
|
829 EUNIT_ASSERT_EQUALS( iQuery->State(), CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
830 |
|
831 CleanupStack::PopAndDestroy( &headers ); |
|
832 } |
|
833 |
|
834 |
|
835 void UT_CMusAvaCapabilityQuery::UT_CMusAvaCapabilityQuery_DoCompletedLL() |
|
836 { |
|
837 |
|
838 // response elements are NULL |
|
839 CSIPClientTransaction* optionResp = NULL; |
|
840 optionResp = CapabilityTestHelper::OptionsResponseL( |
|
841 KMUSAVASIP200, |
|
842 SipStrConsts::EPhraseOk, |
|
843 KCapabilityTestAddress_B, |
|
844 KNullDesC8, |
|
845 KCapabilityTestTerminalID_B, |
|
846 KPAssertedIdentity_B, |
|
847 KCapabilityTestSDP ); |
|
848 CleanupStack::PushL( optionResp ); |
|
849 optionResp->SetResponseElements( NULL ); |
|
850 |
|
851 TRAPD( error, iQuery->DoCompletedL( *optionResp ) ); |
|
852 if ( error == KErrNoMemory ) User::Leave( error ); |
|
853 EUNIT_ASSERT( error == KErrGeneral ); |
|
854 CleanupStack::PopAndDestroy( optionResp ); |
|
855 |
|
856 // status code KMUSAVASIPNotImplemented |
|
857 optionResp = CapabilityTestHelper::OptionsResponseL( |
|
858 KMUSAVASIPNotImplemented, |
|
859 SipStrConsts::EPhraseOk, |
|
860 KCapabilityTestAddress_B, |
|
861 KNullDesC8, |
|
862 KCapabilityTestTerminalID_B, |
|
863 KPAssertedIdentity_B, |
|
864 KCapabilityTestSDP ); |
|
865 CleanupStack::PushL( optionResp ); |
|
866 iQuery->DoCompletedL( *optionResp ); |
|
867 EUNIT_ASSERT_EQUALS( iQuery->State(), CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
868 EUNIT_ASSERT_EQUALS( iQuery->Result(), KCapabilityCapabilitesReady ); |
|
869 CleanupStack::PopAndDestroy( optionResp ); |
|
870 |
|
871 // status code KMUSAVASIPTemporarilyUnavailable |
|
872 optionResp = CapabilityTestHelper::OptionsResponseL( |
|
873 KMUSAVASIPTemporarilyUnavailable, |
|
874 SipStrConsts::EPhraseOk, |
|
875 KCapabilityTestAddress_B, |
|
876 KNullDesC8, |
|
877 KCapabilityTestTerminalID_B, |
|
878 KPAssertedIdentity_B, |
|
879 KCapabilityTestSDP ); |
|
880 CleanupStack::PushL( optionResp ); |
|
881 iQuery->DoCompletedL( *optionResp ); |
|
882 EUNIT_ASSERT_EQUALS( iQuery->State(), CMusAvaCapabilityQueryBase::ECapabilityQueryCreated ); |
|
883 EUNIT_ASSERT_EQUALS( iQuery->Result(), KCapabilityQueryNotReady ); |
|
884 TRAP( error, iQuery->DoRetryL() ); |
|
885 if ( error == KErrNoMemory ) User::Leave( error ); |
|
886 CleanupStack::PopAndDestroy( optionResp ); |
|
887 |
|
888 // status code KMUSAVASIPServerInternalError |
|
889 optionResp = CapabilityTestHelper::OptionsResponseL( |
|
890 KMUSAVASIPServerInternalError, |
|
891 SipStrConsts::EPhraseOk, |
|
892 KCapabilityTestAddress_B, |
|
893 KNullDesC8, |
|
894 KCapabilityTestTerminalID_B, |
|
895 KPAssertedIdentity_B, |
|
896 KCapabilityTestSDP ); |
|
897 CleanupStack::PushL( optionResp ); |
|
898 TRAP( error, iQuery->DoCompletedL( *optionResp ) ); |
|
899 if ( error == KErrNoMemory ) User::Leave( error ); |
|
900 EUNIT_ASSERT_EQUALS( iQuery->State(), CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
901 EUNIT_ASSERT_EQUALS( iQuery->Result(), KCapabilityCapabilitesNotFound ); |
|
902 CleanupStack::PopAndDestroy( optionResp ); |
|
903 |
|
904 } |
|
905 |
|
906 |
|
907 void UT_CMusAvaCapabilityQuery::UT_CMusAvaCapabilityQuery_DoCompleted200OKLL() |
|
908 { |
|
909 |
|
910 // no content |
|
911 CSIPClientTransaction* optionResp = CapabilityTestHelper::OptionsResponseL( |
|
912 KMUSAVASIP200, |
|
913 SipStrConsts::EPhraseOk, |
|
914 KCapabilityTestAddress_B, |
|
915 KCapabilitySwisFeature, |
|
916 KCapabilityTestTerminalID_B, |
|
917 KPAssertedIdentity_B, |
|
918 KNullDesC8 ); |
|
919 CleanupStack::PushL( optionResp ); |
|
920 iQuery->DoCompleted200OKL( *optionResp ); |
|
921 EUNIT_ASSERT_EQUALS( iQuery->State(), CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
922 EUNIT_ASSERT_EQUALS( iQuery->Result(), KCapabilityCapabilitesNotFound ); |
|
923 CleanupStack::PopAndDestroy( optionResp ); |
|
924 |
|
925 |
|
926 // wrong content type header |
|
927 optionResp = |
|
928 CapabilityTestHelper::OptionsResponseL( KMUSAVASIP200, |
|
929 SipStrConsts::EPhraseOk, |
|
930 KCapabilityTestAddress_B, |
|
931 KCapabilitySwisFeature, |
|
932 KCapabilityTestTerminalID_B, |
|
933 KPAssertedIdentity_B, |
|
934 KCapabilityTestSDP ); |
|
935 CleanupStack::PushL( optionResp ); |
|
936 |
|
937 const TDesC8& sdp = KCapabilityTestSDP; |
|
938 HBufC8* content = NULL; |
|
939 content = sdp.AllocL(); |
|
940 CleanupStack::PushL( content ); |
|
941 const CSIPResponseElements* response = optionResp->ResponseElements(); |
|
942 CSIPMessageElements& message = |
|
943 CONST_CAST(CSIPResponseElements*, response)->MessageElements(); |
|
944 |
|
945 CSIPContentTypeHeader* contentTypeHeader = CSIPContentTypeHeader::NewLC( |
|
946 KMUSAVASIPMediaTypeApplication, |
|
947 KMUSAVASIPParamFalse ); |
|
948 |
|
949 message.SetContentL( content, contentTypeHeader ); |
|
950 CleanupStack::Pop( contentTypeHeader ); |
|
951 CleanupStack::Pop( content ); |
|
952 iQuery->DoCompleted200OKL( *optionResp ); |
|
953 EUNIT_ASSERT_EQUALS( iQuery->State(), |
|
954 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
955 EUNIT_ASSERT_EQUALS( iQuery->Result(), KCapabilityCapabilitesNotFound ); |
|
956 |
|
957 content = sdp.AllocL(); |
|
958 CleanupStack::PushL( content ); |
|
959 contentTypeHeader = CSIPContentTypeHeader::NewLC( KMUSAVASIPParamFalse, |
|
960 KMUSAVASIPMediaSubTypeSDP ); |
|
961 message.SetContentL( content, contentTypeHeader ); |
|
962 CleanupStack::Pop( contentTypeHeader ); |
|
963 CleanupStack::Pop( content ); |
|
964 iQuery->DoCompleted200OKL( *optionResp ); |
|
965 EUNIT_ASSERT_EQUALS( iQuery->State(), |
|
966 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
967 EUNIT_ASSERT_EQUALS( iQuery->Result(), KCapabilityCapabilitesNotFound ); |
|
968 |
|
969 CleanupStack::PopAndDestroy( optionResp ); |
|
970 |
|
971 |
|
972 // wrong codec |
|
973 optionResp = CapabilityTestHelper::OptionsResponseL( KMUSAVASIP200, |
|
974 SipStrConsts::EPhraseOk, |
|
975 KCapabilityTestAddress_B, |
|
976 KCapabilitySwisFeature, |
|
977 KCapabilityTestTerminalID_B, |
|
978 KPAssertedIdentity_B, |
|
979 KCapabilityTestSDPWrongCodec ); |
|
980 CleanupStack::PushL( optionResp ); |
|
981 iQuery->DoCompleted200OKL( *optionResp ); |
|
982 EUNIT_ASSERT_EQUALS( iQuery->State(), |
|
983 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
984 EUNIT_ASSERT_EQUALS( iQuery->Result(), KCapabilityCapabilitesNotFound ); |
|
985 CleanupStack::PopAndDestroy( optionResp ); |
|
986 |
|
987 // set standard |
|
988 MultimediaSharingSettings::SetOperatorVariantSettingL( |
|
989 MusSettingsKeys::EStandard ); |
|
990 |
|
991 // wrong attribute (no application, no type ), wrong feature tag |
|
992 optionResp = CapabilityTestHelper::OptionsResponseL( KMUSAVASIP200, |
|
993 SipStrConsts::EPhraseOk, |
|
994 KCapabilityTestAddress_B, |
|
995 KCapabilitySwisFeatureFalse, |
|
996 KCapabilityTestTerminalID_B, |
|
997 KPAssertedIdentity_B, |
|
998 KCapabilityTestSDPNoAppNoType ); |
|
999 CleanupStack::PushL( optionResp ); |
|
1000 iQuery->DoCompleted200OKL( *optionResp ); |
|
1001 EUNIT_ASSERT_EQUALS( iQuery->State(), |
|
1002 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
1003 EUNIT_ASSERT_EQUALS( iQuery->Result(), KCapabilityCapabilitesNotFound ); |
|
1004 CleanupStack::PopAndDestroy( optionResp ); |
|
1005 |
|
1006 |
|
1007 // good attribute, wrong feature tag => KCapabilityCapabilitesReady |
|
1008 optionResp = CapabilityTestHelper::OptionsResponseL( KMUSAVASIP200, |
|
1009 SipStrConsts::EPhraseOk, |
|
1010 KCapabilityTestAddress_B, |
|
1011 KCapabilitySwisFeatureFalse, |
|
1012 KCapabilityTestTerminalID_B, |
|
1013 KPAssertedIdentity_B, |
|
1014 KCapabilityTestSDP ); |
|
1015 CleanupStack::PushL( optionResp ); |
|
1016 iQuery->DoCompleted200OKL( *optionResp ); |
|
1017 EUNIT_ASSERT_EQUALS( iQuery->State(), |
|
1018 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
1019 EUNIT_ASSERT_EQUALS( iQuery->Result(), KCapabilityCapabilitesNotFound ); |
|
1020 CleanupStack::PopAndDestroy( optionResp ); |
|
1021 |
|
1022 // wrong attribute (no application, no type ), good feature tag => KCapabilityCapabilitesReady |
|
1023 optionResp = CapabilityTestHelper::OptionsResponseL( KMUSAVASIP200, |
|
1024 SipStrConsts::EPhraseOk, |
|
1025 KCapabilityTestAddress_B, |
|
1026 KCapabilitySwisFeature, |
|
1027 KCapabilityTestTerminalID_B, |
|
1028 KPAssertedIdentity_B, |
|
1029 KCapabilityTestSDPNoAppNoType ); |
|
1030 CleanupStack::PushL( optionResp ); |
|
1031 iQuery->DoCompleted200OKL( *optionResp ); |
|
1032 EUNIT_ASSERT_EQUALS( iQuery->State(), |
|
1033 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
1034 EUNIT_ASSERT_EQUALS( iQuery->Result(), KCapabilityCapabilitesReady ); |
|
1035 CleanupStack::PopAndDestroy( optionResp ); |
|
1036 |
|
1037 |
|
1038 |
|
1039 // set operator specific |
|
1040 MultimediaSharingSettings::SetOperatorVariantSettingL( |
|
1041 MusSettingsKeys::EOperatorSpecific ); |
|
1042 |
|
1043 // operator specific, wrong attribute (no application, no type ) |
|
1044 optionResp = CapabilityTestHelper::OptionsResponseL( KMUSAVASIP200, |
|
1045 SipStrConsts::EPhraseOk, |
|
1046 KCapabilityTestAddress_B, |
|
1047 KCapabilitySwisFeature, |
|
1048 KCapabilityTestTerminalID_B, |
|
1049 KPAssertedIdentity_B, |
|
1050 KCapabilityTestSDPNoAppNoType ); |
|
1051 CleanupStack::PushL( optionResp ); |
|
1052 iQuery->DoCompleted200OKL( *optionResp ); |
|
1053 EUNIT_ASSERT_EQUALS( iQuery->State(), |
|
1054 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
1055 EUNIT_ASSERT_EQUALS( iQuery->Result(), KCapabilityCapabilitesNotFound ); |
|
1056 CleanupStack::PopAndDestroy( optionResp ); |
|
1057 |
|
1058 |
|
1059 // operator specific, wrong feature tag |
|
1060 optionResp = CapabilityTestHelper::OptionsResponseL( KMUSAVASIP200, |
|
1061 SipStrConsts::EPhraseOk, |
|
1062 KCapabilityTestAddress_B, |
|
1063 KCapabilitySwisFeatureFalse, |
|
1064 KCapabilityTestTerminalID_B, |
|
1065 KPAssertedIdentity_B, |
|
1066 KCapabilityTestSDP ); |
|
1067 CleanupStack::PushL( optionResp ); |
|
1068 iQuery->DoCompleted200OKL( *optionResp ); |
|
1069 EUNIT_ASSERT_EQUALS( iQuery->State(), |
|
1070 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ); |
|
1071 EUNIT_ASSERT_EQUALS( iQuery->Result(), KCapabilityCapabilitesNotFound ); |
|
1072 CleanupStack::PopAndDestroy( optionResp ); |
|
1073 |
|
1074 |
|
1075 } |
|
1076 |
|
1077 void UT_CMusAvaCapabilityQuery::UT_CMusAvaCapabilityOtherSDPHeadersLL() |
|
1078 { |
|
1079 CSdpDocument* content = CSdpDocument::NewLC(); |
|
1080 //AVC Disabled |
|
1081 MultimediaSharingSettings::SetPropertyValueL(MusSettingsKeys::KEncodingDevice, |
|
1082 KMusDisableAVC ); |
|
1083 iQuery->OtherSDPHeadersL(*content); |
|
1084 |
|
1085 RStringF media = MusAvaCapabilityContext::SDPStringL( |
|
1086 SdpCodecStringConstants::EMediaVideo ); |
|
1087 RStringF rtpmap = MusAvaCapabilityContext::SDPStringL( |
|
1088 SdpCodecStringConstants::EAttributeRtpmap ); |
|
1089 |
|
1090 RPointerArray<CSdpMediaField>& mediaFields = content->MediaFields(); |
|
1091 |
|
1092 for ( TInt i=0; i < mediaFields.Count(); i++ ) |
|
1093 { |
|
1094 if ( mediaFields[ i ]->Media() == media ) |
|
1095 { |
|
1096 EUNIT_ASSERT( mediaFields[ i ]->FormatList().Find( KCapabilitySwisFormatListH263Only ) >= KErrNone ); |
|
1097 RPointerArray<CSdpFmtAttributeField>& fmtLines = |
|
1098 mediaFields[ i ]->FormatAttributeFields(); |
|
1099 EUNIT_ASSERT( fmtLines.Count() == 1 ); |
|
1100 for ( TInt j=0; j < fmtLines.Count(); j++ ) |
|
1101 { |
|
1102 if ( fmtLines[ j ]->Attribute() == rtpmap ) |
|
1103 { |
|
1104 EUNIT_ASSERT(fmtLines[ j ]->Value().Find( KRTPCapabilitySDPAttributeCodecH263 ) == 0 ); |
|
1105 EUNIT_ASSERT(fmtLines[ j ]->Format().Find( KRTPCapabilitySDPAttributePayloadTypeH263 ) == 0 ); |
|
1106 } |
|
1107 } |
|
1108 } |
|
1109 } |
|
1110 CleanupStack::PopAndDestroy(content ); |
|
1111 //AVC Enabled |
|
1112 content = CSdpDocument::NewLC(); |
|
1113 MultimediaSharingSettings::SetPropertyValueL(MusSettingsKeys::KEncodingDevice, |
|
1114 KMusDisableAVC - 1 ); |
|
1115 iQuery->OtherSDPHeadersL(*content); |
|
1116 |
|
1117 mediaFields = content->MediaFields(); |
|
1118 |
|
1119 for ( TInt i=0; i < mediaFields.Count(); i++ ) |
|
1120 { |
|
1121 if ( mediaFields[ i ]->Media() == media ) |
|
1122 { |
|
1123 EUNIT_ASSERT( mediaFields[ i ]->FormatList().Find( KCapabilitySwisFormatList ) >= KErrNone ); |
|
1124 RPointerArray<CSdpFmtAttributeField>& fmtLines = |
|
1125 mediaFields[ i ]->FormatAttributeFields(); |
|
1126 EUNIT_ASSERT( fmtLines.Count() == 2 ) |
|
1127 for ( TInt j=0; j < fmtLines.Count(); j++ ) |
|
1128 { |
|
1129 if ( fmtLines[ j ]->Attribute() == rtpmap ) |
|
1130 { |
|
1131 if ( j == 0 ) //AVC first i.e. prefered |
|
1132 { |
|
1133 EUNIT_ASSERT(fmtLines[ j ]->Value().Find( KRTPCapabilitySDPAttributeCodec ) == 0 ); |
|
1134 EUNIT_ASSERT(fmtLines[ j ]->Format().Find( KRTPCapabilitySDPAttributePayloadTypeH264 ) == 0 ); |
|
1135 } |
|
1136 else |
|
1137 { |
|
1138 EUNIT_ASSERT(fmtLines[ j ]->Value().Find( KRTPCapabilitySDPAttributeCodecH263 ) == 0 ); |
|
1139 EUNIT_ASSERT(fmtLines[ j ]->Format().Find( KRTPCapabilitySDPAttributePayloadTypeH263 ) == 0 ); |
|
1140 } |
|
1141 } |
|
1142 } |
|
1143 } |
|
1144 } |
|
1145 CleanupStack::PopAndDestroy(content ); |
|
1146 } |
|
1147 // TEST TABLE |
|
1148 |
|
1149 EUNIT_BEGIN_TEST_TABLE( |
|
1150 UT_CMusAvaCapabilityQuery, |
|
1151 "CMusAvaCapabilityQuery", |
|
1152 "UNIT" ) |
|
1153 |
|
1154 EUNIT_TEST( |
|
1155 "NewL - test ", |
|
1156 "CMusAvaCapabilityQuery", |
|
1157 "NewL", |
|
1158 "FUNCTIONALITY", |
|
1159 SetupL,UT_CMusAvaCapabilityQuery_NewLL, Teardown) |
|
1160 |
|
1161 EUNIT_TEST( |
|
1162 "ExecuteL - test ", |
|
1163 "CMusAvaCapabilityQuery", |
|
1164 "ExecuteL", |
|
1165 "FUNCTIONALITY", |
|
1166 SetupL,UT_CMusAvaCapabilityQuery_ExecuteLL, Teardown) |
|
1167 |
|
1168 EUNIT_TEST( |
|
1169 "Canceled - test ", |
|
1170 "CMusAvaCapabilityQuery", |
|
1171 "Canceled", |
|
1172 "FUNCTIONALITY", |
|
1173 SetupL,UT_CMusAvaCapabilityQuery_CanceledL, Teardown) |
|
1174 |
|
1175 EUNIT_TEST( |
|
1176 "CompletedL - test ", |
|
1177 "CMusAvaCapabilityQuery", |
|
1178 "CompletedL", |
|
1179 "FUNCTIONALITY", |
|
1180 SetupL,UT_CMusAvaCapabilityQuery_CompletedLL, Teardown) |
|
1181 |
|
1182 EUNIT_TEST( |
|
1183 "CompletedL1 - test ", |
|
1184 "CMusAvaCapabilityQuery", |
|
1185 "CompletedL", |
|
1186 "FUNCTIONALITY", |
|
1187 SetupL,UT_CMusAvaCapabilityQuery_CompletedL1L, Teardown) |
|
1188 |
|
1189 EUNIT_TEST( |
|
1190 "CompletedL2 - test ", |
|
1191 "CMusAvaCapabilityQuery", |
|
1192 "CompletedL", |
|
1193 "FUNCTIONALITY", |
|
1194 SetupL,UT_CMusAvaCapabilityQuery_CompletedL2L, Teardown) |
|
1195 |
|
1196 EUNIT_TEST( |
|
1197 "ValidateAndStoreCodecsL - test ", |
|
1198 "CMusAvaCapabilityQuery", |
|
1199 "ValidateAndStoreCodecsL", |
|
1200 "FUNCTIONALITY", |
|
1201 SetupL,UT_CMusAvaCapabilityQuery_ValidateAndStoreCodecsLL, Teardown) |
|
1202 |
|
1203 EUNIT_TEST( |
|
1204 "ValidateAttributesL - test ", |
|
1205 "CMusAvaCapabilityQuery", |
|
1206 "ValidateAttributesL", |
|
1207 "FUNCTIONALITY", |
|
1208 SetupL,UT_CMusAvaCapabilityQuery_ValidateAttributesLL, Teardown) |
|
1209 |
|
1210 EUNIT_TEST( |
|
1211 "ValidateContactL - test ", |
|
1212 "CMusAvaCapabilityQuery", |
|
1213 "ValidateContactL", |
|
1214 "FUNCTIONALITY", |
|
1215 SetupL,UT_CMusAvaCapabilityQuery_ValidateContactLL, Teardown) |
|
1216 |
|
1217 EUNIT_TEST( |
|
1218 "Prepare - test ", |
|
1219 "CMusAvaCapabilityQuery", |
|
1220 "Prepare", |
|
1221 "FUNCTIONALITY", |
|
1222 SetupL,UT_CMusAvaCapabilityQuery_PrepareL, Teardown) |
|
1223 |
|
1224 EUNIT_TEST( |
|
1225 "DoCompletedL - test ", |
|
1226 "CMusAvaCapabilityQuery", |
|
1227 "DoCompletedL", |
|
1228 "FUNCTIONALITY", |
|
1229 SetupL,UT_CMusAvaCapabilityQuery_DoCompletedLL, Teardown) |
|
1230 |
|
1231 EUNIT_TEST( |
|
1232 "DoCompleted200OKL - test ", |
|
1233 "CMusAvaCapabilityQuery", |
|
1234 "DoCompleted200OKL", |
|
1235 "FUNCTIONALITY", |
|
1236 SetupL,UT_CMusAvaCapabilityQuery_DoCompleted200OKLL, Teardown) |
|
1237 |
|
1238 EUNIT_TEST( |
|
1239 "OtherSDPHeadersL - test ", |
|
1240 "CMusAvaCapabilityQuery", |
|
1241 "OtherSDPHeadersL", |
|
1242 "FUNCTIONALITY", |
|
1243 SetupL,UT_CMusAvaCapabilityOtherSDPHeadersLL, Teardown) |
|
1244 |
|
1245 |
|
1246 EUNIT_END_TEST_TABLE |
|
1247 |
|
1248 // END OF FILE |