1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
17 @file |
17 @file |
18 @test |
18 @test |
19 @internalComponent - Internal Symbian test code |
19 @internalComponent - Internal Symbian test code |
20 */ |
20 */ |
21 |
21 |
|
22 #include <e32property.h> |
22 #include "ssmserverpanic.h" |
23 #include "ssmserverpanic.h" |
23 #include "ssmswppolicyframe.h" |
24 #include "ssmswppolicyframe.h" |
24 #include "ssmswppolicyresolver.h" |
25 #include "ssmswppolicyresolver.h" |
25 #include "ssmswptransitionengine.h" |
26 #include "ssmswptransitionengine.h" |
26 #include "ssmswptransitionscheduler.h" |
27 #include "ssmswptransitionscheduler.h" |
31 #include "tssm_step_validswplist.h" |
32 #include "tssm_step_validswplist.h" |
32 #include "tssm_swppolicy_invalidlist.h" |
33 #include "tssm_swppolicy_invalidlist.h" |
33 |
34 |
34 |
35 |
35 const TInt KTestInvalidPanicCategory = -988; |
36 const TInt KTestInvalidPanicCategory = -988; |
|
37 // property uids should be real uids (use these temporarily for test purposes) |
|
38 const TUint key={0x01}; |
36 _LIT(KSsmSwpPolicyServerName, "TestSsmSwpPolicyServer"); |
39 _LIT(KSsmSwpPolicyServerName, "TestSsmSwpPolicyServer"); |
37 |
40 |
38 //---------------------------------------------------------------------------------------------------------------- |
41 //---------------------------------------------------------------------------------------------------------------- |
39 //---------------------------------------- Thread creation framework --------------------------------------------- |
42 //---------------------------------------- Thread creation framework --------------------------------------------- |
40 //---------------------------------------------------------------------------------------------------------------- |
43 //---------------------------------------------------------------------------------------------------------------- |
63 thread.Logon(status); |
66 thread.Logon(status); |
64 TBool jit = User::JustInTime(); |
67 TBool jit = User::JustInTime(); |
65 User::SetJustInTime(EFalse); |
68 User::SetJustInTime(EFalse); |
66 thread.Resume(); |
69 thread.Resume(); |
67 User::WaitForRequest(status); |
70 User::WaitForRequest(status); |
68 |
71 |
69 // always expecting a state transition engine panic |
72 // always expecting a state transition engine panic |
70 TExitCategoryName category = thread.ExitCategory(); |
73 TExitCategoryName category = thread.ExitCategory(); |
71 if (category.Compare(KPanicSysStateMgr) != 0) |
74 if (category.Compare(KPanicSysStateMgr) != 0) |
72 { |
75 { |
73 User::Leave(KTestInvalidPanicCategory); |
76 User::Leave(KTestInvalidPanicCategory); |
99 { |
102 { |
100 CActiveScheduler* sched = new(ELeave) CActiveScheduler(); |
103 CActiveScheduler* sched = new(ELeave) CActiveScheduler(); |
101 CleanupStack::PushL(sched); |
104 CleanupStack::PushL(sched); |
102 CActiveScheduler::Install(sched); |
105 CActiveScheduler::Install(sched); |
103 |
106 |
104 // property uids should be real uids (use these temporarily for test purposes) |
|
105 const TUint key={0x01}; |
|
106 |
|
107 // Create a swp policy resolver and register our property |
107 // Create a swp policy resolver and register our property |
108 CSsmSwpPolicyResolver* resolver = CSsmSwpPolicyResolver::NewL(); |
108 CSsmSwpPolicyResolver* resolver = CSsmSwpPolicyResolver::NewL(); |
109 CleanupStack::PushL(resolver); |
109 CleanupStack::PushL(resolver); |
110 resolver->RegisterSwpMappingL(key, KTestSwpPolicyInvalidListFile); |
110 resolver->RegisterSwpMappingL(key, KTestSwpPolicyInvalidListFile); |
111 |
111 |
127 if (aSsmValidSwpListTest->Function() == ESwpCmdTooManyMultipleWaitErr1) |
127 if (aSsmValidSwpListTest->Function() == ESwpCmdTooManyMultipleWaitErr1) |
128 aSsmValidSwpListTest->GetSsmSwpPolicyServerThreadIdL(); |
128 aSsmValidSwpListTest->GetSsmSwpPolicyServerThreadIdL(); |
129 |
129 |
130 //Request transition according to the reason action, which will define the invalid list |
130 //Request transition according to the reason action, which will define the invalid list |
131 const TSsmSwp swp(key, aSsmValidSwpListTest->Function()); |
131 const TSsmSwp swp(key, aSsmValidSwpListTest->Function()); |
|
132 |
132 handler->SubmitRequestL(swp); |
133 handler->SubmitRequestL(swp); |
133 |
134 |
134 sched->Start(); |
135 sched->Start(); |
135 |
136 |
136 CleanupStack::PopAndDestroy(3, sched); |
137 CleanupStack::PopAndDestroy(3, sched); |
198 { |
199 { |
199 INFO_PRINTF1(_L("CSsmValidSwpListTest started....")); |
200 INFO_PRINTF1(_L("CSsmValidSwpListTest started....")); |
200 |
201 |
201 __UHEAP_MARK; |
202 __UHEAP_MARK; |
202 |
203 |
|
204 TInt err = RProperty::Define(RProcess().SecureId(), key, RProperty::EInt); |
|
205 TEST(err == KErrNone || err == KErrAlreadyExists); |
203 INFO_PRINTF1(_L("Checking cmd list without a Publish System Swp command")); |
206 INFO_PRINTF1(_L("Checking cmd list without a Publish System Swp command")); |
204 TInt exitReason(0); |
207 TInt exitReason(0); |
205 SetFunction(ESwpCmdWithoutPublishSwp); |
208 SetFunction(ESwpCmdWithoutPublishSwp); |
206 TRAPD(err, exitReason = StartSwpInvalidListInThreadL(this)); |
209 TRAP(err, exitReason = StartSwpInvalidListInThreadL(this)); |
207 TEST(err == KErrNone); |
210 TEST(err == KErrNone); |
208 INFO_PRINTF2(_L(" -- StartSwpInvalidListInThreadL method completed with '%d'."), err); |
211 INFO_PRINTF2(_L(" -- StartSwpInvalidListInThreadL method completed with '%d'."), err); |
209 TEST(exitReason == ESwpTransitionEngineError16); |
212 TEST(exitReason == ESwpTransitionEngineError16); |
210 INFO_PRINTF3(_L(" -- received panic '%d', expected was '%d'."), exitReason, ESwpTransitionEngineError16); |
213 INFO_PRINTF3(_L(" -- received panic '%d', expected was '%d'."), exitReason, ESwpTransitionEngineError16); |
211 |
214 |
241 SetFunction(ESwpCmdTooManyMultipleWaitErr1); |
244 SetFunction(ESwpCmdTooManyMultipleWaitErr1); |
242 TRAP(err, exitReason = StartSwpInvalidListInThreadL(this)); |
245 TRAP(err, exitReason = StartSwpInvalidListInThreadL(this)); |
243 TEST(err == KErrNone); |
246 TEST(err == KErrNone); |
244 INFO_PRINTF2(_L(" -- StartSwpInvalidListInThreadL method completed with '%d'."), err); |
247 INFO_PRINTF2(_L(" -- StartSwpInvalidListInThreadL method completed with '%d'."), err); |
245 const TInt threadExitReason = iThread.ExitReason(); |
248 const TInt threadExitReason = iThread.ExitReason(); |
|
249 TBuf<16> threadExitCategory = iThread.ExitCategory(); |
246 // This is the exit reason for the ssmswppolicyserver |
250 // This is the exit reason for the ssmswppolicyserver |
247 TEST(threadExitReason == KSsmTestAppRvError); |
251 TEST(threadExitReason == KSsmTestAppRvError); |
248 // this is the exit reason for the engine. |
252 // this is the exit reason for the engine. |
249 TEST(exitReason == ESwpTransitionEngineError20); |
253 TEST(exitReason == ESwpTransitionEngineError20); |
250 iThread.Close(); |
254 iThread.Close(); |
251 INFO_PRINTF3(_L(" -- received panic '%d', expected was '%d'."), threadExitReason, KSsmTestAppRvError); |
255 INFO_PRINTF4(_L(" -- received panic '%d', category '%S', expected was '%d'."), threadExitReason, &threadExitCategory, KSsmTestAppRvError); |
252 |
256 |
253 INFO_PRINTF1(_L("Checking cmd list with too many Multiple Wait command and and no deferred commands - Validation should be OK - Panic originates in HandleCleReturnValue returning an error")); |
257 INFO_PRINTF1(_L("Checking cmd list with too many Multiple Wait command and and no deferred commands - Validation should be OK - Panic originates in HandleCleReturnValue returning an error")); |
254 exitReason=0; |
258 exitReason=0; |
255 SetFunction(ESwpCmdTooManyMultipleWaitErr2); |
259 SetFunction(ESwpCmdTooManyMultipleWaitErr2); |
256 TRAP(err, exitReason = StartSwpInvalidListInThreadL(this)); |
260 TRAP(err, exitReason = StartSwpInvalidListInThreadL(this)); |
265 TRAP(err, exitReason = StartSwpInvalidListInThreadL(this)); |
269 TRAP(err, exitReason = StartSwpInvalidListInThreadL(this)); |
266 TEST(err == KErrNone); |
270 TEST(err == KErrNone); |
267 INFO_PRINTF2(_L(" -- StartSwpInvalidListInThreadL method completed with '%d'."), err); |
271 INFO_PRINTF2(_L(" -- StartSwpInvalidListInThreadL method completed with '%d'."), err); |
268 TEST(exitReason == ESwpTransitionEngineError20); |
272 TEST(exitReason == ESwpTransitionEngineError20); |
269 INFO_PRINTF3(_L(" -- received panic '%d', expected was '%d'."), exitReason, ESwpTransitionEngineError20); |
273 INFO_PRINTF3(_L(" -- received panic '%d', expected was '%d'."), exitReason, ESwpTransitionEngineError20); |
270 |
274 |
|
275 err = RProperty::Delete(RProcess().SecureId(), key); |
|
276 TEST(err == KErrNone); |
271 __UHEAP_MARKEND; |
277 __UHEAP_MARKEND; |
272 |
278 |
273 // this test raises panics due to negative testing - close them to clear the screen. |
279 // this test raises panics due to negative testing - close them to clear the screen. |
274 CloseAllPanicWindowsL(); |
280 CloseAllPanicWindowsL(); |
275 |
281 |