testexecmdw/tef/tef/tefutilities/platsec/src/testplatseclaunchapp.cpp
branchRCL_3
changeset 3 9397a16b6eb8
parent 1 6edeef394eb7
equal deleted inserted replaced
1:6edeef394eb7 3:9397a16b6eb8
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 * This contains CTestPlatSecLaunchApp class functions implementation.
       
    16 * This class sets the capabilities of the executables and libraries.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #include "testplatseclaunchapp.h"
       
    22 
       
    23 //TEF include
       
    24 #include <test/testexecutelog.h>
       
    25 
       
    26 /*@{*/
       
    27 _LIT(KExecutableName,		"executable");
       
    28 _LIT(KCommandLineParams,	"CommandLineParams");
       
    29 
       
    30 /*@}*/
       
    31 
       
    32 // Test step name
       
    33 _LIT(KLaunchAppStep,	"LaunchApp");
       
    34 
       
    35 /**
       
    36  Destructor
       
    37 */
       
    38 CTestPlatSecLaunchApp::~CTestPlatSecLaunchApp()
       
    39 	{
       
    40 	}
       
    41 
       
    42 /** 
       
    43  Constructor
       
    44 */
       
    45 CTestPlatSecLaunchApp::CTestPlatSecLaunchApp()
       
    46 	{
       
    47 	SetTestStepName(KLaunchAppStep);
       
    48 	}
       
    49 
       
    50 /**
       
    51  The implementation of the CTestStepPlatTest::doTestStepL() pure virutal
       
    52  function.It reads the application name from Config file and tries to 
       
    53  launch the application.
       
    54  @return TVerdict - result of the test step
       
    55  @leave - system wide error codes
       
    56 */
       
    57 TVerdict CTestPlatSecLaunchApp::doTestStepL()
       
    58 	{
       
    59 	
       
    60 
       
    61 	TPtrC ServerName(GetServerName());
       
    62 	INFO_PRINTF1(_L("Server Name"));
       
    63 	INFO_PRINTF2(_L("Server Name %S"), &ServerName);
       
    64 	
       
    65 	//read the executable name from the ini file
       
    66 	TPtrC	appName;
       
    67     TPtrC   commandLine;
       
    68 	if(!GetStringFromConfig(ConfigSection(), KExecutableName, appName))
       
    69 		{
       
    70 		ERR_PRINTF1(_L("Executable/Server name not provided in INI file"));
       
    71 		SetTestStepResult(EFail);
       
    72 		}
       
    73 	else
       
    74 		{
       
    75 		INFO_PRINTF2(_L("Executable name read from the ini file is  %S"),&appName); 
       
    76         if(!GetStringFromConfig(ConfigSection(), KCommandLineParams, commandLine))
       
    77             {
       
    78             INFO_PRINTF1(_L("No Command line arguments provided"));
       
    79             }
       
    80         RProcess process;
       
    81         CleanupClosePushL(process);
       
    82         TInt err=KErrNone;
       
    83         err = process.Create(appName,commandLine);
       
    84         if(err!=KErrNone)
       
    85             {
       
    86             INFO_PRINTF2(_L("Launching the app failed with error : %D"),err);
       
    87             SetTestStepError(err);
       
    88             }
       
    89         else
       
    90             {
       
    91             TRAPD(error,process.Resume();)
       
    92                 if(error!=KErrNone)
       
    93                     {
       
    94                     ERR_PRINTF2(_L("Launching the app failed with error: %D"),err);
       
    95                     SetTestStepError(err);
       
    96                     SetTestStepResult(EFail);
       
    97                     }
       
    98             }
       
    99         CleanupStack::PopAndDestroy(1);
       
   100 		}
       
   101 	return TestStepResult();
       
   102 	}
       
   103