hti/HtiServicePlugins/HtiStifTfServicePlugin/inc/HtiStifTfIf.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:  Defines the class that controls STIF Test Framework through
       
    15 *                the STIF TF interface.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef HTISTIFTFIF_H
       
    22 #define HTISTIFTFIF_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <StifTFwIf.h>
       
    26 #include <HtiServicePluginInterface.h>
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // MACROS
       
    31 
       
    32 // DATA TYPES
       
    33 
       
    34 // FUNCTION PROTOTYPES
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class CDesC8ArrayFlat;
       
    38 class CHtiStifTfServicePlugin;
       
    39 class CConsoleBase;
       
    40 
       
    41 // CLASS DECLARATION
       
    42 /**
       
    43 *  Container class for test modules' test infos.
       
    44 *  One instance of this class contains the test infos of one test module in
       
    45 *  an RPointerArray and the name of the test module as HBufC.
       
    46 *
       
    47 */
       
    48 class CHtiTestModuleCaseInfos : public CBase
       
    49     {
       
    50     public: // Constuctors and destructor
       
    51 
       
    52         /**
       
    53         * Two-phased constructor.
       
    54         */
       
    55         static CHtiTestModuleCaseInfos* NewL( const TDesC& aModuleName );
       
    56 
       
    57 
       
    58         /**
       
    59         * Two-phased constructor.
       
    60         */
       
    61         static CHtiTestModuleCaseInfos* NewLC( const TDesC& aModuleName );
       
    62 
       
    63 
       
    64         /**
       
    65         * Destructor.
       
    66         */
       
    67         ~CHtiTestModuleCaseInfos();
       
    68 
       
    69     public:
       
    70         /**
       
    71         * Compares the order of two CHtiTestMoudleCaseInfos objects.
       
    72         * Order is based on the alphabetical order of the module name.
       
    73         * @param aFirst reference to the first instance to compare
       
    74         * @param aSecond reference to the second instance to compare
       
    75         * @return Positive if the first module's name is greater than the
       
    76         *         second module's name. Negative if the first module's name is
       
    77         *         less than the second module's name. Zero if names are equal.
       
    78         */
       
    79         static TInt Compare( const CHtiTestModuleCaseInfos& aFirst,
       
    80                              const CHtiTestModuleCaseInfos& aSecond );
       
    81 
       
    82         /**
       
    83         * Compares the equality of two CHtiTestMoudleCaseInfos objects.
       
    84         * Equality is based on the name of the module.
       
    85         * @param aFirst reference to the first instance to compare
       
    86         * @param aSecond reference to the second instance to compare
       
    87         * @return ETrue if the module names are equal. EFalse otherwise.
       
    88         */
       
    89         static TBool Match(  const CHtiTestModuleCaseInfos& aFirst,
       
    90                              const CHtiTestModuleCaseInfos& aSecond );
       
    91 
       
    92     private:
       
    93 
       
    94         CHtiTestModuleCaseInfos();
       
    95 
       
    96         void ConstructL( const TDesC& aModuleName );
       
    97 
       
    98     public: // Data
       
    99 
       
   100         // The name of the test module whose test infos this instance contains
       
   101         HBufC* iModuleName;
       
   102 
       
   103         // An array of CTestInfo objects (one per test case)
       
   104         RPointerArray<CTestInfo> iTestInfos;
       
   105 
       
   106     };
       
   107 
       
   108 
       
   109 // CLASS DECLARATION
       
   110 
       
   111 /**
       
   112 *  Implements the STIF Test Framework interface functions.
       
   113 */
       
   114 class CHtiStifTfIf : public CStifTFwIf
       
   115     {
       
   116     public:  // Constructors and destructor
       
   117 
       
   118         /**
       
   119         * Two-phased constructor.
       
   120         */
       
   121         static CHtiStifTfIf* NewL( CHtiStifTfServicePlugin* aPlugin );
       
   122 
       
   123         /**
       
   124         * Destructor.
       
   125         */
       
   126         virtual ~CHtiStifTfIf();
       
   127 
       
   128     public: // New functions
       
   129 
       
   130         /**
       
   131         * Called when there is a message to be processed by this service.
       
   132         * @param aMessage message body destinated to the servive
       
   133         * @param aPriority message priority
       
   134         */
       
   135         void ProcessMessageL( const TDesC8& aMessage,
       
   136             THtiMessagePriority aPriority );
       
   137 
       
   138         /**
       
   139         * Called by the plugin to tell the service how much memory is
       
   140         * available for messages in the message queue.
       
   141         * @param aAvailableMemory amount of currently available memory
       
   142         *        in the message queue
       
   143         */
       
   144         void NotifyMemoryChange( TInt aAvailableMemory );
       
   145 
       
   146         /**
       
   147         * Sets the dispatcher to send outgoing messages to.
       
   148         * @param aDispatcher pointer to dispatcher instance
       
   149         */
       
   150         void SetDispatcher( MHtiDispatcher* aDispatcher );
       
   151 
       
   152     public: // Functions from base classes
       
   153 
       
   154     protected:  // New functions
       
   155 
       
   156 
       
   157     protected:  // Functions from base classes
       
   158 
       
   159         // virtual functions from CStifTFwIf
       
   160         /**
       
   161         * Function that is called when test execution is finished.
       
   162         * @param aTestId id of the test case
       
   163         * @param aTestExecutionResult result of test execution
       
   164         * @param aTestResult actual result of the test case
       
   165         */
       
   166         void TestCompleted( TInt aTestId,
       
   167                             TInt aTestExecutionResult,
       
   168                             TTestResult& aTestResult );
       
   169 
       
   170         /**
       
   171         * Function for sending message to ATS.
       
   172         * @param aMessage message to be sent
       
   173         */
       
   174         void AtsSend( const TDesC& aMessage );
       
   175 
       
   176         /**
       
   177         * Get device identifier.
       
   178         * Should be overridden to make them unique among slaves.
       
   179         * Returns default value for every slave otherwise.
       
   180         * @return the device ID
       
   181         */
       
   182         TUint16 DevId(){ return iDevId; };
       
   183 
       
   184         /**
       
   185         * Function is called when test case prints.
       
   186         */
       
   187         void Print( TInt aTestId, TTestProgress& aProgress );
       
   188 
       
   189     private:
       
   190 
       
   191         /**
       
   192         * C++ default constructor.
       
   193         */
       
   194         CHtiStifTfIf();
       
   195 
       
   196         /**
       
   197         * By default Symbian 2nd phase constructor is private.
       
   198         */
       
   199         void ConstructL( CHtiStifTfServicePlugin* aPlugin );
       
   200 
       
   201         // Private helper methods.
       
   202         void HandleOpenCmdL();
       
   203 
       
   204         void HandleCloseCmdL();
       
   205 
       
   206         void HandleLoadModuleCmdL();
       
   207 
       
   208         void HandleUnloadModuleCmdL();
       
   209 
       
   210         void HandleListCasesCmdL();
       
   211 
       
   212         void HandleStartCaseCmdL();
       
   213 
       
   214         void HandleCancelCaseCmdL();
       
   215 
       
   216         void HandlePauseCaseCmdL();
       
   217 
       
   218         void HandleResumeCaseCmdL();
       
   219 
       
   220         void HandleAddCaseFileCmdL();
       
   221 
       
   222         void HandleRemoveCaseFileCmdL();
       
   223 
       
   224         void HandleCaseMsgCmdL();
       
   225 
       
   226         void HandleSetDevIdCmdL();
       
   227 
       
   228         void HandleSetAttributeCmdL();
       
   229 
       
   230         void LoadTestCaseInfosL();
       
   231 
       
   232         void LoadTestCaseInfosL( TDesC& aModuleName );
       
   233 
       
   234         void ParseParametersL( const TDesC8& aCommand );
       
   235 
       
   236         TInt SendResponseMsg( const TDesC8& aMsg,
       
   237                               const TUint8 aCommandId = 0 );
       
   238 
       
   239         TInt SendErrorResponseMsg( TInt aErrorCode,
       
   240                                    const TDesC8& aErrorDescription,
       
   241                                    const TUint8 aCommandId = 0 );
       
   242 
       
   243         TInt IndexByModuleName( const TDesC& aModuleName );
       
   244 
       
   245         CTestInfo* GetCaseInfoL( TInt aCaseIndex );
       
   246 
       
   247 
       
   248     public:     // Data
       
   249 
       
   250         // Flag telling if the service is busy processing a message
       
   251         TBool iIsBusy;
       
   252 
       
   253     protected:  // Data
       
   254 
       
   255     private:    // Data
       
   256 
       
   257         // ID of the last received command
       
   258         TUint8 iCommandId;
       
   259 
       
   260         // Array container for parameters of the last received message
       
   261         CDesC8ArrayFlat* iParameters;
       
   262 
       
   263         // The message dispatcher interface
       
   264         MHtiDispatcher* iDispatcher;
       
   265 
       
   266         // Container for the response message to be dispatched out
       
   267         HBufC8* iMessage;
       
   268 
       
   269         // Error code in the outgoing error message
       
   270         TInt iErrorCode;
       
   271 
       
   272         // Flag telling if STIF TF has been opened
       
   273         TBool iStifTfOpen;
       
   274 
       
   275         // The device ID
       
   276         TUint16 iDevId;
       
   277 
       
   278         // An array holding the test case infos of all loaded test modules
       
   279         RPointerArray<CHtiTestModuleCaseInfos> iLoadedInfos;
       
   280 
       
   281         // Pointer to the service plugin instance - this is not owned
       
   282         CHtiStifTfServicePlugin* iPlugin;
       
   283 
       
   284         // Pointer to the HTI console
       
   285         CConsoleBase* iConsole;
       
   286     };
       
   287 
       
   288 #endif      // HTISTIFTFIF_H
       
   289 
       
   290 // End of File