|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include <ssm/ssmcommandlistresourcereader.h> |
|
23 #include <ssm/ssmstates.hrh> |
|
24 #include <ssm/ssmsubstates.hrh> |
|
25 #include <ssm/ssmstatemanager.h> |
|
26 |
|
27 // Include the header file for the class under test |
|
28 #include <ssm/starterclient.h> |
|
29 #include <ssm/startupdomainpskeys.h> |
|
30 #include <e32property.h> |
|
31 |
|
32 #include "ssmclayer.h" |
|
33 #include "startupadaptationcommands.h" |
|
34 |
|
35 #include "ssmdebug.h" |
|
36 |
|
37 #include "tclayer_step_startersession.h" |
|
38 |
|
39 //Include the test wrappers |
|
40 #include "adaptationcliwrapper.h" |
|
41 #include "ssmcmnwrapper.h" |
|
42 #include "featurediscoverywrapper.h" |
|
43 |
|
44 /** |
|
45 * Constructs a complete CClayerTestStarterSession object |
|
46 * @internalComponent |
|
47 */ |
|
48 CCLayerTestStarterSession::CCLayerTestStarterSession() |
|
49 { |
|
50 |
|
51 } |
|
52 |
|
53 /** |
|
54 * Releases any resources associated with this test |
|
55 * @internalComponent |
|
56 */ |
|
57 CCLayerTestStarterSession::~CCLayerTestStarterSession() |
|
58 { |
|
59 |
|
60 } |
|
61 |
|
62 /** |
|
63 * Test step preamble |
|
64 * @internalComponent |
|
65 */ |
|
66 TVerdict CCLayerTestStarterSession::doTestStepPreambleL() |
|
67 { |
|
68 return CTestStep::doTestStepPreambleL(); |
|
69 } |
|
70 |
|
71 /** |
|
72 * Test step - a single test step performs a series of tests. |
|
73 * |
|
74 * See the individual doTest... methods on this class for details of the tests. |
|
75 * |
|
76 * All these tests use a variety of wrapper classes which provide equivalent methods |
|
77 * for all the APIs that RStarterSession uses. These wrapper classes can be requested |
|
78 * (via static methods in the appropriate wrapper class) to modify their behaviour, |
|
79 * such as return errors. This allows the internals and error handling to be easily tested. |
|
80 * |
|
81 * @internalComponent |
|
82 */ |
|
83 TVerdict CCLayerTestStarterSession::doTestStepL() |
|
84 { |
|
85 INFO_PRINTF1(_L("Entering test for compatibility layer starter session")); |
|
86 __UHEAP_MARK; |
|
87 doTestConnectAndClose(); |
|
88 doTestSetState(); |
|
89 doTestRequestReset(); |
|
90 doTestRequestShutdown(); |
|
91 doTestRfForEmergencyCall(); |
|
92 doTestEndSplashScreen(); |
|
93 |
|
94 __UHEAP_MARKEND; |
|
95 INFO_PRINTF1(_L("Leaving test for compatibility layer starter session")); |
|
96 return TestStepResult(); |
|
97 } |
|
98 |
|
99 /** |
|
100 * Test step postamble |
|
101 * @internalComponent |
|
102 */ |
|
103 TVerdict CCLayerTestStarterSession::doTestStepPostambleL() |
|
104 { |
|
105 return CTestStep::doTestStepPostambleL(); |
|
106 } |
|
107 |
|
108 /** |
|
109 Old Test CaseID AFSS-CLAYER-0001 |
|
110 New Test CaseID DEVSRVS-SSREFPLUGINS-CLAYER-0001 |
|
111 */ |
|
112 |
|
113 void CCLayerTestStarterSession::doTestConnectAndClose() |
|
114 { |
|
115 INFO_PRINTF1(_L("Entering CCLayerTestStarterSession::doTestConnectAndClose()")); |
|
116 INFO_PRINTF1(_L("Close on undisconnected RStartSession")); |
|
117 RStarterSession starterSession; |
|
118 starterSession.Close(); |
|
119 |
|
120 // Set the next error returned from RSsmStateManager wrapper |
|
121 // This is to test that RStarterSession handles the return value from RSsmStateManager correctly |
|
122 SsmCmnWrapper::SetSsmStateManagerNextConnectReturn(KErrNotFound); |
|
123 |
|
124 INFO_PRINTF1(_L("Connect on RStarterSession with RSsmStateManger::Connect() failing")); |
|
125 TInt ret = starterSession.Connect(); |
|
126 TEST(ret == KErrNotFound); |
|
127 |
|
128 // Set the next error returned from RSsmStateManger |
|
129 SsmCmnWrapper::SetSsmStateManagerNextConnectReturn(KErrNone); |
|
130 |
|
131 INFO_PRINTF1(_L("Connect on RStarterSession with RSsmStateManger::Connect() successful")); |
|
132 ret = starterSession.Connect(); |
|
133 TEST(ret == KErrNone); |
|
134 // Check that the session connected correctly and copied across the handle |
|
135 TEST(starterSession.Handle() != KNullHandle); |
|
136 TEST(starterSession.Handle() == SsmCmnWrapper::SsmStateManagerHandle()); |
|
137 |
|
138 |
|
139 INFO_PRINTF1(_L("Close on connected RStartSession")); |
|
140 starterSession.Close(); |
|
141 TEST(starterSession.Handle() == KNullHandle); |
|
142 |
|
143 INFO_PRINTF1(_L("Double close on connected RStartSession")); |
|
144 starterSession.Close(); |
|
145 TEST(starterSession.Handle() == KNullHandle); |
|
146 |
|
147 INFO_PRINTF1(_L("Exiting CCLayerTestStarterSession::doTestConnectAndClose()")); |
|
148 } |
|
149 |
|
150 /** |
|
151 * This adjustment specifies how to convert start-up sub-states |
|
152 * to the states defined in StartupAdaptation::TGlobalState |
|
153 * |
|
154 * It is calculated using the same method specified in CSaaStateAdaptation::MapToStartupAdaptationState(), |
|
155 * see that method for further details. |
|
156 * |
|
157 * @internalComponent |
|
158 */ |
|
159 const TInt KStartupSubStateAdjustment = static_cast<TInt>(StartupAdaptation::ESWStateStartingUiServices) |
|
160 - static_cast<TInt>(ESsmStartupSubStateNonCritical); |
|
161 |
|
162 /** |
|
163 Old Test CaseID AFSS-CLAYER-0002 |
|
164 New Test CaseID DEVSRVS-SSREFPLUGINS-CLAYER-0001 |
|
165 */ |
|
166 |
|
167 void CCLayerTestStarterSession::doTestSetState() |
|
168 { |
|
169 INFO_PRINTF1(_L("Entering CCLayerTestStarterSession::doTestSetState()")); |
|
170 |
|
171 INFO_PRINTF1(_L("Connecting RStarterSession")); |
|
172 RStarterSession starterSession; |
|
173 TInt ret = starterSession.Connect(); |
|
174 TEST(ret == KErrNone); |
|
175 TEST(starterSession.Handle() != KNullHandle); |
|
176 TEST(starterSession.Handle() == SsmCmnWrapper::SsmStateManagerHandle()); |
|
177 |
|
178 INFO_PRINTF1(_L("Calling SetState(EAlarm)")); |
|
179 ret = starterSession.SetState(RStarterSession::EAlarm); |
|
180 TEST(ret == KErrNone); |
|
181 TEST(SsmCmnWrapper::GetLastMainStateRequest() == ESsmStartup); |
|
182 TEST(SsmCmnWrapper::GetLastSubStateRequest() == StartupAdaptation::ESWStateChargingToAlarm - KStartupSubStateAdjustment); |
|
183 |
|
184 INFO_PRINTF1(_L("Calling SetState(ECharging)")); |
|
185 ret = starterSession.SetState(RStarterSession::ECharging); |
|
186 TEST(ret == KErrNone); |
|
187 TEST(SsmCmnWrapper::GetLastMainStateRequest() == ESsmStartup); |
|
188 TEST(SsmCmnWrapper::GetLastSubStateRequest() == StartupAdaptation::ESWStateAlarmToCharging - KStartupSubStateAdjustment); |
|
189 |
|
190 INFO_PRINTF1(_L("Calling SetState(-1)")); |
|
191 ret = starterSession.SetState(static_cast<RStarterSession::TGlobalState>(-1)); |
|
192 TEST(ret == KErrArgument); |
|
193 |
|
194 INFO_PRINTF1(_L("Close on connected RStartSession")); |
|
195 starterSession.Close(); |
|
196 TEST(starterSession.Handle() == KNullHandle); |
|
197 |
|
198 INFO_PRINTF1(_L("Exiting CCLayerTestStarterSession::doTestSetState()")); |
|
199 } |
|
200 |
|
201 /** |
|
202 Old Test CaseID AFSS-CLAYER-0003 |
|
203 New Test CaseID DEVSRVS-SSREFPLUGINS-CLAYER-0001 |
|
204 */ |
|
205 |
|
206 void CCLayerTestStarterSession::doTestRequestReset() |
|
207 { |
|
208 INFO_PRINTF1(_L("Entering CCLayerTestStarterSession::doTestRequestReset()")); |
|
209 |
|
210 INFO_PRINTF1(_L("Connecting RStarterSession")); |
|
211 RStarterSession starterSession; |
|
212 TInt ret = starterSession.Connect(); |
|
213 TEST(ret == KErrNone); |
|
214 TEST(starterSession.Handle() != KNullHandle); |
|
215 TEST(starterSession.Handle() == SsmCmnWrapper::SsmStateManagerHandle()); |
|
216 |
|
217 |
|
218 INFO_PRINTF1(_L("Calling Reset(ELanguageSwitchReset)")); |
|
219 starterSession.Reset(RStarterSession::ELanguageSwitchReset); |
|
220 TEST(SsmCmnWrapper::GetLastMainStateRequest() == ESsmShutdown); |
|
221 TEST(SsmCmnWrapper::GetLastSubStateRequest() == KSsmAnySubState); |
|
222 TEST(SsmCmnWrapper::GetLastReasonRequest() == RStarterSession::ELanguageSwitchReset); |
|
223 |
|
224 INFO_PRINTF1(_L("Calling Reset(EOperatorSettingReset)")); |
|
225 starterSession.Reset(RStarterSession::EOperatorSettingReset); |
|
226 TEST(SsmCmnWrapper::GetLastMainStateRequest() == ESsmShutdown); |
|
227 TEST(SsmCmnWrapper::GetLastSubStateRequest() == KSsmAnySubState); |
|
228 TEST(SsmCmnWrapper::GetLastReasonRequest() == RStarterSession::EOperatorSettingReset); |
|
229 |
|
230 INFO_PRINTF1(_L("Calling Reset(EFirmwareUpdate)")); |
|
231 starterSession.Reset(RStarterSession::EFirmwareUpdate); |
|
232 TEST(SsmCmnWrapper::GetLastMainStateRequest() == ESsmShutdown); |
|
233 TEST(SsmCmnWrapper::GetLastSubStateRequest() == KSsmAnySubState); |
|
234 TEST(SsmCmnWrapper::GetLastReasonRequest() == RStarterSession::EFirmwareUpdate); |
|
235 |
|
236 INFO_PRINTF1(_L("Close on connected RStartSession")); |
|
237 starterSession.Close(); |
|
238 TEST(starterSession.Handle() == KNullHandle); |
|
239 |
|
240 INFO_PRINTF1(_L("Exiting CCLayerTestStarterSession::doTestRequestReset()")); |
|
241 } |
|
242 |
|
243 |
|
244 /** |
|
245 Old Test CaseID AFSS-CLAYER-0004 |
|
246 New Test CaseID DEVSRVS-SSREFPLUGINS-CLAYER-0001 |
|
247 */ |
|
248 |
|
249 void CCLayerTestStarterSession::doTestRequestShutdown() |
|
250 { |
|
251 INFO_PRINTF1(_L("Entering CCLayerTestStarterSession::doTestRequestShutdown()")); |
|
252 |
|
253 INFO_PRINTF1(_L("Connecting RStarterSession")); |
|
254 RStarterSession starterSession; |
|
255 TInt ret = starterSession.Connect(); |
|
256 TEST(ret == KErrNone); |
|
257 TEST(starterSession.Handle() != KNullHandle); |
|
258 TEST(starterSession.Handle() == SsmCmnWrapper::SsmStateManagerHandle()); |
|
259 |
|
260 INFO_PRINTF1(_L("Calling Shutdown()")); |
|
261 starterSession.Shutdown(); |
|
262 TEST(SsmCmnWrapper::GetLastMainStateRequest() == ESsmShutdown); |
|
263 TEST(SsmCmnWrapper::GetLastSubStateRequest() == KSsmAnySubState); |
|
264 TEST(SsmCmnWrapper::GetLastReasonRequest() == KSsmCLayerPowerOffReason); |
|
265 |
|
266 INFO_PRINTF1(_L("Close on connected RStartSession")); |
|
267 starterSession.Close(); |
|
268 TEST(starterSession.Handle() == KNullHandle); |
|
269 |
|
270 INFO_PRINTF1(_L("Exiting CCLayerTestStarterSession::doTestRequestShutdown()")); |
|
271 } |
|
272 |
|
273 /** |
|
274 Old Test CaseID AFSS-CLAYER-0007 |
|
275 New Test CaseID DEVSRVS-SSREFPLUGINS-CLAYER-0001 |
|
276 */ |
|
277 |
|
278 void CCLayerTestStarterSession::doTestRfForEmergencyCall() |
|
279 { |
|
280 INFO_PRINTF1(_L("Entering CCLayerTestStarterSession::doTestRfForEmergencyCall()")); |
|
281 |
|
282 INFO_PRINTF1(_L("Connecting RStarterSession")); |
|
283 RStarterSession starterSession; |
|
284 TInt ret = starterSession.Connect(); |
|
285 TEST(ret == KErrNone); |
|
286 TEST(starterSession.Handle() != KNullHandle); |
|
287 TEST(starterSession.Handle() == SsmCmnWrapper::SsmStateManagerHandle()); |
|
288 |
|
289 INFO_PRINTF1(_L("Failure to connect to RSsmEmergencyCallRfAdaptation")); |
|
290 // Set up connection to fail |
|
291 AdaptationCliWrapper::SetRSsmAdaptationBaseNextConnectReturn(KErrPermissionDenied); |
|
292 ret = starterSession.ActivateRfForEmergencyCall(); |
|
293 TEST(ret == KErrPermissionDenied); |
|
294 // Allow connection to succeed on the next tests |
|
295 AdaptationCliWrapper::SetRSsmAdaptationBaseNextConnectReturn(KErrNone); |
|
296 |
|
297 INFO_PRINTF1(_L("Activation and deactivation of RF for emergency calls")); |
|
298 ret = starterSession.ActivateRfForEmergencyCall(); |
|
299 TEST(ret == KErrNone); |
|
300 ret = starterSession.DeactivateRfAfterEmergencyCall(); |
|
301 TEST(ret == KErrNone); |
|
302 |
|
303 INFO_PRINTF1(_L("Activation and deactivation of RF for emergency calls not supported")); |
|
304 AdaptationCliWrapper::SetRSsmEmergencyCallReturnValue(KErrNotSupported); |
|
305 ret = starterSession.ActivateRfForEmergencyCall(); |
|
306 TEST(ret == KErrNotSupported); |
|
307 ret = starterSession.DeactivateRfAfterEmergencyCall(); |
|
308 TEST(ret == KErrNotSupported); |
|
309 // Allow future calls to succeed |
|
310 AdaptationCliWrapper::SetRSsmEmergencyCallReturnValue(KErrNone); |
|
311 |
|
312 INFO_PRINTF1(_L("Close on connected RStartSession")); |
|
313 starterSession.Close(); |
|
314 TEST(starterSession.Handle() == KNullHandle); |
|
315 |
|
316 INFO_PRINTF1(_L("Exiting CCLayerTestStarterSession::doTestRfForEmergencyCall()")); |
|
317 } |
|
318 |
|
319 /** |
|
320 Old Test CaseID AFSS-CLAYER-0008 |
|
321 New Test CaseID DEVSRVS-SSREFPLUGINS-CLAYER-0001 |
|
322 */ |
|
323 |
|
324 void CCLayerTestStarterSession::doTestEndSplashScreen() |
|
325 { |
|
326 INFO_PRINTF1(_L("Entering CCLayerTestStarterSession::doTestEndSplashScreen()")); |
|
327 |
|
328 INFO_PRINTF1(_L("Connecting RStarterSession")); |
|
329 RStarterSession starterSession; |
|
330 TInt ret = starterSession.Connect(); |
|
331 TEST(ret == KErrNone); |
|
332 TEST(starterSession.Handle() != KNullHandle); |
|
333 TEST(starterSession.Handle() == SsmCmnWrapper::SsmStateManagerHandle()); |
|
334 |
|
335 INFO_PRINTF1(_L("Deleting splash screen property")); |
|
336 ret = RProperty::Delete(KPSUidStartup, KPSSplashShutdown); |
|
337 TEST(ret == KErrNone || ret == KErrNotFound); |
|
338 |
|
339 |
|
340 INFO_PRINTF1(_L("Ending splashscreen without defining property")); |
|
341 ret = starterSession.EndSplashScreen(); |
|
342 TEST(ret == KErrNotFound); |
|
343 |
|
344 INFO_PRINTF1(_L("Defining splash screen property")); |
|
345 // In a test enviroment we don't need to worry about protecting the property |
|
346 // so allow anything to change it |
|
347 _LIT_SECURITY_POLICY_PASS(KAllPass); //lint !e648 Suppress overflow in computing constant for operation |
|
348 ret = RProperty::Define(KPSUidStartup, KPSSplashShutdown, RProperty::EInt, KAllPass, KAllPass); |
|
349 TEST(ret == KErrNone); |
|
350 |
|
351 INFO_PRINTF1(_L("Ending splashscreen with property defined")); |
|
352 ret = starterSession.EndSplashScreen(); |
|
353 TEST(ret == KErrNone); |
|
354 |
|
355 INFO_PRINTF1(_L("Reading splash screen property")); |
|
356 TInt value; |
|
357 ret = RProperty::Get(KPSUidStartup, KPSSplashShutdown, value); |
|
358 TEST(ret == KErrNone); |
|
359 TEST(value == ESplashShutdown); |
|
360 |
|
361 INFO_PRINTF1(_L("Close on connected RStartSession")); |
|
362 starterSession.Close(); |
|
363 TEST(starterSession.Handle() == KNullHandle); |
|
364 |
|
365 INFO_PRINTF1(_L("Exiting CCLayerTestStarterSession::doTestEndSplashScreen()")); |
|
366 } |
|
367 |