testexecfw/stf/stfext/testmodules/scriptermod/inc/SubTestCaseRunner.h
changeset 2 8bb370ba6d1d
equal deleted inserted replaced
1:bbd31066657e 2:8bb370ba6d1d
       
     1 /*
       
     2  * Copyright (c) 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: This file contains the header file of the TestScripter 
       
    15  * module of STIF Test Framework.
       
    16  *
       
    17  */
       
    18 
       
    19 #ifndef SUBTESTCASERUNNER_H_
       
    20 #define SUBTESTCASERUNNER_H_
       
    21 
       
    22 //  INCLUDES
       
    23 #include <StifTestInterface.h>
       
    24 #include <TestEngineClient.h>
       
    25 #include "TestScripterUtils.h"
       
    26 
       
    27 // CONSTANTS
       
    28 // None
       
    29 
       
    30 // MACROS
       
    31 // None
       
    32 
       
    33 // DATA TYPES
       
    34 // None
       
    35 
       
    36 // FUNCTION PROTOTYPES
       
    37 // None
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 class CTestRunner;
       
    41 class CSlave;
       
    42 class CRemoteCallsProxy;
       
    43 
       
    44 // CLASS DECLARATION
       
    45 // DESCRIPTION
       
    46 // CSubTestCaseRunner manages sub test cases execution and retuns 
       
    47 // execution results to CTestRunner
       
    48 NONSHARABLE_CLASS(CSubTestCaseRunner): public CActive
       
    49     {
       
    50 public:
       
    51     enum TSubTestCaseType { ESTTLocal, ESTTRemote };
       
    52     enum TSubTestCaseState { ESTSIdle, ESTSRunning, ESTSPaused };
       
    53 public:
       
    54     /**
       
    55      * Coinstructor.
       
    56      */
       
    57     CSubTestCaseRunner();
       
    58 
       
    59     /**
       
    60      * Starts execution of selected test case.
       
    61      */
       
    62     virtual void RunSubTestCaseL( CStartInfo& aStartTestCaseInfo ) = 0;
       
    63     
       
    64     /**
       
    65      * Pauses selected sub test case.
       
    66      */
       
    67     virtual void PauseSubTestCaseL() = 0;
       
    68     
       
    69     /**
       
    70      * Reasume selected sub test case.
       
    71      */
       
    72     virtual void ResumeSubTestCaseL() = 0;
       
    73     
       
    74     virtual void CancelSubTestCaseL() = 0;
       
    75     
       
    76     
       
    77     /**
       
    78      * Gets execution result.
       
    79      */
       
    80     virtual TInt GetRunResult() const = 0;
       
    81 
       
    82     /**
       
    83      * Gets test case execution result..
       
    84      */
       
    85     virtual const TFullTestResult& GetTestCaseResult() const = 0;
       
    86     
       
    87     /**
       
    88      * Gets executed test case info.
       
    89      */
       
    90     virtual const CStartInfo* GetStartInfo() const = 0;
       
    91 
       
    92     /**
       
    93      * Gets sub test case runner type.
       
    94      */
       
    95     virtual TSubTestCaseType GetType() const = 0;
       
    96     
       
    97     TSubTestCaseState GetState() const;
       
    98 protected:
       
    99     TSubTestCaseState iState;
       
   100     }; // class CSubTestCaseRunner
       
   101 
       
   102 
       
   103 // DESCRIPTION
       
   104 // CSubTestCaseRunner manages sub test cases execution and retuns 
       
   105 // execution results to CTestRunner
       
   106 NONSHARABLE_CLASS(CLocalSubTestCaseRunner): public CSubTestCaseRunner
       
   107     {
       
   108 public:
       
   109     /**
       
   110      * Two-phased constructor.
       
   111      */
       
   112     static CLocalSubTestCaseRunner* NewL( CTestRunner* aTestRunner );
       
   113 
       
   114     /**
       
   115      * Two-phased constructor.
       
   116      */
       
   117     static CLocalSubTestCaseRunner* NewLC( CTestRunner* aTestRunner );
       
   118 public:
       
   119     /**
       
   120      * Destructor.
       
   121      */
       
   122     ~CLocalSubTestCaseRunner();
       
   123 
       
   124     /**
       
   125      * Starts execution of selected test case.
       
   126      */
       
   127     void RunSubTestCaseL( CStartInfo& aStartTestCaseInfo );
       
   128     
       
   129     /**
       
   130      * Pauses selected sub test case.
       
   131      */
       
   132     void PauseSubTestCaseL();
       
   133     
       
   134     /**
       
   135      * Reasume selected sub test case.
       
   136      */
       
   137     void ResumeSubTestCaseL();
       
   138     
       
   139     void CancelSubTestCaseL();
       
   140     
       
   141     /**
       
   142      * Gets execution result.
       
   143      */
       
   144     TInt GetRunResult() const;
       
   145 
       
   146     /**
       
   147      * Gets test case execution result..
       
   148      */
       
   149     const TFullTestResult& GetTestCaseResult() const;
       
   150     
       
   151     /**
       
   152      * Gets executed test case info.
       
   153      */
       
   154     const CStartInfo* GetStartInfo() const;
       
   155 
       
   156     /**
       
   157      * Gets sub test case runner type.
       
   158      */
       
   159     TSubTestCaseType GetType() const;    
       
   160 private:
       
   161     /**
       
   162      * Constructor.
       
   163      */
       
   164     CLocalSubTestCaseRunner( CTestRunner* aTestRunner );
       
   165 
       
   166     /**
       
   167      * Second phase of two-phased constructor.
       
   168      */
       
   169     void ConstructL();
       
   170     
       
   171     /**
       
   172      * See CActive::RunL()
       
   173      */
       
   174     void RunL();
       
   175 
       
   176     /**
       
   177      * See CActive::DoCancel()
       
   178      */
       
   179     void DoCancel();
       
   180     
       
   181     /**
       
   182      * Resets runner internal state to default values.
       
   183      */
       
   184     void Reset();
       
   185 private:
       
   186     // Pointer to test runner which will be notified about test case execution end.
       
   187     CTestRunner* iTestRunner;
       
   188     
       
   189     // Test engine session used to load test module and open RTestCase subsession
       
   190     RTestEngine iTestEngine;
       
   191     
       
   192     // Test case sub session used to run test case
       
   193     RTestCase iTestCase;
       
   194 
       
   195     // Copy of CStartInfo passed as an argument of RunSubTestCaseL call 
       
   196     CStartInfo* iStartInfo;
       
   197     
       
   198     // Value of iState.Int() after test case execution
       
   199     TInt iRunResult;
       
   200     
       
   201     // Result of test case execution
       
   202     TFullTestResult iResult;
       
   203     
       
   204     // Descriptor used to retrive result from TestEngine
       
   205     TFullTestResultPckg iResultPckg;
       
   206     }; // class CLocalSubTestCaseRunner
       
   207 
       
   208 
       
   209 // DESCRIPTION
       
   210 // CRemoteSubTestCaseRunner manages sub test cases execution and retuns 
       
   211 // execution results to CTestRunner
       
   212 NONSHARABLE_CLASS(CRemoteSubTestCaseRunner): public CSubTestCaseRunner
       
   213     {
       
   214     private:
       
   215         enum TCurrentOperation {    ECONone, 
       
   216                                     ECORunSubtestCase,
       
   217                                     ECOPauseSubtestCase,
       
   218                                     ECOResumeSubtestCase,
       
   219                                     ECOCancelSubtestCase };
       
   220     public:
       
   221         /**
       
   222          * Two-phased constructor.
       
   223          */
       
   224         static CRemoteSubTestCaseRunner* NewL( CTestRunner* aTestRunner, 
       
   225                 CSlave* aSlave, CRemoteCallsProxy* aRemoteCallsProxy );
       
   226         
       
   227         /**
       
   228          * Two-phased constructor.
       
   229          */
       
   230         static CRemoteSubTestCaseRunner* NewLC( CTestRunner* aTestRunner, 
       
   231                 CSlave* aSlave, CRemoteCallsProxy* aRemoteCallsProxy );
       
   232     public:
       
   233         /**
       
   234          * Destructor.
       
   235          */
       
   236         ~CRemoteSubTestCaseRunner();
       
   237     
       
   238         /**
       
   239          * Starts execution of selected test case.
       
   240          */
       
   241         void RunSubTestCaseL( CStartInfo& aStartTestCaseInfo );
       
   242         
       
   243         /**
       
   244          * Pauses selected sub test case.
       
   245          */
       
   246         void PauseSubTestCaseL();
       
   247         
       
   248         /**
       
   249          * Reasume selected sub test case.
       
   250          */
       
   251         void ResumeSubTestCaseL();
       
   252     
       
   253         void CancelSubTestCaseL();
       
   254         
       
   255         /**
       
   256          * Gets execution result.
       
   257          */
       
   258         TInt GetRunResult() const;
       
   259     
       
   260         /**
       
   261          * Gets test case execution result..
       
   262          */
       
   263         const TFullTestResult& GetTestCaseResult() const;
       
   264         
       
   265         /**
       
   266          * Gets executed test case info.
       
   267          */
       
   268         const CStartInfo* GetStartInfo() const;
       
   269     
       
   270         /**
       
   271          * Gets sub test case runner type.
       
   272          */
       
   273         TSubTestCaseType GetType() const;
       
   274         
       
   275         CSlave* GetSlave();
       
   276         
       
   277         TUint16 GetTestCaseId() const;
       
   278         
       
   279         void NotifyTestCaseStartedL( TUint16 aTestCaseId );
       
   280         void NotifyTestCaseRunError( const TFullTestResult& aTestCaseResult );
       
   281         
       
   282         void NotifyTestCasePausedL();
       
   283         void NotifyTestCaseResumedL();
       
   284         void NotifyTestCaseCancelledL();
       
   285         
       
   286         void NotifyTestCaseFinishedL( const TFullTestResult& aTestCaseResult );
       
   287         
       
   288         TBool IsRunSubTestCaseRequestOngoing() const;
       
   289     private:
       
   290         /**
       
   291          * Constructor.
       
   292          */
       
   293         CRemoteSubTestCaseRunner( CTestRunner* aTestRunner, 
       
   294                 CSlave* aSlave, CRemoteCallsProxy* aRemoteCallsProxy );
       
   295 
       
   296         /**
       
   297          * Second phase of two-phased constructor.
       
   298          */
       
   299         void ConstructL();
       
   300         
       
   301         /**
       
   302          * See CActive::RunL()
       
   303          */
       
   304         void RunL();
       
   305 
       
   306         /**
       
   307          * See CActive::DoCancel()
       
   308          */
       
   309         void DoCancel();
       
   310         
       
   311         void Reset();
       
   312     private:
       
   313         // Pointer to test runner which will be notified about test case execution end.
       
   314         CTestRunner* iTestRunner;
       
   315         CSlave* iSlave;
       
   316         CRemoteCallsProxy* iRemoteCallsProxy;
       
   317                         
       
   318         // Copy of CStartInfo passed as an argument of RunSubTestCaseL call 
       
   319         CStartInfo* iStartInfo;
       
   320         
       
   321         TUint16 iTestCaseId;
       
   322                 
       
   323         // Value of iState.Int() after test case execution
       
   324         TInt iRunResult;
       
   325         
       
   326         // Result of test case execution
       
   327         TFullTestResult iResult;
       
   328         
       
   329         TCurrentOperation iCurrentOperation;
       
   330         TInt iOperationResult;
       
   331         
       
   332         TTimeIntervalMicroSeconds32 iOperationTimeout;
       
   333         RTimer iTimeoutTimer;
       
   334         
       
   335         CActiveSchedulerWait* iNestedASLoop;
       
   336     }; // class CRemoteSubTestCaseRunner
       
   337 
       
   338 
       
   339 
       
   340 #endif /* SUBTESTCASERUNNER_H_ */
       
   341 // EOF