|
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_CMceNatStateDecodeOffer.h" |
|
23 |
|
24 // EXTERNAL INCLUDES |
|
25 #include <digia/eunit/eunitmacros.h> |
|
26 |
|
27 |
|
28 // INTERNAL INCLUDES |
|
29 #include "mcetesthelper.h" |
|
30 #include "mceservercore.h" |
|
31 #include "cmcetls.h" |
|
32 #include "mceactionset.h" |
|
33 #include "mcecssession.h" |
|
34 #include "mcecssessionimplementation.h" |
|
35 #include "mcenatsipsession.h" |
|
36 #include "mcenatsipstatemachine.h" |
|
37 #include "mcemediamanager.h" |
|
38 #include "../inc/mcenatpluginmanager.h" |
|
39 #include "nspplugin.h" |
|
40 |
|
41 |
|
42 _LIT8( KIceOffer, |
|
43 "v=0\r\n\ |
|
44 o=alice 2890844526 2890844527 IN IP4 131.117.0.4\r\n\ |
|
45 s=-\r\n\ |
|
46 c=IN IP4 192.0.0.19\r\n\ |
|
47 t=0 0\r\n\ |
|
48 a=ice-ufrag:xStE\r\n\ |
|
49 a=ice-pwd:ermyyyErTTeseEWWtr\r\n\ |
|
50 m=audio 6231 RTP/AVP 96\r\n\ |
|
51 a=candidate:1 1 UDP 11435664 192.0.0.19 4356 typ srflx\r\n\ |
|
52 a=candidate:1 2 UDP 10435664 192.0.0.19 5333 typ srflx\r\n\ |
|
53 a=rtpmap:96 AMR/8000\r\n\ |
|
54 a=rtcp:6232 IN IP4 192.0.0.19\r\n" ); |
|
55 |
|
56 |
|
57 |
|
58 // CONSTRUCTION |
|
59 UT_CMceNatStateDecodeOffer* UT_CMceNatStateDecodeOffer::NewL() |
|
60 { |
|
61 UT_CMceNatStateDecodeOffer* self = |
|
62 UT_CMceNatStateDecodeOffer::NewLC(); |
|
63 CleanupStack::Pop(); |
|
64 return self; |
|
65 } |
|
66 |
|
67 UT_CMceNatStateDecodeOffer* UT_CMceNatStateDecodeOffer::NewLC() |
|
68 { |
|
69 UT_CMceNatStateDecodeOffer* self = |
|
70 new ( ELeave ) UT_CMceNatStateDecodeOffer(); |
|
71 CleanupStack::PushL( self ); |
|
72 self->ConstructL(); |
|
73 return self; |
|
74 } |
|
75 |
|
76 // Destructor (virtual by CBase) |
|
77 UT_CMceNatStateDecodeOffer::~UT_CMceNatStateDecodeOffer() |
|
78 { |
|
79 } |
|
80 |
|
81 // Default constructor |
|
82 UT_CMceNatStateDecodeOffer::UT_CMceNatStateDecodeOffer() |
|
83 { |
|
84 } |
|
85 |
|
86 // Second phase construct |
|
87 void UT_CMceNatStateDecodeOffer::ConstructL() |
|
88 { |
|
89 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
90 // It generates the test case table. |
|
91 CEUnitTestSuiteClass::ConstructL(); |
|
92 } |
|
93 |
|
94 // METHODS |
|
95 |
|
96 void UT_CMceNatStateDecodeOffer::SetupL() |
|
97 { |
|
98 CMCETls::OpenL(); |
|
99 SdpCodecStringPool::OpenL(); |
|
100 |
|
101 iIds.iAppUID = 10; |
|
102 iIds.iProfileID = 1; |
|
103 iIds.iManagerType = KMceCSSIPSession; |
|
104 iIds.iDialogType = KMceDlgTypeInvite; |
|
105 iServerCore = CMceServerCore::NewL(); |
|
106 |
|
107 iStorage = CMCETls::Storage(); |
|
108 |
|
109 iNatSessionId = 3; |
|
110 iServerCore->Manager().MediaManager().NatPluginManager().iEnabled = ETrue; |
|
111 |
|
112 CDesC8ArrayFlat* params = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity ); |
|
113 CleanupStack::PushL( params ); |
|
114 params->AppendL( _L8("User <user2@host>") ); |
|
115 params->AppendL( _L8("User <user@host>") ); |
|
116 |
|
117 CMceMsgTextArray* msgParams = new (ELeave) CMceMsgTextArray( *params ); |
|
118 CleanupStack::PushL( msgParams ); |
|
119 iStorage->StoreL( iIds, *msgParams ); |
|
120 CleanupStack::PopAndDestroy( msgParams ); |
|
121 CleanupStack::PopAndDestroy( params ); |
|
122 |
|
123 iSession = CMceCsSession::NewL(*iServerCore); |
|
124 iSession->CreateSubSessionL(iIds, RMessage2()); |
|
125 iSipSession = static_cast<CMceSipSession*> |
|
126 ((iSession->Implementation().SubSessions())[0]); |
|
127 |
|
128 CMceSipManager& manager = iServerCore->Manager(); |
|
129 CSIPProfile& profile = manager.ProfileL( iIds.iProfileID ); |
|
130 |
|
131 iNatSession = CMceNatSipSession::NewL( *iSession, |
|
132 iSipSession->SIPConnection(), |
|
133 *iSipSession->iStateMachine, |
|
134 profile, |
|
135 NULL ); |
|
136 iNatSession->iNatStateMachine->iCurrentState = KMceNatStateDecodeOffer; |
|
137 iState = iNatSession->iNatStateMachine->iStates[ |
|
138 iNatSession->iNatStateMachine->iCurrentState ]; |
|
139 |
|
140 } |
|
141 |
|
142 void UT_CMceNatStateDecodeOffer::Teardown() |
|
143 { |
|
144 CMCETls::Close(); |
|
145 delete iSession; |
|
146 iSession = NULL; |
|
147 delete iNatSession; |
|
148 iNatSession = NULL; |
|
149 delete iServerCore; |
|
150 iServerCore = NULL; |
|
151 |
|
152 SdpCodecStringPool::Close(); |
|
153 } |
|
154 |
|
155 void UT_CMceNatStateDecodeOffer:: |
|
156 UT_CMceNatStateDecodeOffer_AcceptLL() |
|
157 { |
|
158 EUNIT_ASSERT( DoesAccept( EMceNatError ) ); |
|
159 EUNIT_ASSERT( DoesAccept( EMceNatICMPError ) ); |
|
160 EUNIT_ASSERT( DoesAccept( EMceNatOffer ) ); |
|
161 EUNIT_ASSERT( DoesAccept( EMceNatHandleSIP ) ); |
|
162 |
|
163 EUNIT_ASSERT( !DoesAccept( EMceNatInitialized ) ); |
|
164 EUNIT_ASSERT( !DoesAccept( EMceNatAnswer ) ); |
|
165 EUNIT_ASSERT( !DoesAccept( EMceNatUpdateSdp ) ); |
|
166 EUNIT_ASSERT( !DoesAccept( EMceNatUpdated ) ); |
|
167 EUNIT_ASSERT( !DoesAccept( EMceNatSync ) ); |
|
168 |
|
169 } |
|
170 |
|
171 void UT_CMceNatStateDecodeOffer:: |
|
172 UT_CMceNatStateDecodeOffer_EntryLL() |
|
173 { |
|
174 iNatSession->SetOffer( CSdpDocument::DecodeL( KIceOffer() ) ); |
|
175 iNatSession->iBody = CMceComSession::NewL( CMceComSession::EInSession ); |
|
176 |
|
177 TMceNatEventCode eventcode = EMceNatAnswer; |
|
178 iNatSession->iNatDisabled = EFalse; |
|
179 iNatSession->iEntryPoint = CMceNatSipSession::ENatEntryUpdated; |
|
180 |
|
181 TMceNatStateTransitionEvent event( NULL,*iNatSession,eventcode, |
|
182 *iNatSession, EMceInvite ); |
|
183 |
|
184 iState->TransitionHandler().EntryL( event ); |
|
185 |
|
186 EUNIT_ASSERT( KMceNatStateDecodeOffer == |
|
187 iNatSession->iNatStateMachine->iCurrentState ); |
|
188 EUNIT_ASSERT( !iNatSession->iNatDisabled ); |
|
189 |
|
190 } |
|
191 |
|
192 |
|
193 void UT_CMceNatStateDecodeOffer:: |
|
194 UT_CMceNatStateDecodeOffer_ExitLL() |
|
195 { |
|
196 |
|
197 // NAT Error Occured |
|
198 iNatSession->iBody = CMceComSession::NewL( CMceComSession::EOutSession ); |
|
199 TMceNatEventCode eventcode = EMceNatError; |
|
200 iNatSession->iNatDisabled = EFalse; |
|
201 iNatSession->iEntryPoint = CMceNatSipSession::ENatEntryUpdated; |
|
202 |
|
203 TMceNatStateTransitionEvent event( NULL,*iNatSession,eventcode, |
|
204 *iNatSession, EMceInvite ); |
|
205 |
|
206 EUNIT_ASSERT_LEAVE( iState->TransitionHandler().ExitL( event )); |
|
207 |
|
208 |
|
209 // NAT ICMP IGnored |
|
210 iNatSession->iNatDisabled = EFalse; |
|
211 eventcode = EMceNatICMPError; |
|
212 TMceNatStateTransitionEvent event1( NULL, *iNatSession,eventcode, |
|
213 *iNatSession, EMceInvite ); |
|
214 EUNIT_ASSERT_NO_LEAVE( iState->TransitionHandler().ExitL( event1 )); |
|
215 |
|
216 |
|
217 // NAT ICMP Handled i.e MCE State is Established |
|
218 iNatSession->iNatDisabled = EFalse; |
|
219 eventcode = EMceNatICMPError; |
|
220 iNatSession->NextState( KMceStateEstablished ); |
|
221 TMceNatStateTransitionEvent event2( NULL, *iNatSession,eventcode, |
|
222 *iNatSession, EMceInvite ); |
|
223 EUNIT_ASSERT_NO_LEAVE( iState->TransitionHandler().ExitL( event2 )); |
|
224 |
|
225 |
|
226 } |
|
227 |
|
228 TBool |
|
229 UT_CMceNatStateDecodeOffer::DoesAccept( TMceNatEventCode aEventCode ) |
|
230 { |
|
231 TMceNatStateTransitionEvent event( NULL, |
|
232 *iNatSession, |
|
233 aEventCode, |
|
234 *iNatSession, |
|
235 EMceInvite ); |
|
236 return iState->Accept( event ); |
|
237 } |
|
238 |
|
239 // TEST TABLE |
|
240 |
|
241 EUNIT_BEGIN_TEST_TABLE( |
|
242 UT_CMceNatStateDecodeOffer, |
|
243 "UT_CMceNatStateDecodeOffer", |
|
244 "UNIT" ) |
|
245 |
|
246 EUNIT_TEST( |
|
247 "DoAcceptL - test ", |
|
248 "CMceNatStateDecodeOffer", |
|
249 "AcceptL", |
|
250 "FUNCTIONALITY", |
|
251 SetupL, UT_CMceNatStateDecodeOffer_AcceptLL, Teardown) |
|
252 |
|
253 EUNIT_TEST( |
|
254 "EntryL - test ", |
|
255 "CMceNatStateDecodeOffer", |
|
256 "EntryL", |
|
257 "FUNCTIONALITY", |
|
258 SetupL, UT_CMceNatStateDecodeOffer_EntryLL, Teardown) |
|
259 |
|
260 EUNIT_TEST( |
|
261 "ExitL - test ", |
|
262 "CMceNatStateDecodeOffer", |
|
263 "ExitL", |
|
264 "FUNCTIONALITY", |
|
265 SetupL, UT_CMceNatStateDecodeOffer_ExitLL, Teardown) |
|
266 |
|
267 |
|
268 EUNIT_END_TEST_TABLE |
|
269 |
|
270 // END OF FILE |
|
271 |