testexecfw/stf/stfext/testmodules/scriptermod/inc/TestScripter.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 TestScripter_H
       
    20 #define TestScripter_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32std.h>
       
    24 
       
    25 #include <StifParser.h>
       
    26 #include <StifLogger.h>
       
    27 #include <StifTestModule.h>
       
    28 #include "TestScripterInternal.h"
       
    29 #include "TestKeywords.h"
       
    30 #include "StifKernelTestClass.h"
       
    31 #include "StifTestInterference.h"
       
    32 #include "STIFMeasurement.h"
       
    33 #include "StfTestLibPluginInterface.h"
       
    34 #include "StifTestModule.h"
       
    35 #include "TestScripterUtils.h"
       
    36 #include "SubTestCaseRunner.h"
       
    37 
       
    38 // CONSTANTS
       
    39 // Printing priorities
       
    40 const TInt KPrintPriLow = 10;
       
    41 const TInt KPrintPriNorm = 30;
       
    42 const TInt KPrintPriHigh = 50;
       
    43 // Log dir and file
       
    44 _LIT( KTestScripterLogDir, "\\Logs\\TestFramework\\TestScripter\\" );
       
    45 _LIT( KTestScripterLogFile, "TestScripter.txt" );
       
    46 _LIT( KTestScripterLogFileWithTitle, "TestScripter_[%S].txt");
       
    47 // Configuration file tags
       
    48 _LIT( KTestStartTag, "[Test]" );
       
    49 _LIT( KTestEndTag, "[Endtest]" );
       
    50 // Define tags
       
    51 _LIT( KDefineStartTag, "[Define]" );
       
    52 _LIT( KDefineEndTag, "[Enddefine]" );
       
    53 // Data tags
       
    54 _LIT( KDataStartTag, "[Data]" );
       
    55 _LIT( KDataEndTag, "[Enddata]" );
       
    56 // Loop counter macro
       
    57 _LIT( KLoopCounter, "LOOP_COUNTER" );
       
    58 // ini flag
       
    59 _LIT(KFileFlag,"$");
       
    60 _LIT(KSectionFlag,"@");
       
    61 _LIT(KKeyFlag,"#");
       
    62 
       
    63 // Remote protocol timeout 
       
    64 const TInt KRemoteProtocolTimeout = 30000000;
       
    65 // Remote protocol Master id
       
    66 const TUint32 KRemoteProtocolMasterId = 0xdeadbeef;
       
    67 
       
    68 
       
    69 // MACROS
       
    70 // None
       
    71 
       
    72 // DATA TYPES
       
    73 class CTestRunner;
       
    74 typedef CScriptBase* (*CInterfaceFactory)(CTestModuleIf& aTestModuleIf);
       
    75 
       
    76 // FUNCTION PROTOTYPES
       
    77 // None
       
    78 
       
    79 // FORWARD DECLARATIONS
       
    80 class CTestRunner;
       
    81 class CTestContinue;
       
    82 class TTestModule;
       
    83 class TTestObjectBase;
       
    84 class TTestObject;
       
    85 class TTestInterference;
       
    86 class CStifTestMeasurement;
       
    87 class TTestMeasurement;
       
    88 class TSharedTestModule;
       
    89 
       
    90 // CLASS DECLARATION
       
    91 
       
    92 // DESCRIPTION
       
    93 // Predefined value entry
       
    94 class CDefinedValue : public CBase
       
    95     {
       
    96 public:
       
    97     // Constructors and destructor
       
    98 
       
    99     /**
       
   100      * Two-phased constructor.
       
   101      */
       
   102     static CDefinedValue* NewL(TDesC& aName, TDesC& aValue);
       
   103 
       
   104     /**
       
   105      * Destructor.
       
   106      */
       
   107     virtual ~CDefinedValue();
       
   108 
       
   109 public:
       
   110     // New functions
       
   111 
       
   112     /**
       
   113      * Returns define name.
       
   114      */
       
   115     TDesC& Name();
       
   116 
       
   117     /**
       
   118      * Returns define value.
       
   119      */
       
   120     TDesC& Value();
       
   121 
       
   122     /**
       
   123      * Returns new define value.
       
   124      */
       
   125     void SetValueL(TDesC& aValue);
       
   126 
       
   127 private:
       
   128 
       
   129     /**
       
   130      * C++ default constructor.
       
   131      */
       
   132     CDefinedValue();
       
   133 
       
   134     /**
       
   135      * By default Symbian OS constructor is private.
       
   136      */
       
   137     void ConstructL(TDesC& aName, TDesC& aValue);
       
   138 
       
   139 private:
       
   140     // Data
       
   141 
       
   142     // Define name
       
   143     HBufC* iNameBuf;
       
   144     TPtrC iName;
       
   145 
       
   146     // Define value
       
   147     HBufC* iValueBuf;
       
   148     TPtrC iValue;
       
   149 
       
   150     };
       
   151 
       
   152 // CLASS DECLARATION
       
   153 
       
   154 // DESCRIPTION
       
   155 // CTestScripter contains the Test Module interface of TestScripter 
       
   156 // for STIF Test Framework
       
   157 
       
   158 class CTestScripter : public CTestModuleBase
       
   159     {
       
   160 public:
       
   161     // Enumerations
       
   162 
       
   163 private:
       
   164     // Enumerations
       
   165 
       
   166 public:
       
   167     // Constructors and destructor
       
   168 
       
   169     /**
       
   170      * Two-phased constructor.
       
   171      */
       
   172     static CTestScripter* NewL();
       
   173 
       
   174     /**
       
   175      * Destructor.
       
   176      */
       
   177     ~CTestScripter();
       
   178 
       
   179 public:
       
   180     // New functions
       
   181 
       
   182     /**
       
   183      * Call specified tst class object.
       
   184      */
       
   185     TInt CallTestClass(const TDesC& aLine);
       
   186 
       
   187     /**
       
   188      * Get pointer to test class object.
       
   189      */
       
   190     TInt GetTestScriptObject(const TDesC& aObjectName);
       
   191 
       
   192     /**
       
   193      * Return runner handle.
       
   194      */
       
   195     CTestRunner& TestRunner()
       
   196         {
       
   197         return *iTestRunner;
       
   198         }
       
   199     ;
       
   200 
       
   201 public:
       
   202     // Functions from base classes
       
   203 
       
   204     /**
       
   205      * Test module initialization.
       
   206      */
       
   207     TInt InitL(TFileName& aIniFile, TBool aFirstTime);
       
   208 
       
   209     /**
       
   210      * GetTestCasesL is used to inquire testcases. 
       
   211      */
       
   212     TInt GetTestCasesL(const TFileName& aConfigFile, RPointerArray<
       
   213             TTestCaseInfo>& aTestCases);
       
   214 
       
   215     /**
       
   216      * RunTestCase is used to run an individual test case specified 
       
   217      * by aTestCase. 
       
   218      */
       
   219     TInt RunTestCaseL(const TInt aCaseNumber, const TFileName& aConfig,
       
   220             TTestResult& aResult);
       
   221 
       
   222     /**
       
   223      * Internal fuction to get const value defined in 
       
   224      * [Define]...[Enddefine] section of script file
       
   225      */
       
   226     IMPORT_C TInt GetConstantValue(const TDesC& aName, TDes& aValue);
       
   227 
       
   228     /**
       
   229      * Set result description of test case.
       
   230      */
       
   231     IMPORT_C void SetResultDescription(const TDesC& aDescr);
       
   232 
       
   233     /**
       
   234      * Internal fuction to set local value.
       
   235      */
       
   236     IMPORT_C TInt SetLocalValue(const TDesC& aName, const TDesC& aValue);
       
   237 
       
   238     /**
       
   239      * Internal fuction to get local value.
       
   240      */
       
   241     IMPORT_C TInt GetLocalValue(const TDesC& aName, TDes& aValue);
       
   242 
       
   243 protected:
       
   244     // New functions
       
   245 
       
   246 protected:
       
   247     // Functions from base classes
       
   248 
       
   249 private:
       
   250     /**
       
   251      * C++ default constructor.
       
   252      */
       
   253     CTestScripter();
       
   254 
       
   255     /**
       
   256      * By default Symbian OS constructor is private.
       
   257      */
       
   258     void ConstructL();
       
   259 
       
   260     /**
       
   261      * GetTestCaseL gets the specified test case section 
       
   262      * from the onfigfile.
       
   263      */
       
   264     CStifSectionParser* GetTestCaseL(TInt aCaseNumber,
       
   265             const TFileName& aConfig);
       
   266 
       
   267     /**
       
   268      * RunTestL runs the testcase specified in section.
       
   269      */
       
   270     void RunTestL();
       
   271 
       
   272     /**
       
   273      * LoadTestModuleL loads test module.
       
   274      */
       
   275     TTestModule* LoadTestModuleL(TDesC& aModule);
       
   276     
       
   277     /**
       
   278      * LoadTestModuleL loads test module.
       
   279      */
       
   280     TTestModule* LoadSharedTestModuleL(TDesC& aModule);
       
   281 
       
   282     /**
       
   283      * CreateObjectL create new object.
       
   284      */
       
   285     void CreateObjectL(TDesC& aModule, TDesC& aObjectId);
       
   286 
       
   287     /**
       
   288      * CreateShareObjectL create new object.
       
   289      */
       
   290     void CreateShareObjectL(TDesC& aModule, TDesC& aObjectId);
       
   291 
       
   292     /**
       
   293      * RestoreShareObjectL create new object.
       
   294      */
       
   295     void RestoreShareObjectL(TDesC& aObjectId);
       
   296 
       
   297     /**
       
   298      * CreateKernelObjectL create new kernel object.
       
   299      */
       
   300     void CreateKernelObjectL(TDesC& aDriver, TDesC& aObjectId);
       
   301 
       
   302     /**
       
   303      * DeleteObjectL deletes object with aObjectId.
       
   304      */
       
   305     TInt DeleteObjectL(TDesC& aObjectId);
       
   306 
       
   307     /**
       
   308      * DeleteGlobalObjectL deletes object with aObjectId.
       
   309      */
       
   310     TInt CTestScripter::DeleteScripterObjectL(TDesC& aObjectId);
       
   311 
       
   312     /**
       
   313      * GetObject returns object corresponding to aObjectId.
       
   314      */
       
   315     TTestObjectBase* GetObject(const TDesC& aObjectId);
       
   316 
       
   317     /**
       
   318      * Read initialization from file.
       
   319      */
       
   320     void ReadInitializationL(const TDesC& aIniFile, RPointerArray<
       
   321             CDefinedValue>& aDefines);
       
   322 
       
   323     /**
       
   324      * Read sub section from test case file.
       
   325      */
       
   326     CStifSectionParser* GetSubL(const TDesC& aSubName);
       
   327 
       
   328     /**
       
   329      * Updates result of test case.
       
   330      */
       
   331     void UpdateTestCaseResult(const TInt aError, const TDesC& aDescr);
       
   332 
       
   333     void Substitute(const TDesC& aSrc, TDes& aDest);
       
   334 
       
   335     /**
       
   336      * Add Test object 
       
   337      */
       
   338     void AddTestObjToScripterDictL(TTestObject* aObject);
       
   339 
       
   340     /**
       
   341      * Delete Test object
       
   342      */
       
   343     void DelTestObjFromScripterDict(const TDesC& aObjectId);
       
   344 
       
   345     /**
       
   346      * Get Test object
       
   347      */
       
   348     TTestObject* GetTestObjFromScripterDict(const TDesC& aObjectId) const;
       
   349 
       
   350     /**
       
   351     * Append to TS's result description (if possible due to length)
       
   352     * limitation provided text in [] brackets.
       
   353     */
       
   354     void AppendTestResultToResultDes(TDes& aResultDescr, const TDesC& aTestCaseResultDescr);
       
   355     
       
   356     /**
       
   357      * Trace memory usage of global objects and output to log. method return the used cells.
       
   358     */
       
   359     TInt TraceGlobalObjectsMemoryUsage();
       
   360     
       
   361 public:
       
   362     // Data
       
   363     // Logger 
       
   364     CStifLogger* iLog;
       
   365 
       
   366 protected:
       
   367     // Data
       
   368 
       
   369 private:
       
   370     // Data
       
   371     // Test case array of running/runned test cases 
       
   372     RPointerArray<TTestObjectBase> iTestObjects;
       
   373     // Array of test modules
       
   374     RPointerArray<TTestModule> iTestModules;
       
   375     
       
   376     // Array of test modules
       
   377     RPointerArray<TSharedTestModule> iSharedTestModules;
       
   378 
       
   379     // Test case array of global test objects 
       
   380     RPointerArray<TTestObject> iGlobalObjects;
       
   381 
       
   382     // Test case result of the TestScripter
       
   383     TTestResult iResult;
       
   384 
       
   385     // Sectionparser for the current testcase
       
   386     CStifSectionParser* iSectionParser;
       
   387 
       
   388     // Currently used section parser (changed when executing a function (sub))
       
   389     CStifSectionParser* iCurrentParser;
       
   390 
       
   391     // It says if we need to call GetLine or GetNextLine for the parser
       
   392     TBool iCurrentParserReadFirstLine;
       
   393 
       
   394     // Stack of parsers for called functions (subs)
       
   395     RPointerArray<CStifSectionParser> iParserStack;
       
   396 
       
   397     // Pointer to used testrunner
       
   398     CTestRunner* iTestRunner;
       
   399 
       
   400     // Predefined values are listed here
       
   401     RPointerArray<CDefinedValue> iDefinedIni;
       
   402     RPointerArray<CDefinedValue> iDefinedRuntime;
       
   403     RPointerArray<CDefinedValue> iDefinedLocal;
       
   404 
       
   405     // Flag for OOM testing. If true test class's build
       
   406     // block execution result will ignored.
       
   407     TBool iOOMIgnoreFailure;
       
   408 
       
   409     // Flag which says if heap balance should be checked (affects only 
       
   410     // EKA2 environment). May be set in StifSettings section.
       
   411     TBool iCheckHeapBalance;
       
   412 
       
   413     // Standard logger 
       
   414     CStifLogger* iStdLog;
       
   415 
       
   416     // Test case Logger 
       
   417     CStifLogger* iTCLog;
       
   418 
       
   419     // Flag which says if test case title should be appended to the
       
   420     // log file name. This is read from SettingServer
       
   421     TBool iAddTestCaseTitleToLogName;
       
   422 
       
   423     // The running test case's config file name
       
   424     TFileName iConfig;
       
   425 
       
   426     TBuf<KMaxFileName> iCurrentFile;
       
   427     TBuf<KMaxFileName> iCurrentFileAlias;
       
   428 
       
   429     TBuf<KMaxFileName> iCurrentSection;
       
   430     TBuf<KMaxFileName> iCurrentSectionFileAlias;
       
   431 
       
   432     TBuf<KMaxFileName> iCurrentKey;
       
   433     TBuf<KMaxFileName> iCurrentvalues;
       
   434 
       
   435     RArray<TBuf<KMaxFileName> > iKeys;
       
   436     RArray<TBuf<KMaxFileName> > iValues;
       
   437     RPointerArray<TScriptObject> *iObjects;
       
   438 
       
   439     // Indicates if pass limit in loops was met
       
   440     TBool iPassLimitNotMet;    
       
   441 public:
       
   442     // Friend classes
       
   443 
       
   444 protected:
       
   445     // Friend classes
       
   446 
       
   447 private:
       
   448     // Friend classes
       
   449     friend class CTestRunner;
       
   450     friend class CTestContinue;
       
   451 
       
   452     };
       
   453 
       
   454 // CLASS DECLARATION
       
   455 
       
   456 // DESCRIPTION
       
   457 // CTestRunner parses the TestScripter configuration file and 
       
   458 // runs a testcase. CTestRunner is the friend of CTestScripter
       
   459 // and uses its private member variables directly.
       
   460 
       
   461 class CTestRunner : public CActive
       
   462     {
       
   463 public:
       
   464     // Enumerations
       
   465 
       
   466 private:
       
   467     // Enumerations
       
   468     enum TRunnerState
       
   469         {
       
   470         ERunnerIdle,
       
   471         ERunnerRunning,
       
   472         ERunnerCancel,
       
   473         ERunnerError,
       
   474         ERunnerPaused,
       
   475         };
       
   476 
       
   477     enum TInternalStateForSubTestCases
       
   478         {
       
   479         EISNotStarted,
       
   480         EISRuning,
       
   481         EISWaitingForComplete,
       
   482         EISEndLoopWaitingForSubTestCases,
       
   483         EISFinishedWaitingForSubTestCases,
       
   484         EISFinished,
       
   485         };
       
   486 public:
       
   487     // Constructors and destructor  
       
   488     /**
       
   489      * Two-phased constructor.
       
   490      */
       
   491     static CTestRunner* NewL(CTestScripter* aTestScripter);
       
   492 
       
   493     /**
       
   494      * Destructor.
       
   495      */
       
   496     ~CTestRunner();
       
   497 
       
   498 public:
       
   499     // New functions
       
   500     /**
       
   501      * Calls SetActive() from CActive.
       
   502      */
       
   503     void SetRunnerActive();
       
   504 
       
   505     /**
       
   506      * Get test case result handle.
       
   507      */
       
   508     RArray<TInt>& TestCaseResults()
       
   509         {
       
   510         return iTestCaseResults;
       
   511         }
       
   512     ;
       
   513 
       
   514 public:
       
   515     // Functions from base classes     
       
   516     /**
       
   517      * RunL derived from CActive handles the completed requests.
       
   518      */
       
   519     void RunL();
       
   520 
       
   521     /**
       
   522      * DoCancel derived from CActive handles the Cancel.
       
   523      */
       
   524     void DoCancel();
       
   525 
       
   526     /**
       
   527      * RunError derived from CActive handles errors from active handler.
       
   528      */
       
   529     TInt RunError(TInt aError);
       
   530 
       
   531     CStifLogger* GetLogger();
       
   532     
       
   533     /**
       
   534      * Recieves notification about finished sub test case execution.
       
   535      */
       
   536     void SubTestCaseFinishedL( CSubTestCaseRunner* aSubTestCaseRunner );
       
   537 
       
   538     /**
       
   539      * Recives report from CLoopHelper about result of loop execution
       
   540      */
       
   541     void ReportLoopEndResultL( TInt aPassedIterations );
       
   542     
       
   543     /**
       
   544      * Releases resources allocated in loop
       
   545      */
       
   546     void ReleaseRemoteResourcesAllocatedInLoopL();
       
   547         
       
   548     /**
       
   549      * Gets information if there was reported executed sub test case 
       
   550      * which failed.
       
   551      */
       
   552     TBool IsFailedSubTestCaseReported() const;
       
   553 
       
   554     /**
       
   555      * Returns first failed sub test case result.
       
   556      */
       
   557     TFullTestResult GetFailedSubTestCaseResult() const;
       
   558     
       
   559     /**
       
   560      * Returns first failed sub test case info.
       
   561      */
       
   562     const CStartInfo* GetFailedSubTestCaseInfo() const;
       
   563     
       
   564     void HandleRemoteReceiveError( TInt aError, const TDesC& aErrorDescription );
       
   565 protected:
       
   566     // New functions
       
   567 
       
   568 protected:
       
   569     // Functions from base classes
       
   570 
       
   571 private:
       
   572     /**
       
   573      * C++ default constructor.
       
   574      */
       
   575     CTestRunner(CTestScripter* aTestScripter);
       
   576 
       
   577     /**
       
   578      * By default Symbian OS constructor is private.
       
   579      */
       
   580     void ConstructL();
       
   581 
       
   582     /**
       
   583      * Executes one script line.
       
   584      */
       
   585     TBool ExecuteLineL(TDesC& aKeyword, CStifItemParser* aItem);
       
   586 
       
   587     /**
       
   588     * Executes run script line.
       
   589     */
       
   590     TBool ExecuteRunL( CStifItemParser* aItem );
       
   591     
       
   592     TBool ExecuteCompleteL( CStifItemParser* aItem );
       
   593     
       
   594     /**
       
   595     * Parses run parameters.
       
   596     */
       
   597     void ParseRunParamsL( CStifItemParser* aItem, CStartInfo& aStartInfo );
       
   598 
       
   599     /**
       
   600     * Parses optional argument.
       
   601     */
       
   602     void ParseOptArgL( const TDesC& aOptArg, TPtrC& aArg, TPtrC& aVal);    
       
   603     
       
   604     /**
       
   605      * Executes method call to object script line.
       
   606      */
       
   607     TBool ExecuteCommandL(TDesC& aObject, CStifItemParser* aItem);
       
   608 
       
   609     /**
       
   610      * Executes method call to object script line.
       
   611      */
       
   612     TBool ExecuteLibL(TDesC& lib, CStifItemParser* aItem);
       
   613 
       
   614     /**
       
   615      * Executes event control script line.
       
   616      */
       
   617     TBool ExecuteEventL(TDesC& aKeyword, CStifItemParser* aItem);
       
   618 
       
   619     /**
       
   620      * Preprocess hardcoded values in test case.
       
   621      */
       
   622     CStifItemParser* PreprocessLineL(TDesC& line);
       
   623 
       
   624     /**
       
   625      * Checks if aWord is defined value.
       
   626      */
       
   627     TInt CheckDefined(TPtrC& aWord);
       
   628 
       
   629     /**
       
   630      * Checks if aWord is a local variable.
       
   631      */
       
   632     TInt CheckDefinedLocals(TPtrC& aWord);
       
   633 
       
   634     /**
       
   635      * Handles 'oomignorefailure' keyword parsing.
       
   636      */
       
   637     void OOMIgnoreFailureL(CStifItemParser* aItem);
       
   638 
       
   639     /**
       
   640      * Handles 'oomheapfailnext' keyword parsing.
       
   641      */
       
   642     void OOMHeapFailNextL(CStifItemParser* aItem);
       
   643 
       
   644     /**
       
   645      * Handles 'oomheapsetfail' keyword parsing.
       
   646      */
       
   647     void OOMHeapSetFailL(CStifItemParser* aItem);
       
   648 
       
   649     /**
       
   650      * Initialize all OOM related variables.
       
   651      */
       
   652     void OOMHeapToNormal();
       
   653 
       
   654     /**
       
   655      * Handles 'testinterference' keyword parsing.
       
   656      */
       
   657     void TestInterferenceL(CStifItemParser* aItem);
       
   658 
       
   659     /**
       
   660      * Starts test interference.
       
   661      */
       
   662     void StartInterferenceL(TDesC& aName, CStifItemParser* aItem);
       
   663 
       
   664     /**
       
   665      * Stops test interference.
       
   666      */
       
   667     void StopInterferenceL(TDesC& aName);
       
   668 
       
   669     /**
       
   670      * Handles 'measurement' keyword parsing.
       
   671      */
       
   672     void MeasurementL(CStifItemParser* aItem);
       
   673 
       
   674     /**
       
   675      * Starts measurement.
       
   676      */
       
   677     void StartMeasurementL(const TDesC& aType, CStifItemParser* aItem);
       
   678 
       
   679     /**
       
   680      * Stops measurementplugin's measurement.
       
   681      */
       
   682     void StopMeasurementL(const TDesC& aType);
       
   683 
       
   684     /**
       
   685      * Adds new test case result. Used with 'allownextresult'
       
   686      * and 'allowerrorcodes' keywords.
       
   687      */
       
   688     void AddTestCaseResultL(CStifItemParser* aItem);
       
   689 
       
   690     /** Adds new test case panic. Used with 'allowpanic'
       
   691      */
       
   692     void AddTestCasePanicL(CStifItemParser* aItem);
       
   693 
       
   694     /**
       
   695      * Sends key press event to AppUi
       
   696      */
       
   697     TBool PressKeyL(CStifItemParser* aItem);
       
   698 
       
   699     /**
       
   700      * Sends text to AppUi
       
   701      */
       
   702     TBool TypeTextL(CStifItemParser* aItem);
       
   703 
       
   704     /**
       
   705      * Sends pointer event to AppUi
       
   706      */
       
   707     TBool SendPointerEventL(CStifItemParser* aItem);
       
   708     
       
   709     /**
       
   710      * Controls sub test case execution
       
   711      */
       
   712     TBool ControlSubTestCaseL( TTestKeywords::TKeywords aOperation, CStifItemParser* aItem );
       
   713 
       
   714     /**
       
   715      * Executes loop keyword
       
   716      */
       
   717     TBool ExecuteLoopL( CStifItemParser* aItem );
       
   718     
       
   719     /**
       
   720      * Executes endloop keyword
       
   721      */
       
   722     TBool ExecuteEndLoopL( CStifItemParser* aItem );
       
   723     
       
   724     TBool ExecuteAllocateL( CStifItemParser* aItem );
       
   725     TBool ExecuteFreeL( CStifItemParser* aItem );
       
   726     TBool ExecuteRemoteL( CStifItemParser* aItem );
       
   727     
       
   728     /**
       
   729     * Executes remote run script line.
       
   730     */
       
   731     TBool ExecuteRemoteRunL( CStifItemParser* aItem, CSlave* aSlave,
       
   732                              HBufC *aSetUnsetEvent = NULL,
       
   733                              TInt aCaseNumber = 0 );
       
   734 
       
   735     /**
       
   736     * Executes remote event control script line.
       
   737     */
       
   738     TBool ExecuteRemoteEventCtlL( CStifItemParser* aItem, 
       
   739                                   CSlave* aSlave, 
       
   740                                   TInt aCmd );
       
   741 
       
   742     /**
       
   743     * Executes asynchronous remote sendreceive control script line.
       
   744     */
       
   745     TBool ExecuteRemoteSendReceiveL( CStifItemParser* aItem, 
       
   746                                   CSlave* aSlave );
       
   747 
       
   748     /**
       
   749     * Executes remote unknown control script line.
       
   750     */
       
   751     TBool ExecuteRemoteUnknownL( CStifItemParser* aItem, 
       
   752                                  CSlave* aSlave,
       
   753                                  TDesC& aCommand );    
       
   754     
       
   755 public:
       
   756     // Data
       
   757 
       
   758 protected:
       
   759     // Data
       
   760 
       
   761 private:
       
   762     // Data
       
   763     // Runner state
       
   764     TRunnerState iState;
       
   765 
       
   766     TInternalStateForSubTestCases iInternalStateForSubTestCases;
       
   767     
       
   768     // Backpointer to CTestScripter
       
   769     CTestScripter* iTestScripter;
       
   770 
       
   771     // Allowed test case results
       
   772     RArray<TInt> iTestCaseResults;
       
   773 
       
   774     // Temporary line buffer 
       
   775     HBufC* iLine;
       
   776 
       
   777     // Store for requested events
       
   778     RPointerArray<HBufC> iEventArray;
       
   779 
       
   780     // Pause timer
       
   781     RTimer iPauseTimer;
       
   782 
       
   783     // Pause value for timer
       
   784     TInt iRemainingTimeValue;
       
   785 
       
   786     // Loop times, counter and start position
       
   787     TInt iLoopTimes;
       
   788     TInt iLoopCounter;
       
   789     TInt iLoopStartPos;
       
   790     TBuf<10> iLoopCounterDes;
       
   791 
       
   792     // Loop (timed loop option)
       
   793     TBool iTimedLoop;
       
   794     TTime iStartTime;
       
   795     TTimeIntervalMicroSeconds iExpectedLoopTime;
       
   796 
       
   797     // For OOM heap testing, FAILNEXT: count
       
   798     TInt iHeapFailNext;
       
   799     // For OOM heap testing, SETFAIL: type and value(rate)
       
   800     RHeap::TAllocFail iHeapSetFailType;
       
   801     TInt iHeapSetFailValue;
       
   802 
       
   803     // Array for test interference
       
   804     RPointerArray<TTestInterference> iTestInterferenceArray;
       
   805 
       
   806     // CStifTestMeasurement object
       
   807     RPointerArray<TTestMeasurement> iTestMeasurementArray;
       
   808 
       
   809     // Message displayed when leave occurs during script parsing
       
   810     TBuf<256> iRunErrorMessage;
       
   811 
       
   812     // test lib plugins array 
       
   813     RPointerArray<CStfTestLibPlugin> iPlugins;
       
   814 
       
   815     // test lib pluginnames array 
       
   816     RPointerArray<HBufC> iPluginnames;
       
   817 
       
   818     RLibrary iLibrary;
       
   819     
       
   820     // Array of executed sub test cases
       
   821     RPointerArray<CSubTestCaseRunner> iSubTestCases;
       
   822     
       
   823     // Indicates on which sub test case waits last complete call
       
   824     HBufC* iTestIdForComplete;
       
   825     
       
   826     // Indicates if execution of some sub test case failed
       
   827     TBool iFailedSubTestCaseReported;
       
   828     
       
   829     // Caintains test execution result of first failed sub test case 
       
   830     TFullTestResult iFailedSubTestCaseResult;
       
   831     
       
   832     // Caintains information about first failed sub test case
       
   833     CStartInfo* iFailedSubTestCaseInfo;
       
   834     
       
   835     // Indicates if test case executions should be breaked when of the sub test case fails
       
   836     TBool iCancelIfError;
       
   837     
       
   838     // Indicates whether passlimit feature is enabled or not
       
   839     TBool iPasslimitEnabled;
       
   840     
       
   841     // Pass limit for loop
       
   842     TInt iPasslimit;
       
   843 
       
   844     // Loop helper
       
   845     CLoopHelper* iLoopHelper;
       
   846 
       
   847     // Slaves manager
       
   848     CSlavesManager* iSlavesManager;
       
   849 public:
       
   850     // Friend classes
       
   851 
       
   852 protected:
       
   853     // Friend classes
       
   854 
       
   855 private:
       
   856     // Friend classes
       
   857 
       
   858     };
       
   859 
       
   860 // CLASS DECLARATION
       
   861 
       
   862 // DESCRIPTION
       
   863 // CTestContinue gets ContinueScript signals from test class
       
   864 class CTestContinue : public CActive
       
   865     {
       
   866 public:
       
   867     // Enumerations
       
   868 
       
   869 private:
       
   870     // Enumerations
       
   871 
       
   872 public:
       
   873     // Constructors and destructor  
       
   874     /**
       
   875      * Two-phased constructor.
       
   876      */
       
   877     static CTestContinue* NewL(CTestScripter* aTestScripter,
       
   878             TTestObject* aObject);
       
   879 
       
   880     /**
       
   881      * Destructor.
       
   882      */
       
   883     ~CTestContinue();
       
   884 
       
   885 public:
       
   886     // New functions
       
   887 
       
   888 public:
       
   889     // Functions from base classes     
       
   890     /**
       
   891      * RunL derived from CActive handles the completed requests.
       
   892      */
       
   893     void RunL();
       
   894 
       
   895     /**
       
   896      * DoCancel derived from CActive handles the Cancel.
       
   897      */
       
   898     void DoCancel();
       
   899 
       
   900     /**
       
   901      * RunError derived from CActive handles errors from active handler.
       
   902      */
       
   903     TInt RunError(TInt aError);
       
   904 
       
   905 protected:
       
   906     // New functions
       
   907 
       
   908 protected:
       
   909     // Functions from base classes
       
   910 
       
   911 private:
       
   912     /**
       
   913      * C++ default constructor.
       
   914      */
       
   915     CTestContinue(CTestScripter* aTestScripter, TTestObject* aObject);
       
   916 
       
   917     /**
       
   918      * By default Symbian OS constructor is private.
       
   919      */
       
   920     void ConstructL();
       
   921 
       
   922 public:
       
   923     //Data
       
   924 
       
   925 protected:
       
   926     // Data
       
   927 
       
   928 private:
       
   929     // Data
       
   930     // Backpointer to CTestScripter
       
   931     CTestScripter* iTestScripter;
       
   932 
       
   933     // Objectid for this object
       
   934     TTestObject* iObject;
       
   935 
       
   936 public:
       
   937     // Friend classes
       
   938 
       
   939 protected:
       
   940     // Friend classes
       
   941 
       
   942 private:
       
   943     // Friend classes
       
   944 
       
   945     };
       
   946 
       
   947 // CLASS DECLARATION
       
   948 
       
   949 // DESCRIPTION
       
   950 // TTestObjectBase contains test object base information
       
   951 class TTestObjectBase : public TScriptObject
       
   952     {
       
   953 public:
       
   954     enum TObjectType
       
   955         {
       
   956         EObjectNormal, EObjectKernel,
       
   957         };
       
   958 
       
   959 public:
       
   960     TTestObjectBase(TObjectType aType);
       
   961     virtual ~TTestObjectBase();
       
   962 public:
       
   963     TObjectType ObjectType()
       
   964         {
       
   965         return iType;
       
   966         }
       
   967     ;
       
   968 
       
   969     virtual TInt RunMethodL(CStifItemParser& aItem) = 0;
       
   970     virtual TBool Signal() = 0;
       
   971     virtual TBool Wait() = 0;
       
   972 
       
   973 public:
       
   974     TInt iAsyncResult;
       
   975 
       
   976 protected:
       
   977     TObjectType iType;
       
   978 
       
   979 private:
       
   980     //     TName       iName;
       
   981 
       
   982     };
       
   983 
       
   984 // CLASS DECLARATION
       
   985 
       
   986 // DESCRIPTION
       
   987 // TTestObject contains test object information
       
   988 class TTestObject : public TTestObjectBase
       
   989     {
       
   990 public:
       
   991     TTestObject();
       
   992     virtual ~TTestObject();
       
   993 
       
   994 public:
       
   995     TInt RunMethodL(CStifItemParser& aItem);
       
   996     inline TBool Signal()
       
   997         {
       
   998         return (iCount++ < 0);
       
   999         }
       
  1000     ;
       
  1001     inline TBool Wait()
       
  1002         {
       
  1003         return (--iCount >= 0);
       
  1004         }
       
  1005     ;
       
  1006 
       
  1007 public:
       
  1008     CTestContinue* iContinue;
       
  1009     TName iModule;
       
  1010 private:
       
  1011     TInt iCount;
       
  1012     };
       
  1013 
       
  1014 // CLASS DECLARATION
       
  1015 
       
  1016 // DESCRIPTION
       
  1017 // TTestObjectKernel contains kernel test object information
       
  1018 class TTestObjectKernel : public TTestObjectBase
       
  1019     {
       
  1020 public:
       
  1021     TTestObjectKernel();
       
  1022     virtual ~TTestObjectKernel();
       
  1023 
       
  1024 public:
       
  1025     TInt RunMethodL(CStifItemParser& aItem);
       
  1026 
       
  1027     // Signal and Wait not supported
       
  1028     TBool Signal()
       
  1029         {
       
  1030         return ETrue;
       
  1031         }
       
  1032     ;
       
  1033     TBool Wait()
       
  1034         {
       
  1035         return ETrue;
       
  1036         }
       
  1037     ;
       
  1038 
       
  1039     TName& LddName()
       
  1040         {
       
  1041         return iLddName;
       
  1042         }
       
  1043     RStifKernelTestClass& KernelTestClass()
       
  1044         {
       
  1045         return iTestClass;
       
  1046         }
       
  1047 
       
  1048 private:
       
  1049     RStifKernelTestClass iTestClass;
       
  1050     TName iLddName;
       
  1051 
       
  1052     };
       
  1053 
       
  1054 // CLASS DECLARATION
       
  1055 
       
  1056 // DESCRIPTION
       
  1057 // TTestModule contains test module information
       
  1058 class TTestModule
       
  1059     {
       
  1060 public:
       
  1061     TTestModule()
       
  1062         {
       
  1063         }
       
  1064     ;
       
  1065     ~TTestModule()
       
  1066         {
       
  1067         iLibrary.Close();
       
  1068         }
       
  1069     ;
       
  1070 
       
  1071 public:
       
  1072     TName& ModuleName()
       
  1073         {
       
  1074         return iName;
       
  1075         }
       
  1076 
       
  1077 public:
       
  1078     RLibrary iLibrary;
       
  1079     CInterfaceFactory iLibEntry;
       
  1080 
       
  1081 private:
       
  1082     TName iName;
       
  1083 
       
  1084     };
       
  1085 
       
  1086 // CLASS DECLARATION
       
  1087 
       
  1088 // DESCRIPTION
       
  1089 // TSharedTestModule contains test module information
       
  1090 class TSharedTestModule
       
  1091     {
       
  1092 public:
       
  1093     TSharedTestModule(TTestModule *aTestModule)
       
  1094     {
       
  1095         refCount=1;
       
  1096         iTestModule = aTestModule;
       
  1097     };
       
  1098     ~TSharedTestModule(){};
       
  1099     TName& ModuleName()
       
  1100         {
       
  1101         return iTestModule->ModuleName();
       
  1102         };
       
  1103     TTestModule* Get()
       
  1104             {
       
  1105                 ++refCount;
       
  1106                 return iTestModule;
       
  1107             }
       
  1108     void Del()
       
  1109         {
       
  1110         if(--refCount<=0)
       
  1111             {
       
  1112                 delete iTestModule;
       
  1113                 iTestModule = NULL;
       
  1114             }
       
  1115         };
       
  1116     
       
  1117     const TInt RefCount(){ return refCount; };
       
  1118 
       
  1119 private:
       
  1120     TInt refCount;
       
  1121     TTestModule *iTestModule;
       
  1122     };
       
  1123 
       
  1124 // CLASS DECLARATION
       
  1125 
       
  1126 // DESCRIPTION
       
  1127 // TTestInterference contains test interference object information
       
  1128 class TTestInterference
       
  1129     {
       
  1130 public:
       
  1131     TTestInterference()
       
  1132         {
       
  1133         iInterference = NULL;
       
  1134         }
       
  1135     ;
       
  1136     ~TTestInterference()
       
  1137         {
       
  1138         delete iInterference;
       
  1139         }
       
  1140     ;
       
  1141 
       
  1142 public:
       
  1143 
       
  1144 public:
       
  1145     // "object" name given in test case file.
       
  1146     TName iName;
       
  1147     // MSTIFTestInterference object.
       
  1148     MSTIFTestInterference* iInterference;
       
  1149 
       
  1150 private:
       
  1151 
       
  1152     };
       
  1153 
       
  1154 // DESCRIPTION
       
  1155 // TTestMeasurement contains test measurement module information
       
  1156 class TTestMeasurement
       
  1157     {
       
  1158 public:
       
  1159     TTestMeasurement()
       
  1160         {
       
  1161         iMeasurement = NULL;
       
  1162         }
       
  1163     ;
       
  1164     ~TTestMeasurement()
       
  1165         {
       
  1166         delete iMeasurement;
       
  1167         }
       
  1168     ;
       
  1169 
       
  1170 public:
       
  1171 
       
  1172 public:
       
  1173     // "object" name given in test case file.
       
  1174     TName iName;
       
  1175     // MSTIFTestInterference object.
       
  1176     CSTIFTestMeasurement* iMeasurement;
       
  1177 
       
  1178 private:
       
  1179 
       
  1180     };
       
  1181 
       
  1182 #endif        // TestScripter_H
       
  1183 // End of File