199 else |
187 else |
200 { |
188 { |
201 RDebug::Print(_L("\nStateTran Test: RequestStateTransition from Normal to shutdown state Failed")); |
189 RDebug::Print(_L("\nStateTran Test: RequestStateTransition from Normal to shutdown state Failed")); |
202 User::Leave(KTestAppFailure); |
190 User::Leave(KTestAppFailure); |
203 } |
191 } |
204 |
192 |
205 //Scenario 4 - Request for two state changes one after the other without waiting for the first one to complete |
193 iFileWriteStream.Close(); |
206 // Once first and second request are completed the system will be in fail state, now issue another state transition |
194 |
207 // request to fail state again. |
195 // Creates and open the result file for streaming |
208 // The first request to the fail state will be completed with KErrCancel |
196 err = iFileWriteStream.Replace(iFs, KGsaTestStateTranFromShutdownResult, EFileWrite); |
209 // the second request to transit to the fail state will be completed with KErrNone. |
197 RDebug::Print(_L("\nStateTran Test: iFileWriteStream open with %d\n"), err); |
210 // the third request to transit to the fail state will be completed with KErrNotSupported. |
198 |
211 |
199 |
212 RDebug::Print(_L("\nStateTran Test: Scenario 4 \n")); |
200 // Gets the Current system state before starting the test |
213 stateMan.RequestStateTransition(stateTrans3, status1); |
201 CurrentSystemStateL(); |
214 RDebug::Print(_L("\nStateTran Test: Start First RequestStateTransition from Normal to fail state %d\n "), status1.Int()); |
202 |
215 |
203 //Scenario 1 - Request for state change from Normal to shutdown state to critical substate |
216 stateMan.RequestStateTransition(stateTrans3, status2); |
204 // Cancel the request immediately |
217 RDebug::Print(_L("\nStateTran Test: Start Second RequestStateTransition from Normal to fail state %d\n "), status2.Int()); |
205 RDebug::Print(_L("\nScenario 1 \n")); |
218 |
206 TRequestStatus status_shutdowncritsubstate; |
219 User::WaitForRequest(status1); |
207 /*TSsmState shutdownState_Critical(ESsmShutdown, ESsmShutdownSubStateCritical); |
220 iFileWriteStream.WriteInt32L(status1.Int()); |
208 TSsmStateTransition stateTrans_Shutdowncritical(shutdownState_Critical, 1);*/ |
221 if (status1.Int() == KErrCancel) |
209 |
222 { |
210 stateMan.RequestStateTransition(stateTrans_Shutdowncritical, status_shutdowncritsubstate); |
223 RDebug::Print(_L("\nStateTran Test: First RequestStateTransition from Normal to fail state completes with %d Expected -3\n "), status1.Int()); |
211 RDebug::Print(_L("\n RequestStateTransition from Normal to shutdown state critical substate %d\n "), status_shutdowncritsubstate.Int()); |
224 CurrentSystemStateL(); |
212 |
225 } |
213 stateMan.RequestStateTransitionCancel(); |
226 else |
214 |
227 { |
215 iFileWriteStream.WriteInt32L(status_shutdowncritsubstate.Int()); |
228 RDebug::Print(_L("\nStateTran Test: First RequestStateTransition from Normal to fail state Failed")); |
216 if (status_shutdowncritsubstate.Int() == KErrCancel) |
229 User::Leave(KTestAppFailure); |
217 { |
230 } |
218 CurrentSystemStateL(); |
231 |
219 RDebug::Print(_L("\n RequestStateTransition from Normal to shutdown state critical substate completed %d Expected -3\n "), status_shutdowncritsubstate.Int()); |
232 User::WaitForRequest(status2); |
220 } |
233 iFileWriteStream.WriteInt32L(status2.Int()); |
221 else |
234 if (status2.Int() == KErrNone) |
222 User::Leave(KTestAppFailure); |
235 { |
223 |
236 RDebug::Print(_L("\nStateTran Test: Second RequestStateTransition from Normal to fail state %d Expected 0\n "), status2.Int()); |
224 //Scenario 2 - Request for state change from Normal to shutdown state to any substate |
237 CurrentSystemStateL(); |
225 // Cancel the request immediately, so that we can proceed with the next test scenario. |
238 } |
226 RDebug::Print(_L("\nScenario 2 \n")); |
239 else |
227 TRequestStatus status_shutdownanysubstate; |
240 { |
228 TSsmState shutdownState_Any(ESsmShutdown, KSsmAnySubState); |
241 RDebug::Print(_L("\nStateTran Test: Second RequestStateTransition from Normal to fail state Failed")); |
229 TSsmStateTransition stateTrans_shutdownAnySubState(shutdownState_Any, 1); |
242 User::Leave(KTestAppFailure); |
230 |
243 } |
231 stateMan.RequestStateTransition(stateTrans_shutdownAnySubState, status_shutdownanysubstate); |
244 |
232 RDebug::Print(_L("\n RequestStateTransition from Normal to shutdown state any substate %d\n "), status_shutdownanysubstate.Int()); |
245 stateMan.RequestStateTransition(stateTrans3, status2); //System is in fail state |
233 |
246 RDebug::Print(_L("\nStateTran Test: Start RequestStateTransition from fail to fail state %d\n "), status2.Int()); |
234 stateMan.RequestStateTransitionCancel(); |
247 |
235 |
248 User::WaitForRequest(status2); |
236 iFileWriteStream.WriteInt32L(status_shutdownanysubstate.Int()); |
249 iFileWriteStream.WriteInt32L(status2.Int()); |
237 if (status_shutdownanysubstate.Int() == KErrCancel) |
250 if (status2.Int() == KErrNotSupported) |
238 { |
251 { |
239 CurrentSystemStateL(); |
252 RDebug::Print(_L("\nStateTran Test: RequestStateTransition from fail to fail state completed with %d Expected -5\n "), status2.Int()); |
240 RDebug::Print(_L("\n RequestStateTransition from Normal to shutdown state any substate completed %d Expected -3\n "), status_shutdownanysubstate.Int()); |
253 CurrentSystemStateL(); |
241 } |
254 } |
242 else |
255 else |
243 User::Leave(KTestAppFailure); |
256 { |
244 |
257 RDebug::Print(_L("\nStateTran Test: RequestStateTransition from fail to fail state Failed")); |
245 iFileWriteStream.Close(); |
258 User::Leave(KTestAppFailure); |
246 |
259 } |
247 // Creates and open the result file for streaming |
|
248 err = iFileWriteStream.Replace(iFs, KGsaTestStateTranToShutdownResult, EFileWrite); |
|
249 RDebug::Print(_L("\nStateTran Test: iFileWriteStream open with %d\n"), err); |
|
250 |
|
251 |
|
252 // Gets the Current system state before starting the test |
|
253 CurrentSystemStateL(); |
|
254 |
|
255 //Scenario 1 - Request for state transition to shutdown state - invalid substate |
|
256 // request to transit to the shutdown state will be completed with KErrNotSupported |
|
257 RDebug::Print(_L("\nScenario 1 \n")); |
|
258 |
|
259 TRequestStatus status_invalidsubstate; |
|
260 TSsmState shutdownState_Invalid(ESsmShutdown, 150); |
|
261 TSsmStateTransition stateTrans_Invalid(shutdownState_Invalid, 1); |
|
262 |
|
263 stateMan.RequestStateTransition(stateTrans_Invalid, status_invalidsubstate); |
|
264 RDebug::Print(_L("\n Start RequestStateTransition from Normal to shutdown state with invalid substate %d\n "), status_invalidsubstate.Int()); |
|
265 |
|
266 User::WaitForRequest(status_invalidsubstate); |
|
267 iFileWriteStream.WriteInt32L(status_invalidsubstate.Int()); |
|
268 if (status_invalidsubstate.Int() == KErrNotSupported) |
|
269 { |
|
270 CurrentSystemStateL(); |
|
271 RDebug::Print(_L("\n RequestStateTransition from Normal to shutdown state with invalid substate completes with %d Expected -5\n "), status_invalidsubstate.Int()); |
|
272 } |
|
273 else |
|
274 User::Leave(KTestAppFailure); |
|
275 |
|
276 iFileWriteStream.Close(); |
|
277 CleanupStack::PopAndDestroy(&stateMan); |
260 } |
278 } |
261 |
279 |
262 void CStateTranFromNormal::StartTestL() |
280 void CStateTranFromNormal::StartTestL() |
263 { |
281 { |
264 CActiveScheduler* sched=new(ELeave) CActiveScheduler; |
282 CActiveScheduler* sched=new(ELeave) CActiveScheduler; |
265 CleanupStack::PushL(sched); |
283 CleanupStack::PushL(sched); |
266 CActiveScheduler::Install(sched); |
284 CActiveScheduler::Install(sched); |
267 |
|
268 // Notifier used to get the notification when system gets to fail state |
|
269 CSsmStateAwareSession* notif_for_failstate = CSsmStateAwareSession::NewLC(KSM2UiServicesDomain3); |
|
270 notif_for_failstate->AddSubscriberL(*this); |
|
271 |
285 |
272 // This async callback is used to start the state transition test once system enters to normal state. |
286 // This async callback is used to start the state transition test once system enters to normal state. |
273 iAsyncCallbackForStartTest = new(ELeave) CAsyncCallBack(CActive::EPriorityIdle); |
287 iAsyncCallbackForStartTest = new(ELeave) CAsyncCallBack(CActive::EPriorityIdle); |
274 TCallBack startTestCallback(StartTest, this); |
288 TCallBack startTestCallback(StartTest, this); |
275 iAsyncCallbackForStartTest->Set(startTestCallback); |
289 iAsyncCallbackForStartTest->Set(startTestCallback); |