stif/TestCombiner/inc/TestCase.h
branchRCL_3
changeset 59 8ad140f3dd41
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
       
     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 CTCTestCase 
       
    15 * and TTCTestModule.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef TESTCASE_H
       
    20 #define TESTCASE_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <stifinternal/TestServerClient.h>
       
    25 #include <StifTestModule.h>
       
    26 #include "TestCaseNotify.h"
       
    27 
       
    28 // CONSTANTS
       
    29 // None
       
    30 
       
    31 // MACROS
       
    32 // None
       
    33 
       
    34 // DATA TYPES
       
    35 // None
       
    36 
       
    37 // FUNCTION PROTOTYPES
       
    38 // None
       
    39 
       
    40 // FORWARD DECLARATIONS
       
    41 class CTestCombiner;
       
    42 
       
    43 // CLASS DECLARATION
       
    44 
       
    45 // DESCRIPTION
       
    46 // CTestCase is a parent class for the test case runner in TestCombiner.
       
    47 NONSHARABLE_CLASS(CTestCase)
       
    48     :public CActive
       
    49     {
       
    50     public: // Enumerations
       
    51         enum TTestCaseStatus
       
    52             {
       
    53             ETestCaseIdle,
       
    54             ETestCaseRunning,
       
    55             ETestCaseCompleted
       
    56             };
       
    57         
       
    58         enum TCaseType
       
    59             {
       
    60             ECaseLocal,
       
    61             ECaseRemote,
       
    62             };
       
    63 
       
    64     private: // Enumerations
       
    65 
       
    66     public: // Destructor
       
    67         /**
       
    68         * Destructor.
       
    69         */
       
    70         virtual ~CTestCase();
       
    71 
       
    72     public: // New functions
       
    73         /**
       
    74         * Calls SetActive() from CActive.
       
    75         */
       
    76         virtual void StartL();
       
    77         
       
    78         /**
       
    79         * Get state of the test case.
       
    80         */
       
    81         TTestCaseStatus State(){ return iState; }
       
    82                 
       
    83         /**
       
    84         * Get reference to TestId.
       
    85         */
       
    86         const TDesC& TestId(){ return *iTestId; }
       
    87 
       
    88         /**
       
    89         * Get expected result.
       
    90         */
       
    91         TInt ExpectedResult(){ return iExpectedResult; }
       
    92 
       
    93         /**
       
    94         * Get expected result category.
       
    95         */
       
    96         TFullTestResult::TCaseExecutionResult
       
    97             ExpectedResultCategory(){ return iExpectedResultCategory; }
       
    98 
       
    99         /**
       
   100         * Get test case type.
       
   101         */
       
   102         TCaseType Type(){ return iType; }
       
   103 
       
   104         //--PYTHON-- begin
       
   105         /**
       
   106         * Get TestModule.
       
   107         */
       
   108         CTCTestModule* TestModule(void){ return iTestModule; }
       
   109         //--PYTHON-- end
       
   110 
       
   111         /**
       
   112         * Checks state and additional conditions
       
   113         */
       
   114         virtual TBool IsCompletelyFinished(void);
       
   115 
       
   116     public: // Functions from base classes
       
   117 
       
   118         /**
       
   119         * RunL derived from CActive handles the completed requests.
       
   120         */
       
   121         void RunL();
       
   122 
       
   123         /**
       
   124         * DoCancel derived from CActive handles the Cancel
       
   125         */
       
   126         void DoCancel();
       
   127 
       
   128     protected: // New functions
       
   129 
       
   130         /**
       
   131         * Completes testcase.
       
   132         */
       
   133         virtual void Complete( TInt aError );
       
   134 
       
   135     protected: // Constructors
       
   136         /**
       
   137         * C++ default constructor.
       
   138         */
       
   139         CTestCase( CTestCombiner* testCombiner,
       
   140                    TInt aExpectedResult,
       
   141                    TFullTestResult::TCaseExecutionResult aCategory,
       
   142                    TCaseType aType,
       
   143                    CTCTestModule* aModule ); //--PYTHON--
       
   144 
       
   145         /**
       
   146         * By default Symbian OS constructor is private.
       
   147         */
       
   148         void ConstructL( TDesC& aTestId );
       
   149 
       
   150     private:
       
   151 
       
   152     public:  // Data
       
   153 
       
   154         // Test case result
       
   155         TFullTestResult         iResult;
       
   156 
       
   157     protected: // Data
       
   158         // Test case type
       
   159         TCaseType               iType;
       
   160 
       
   161         // Backpointer
       
   162         CTestCombiner*          iTestCombiner;
       
   163 
       
   164         // Internal state
       
   165         TTestCaseStatus         iState;
       
   166 
       
   167         // Unique test id
       
   168         HBufC*                  iTestId;
       
   169 
       
   170         // Expected result for the test case
       
   171         TInt                    iExpectedResult;
       
   172 
       
   173         // Expected result category
       
   174         TFullTestResult::TCaseExecutionResult iExpectedResultCategory;
       
   175 
       
   176     private: // Data
       
   177         //--PYTHON-- begin
       
   178         CTCTestModule*			iTestModule;
       
   179         //--PYTHON-- end
       
   180 
       
   181     public: // Friend classes
       
   182 
       
   183     protected: // Friend classes
       
   184 
       
   185     private: // Friend classes
       
   186         friend class CTestRunner;
       
   187 
       
   188     };
       
   189 
       
   190 // CLASS DECLARATION
       
   191 
       
   192 // DESCRIPTION
       
   193 // CTCTestCase handles the running of a single testcase in TestCombiner.
       
   194 
       
   195 NONSHARABLE_CLASS(CTCTestCase)
       
   196     :public CTestCase
       
   197     {
       
   198     public: // Enumerations
       
   199 
       
   200     private: // Enumerations
       
   201 
       
   202     public: // Constructors and destructor
       
   203         /**
       
   204         * Two-phased constructor.
       
   205         */
       
   206         static CTCTestCase* NewL( CTestCombiner* testCombiner,
       
   207                                   TDesC& aModuleName,
       
   208                                   TDesC& aTestId,
       
   209                                   TInt aExpectedResult,
       
   210                                   TFullTestResult::TCaseExecutionResult aCategory,
       
   211                                   const TDesC& aTestCaseArguments,
       
   212                                   CTCTestModule* aModule ); //--PYTHON--
       
   213 
       
   214         /**
       
   215         * Destructor.
       
   216         */
       
   217         ~CTCTestCase();
       
   218 
       
   219     public: // New functions
       
   220         /**
       
   221         * Calls SetActive() from CActive.
       
   222         */
       
   223         void StartL();
       
   224 
       
   225         /**
       
   226         * Get reference to ModuleName.
       
   227         */
       
   228         const TDesC& ModuleName(){ return *iModuleName; }
       
   229 
       
   230         /**
       
   231          * Get test case arguments
       
   232          */
       
   233         const TDesC& TestCaseArguments() const;
       
   234         
       
   235         /**
       
   236         * Get reference to RTestExecution.
       
   237         */
       
   238         RTestExecution& TestExecution(){ return iTestExecution; }
       
   239 
       
   240         /**
       
   241         * Get reference to event array.
       
   242         */
       
   243         RPointerArray<CTestEventNotify>& EventArray(){ return iEventArray; }
       
   244 
       
   245         /**
       
   246         * Get reference to state event array.
       
   247         */
       
   248         RPointerArray<TEventIf>& StateEventArray(){ return iStateEventArray; }
       
   249 
       
   250          /**
       
   251         * Final complete of the testcase.
       
   252         */
       
   253         void Complete2();
       
   254 
       
   255         /**
       
   256         * Checks state and progress notifier
       
   257         */
       
   258         TBool IsCompletelyFinished(void);
       
   259 
       
   260     public: // Functions from base classes
       
   261 
       
   262     protected: // New functions
       
   263 
       
   264     protected: // Functions from base classes
       
   265         /**
       
   266         * DoCancel derived from CActive handles the Cancel
       
   267         */
       
   268         void DoCancel();
       
   269 
       
   270     private:
       
   271         /**
       
   272         * C++ default constructor.
       
   273         */
       
   274         CTCTestCase( CTestCombiner* testCombiner,
       
   275                      TInt aExpectedResult,
       
   276                      TFullTestResult::TCaseExecutionResult aCategory,
       
   277                      CTCTestModule* aModule ); //--PYTHON--
       
   278 
       
   279         /**
       
   280         * By default Symbian OS constructor is private.
       
   281         */
       
   282         void ConstructL( TDesC& aModuleName, TDesC& aTestId, const TDesC& aTestCaseArguments );
       
   283 
       
   284         /**
       
   285         * Start complete the testcase(Complete2 make the final complete).
       
   286         */
       
   287         void Complete( TInt aError );
       
   288 
       
   289     public:  // Data
       
   290         // Test case result package
       
   291         TFullTestResultPckg iResultPckg;
       
   292 
       
   293     protected: // Data
       
   294 
       
   295     private: // Data
       
   296 
       
   297         // Progress notifier
       
   298         CTestProgressNotifier*  iProgress;
       
   299 
       
   300         // Event notifier
       
   301         CTestEventNotifier*     iEvent;
       
   302 
       
   303         // Module name
       
   304         HBufC*                  iModuleName;
       
   305 
       
   306         // Test case arguments
       
   307         HBufC*                  iTestCaseArguments;
       
   308         
       
   309         // Handle to test case execution
       
   310         RTestExecution          iTestExecution;
       
   311 
       
   312         // Event array for events requested by test case
       
   313         RPointerArray<CTestEventNotify> iEventArray;
       
   314 
       
   315         // Event array for state events set by test case
       
   316         RPointerArray<TEventIf>         iStateEventArray;
       
   317         
       
   318         // Command notifier
       
   319         CTestCommandNotifier*    iCommand;
       
   320 
       
   321     public: // Friend classes
       
   322 
       
   323     protected: // Friend classes
       
   324 
       
   325     private: // Friend classes
       
   326 
       
   327     };
       
   328 
       
   329 
       
   330 // CLASS DECLARATION
       
   331 
       
   332 // DESCRIPTION
       
   333 // Testcase starting information
       
   334 NONSHARABLE_CLASS(CRemoteTestCase)
       
   335     :public CTestCase
       
   336     {
       
   337 
       
   338     public: // Enumerations
       
   339         enum TRemoteState
       
   340             {
       
   341             ECaseIdle,
       
   342             ECaseRunSent,
       
   343             ECaseRunning,
       
   344             ECasePauseSent,
       
   345             ECasePaused,
       
   346             ECaseResumeSent,
       
   347             ECaseCancelSent,
       
   348             ECaseCancelled,
       
   349             ECaseCompleted,
       
   350             };
       
   351 
       
   352     private: // Enumerations
       
   353 
       
   354     public: // Constructors and destructor
       
   355         /**
       
   356         * Two-phased constructor.
       
   357         */
       
   358         static CRemoteTestCase* NewL( CTestCombiner* testCombiner,
       
   359                                       TDesC& aTestId,
       
   360                                       TInt aExpectedResult,
       
   361                                       TFullTestResult::TCaseExecutionResult
       
   362                                             aCategory );
       
   363 
       
   364         /**
       
   365         * Destructor.
       
   366         */
       
   367         ~CRemoteTestCase();
       
   368 
       
   369     public: // New functions
       
   370 
       
   371     public: // Functions from base classes
       
   372 
       
   373     protected: // New functions
       
   374 
       
   375     protected: // Functions from base classes
       
   376 
       
   377     private:
       
   378         /**
       
   379         * C++ default constructor.
       
   380         */
       
   381         CRemoteTestCase( CTestCombiner* testCombiner,
       
   382                          TInt aExpectedResult,
       
   383                          TFullTestResult::TCaseExecutionResult aCategory );
       
   384 
       
   385         /**
       
   386         * By default Symbian OS constructor is private.
       
   387         */
       
   388         void ConstructL( TDesC& aTestId );
       
   389 
       
   390     public:  // Data
       
   391         // Remote slave state
       
   392         TRemoteState    iRemoteState;
       
   393 
       
   394         // Slave identifier
       
   395         TUint32         iSlaveId;
       
   396 
       
   397         // Free slave after completed
       
   398         TBool           iFreeSlave;
       
   399 
       
   400     protected: // Data
       
   401 
       
   402     private: // Data
       
   403 
       
   404     public: // Friend classes
       
   405 
       
   406     protected: // Friend classes
       
   407 
       
   408     private: // Friend classes
       
   409 
       
   410     };
       
   411 
       
   412 // CLASS DECLARATION
       
   413 
       
   414 // DESCRIPTION
       
   415 // CRemoteSendReceive handles the running of an asynchronous 'sendreveive'
       
   416 // in TestCombiner.
       
   417 // Note: If want to improve sendreceive for allowing use like 'run'
       
   418 // then this must inherit from CActive
       
   419 NONSHARABLE_CLASS(CRemoteSendReceive) :public CBase
       
   420     {
       
   421     public: // Enumerations
       
   422 
       
   423     public: // Enumerations
       
   424         enum TRemoteState
       
   425             {
       
   426             ECaseSend,
       
   427             ECaseCompleted,
       
   428             };
       
   429 
       
   430     private: // Enumerations
       
   431 
       
   432     public: // Constructors and destructor
       
   433         /**
       
   434         * Two-phased constructor.
       
   435         */
       
   436         static CRemoteSendReceive* NewL( CTestCombiner* aTestCombiner );
       
   437 
       
   438         /**
       
   439         * Destructor.
       
   440         */
       
   441         ~CRemoteSendReceive();
       
   442 
       
   443     public: // Constructors and destructor
       
   444 
       
   445     public: // New functions
       
   446 
       
   447 
       
   448     public: // Functions from base classes
       
   449 
       
   450     protected:  // New functions
       
   451 
       
   452     protected: // Functions from base classes
       
   453 
       
   454     private:
       
   455         /**
       
   456         * C++ default constructor.
       
   457         */
       
   458         CRemoteSendReceive( CTestCombiner* aTestCombiner );
       
   459 
       
   460         /**
       
   461         * By default Symbian OS constructor is private.
       
   462         */
       
   463         void ConstructL();
       
   464 
       
   465     public:  // Data
       
   466 
       
   467        // Remote slave state
       
   468         TRemoteState    iRemoteState;
       
   469 
       
   470         // Slave identifier
       
   471         TUint32         iSlaveId;
       
   472 
       
   473     protected: // Data
       
   474 
       
   475     private: // Data
       
   476 
       
   477         // Backpointer
       
   478         CTestCombiner*      iTestCombiner;
       
   479 
       
   480     public: // Friend classes
       
   481 
       
   482     protected: // Friend classes
       
   483 
       
   484     private: // Friend classes
       
   485 
       
   486     };
       
   487 
       
   488 // CLASS DECLARATION
       
   489 
       
   490 
       
   491 // DESCRIPTION
       
   492 // TTCTestModule encapsulates information about loaded test module.
       
   493 
       
   494 NONSHARABLE_CLASS(CTCTestModule)
       
   495     :public CBase
       
   496     {
       
   497     public: // Enumerations
       
   498 
       
   499     private: // Enumerations
       
   500 
       
   501     public: // Constructors and destructor
       
   502         /**
       
   503         * Two-phased constructor.
       
   504         */
       
   505         static CTCTestModule* NewL( CTestCombiner* testCombiner,
       
   506                                     TDesC& aModule,
       
   507                                     TDesC& aIni,
       
   508                                     const TDesC& aConfigFile );
       
   509 
       
   510         /**
       
   511         * Destructor.
       
   512         */
       
   513         ~CTCTestModule();
       
   514 
       
   515     public: // Constructors and destructor
       
   516 
       
   517     public: // New functions
       
   518          /**
       
   519          * Get module name.
       
   520          */
       
   521          const TDesC& ModuleName(){ return *iModuleName; }
       
   522 
       
   523          /**
       
   524          * Get module inifile name.
       
   525          */
       
   526          const TDesC& IniFile(){ return *iIniFile; }
       
   527 
       
   528          /**
       
   529         * Get reference to RTestServer.
       
   530         */
       
   531         RTestServer& TestServer(){ return iTestServer; }
       
   532 
       
   533         /**
       
   534         * Get reference to RTestModule.
       
   535         */
       
   536         RTestModule& TestModule(){ return iTestModule; }
       
   537 
       
   538         /**
       
   539         * Get test cases from module.
       
   540         */
       
   541         void GetTestCasesForCombiner(const TDesC& aConfigFile);
       
   542 
       
   543         /**
       
   544         * Get index of given test case.
       
   545         */
       
   546         TInt GetCaseNumByTitle(TDesC& aTitle, TInt& aCaseNum);
       
   547 
       
   548     public: // Functions from base classes
       
   549 
       
   550     protected:  // New functions
       
   551 
       
   552     protected: // Functions from base classes
       
   553 
       
   554     private:
       
   555         /**
       
   556         * C++ default constructor.
       
   557         */
       
   558         CTCTestModule( CTestCombiner* testCombiner );
       
   559 
       
   560         /**
       
   561         * By default Symbian OS constructor is private.
       
   562         */
       
   563         void ConstructL( TDesC& aModule,
       
   564                          TDesC& aIni,
       
   565                          const TDesC& aConfigFile );
       
   566 
       
   567     public:  // Data
       
   568 
       
   569     protected: // Data
       
   570 
       
   571     private: // Data
       
   572         // Backpointer
       
   573         CTestCombiner*      iTestCombiner;
       
   574         
       
   575         // Module name
       
   576         HBufC*              iModuleName;
       
   577         // Module initialization file
       
   578         HBufC*              iIniFile;
       
   579 
       
   580         // Handle to test server
       
   581         RTestServer         iTestServer;
       
   582         // Handle to module 
       
   583         RTestModule         iTestModule;
       
   584         
       
   585         // Error notifier
       
   586         CTestErrorNotifier* iErrorPrinter;
       
   587 
       
   588         // Array of test cases used to find test case number by title
       
   589         CFixedFlatArray<TTestCaseInfo>* iTestCases;
       
   590 
       
   591     public: // Friend classes
       
   592 
       
   593     protected: // Friend classes
       
   594 
       
   595     private: // Friend classes
       
   596 
       
   597     };
       
   598     
       
   599 #endif        // TESTCASE_H  
       
   600 
       
   601 // End of File