|
1 /* |
|
2 * Copyright (c) 2010 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 This file has been generated with EUnit Pro |
|
20 http://www.digia.com/eunit |
|
21 ----------------------------------------------------------------------------- |
|
22 */ |
|
23 #include "ut_cphoneerrormessageshandler.h" |
|
24 #include <coemain.h> |
|
25 #include <EUnitMacros.h> |
|
26 #include <EUnitDecorators.h> |
|
27 |
|
28 |
|
29 |
|
30 #include <csmcmockcontext.h> |
|
31 #include <msmcmockspecbuilder.h> |
|
32 #include "cphoneerrormessageshandler.h" |
|
33 #include "CPhoneStateMachineGSM.h" |
|
34 #include "mock_cphoneviewcommandhandle.h" |
|
35 #include "CPhoneMainErrorMessagesHandler.h" |
|
36 #include "cphonemainresourceresolver.h" |
|
37 #include "tphonecmdparamglobalnote.h" |
|
38 |
|
39 // needed for mocking CPhoneMainErrorMessagesHandler::Instance() |
|
40 class CPhoneMainErrorMessagesHandlerMock : public CPhoneMainErrorMessagesHandler |
|
41 { |
|
42 |
|
43 }; |
|
44 |
|
45 // needed for mocking CPhoneMainResourceResolver::Instance() |
|
46 class CPhoneMainResourceResolverMock : public CPhoneMainResourceResolver |
|
47 { |
|
48 |
|
49 }; |
|
50 |
|
51 |
|
52 // - Construction ----------------------------------------------------------- |
|
53 |
|
54 ut_cphoneerrormessageshandler* ut_cphoneerrormessageshandler::NewL() |
|
55 { |
|
56 ut_cphoneerrormessageshandler* self = ut_cphoneerrormessageshandler::NewLC(); |
|
57 CleanupStack::Pop(); |
|
58 return self; |
|
59 } |
|
60 |
|
61 ut_cphoneerrormessageshandler* ut_cphoneerrormessageshandler::NewLC() |
|
62 { |
|
63 ut_cphoneerrormessageshandler* self = new( ELeave ) ut_cphoneerrormessageshandler(); |
|
64 CleanupStack::PushL( self ); |
|
65 self->ConstructL(); |
|
66 return self; |
|
67 } |
|
68 |
|
69 ut_cphoneerrormessageshandler::~ut_cphoneerrormessageshandler() |
|
70 { |
|
71 CSmcMockContext::Release(); |
|
72 |
|
73 delete iCPhoneErrorMessagesHandler; |
|
74 delete iCoeEnvMock; |
|
75 delete iCPhoneMainErrorMessagesHandlerMock; |
|
76 delete iCPhoneMainResourceResolverMock; |
|
77 delete iEngineInfoMock; |
|
78 delete iViewCommandHandleMock; |
|
79 delete iStateMachineMock; |
|
80 } |
|
81 |
|
82 ut_cphoneerrormessageshandler::ut_cphoneerrormessageshandler() |
|
83 { |
|
84 } |
|
85 |
|
86 void ut_cphoneerrormessageshandler::ConstructL() |
|
87 { |
|
88 CEUnitTestSuiteClass::ConstructL(); |
|
89 iMockContext = CSmcMockContext::InstanceL(); |
|
90 } |
|
91 |
|
92 // - Test methods ----------------------------------------------------------- |
|
93 |
|
94 |
|
95 |
|
96 void ut_cphoneerrormessageshandler::SetupL( ) |
|
97 { |
|
98 iMockContext->InitializeL(); |
|
99 |
|
100 iCoeEnvMock = new ( ELeave ) CCoeEnv(); |
|
101 SmcDefaultValue<CCoeEnv*>::SetL( iCoeEnvMock ); |
|
102 CleanupResetDefaultValuePushL<SmcDefaultValue<CCoeEnv*> >(); |
|
103 |
|
104 iCPhoneMainErrorMessagesHandlerMock = new ( ELeave ) CPhoneMainErrorMessagesHandlerMock(); |
|
105 SmcDefaultValue<CPhoneMainErrorMessagesHandler*>::SetL( iCPhoneMainErrorMessagesHandlerMock ); |
|
106 |
|
107 iCPhoneMainResourceResolverMock = new ( ELeave ) CPhoneMainResourceResolverMock(); |
|
108 SmcDefaultValue<CPhoneMainResourceResolver*>::SetL( iCPhoneMainResourceResolverMock ); |
|
109 |
|
110 iEngineInfoMock = CPEEngineInfo::NewL(); |
|
111 SmcDefaultValue<MPEEngineInfo*>::SetL( iEngineInfoMock ); |
|
112 |
|
113 iViewCommandHandleMock = new CPhoneViewCommandHandleMock(); |
|
114 iStateMachineMock = CPhoneStateMachineGSM::NewL( iViewCommandHandleMock ); |
|
115 |
|
116 iCPhoneErrorMessagesHandler = CPhoneErrorMessagesHandler::NewL( iViewCommandHandleMock, iStateMachineMock); |
|
117 |
|
118 } |
|
119 |
|
120 void ut_cphoneerrormessageshandler::Teardown( ) |
|
121 { |
|
122 delete iCPhoneErrorMessagesHandler; |
|
123 iCPhoneErrorMessagesHandler = NULL; |
|
124 delete iStateMachineMock; |
|
125 iStateMachineMock = NULL; |
|
126 delete iViewCommandHandleMock; |
|
127 iViewCommandHandleMock = NULL; |
|
128 delete iEngineInfoMock; |
|
129 iEngineInfoMock = NULL; |
|
130 delete iCPhoneMainResourceResolverMock; |
|
131 iCPhoneMainResourceResolverMock = NULL; |
|
132 delete iCPhoneMainErrorMessagesHandlerMock; |
|
133 iCPhoneMainErrorMessagesHandlerMock = NULL; |
|
134 delete iCoeEnvMock; |
|
135 iCoeEnvMock = NULL; |
|
136 |
|
137 CleanupStack::PopAndDestroy(); |
|
138 |
|
139 SmcDefaultValue<CPhoneMainResourceResolver*>::Reset(); |
|
140 SmcDefaultValue<CPhoneMainErrorMessagesHandler*>::Reset(); |
|
141 |
|
142 iMockContext->Reset(); |
|
143 } |
|
144 |
|
145 void ut_cphoneerrormessageshandler::T_Global_ShowErrorSpecificNoteForVideoCallL( ) |
|
146 { |
|
147 TPEErrorInfo aErrorInfo; |
|
148 aErrorInfo.iErrorCode = ECCPErrorCCPreemption; |
|
149 aErrorInfo.iCallId = 1; |
|
150 const TInt KEnabled = 1; |
|
151 const TInt KCallId = 1; |
|
152 |
|
153 iEngineInfoMock->SetCallTypeCommand( EPECallTypeVideo ); |
|
154 iEngineInfoMock->SetCallType( EPECallTypeVideo, KCallId ); |
|
155 |
|
156 TPECallType type(EPECallTypeVideo); |
|
157 iMockContext->ExpectCallL("CPEEngineInfoImpl::CallType"). |
|
158 WithL(KCallId). |
|
159 ReturnsL(type); |
|
160 |
|
161 iMockContext-> |
|
162 ExpectCallL( "TPhoneCmdParamBoolean::SetBoolean" ). |
|
163 WithL( EFalse ); |
|
164 iMockContext-> |
|
165 ExpectCallL( "TPhoneCmdParamGlobalNote::SetType" ). |
|
166 WithL( EPhoneMessageBoxInformation ); |
|
167 iMockContext-> |
|
168 ExpectCallL( "CPhoneMainResourceResolver::ResolveResourceID" ). |
|
169 WithL<const TInt&>( EPhoneNoteCallInfoNotSupported ); |
|
170 iMockContext-> |
|
171 ExpectCallL( "TPhoneCmdParamGlobalNote::SetTextResourceId" ); |
|
172 |
|
173 iCPhoneErrorMessagesHandler->ShowErrorSpecificNoteL( aErrorInfo ); |
|
174 EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() ); |
|
175 } |
|
176 |
|
177 void ut_cphoneerrormessageshandler::T_Global_ShowErrorSpecificNoteForCsCallL( ) |
|
178 { |
|
179 TPEErrorInfo aErrorInfo; |
|
180 aErrorInfo.iErrorCode = ECCPErrorCCPreemption; |
|
181 aErrorInfo.iCallId = 1; |
|
182 const TInt KEnabled = 1; |
|
183 const TInt KCallId = 1; |
|
184 |
|
185 EUNIT_PRINT( _L("CPEEngineInfoImpl::CallType")); |
|
186 |
|
187 TPECallType type(EPECallTypeUninitialized); |
|
188 iMockContext->ExpectCallL("CPEEngineInfoImpl::CallType"). |
|
189 WithL(KCallId). |
|
190 ReturnsL(type); |
|
191 |
|
192 iEngineInfoMock->SetSimState(EPESimReadable); |
|
193 |
|
194 EUNIT_PRINT( _L("TPhoneCmdParamGlobalNote::SetType")); |
|
195 iMockContext-> |
|
196 ExpectCallL( "TPhoneCmdParamGlobalNote::SetType" ). |
|
197 WithL( EPhoneNotificationDialog ); |
|
198 |
|
199 iMockContext-> |
|
200 ExpectCallL( "CPhoneMainResourceResolver::ResolveResourceID" ). |
|
201 WithL<const TInt&>( EPhoneErrorInConnection ); |
|
202 |
|
203 iMockContext-> |
|
204 ExpectCallL( "TPhoneCmdParamGlobalNote::SetTextResourceId" ); |
|
205 EUNIT_PRINT( _L("iCPhoneErrorMessagesHandler->ShowErrorSpecificNoteL ->")); |
|
206 iCPhoneErrorMessagesHandler->ShowErrorSpecificNoteL( aErrorInfo ); |
|
207 EUNIT_PRINT( _L("iCPhoneErrorMessagesHandler->ShowErrorSpecificNoteL <-")); |
|
208 EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() ); |
|
209 } |
|
210 |
|
211 void ut_cphoneerrormessageshandler::VerifyNote( TPECallType aCallType, TCCPError aErrorCode, TPhoneRssBase aNote ) |
|
212 { |
|
213 TPEErrorInfo errorInfo; |
|
214 errorInfo.iErrorCode = aErrorCode; |
|
215 errorInfo.iCallId = 1; |
|
216 const TInt KEnabled = 1; |
|
217 const TInt KCallId = 1; |
|
218 |
|
219 iEngineInfoMock->SetSimState(EPESimReadable); |
|
220 iEngineInfoMock->SetCallTypeCommand( aCallType ); |
|
221 iEngineInfoMock->SetCallType( aCallType, KCallId ); |
|
222 |
|
223 iMockContext->ExpectCallL("CPEEngineInfoImpl::CallType"). |
|
224 WithL(KCallId). |
|
225 ReturnsL(aCallType). |
|
226 TimesL( ( aCallType == EPECallTypeCSVoice |
|
227 && aErrorCode == ECCPErrorCCCallRejected ) ? 2 : 1 ); |
|
228 |
|
229 iMockContext-> |
|
230 ExpectCallL( "CPhoneMainResourceResolver::ResolveResourceID" ). |
|
231 WithL<const TInt&>( aNote ). |
|
232 TimesL( aNote == EPhoneRssBaseLast ? 0 : 1 ); |
|
233 |
|
234 iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ). |
|
235 TimesL( aNote == EPhoneRssBaseLast ? 0 : 2 ); |
|
236 |
|
237 iCPhoneErrorMessagesHandler->ShowErrorSpecificNoteL( errorInfo ); |
|
238 EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() ); |
|
239 } |
|
240 |
|
241 void ut_cphoneerrormessageshandler::VerifyNoNote( TPECallType aCallType, TCCPError aErrorCode ) |
|
242 { |
|
243 TPEErrorInfo errorInfo; |
|
244 errorInfo.iErrorCode = aErrorCode; |
|
245 errorInfo.iCallId = 1; |
|
246 const TInt KEnabled = 1; |
|
247 const TInt KCallId = 1; |
|
248 |
|
249 iEngineInfoMock->SetCallTypeCommand( aCallType ); |
|
250 iEngineInfoMock->SetCallType( aCallType, KCallId ); |
|
251 |
|
252 iMockContext->ExpectCallL("CPEEngineInfoImpl::CallType"). |
|
253 WithL(KCallId). |
|
254 ReturnsL(aCallType); |
|
255 |
|
256 iMockContext->ExpectCallL( "CPhonePubSubProxy::Value" ). |
|
257 TimesL( 0 ). |
|
258 ReturnsL( KEnabled ); |
|
259 |
|
260 iMockContext-> |
|
261 ExpectCallL( "CPhoneMainResourceResolver::ResolveResourceID" ). |
|
262 TimesL( 0 ); |
|
263 |
|
264 iMockContext->ExpectCallL( "CPhoneViewCommandHandleMock::ExecuteCommandL" ). |
|
265 TimesL( 0 ); |
|
266 |
|
267 iCPhoneErrorMessagesHandler->ShowErrorSpecificNoteL( errorInfo ); |
|
268 |
|
269 EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() ); |
|
270 } |
|
271 |
|
272 void ut_cphoneerrormessageshandler::T_Global_ShowErrorSpecificNoteL( ) |
|
273 { |
|
274 iEngineInfoMock->SetSimState(EPESimReadable); |
|
275 // eCall type Error Note Resource |
|
276 EUNIT_PRINT( _L( "Video call and ECCPErrorServiceSettingError" ) ); |
|
277 VerifyNote( EPECallTypeVideo, ECCPErrorServiceSettingError, EPhoneNotePhoneOutOf3GCoverage ); |
|
278 iMockContext->Reset(); |
|
279 |
|
280 EUNIT_PRINT( _L( "CS Voice call and ECCPErrorServiceSettingError" ) ); |
|
281 iMockContext->InitializeL(); |
|
282 VerifyNote( EPECallTypeCSVoice, ECCPErrorServiceSettingError, EPhoneNoteTextCheckNetworkservices ); |
|
283 iMockContext->Reset(); |
|
284 |
|
285 EUNIT_PRINT( _L( "Video call and ECCPErrorCCNoRouteToDestination" ) ); |
|
286 iMockContext->InitializeL(); |
|
287 VerifyNote( EPECallTypeVideo, ECCPErrorCCNoRouteToDestination, EPhoneErrorInConnection ); |
|
288 iMockContext->Reset(); |
|
289 |
|
290 EUNIT_PRINT( _L( "CS Voice call and ECCPErrorCCNoRouteToDestination" ) ); |
|
291 iMockContext->InitializeL(); |
|
292 VerifyNote( EPECallTypeCSVoice, ECCPErrorCCNoRouteToDestination, EPhoneErrorInConnection ); |
|
293 iMockContext->Reset(); |
|
294 |
|
295 EUNIT_PRINT( _L( "Video call and ECCPErrorCCCallRejected" ) ); |
|
296 iMockContext->InitializeL(); |
|
297 VerifyNote( EPECallTypeVideo, ECCPErrorCCCallRejected, EPhoneNoteCalledNumberHasBarredIncomingCalls ); |
|
298 iMockContext->Reset(); |
|
299 |
|
300 EUNIT_PRINT( _L( "CS Voice call and ECCPErrorCCCallRejected" ) ); |
|
301 iMockContext->InitializeL(); |
|
302 VerifyNote( EPECallTypeCSVoice, ECCPErrorCCCallRejected, EPhoneNoteCalledNumberHasBarredIncomingCalls); |
|
303 iMockContext->Reset(); |
|
304 |
|
305 EUNIT_PRINT( _L( "Video call and ECCPErrorNoAnswerForVideo" ) ); |
|
306 iMockContext->InitializeL(); |
|
307 VerifyNote( EPECallTypeVideo, ECCPErrorNoAnswerForVideo, EPhoneNotePhoneOutOf3GCoverage ); |
|
308 iMockContext->Reset(); |
|
309 |
|
310 EUNIT_PRINT( _L( "CS Voice call and ECCPErrorNoAnswerForVideo" ) ); |
|
311 iMockContext->InitializeL(); |
|
312 VerifyNote( EPECallTypeCSVoice, ECCPErrorNoAnswerForVideo, EPhoneNoAnswer ); |
|
313 iMockContext->Reset(); |
|
314 |
|
315 EUNIT_PRINT( _L( "Video call and ECCPErrorCCRequestedFacilityNotSubscribed" ) ); |
|
316 iMockContext->InitializeL(); |
|
317 VerifyNote( EPECallTypeVideo, ECCPErrorCCRequestedFacilityNotSubscribed,EPhoneNoteVideoCallOnlyPossibleUnder3GCoverage ); |
|
318 iMockContext->Reset(); |
|
319 |
|
320 EUNIT_PRINT( _L( "CS Voice call and ECCPErrorCCRequestedFacilityNotSubscribed" ) ); |
|
321 iMockContext->InitializeL(); |
|
322 VerifyNote( EPECallTypeCSVoice, ECCPErrorCCRequestedFacilityNotSubscribed,EPhoneNoteTextNotAllowed ); |
|
323 iMockContext->Reset(); |
|
324 |
|
325 EUNIT_PRINT( _L( "Video call and ECCPErrorCCIncompatibleDestination" ) ); |
|
326 iMockContext->InitializeL(); |
|
327 VerifyNote( EPECallTypeVideo, ECCPErrorCCIncompatibleDestination, EPhoneNoteUnableToMakeVideoCallNotSupportedByOtherPhone ); |
|
328 iMockContext->Reset(); |
|
329 |
|
330 EUNIT_PRINT( _L( "CS Voice call and ECCPErrorCCIncompatibleDestination" ) ); |
|
331 iMockContext->InitializeL(); |
|
332 VerifyNote( EPECallTypeCSVoice, ECCPErrorCCIncompatibleDestination, EPhoneErrorInConnection ); |
|
333 iMockContext->Reset(); |
|
334 |
|
335 EUNIT_PRINT( _L( "Video call and ECCPErrorCCBearerCapabilityNotAuthorised" ) ); |
|
336 iMockContext->InitializeL(); |
|
337 VerifyNote( EPECallTypeVideo, ECCPErrorCCBearerCapabilityNotAuthorised, EPhoneNoteUnableToMakeVideoCallNotSupportedByOtherPhone ); |
|
338 iMockContext->Reset(); |
|
339 |
|
340 EUNIT_PRINT( _L( "CS Voice call and ECCPErrorCCBearerCapabilityNotAuthorised" ) ); |
|
341 iMockContext->InitializeL(); |
|
342 VerifyNote( EPECallTypeCSVoice, ECCPErrorCCBearerCapabilityNotAuthorised, EPhoneErrorInConnection ); |
|
343 iMockContext->Reset(); |
|
344 |
|
345 EUNIT_PRINT( _L( "Video call and ECCPErrorBadRequest" ) ); |
|
346 iMockContext->InitializeL(); |
|
347 VerifyNote( EPECallTypeVideo, ECCPErrorBadRequest, EPhoneNoteUnableToMakeVideoCallNotSupportedByOtherPhone ); |
|
348 iMockContext->Reset(); |
|
349 |
|
350 EUNIT_PRINT( _L( "CS Voice call and ECCPErrorBadRequest" ) ); |
|
351 iMockContext->InitializeL(); |
|
352 VerifyNote( EPECallTypeCSVoice, ECCPErrorBadRequest, EPhoneErrorInConnection ); |
|
353 } |
|
354 |
|
355 |
|
356 // - EUnit test table ------------------------------------------------------- |
|
357 |
|
358 EUNIT_BEGIN_TEST_TABLE( |
|
359 ut_cphoneerrormessageshandler, |
|
360 "Add test suite description here.", |
|
361 "UNIT" ) |
|
362 |
|
363 EUNIT_TEST( |
|
364 "ShowErrorSpecificNoteForVideoCallL - test1", |
|
365 "CPhoneErrorMessagesHandler", |
|
366 "ShowErrorSpecificNoteL - test1", |
|
367 "FUNCTIONALITY", |
|
368 SetupL, T_Global_ShowErrorSpecificNoteForVideoCallL, Teardown) |
|
369 |
|
370 EUNIT_TEST( |
|
371 "ShowErrorSpecificNoteForCsCallL - test2", |
|
372 "CPhoneErrorMessagesHandler", |
|
373 "ShowErrorSpecificNoteL - test2", |
|
374 "FUNCTIONALITY", |
|
375 SetupL, T_Global_ShowErrorSpecificNoteForCsCallL, Teardown) |
|
376 |
|
377 EUNIT_TEST( |
|
378 "ShowErrorSpecificNoteL - test3", |
|
379 "CPhoneErrorMessagesHandler", |
|
380 "ShowErrorSpecificNoteL - test3", |
|
381 "FUNCTIONALITY", |
|
382 SetupL, T_Global_ShowErrorSpecificNoteL, Teardown) |
|
383 |
|
384 EUNIT_END_TEST_TABLE |