phonebookengines/contactsmodel/tsrc/Integration/TestStartUp/src/TestStartUpExeStep.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 11 Jun 2010 13:29:23 +0300
changeset 40 b46a585f6909
parent 24 0ba2181d7c28
permissions -rw-r--r--
Revision: 201021 Kit: 2010123

/*
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/


#include "teststartupexestep.h"

CTestStartUpExeStep::~CTestStartUpExeStep()
/**
 * Destructor
 */
	{
	}

CTestStartUpExeStep::CTestStartUpExeStep(CTestStartUpServer& aTestServerPtr) 
/**
 * Constructor
 */
	{ 
	// Call base class method to set up the human readable name for logging
	SetTestStepName(KTestStartUpExeStep);
	iTestServerPtr = &aTestServerPtr;
	}

TVerdict CTestStartUpExeStep::doTestStepPreambleL()
/**Step
 * @return - TVerdict code
 * Override of base class virtual
 */
 	{
 	SetTestStepResult(EPass);	
 	GetStringFromConfig(ConfigSection(),KStartupnameTag,iCntsStarupExeName);
 	GetStringFromConfig(ConfigSection(),KStartupActionTag,iStartupAction); 	 
 	GetIntFromConfig(ConfigSection(),KExitReasonTag,iExitReasonFromIni); 
 	GetStringFromConfig(ConfigSection(),KModeTag,iServerMode);
 	
 	//Fetch the expected exit type for the cnts server process and convert
 	//to the correct type
 	TInt exitTypeFromIni;
 	if (GetIntFromConfig(ConfigSection(),KExitTypeTag,exitTypeFromIni))
 	    {
 		switch (exitTypeFromIni)
 	        {
 	        case (0):
 	        iExitTypeFromIni = EExitKill;
 	        break;
 	    
 	        case (1):
 	        iExitTypeFromIni = EExitTerminate;
 	        break;
 	    
 	        case (2):
 	        iExitTypeFromIni = EExitPanic;
 	        break;
 	    
 	        case (3):
 	        iExitTypeFromIni = EExitPending;
 	        break;
 	    
 	        default:
 	        _LIT(KinvalidExitType,"Invalid Exit Type Read From ini File");
 	        ERR_PRINTF1(KinvalidExitType);
 	        SetTestStepResult(EFail);
 	        }
 	    }    	
 	return TestStepResult(); 	
 	}
 	

TVerdict CTestStartUpExeStep::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class virtual. Implements the main control
 * for the test step. Depending on the action requested the stored
 * TestServer pointer is used to either launch, terminate or check
 * the contacts server.
 */
    {
    SetTestStepResult(EPass);
    
    if (iStartupAction.Compare(KLaunch) == KErrNone)
 	    {
 		TInt err = iTestServerPtr->LaunchCntsStartUpExe(iCntsStarupExeName,iServerMode);
        if(err != KErrNone)
            {
        	SetTestStepResult(EFail);
            }
 	    } 	    
 
 	else if (iStartupAction.Compare(KCheck) == KErrNone)
 	    {
 		TBool res = iTestServerPtr->CheckCntsStartUpExe(iExitTypeFromIni,iExitReasonFromIni);
        if(!res)
            {
        	SetTestStepResult(EFail);
            } 
 	    }
 	    
 	else if (iStartupAction.Compare(KTerminate) == KErrNone)
 	    {
 		iTestServerPtr->TermCntsStartUpExe();
 	    } 	  
 	    
    else
        {
    	//illegal action
    	SetTestStepResult(EFail);
        } 	    
    
 	return TestStepResult();
    };
  
 
 TVerdict CTestStartUpExeStep::doTestStepPostambleL()
 /**
 * @return - TVerdict code
 * Override of base class virtual
 */
    {
	return TestStepResult();
	}