uifw/AvKon/tsrc/bc/bctestutil/src/bctestutil.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:  Test utility, the interface of test framework.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <eikenv.h>
       
    20 
       
    21 #include "bctestutil.h"
       
    22 #include "bctestsuite.h"
       
    23 #include "bctestlogger.h"
       
    24 #include "bctestkeyfeeder.h"
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // C++ default Constructor
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CBCTestUtil::CBCTestUtil()    
       
    33     {
       
    34     }
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // 2nd Constructor
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 void CBCTestUtil::ConstructL()
       
    41     {
       
    42     CEikonEnv* eikonEnv = CEikonEnv::Static();
       
    43         
       
    44     iLogger = CBCTestLogger::NewL( eikonEnv );    
       
    45     iTestSuite = new( ELeave ) CBCTestSuite( iLogger );
       
    46     iKeyFeeder = new( ELeave ) CBCTestKeyFeeder();
       
    47     iKeyFeeder->SetSuite( iTestSuite );
       
    48     
       
    49     iAutoTest.scripts = NULL;
       
    50     iAutoTest.countArray = NULL;
       
    51     iAutoTest.scriptCount = 0;
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // static ConstructL
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 EXPORT_C CBCTestUtil* CBCTestUtil::NewL()
       
    59     {
       
    60     CBCTestUtil* util = new( ELeave ) CBCTestUtil();    
       
    61     CleanupStack::PushL( util );
       
    62     util->ConstructL();
       
    63     CleanupStack::Pop( util );    
       
    64     return util;
       
    65     }
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // Destructor
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 EXPORT_C CBCTestUtil::~CBCTestUtil()
       
    72     {        
       
    73     delete iKeyFeeder;            
       
    74     delete [] iAutoTest.countArray;
       
    75     delete [] iAutoTest.scripts;
       
    76     iAutoTest.nameArray.Close();
       
    77     delete iTestSuite;
       
    78     delete iLogger;
       
    79     }
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // CBCTestUtil::RunL
       
    83 // Execute automatic test.
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 EXPORT_C void CBCTestUtil::RunL()
       
    87     {  
       
    88     iTestSuite->BuildScriptsL( &iAutoTest );    
       
    89     iKeyFeeder->StartAutoTestL( &iAutoTest );   
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // CBCTestUtil::RunL
       
    94 // Execute a command specified by the command.
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 EXPORT_C void CBCTestUtil::RunL( TInt aCmd )
       
    98     {
       
    99     iTestSuite->RunL( aCmd );
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // CBCTestUtil::AddTestCaseL
       
   104 // Add test case to test suite.
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 EXPORT_C void CBCTestUtil::AddTestCaseL( 
       
   108     CBCTestCase* aTestCase, const TDesC& aName )
       
   109     {
       
   110     iTestSuite->AddTestCaseL( aTestCase, aName );
       
   111     }
       
   112