sysstatemgmt/systemstarter/test/tsysmon/src/tsysmon_steprestartthrottle.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code
       
    20 */
       
    21 
       
    22 #include "testprocgoodsession.h"
       
    23 #include "tsysmon_steprestartthrottle.h"
       
    24 
       
    25 
       
    26 CStepRestartThrottle::CStepRestartThrottle()
       
    27 	{
       
    28 	SetTestStepName(KCTestCaseRestartThrottle);
       
    29 	}
       
    30 
       
    31 /**
       
    32 Old Test CaseID 		APPFWK-SYSMON-0004
       
    33 New Test CaseID 		DEVSRVS-SYSSTART-SYSMON-0004
       
    34  */
       
    35 
       
    36 TVerdict CStepRestartThrottle::doTestStepL()
       
    37 	{
       
    38 	INFO_PRINTF1(_L("TEST APPFWK-SYSMON-0003"));
       
    39 	
       
    40 	INFO_PRINTF1(_L("New Test step"));
       
    41 	RProcess process;
       
    42 	CleanupClosePushL(process);
       
    43 	StartAndMonitorL(process, EWaitForStart);
       
    44 	
       
    45 	//Killing the process will cause sysmon to restart after KWaitTime (declared in sysmon_patch.h)
       
    46 	process.Kill(KErrNone);
       
    47 	CleanupStack::PopAndDestroy(&process);
       
    48 	INFO_PRINTF1(_L("Killed monitored process."));
       
    49 	
       
    50 	//Sleep 14 seconds and then assert that the server is not yet restarted
       
    51 	INFO_PRINTF1(_L("Going to sleep for 14 seconds."));		
       
    52 	User::After(KThrottleTime - 1000000);
       
    53 	RTestProcGoodSession server;
       
    54 	TInt err = server.Connect();
       
    55 	TESTE(KErrNotFound == err, err);
       
    56 	server.Close();
       
    57 	if(KErrNotFound == err)
       
    58 		{
       
    59 		INFO_PRINTF1(_L("Asserted that server is not yet restarted."));		
       
    60 		}
       
    61 	else
       
    62 		{
       
    63 		ERR_PRINTF1(_L("Error - the restart took place too soon."));		
       
    64 		}
       
    65 		
       
    66 	//Allow the process to be restarted
       
    67 	INFO_PRINTF1(_L("Going to sleep for 2 more seconds."));		
       
    68 	User::After(2000000);
       
    69 	
       
    70 	//Assert that the server is running
       
    71 	INFO_PRINTF1(_L("Woke up, now the server should be restarted (sysmon KWaitTime is 15s)."));		
       
    72 	err = server.Connect();
       
    73 	TESTE(KErrNone == err, err);
       
    74 	if(KErrNone == err)
       
    75 		{
       
    76 		INFO_PRINTF1(_L("Yes, asserted that server is running, going to cancel monitoring shutdown server"));		
       
    77 		}
       
    78 	server.CancelMonitor();
       
    79 	server.ShutDown();
       
    80 	server.Close();
       
    81 	
       
    82 	INFO_PRINTF1(_L("Test complete"));		
       
    83 	return TestStepResult();	
       
    84 	}