|
1 // Copyright (c) 2005-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 the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent - Internal Symbian test code |
|
21 */ |
|
22 |
|
23 #include "T_IntegritySupportStep.h" |
|
24 #include <bautils.h> |
|
25 |
|
26 |
|
27 |
|
28 /** |
|
29 * Constructor |
|
30 */ |
|
31 CT_IntegritySupportTestStep::CT_IntegritySupportTestStep() |
|
32 { |
|
33 // Call base class method to set up the human readable name for logging |
|
34 SetTestStepName(KT_IntegritySupportStep); |
|
35 } |
|
36 |
|
37 /** |
|
38 * Destructor |
|
39 */ |
|
40 CT_IntegritySupportTestStep::~CT_IntegritySupportTestStep() |
|
41 { |
|
42 iSession.Close(); |
|
43 iUtils.Close(); |
|
44 } |
|
45 |
|
46 /** |
|
47 * @return - TVerdict code |
|
48 * Override of base class virtual |
|
49 */ |
|
50 TVerdict CT_IntegritySupportTestStep::doTestStepPreambleL() |
|
51 { |
|
52 SetTestStepResult(EPass); |
|
53 doAbstractNonNativeAppsTestStepPreambleL(); |
|
54 return TestStepResult(); |
|
55 } |
|
56 |
|
57 /** |
|
58 * @return - TVerdict code |
|
59 * Override of base class virtual |
|
60 */ |
|
61 TVerdict CT_IntegritySupportTestStep::doTestStepPostambleL() |
|
62 { |
|
63 return TestStepResult(); |
|
64 } |
|
65 |
|
66 TVerdict CT_IntegritySupportTestStep::doTestStepL() |
|
67 { |
|
68 INFO_PRINTF1(_L("Testing Apparc...T_IntegritySupport Test Cases Running...")); |
|
69 |
|
70 TRAPD(ret,RunTestCasesL()) |
|
71 TEST(ret==KErrNone); |
|
72 |
|
73 INFO_PRINTF1(_L("...T_IntegritySupport Test Cases Completed.")); |
|
74 |
|
75 return TestStepResult(); |
|
76 } |
|
77 |
|
78 TInt CT_IntegritySupportTestStep::RunTestCasesL() |
|
79 { |
|
80 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestNormalInstallation1L(), NO_CLEANUP); |
|
81 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestManualRollback1L(), NO_CLEANUP); |
|
82 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestRollbackOnError1L(), NO_CLEANUP); |
|
83 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestRollbackOnSessionCloseL(), NO_CLEANUP); |
|
84 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestNormalRemoval1L(), NO_CLEANUP); |
|
85 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestManualRollback2L(), NO_CLEANUP); |
|
86 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestRollbackWithoutPrepareL(), NO_CLEANUP); |
|
87 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestRegisterWithoutPrepareL(), NO_CLEANUP); |
|
88 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestCallingPrepareTwiceL(), NO_CLEANUP); |
|
89 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestCallingPrepareFromTwoSessionsL(), NO_CLEANUP); |
|
90 /* Removed from armv5 because they seem to cause filesystem corruption */ |
|
91 #ifdef __WINS__ |
|
92 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestReregisterApplicationL(), NO_CLEANUP); |
|
93 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestDoubleInstallFailsL(), NO_CLEANUP); |
|
94 HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestRollbackOnFailedUpdateStepL(), NO_CLEANUP); |
|
95 #endif |
|
96 return KErrNone; |
|
97 } |
|
98 |
|
99 |
|
100 _LIT(KLitLogicalExecutable1,"c:\\TestIntegritySupport1.ist"); |
|
101 _LIT(KLitRegistrationFile1,"c:\\private\\10003a3f\\import\\apps\\NonNative\\Resource\\102081a1_reg.rsc"); |
|
102 static const CT_AbstractNonNativeAppsTestStep::TTestAppDetails KApplication1(0x102081A1,KLitLogicalExecutable1,KLitRegistrationFile1); |
|
103 |
|
104 _LIT(KLitLogicalExecutable2,"c:\\TestIntegritySupport2.ist"); |
|
105 _LIT(KLitRegistrationFile2,"c:\\private\\10003a3f\\import\\apps\\NonNative\\Resource\\102081c0_reg.rsc"); |
|
106 static const CT_AbstractNonNativeAppsTestStep::TTestAppDetails KApplication2(0x102081C0,KLitLogicalExecutable2,KLitRegistrationFile2); |
|
107 |
|
108 _LIT(KLitLogicalExecutable3,"c:\\TestIntegritySupport3.ist"); |
|
109 _LIT(KLitRegistrationFile3,"c:\\private\\10003a3f\\import\\apps\\NonNative\\Resource\\102081c1_reg.rsc"); |
|
110 static const CT_AbstractNonNativeAppsTestStep::TTestAppDetails KApplication3(0x102081C1,KLitLogicalExecutable3,KLitRegistrationFile3); |
|
111 |
|
112 _LIT(KLitLogicalExecutable4,"c:\\TestIntegritySupport4.ist"); |
|
113 _LIT(KLitRegistrationFile4,"c:\\private\\10003a3f\\import\\apps\\NonNative\\Resource\\102081c2_reg.rsc"); |
|
114 static const CT_AbstractNonNativeAppsTestStep::TTestAppDetails KApplication4(0x102081C2,KLitLogicalExecutable4,KLitRegistrationFile4); |
|
115 |
|
116 // uses logical executable from KApplication4 |
|
117 _LIT(KLitRegistrationFile5,"c:\\private\\10003a3f\\import\\apps\\NonNative\\Resource\\102081c3_reg.rsc"); |
|
118 static const CT_AbstractNonNativeAppsTestStep::TTestAppDetails KApplication5(0x102081C3,KLitLogicalExecutable4,KLitRegistrationFile5); |
|
119 |
|
120 |
|
121 /** |
|
122 @SYMTestCaseID T-IntegritySupportTestStep-TestNormalInstallation1L |
|
123 |
|
124 @SYMPREQ |
|
125 |
|
126 @SYMTestCaseDesc Tests the integrity support during a normal installation |
|
127 |
|
128 @SYMTestPriority |
|
129 |
|
130 @SYMTestStatus Implemented |
|
131 |
|
132 @SYMTestActions Tests installation process when there are no problems. |
|
133 |
|
134 @SYMTestExpectedResults The application is successfully installed and then removed. |
|
135 */ |
|
136 void CT_IntegritySupportTestStep::TestNormalInstallation1L() |
|
137 { |
|
138 INFO_PRINTF1(_L("Testing normal application installation...")); |
|
139 |
|
140 RProcess().SetPriority(EPriorityLow); // so that we're pre-empted by the Apparc server when it does its scan |
|
141 CleanupAndReset(iSession, KApplication1); |
|
142 |
|
143 iSession.PrepareNonNativeApplicationsUpdatesL(); |
|
144 |
|
145 INFO_PRINTF1(_L("..registering app using RegisterNonNativeApplicationL() ")); |
|
146 CallRegisterL(iSession, KApplication1); |
|
147 |
|
148 // Since we have not committed yet, at this stage the files should not be in their |
|
149 // final locations |
|
150 TEST(AppAbsent(iSession, KApplication1)); |
|
151 |
|
152 iSession.CommitNonNativeApplicationsUpdatesL(); |
|
153 |
|
154 // the files should now be present in their final locations |
|
155 TEST(AppPresent(iSession, KApplication1)); |
|
156 |
|
157 INFO_PRINTF1(_L("..deregistering app using DeregisterNonNativeApplicationL() ")); |
|
158 CompleteDeregisterL(iSession, KApplication1); |
|
159 |
|
160 TEST(AppAbsent(iSession, KApplication1)); |
|
161 } |
|
162 |
|
163 |
|
164 /** |
|
165 @SYMTestCaseID T-IntegritySupportTestStep-TestManualRollback1L |
|
166 |
|
167 @SYMPREQ |
|
168 |
|
169 @SYMTestCaseDesc Tests the integrity support during an installation that is rolled back |
|
170 |
|
171 @SYMTestPriority |
|
172 |
|
173 @SYMTestStatus Implemented |
|
174 |
|
175 @SYMTestActions Tests installation process when the client decides to rollback the changes. |
|
176 |
|
177 @SYMTestExpectedResults The installtion is successfully rolled back and the device is in the |
|
178 same state as before the installation attempt. |
|
179 */ |
|
180 void CT_IntegritySupportTestStep::TestManualRollback1L() |
|
181 { |
|
182 INFO_PRINTF1(_L("Testing manual rollback during installation...")); |
|
183 CleanupAndReset(iSession, KApplication2); |
|
184 |
|
185 iSession.PrepareNonNativeApplicationsUpdatesL(); |
|
186 INFO_PRINTF1(_L("..registering app using RegisterNonNativeApplicationL() ")); |
|
187 CallRegisterL(iSession, KApplication2); |
|
188 |
|
189 // Since we have not committed yet, at this stage the files should not be in their |
|
190 // final locations |
|
191 TEST(AppAbsent(iSession, KApplication2)); |
|
192 |
|
193 iSession.RollbackNonNativeApplicationsUpdates(); |
|
194 |
|
195 // Test that they're still all absent since we never committed |
|
196 TEST(AppAbsent(iSession, KApplication2)); |
|
197 } |
|
198 |
|
199 void CT_IntegritySupportTestStep::TestRollbackOnError1L() |
|
200 { |
|
201 |
|
202 // this can be tested by trying to overwrite an icon file. |
|
203 } |
|
204 |
|
205 |
|
206 /** |
|
207 @SYMTestCaseID T-IntegritySupportTestStep-TestRollbackOnSessionCloseL |
|
208 |
|
209 @SYMPREQ |
|
210 |
|
211 @SYMTestCaseDesc Tests that any updates are rolled back if the session is closed in the middle |
|
212 of an update |
|
213 |
|
214 @SYMTestPriority |
|
215 |
|
216 @SYMTestStatus Implemented |
|
217 |
|
218 @SYMTestActions Tests installation process when the client closes the session before |
|
219 committing or rolling back. |
|
220 |
|
221 @SYMTestExpectedResults The installation is successfully rolled back and the device is in the |
|
222 same state as before the installation attempt. |
|
223 */ |
|
224 void CT_IntegritySupportTestStep::TestRollbackOnSessionCloseL() |
|
225 { |
|
226 INFO_PRINTF1(_L("Testing rollback if RApaLsSession is closed...")); |
|
227 |
|
228 RTestableApaLsSession apaSession; |
|
229 User::LeaveIfError(apaSession.Connect()); |
|
230 CleanupClosePushL(apaSession); |
|
231 |
|
232 CleanupAndReset(apaSession, KApplication3); |
|
233 |
|
234 apaSession.PrepareNonNativeApplicationsUpdatesL(); |
|
235 INFO_PRINTF1(_L("..registering app using RegisterNonNativeApplicationL() ")); |
|
236 CallRegisterL(apaSession, KApplication3); |
|
237 |
|
238 // shouldn't be present until comitted |
|
239 TEST(AppAbsent(iSession, KApplication3)); |
|
240 |
|
241 // We close the session before committing or rolling back. |
|
242 CleanupStack::PopAndDestroy(&apaSession); |
|
243 |
|
244 // We never committed, so check that nothing's changed |
|
245 TEST(AppAbsent(iSession, KApplication3)); |
|
246 } |
|
247 |
|
248 /** |
|
249 @SYMTestCaseID T-IntegritySupportTestStep-TestNormalRemoval1L |
|
250 |
|
251 @SYMPREQ |
|
252 |
|
253 @SYMTestCaseDesc Tests a normal removal attempt |
|
254 |
|
255 @SYMTestPriority |
|
256 |
|
257 @SYMTestStatus Implemented |
|
258 |
|
259 @SYMTestActions Tests the correct working of the removal process. |
|
260 |
|
261 @SYMTestExpectedResults The application is installed and then removed without errors. |
|
262 */ |
|
263 void CT_IntegritySupportTestStep::TestNormalRemoval1L() |
|
264 { |
|
265 INFO_PRINTF1(_L("Testing removal...")); |
|
266 CleanupAndReset(iSession, KApplication4); |
|
267 |
|
268 INFO_PRINTF1(_L("..registering app using RegisterNonNativeApplicationL() ")); |
|
269 CompleteRegisterL(iSession, KApplication4); |
|
270 TEST(AppPresent(iSession, KApplication4)); |
|
271 |
|
272 INFO_PRINTF1(_L("..deregistering app using DeregisterNonNativeApplicationL() ")); |
|
273 iSession.PrepareNonNativeApplicationsUpdatesL(); |
|
274 CallDeregisterL(iSession,KApplication4); |
|
275 |
|
276 // Check that everythign is still the same as we haven't committed yet |
|
277 TEST(AppPresent(iSession, KApplication4)); |
|
278 |
|
279 iSession.CommitNonNativeApplicationsUpdatesL(); |
|
280 TEST(AppAbsent(iSession, KApplication4)); |
|
281 } |
|
282 |
|
283 /** |
|
284 @SYMTestCaseID T-IntegritySupportTestStep-TestManualRollback2L |
|
285 |
|
286 @SYMPREQ |
|
287 |
|
288 @SYMTestCaseDesc Tests the integrity support during an installation that is rolled back |
|
289 |
|
290 @SYMTestPriority |
|
291 |
|
292 @SYMTestStatus Implemented |
|
293 |
|
294 @SYMTestActions Tests installation process when the client decides to rollback the changes. |
|
295 |
|
296 @SYMTestExpectedResults The installtion is successfully rolled back and the device is in the |
|
297 same state as before the installation attempt. |
|
298 */ |
|
299 void CT_IntegritySupportTestStep::TestManualRollback2L() |
|
300 { |
|
301 INFO_PRINTF1(_L("Testing removal rollback...")); |
|
302 CleanupAndReset(iSession, KApplication5); |
|
303 |
|
304 iSession.PrepareNonNativeApplicationsUpdatesL(); |
|
305 INFO_PRINTF1(_L("..registering app using RegisterNonNativeApplicationL() ")); |
|
306 CallRegisterL(iSession, KApplication5); |
|
307 iSession.CommitNonNativeApplicationsUpdatesL(); |
|
308 |
|
309 TEST(AppPresent(iSession, KApplication5)); |
|
310 |
|
311 INFO_PRINTF1(_L("..deregistering app using DeregisterNonNativeApplicationL() ")); |
|
312 iSession.PrepareNonNativeApplicationsUpdatesL(); |
|
313 CallDeregisterL(iSession, KApplication5); |
|
314 |
|
315 // Check that all is still present as we haven't committed yet |
|
316 TEST(AppPresent(iSession, KApplication5)); |
|
317 iSession.RollbackNonNativeApplicationsUpdates(); |
|
318 |
|
319 // Check that app is in list of installed apps, still |
|
320 TEST(AppPresent(iSession, KApplication5)); |
|
321 |
|
322 // Cleanup and remove app |
|
323 CompleteDeregisterL(iSession, KApplication5); |
|
324 |
|
325 // Check that app is not in list of installed apps anymore |
|
326 TEST(AppAbsent(iSession, KApplication5)); |
|
327 } |
|
328 |
|
329 /** |
|
330 @SYMTestCaseID T-IntegritySupportTestStep-TestRollbackWithoutPrepareL |
|
331 |
|
332 @SYMPREQ |
|
333 |
|
334 @SYMTestCaseDesc Tests that calling RollbackNonNativeApplicationsUpdates works even if |
|
335 the client hasn't calling the PrepareNonNativeApplicationsUpdatesL function. |
|
336 |
|
337 @SYMTestPriority |
|
338 |
|
339 @SYMTestStatus Implemented |
|
340 |
|
341 @SYMTestActions Tests that calling RollbackNonNativeApplicationsUpdates works even if |
|
342 the client hasn't calling the PrepareNonNativeApplicationsUpdatesL function. |
|
343 |
|
344 @SYMTestExpectedResults The function doesn't return an error. |
|
345 */ |
|
346 void CT_IntegritySupportTestStep::TestRollbackWithoutPrepareL() |
|
347 { |
|
348 INFO_PRINTF1(_L("Testing RollbackNonNativeApplicationsUpdates without prepare before...")); |
|
349 // Just call the function, if it doesn't panic, we assume it works |
|
350 iSession.RollbackNonNativeApplicationsUpdates(); |
|
351 } |
|
352 |
|
353 /** |
|
354 @SYMTestCaseID T-IntegritySupportTestStep-TestRegisterWithoutPrepareL |
|
355 |
|
356 @SYMPREQ |
|
357 |
|
358 @SYMTestCaseDesc Tests that calling RegisterNonNativeApplicationL fails if |
|
359 PrepareNonNativeApplicationsUpdatesL hasn't been called. |
|
360 |
|
361 @SYMTestPriority |
|
362 |
|
363 @SYMTestStatus Implemented |
|
364 |
|
365 @SYMTestActions Call RegisterNonNativeApplicationL without calling PrepareNonNativeApplicationsUpdatesL |
|
366 first. |
|
367 |
|
368 @SYMTestExpectedResults The function returns KErrNotReady. |
|
369 */ |
|
370 void CT_IntegritySupportTestStep::TestRegisterWithoutPrepareL() |
|
371 { |
|
372 INFO_PRINTF1(_L("Testing RegisterNonNativeApplicationL without prepare before...")); |
|
373 TRAPD(err, CallRegisterL(iSession,KApplication1)); |
|
374 TEST(err == KErrNotReady); |
|
375 } |
|
376 |
|
377 /** |
|
378 @SYMTestCaseID T-IntegritySupportTestStep-TestCallingPrepareTwiceL |
|
379 |
|
380 @SYMPREQ |
|
381 |
|
382 @SYMTestCaseDesc Tests that calling PrepareNonNativeApplicationsUpdatesL twice fails. |
|
383 |
|
384 @SYMTestPriority |
|
385 |
|
386 @SYMTestStatus Implemented |
|
387 |
|
388 @SYMTestActions Call PrepareNonNativeApplicationsUpdatesL twice. |
|
389 |
|
390 @SYMTestExpectedResults The second call returns KErrNotReady. |
|
391 */ |
|
392 void CT_IntegritySupportTestStep::TestCallingPrepareTwiceL() |
|
393 { |
|
394 INFO_PRINTF1(_L("Testing PrepareNonNativeApplicationsUpdatesL twice...")); |
|
395 |
|
396 // Should work |
|
397 iSession.PrepareNonNativeApplicationsUpdatesL(); |
|
398 |
|
399 // Shouldn't work since already called |
|
400 TRAPD(err, iSession.PrepareNonNativeApplicationsUpdatesL()); |
|
401 TEST(err == KErrInUse); |
|
402 iSession.RollbackNonNativeApplicationsUpdates(); |
|
403 |
|
404 // Should work again since we have rolled back |
|
405 iSession.PrepareNonNativeApplicationsUpdatesL(); |
|
406 iSession.RollbackNonNativeApplicationsUpdates(); |
|
407 } |
|
408 |
|
409 /** |
|
410 @SYMTestCaseID T-IntegritySupportTestStep-TestCallingPrepareFromTwoSessionsL |
|
411 |
|
412 @SYMPREQ |
|
413 |
|
414 @SYMTestCaseDesc Tests that commiting an app update when another session |
|
415 has already installed it is successfull. |
|
416 |
|
417 @SYMTestPriority |
|
418 |
|
419 @SYMTestStatus Implemented |
|
420 |
|
421 @SYMTestActions Call PrepareNonNativeApplicationsUpdatesL from a session and then from |
|
422 another one. |
|
423 |
|
424 @SYMTestExpectedResults The second call returns KErrNone. |
|
425 */ |
|
426 void CT_IntegritySupportTestStep::TestCallingPrepareFromTwoSessionsL() |
|
427 { |
|
428 INFO_PRINTF1(_L("Testing PrepareNonNativeApplicationsUpdatesL and other function calls from 2 sessions...")); |
|
429 INFO_PRINTF1(_L(" Cleaning up any existing reg files first...")); |
|
430 |
|
431 CleanupAndReset(iSession, KApplication1); |
|
432 |
|
433 INFO_PRINTF1(_L(" Running test...")); |
|
434 |
|
435 // open a second session |
|
436 RTestableApaLsSession session2; |
|
437 User::LeaveIfError(session2.Connect()); |
|
438 CleanupClosePushL(session2); |
|
439 |
|
440 // Prepare & Register with the first session |
|
441 iSession.PrepareNonNativeApplicationsUpdatesL(); |
|
442 CallRegisterL(iSession, KApplication1); |
|
443 |
|
444 // Prepare, Register & Deregister with the second session |
|
445 TRAPD(err,session2.PrepareNonNativeApplicationsUpdatesL()); |
|
446 TEST(err == KErrNone); |
|
447 CallRegisterL(session2, KApplication1); |
|
448 |
|
449 // commit the updates with iSession, installing app 1 |
|
450 TRAP(err, iSession.CommitNonNativeApplicationsUpdatesL()); |
|
451 TEST(err == KErrNone); |
|
452 |
|
453 // both sessions should now report app 1 as installed |
|
454 TEST(AppPresent(iSession, KApplication1)); |
|
455 TEST(AppPresent(session2, KApplication1)); |
|
456 |
|
457 // Try to commit with session 2 |
|
458 // This could be an upgrade of the app so completes successfully |
|
459 TRAP(err, session2.CommitNonNativeApplicationsUpdatesL()); |
|
460 INFO_PRINTF2(_L("Err: %d "), err); |
|
461 TEST(err == KErrNone); |
|
462 |
|
463 // check that nothing was damaged |
|
464 TEST(AppPresent(iSession, KApplication1)); |
|
465 TEST(AppPresent(session2, KApplication1)); |
|
466 |
|
467 CleanupStack::PopAndDestroy(&session2); |
|
468 |
|
469 // clean up |
|
470 CompleteDeregisterL(iSession, KApplication1); |
|
471 TEST(AppAbsent(iSession, KApplication1)); |
|
472 } |
|
473 |
|
474 /** |
|
475 @SYMTestCaseID T-IntegritySupportTestStep-TestReregisterApplicationL |
|
476 |
|
477 @SYMPREQ |
|
478 |
|
479 @SYMTestCaseDesc Tests we can deregister an already-installed app and reregister it in |
|
480 one transaction |
|
481 |
|
482 @SYMTestPriority |
|
483 |
|
484 @SYMTestStatus Implemented |
|
485 |
|
486 @SYMTestActions Call Prepare updates, Deregister, Register, Commit |
|
487 |
|
488 @SYMTestExpectedResults All successful, no panics |
|
489 */ |
|
490 void CT_IntegritySupportTestStep::TestReregisterApplicationL() |
|
491 { |
|
492 INFO_PRINTF1(_L("Testing deregister/register of an application in one transaction...")); |
|
493 INFO_PRINTF1(_L(" Cleaning up any existing reg files first...")); |
|
494 |
|
495 CleanupAndReset(iSession, KApplication1); |
|
496 |
|
497 INFO_PRINTF1(_L(" Registering beforehand so that the deregister has something to do...")); |
|
498 CompleteRegisterL(iSession, KApplication1); |
|
499 |
|
500 // test that it has installed OK |
|
501 TEST(AppPresent(iSession, KApplication1)); |
|
502 |
|
503 INFO_PRINTF1(_L(" Running test...")); |
|
504 // Prepare, Deregister & Register |
|
505 iSession.PrepareNonNativeApplicationsUpdatesL(); |
|
506 CallDeregisterL(iSession, KApplication1); |
|
507 CallRegisterL(iSession, KApplication1); |
|
508 TRAPD(err, iSession.CommitNonNativeApplicationsUpdatesL()); |
|
509 TEST(err == KErrNone); |
|
510 |
|
511 // test that it is still installed OK |
|
512 TEST(AppPresent(iSession, KApplication1)); |
|
513 |
|
514 // clean up |
|
515 CompleteDeregisterL(iSession, KApplication1); |
|
516 } |
|
517 |
|
518 /** |
|
519 @SYMTestCaseID T-IntegritySupportTestStep-TestDoubleInstallFailsL |
|
520 |
|
521 @SYMPREQ |
|
522 |
|
523 @SYMTestCaseDesc |
|
524 |
|
525 @SYMTestPriority |
|
526 |
|
527 @SYMTestStatus Implemented |
|
528 |
|
529 @SYMTestActions |
|
530 |
|
531 @SYMTestExpectedResults |
|
532 */ |
|
533 void CT_IntegritySupportTestStep::TestDoubleInstallFailsL() |
|
534 { |
|
535 INFO_PRINTF1(_L("Testing double register of an application in one transaction...")); |
|
536 INFO_PRINTF1(_L(" Cleaning up any existing reg files first...")); |
|
537 |
|
538 CleanupAndReset(iSession, KApplication1); |
|
539 |
|
540 // test that the application is absent |
|
541 TEST(AppAbsent(iSession, KApplication1)); |
|
542 |
|
543 INFO_PRINTF1(_L(" Running test...")); |
|
544 iSession.PrepareNonNativeApplicationsUpdatesL(); |
|
545 CallRegisterL(iSession, KApplication1); |
|
546 CallRegisterL(iSession, KApplication1); |
|
547 TRAPD(err, iSession.CommitNonNativeApplicationsUpdatesL()); |
|
548 TEST(err == KErrAccessDenied); // Since app is already registered, KErrAccessDenied will be returned when try to delete the registered app. |
|
549 |
|
550 // test that the rollback happened when the second register failed, |
|
551 // and thus the app is still absent |
|
552 TEST(AppAbsent(iSession, KApplication1)); |
|
553 |
|
554 // test that things still work |
|
555 TRAP(err, CompleteRegisterL(iSession, KApplication1)); |
|
556 TEST(err == KErrNone); |
|
557 TEST(AppPresent(iSession, KApplication1)); |
|
558 |
|
559 CompleteDeregisterL(iSession, KApplication1); |
|
560 TEST(AppAbsent(iSession, KApplication1)); |
|
561 } |
|
562 |
|
563 /** |
|
564 @SYMTestCaseID T-IntegritySupportTestStep-TestRollbackOnFailedUpdateStepL |
|
565 |
|
566 @SYMPREQ |
|
567 |
|
568 @SYMTestCaseDesc |
|
569 |
|
570 @SYMTestPriority |
|
571 |
|
572 @SYMTestStatus Implemented |
|
573 |
|
574 @SYMTestActions |
|
575 |
|
576 @SYMTestExpectedResults |
|
577 */ |
|
578 void CT_IntegritySupportTestStep::TestRollbackOnFailedUpdateStepL() |
|
579 { |
|
580 INFO_PRINTF1(_L("Testing register app1, deregister app2, then a force-failed update that causes the first two to roll back...")); |
|
581 INFO_PRINTF1(_L(" Cleaning up any existing reg files first...")); |
|
582 |
|
583 CleanupAndReset(iSession, KApplication1); |
|
584 CleanupAndReset(iSession, KApplication2); |
|
585 |
|
586 // test that both apps are absent |
|
587 TEST(AppAbsent(iSession, KApplication1)); |
|
588 TEST(AppAbsent(iSession, KApplication2)); |
|
589 |
|
590 // register app 2 and check |
|
591 TRAPD(err,CompleteRegisterL(iSession, KApplication2)); |
|
592 TEST(err == KErrNone); |
|
593 TEST(AppAbsent(iSession, KApplication1)); |
|
594 TEST(AppPresent(iSession, KApplication2)); |
|
595 |
|
596 INFO_PRINTF1(_L(" Running test...")); |
|
597 iSession.PrepareNonNativeApplicationsUpdatesL(); |
|
598 // call register/deregister/fail operations |
|
599 CallRegisterL(iSession, KApplication1); |
|
600 CallDeregisterL(iSession, KApplication2); |
|
601 iSession.AddFailingNonNativeApplicationsUpdate(); |
|
602 // test that nothing has changed yet |
|
603 TEST(AppAbsent(iSession, KApplication1)); |
|
604 TEST(AppPresent(iSession, KApplication2)); |
|
605 // commit, expect KErrGeneral from the force-fail step |
|
606 TRAP(err, iSession.CommitNonNativeApplicationsUpdatesL()); |
|
607 TEST(err == KErrGeneral); |
|
608 // make sure nothing has changed, i.e. everything rolled back ok |
|
609 TEST(AppAbsent(iSession, KApplication1)); |
|
610 TEST(AppPresent(iSession, KApplication2)); |
|
611 |
|
612 // test that things still work |
|
613 iSession.PrepareNonNativeApplicationsUpdatesL(); |
|
614 CallRegisterL(iSession, KApplication1); |
|
615 CallDeregisterL(iSession, KApplication2); |
|
616 TRAP(err,iSession.CommitNonNativeApplicationsUpdatesL()); |
|
617 TEST(err == KErrNone); |
|
618 TEST(AppPresent(iSession, KApplication1)); |
|
619 TEST(AppAbsent(iSession, KApplication2)); |
|
620 |
|
621 CompleteDeregisterL(iSession, KApplication1); |
|
622 TEST(AppAbsent(iSession, KApplication1)); |
|
623 } |