|
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 // Old Test CaseID APPFWK-SSS-0007 |
|
15 // New Test CaseID DEVSRVS-SSMA-STARTSAFE-0007 |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @test |
|
22 @internalComponent - Internal Symbian test code |
|
23 */ |
|
24 |
|
25 |
|
26 #include "tss_startandcancel.h" |
|
27 |
|
28 |
|
29 const TInt KSsDeletionTimeout = 300000; // us |
|
30 const TInt KStartAndCancelNominalTimeout = 3000; // ms...Generous |
|
31 |
|
32 |
|
33 |
|
34 TVerdict CSsTestStepStartAndCancel::doTestStepL() |
|
35 { |
|
36 __UHEAP_MARK; |
|
37 |
|
38 TRAPD(err, DoTestStartProcessAndCancelL()); |
|
39 TEST(err == KErrNone); |
|
40 INFO_PRINTF2(_L("DoTestStartProcessAndCancelL completed with err = %d"), err); |
|
41 |
|
42 TRAP(err, DoTestStartAppAndCancelL()); |
|
43 TEST(err == KErrNone); |
|
44 INFO_PRINTF2(_L("DoTestStartAppAndCancelL completed with err = %d"), err); |
|
45 |
|
46 TRAP(err, DoTestMultiStartAndDeleteL()); |
|
47 TEST(err == KErrNone); |
|
48 INFO_PRINTF2(_L("DoTestMultiStartAndDeleteL completed with err = %d"), err); |
|
49 |
|
50 __UHEAP_MARKEND; |
|
51 return TestStepResult(); |
|
52 } |
|
53 |
|
54 |
|
55 /** |
|
56 Start an instance of ssmtestappslow.exe asynchronously, as a process, specifying wait-for-start, |
|
57 but setting the timeout to zero which means that startsafe would wait indefinitely if need be. |
|
58 After a short period, StartCancel() is called on SsmStartSafe and the value of the TRS reported and tested |
|
59 via the mixin CSsTestStepStartAndCancel::SsTestNotify( TInt aNotify ) |
|
60 */ |
|
61 void CSsTestStepStartAndCancel::DoTestStartProcessAndCancelL() |
|
62 { |
|
63 INFO_PRINTF1( _L("\n\nPerforming async process start-and-cancel test") ); |
|
64 |
|
65 CSsmStartupProperties* startupProperties = CSsmStartupProperties::NewL(); |
|
66 CleanupStack::PushL( startupProperties ); |
|
67 |
|
68 // Zero timeout specified, therefore RvObserver will wait indefinitely |
|
69 startupProperties->SetFileParamsL( KTestAppSlow, KNullDesC ); |
|
70 startupProperties->SetCommandTypeL( ESsmCmdStartProcess ); |
|
71 startupProperties->SetExecutionBehaviour( ESsmWaitForSignal ); |
|
72 startupProperties->SetTimeout( KSsmStartSafeNoTimeout ); |
|
73 |
|
74 CSsmStartSafe* ss = CSsmStartSafe::NewLC(); |
|
75 RProcess process; |
|
76 CleanupClosePushL( process ); |
|
77 |
|
78 CTestAndCanceler* canceler = new(ELeave) CTestAndCanceler( *ss, *startupProperties, process, KSsTestTimeToCancel, this ); |
|
79 CleanupStack::PushL( canceler ); |
|
80 |
|
81 CActiveScheduler::Start(); |
|
82 |
|
83 CleanupStack::PopAndDestroy( 4, startupProperties ); |
|
84 |
|
85 FindAndKill( KTestAppSlow ); |
|
86 } |
|
87 |
|
88 |
|
89 |
|
90 /** |
|
91 Start an instance of ssmtestappslow.exe asynchronously, as an app, specifying wait-for-start, |
|
92 but setting the timeout to zero which means that startsafe would wait indefinitely if need be. |
|
93 After a short period, StartCancel() is called on SsmStartSafe and the value of the TRS reported and tested |
|
94 via the mixin CSsTestStepStartAndCancel::SsTestNotify( TInt aNotify ) |
|
95 */ |
|
96 void CSsTestStepStartAndCancel::DoTestStartAppAndCancelL() |
|
97 { |
|
98 INFO_PRINTF1( _L("\n\nPerforming async app. start-and-cancel test") ); |
|
99 |
|
100 CSsmStartupProperties* startupProperties = CSsmStartupProperties::NewL(); |
|
101 CleanupStack::PushL( startupProperties ); |
|
102 |
|
103 // Zero timeout specified, therefore RvObserver will wait indefinitely |
|
104 startupProperties->SetFileParamsL( KTestAppSlow, KNullDesC ); |
|
105 startupProperties->SetCommandTypeL( ESsmCmdStartApp ); |
|
106 startupProperties->SetExecutionBehaviour( ESsmWaitForSignal ); |
|
107 startupProperties->SetTimeout( KSsmStartSafeNoTimeout ); |
|
108 |
|
109 CSsmStartSafe* ss = CSsmStartSafe::NewLC(); |
|
110 RProcess process; |
|
111 CleanupClosePushL( process ); |
|
112 |
|
113 CTestAndCanceler* canceler = new(ELeave) CTestAndCanceler( *ss, *startupProperties, process, KSsTestTimeToCancel, this ); |
|
114 CleanupStack::PushL( canceler ); |
|
115 |
|
116 CActiveScheduler::Start(); |
|
117 |
|
118 CleanupStack::PopAndDestroy( 4, startupProperties ); |
|
119 |
|
120 FindAndKill( KTestAppSlow ); |
|
121 } |
|
122 |
|
123 |
|
124 |
|
125 /** |
|
126 Start four instances of ssmtestappnorv.exe (which never rendezvous), although supplying a timeout |
|
127 so that the timeoutwaiter is instantiated for each of them. Then delete CSsmStartSafe and check the completion code of their TRSs. |
|
128 Start two as apps and two as processes. |
|
129 */ |
|
130 void CSsTestStepStartAndCancel::DoTestMultiStartAndDeleteL() |
|
131 { |
|
132 INFO_PRINTF1( _L("\n\nPerforming Multi-Start and delete SS test") ); |
|
133 |
|
134 CSsmStartupProperties* startupProperties_0 = CSsmStartupProperties::NewL(); |
|
135 CleanupStack::PushL( startupProperties_0 ); |
|
136 |
|
137 CSsmStartupProperties* startupProperties_1 = CSsmStartupProperties::NewL(); |
|
138 CleanupStack::PushL( startupProperties_1 ); |
|
139 |
|
140 // Define a startup properties as EStartProcess |
|
141 startupProperties_0->SetFileParamsL( KTestAppNoRv, KNullDesC ); |
|
142 startupProperties_0->SetCommandTypeL( ESsmCmdStartProcess ); |
|
143 startupProperties_0->SetExecutionBehaviour( ESsmWaitForSignal ); |
|
144 startupProperties_0->SetTimeout( KStartAndCancelNominalTimeout ); |
|
145 // Define a startup properties as EStartApp |
|
146 startupProperties_1->SetFileParamsL( KTestAppNoRv, KNullDesC ); |
|
147 startupProperties_1->SetCommandTypeL( ESsmCmdStartApp ); |
|
148 startupProperties_1->SetExecutionBehaviour( ESsmWaitForSignal ); |
|
149 startupProperties_1->SetTimeout( KStartAndCancelNominalTimeout ); |
|
150 |
|
151 RProcess process_0; |
|
152 CleanupClosePushL( process_0 ); |
|
153 RProcess process_1; |
|
154 CleanupClosePushL( process_1 ); |
|
155 RProcess process_2; |
|
156 CleanupClosePushL( process_2 ); |
|
157 RProcess process_3; |
|
158 CleanupClosePushL( process_3 ); |
|
159 |
|
160 TInt id_0 = 0; |
|
161 TInt id_1 = 0; |
|
162 TInt id_2 = 0; |
|
163 TInt id_3 = 0; |
|
164 |
|
165 CStartAcknowledge* ack_0 = new(ELeave) CStartAcknowledge( this ); |
|
166 CleanupStack::PushL( ack_0 ); |
|
167 CStartAcknowledge* ack_1 = new(ELeave) CStartAcknowledge( this ); |
|
168 CleanupStack::PushL( ack_1 ); |
|
169 CStartAcknowledge* ack_2 = new(ELeave) CStartAcknowledge( this ); |
|
170 CleanupStack::PushL( ack_2 ); |
|
171 CStartAcknowledge* ack_3 = new(ELeave) CStartAcknowledge( this ); |
|
172 CleanupStack::PushL( ack_3 ); |
|
173 |
|
174 CSsmStartSafe* ss = CSsmStartSafe::NewLC(); |
|
175 ss->Start(*startupProperties_0, process_0, ack_0->iStatus, id_0); |
|
176 ss->Start(*startupProperties_1, process_1, ack_1->iStatus, id_1); |
|
177 ss->Start(*startupProperties_0, process_2, ack_2->iStatus, id_2); |
|
178 ss->Start(*startupProperties_1, process_3, ack_3->iStatus, id_3); |
|
179 CleanupStack::Pop( ss ); |
|
180 |
|
181 // Ao to timeout and delete the SS |
|
182 CSsPauseDeleter* pauseDeleter = new(ELeave) CSsPauseDeleter( KSsDeletionTimeout, ss ); |
|
183 CleanupStack::PushL( pauseDeleter ); |
|
184 |
|
185 // Times-out and stops the sched. |
|
186 CAsPauseStopper* pauseStopper = new(ELeave) CAsPauseStopper( KSsAsStopperNominalTimeout * 5 ); // 10s |
|
187 CleanupStack::PushL( pauseStopper ); |
|
188 |
|
189 //Process are started using Wait for start execution behaviour, |
|
190 //Start method always sets TRequestStatus to KRequestPending. |
|
191 if( (KRequestPending == ack_0->iStatus.Int()) && (KRequestPending == ack_1->iStatus.Int()) && (KRequestPending == ack_2->iStatus.Int()) && (KRequestPending == ack_3->iStatus.Int()) ) |
|
192 { |
|
193 CActiveScheduler::Start(); |
|
194 |
|
195 INFO_PRINTF5( _L("Test apps rv'd with the values %d %d %d %d "), ack_0->iStatus.Int(), ack_1->iStatus.Int(), ack_2->iStatus.Int(), ack_3->iStatus.Int() ); |
|
196 INFO_PRINTF5( _L("Expected values %d %d %d %d "), KErrCancel, KErrCancel, KErrCancel, KErrCancel ); |
|
197 |
|
198 TEST( ack_0->iStatus == KErrCancel ); |
|
199 TEST( ack_1->iStatus == KErrCancel ); |
|
200 TEST( ack_2->iStatus == KErrCancel ); |
|
201 TEST( ack_3->iStatus == KErrCancel ); |
|
202 } |
|
203 |
|
204 |
|
205 CleanupStack::PopAndDestroy( 12, startupProperties_0 ); |
|
206 |
|
207 TEST( 4 == FindAndKill(KTestAppNoRv) ); |
|
208 } |
|
209 |
|
210 |
|
211 |
|
212 TVerdict CSsTestStepStartAndCancel::doTestStepPreambleL() |
|
213 { |
|
214 iActiveScheduler = new(ELeave) CActiveScheduler; |
|
215 CActiveScheduler::Install( iActiveScheduler ); |
|
216 |
|
217 return CTestStep::doTestStepPreambleL(); |
|
218 } |
|
219 |
|
220 |
|
221 |
|
222 /** */ |
|
223 TVerdict CSsTestStepStartAndCancel::doTestStepPostambleL() |
|
224 { |
|
225 return CTestStep::doTestStepPostambleL(); |
|
226 } |
|
227 |
|
228 |
|
229 /** |
|
230 From MSsTestAsyncNotifier |
|
231 */ |
|
232 void CSsTestStepStartAndCancel::SsTestNotify( TInt aNotify ) |
|
233 { |
|
234 TEST( KErrCancel == aNotify ); |
|
235 |
|
236 INFO_PRINTF3( _L("Expected completion code %d. Supplied completion code %d"), KErrCancel, aNotify ); |
|
237 } |
|
238 |
|
239 |
|
240 |
|
241 CSsTestStepStartAndCancel::CSsTestStepStartAndCancel() |
|
242 { |
|
243 SetTestStepName( KCTestCaseStartAndCancel ); |
|
244 } |
|
245 |
|
246 |
|
247 |
|
248 CSsTestStepStartAndCancel::~CSsTestStepStartAndCancel() |
|
249 { |
|
250 delete iActiveScheduler; |
|
251 } |
|
252 |