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