74
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 |
#include "ut_cphoneconferenceandwaiting.h"
|
|
19 |
#include <csmcmockcontext.h>
|
|
20 |
#include <smcdefaultvalue.h>
|
|
21 |
#include <msmcmockspecbuilder.h>
|
|
22 |
#include <smcobjecttotypemapper.h>
|
|
23 |
#include <EUnitMacros.h>
|
|
24 |
#include <EUnitDecorators.h>
|
|
25 |
#include <featmgr.h>
|
|
26 |
#include "CPhoneConferenceAndWaiting.h"
|
|
27 |
#include "PEVirtualEngine.h"
|
|
28 |
#include "MPhoneKeyEvents.h"
|
|
29 |
#include "TPhoneCommandParam.h"
|
|
30 |
#include "CPhoneMainResourceResolver.h"
|
|
31 |
#include "CPhoneStateMachineGSM.h"
|
|
32 |
#include "mock_cphoneviewcommandhandle.h"
|
|
33 |
#include "TPhoneCmdParamCallHeaderData.h"
|
|
34 |
#include "TPhoneCmdParamAudioOutput.h"
|
|
35 |
#include "phonerssbase.h"
|
|
36 |
#include "phonestatedefinitionsgsm.h"
|
|
37 |
#include "TPhoneCmdParamInteger.h"
|
|
38 |
#include "TPhoneCmdParamCallStateData.h"
|
|
39 |
|
|
40 |
// needed for mocking CPhoneMainResourceResolver::Instance()
|
|
41 |
class CPhoneMainResourceResolverMock : public CPhoneMainResourceResolver
|
|
42 |
{
|
|
43 |
};
|
|
44 |
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
// operator for comparing parameter expected and result value.
|
|
47 |
// -
|
|
48 |
// -----------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
TBool operator==(const TPhoneCommandParam& param1, const TPhoneCommandParam& param2 )
|
|
51 |
{
|
|
52 |
return ETrue;
|
|
53 |
}
|
|
54 |
|
|
55 |
// - Construction -----------------------------------------------------------
|
|
56 |
|
|
57 |
ut_cphoneconferenceandwaiting* ut_cphoneconferenceandwaiting::NewL()
|
|
58 |
{
|
|
59 |
ut_cphoneconferenceandwaiting* self = ut_cphoneconferenceandwaiting::NewLC();
|
|
60 |
CleanupStack::Pop();
|
|
61 |
return self;
|
|
62 |
}
|
|
63 |
|
|
64 |
ut_cphoneconferenceandwaiting* ut_cphoneconferenceandwaiting::NewLC()
|
|
65 |
{
|
|
66 |
ut_cphoneconferenceandwaiting* self = new( ELeave ) ut_cphoneconferenceandwaiting();
|
|
67 |
CleanupStack::PushL( self );
|
|
68 |
self->ConstructL();
|
|
69 |
return self;
|
|
70 |
}
|
|
71 |
|
|
72 |
ut_cphoneconferenceandwaiting::~ut_cphoneconferenceandwaiting()
|
|
73 |
{
|
|
74 |
CSmcMockContext::Release();
|
|
75 |
}
|
|
76 |
|
|
77 |
ut_cphoneconferenceandwaiting::ut_cphoneconferenceandwaiting()
|
|
78 |
{
|
|
79 |
}
|
|
80 |
|
|
81 |
void ut_cphoneconferenceandwaiting::ConstructL()
|
|
82 |
{
|
|
83 |
CEUnitTestSuiteClass::ConstructL();
|
|
84 |
iMockContext = CSmcMockContext::InstanceL();
|
|
85 |
}
|
|
86 |
|
|
87 |
// - Test methods -----------------------------------------------------------
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
void ut_cphoneconferenceandwaiting::SetupL( )
|
|
92 |
{
|
|
93 |
iMockContext->InitializeL();
|
|
94 |
|
|
95 |
iCPhoneMainResourceResolverMock = new ( ELeave ) CPhoneMainResourceResolverMock();
|
|
96 |
SmcDefaultValue<CPhoneMainResourceResolver*>::SetL( iCPhoneMainResourceResolverMock );
|
|
97 |
|
|
98 |
iViewCmdHandleMock = new CPhoneViewCommandHandleMock();
|
|
99 |
iStateMachineMock = CPhoneStateMachineGSM::NewL( iViewCmdHandleMock );
|
|
100 |
|
78
|
101 |
iMockContext->ExpectCallL( "PhoneCallUtil::CallIdByState" ).
|
74
|
102 |
ReturnsL( 2 );
|
|
103 |
iStateConferenceAndWaiting = CPhoneConferenceAndWaiting::NewL(
|
|
104 |
iStateMachineMock, iViewCmdHandleMock, NULL );
|
|
105 |
|
78
|
106 |
iMockContext->Reset();
|
74
|
107 |
}
|
|
108 |
|
|
109 |
void ut_cphoneconferenceandwaiting::Setup_NoRingingCallIdL( )
|
|
110 |
{
|
|
111 |
iMockContext->InitializeL();
|
|
112 |
|
|
113 |
iCPhoneMainResourceResolverMock = new ( ELeave ) CPhoneMainResourceResolverMock();
|
|
114 |
SmcDefaultValue<CPhoneMainResourceResolver*>::SetL( iCPhoneMainResourceResolverMock );
|
|
115 |
|
|
116 |
iViewCmdHandleMock = new CPhoneViewCommandHandleMock();
|
|
117 |
iStateMachineMock = CPhoneStateMachineGSM::NewL( iViewCmdHandleMock );
|
|
118 |
|
78
|
119 |
iMockContext->ExpectCallL( "PhoneCallUtil::CallIdByState" ).
|
74
|
120 |
ReturnsL( -1 );
|
|
121 |
iStateConferenceAndWaiting = CPhoneConferenceAndWaiting::NewL(
|
|
122 |
iStateMachineMock, iViewCmdHandleMock, NULL );
|
78
|
123 |
iMockContext->Reset();
|
74
|
124 |
}
|
|
125 |
|
|
126 |
|
|
127 |
void ut_cphoneconferenceandwaiting::Teardown( )
|
|
128 |
{
|
|
129 |
|
|
130 |
delete iStateConferenceAndWaiting;
|
|
131 |
iStateConferenceAndWaiting = NULL;
|
|
132 |
delete iStateMachineMock;
|
|
133 |
iStateMachineMock = NULL;
|
|
134 |
delete iViewCmdHandleMock;
|
|
135 |
iViewCmdHandleMock = NULL;
|
|
136 |
delete iCPhoneMainResourceResolverMock;
|
|
137 |
iCPhoneMainResourceResolverMock = NULL;
|
|
138 |
|
|
139 |
SmcDefaultValue<CPhoneMainResourceResolver*>::Reset();
|
|
140 |
|
|
141 |
iMockContext->Reset();
|
|
142 |
}
|
|
143 |
|
|
144 |
// -----------------------------------------------------------------------------
|
|
145 |
// Test construction
|
|
146 |
// -----------------------------------------------------------------------------
|
|
147 |
//
|
|
148 |
void ut_cphoneconferenceandwaiting::T_ConstructionL()
|
|
149 |
{
|
|
150 |
// SetupL and Teardown does the test.
|
|
151 |
}
|
|
152 |
|
|
153 |
// -----------------------------------------------------------------------------
|
|
154 |
// Precontition: Conference and waiting calls
|
|
155 |
// Use case: User answer waiting call, waiting call connected
|
|
156 |
// -----------------------------------------------------------------------------
|
|
157 |
//
|
|
158 |
void ut_cphoneconferenceandwaiting::T_HandleConnected_1L( )
|
|
159 |
{
|
76
|
160 |
iMockContext->ExpectCallL( "CPhoneState::UpdateCallHeaderAndUiCommandsL" ).
|
|
161 |
WithL<TInt> ( 2 );
|
74
|
162 |
|
|
163 |
iMockContext->ExpectCallL( "CPhoneStateMachine::ChangeState" ).
|
|
164 |
WithL<TInt> ( EPhoneStateConferenceAndSingle );
|
|
165 |
|
|
166 |
iStateConferenceAndWaiting->HandlePhoneEngineMessageL( MEngineMonitor::EPEMessageConnected, 2 );
|
|
167 |
|
|
168 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
169 |
}
|
|
170 |
|
|
171 |
// -----------------------------------------------------------------------------
|
|
172 |
// Precontition: Conference(with 3 calls) and waiting calls
|
|
173 |
// Use case: Go one to one with conference member
|
|
174 |
// -----------------------------------------------------------------------------
|
|
175 |
//
|
|
176 |
void ut_cphoneconferenceandwaiting::T_HandleConnected_2L( )
|
|
177 |
{
|
76
|
178 |
iMockContext->ExpectCallL( "CPhoneState::UpdateCallHeader" ).
|
|
179 |
WithL<TInt> ( 0 );
|
74
|
180 |
|
|
181 |
iStateConferenceAndWaiting->HandlePhoneEngineMessageL( MEngineMonitor::EPEMessageConnected, 0 );
|
|
182 |
|
|
183 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
184 |
}
|
|
185 |
|
|
186 |
// -----------------------------------------------------------------------------
|
|
187 |
// Precontition: Conference and waiting calls
|
|
188 |
// Use case: idle message and no confecence and no active calls
|
|
189 |
// -----------------------------------------------------------------------------
|
|
190 |
//
|
|
191 |
void ut_cphoneconferenceandwaiting::T_HandleIdleL_1()
|
|
192 |
{
|
|
193 |
//No conference call
|
|
194 |
iMockContext->ExpectCallL( "TPhoneCmdParamBoolean::Boolean" ).
|
|
195 |
ReturnsL( EFalse );
|
|
196 |
|
|
197 |
//Active call count
|
|
198 |
iMockContext->ExpectCallL( "TPhoneCmdParamInteger::Integer" ).
|
|
199 |
ReturnsL( 0 );
|
|
200 |
|
|
201 |
iMockContext->ExpectCallL( "CPhoneStateMachine::ChangeState" ).
|
|
202 |
WithL<TInt> ( EPhoneStateIncoming );
|
|
203 |
|
|
204 |
iStateConferenceAndWaiting->HandlePhoneEngineMessageL( MEngineMonitor::EPEMessageIdle, 0 );
|
|
205 |
|
|
206 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
207 |
}
|
|
208 |
|
|
209 |
// -----------------------------------------------------------------------------
|
|
210 |
// Precontition: Conference and waiting calls
|
|
211 |
// Use case: idle message and no confecence and one active call
|
|
212 |
// -----------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
void ut_cphoneconferenceandwaiting::T_HandleIdleL_2()
|
|
215 |
{
|
|
216 |
//No conference call
|
|
217 |
iMockContext->ExpectCallL( "TPhoneCmdParamBoolean::Boolean" ).
|
|
218 |
ReturnsL( EFalse );
|
|
219 |
|
|
220 |
//Active call count
|
|
221 |
iMockContext->ExpectCallL( "TPhoneCmdParamInteger::Integer" ).
|
|
222 |
ReturnsL( 1 );
|
|
223 |
|
|
224 |
iMockContext->ExpectCallL( "CPhoneStateMachine::ChangeState" ).
|
|
225 |
WithL<TInt> ( EPhoneStateWaitingInSingle );
|
|
226 |
|
|
227 |
iStateConferenceAndWaiting->HandlePhoneEngineMessageL( MEngineMonitor::EPEMessageIdle, 0 );
|
|
228 |
|
|
229 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
230 |
}
|
|
231 |
|
|
232 |
// -----------------------------------------------------------------------------
|
|
233 |
// Precontition: Conference and waiting calls
|
|
234 |
// Use case: idle message and no confecence and two active call
|
|
235 |
// -----------------------------------------------------------------------------
|
|
236 |
//
|
|
237 |
void ut_cphoneconferenceandwaiting::T_HandleIdleL_3()
|
|
238 |
{
|
|
239 |
//No conference call
|
|
240 |
iMockContext->ExpectCallL( "TPhoneCmdParamBoolean::Boolean" ).
|
|
241 |
ReturnsL( EFalse );
|
|
242 |
|
|
243 |
//Active call count
|
|
244 |
iMockContext->ExpectCallL( "TPhoneCmdParamInteger::Integer" ).
|
|
245 |
ReturnsL( 2 );
|
|
246 |
|
|
247 |
iMockContext->ExpectCallL( "CPhoneStateMachine::ChangeState" ).
|
|
248 |
WithL<TInt> ( EPhoneStateTwoSinglesAndWaiting );
|
|
249 |
|
|
250 |
iStateConferenceAndWaiting->HandlePhoneEngineMessageL( MEngineMonitor::EPEMessageIdle, 0 );
|
|
251 |
|
|
252 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
253 |
}
|
|
254 |
|
|
255 |
|
|
256 |
// -----------------------------------------------------------------------------
|
|
257 |
// Precontition: Conference and waiting calls
|
|
258 |
// Use case: idle message for waiting call
|
|
259 |
// -----------------------------------------------------------------------------
|
|
260 |
//
|
|
261 |
void ut_cphoneconferenceandwaiting::T_HandleIdleL_4()
|
|
262 |
{
|
|
263 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ).
|
|
264 |
WithL<TPhoneViewCommandId, TInt> ( EPhoneViewRemoveCallHeader, 2 );
|
|
265 |
|
|
266 |
iMockContext->ExpectCallL( "CPhoneStateMachine::ChangeState" ).
|
|
267 |
WithL<TInt> ( EPhoneStateConference );
|
|
268 |
|
|
269 |
iStateConferenceAndWaiting->HandlePhoneEngineMessageL( MEngineMonitor::EPEMessageIdle, 2 );
|
|
270 |
|
|
271 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
272 |
}
|
|
273 |
|
|
274 |
// -----------------------------------------------------------------------------
|
|
275 |
// Precontition: Conference and waiting calls
|
|
276 |
// Use case: User give command private
|
|
277 |
// -----------------------------------------------------------------------------
|
|
278 |
//
|
|
279 |
void ut_cphoneconferenceandwaiting::T_HandleWentOneToOne_1L()
|
|
280 |
{
|
|
281 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ).
|
|
282 |
WithL<TPhoneViewCommandId, TInt> ( EPhoneViewPrivateFromConference, 0 );
|
|
283 |
|
|
284 |
//Conference call exsist
|
|
285 |
iMockContext->ExpectCallL( "TPhoneCmdParamBoolean::Boolean" ).
|
|
286 |
ReturnsL( ETrue );
|
|
287 |
|
|
288 |
iMockContext->ExpectCallL( "CPhoneStateMachine::ChangeState" ).
|
|
289 |
WithL<TInt> ( EPhoneStateConferenceAndSingleAndWaiting );
|
|
290 |
|
|
291 |
iStateConferenceAndWaiting->HandlePhoneEngineMessageL( MEngineMonitor::EPEMessageWentOneToOne, 0 );
|
|
292 |
|
|
293 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
294 |
}
|
|
295 |
|
|
296 |
// - EUnit test table -------------------------------------------------------
|
|
297 |
|
|
298 |
EUNIT_BEGIN_TEST_TABLE(
|
|
299 |
ut_cphoneconferenceandwaiting,
|
|
300 |
"Add test suite description here.",
|
|
301 |
"UNIT" )
|
|
302 |
|
|
303 |
EUNIT_TEST(
|
|
304 |
"0- Test construction",
|
|
305 |
"",
|
|
306 |
"Test0",
|
|
307 |
"FUNCTIONALITY",
|
|
308 |
SetupL, T_ConstructionL, Teardown)
|
|
309 |
|
|
310 |
EUNIT_TEST(
|
|
311 |
"1- Test handle connecting",
|
|
312 |
"",
|
|
313 |
"Test0",
|
|
314 |
"FUNCTIONALITY",
|
|
315 |
SetupL, T_HandleConnected_1L, Teardown)
|
|
316 |
|
|
317 |
EUNIT_TEST(
|
|
318 |
"2- Test handle connecting",
|
|
319 |
"",
|
|
320 |
"Test0",
|
|
321 |
"FUNCTIONALITY",
|
|
322 |
SetupL, T_HandleConnected_2L, Teardown)
|
|
323 |
|
|
324 |
EUNIT_TEST(
|
|
325 |
"3- Test handle idle",
|
|
326 |
"",
|
|
327 |
"Test0",
|
|
328 |
"FUNCTIONALITY",
|
|
329 |
SetupL, T_HandleIdleL_1, Teardown)
|
|
330 |
|
|
331 |
EUNIT_TEST(
|
|
332 |
"4- Test handle idle",
|
|
333 |
"",
|
|
334 |
"Test0",
|
|
335 |
"FUNCTIONALITY",
|
|
336 |
SetupL, T_HandleIdleL_2, Teardown)
|
|
337 |
|
|
338 |
EUNIT_TEST(
|
|
339 |
"5- Test handle idle",
|
|
340 |
"",
|
|
341 |
"Test0",
|
|
342 |
"FUNCTIONALITY",
|
|
343 |
SetupL, T_HandleIdleL_3, Teardown)
|
|
344 |
|
|
345 |
EUNIT_TEST(
|
|
346 |
"6- Test handle idle",
|
|
347 |
"",
|
|
348 |
"Test0",
|
|
349 |
"FUNCTIONALITY",
|
|
350 |
SetupL, T_HandleIdleL_4, Teardown)
|
|
351 |
|
|
352 |
EUNIT_TEST(
|
|
353 |
"7- Test handle went one to one",
|
|
354 |
"",
|
|
355 |
"Test0",
|
|
356 |
"FUNCTIONALITY",
|
|
357 |
SetupL, T_HandleWentOneToOne_1L, Teardown)
|
|
358 |
|
|
359 |
EUNIT_END_TEST_TABLE
|