|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // CLASS HEADER |
|
22 #include "ut_cmcestateconfirmationrequired.h" |
|
23 |
|
24 // EXTERNAL INCLUDES |
|
25 #include <digia/eunit/eunitmacros.h> |
|
26 |
|
27 |
|
28 // INTERNAL INCLUDES |
|
29 #include "MCETestHelper.h" |
|
30 |
|
31 #include "mcesipsession.h" |
|
32 #include "mcesipstatemachine.h" |
|
33 #include "mceservercore.h" |
|
34 #include "mcecssession.h" |
|
35 #include "mcecssessionimplementation.h" |
|
36 #include "mcesipconnection.h" |
|
37 #include "mcecomsession.h" |
|
38 #include "mcestateconfirmationrequired.h" |
|
39 #include "mceevent.h" |
|
40 #include "mceserial.h" |
|
41 #include "mcemediamanager.h" |
|
42 |
|
43 |
|
44 |
|
45 // CONSTRUCTION |
|
46 UT_CMceStateConfirmationRequired* UT_CMceStateConfirmationRequired::NewL() |
|
47 { |
|
48 UT_CMceStateConfirmationRequired* self = UT_CMceStateConfirmationRequired::NewLC(); |
|
49 CleanupStack::Pop(); |
|
50 |
|
51 return self; |
|
52 } |
|
53 |
|
54 UT_CMceStateConfirmationRequired* UT_CMceStateConfirmationRequired::NewLC() |
|
55 { |
|
56 UT_CMceStateConfirmationRequired* self = new( ELeave ) UT_CMceStateConfirmationRequired(); |
|
57 CleanupStack::PushL( self ); |
|
58 |
|
59 self->ConstructL(); |
|
60 |
|
61 return self; |
|
62 } |
|
63 |
|
64 // Destructor (virtual by CBase) |
|
65 UT_CMceStateConfirmationRequired::~UT_CMceStateConfirmationRequired() |
|
66 { |
|
67 } |
|
68 |
|
69 |
|
70 // Default constructor |
|
71 UT_CMceStateConfirmationRequired::UT_CMceStateConfirmationRequired() |
|
72 { |
|
73 } |
|
74 |
|
75 // Second phase construct |
|
76 void UT_CMceStateConfirmationRequired::ConstructL() |
|
77 { |
|
78 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
79 // It generates the test case table. |
|
80 CEUnitTestSuiteClass::ConstructL(); |
|
81 } |
|
82 |
|
83 // METHODS |
|
84 |
|
85 void UT_CMceStateConfirmationRequired::SetupL( ) |
|
86 { |
|
87 CMCETls::OpenL(); |
|
88 SdpCodecStringPool::OpenL(); |
|
89 |
|
90 iIds.iProfileID = 1; |
|
91 iIds.iManagerType = KMceCSSIPSession; |
|
92 iIds.iDialogType = KMceDlgTypeInvite; |
|
93 iServerCore = CMceServerCore::NewL(); |
|
94 |
|
95 iStorage = CMCETls::Storage(); |
|
96 |
|
97 CDesC8ArrayFlat* params = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity ); |
|
98 CleanupStack::PushL( params ); |
|
99 params->AppendL( _L8("User <user2@host>") ); |
|
100 params->AppendL( _L8("User <user@host>") ); |
|
101 |
|
102 CMceMsgTextArray* msgParams = new (ELeave) CMceMsgTextArray( *params ); |
|
103 CleanupStack::PushL( msgParams ); |
|
104 iStorage->StoreL( iIds, *msgParams ); |
|
105 CleanupStack::PopAndDestroy( msgParams ); |
|
106 CleanupStack::PopAndDestroy( params ); |
|
107 |
|
108 iSession = CMceCsSession::NewL(*iServerCore); |
|
109 iSession->CreateSubSessionL(iIds, RMessage2()); |
|
110 iSipSession = static_cast<CMceSipSession*>((iSession->Implementation().SubSessions())[0]); |
|
111 |
|
112 iSipSession->SetBodyL(); |
|
113 |
|
114 MCETestHelper::RequestL( iSipSession, SipStrConsts::EUpdate, ETrue, EFalse ); |
|
115 |
|
116 MCE_SET_STATES( iSipSession /*session*/, |
|
117 CMceSession::EReserving /*clientState*/, |
|
118 KMceStateConfirmationRequired /*serverState*/ ); |
|
119 iState = static_cast<CMceStateConfirmationRequired*>(&iSipSession->CurrentState()); |
|
120 HBufC8* token = KMediaToken().AllocL(); |
|
121 iSipSession->SetMediaAuthorizationToken( token ); |
|
122 MCE_RESET_STUBS(); |
|
123 } |
|
124 |
|
125 void UT_CMceStateConfirmationRequired::Teardown() |
|
126 { |
|
127 CMCETls::Close(); |
|
128 delete iSession; |
|
129 delete iServerCore; |
|
130 |
|
131 SdpCodecStringPool::Close(); |
|
132 } |
|
133 |
|
134 void UT_CMceStateConfirmationRequired::UT_CMceStateConfirmationRequired_AcceptLL() |
|
135 { |
|
136 TMceStateTransitionEvent event1( *iSipSession, EMceUpdate ); |
|
137 EUNIT_ASSERT ( iState->AcceptL( event1 ) ); |
|
138 |
|
139 TMceStateTransitionEvent event2( *iSipSession, EMceMediaUpdated ); |
|
140 EUNIT_ASSERT ( iState->AcceptL( event2 ) ); |
|
141 |
|
142 TMceStateTransitionEvent event3( *iSipSession, EMceResponse ); |
|
143 EUNIT_ASSERT_SPECIFIC_LEAVE ( iState->AcceptL( event3 ), KErrTotalLossOfPrecision ); |
|
144 |
|
145 TMceIds ids; |
|
146 TMceStateTransitionEvent event4( *iSipSession, EMceItcRejectSession, ids ); |
|
147 EUNIT_ASSERT ( iState->AcceptL( event4 ) ); |
|
148 } |
|
149 |
|
150 void UT_CMceStateConfirmationRequired::UT_CMceStateConfirmationRequired_EntryLL() |
|
151 { |
|
152 // EMceUpdate |
|
153 // update fails |
|
154 TMceStateTransitionEvent event1( *iSipSession, EMceUpdate ); |
|
155 iStorage->iMediaManagerUpdateStatus = KErrGeneral; |
|
156 iState->EntryL( event1 ); |
|
157 MCE_ASSERT_STUBS( CMCETls::EUpdate /*mmaction*/, |
|
158 CMCETls::EDecode /*mmsdpaction*/, |
|
159 SipStrConsts::EEmpty /*sentMethod*/, |
|
160 KErrNotFound /*sentResponse*/); |
|
161 MCE_ASSERT_EVENT( event1 /*event*/, |
|
162 EMceUpdate /*code*/, |
|
163 KErrGeneral /*status*/ ); |
|
164 |
|
165 MCE_RESET_STUBS(); |
|
166 |
|
167 // async |
|
168 TMceStateTransitionEvent event2( *iSipSession, EMceUpdate ); |
|
169 iStorage->iMediaManagerUpdateStatus = KMceAsync; |
|
170 iState->EntryL( event2 ); |
|
171 MCE_ASSERT_STUBS( CMCETls::EUpdate /*mmaction*/, |
|
172 CMCETls::EDecode /*mmsdpaction*/, |
|
173 SipStrConsts::EEmpty /*sentMethod*/, |
|
174 KErrNotFound /*sentResponse*/); |
|
175 MCE_ASSERT_EVENT( event2 /*event*/, |
|
176 EMceUpdate /*code*/, |
|
177 KMceAsync /*status*/ ); |
|
178 |
|
179 MCE_RESET_STUBS(); |
|
180 |
|
181 // ready, reserve async |
|
182 |
|
183 TMceStateTransitionEvent event3( *iSipSession, EMceUpdate ); |
|
184 iStorage->iMediaManagerUpdateStatus = KMceReady; |
|
185 iStorage->iMediaManagerReserveStatus = KMceAsync; |
|
186 iState->EntryL( event3 ); |
|
187 MCE_ASSERT_STUBS( CMCETls::EReserve /*mmaction*/, |
|
188 CMCETls::EDecode /*mmsdpaction*/, |
|
189 SipStrConsts::EEmpty /*sentMethod*/, |
|
190 KErrNotFound /*sentResponse*/); |
|
191 MCE_ASSERT_EVENT( event3 /*event*/, |
|
192 EMceMediaUpdated /*code*/, |
|
193 KMceAsync /*status*/ ); |
|
194 |
|
195 MCE_RESET_STUBS(); |
|
196 |
|
197 // EMceMediaUpdated |
|
198 // reserve fails |
|
199 TMceStateTransitionEvent event4( *iSipSession, EMceMediaUpdated ); |
|
200 iStorage->iMediaManagerReserveStatus = KErrGeneral; |
|
201 iState->EntryL( event4 ); |
|
202 MCE_ASSERT_STUBS( CMCETls::EReserve /*mmaction*/, |
|
203 CMCETls::ENone /*mmsdpaction*/, |
|
204 SipStrConsts::EEmpty /*sentMethod*/, |
|
205 KErrNotFound /*sentResponse*/); |
|
206 MCE_ASSERT_EVENT( event4 /*event*/, |
|
207 EMceMediaUpdated /*code*/, |
|
208 KErrGeneral /*status*/ ); |
|
209 |
|
210 MCE_RESET_STUBS(); |
|
211 |
|
212 // reserve async |
|
213 TMceStateTransitionEvent event5( *iSipSession, EMceMediaUpdated ); |
|
214 iStorage->iMediaManagerReserveStatus = KMceAsync; |
|
215 iState->EntryL( event5 ); |
|
216 MCE_ASSERT_STUBS( CMCETls::EReserve /*mmaction*/, |
|
217 CMCETls::ENone /*mmsdpaction*/, |
|
218 SipStrConsts::EEmpty /*sentMethod*/, |
|
219 KErrNotFound /*sentResponse*/); |
|
220 MCE_ASSERT_EVENT( event5 /*event*/, |
|
221 EMceMediaUpdated /*code*/, |
|
222 KMceAsync /*status*/ ); |
|
223 |
|
224 MCE_RESET_STUBS(); |
|
225 |
|
226 // reserve ready, no update |
|
227 MCETestHelper::RequestL( iSipSession, SipStrConsts::EPrack ); |
|
228 TMceStateTransitionEvent event6( *iSipSession, EMceMediaUpdated ); |
|
229 iStorage->iMediaManagerReserveStatus = KMceReady; |
|
230 EUNIT_ASSERT_SPECIFIC_LEAVE( iState->EntryL( event6 ), KErrTotalLossOfPrecision ); |
|
231 MCE_ASSERT_STUBS( CMCETls::EReserve /*mmaction*/, |
|
232 CMCETls::ENone /*mmsdpaction*/, |
|
233 SipStrConsts::EEmpty /*sentMethod*/, |
|
234 KErrNotFound /*sentResponse*/); |
|
235 MCE_ASSERT_EVENT( event6 /*event*/, |
|
236 EMceMediaUpdated /*code*/, |
|
237 KMceReady /*status*/ ); |
|
238 |
|
239 MCE_RESET_STUBS(); |
|
240 |
|
241 // reserve ready, update received |
|
242 MCETestHelper::RequestL( iSipSession, SipStrConsts::EUpdate, ETrue ); |
|
243 TMceStateTransitionEvent event7( *iSipSession, EMceMediaUpdated ); |
|
244 iStorage->iMediaManagerReserveStatus = KMceReady; |
|
245 iState->EntryL( event7 ); |
|
246 MCE_ASSERT_STUBS( CMCETls::EReserve /*mmaction*/, |
|
247 CMCETls::EEncode /*mmsdpaction*/, |
|
248 SipStrConsts::EEmpty /*sentMethod*/, |
|
249 KMceSipOK /*sentResponse*/); |
|
250 MCE_ASSERT_EVENT( event7 /*event*/, |
|
251 EMceMediaUpdated /*code*/, |
|
252 KMceReady /*status*/ ); |
|
253 |
|
254 MCE_RESET_STUBS(); |
|
255 |
|
256 // default |
|
257 TMceStateTransitionEvent event8( *iSipSession, EMceResponse ); |
|
258 iState->EntryL( event8 ); |
|
259 MCE_ASSERT_STUBS( CMCETls::ENone /*mmaction*/, |
|
260 CMCETls::ENone /*mmsdpaction*/, |
|
261 SipStrConsts::EEmpty /*sentMethod*/, |
|
262 KErrNotFound /*sentResponse*/); |
|
263 MCE_ASSERT_EVENT( event8 /*event*/, |
|
264 EMceResponse /*code*/, |
|
265 KMceReady /*status*/ ); |
|
266 |
|
267 MCE_RESET_STUBS(); |
|
268 |
|
269 //EMceItcRejectSession |
|
270 TMceIds ids; |
|
271 TMceStateTransitionEvent event9( *iSipSession, EMceItcRejectSession, ids ); |
|
272 iStorage->iMediaManagerUpdateStatus = KMceReady; |
|
273 iState->EntryL( event9 ); |
|
274 MCE_ASSERT_STUBS( CMCETls::ECloseSession /*mmaction*/, |
|
275 CMCETls::ENone /*mmsdpaction*/, |
|
276 SipStrConsts::EEmpty /*sentMethod*/, |
|
277 KMceSipDecline /*sentResponse*/); |
|
278 MCE_ASSERT_EVENT( event9 /*event*/, |
|
279 EMceItcRejectSession /*code*/, |
|
280 KMceReady /*status*/ ); |
|
281 |
|
282 MCE_RESET_STUBS(); |
|
283 |
|
284 // Enable & disable |
|
285 |
|
286 // TMceIds ids; |
|
287 CMceMsgBase* msg = NULL; |
|
288 |
|
289 MCE_ASSERT_ENDPOINT_ENABLE_AND_DISABLE(); |
|
290 } |
|
291 |
|
292 void UT_CMceStateConfirmationRequired::UT_CMceStateConfirmationRequired_ExitLL() |
|
293 { |
|
294 // EMceUpdate |
|
295 // error |
|
296 TMceStateTransitionEvent event1( *iSipSession, EMceUpdate ); |
|
297 event1.ParamStatus() = KErrGeneral; |
|
298 iState->ExitL( event1 ); |
|
299 MCE_ASSERT_STATES( iSipSession /*session*/, |
|
300 CMceSession::EReserving /*clientState*/, |
|
301 KMceStateConfirmationRequired /*serverState*/ ); |
|
302 MCE_SET_STATES( iSipSession /*session*/, |
|
303 CMceSession::EReserving /*clientState*/, |
|
304 KMceStateConfirmationRequired /*serverState*/ ); |
|
305 |
|
306 MCE_RESET_STUBS(); |
|
307 |
|
308 // no error, async |
|
309 TMceStateTransitionEvent event2( *iSipSession, EMceUpdate ); |
|
310 iState->ExitL( event2 ); |
|
311 MCE_ASSERT_STATES( iSipSession /*session*/, |
|
312 CMceSession::EReserving /*clientState*/, |
|
313 KMceStateConfirmationRequired /*serverState*/ ); |
|
314 MCE_RESET_STUBS(); |
|
315 |
|
316 // EMceMediaUpdated |
|
317 // error |
|
318 TMceStateTransitionEvent event3( *iSipSession, EMceMediaUpdated ); |
|
319 event3.ParamStatus() = KErrGeneral; |
|
320 iState->ExitL( event3 ); |
|
321 MCE_ASSERT_STATES( iSipSession /*session*/, |
|
322 CMceSession::EReserving /*clientState*/, |
|
323 KMceStateConfirmationRequired /*serverState*/ ); |
|
324 MCE_SET_STATES( iSipSession /*session*/, |
|
325 CMceSession::EReserving /*clientState*/, |
|
326 KMceStateConfirmationRequired /*serverState*/ ); |
|
327 |
|
328 MCE_RESET_STUBS(); |
|
329 |
|
330 // async |
|
331 TMceStateTransitionEvent event4( *iSipSession, EMceMediaUpdated ); |
|
332 event4.ParamStatus() = KMceAsync; |
|
333 iState->ExitL( event4 ); |
|
334 MCE_ASSERT_STATES( iSipSession /*session*/, |
|
335 CMceSession::EReserving /*clientState*/, |
|
336 KMceStateServerReserving /*serverState*/ ); |
|
337 MCE_SET_STATES( iSipSession /*session*/, |
|
338 CMceSession::EReserving /*clientState*/, |
|
339 KMceStateConfirmationRequired /*serverState*/ ); |
|
340 |
|
341 MCE_RESET_STUBS(); |
|
342 |
|
343 // ready |
|
344 TMceStateTransitionEvent event5( *iSipSession, EMceMediaUpdated ); |
|
345 event5.ParamStatus() = KMceReady; |
|
346 iState->ExitL( event5 ); |
|
347 MCE_ASSERT_STATES( iSipSession /*session*/, |
|
348 CMceSession::EProceeding /*clientState*/, |
|
349 KMceStateUpdated /*serverState*/ ); |
|
350 MCE_SET_STATES( iSipSession /*session*/, |
|
351 CMceSession::EReserving /*clientState*/, |
|
352 KMceStateConfirmationRequired /*serverState*/ ); |
|
353 |
|
354 MCE_RESET_STUBS(); |
|
355 |
|
356 //EMceItcRejectSession |
|
357 TMceIds ids; |
|
358 TMceStateTransitionEvent event7( *iSipSession, EMceItcRejectSession, ids ); |
|
359 event7.ParamStatus() = KErrGeneral; |
|
360 iState->ExitL( event7 ); |
|
361 MCE_ASSERT_STATES( iSipSession /*session*/, |
|
362 CMceSession::ETerminated /*clientState*/, |
|
363 KMceStateTerminated /*serverState*/ ); |
|
364 MCE_SET_STATES( iSipSession /*session*/, |
|
365 CMceSession::EReserving /*clientState*/, |
|
366 KMceStateConfirmationRequired /*serverState*/ ); |
|
367 |
|
368 MCE_RESET_STUBS(); |
|
369 |
|
370 // default |
|
371 TMceStateTransitionEvent event6( *iSipSession, EMceResponse ); |
|
372 iState->ExitL( event6 ); |
|
373 MCE_ASSERT_STATES( iSipSession /*session*/, |
|
374 CMceSession::EReserving /*clientState*/, |
|
375 KMceStateConfirmationRequired /*serverState*/ ); |
|
376 } |
|
377 |
|
378 // TEST TABLE |
|
379 |
|
380 EUNIT_BEGIN_TEST_TABLE( |
|
381 UT_CMceStateConfirmationRequired, |
|
382 "UT_CMceStateConfirmationRequired", |
|
383 "UNIT" ) |
|
384 |
|
385 EUNIT_TEST( |
|
386 "AcceptL - test ", |
|
387 "CMceStateConfirmationRequired", |
|
388 "AcceptL", |
|
389 "FUNCTIONALITY", |
|
390 SetupL, UT_CMceStateConfirmationRequired_AcceptLL, Teardown) |
|
391 |
|
392 EUNIT_TEST( |
|
393 "EntryL - test ", |
|
394 "CMceStateConfirmationRequired", |
|
395 "EntryL", |
|
396 "FUNCTIONALITY", |
|
397 SetupL, UT_CMceStateConfirmationRequired_EntryLL, Teardown) |
|
398 |
|
399 EUNIT_TEST( |
|
400 "ExitL - test ", |
|
401 "CMceStateConfirmationRequired", |
|
402 "ExitL", |
|
403 "FUNCTIONALITY", |
|
404 SetupL, UT_CMceStateConfirmationRequired_ExitLL, Teardown) |
|
405 |
|
406 EUNIT_END_TEST_TABLE |
|
407 |
|
408 // END OF FILE |