systemhealthmanagement/systemhealthmgr/test/tstartsafe/src/tstartsafe_apptimesucc.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 <startupproperties.h>
       
    23 #include <hal.h>
       
    24 
       
    25 #include "startsafe.h"
       
    26 #include "tstartsafe_apptimesucc.h"
       
    27 #include "testappslow.h"
       
    28 #include "testapps.h"
       
    29 
       
    30 
       
    31 const TInt KAppTimeSuccWaitTimeTimeoutMargin = 1600; //400; // milliseconds
       
    32 const TInt KKAppTimeSuccWaitTime = KTestAppSlowTimeoutInMilliSeconds + KAppTimeSuccWaitTimeTimeoutMargin;
       
    33 
       
    34 /**
       
    35 Old Test CaseID 		APPFWK-STARTSAFE-0006
       
    36 New Test CaseID 		DEVSRVS-SHMA-STARTSAFE-0006
       
    37  */
       
    38 
       
    39 TVerdict CAppFwkStartSafeTestStepAppTimeSucc::doTestStepL()
       
    40 	{
       
    41 	
       
    42 	CStartSafe *startSafe = CStartSafe::NewL();	
       
    43 	CleanupStack::PushL(startSafe);
       
    44 	
       
    45 	CStartupProperties *prop = CStartupProperties::NewL();
       
    46 	CleanupStack::PushL(prop);
       
    47 
       
    48 	RProcess proc;
       
    49 	CleanupClosePushL( proc );
       
    50 		
       
    51 	prop->SetFileParamsL( KTestAppSlow, KNullDesC );
       
    52 	prop->SetStartupType( EStartApp );	
       
    53 	prop->SetStartMethod( EWaitForStart );
       
    54 	prop->SetNoOfRetries( 0 );
       
    55 	prop->SetTimeout( KKAppTimeSuccWaitTime );
       
    56 
       
    57 	
       
    58 	TInt tried = 0;
       
    59 	TInt nTicksInMicroseconds = 0;
       
    60 	HAL::Get( HAL::ENanoTickPeriod, nTicksInMicroseconds );
       
    61 	INFO_PRINTF2( _L("System nano-ticks in uSec = %d"), nTicksInMicroseconds );
       
    62 	
       
    63 	TUint nTicks = User::NTickCount();	
       
    64 	
       
    65 	INFO_PRINTF1( _L("Starting the slow app") );
       
    66 	TRAPD( err, startSafe->StartL(*prop, proc, tried) );
       
    67 	
       
    68 	nTicks = ( User::NTickCount() - nTicks );
       
    69 	INFO_PRINTF2( _L("milliseconds after = %d"), nTicks * (nTicksInMicroseconds / 1000) );
       
    70 	INFO_PRINTF2( _L("Of which test-app tardiness accounts for = %dms"), KTestAppSlowTimeoutInMilliSeconds );
       
    71 	
       
    72 	
       
    73 	// Prepare to check that the process is the app we think it is.
       
    74 	TPtrC procNamePtr = proc.FileName().Right( KTestAppSlow().Length() );
       
    75 	TInt nameComparison = procNamePtr.Compare( KTestAppSlow() );	
       
    76 	
       
    77 	if( (KErrNone == err) && (0 == nameComparison) )
       
    78 		{
       
    79 		SetTestStepResult( EPass );
       
    80 		INFO_PRINTF2( _L("Application \"%S\" started correctly (albeit slowly)"), &procNamePtr );
       
    81 		INFO_PRINTF1( _L("Test passed") );
       
    82 		}
       
    83 	else
       
    84 		{
       
    85 		ERR_PRINTF2(_L("Test Failed StartSafe returned %d"), err );
       
    86 		INFO_PRINTF2(_L("Process name returned \"%S\""), &procNamePtr );
       
    87 		
       
    88 		SetTestStepResult( EFail );	
       
    89 		}
       
    90 
       
    91 	// Dispose of the test-app.	
       
    92 	if( 0 == nameComparison )
       
    93 		{
       
    94 		proc.Kill( KErrNone );			
       
    95 		}
       
    96 		
       
    97 		
       
    98 	CleanupStack::PopAndDestroy( 3, startSafe );
       
    99 
       
   100 	return TestStepResult();	
       
   101 	}
       
   102 
       
   103 
       
   104 
       
   105 CAppFwkStartSafeTestStepAppTimeSucc::CAppFwkStartSafeTestStepAppTimeSucc()
       
   106 	{
       
   107 	SetTestStepName(KCTestCaseAppTimeSucc);
       
   108 	}
       
   109