systemhealthmanagement/systemhealthmgr/test/tsysmon/src/tsysmon_steprestartthrottle.cpp
changeset 63 09d657f1ee00
parent 0 4e1aa6a622a0
child 61 8cb079868133
equal deleted inserted replaced
54:072a9626b290 63:09d657f1ee00
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    69 	return TestStepResult();	
    69 	return TestStepResult();	
    70 	}
    70 	}
    71 
    71 
    72 void CStepRestartThrottle::DoTestMonitor()
    72 void CStepRestartThrottle::DoTestMonitor()
    73 	{
    73 	{
       
    74     TInt millisecs1 =0;
       
    75     TDateTime datetime;
       
    76     TTime time;
       
    77     time.HomeTime();
       
    78     datetime = time.DateTime();
       
    79     millisecs1 = (datetime.MicroSecond() / 1000) + 
       
    80                 (datetime.Second() * 1000) + 
       
    81                 (datetime.Minute() * 60 * 1000) +
       
    82                 (datetime.Hour() * 60 * 60 * 1000);
       
    83                 
    74 	//Sleep 14 seconds and then assert that the server is not yet restarted
    84 	//Sleep 14 seconds and then assert that the server is not yet restarted
    75 	INFO_PRINTF1(_L("Going to sleep for 14 seconds."));		
    85 	INFO_PRINTF1(_L("Going to sleep for 14 seconds."));		
    76 	User::After(KThrottleTime - 1000000);
    86 	User::After(KThrottleTime - 1000000);
    77 	RTestProcGoodSession server;
    87 	RTestProcGoodSession server;
    78 	TInt err = server.Connect();
    88 	TInt err = server.Connect();
    89 		
    99 		
    90 	//Allow the process to be restarted
   100 	//Allow the process to be restarted
    91 	INFO_PRINTF1(_L("Waiting till the process is restarted using semaphore."));		
   101 	INFO_PRINTF1(_L("Waiting till the process is restarted using semaphore."));		
    92 	//Wait for the process to be restarted 
   102 	//Wait for the process to be restarted 
    93 	iProcStartSignalSem.Wait();
   103 	iProcStartSignalSem.Wait();
       
   104 	
       
   105     time.HomeTime();
       
   106     datetime = time.DateTime();
       
   107     TInt millisecs2 = 0;
       
   108     millisecs2 = (datetime.MicroSecond() / 1000) + 
       
   109                 (datetime.Second() * 1000) + 
       
   110                 (datetime.Minute() * 60 * 1000) +
       
   111                 (datetime.Hour() * 60 * 60 * 1000);
    94 		
   112 		
    95 	//Assert that the server is running
   113 	//Assert that the server is running
    96 	INFO_PRINTF1(_L("Woke up, now the server should be restarted (sysmon KWaitTime is 15s)."));		
   114 	INFO_PRINTF1(_L("Woke up, now the server should be restarted (sysmon KWaitTime is 15s)."));		
    97 	err = server.Connect();
   115 	err = server.Connect();
    98 	TESTE(KErrNone == err, err);
   116 	TESTE(KErrNone == err, err);
       
   117 	INFO_PRINTF2(_L("Server restarted after %d ms"), (millisecs2 - millisecs1));
       
   118 	//Testing whether the server restarted after the throttle time, which is 15s
       
   119 	TEST((millisecs2 - millisecs1) >= 15000);
    99 	if(KErrNone == err)
   120 	if(KErrNone == err)
   100 		{
   121 		{
   101 		INFO_PRINTF1(_L("Yes, asserted that server is running, going to cancel monitoring shutdown server"));		
   122 		INFO_PRINTF1(_L("Yes, asserted that server is running, going to cancel monitoring shutdown server"));		
   102 		}
   123 		}
   103 	server.CancelMonitor();
   124 	server.CancelMonitor();