74
|
1 |
|
|
2 |
/*
|
|
3 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
* All rights reserved.
|
|
5 |
* This component and the accompanying materials are made available
|
|
6 |
* under the terms of "Eclipse Public License v1.0"
|
|
7 |
* which accompanies this distribution, and is available
|
|
8 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
9 |
*
|
|
10 |
* Initial Contributors:
|
|
11 |
* Nokia Corporation - initial contribution.
|
|
12 |
*
|
|
13 |
* Contributors:
|
|
14 |
*
|
|
15 |
* Description:
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
#include <csmcmockcontext.h>
|
|
19 |
#include <smcdefaultvalue.h>
|
|
20 |
#include <msmcmockspecbuilder.h>
|
|
21 |
#include <smcobjecttotypemapper.h>
|
|
22 |
#include <EUnitMacros.h>
|
|
23 |
#include <EUnitDecorators.h>
|
|
24 |
|
|
25 |
#include <phoneui.rsg>
|
|
26 |
|
|
27 |
#include "mock_cphoneviewcommandhandle.h"
|
|
28 |
#include "cphonestatemachine.h"
|
|
29 |
#include "ut_cphoneuicommandmanager.h"
|
|
30 |
#include "CPhoneCenRepProxy.h"
|
|
31 |
#include "cpeengineinfo.h"
|
|
32 |
#include "phonerssbase.h"
|
|
33 |
#include "CPhoneMainResourceResolver.h"
|
|
34 |
|
|
35 |
#include <csmcmockcontext.h>
|
|
36 |
#include <msmcmockspecbuilder.h>
|
|
37 |
|
|
38 |
#include "telephonyvariant.hrh"
|
|
39 |
#include "TPhoneCmdParamInteger.h"
|
|
40 |
#include "TPhoneCmdParamBoolean.h"
|
|
41 |
#include <startupdomainpskeys.h>
|
|
42 |
#include <hwrmdomainpskeys.h>
|
|
43 |
#include "tphonecmdparamcallstatedata.h"
|
|
44 |
#include "phoneresourceids.h"
|
|
45 |
|
|
46 |
CPhoneCenRepProxy* GlobalCPhoneCenRepProxy;
|
|
47 |
TPEPhoneAudioRouteParameters routeParameters;
|
|
48 |
|
|
49 |
// needed for mocking CPhoneMainResourceResolver::Instance()
|
|
50 |
class CPhoneMainResourceResolverMock : public CPhoneMainResourceResolver
|
|
51 |
{
|
|
52 |
|
|
53 |
};
|
|
54 |
|
|
55 |
// Class to access protected constructor
|
|
56 |
class CPhoneStateMachineMock : public CPhoneStateMachine
|
|
57 |
{
|
|
58 |
public:
|
|
59 |
CPhoneStateMachineMock( MPhoneViewCommandHandle* aViewCommandHandle )
|
|
60 |
: CPhoneStateMachine( aViewCommandHandle )
|
|
61 |
{
|
|
62 |
|
|
63 |
}
|
|
64 |
};
|
|
65 |
|
|
66 |
//---------------------------------------------------------------------------
|
|
67 |
|
|
68 |
//CONSTANS
|
|
69 |
_LIT( KTestString, "test_string" );
|
|
70 |
|
|
71 |
// - Construction -----------------------------------------------------------
|
|
72 |
|
|
73 |
ut_cphoneuicommandmanager* ut_cphoneuicommandmanager::NewL()
|
|
74 |
{
|
|
75 |
ut_cphoneuicommandmanager* self = ut_cphoneuicommandmanager::NewLC();
|
|
76 |
CleanupStack::Pop();
|
|
77 |
return self;
|
|
78 |
}
|
|
79 |
|
|
80 |
ut_cphoneuicommandmanager* ut_cphoneuicommandmanager::NewLC()
|
|
81 |
{
|
|
82 |
ut_cphoneuicommandmanager* self = new( ELeave ) ut_cphoneuicommandmanager();
|
|
83 |
CleanupStack::PushL( self );
|
|
84 |
self->ConstructL();
|
|
85 |
return self;
|
|
86 |
}
|
|
87 |
|
|
88 |
ut_cphoneuicommandmanager::~ut_cphoneuicommandmanager()
|
|
89 |
{
|
|
90 |
CSmcMockContext::Release();
|
|
91 |
}
|
|
92 |
|
|
93 |
ut_cphoneuicommandmanager::ut_cphoneuicommandmanager()
|
|
94 |
{
|
|
95 |
}
|
|
96 |
|
|
97 |
void ut_cphoneuicommandmanager::ConstructL()
|
|
98 |
{
|
|
99 |
CEUnitTestSuiteClass::ConstructL();
|
|
100 |
iMockContext = CSmcMockContext::InstanceL();
|
|
101 |
}
|
|
102 |
|
|
103 |
// - Test methods -----------------------------------------------------------
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
void ut_cphoneuicommandmanager::SetupL( )
|
|
108 |
{
|
|
109 |
iViewCmdHandleMock = new CPhoneViewCommandHandleMock();
|
|
110 |
iStateMachineMock = new (ELeave) CPhoneStateMachineMock( iViewCmdHandleMock );
|
|
111 |
iCustomization = NULL;
|
|
112 |
iPhoneStateMock = new (ELeave) CPhoneState(iStateMachineMock, iViewCmdHandleMock, iCustomization );
|
|
113 |
iCmdManager = CPhoneUiCommandManager::NewL(
|
|
114 |
iPhoneStateMock,
|
|
115 |
*iViewCmdHandleMock,
|
|
116 |
*iStateMachineMock );
|
|
117 |
|
|
118 |
iCPhoneMainResourceResolverMock = new ( ELeave ) CPhoneMainResourceResolverMock();
|
|
119 |
SmcDefaultValue<CPhoneMainResourceResolver*>::SetL( iCPhoneMainResourceResolverMock );
|
|
120 |
|
|
121 |
GlobalCPhoneCenRepProxy = NULL;
|
|
122 |
|
|
123 |
iEngineInfoMock = CPEEngineInfo::NewL();
|
|
124 |
SmcDefaultValue<MPEEngineInfo*>::SetL( iEngineInfoMock );
|
|
125 |
|
|
126 |
SmcDefaultValue<const TPESimState&>::SetL( EPESimUsable );
|
|
127 |
SmcDefaultValue<const TPEAudioOutput&>::SetL( EPENotActive );
|
|
128 |
SmcDefaultValue<const TPEPhoneAudioRouteParameters&>::SetL( routeParameters );
|
|
129 |
SmcDefaultValue<const TBool&>::SetL( EFalse );
|
|
130 |
}
|
|
131 |
|
|
132 |
void ut_cphoneuicommandmanager::Teardown( )
|
|
133 |
{
|
|
134 |
delete iCmdManager;
|
|
135 |
iCmdManager = NULL;
|
|
136 |
delete iPhoneStateMock;
|
|
137 |
iPhoneStateMock = NULL;
|
|
138 |
delete iViewCmdHandleMock;
|
|
139 |
iViewCmdHandleMock = NULL;
|
|
140 |
delete iStateMachineMock;
|
|
141 |
iStateMachineMock = NULL;
|
|
142 |
delete iCustomization;
|
|
143 |
iCustomization = NULL;
|
|
144 |
delete iCPhoneMainResourceResolverMock;
|
|
145 |
iCPhoneMainResourceResolverMock = NULL;
|
|
146 |
SmcDefaultValue<CPhoneMainResourceResolver*>::Reset();
|
|
147 |
iMockContext->Reset();
|
|
148 |
delete iEngineInfoMock;
|
|
149 |
iEngineInfoMock = NULL;
|
|
150 |
|
|
151 |
SmcDefaultValue<MPEEngineInfo*>::Reset();
|
|
152 |
SmcDefaultValue<const TPESimState&>::Reset();
|
|
153 |
SmcDefaultValue<const TPEAudioOutput&>::Reset();
|
|
154 |
SmcDefaultValue<const TPEPhoneAudioRouteParameters&>::Reset();
|
|
155 |
SmcDefaultValue<const TBool&>::Reset();
|
|
156 |
}
|
|
157 |
|
|
158 |
void ut_cphoneuicommandmanager::T_CPhoneUiCommandManager__EmptyL( )
|
|
159 |
{
|
|
160 |
//EMPTY CASE
|
|
161 |
}
|
|
162 |
|
|
163 |
/**
|
|
164 |
* Test name: T_UpdateUiCommands
|
|
165 |
*
|
|
166 |
* Use case: Client calls UpdateUiCommands check that SetButtonFlags/SetTouchButtons/SetToolBarButtons gets called.
|
|
167 |
* Motivation:
|
|
168 |
*/
|
|
169 |
void ut_cphoneuicommandmanager::T_UpdateUiCommands( )
|
|
170 |
{
|
78
|
171 |
/*expect call from SetButtonFlags*/
|
|
172 |
iMockContext->ExpectCallL( "PhoneCallUtil::CallIdByState" ).ReturnsL(KErrNotFound);
|
74
|
173 |
TPhoneCmdParamBoolean muteParam;
|
|
174 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommand" ).
|
|
175 |
WithL<TPhoneViewCommandId, TPhoneCommandParam&> ( EPhoneViewSetMuteFlag, muteParam );
|
|
176 |
|
|
177 |
/*expect call from SetTouchButtons*/
|
|
178 |
TPhoneCmdParamBoolean booleanParam;
|
|
179 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommand" ).
|
|
180 |
WithL<TPhoneViewCommandId, TPhoneCommandParam&> ( EPhoneViewSetTouchPaneButtons, booleanParam );
|
|
181 |
|
|
182 |
/*expect call from SetToolBarButtons*/
|
|
183 |
TPhoneCmdParamInteger integerParam;
|
|
184 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommand" ).
|
|
185 |
WithL<TPhoneViewCommandId, TPhoneCommandParam&> ( EPhoneViewUpdateCba, integerParam );
|
|
186 |
|
|
187 |
iCmdManager->UpdateUiCommands();
|
|
188 |
|
|
189 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
190 |
}
|
|
191 |
|
|
192 |
/**
|
|
193 |
* Test name: T_UpdateUiCommands
|
|
194 |
*
|
|
195 |
* Use case: Client calls UpdateUiCommands check that SetButtonFlags/SetTouchButtons/SetToolBarButtons gets called.
|
|
196 |
* Motivation:
|
|
197 |
*/
|
|
198 |
void ut_cphoneuicommandmanager::T_Set_Get_SoftRejectStatus( )
|
|
199 |
{
|
|
200 |
iCmdManager->SetSoftRejectStatus(ETrue);
|
|
201 |
EUNIT_ASSERT_EQUALS( ETrue, iCmdManager->SoftRejectStatus() );
|
|
202 |
}
|
|
203 |
|
|
204 |
// - EUnit test table -------------------------------------------------------
|
|
205 |
|
|
206 |
EUNIT_BEGIN_TEST_TABLE(
|
|
207 |
ut_cphoneuicommandmanager,
|
|
208 |
"Add test suite description here.",
|
|
209 |
"UNIT" )
|
|
210 |
|
|
211 |
EUNIT_TEST(
|
|
212 |
"1- ut_cphoneuicommandmanager",
|
|
213 |
"ut_cphoneuicommandmanager",
|
|
214 |
"1- Setup-teardown",
|
|
215 |
"FUNCTIONALITY",
|
|
216 |
SetupL, T_CPhoneUiCommandManager__EmptyL, Teardown)
|
|
217 |
|
|
218 |
EUNIT_TEST(
|
|
219 |
"2- ut_cphoneuicommandmanager",
|
|
220 |
"ut_cphoneuicommandmanager",
|
|
221 |
"2- T_UpdateUiCommands",
|
|
222 |
"FUNCTIONALITY",
|
|
223 |
SetupL, T_UpdateUiCommands, Teardown)
|
|
224 |
|
|
225 |
EUNIT_TEST(
|
|
226 |
"3- ut_cphoneuicommandmanager",
|
|
227 |
"ut_cphoneuicommandmanager",
|
|
228 |
"3- T_Set_Get_SoftRejectStatus",
|
|
229 |
"FUNCTIONALITY",
|
|
230 |
SetupL, T_Set_Get_SoftRejectStatus, Teardown)
|
|
231 |
|
|
232 |
EUNIT_END_TEST_TABLE
|