localisation/apparchitecture/tef/T_IntegritySupportRebootStep.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     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_IntegritySupportRebootStep.h"
       
    24 
       
    25 /**
       
    26  * Constructor
       
    27  */	
       
    28 CT_IntegritySupportReboot1TestStep::CT_IntegritySupportReboot1TestStep()
       
    29 	{
       
    30 	// Call base class method to set up the human readable name for logging
       
    31 	SetTestStepName(KT_IntegritySupportReboot1Step);
       
    32 	}
       
    33 
       
    34 /**
       
    35  * Destructor
       
    36  */
       
    37 CT_IntegritySupportReboot1TestStep::~CT_IntegritySupportReboot1TestStep()
       
    38 	{
       
    39 	iSession.Close();
       
    40 	iUtils.Close();
       
    41 	}
       
    42 
       
    43 /**
       
    44  * @return - TVerdict code
       
    45  * Override of base class virtual
       
    46  */	
       
    47 TVerdict CT_IntegritySupportReboot1TestStep::doTestStepPreambleL()
       
    48 	{
       
    49 	SetTestStepResult(EPass);
       
    50 	doAbstractNonNativeAppsTestStepPreambleL();
       
    51 	return TestStepResult();
       
    52 	}
       
    53 
       
    54 /**
       
    55  * @return - TVerdict code
       
    56  * Override of base class virtual
       
    57  */
       
    58 TVerdict CT_IntegritySupportReboot1TestStep::doTestStepPostambleL()
       
    59 	{
       
    60 	return TestStepResult();
       
    61 	}
       
    62 
       
    63 TVerdict CT_IntegritySupportReboot1TestStep::doTestStepL()
       
    64 	{
       
    65 	INFO_PRINTF1(_L("Testing Apparc...T_IntegritySupportReboot1 Test Cases Running..."));
       
    66 
       
    67 	TRAPD(ret,RunTestCasesL())
       
    68 	TEST(ret==KErrNone);
       
    69 	
       
    70 	INFO_PRINTF1(_L("...T_IntegritySupportReboot1 Test Cases Completed."));
       
    71 
       
    72 	return TestStepResult();
       
    73 	}
       
    74 	
       
    75 TInt CT_IntegritySupportReboot1TestStep::RunTestCasesL()
       
    76 	{
       
    77 	//DONT_CHECK due to recreation of applist on server
       
    78 	HEAP_TEST_LS_SESSION(iSession, 0, DONT_CHECK, TestSetupL(), NO_CLEANUP);
       
    79 	
       
    80 	return KErrNone;
       
    81 	}
       
    82 	
       
    83 _LIT(KLitLogicalExecutable1, "c:\\TestIntegritySupportReboot1.ist");
       
    84 _LIT(KLitRegistrationFile1,"c:\\private\\10003a3f\\import\\apps\\NonNative\\Resource\\102081ce_reg.rsc");
       
    85 static const CT_AbstractNonNativeAppsTestStep::TTestAppDetails KApplication1(0x102081CE,KLitLogicalExecutable1,KLitRegistrationFile1);
       
    86 
       
    87 
       
    88 _LIT(KLitLogicalExecutable2, "c:\\TestIntegritySupportReboot2.ist");
       
    89 _LIT(KLitRegistrationFile2,"c:\\private\\10003a3f\\import\\apps\\NonNative\\Resource\\102081cf_reg.rsc");
       
    90 static const CT_AbstractNonNativeAppsTestStep::TTestAppDetails KApplication2(0x102081CF,KLitLogicalExecutable2,KLitRegistrationFile2);
       
    91 
       
    92 /**
       
    93    @SYMTestCaseID T-IntegritySupportReboot1TestStep-TestSetupL
       
    94   
       
    95    @SYMPREQ 
       
    96   
       
    97    @SYMTestCaseDesc This is only the first half of the test case. It will simulate a
       
    98    reboot in the middle of an installation. 
       
    99    
       
   100    @SYMTestPriority 
       
   101   
       
   102    @SYMTestStatus Implemented
       
   103    
       
   104    @SYMTestActions Simulate a reboot in the middle of an installation.
       
   105    
       
   106    @SYMTestExpectedResults None. See CT_IntegritySupportReboot2TestStep for the actual test.
       
   107  */	
       
   108 void CT_IntegritySupportReboot1TestStep::TestSetupL()
       
   109 	{
       
   110 	INFO_PRINTF1(_L("Setting up reboot recovery test..."));
       
   111 
       
   112 	// so that we can check the presence/absence of stuff before apparc has respawned
       
   113 	RProcess().SetPriority(EPriorityHigh); 
       
   114 
       
   115 	// make sure we're starting from a clean sheet
       
   116 	CleanupAndReset(iSession, KApplication1);
       
   117 	CleanupAndReset(iSession, KApplication2);
       
   118 
       
   119 	// prepare the starting state: KApp1 uninstalled, KApp2 installed
       
   120 	CompleteRegisterL(iSession, KApplication2);
       
   121 	
       
   122 	TEST(AppAbsent(iSession, KApplication1));
       
   123 	TEST(AppPresent(iSession, KApplication2));
       
   124 
       
   125 	// Prepare to install KApp1 and remove KApp2, and then panic after actually performing these steps
       
   126 	iSession.PrepareNonNativeApplicationsUpdatesL();
       
   127 	CallRegisterL(iSession, KApplication1);
       
   128 	CallDeregisterL(iSession, KApplication2);
       
   129 	iSession.AddPanicingNonNativeApplicationsUpdate();
       
   130 
       
   131 	// test that nothing has changed yet
       
   132 	TEST(AppAbsent(iSession, KApplication1));
       
   133 	TEST(AppPresent(iSession, KApplication2));
       
   134 
       
   135 	// commit, expect Apparc to die horribly
       
   136 	// this function will actually restart apparc if it fails the first time
       
   137 	TRAPD(err,iSession.CommitNonNativeApplicationsUpdatesL());
       
   138 	TEST(err == KErrServerTerminated);
       
   139 	
       
   140 	// the files should be as-if the update happened, but we can't check
       
   141 	// the app list because apparc is now dead.
       
   142 	TEST(FilePresent(KLitUpdatedAppsList));
       
   143 	TEST(FilePresent(KApplication1.iRegistrationFile));
       
   144 	TEST(FileAbsent(KApplication2.iRegistrationFile));
       
   145 	}
       
   146 
       
   147 /**
       
   148  * Constructor
       
   149  */	
       
   150 CT_IntegritySupportReboot2TestStep::CT_IntegritySupportReboot2TestStep()
       
   151 	{
       
   152 	// Call base class method to set up the human readable name for logging
       
   153 	SetTestStepName(KT_IntegritySupportReboot2Step);
       
   154 	}
       
   155 
       
   156 /**
       
   157  * Destructor
       
   158  */
       
   159 CT_IntegritySupportReboot2TestStep::~CT_IntegritySupportReboot2TestStep()
       
   160 	{
       
   161 	iSession.Close();
       
   162 	iUtils.Close();
       
   163 	}
       
   164 
       
   165 /**
       
   166  * @return - TVerdict code
       
   167  * Override of base class virtual
       
   168  */	
       
   169 TVerdict CT_IntegritySupportReboot2TestStep::doTestStepPreambleL()
       
   170 	{
       
   171 	SetTestStepResult(EPass);
       
   172 	doAbstractNonNativeAppsTestStepPreambleL();
       
   173 	return TestStepResult();
       
   174 	}
       
   175 
       
   176 /**
       
   177  * @return - TVerdict code
       
   178  * Override of base class virtual
       
   179  */
       
   180 TVerdict CT_IntegritySupportReboot2TestStep::doTestStepPostambleL()
       
   181 	{
       
   182 	return TestStepResult();
       
   183 	}
       
   184 
       
   185 TVerdict CT_IntegritySupportReboot2TestStep::doTestStepL()
       
   186 	{
       
   187 	INFO_PRINTF1(_L("Testing Apparc...T_IntegritySupportReboot2 Test Cases Running..."));
       
   188 
       
   189 	TRAPD(ret,RunTestCasesL())
       
   190 	TEST(ret==KErrNone);
       
   191 	
       
   192 	INFO_PRINTF1(_L("...T_IntegritySupportReboot2 Test Cases Completed."));
       
   193 
       
   194 	return TestStepResult();
       
   195 	}
       
   196 	
       
   197 TInt CT_IntegritySupportReboot2TestStep::RunTestCasesL()
       
   198 	{
       
   199 	HEAP_TEST_LS_SESSION(iSession, 0, 0, TestRollbackL(), NO_CLEANUP);
       
   200 	return KErrNone;
       
   201 	}
       
   202 	
       
   203 /**
       
   204    @SYMTestCaseID T-IntegritySupportReboot2TestStep-TestRollbackL
       
   205   
       
   206    @SYMPREQ 
       
   207   
       
   208    @SYMTestCaseDesc This test case assumes IntegritySupportReboot1TestStep has been run before
       
   209   IntegritySupportReboot1TestStep have been rolled back and that the device is in a consistent state.
       
   210       
       
   211    @SYMTestPriority 
       
   212   
       
   213    @SYMTestStatus Implemented
       
   214    
       
   215    @SYMTestActions Check the presence/absence of KApplication2 and KApplication1 respectively
       
   216    
       
   217    @SYMTestExpectedResults KApplication1 is absent, KApplication2 is present.
       
   218  */	
       
   219 void CT_IntegritySupportReboot2TestStep::TestRollbackL()
       
   220 	{
       
   221 	INFO_PRINTF1(_L("Checking that the device is in a consistent state, with all updates rolled back"));
       
   222 	TEST(AppAbsent(iSession, KApplication1));
       
   223 	TEST(AppPresent(iSession, KApplication2));
       
   224 	}