|
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_cmcestateanswering.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 "mcestateanswering.h" |
|
39 |
|
40 |
|
41 // CONSTRUCTION |
|
42 UT_CMceStateAnswering* UT_CMceStateAnswering::NewL() |
|
43 { |
|
44 UT_CMceStateAnswering* self = UT_CMceStateAnswering::NewLC(); |
|
45 CleanupStack::Pop(); |
|
46 |
|
47 return self; |
|
48 } |
|
49 |
|
50 UT_CMceStateAnswering* UT_CMceStateAnswering::NewLC() |
|
51 { |
|
52 UT_CMceStateAnswering* self = new( ELeave ) UT_CMceStateAnswering(); |
|
53 CleanupStack::PushL( self ); |
|
54 |
|
55 self->ConstructL(); |
|
56 |
|
57 return self; |
|
58 } |
|
59 |
|
60 // Destructor (virtual by CBase) |
|
61 UT_CMceStateAnswering::~UT_CMceStateAnswering() |
|
62 { |
|
63 } |
|
64 |
|
65 |
|
66 // Default constructor |
|
67 UT_CMceStateAnswering::UT_CMceStateAnswering() |
|
68 { |
|
69 } |
|
70 |
|
71 // Second phase construct |
|
72 void UT_CMceStateAnswering::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_CMceStateAnswering::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( KMceStateAnswering ); |
|
111 iState = static_cast<CMceStateAnswering*>(&iSipSession->CurrentState()); |
|
112 } |
|
113 |
|
114 void UT_CMceStateAnswering::Teardown() |
|
115 { |
|
116 CMCETls::Close(); |
|
117 delete iSession; |
|
118 delete iServerCore; |
|
119 |
|
120 } |
|
121 |
|
122 |
|
123 void UT_CMceStateAnswering::UT_CMceStateAnswering_AcceptLL() |
|
124 { |
|
125 TMceIds ids; |
|
126 CMceMsgBase* msg = NULL; |
|
127 |
|
128 TMceStateTransitionEvent event1( *iSipSession, EMceAck ); |
|
129 EUNIT_ASSERT ( iState->AcceptL( event1 ) ); |
|
130 |
|
131 TMceStateTransitionEvent event2( *iSipSession, EMceItcCancel, ids, *msg ); |
|
132 TRAPD( e1, iState->AcceptL( event2 ) ); |
|
133 EUNIT_ASSERT ( e1 == KErrTotalLossOfPrecision ); |
|
134 |
|
135 TMceStateTransitionEvent event3( *iSipSession, EMceMediaSessionStopped ); |
|
136 TRAPD( e2, iState->AcceptL( event3 ) ); |
|
137 EUNIT_ASSERT ( e2 == KErrTotalLossOfPrecision ); |
|
138 |
|
139 |
|
140 } |
|
141 |
|
142 void UT_CMceStateAnswering::UT_CMceStateAnswering_EntryLL() |
|
143 { |
|
144 CMceComSession* clientSession = CMceComSession::NewL( CMceComSession::EOutSession ); |
|
145 CleanupStack::PushL( clientSession ); |
|
146 iSipSession->SetBodyL( clientSession ); |
|
147 CleanupStack::Pop( clientSession ); |
|
148 |
|
149 CSIPClientTransaction* invite = |
|
150 MCETestHelper::ClientTransactionLC( SipStrConsts::EInvite ); |
|
151 iSipSession->SetPendingTransactionL( invite ); |
|
152 CleanupStack::Pop( invite ); |
|
153 |
|
154 iStorage->iSipSentMethod = SIPStrings::StringF( SipStrConsts::EEmpty ); |
|
155 iStorage->iSipResponseToMethod = SIPStrings::StringF( SipStrConsts::EEmpty ); |
|
156 |
|
157 TMceStateTransitionEvent event1( *iSipSession, EMceAck ); |
|
158 iState->EntryL( event1 ); |
|
159 |
|
160 EUNIT_ASSERT ( iStorage->iMediaManagerAction == CMCETls::ENone ); |
|
161 EUNIT_ASSERT ( iStorage->iSipSentMethod == SIPStrings::StringF( SipStrConsts::EEmpty ) ); |
|
162 EUNIT_ASSERT ( iStorage->iSipResponseToMethod == SIPStrings::StringF( SipStrConsts::EEmpty ) ); |
|
163 EUNIT_ASSERT ( iStorage->iSipSentMessage == NULL ); |
|
164 EUNIT_ASSERT ( iStorage->iSipSentResponse == NULL ); |
|
165 |
|
166 MCE_RESET_STUBS(); |
|
167 |
|
168 // Enable & disable |
|
169 |
|
170 TMceIds ids; |
|
171 CMceMsgBase* msg = NULL; |
|
172 |
|
173 MCE_ASSERT_ENDPOINT_ENABLE_AND_DISABLE(); |
|
174 } |
|
175 |
|
176 void UT_CMceStateAnswering::UT_CMceStateAnswering_ExitLL() |
|
177 { |
|
178 iSipSession->iBody = CMceComSession::NewL( CMceComSession::EInSession ); |
|
179 |
|
180 EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateAnswering ); |
|
181 |
|
182 CSIPServerTransaction* srvtransaction = |
|
183 MCETestHelper::ServerTransactionL( SipStrConsts::EAck, EFalse ); |
|
184 |
|
185 CleanupStack::PushL( srvtransaction ); |
|
186 iSipSession->iPendingReceivedRequests.AppendL( srvtransaction ); |
|
187 CleanupStack::Pop( srvtransaction ); |
|
188 |
|
189 TMceStateTransitionEvent event1( *iSipSession, EMceAck ); |
|
190 iState->ExitL( event1 ); |
|
191 EUNIT_ASSERT ( iSipSession->CurrentState().Id() == KMceStateEstablished ); |
|
192 EUNIT_ASSERT ( iSipSession->iBody->iState == CMceSession::EEstablished ); |
|
193 |
|
194 |
|
195 } |
|
196 |
|
197 |
|
198 |
|
199 // TEST TABLE |
|
200 |
|
201 EUNIT_BEGIN_TEST_TABLE( |
|
202 UT_CMceStateAnswering, |
|
203 "UT_CMceStateAnswering", |
|
204 "UNIT" ) |
|
205 |
|
206 EUNIT_TEST( |
|
207 "AcceptL - test ", |
|
208 "CMceStateAnswering", |
|
209 "AcceptL", |
|
210 "FUNCTIONALITY", |
|
211 SetupL, UT_CMceStateAnswering_AcceptLL, Teardown) |
|
212 |
|
213 EUNIT_TEST( |
|
214 "EntryL - test ", |
|
215 "CMceStateAnswering", |
|
216 "EntryL", |
|
217 "FUNCTIONALITY", |
|
218 SetupL, UT_CMceStateAnswering_EntryLL, Teardown) |
|
219 |
|
220 EUNIT_TEST( |
|
221 "ExitL - test ", |
|
222 "CMceStateAnswering", |
|
223 "ExitL", |
|
224 "FUNCTIONALITY", |
|
225 SetupL, UT_CMceStateAnswering_ExitLL, Teardown) |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 EUNIT_END_TEST_TABLE |
|
231 |
|
232 // END OF FILE |