stif/TestCombiner/inc/TestCase.h
changeset 0 a03f92240627
child 8 ecff51f1e7fb
equal deleted inserted replaced
-1:000000000000 0:a03f92240627
       
     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
       
   211                                         aCategory,
       
   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 reference to RTestExecution.
       
   232         */
       
   233         RTestExecution& TestExecution(){ return iTestExecution; }
       
   234 
       
   235         /**
       
   236         * Get reference to event array.
       
   237         */
       
   238         RPointerArray<CTestEventNotify>& EventArray(){ return iEventArray; }
       
   239 
       
   240         /**
       
   241         * Get reference to state event array.
       
   242         */
       
   243         RPointerArray<TEventIf>& StateEventArray(){ return iStateEventArray; }
       
   244 
       
   245          /**
       
   246         * Final complete of the testcase.
       
   247         */
       
   248         void Complete2();
       
   249 
       
   250         /**
       
   251         * Checks state and progress notifier
       
   252         */
       
   253         TBool IsCompletelyFinished(void);
       
   254 
       
   255     public: // Functions from base classes
       
   256 
       
   257     protected: // New functions
       
   258 
       
   259     protected: // Functions from base classes
       
   260         /**
       
   261         * DoCancel derived from CActive handles the Cancel
       
   262         */
       
   263         void DoCancel();
       
   264 
       
   265     private:
       
   266         /**
       
   267         * C++ default constructor.
       
   268         */
       
   269         CTCTestCase( CTestCombiner* testCombiner,
       
   270                      TInt aExpectedResult,
       
   271                      TFullTestResult::TCaseExecutionResult aCategory,
       
   272                      CTCTestModule* aModule ); //--PYTHON--
       
   273 
       
   274         /**
       
   275         * By default Symbian OS constructor is private.
       
   276         */
       
   277         void ConstructL( TDesC& aModuleName, TDesC& aTestId );
       
   278 
       
   279         /**
       
   280         * Start complete the testcase(Complete2 make the final complete).
       
   281         */
       
   282         void Complete( TInt aError );
       
   283 
       
   284     public:  // Data
       
   285         // Test case result package
       
   286         TFullTestResultPckg iResultPckg;
       
   287 
       
   288     protected: // Data
       
   289 
       
   290     private: // Data
       
   291 
       
   292         // Progress notifier
       
   293         CTestProgressNotifier*  iProgress;
       
   294 
       
   295         // Event notifier
       
   296         CTestEventNotifier*     iEvent;
       
   297 
       
   298         // Module name
       
   299         HBufC*                  iModuleName;
       
   300 
       
   301         // Handle to test case execution
       
   302         RTestExecution          iTestExecution;
       
   303 
       
   304         // Event array for events requested by test case
       
   305         RPointerArray<CTestEventNotify> iEventArray;
       
   306 
       
   307         // Event array for state events set by test case
       
   308         RPointerArray<TEventIf>         iStateEventArray;
       
   309         
       
   310         // Command notifier
       
   311         CTestCommandNotifier*    iCommand;
       
   312 
       
   313     public: // Friend classes
       
   314 
       
   315     protected: // Friend classes
       
   316 
       
   317     private: // Friend classes
       
   318 
       
   319     };
       
   320 
       
   321 
       
   322 // CLASS DECLARATION
       
   323 
       
   324 // DESCRIPTION
       
   325 // Testcase starting information
       
   326 NONSHARABLE_CLASS(CRemoteTestCase)
       
   327     :public CTestCase
       
   328     {
       
   329 
       
   330     public: // Enumerations
       
   331         enum TRemoteState
       
   332             {
       
   333             ECaseIdle,
       
   334             ECaseRunSent,
       
   335             ECaseRunning,
       
   336             ECasePauseSent,
       
   337             ECasePaused,
       
   338             ECaseResumeSent,
       
   339             ECaseCancelSent,
       
   340             ECaseCancelled,
       
   341             ECaseCompleted,
       
   342             };
       
   343 
       
   344     private: // Enumerations
       
   345 
       
   346     public: // Constructors and destructor
       
   347         /**
       
   348         * Two-phased constructor.
       
   349         */
       
   350         static CRemoteTestCase* NewL( CTestCombiner* testCombiner,
       
   351                                       TDesC& aTestId,
       
   352                                       TInt aExpectedResult,
       
   353                                       TFullTestResult::TCaseExecutionResult
       
   354                                             aCategory );
       
   355 
       
   356         /**
       
   357         * Destructor.
       
   358         */
       
   359         ~CRemoteTestCase();
       
   360 
       
   361     public: // New functions
       
   362 
       
   363     public: // Functions from base classes
       
   364 
       
   365     protected: // New functions
       
   366 
       
   367     protected: // Functions from base classes
       
   368 
       
   369     private:
       
   370         /**
       
   371         * C++ default constructor.
       
   372         */
       
   373         CRemoteTestCase( CTestCombiner* testCombiner,
       
   374                          TInt aExpectedResult,
       
   375                          TFullTestResult::TCaseExecutionResult aCategory );
       
   376 
       
   377         /**
       
   378         * By default Symbian OS constructor is private.
       
   379         */
       
   380         void ConstructL( TDesC& aTestId );
       
   381 
       
   382     public:  // Data
       
   383         // Remote slave state
       
   384         TRemoteState    iRemoteState;
       
   385 
       
   386         // Slave identifier
       
   387         TUint32         iSlaveId;
       
   388 
       
   389         // Free slave after completed
       
   390         TBool           iFreeSlave;
       
   391 
       
   392     protected: // Data
       
   393 
       
   394     private: // Data
       
   395 
       
   396     public: // Friend classes
       
   397 
       
   398     protected: // Friend classes
       
   399 
       
   400     private: // Friend classes
       
   401 
       
   402     };
       
   403 
       
   404 // CLASS DECLARATION
       
   405 
       
   406 // DESCRIPTION
       
   407 // CRemoteSendReceive handles the running of an asynchronous 'sendreveive'
       
   408 // in TestCombiner.
       
   409 // Note: If want to improve sendreceive for allowing use like 'run'
       
   410 // then this must inherit from CActive
       
   411 NONSHARABLE_CLASS(CRemoteSendReceive) :public CBase
       
   412     {
       
   413     public: // Enumerations
       
   414 
       
   415     public: // Enumerations
       
   416         enum TRemoteState
       
   417             {
       
   418             ECaseSend,
       
   419             ECaseCompleted,
       
   420             };
       
   421 
       
   422     private: // Enumerations
       
   423 
       
   424     public: // Constructors and destructor
       
   425         /**
       
   426         * Two-phased constructor.
       
   427         */
       
   428         static CRemoteSendReceive* NewL( CTestCombiner* aTestCombiner );
       
   429 
       
   430         /**
       
   431         * Destructor.
       
   432         */
       
   433         ~CRemoteSendReceive();
       
   434 
       
   435     public: // Constructors and destructor
       
   436 
       
   437     public: // New functions
       
   438 
       
   439 
       
   440     public: // Functions from base classes
       
   441 
       
   442     protected:  // New functions
       
   443 
       
   444     protected: // Functions from base classes
       
   445 
       
   446     private:
       
   447         /**
       
   448         * C++ default constructor.
       
   449         */
       
   450         CRemoteSendReceive( CTestCombiner* aTestCombiner );
       
   451 
       
   452         /**
       
   453         * By default Symbian OS constructor is private.
       
   454         */
       
   455         void ConstructL();
       
   456 
       
   457     public:  // Data
       
   458 
       
   459        // Remote slave state
       
   460         TRemoteState    iRemoteState;
       
   461 
       
   462         // Slave identifier
       
   463         TUint32         iSlaveId;
       
   464 
       
   465     protected: // Data
       
   466 
       
   467     private: // Data
       
   468 
       
   469         // Backpointer
       
   470         CTestCombiner*      iTestCombiner;
       
   471 
       
   472     public: // Friend classes
       
   473 
       
   474     protected: // Friend classes
       
   475 
       
   476     private: // Friend classes
       
   477 
       
   478     };
       
   479 
       
   480 // CLASS DECLARATION
       
   481 
       
   482 
       
   483 // DESCRIPTION
       
   484 // TTCTestModule encapsulates information about loaded test module.
       
   485 
       
   486 NONSHARABLE_CLASS(CTCTestModule)
       
   487     :public CBase
       
   488     {
       
   489     public: // Enumerations
       
   490 
       
   491     private: // Enumerations
       
   492 
       
   493     public: // Constructors and destructor
       
   494         /**
       
   495         * Two-phased constructor.
       
   496         */
       
   497         static CTCTestModule* NewL( CTestCombiner* testCombiner,
       
   498                                     TDesC& aModule,
       
   499                                     TDesC& aIni,
       
   500                                     const TDesC& aConfigFile );
       
   501 
       
   502         /**
       
   503         * Destructor.
       
   504         */
       
   505         ~CTCTestModule();
       
   506 
       
   507     public: // Constructors and destructor
       
   508 
       
   509     public: // New functions
       
   510          /**
       
   511          * Get module name.
       
   512          */
       
   513          const TDesC& ModuleName(){ return *iModuleName; }
       
   514 
       
   515          /**
       
   516          * Get module inifile name.
       
   517          */
       
   518          const TDesC& IniFile(){ return *iIniFile; }
       
   519 
       
   520          /**
       
   521         * Get reference to RTestServer.
       
   522         */
       
   523         RTestServer& TestServer(){ return iTestServer; }
       
   524 
       
   525         /**
       
   526         * Get reference to RTestModule.
       
   527         */
       
   528         RTestModule& TestModule(){ return iTestModule; }
       
   529 
       
   530         /**
       
   531         * Get test cases from module.
       
   532         */
       
   533         void GetTestCasesForCombiner(const TDesC& aConfigFile);
       
   534 
       
   535         /**
       
   536         * Get index of given test case.
       
   537         */
       
   538         TInt GetCaseNumByTitle(TDesC& aTitle, TInt& aCaseNum);
       
   539 
       
   540     public: // Functions from base classes
       
   541 
       
   542     protected:  // New functions
       
   543 
       
   544     protected: // Functions from base classes
       
   545 
       
   546     private:
       
   547         /**
       
   548         * C++ default constructor.
       
   549         */
       
   550         CTCTestModule( CTestCombiner* testCombiner );
       
   551 
       
   552         /**
       
   553         * By default Symbian OS constructor is private.
       
   554         */
       
   555         void ConstructL( TDesC& aModule,
       
   556                          TDesC& aIni,
       
   557                          const TDesC& aConfigFile );
       
   558 
       
   559     public:  // Data
       
   560 
       
   561     protected: // Data
       
   562 
       
   563     private: // Data
       
   564         // Backpointer
       
   565         CTestCombiner*      iTestCombiner;
       
   566         
       
   567         // Module name
       
   568         HBufC*              iModuleName;
       
   569         // Module initialization file
       
   570         HBufC*              iIniFile;
       
   571 
       
   572         // Handle to test server
       
   573         RTestServer         iTestServer;
       
   574         // Handle to module 
       
   575         RTestModule         iTestModule;
       
   576         
       
   577         // Error notifier
       
   578         CTestErrorNotifier* iErrorPrinter;
       
   579 
       
   580         // Array of test cases used to find test case number by title
       
   581         CFixedFlatArray<TTestCaseInfo>* iTestCases;
       
   582 
       
   583     public: // Friend classes
       
   584 
       
   585     protected: // Friend classes
       
   586 
       
   587     private: // Friend classes
       
   588 
       
   589     };
       
   590     
       
   591 #endif        // TESTCASE_H  
       
   592                 
       
   593 // End of File