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