sysstatemgmt/systemstarter/test/tstartsafe/src/tstartsafe_appasynchstart.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 
       
    24 #include "startsafe.h"
       
    25 #include "tstartsafe_appasynchstart.h"
       
    26 #include "testapps.h"
       
    27 
       
    28 
       
    29 /**
       
    30 Old Test CaseID 		APPFWK-STARTSAFE-0010
       
    31 New Test CaseID 		DEVSRVS-SYSSTART-STARTSAFE-0010
       
    32  */
       
    33 
       
    34 
       
    35 TVerdict CAppFwkStartSafeTestStepAppAsynchStart::doTestStepL()
       
    36 	{
       
    37 	
       
    38 	CStartSafe *startSafe = CStartSafe::NewL();	
       
    39 	CleanupStack::PushL(startSafe);
       
    40 	
       
    41 	CStartupProperties* prop = CStartupProperties::NewL();
       
    42 	CleanupStack::PushL( prop );
       
    43 	
       
    44 	RProcess proc;
       
    45 	CleanupClosePushL( proc );
       
    46 	
       
    47 	prop->SetFileParamsL( KTestAppGood, KNullDesC );
       
    48 	prop->SetStartupType( EStartApp );
       
    49 	prop->SetStartMethod( EDeferredWaitForStart );
       
    50 	
       
    51 	
       
    52 	INFO_PRINTF1( _L("Start the Test-app asynchronously") );
       
    53 	
       
    54 	TRequestStatus commandStatus;
       
    55 	
       
    56 	TRAPD( err, startSafe->StartL(*prop, proc, commandStatus) );	
       
    57 	User::WaitForRequest(commandStatus);
       
    58 
       
    59 	INFO_PRINTF1( _L("Async call returned. Now check the startup status") );
       
    60 	
       
    61 	TPtrC procNamePtr = proc.FileName().Right( KTestAppGood().Length() );
       
    62 	TInt nameComparison = procNamePtr.Compare( KTestAppGood() );
       
    63 		
       
    64 	if ( (commandStatus == KErrNone) && (0 == nameComparison) && (KErrNone == err) )
       
    65 		{
       
    66 		INFO_PRINTF2( _L("Application \"%S\" started correctly"), &procNamePtr );
       
    67 		
       
    68 		SetTestStepResult( EPass );
       
    69 		INFO_PRINTF1( _L("Test passed") );
       
    70 		}
       
    71 	else 
       
    72 		{
       
    73 		SetTestStepResult( EFail );
       
    74 		ERR_PRINTF3( _L("Test failed. TRS = %d, StartL returned %d"), commandStatus.Int(), err );				
       
    75 		}
       
    76 
       
    77 	// Dispose of the test-app.	
       
    78 	if( 0 == nameComparison )
       
    79 		{
       
    80 		proc.Kill( KErrNone );			
       
    81 		}
       
    82 
       
    83 
       
    84 	CleanupStack::PopAndDestroy( 3, startSafe ); // proc, prop, startSafe
       
    85 	
       
    86 	return TestStepResult();	
       
    87 	}
       
    88 
       
    89 
       
    90 
       
    91 CAppFwkStartSafeTestStepAppAsynchStart::CAppFwkStartSafeTestStepAppAsynchStart()
       
    92 	{
       
    93 	SetTestStepName( KCTestCaseAppAsynchStart );
       
    94 	}
       
    95