78
|
1 |
/*
|
|
2 |
* Copyright (c) 2020 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_phonenoteutil.h"
|
|
19 |
#include "phonenoteutil.h"
|
|
20 |
#include <EUnitMacros.h>
|
|
21 |
#include <EUnitDecorators.h>
|
|
22 |
|
|
23 |
#include "CPhoneStateMachineGSM.h"
|
|
24 |
#include "mock_cphoneviewcommandhandle.h"
|
|
25 |
#include "CPEEngineInfo.h"
|
|
26 |
#include "cphonestateincall.h"
|
|
27 |
#include "cphonestatehandle.h"
|
|
28 |
#include "CPhoneCenRepProxy.h"
|
|
29 |
#include "CPhoneMainResourceResolver.h"
|
|
30 |
#include "tphonecmdparamnote.h"
|
|
31 |
#include "tphonecmdparamquery.h"
|
|
32 |
#include <EUnitMacros.h>
|
|
33 |
#include <EUnitDecorators.h>
|
|
34 |
#include "phoneui.hrh"
|
|
35 |
#include <csmcmockcontext.h>
|
|
36 |
#include <msmcmockspecbuilder.h>
|
|
37 |
#include <coemain.h>
|
|
38 |
#include <PhoneUI.rsg>
|
|
39 |
#include "phoneresourceids.h"
|
|
40 |
#include "phonerssbase.h"
|
|
41 |
#include "CPhoneTerminateAllConnectionsCommand.h"
|
|
42 |
#include "CPhoneMainErrorMessagesHandler.h"
|
|
43 |
|
|
44 |
// needed for mocking CPhoneMainResourceResolver::Instance()
|
|
45 |
class CPhoneMainResourceResolverMock : public CPhoneMainResourceResolver{};
|
|
46 |
|
|
47 |
class CPhoneMainErrorMessagesHandlerMock : public CPhoneMainErrorMessagesHandler
|
|
48 |
{
|
|
49 |
|
|
50 |
};
|
|
51 |
|
|
52 |
class CPhoneStateMachineGSMMock : public CPhoneStateMachineGSM{};
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
// - Construction -----------------------------------------------------------
|
|
58 |
|
|
59 |
ut_phonenoteutil* ut_phonenoteutil::NewL()
|
|
60 |
{
|
|
61 |
ut_phonenoteutil* self = ut_phonenoteutil::NewLC();
|
|
62 |
CleanupStack::Pop();
|
|
63 |
return self;
|
|
64 |
}
|
|
65 |
|
|
66 |
ut_phonenoteutil* ut_phonenoteutil::NewLC()
|
|
67 |
{
|
|
68 |
ut_phonenoteutil* self = new( ELeave ) ut_phonenoteutil();
|
|
69 |
CleanupStack::PushL( self );
|
|
70 |
self->ConstructL();
|
|
71 |
return self;
|
|
72 |
}
|
|
73 |
|
|
74 |
ut_phonenoteutil::~ut_phonenoteutil()
|
|
75 |
{
|
|
76 |
CSmcMockContext::Release();
|
|
77 |
}
|
|
78 |
|
|
79 |
ut_phonenoteutil::ut_phonenoteutil()
|
|
80 |
{
|
|
81 |
}
|
|
82 |
|
|
83 |
void ut_phonenoteutil::ConstructL()
|
|
84 |
{
|
|
85 |
CEUnitTestSuiteClass::ConstructL();
|
|
86 |
iMockContext = CSmcMockContext::InstanceL();
|
|
87 |
}
|
|
88 |
|
|
89 |
// - Test methods -----------------------------------------------------------
|
|
90 |
|
|
91 |
void ut_phonenoteutil::SetupL( )
|
|
92 |
{
|
|
93 |
iCPhoneMainResourceResolverMock = new ( ELeave ) CPhoneMainResourceResolverMock();
|
|
94 |
SmcDefaultValue<CPhoneMainResourceResolver*>::SetL( iCPhoneMainResourceResolverMock );
|
|
95 |
|
|
96 |
iCoeEnvMock = new (ELeave ) CCoeEnv();
|
|
97 |
SmcDefaultValue<CCoeEnv*>::SetL( iCoeEnvMock );
|
|
98 |
|
|
99 |
iViewCommandHandle = new CPhoneViewCommandHandleMock();
|
|
100 |
SmcDefaultValue<MPhoneViewCommandHandle*>::SetL( iViewCommandHandle );
|
|
101 |
|
|
102 |
iStateMachine = CPhoneStateMachineGSMMock::NewL(iViewCommandHandle);
|
|
103 |
SmcDefaultValue<MPhoneStateMachine*>::SetL( iStateMachine );
|
|
104 |
|
|
105 |
iCPhoneStateHandleMock = CPhoneStateHandle::
|
|
106 |
CreateL(iViewCommandHandle, _L("test"), TUid::Uid(1));
|
|
107 |
SmcDefaultValue<CPhoneStateHandle*>::SetL( iCPhoneStateHandleMock );
|
|
108 |
|
|
109 |
iCPhoneMainErrorMessagesHandlerMock = new ( ELeave ) CPhoneMainErrorMessagesHandlerMock();
|
|
110 |
SmcDefaultValue<CPhoneMainErrorMessagesHandler*>::SetL( iCPhoneMainErrorMessagesHandlerMock );
|
|
111 |
|
|
112 |
iEngineInfo = CPEEngineInfo::NewL();
|
|
113 |
SmcDefaultValue<MPEEngineInfo*>::SetL( iEngineInfo );
|
|
114 |
}
|
|
115 |
|
|
116 |
void ut_phonenoteutil::Teardown( )
|
|
117 |
{
|
|
118 |
delete iStateMachine;
|
|
119 |
iStateMachine = NULL;
|
|
120 |
SmcDefaultValue<MPhoneStateMachine*>::Reset();
|
|
121 |
|
|
122 |
delete iCPhoneStateHandleMock;
|
|
123 |
iCPhoneStateHandleMock = NULL;
|
|
124 |
SmcDefaultValue<CPhoneStateHandle*>::Reset();
|
|
125 |
|
|
126 |
delete iViewCommandHandle;
|
|
127 |
iViewCommandHandle = NULL;
|
|
128 |
SmcDefaultValue<MPhoneViewCommandHandle*>::Reset();
|
|
129 |
|
|
130 |
delete iEngineInfo;
|
|
131 |
iEngineInfo = NULL;
|
|
132 |
SmcDefaultValue<MPEEngineInfo*>::Reset();
|
|
133 |
|
|
134 |
delete iCoeEnvMock;
|
|
135 |
iCoeEnvMock = NULL;
|
|
136 |
SmcDefaultValue<CCoeEnv*>::Reset();
|
|
137 |
|
|
138 |
delete iCPhoneMainResourceResolverMock;
|
|
139 |
iCPhoneMainResourceResolverMock = NULL;
|
|
140 |
SmcDefaultValue<CPhoneMainResourceResolver*>::Reset();
|
|
141 |
|
|
142 |
delete iCPhoneMainErrorMessagesHandlerMock;
|
|
143 |
iCPhoneMainErrorMessagesHandlerMock = NULL;
|
|
144 |
SmcDefaultValue<CPhoneMainErrorMessagesHandler*>::Reset();
|
|
145 |
|
|
146 |
iMockContext->Reset();
|
|
147 |
}
|
|
148 |
|
|
149 |
void ut_phonenoteutil::T_ConstructionL( )
|
|
150 |
{
|
|
151 |
// SetupL and Teardown does the test.
|
|
152 |
}
|
|
153 |
|
|
154 |
void ut_phonenoteutil::T_SendGlobalInfoNoteL( )
|
|
155 |
{
|
|
156 |
TInt resource = 10;
|
|
157 |
TBool notification = ETrue;
|
|
158 |
|
|
159 |
TPhoneCmdParamGlobalNote globalNoteParam;
|
|
160 |
iMockContext->ExpectCallL( "CPhoneMainResourceResolver::ResolveResourceID" ).
|
|
161 |
WithL(resource).
|
|
162 |
ReturnsL(resource);
|
|
163 |
|
|
164 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ).
|
|
165 |
WithL<TPhoneViewCommandId, TPhoneCommandParam&> ( EPhoneViewShowGlobalNote, globalNoteParam );
|
|
166 |
|
|
167 |
PhoneNoteUtil::SendGlobalInfoNoteL( resource, notification);
|
|
168 |
|
|
169 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
170 |
iMockContext->Reset();
|
|
171 |
|
|
172 |
iMockContext->ExpectCallL( "CPhoneMainResourceResolver::ResolveResourceID" ).
|
|
173 |
WithL(resource).
|
|
174 |
ReturnsL(resource);
|
|
175 |
|
|
176 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ).
|
|
177 |
WithL<TPhoneViewCommandId, TPhoneCommandParam&> ( EPhoneViewShowGlobalNote, globalNoteParam );
|
|
178 |
|
|
179 |
PhoneNoteUtil::SendGlobalNoteL( resource, notification);
|
|
180 |
|
|
181 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
182 |
}
|
|
183 |
|
|
184 |
void ut_phonenoteutil::T_SendGlobalWarningNoteL( )
|
|
185 |
{
|
|
186 |
TInt resource = 10;
|
|
187 |
TBool notification = ETrue;
|
|
188 |
|
|
189 |
TPhoneCmdParamGlobalNote globalNoteParam;
|
|
190 |
iMockContext->ExpectCallL( "CPhoneMainResourceResolver::ResolveResourceID" ).
|
|
191 |
WithL(resource).
|
|
192 |
ReturnsL(resource);
|
|
193 |
|
|
194 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ).
|
|
195 |
WithL<TPhoneViewCommandId, TPhoneCommandParam&> ( EPhoneViewShowGlobalNote, globalNoteParam );
|
|
196 |
|
|
197 |
PhoneNoteUtil::SendGlobalWarningNoteL( resource, notification);
|
|
198 |
|
|
199 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
200 |
}
|
|
201 |
|
|
202 |
void ut_phonenoteutil::T_SendGlobalErrorNoteL( )
|
|
203 |
{
|
|
204 |
TInt resource = 10;
|
|
205 |
TBool notification = ETrue;
|
|
206 |
|
|
207 |
TPhoneCmdParamGlobalNote globalNoteParam;
|
|
208 |
iMockContext->ExpectCallL( "CPhoneMainResourceResolver::ResolveResourceID" ).
|
|
209 |
WithL(resource).
|
|
210 |
ReturnsL(resource);
|
|
211 |
|
|
212 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ).
|
|
213 |
WithL<TPhoneViewCommandId, TPhoneCommandParam&> ( EPhoneViewShowGlobalNote, globalNoteParam );
|
|
214 |
|
|
215 |
PhoneNoteUtil::SendGlobalErrorNoteL( resource, notification);
|
|
216 |
|
|
217 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
218 |
}
|
|
219 |
|
|
220 |
void ut_phonenoteutil::T_SendGlobalNoteL2( )
|
|
221 |
{
|
|
222 |
_LIT(KTestText,"test");
|
|
223 |
|
|
224 |
TPhoneCmdParamGlobalNote globalNoteParam;
|
|
225 |
|
|
226 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ).
|
|
227 |
WithL<TPhoneViewCommandId, TPhoneCommandParam&> ( EPhoneViewShowGlobalNote, globalNoteParam );
|
|
228 |
|
|
229 |
PhoneNoteUtil::SendGlobalNoteL( EPhoneNotificationDialog, KTestText());
|
|
230 |
|
|
231 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
232 |
}
|
|
233 |
|
|
234 |
void ut_phonenoteutil::T_ShowNoteAndQueryL( )
|
|
235 |
{
|
|
236 |
TInt resource = 10;
|
|
237 |
TPhoneCmdParamNote noteParam;
|
|
238 |
TPhoneCmdParamQuery queryParam;
|
|
239 |
|
|
240 |
// Test ShowNoteL
|
|
241 |
iMockContext->ExpectCallL( "CPhoneMainResourceResolver::ResolveResourceID" ).
|
|
242 |
WithL(resource).
|
|
243 |
ReturnsL(resource);
|
|
244 |
|
|
245 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ).
|
|
246 |
WithL<TPhoneViewCommandId, TPhoneCommandParam&> ( EPhoneViewShowNote, noteParam );
|
|
247 |
|
|
248 |
PhoneNoteUtil::ShowNoteL( resource );
|
|
249 |
|
|
250 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
251 |
iMockContext->Reset();
|
|
252 |
|
|
253 |
// Test ShowQueryL
|
|
254 |
iMockContext->ExpectCallL( "CPhoneMainResourceResolver::ResolveResourceID" ).
|
|
255 |
WithL(resource).
|
|
256 |
ReturnsL(resource);
|
|
257 |
|
|
258 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ).
|
|
259 |
WithL<TPhoneViewCommandId, TPhoneCommandParam&> ( EPhoneViewShowQuery, queryParam );
|
|
260 |
|
|
261 |
PhoneNoteUtil::ShowQueryL( resource );
|
|
262 |
|
|
263 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
264 |
iMockContext->Reset();
|
|
265 |
|
|
266 |
HBufC* emptyString = HBufC::NewLC( KPhoneNumberEntryBufferSize );
|
|
267 |
TPtr ptr( emptyString->Des() );
|
|
268 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ).
|
|
269 |
WithL<TPhoneViewCommandId, TPhoneCommandParam&> ( EPhoneViewShowQuery, queryParam );
|
|
270 |
|
|
271 |
PhoneNoteUtil::ShowTextQueryL(resource,resource,resource,&ptr,ETrue);
|
|
272 |
|
|
273 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
274 |
CleanupStack::PopAndDestroy( emptyString );
|
|
275 |
}
|
|
276 |
|
|
277 |
void ut_phonenoteutil::T_HandleErrorL( )
|
|
278 |
{
|
|
279 |
TPEErrorInfo errorInfo;
|
|
280 |
|
|
281 |
iMockContext->ExpectCallL( "CPhoneMainErrorMessagesHandler::ShowErrorSpecificNoteL" ).
|
|
282 |
WithL<TPEErrorInfo&> ( errorInfo );
|
|
283 |
iMockContext->ExpectCallL( "CPhoneClearBlacklist::ClearBlackListOnNextKey" );
|
|
284 |
PhoneNoteUtil::HandleErrorL(errorInfo);
|
|
285 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
286 |
iMockContext->Reset();
|
|
287 |
|
|
288 |
errorInfo.iErrorCode = ECCPErrorNoService;
|
|
289 |
iMockContext->ExpectCallL( "CPhoneMainErrorMessagesHandler::ShowErrorSpecificNoteL" ).
|
|
290 |
WithL<TPEErrorInfo&> ( errorInfo );
|
|
291 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ).
|
|
292 |
WithL( EPhoneViewHideNaviPaneAudioVolume );
|
|
293 |
iMockContext->ExpectCallL( "CPhoneClearBlacklist::ClearBlackListOnNextKey" );
|
|
294 |
PhoneNoteUtil::HandleErrorL(errorInfo);
|
|
295 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
296 |
iMockContext->Reset();
|
|
297 |
|
|
298 |
errorInfo.iErrorCode = ECCPErrorSatControl;
|
|
299 |
iMockContext->ExpectCallL( "CPhoneMainErrorMessagesHandler::ShowErrorSpecificNoteL" ).
|
|
300 |
WithL<TPEErrorInfo&> ( errorInfo );
|
|
301 |
iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ).
|
|
302 |
WithL( EPhoneViewClearNumberEntryContent );
|
|
303 |
iMockContext->ExpectCallL( "CPhoneClearBlacklist::ClearBlackListOnNextKey" );
|
|
304 |
PhoneNoteUtil::HandleErrorL(errorInfo);
|
|
305 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
306 |
iMockContext->Reset();
|
|
307 |
}
|
|
308 |
|
|
309 |
void ut_phonenoteutil::T_HandleRemoteBusyNoteL( )
|
|
310 |
{
|
|
311 |
TInt callId = 1;
|
|
312 |
iMockContext->ExpectCallL( "CPhoneMainErrorMessagesHandler::ShowErrorSpecificNoteL" );
|
|
313 |
PhoneNoteUtil::HandleRemoteBusyNoteL(callId);
|
|
314 |
EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
|
|
315 |
}
|
|
316 |
|
|
317 |
// - EUnit test table -------------------------------------------------------
|
|
318 |
|
|
319 |
EUNIT_BEGIN_TEST_TABLE(
|
|
320 |
ut_phonenoteutil,
|
|
321 |
"Add test suite description here.",
|
|
322 |
"UNIT" )
|
|
323 |
|
|
324 |
EUNIT_TEST(
|
|
325 |
"Test0",
|
|
326 |
"T_ConstructionL",
|
|
327 |
"Test0",
|
|
328 |
"FUNCTIONALITY",
|
|
329 |
SetupL, T_ConstructionL, Teardown)
|
|
330 |
|
|
331 |
EUNIT_TEST(
|
|
332 |
"Test1",
|
|
333 |
"T_SendGlobalInfoNoteL",
|
|
334 |
"Test1",
|
|
335 |
"FUNCTIONALITY",
|
|
336 |
SetupL, T_SendGlobalInfoNoteL, Teardown)
|
|
337 |
|
|
338 |
EUNIT_TEST(
|
|
339 |
"Test2",
|
|
340 |
"T_SendGlobalWarningNoteL",
|
|
341 |
"Test2",
|
|
342 |
"FUNCTIONALITY",
|
|
343 |
SetupL, T_SendGlobalWarningNoteL, Teardown)
|
|
344 |
|
|
345 |
EUNIT_TEST(
|
|
346 |
"Test3",
|
|
347 |
"T_SendGlobalErrorNoteL",
|
|
348 |
"Test3",
|
|
349 |
"FUNCTIONALITY",
|
|
350 |
SetupL, T_SendGlobalErrorNoteL, Teardown)
|
|
351 |
|
|
352 |
EUNIT_TEST(
|
|
353 |
"Test4",
|
|
354 |
"T_SendGlobalNoteL2",
|
|
355 |
"Test4",
|
|
356 |
"FUNCTIONALITY",
|
|
357 |
SetupL, T_SendGlobalNoteL2, Teardown)
|
|
358 |
|
|
359 |
EUNIT_TEST(
|
|
360 |
"Test5",
|
|
361 |
"T_ShowNoteAndQueryL",
|
|
362 |
"Test5",
|
|
363 |
"FUNCTIONALITY",
|
|
364 |
SetupL, T_ShowNoteAndQueryL, Teardown)
|
|
365 |
|
|
366 |
EUNIT_TEST(
|
|
367 |
"Test6",
|
|
368 |
"T_HandleRemoteBusyNoteL",
|
|
369 |
"Test6",
|
|
370 |
"FUNCTIONALITY",
|
|
371 |
SetupL, T_HandleRemoteBusyNoteL, Teardown)
|
|
372 |
|
|
373 |
EUNIT_TEST(
|
|
374 |
"Test7",
|
|
375 |
"T_HandleErrorL",
|
|
376 |
"Test7",
|
|
377 |
"FUNCTIONALITY",
|
|
378 |
SetupL, T_HandleErrorL, Teardown)
|
|
379 |
|
|
380 |
EUNIT_END_TEST_TABLE
|