testexecmdw/tef/tef/tefunit/src/ctestcommand.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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file CTestCommand.cpp
       
    22 */
       
    23 
       
    24 #include "ctestcommand.h"
       
    25 #include "crunner.h"
       
    26 
       
    27 CTestCommand::CTestCommand(const TDes& aStepPath, CTestSuite* aSuite )
       
    28 /**
       
    29  * Constructor
       
    30  *
       
    31  * @param aStepPath - Path of the test to execute
       
    32  * @param aSuite - Suite of tests
       
    33  */
       
    34 	: iSuite(aSuite), iStepPath(aStepPath)
       
    35 	{
       
    36 	}
       
    37 
       
    38 CTestCommand::~CTestCommand()
       
    39 /**
       
    40  * Destructor
       
    41  */
       
    42 	{
       
    43 	}
       
    44 
       
    45 TVerdict CTestCommand::doTestStepL()
       
    46 /**
       
    47  * dotestStepL
       
    48  */
       
    49 	{
       
    50 	// Create a test config from this test step
       
    51 	CTestConfig testConfig(this);
       
    52 	
       
    53 	// Search for the test/suite of tests and run it/them
       
    54 	CRunner* runner = CRunner::NewL( iStepPath, testConfig,	Logger() );
       
    55 	CleanupStack::PushL(runner);
       
    56 	TRAPD( err, iSuite->AcceptL( *runner ) );
       
    57 
       
    58 	if( err != KErrTEFUnitPass )
       
    59 		{
       
    60 		// Map the TEFVerdict onto a TVerdict for TestExecute
       
    61 		switch(err)
       
    62 			{
       
    63 			case KErrTEFUnitFail:
       
    64 				{
       
    65 				SetTestStepResult(EFail);
       
    66 				}
       
    67 				break;
       
    68 			case KErrTEFUnitInconclusive:
       
    69 				{
       
    70 				SetTestStepResult(EInconclusive);
       
    71 				}
       
    72 				break;
       
    73 			case KErrTEFUnitTestSuiteError:
       
    74 				{
       
    75 				SetTestStepResult(ETestSuiteError);
       
    76 				}
       
    77 				break;
       
    78 			case KErrTEFUnitAbort:
       
    79 				{
       
    80 				SetTestStepResult(EAbort);
       
    81 				}
       
    82 				break;
       
    83 			case KErrTEFUnitIgnore:
       
    84 				{
       
    85 				SetTestStepResult(EIgnore);
       
    86 				}
       
    87 				break;
       
    88 			default:
       
    89 				{
       
    90 				// Else, if another error code is contained in the leave,
       
    91 				//  leave again
       
    92 				User::Leave(err);
       
    93 				}
       
    94 				break;
       
    95 			}
       
    96 		}
       
    97 
       
    98 	// Cleanup
       
    99 	CleanupStack::PopAndDestroy(runner);
       
   100 
       
   101 	return TestStepResult();
       
   102 }