|
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_cmcestateterminating.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 "mcestateterminating.h" |
|
39 |
|
40 |
|
41 // CONSTRUCTION |
|
42 UT_CMceStateTerminating* UT_CMceStateTerminating::NewL() |
|
43 { |
|
44 UT_CMceStateTerminating* self = UT_CMceStateTerminating::NewLC(); |
|
45 CleanupStack::Pop(); |
|
46 |
|
47 return self; |
|
48 } |
|
49 |
|
50 UT_CMceStateTerminating* UT_CMceStateTerminating::NewLC() |
|
51 { |
|
52 UT_CMceStateTerminating* self = new( ELeave ) UT_CMceStateTerminating(); |
|
53 CleanupStack::PushL( self ); |
|
54 |
|
55 self->ConstructL(); |
|
56 |
|
57 return self; |
|
58 } |
|
59 |
|
60 // Destructor (virtual by CBase) |
|
61 UT_CMceStateTerminating::~UT_CMceStateTerminating() |
|
62 { |
|
63 } |
|
64 |
|
65 |
|
66 // Default constructor |
|
67 UT_CMceStateTerminating::UT_CMceStateTerminating() |
|
68 { |
|
69 } |
|
70 |
|
71 // Second phase construct |
|
72 void UT_CMceStateTerminating::ConstructL() |
|
73 { |
|
74 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
75 // It generates the test case table. |
|
76 CEUnitTestSuiteClass::ConstructL(); |
|
77 } |
|
78 |
|
79 // METHODS |
|
80 |
|
81 |
|
82 |
|
83 void UT_CMceStateTerminating::SetupL( ) |
|
84 { |
|
85 CMCETls::OpenL(); |
|
86 |
|
87 //TMceIds ids; |
|
88 iIds.iProfileID = 1; |
|
89 iIds.iManagerType = KMceCSSIPSession; |
|
90 iIds.iDialogType = KMceDlgTypeInvite; |
|
91 iServerCore = CMceServerCore::NewL(); |
|
92 |
|
93 iStorage = CMCETls::Storage(); |
|
94 |
|
95 CDesC8ArrayFlat* params = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity ); |
|
96 CleanupStack::PushL( params ); |
|
97 params->AppendL( _L8("User <user2@host>") ); |
|
98 params->AppendL( _L8("User <user@host>") ); |
|
99 |
|
100 CMceMsgTextArray* msgParams = new (ELeave) CMceMsgTextArray( *params ); |
|
101 CleanupStack::PushL( msgParams ); |
|
102 iStorage->StoreL( iIds, *msgParams ); |
|
103 CleanupStack::PopAndDestroy( msgParams ); |
|
104 CleanupStack::PopAndDestroy( params ); |
|
105 |
|
106 iSession = CMceCsSession::NewL(*iServerCore); |
|
107 iSession->CreateSubSessionL(iIds, RMessage2()); |
|
108 iSipSession = static_cast<CMceSipSession*>((iSession->Implementation().SubSessions())[0]); |
|
109 |
|
110 iSipSession->NextState( KMceStateTerminating ); |
|
111 iState = static_cast<CMceStateTerminating*>(&iSipSession->CurrentState()); |
|
112 |
|
113 } |
|
114 |
|
115 void UT_CMceStateTerminating::Teardown() |
|
116 { |
|
117 CMCETls::Close(); |
|
118 delete iSession; |
|
119 delete iServerCore; |
|
120 |
|
121 } |
|
122 |
|
123 |
|
124 void UT_CMceStateTerminating::UT_CMceStateTerminating_AcceptLL() |
|
125 { |
|
126 |
|
127 TMceIds ids; |
|
128 CMceMsgBase* msg = NULL; |
|
129 |
|
130 CSIPClientTransaction* clitransaction = |
|
131 MCETestHelper::ClientTransactionLC( SipStrConsts::EBye, KMceSipOK, SipStrConsts::EPhraseOk ); |
|
132 iSipSession->SetPendingTransactionL( clitransaction ); |
|
133 CleanupStack::Pop( clitransaction ); |
|
134 |
|
135 iSipSession->iResponse = clitransaction; |
|
136 |
|
137 |
|
138 TMceStateTransitionEvent event1( *iSipSession, EMceItcTerminateSession, ids, *msg ); |
|
139 TRAPD( e1, iState->AcceptL( event1 ) ); |
|
140 EUNIT_ASSERT ( e1 == KErrTotalLossOfPrecision ); |
|
141 |
|
142 TMceStateTransitionEvent event2( *iSipSession, EMceAck ); |
|
143 EUNIT_ASSERT ( !iState->AcceptL( event2 ) ); |
|
144 TMceStateTransitionEvent event3( *iSipSession, EMceResponse ); |
|
145 EUNIT_ASSERT ( iState->AcceptL( event3 ) ); |
|
146 TMceStateTransitionEvent event4( *iSipSession, EMceErrorResponse ); |
|
147 EUNIT_ASSERT ( iState->AcceptL( event4 ) ); |
|
148 TMceStateTransitionEvent event5( *iSipSession, EMceMediaSessionStopped ); |
|
149 EUNIT_ASSERT ( !iState->AcceptL( event5 ) ); |
|
150 |
|
151 TMceStateTransitionEvent event6( *iSipSession, EMceMediaUpdated ); |
|
152 TRAPD( e2, iState->AcceptL( event6 ) ); |
|
153 EUNIT_ASSERT ( e2 == KErrTotalLossOfPrecision ); |
|
154 |
|
155 } |
|
156 |
|
157 void UT_CMceStateTerminating::UT_CMceStateTerminating_EntryLL() |
|
158 { |
|
159 iSipSession->iBody = CMceComSession::NewL( CMceComSession::EOutSession ); |
|
160 |
|
161 iStorage->iSipSentMethod = SIPStrings::StringF( SipStrConsts::EEmpty ); |
|
162 iStorage->iSipResponseToMethod = SIPStrings::StringF( SipStrConsts::EEmpty ); |
|
163 |
|
164 CSIPClientTransaction* clitransaction = |
|
165 MCETestHelper::ClientTransactionLC( SipStrConsts::EBye, KMceSipOK, SipStrConsts::EPhraseOk ); |
|
166 iSipSession->SetPendingTransactionL( clitransaction ); |
|
167 CleanupStack::Pop( clitransaction ); |
|
168 |
|
169 iSipSession->iResponse = clitransaction; |
|
170 |
|
171 TMceStateTransitionEvent event1( *iSipSession, EMceResponse ); |
|
172 iState->EntryL( event1 ); |
|
173 |
|
174 EUNIT_ASSERT ( iStorage->iMediaManagerAction == CMCETls::ENone ); |
|
175 EUNIT_ASSERT ( iStorage->iSipSentMethod == SIPStrings::StringF( SipStrConsts::EEmpty ) ); |
|
176 EUNIT_ASSERT ( iStorage->iSipResponseToMethod == SIPStrings::StringF( SipStrConsts::EEmpty ) ); |
|
177 EUNIT_ASSERT ( iStorage->iSipSentMessage == NULL ); |
|
178 EUNIT_ASSERT ( iStorage->iSipSentResponse == NULL ); |
|
179 |
|
180 MCETestHelper::SetResponseL( *iSipSession->iResponse, KMceSipBusyHere, SipStrConsts::EPhraseBusyHere ); |
|
181 |
|
182 TMceStateTransitionEvent event2( *iSipSession, EMceErrorResponse ); |
|
183 iState->EntryL( event2 ); |
|
184 |
|
185 EUNIT_ASSERT ( iStorage->iMediaManagerAction == CMCETls::ENone ); |
|
186 EUNIT_ASSERT ( iStorage->iSipSentMethod == SIPStrings::StringF( SipStrConsts::EEmpty ) ); |
|
187 EUNIT_ASSERT ( iStorage->iSipResponseToMethod == SIPStrings::StringF( SipStrConsts::EEmpty ) ); |
|
188 EUNIT_ASSERT ( iStorage->iSipSentMessage == NULL ); |
|
189 EUNIT_ASSERT ( iStorage->iSipSentResponse == NULL ); |
|
190 |
|
191 TMceStateTransitionEvent event3( *iSipSession, EMceMediaSessionStopped ); |
|
192 iState->EntryL( event3 ); |
|
193 |
|
194 EUNIT_ASSERT ( iStorage->iMediaManagerAction == CMCETls::ENone ); |
|
195 EUNIT_ASSERT ( iStorage->iSipSentMethod == SIPStrings::StringF( SipStrConsts::EEmpty ) ); |
|
196 EUNIT_ASSERT ( iStorage->iSipResponseToMethod == SIPStrings::StringF( SipStrConsts::EEmpty ) ); |
|
197 EUNIT_ASSERT ( iStorage->iSipSentMessage == NULL ); |
|
198 EUNIT_ASSERT ( iStorage->iSipSentResponse == NULL ); |
|
199 |
|
200 CSIPServerTransaction* transaction = MCETestHelper::ServerTransactionL( SipStrConsts::EBye, EFalse ); |
|
201 CleanupStack::PushL( transaction ); |
|
202 iSipSession->iPendingReceivedRequests.AppendL( transaction ); |
|
203 CleanupStack::Pop( transaction ); |
|
204 |
|
205 |
|
206 TMceStateTransitionEvent event4( *iSipSession, EMceBye ); |
|
207 iState->EntryL( event4 ); |
|
208 |
|
209 EUNIT_ASSERT ( iStorage->iMediaManagerAction == CMCETls::ECloseSession ); |
|
210 EUNIT_ASSERT ( iStorage->iSipSentMethod == SIPStrings::StringF( SipStrConsts::EEmpty ) ); |
|
211 EUNIT_ASSERT ( iStorage->iSipResponseToMethod == SIPStrings::StringF( SipStrConsts::EBye ) ); |
|
212 EUNIT_ASSERT ( iStorage->iSipSentMessage == NULL ); |
|
213 EUNIT_ASSERT ( iStorage->iSipSentResponse != NULL ); |
|
214 |
|
215 |
|
216 } |
|
217 |
|
218 void UT_CMceStateTerminating::UT_CMceStateTerminating_ExitLL() |
|
219 { |
|
220 iSipSession->iBody = CMceComSession::NewL( CMceComSession::EOutSession ); |
|
221 |
|
222 EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateTerminating ); |
|
223 |
|
224 CSIPClientTransaction* clitransaction = |
|
225 MCETestHelper::ClientTransactionLC( SipStrConsts::EBye, KMceSipOK, SipStrConsts::EPhraseOk ); |
|
226 iSipSession->SetPendingTransactionL( clitransaction ); |
|
227 CleanupStack::Pop( clitransaction ); |
|
228 |
|
229 iSipSession->iResponse = clitransaction; |
|
230 |
|
231 TMceStateTransitionEvent event1( *iSipSession, EMceResponse ); |
|
232 iState->ExitL( event1 ); |
|
233 EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateTerminated ); |
|
234 EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::ETerminated ); |
|
235 |
|
236 |
|
237 } |
|
238 |
|
239 |
|
240 |
|
241 // TEST TABLE |
|
242 |
|
243 EUNIT_BEGIN_TEST_TABLE( |
|
244 UT_CMceStateTerminating, |
|
245 "UT_CMceStateTerminating", |
|
246 "UNIT" ) |
|
247 |
|
248 |
|
249 EUNIT_TEST("AcceptL - test ", |
|
250 "CMceStateTerminating", |
|
251 "AcceptL", |
|
252 "FUNCTIONALITY", |
|
253 SetupL, UT_CMceStateTerminating_AcceptLL, Teardown) |
|
254 |
|
255 EUNIT_TEST( |
|
256 "EntryL - test ", |
|
257 "CMceStateTerminating", |
|
258 "EntryL", |
|
259 "FUNCTIONALITY", |
|
260 SetupL, UT_CMceStateTerminating_EntryLL, Teardown) |
|
261 |
|
262 EUNIT_TEST( |
|
263 "ExitL - test ", |
|
264 "CMceStateTerminating", |
|
265 "ExitL", |
|
266 "FUNCTIONALITY", |
|
267 SetupL, UT_CMceStateTerminating_ExitLL, Teardown) |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 EUNIT_END_TEST_TABLE |
|
273 |
|
274 // END OF FILE |