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_cphconfandwaitingandcallsetup.h"
|
|
19 |
#include <EUnitMacros.h>
|
|
20 |
#include <EUnitDecorators.h>
|
|
21 |
#include <featmgr.h>
|
|
22 |
#include "CPhoneConferenceAndWaitingAndCallSetup.h"
|
|
23 |
#include "PEVirtualEngine.h"
|
|
24 |
#include "MPhoneKeyEvents.h"
|
|
25 |
#include "TPhoneCommandParam.h"
|
|
26 |
#include "CPhoneMainResourceResolver.h"
|
|
27 |
|
|
28 |
#include <coemain.h>
|
|
29 |
#include <csmcmockcontext.h>
|
|
30 |
#include <smcdefaultvalue.h>
|
|
31 |
#include <msmcmockspecbuilder.h>
|
|
32 |
#include <smcobjecttotypemapper.h>
|
|
33 |
|
|
34 |
#include "cphonestatemachinegsm.h"
|
|
35 |
#include "mock_cphoneviewcommandhandle.h"
|
|
36 |
|
|
37 |
#include "cpeengineinfo.h"
|
|
38 |
#include "cpeengineinfoimpl.h"
|
|
39 |
|
|
40 |
#include "tphonecmdparamcallheaderdata.h"
|
|
41 |
|
|
42 |
// needed for mocking CPhoneMainResourceResolver::Instance()
|
|
43 |
class CPhoneMainResourceResolverMock : public CPhoneMainResourceResolver
|
|
44 |
{
|
|
45 |
};
|
|
46 |
|
|
47 |
// - Construction -----------------------------------------------------------
|
|
48 |
|
|
49 |
ut_cphconfandwaitingandcallsetup* ut_cphconfandwaitingandcallsetup::NewL()
|
|
50 |
{
|
|
51 |
ut_cphconfandwaitingandcallsetup* self = ut_cphconfandwaitingandcallsetup::NewLC();
|
|
52 |
CleanupStack::Pop();
|
|
53 |
return self;
|
|
54 |
}
|
|
55 |
|
|
56 |
ut_cphconfandwaitingandcallsetup* ut_cphconfandwaitingandcallsetup::NewLC()
|
|
57 |
{
|
|
58 |
ut_cphconfandwaitingandcallsetup* self = new( ELeave ) ut_cphconfandwaitingandcallsetup();
|
|
59 |
CleanupStack::PushL( self );
|
|
60 |
self->ConstructL();
|
|
61 |
return self;
|
|
62 |
}
|
|
63 |
|
|
64 |
ut_cphconfandwaitingandcallsetup::~ut_cphconfandwaitingandcallsetup()
|
|
65 |
{
|
|
66 |
CSmcMockContext::Release();
|
|
67 |
}
|
|
68 |
|
|
69 |
ut_cphconfandwaitingandcallsetup::ut_cphconfandwaitingandcallsetup()
|
|
70 |
{
|
|
71 |
}
|
|
72 |
|
|
73 |
void ut_cphconfandwaitingandcallsetup::ConstructL()
|
|
74 |
{
|
|
75 |
CEUnitTestSuiteClass::ConstructL();
|
|
76 |
iMockContext = CSmcMockContext::InstanceL();
|
|
77 |
}
|
|
78 |
|
|
79 |
// - Test methods -----------------------------------------------------------
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
void ut_cphconfandwaitingandcallsetup::SetupL( )
|
|
84 |
{
|
|
85 |
iMockContext->InitializeL();
|
|
86 |
|
|
87 |
iCPhoneMainResourceResolverMock = new ( ELeave ) CPhoneMainResourceResolverMock();
|
|
88 |
SmcDefaultValue<CPhoneMainResourceResolver*>::SetL( iCPhoneMainResourceResolverMock );
|
|
89 |
|
|
90 |
iViewCommandHandleMock = new CPhoneViewCommandHandleMock();
|
|
91 |
iStateMachineMock = CPhoneStateMachineGSM::NewL( iViewCommandHandleMock );
|
|
92 |
iStateConferenceAndCallSetupAndWaiting = CPhoneConferenceAndWaitingAndCallSetup::NewL(
|
|
93 |
iStateMachineMock, iViewCommandHandleMock, NULL );
|
|
94 |
|
|
95 |
iCoeEnvMock = new (ELeave ) CCoeEnv();
|
|
96 |
SmcDefaultValue<CCoeEnv*>::SetL( iCoeEnvMock );
|
|
97 |
|
|
98 |
iEngineInfoMock = CPEEngineInfo::NewL();
|
|
99 |
SmcDefaultValue<MPEEngineInfo*>::SetL( iEngineInfoMock );
|
|
100 |
}
|
|
101 |
|
|
102 |
|
|
103 |
void ut_cphconfandwaitingandcallsetup::Teardown( )
|
|
104 |
{
|
|
105 |
delete iCPhoneMainResourceResolverMock;
|
|
106 |
iCPhoneMainResourceResolverMock = NULL;
|
|
107 |
SmcDefaultValue<CPhoneMainResourceResolver*>::Reset();
|
|
108 |
|
|
109 |
delete iStateConferenceAndCallSetupAndWaiting;
|
|
110 |
delete iViewCommandHandleMock;
|
|
111 |
delete iStateMachineMock;
|
|
112 |
|
|
113 |
delete iCoeEnvMock;
|
|
114 |
iCoeEnvMock = NULL;
|
|
115 |
SmcDefaultValue<CCoeEnv*>::Reset();
|
|
116 |
|
|
117 |
delete iEngineInfoMock;
|
|
118 |
iEngineInfoMock = NULL;
|
|
119 |
SmcDefaultValue<MPEEngineInfo*>::Reset();
|
|
120 |
|
|
121 |
iMockContext->Reset();
|
|
122 |
}
|
|
123 |
|
|
124 |
// -----------------------------------------------------------------------------
|
|
125 |
// Test conference and waiting state in connecting
|
|
126 |
// -check commands
|
|
127 |
// -----------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
void ut_cphconfandwaitingandcallsetup::T_HandleConnectedL( )
|
|
130 |
{
|
|
131 |
TInt callId(2);
|
|
132 |
TPhoneCmdParamCallHeaderData callHeaderParam;
|
|
133 |
callHeaderParam.SetCallState( EPEStateConnected );
|
76
|
134 |
iMockContext->ExpectCallL( "CPhoneState::UpdateCallHeader" ).
|
|
135 |
WithL<TInt> ( callId );
|
74
|
136 |
|
|
137 |
iStateConferenceAndCallSetupAndWaiting->HandlePhoneEngineMessageL( MEngineMonitor::EPEMessageConnected, callId );
|
|
138 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
139 |
}
|
|
140 |
|
|
141 |
// -----------------------------------------------------------------------------
|
|
142 |
// Test idle
|
|
143 |
// -check commands
|
|
144 |
// -----------------------------------------------------------------------------
|
|
145 |
//
|
|
146 |
void ut_cphconfandwaitingandcallsetup::T_HandleIdleL()
|
|
147 |
{
|
|
148 |
TInt callId(0);
|
|
149 |
TPhoneCmdParamBoolean conferenceExistsForCallId;
|
|
150 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ).
|
|
151 |
WithL<TPhoneViewCommandId, TInt, TPhoneCommandParam&> (
|
|
152 |
EPhoneViewGetCallExistsInConference,
|
|
153 |
callId,
|
|
154 |
conferenceExistsForCallId );
|
|
155 |
|
|
156 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ).
|
|
157 |
WithL<TPhoneViewCommandId, TInt>( EPhoneViewRemoveCallHeader, callId );
|
|
158 |
|
|
159 |
iStateConferenceAndCallSetupAndWaiting->HandlePhoneEngineMessageL( MEngineMonitor::EPEMessageIdle, 0 );
|
|
160 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
161 |
}
|
|
162 |
|
|
163 |
// -----------------------------------------------------------------------------
|
|
164 |
// Test conference idle
|
|
165 |
// -check commands
|
|
166 |
// -----------------------------------------------------------------------------
|
|
167 |
//
|
|
168 |
void ut_cphconfandwaitingandcallsetup::T_HandleConferenceIdleL( )
|
|
169 |
{
|
|
170 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ).
|
|
171 |
WithL( EPhoneViewRemoveConferenceBubble );
|
|
172 |
|
|
173 |
iStateConferenceAndCallSetupAndWaiting->HandlePhoneEngineMessageL( MEngineMonitor::EPEMessageConferenceIdle, 0 );
|
|
174 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
175 |
}
|
|
176 |
|
|
177 |
|
|
178 |
// - EUnit test table -------------------------------------------------------
|
|
179 |
|
|
180 |
EUNIT_BEGIN_TEST_TABLE(
|
|
181 |
ut_cphconfandwaitingandcallsetup,
|
|
182 |
"Add test suite description here.",
|
|
183 |
"UNIT" )
|
|
184 |
|
|
185 |
EUNIT_TEST(
|
|
186 |
"1- Test handle connecting",
|
|
187 |
"",
|
|
188 |
"Test0",
|
|
189 |
"FUNCTIONALITY",
|
|
190 |
SetupL, T_HandleConnectedL, Teardown)
|
|
191 |
|
|
192 |
EUNIT_TEST(
|
|
193 |
"2- Test handle idle",
|
|
194 |
"",
|
|
195 |
"Test0",
|
|
196 |
"FUNCTIONALITY",
|
|
197 |
SetupL, T_HandleIdleL, Teardown)
|
|
198 |
|
|
199 |
EUNIT_TEST(
|
|
200 |
"3- Test handle conference idle",
|
|
201 |
"",
|
|
202 |
"Test0",
|
|
203 |
"FUNCTIONALITY",
|
|
204 |
SetupL, T_HandleConferenceIdleL, Teardown)
|
|
205 |
|
|
206 |
|
|
207 |
EUNIT_END_TEST_TABLE
|