testexecfw/stf/api/api_platform/inc/UIStore.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 CUIStore 
       
    15 * class
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef UISTORE_H
       
    20 #define UISTORE_H
       
    21 
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32std.h>
       
    25 #include <e32base.h>
       
    26 
       
    27 #include <stifinternal/UIEngine.h>
       
    28 #include <stifinternal/UIStoreIf.h>
       
    29 #include <stifinternal/UIStoreContainer.h>
       
    30 
       
    31 #include <StifLogger.h>
       
    32 
       
    33 // CONSTANTS
       
    34 _LIT( KDefaultIni, "\\testframework\\testframework.ini" );
       
    35 
       
    36 // Timeout for popups
       
    37 const TInt KDefaultPopupTimeout = 2100; // 35s. Note this is maximun time in
       
    38                                         // current implementation(used in
       
    39                                         // After()-method, 32bit).
       
    40 // Timeout for popups
       
    41 const TInt KRebootPopupTimeout = 1;
       
    42 
       
    43 // MACROS
       
    44 
       
    45 // DATA TYPES
       
    46 
       
    47 // Menu update type
       
    48 
       
    49 // FUNCTION PROTOTYPES
       
    50 //
       
    51 // FORWARD DECLARATIONS
       
    52 class CUIStoreIf;
       
    53 class CStartedTestCase;
       
    54 class CUIEngine;
       
    55 class CTestInfo;
       
    56 class CUIEngineContainer;
       
    57 class CStartedTestSet;
       
    58 class CUIStorePopup;
       
    59 
       
    60 // DESCRIPTION
       
    61 // CUIStore class
       
    62 class CUIStore
       
    63         :public CUIIf
       
    64     {
       
    65     public: // Enumerations
       
    66                 
       
    67     private: // Enumerations
       
    68     
       
    69         // Popup priorities
       
    70         enum TPopupPriority
       
    71             {
       
    72             EPopupPriorityHighest,
       
    73             EPopupPriorityNormal,
       
    74             EPopupPriorityLow
       
    75             };
       
    76          
       
    77     public:  // Constructors and destructor
       
    78 
       
    79         /**
       
    80         * NewL is first phase of two-phased constructor.
       
    81         */ 
       
    82         static CUIStore* NewL( CUIStoreIf* iUIStoreIf );
       
    83 
       
    84         /**
       
    85         * Destructor of CUIStore.
       
    86         */
       
    87         ~CUIStore();
       
    88 
       
    89 
       
    90     public: // New functions
       
    91         
       
    92         /**
       
    93         * Used to open TestFramework.
       
    94         *
       
    95         * Returns Symbian OS error code.
       
    96         */
       
    97         IMPORT_C TInt Open( const TDesC& aTestFrameworkIni = KNullDesC );
       
    98 
       
    99         /**
       
   100         * Used to close TestFramework.
       
   101         *
       
   102         * Returns Symbian OS error code.
       
   103         */
       
   104         IMPORT_C TInt Close();
       
   105 
       
   106         /**
       
   107         * Used to add test module to test framework.
       
   108         *
       
   109         * Returns Symbian OS error code.
       
   110         */
       
   111         IMPORT_C TInt AddTestModule( const TDesC& aModuleName, 
       
   112                                      const TDesC& aIniFile = KNullDesC );
       
   113 
       
   114         /**
       
   115         * Used to remove test module to test framework.
       
   116         *
       
   117         * Returns Symbian OS error code.
       
   118         */
       
   119         IMPORT_C TInt RemoveTestModule( const TDesC& aModuleName );
       
   120 
       
   121         /**
       
   122         * Used to add test case file for test module.
       
   123         *
       
   124         * Returns Symbian OS error code.
       
   125         */
       
   126         IMPORT_C TInt AddTestCaseFile( const TDesC& aModuleName,
       
   127                                        const TDesC& aCaseFile );
       
   128 
       
   129         /**
       
   130         * Used to remove test case file from test module.
       
   131         *
       
   132         * Returns Symbian OS error code.
       
   133         */
       
   134         IMPORT_C TInt RemoveTestCaseFile( const TDesC& aModuleName,
       
   135                                           const TDesC& aCaseFile );
       
   136 
       
   137         /**
       
   138         * Start selected test case identified with CTestInfo.
       
   139         * anIndex contains index in StartedTestCase array, 
       
   140         * which is valid only during execution of calling 
       
   141         * function.
       
   142         *
       
   143         * Returns Symbian OS error code.
       
   144         */
       
   145         IMPORT_C TInt StartTestCase( const CTestInfo& aTestInfo,
       
   146                                      TInt& anIndex );
       
   147                                         
       
   148         /**
       
   149         * Return array of existing test cases.
       
   150         */
       
   151         IMPORT_C TInt TestCases( RRefArray<CTestInfo>& aTestCases,
       
   152                                  const TDesC& aTestModule = (TDesC&) KNullDesC(),
       
   153                                  const TDesC& aTestCaseFile = (TDesC&) KNullDesC() );
       
   154 
       
   155         
       
   156         
       
   157         /**
       
   158         * Return started (running/runned) test case
       
   159         */
       
   160         IMPORT_C CStartedTestCase& StartedTestCaseL( TInt anIndex );
       
   161       
       
   162         /**
       
   163         * Return started (running/runned) test cases
       
   164         */
       
   165         IMPORT_C TInt StartedTestCases( RRefArray<CStartedTestCase>& aTestCases,
       
   166                                TInt aStatus = CUIStoreIf::EStatusAll,
       
   167                                const TDesC& aTestModule = (TDesC&) KNullDesC(),
       
   168                                const TDesC& aTestCaseFile = (TDesC&) KNullDesC() );        
       
   169         
       
   170         /**
       
   171         * Return modules array
       
   172         */
       
   173         IMPORT_C TInt Modules( RRefArray<TDesC>& aTestModules );
       
   174 
       
   175         /**
       
   176         * Return test case files
       
   177         */
       
   178         IMPORT_C TInt TestCaseFiles( RRefArray<TDesC>& aTestCaseFiles,
       
   179                             const TDesC& aTestModule = (TDesC&) KNullDesC() );
       
   180 
       
   181 
       
   182         /**
       
   183         * Loads all TestFramework test modules from \sys\bin\ directories 
       
   184         * of all drives.
       
   185         */
       
   186         IMPORT_C TInt LoadAllModules();
       
   187         
       
   188         /**
       
   189         * Lists all TestFramework test modules from \sys\bin\ directories 
       
   190         * of all drives.
       
   191         */
       
   192         IMPORT_C TInt ListAllModules( RPointerArray<TDesC>& aModuleNames );
       
   193 
       
   194 
       
   195         /**
       
   196         * Test set support.
       
   197         */
       
   198                                      
       
   199         /**
       
   200         * Create new test set.
       
   201         *
       
   202         * Returns Symbian OS error code.
       
   203         */
       
   204         IMPORT_C TInt CreateTestSet( const TDesC& aSetName );
       
   205 
       
   206         /**
       
   207         * Remove active test set.
       
   208         *
       
   209         * Returns Symbian OS error code.
       
   210         */
       
   211         IMPORT_C TInt RemoveTestSet( const TDesC& aSetName );
       
   212         
       
   213         /**
       
   214         * Query test sets.
       
   215         *
       
   216         * Returns Symbian OS error code.
       
   217         */
       
   218         IMPORT_C TInt TestSets( RRefArray<CTestSetInfo>& aSetInfos );        
       
   219 
       
   220         /**
       
   221         * Query test set.
       
   222         *
       
   223         * Returns Symbian OS error code.
       
   224         */
       
   225         IMPORT_C const CTestSetInfo& TestSetL( const TDesC& aSetName  );                
       
   226         
       
   227         /**
       
   228         * Add test case to test set.
       
   229         *
       
   230         * Returns Symbian OS error code.
       
   231         */
       
   232         IMPORT_C TInt AddToTestSet( const TDesC& aSetName, const CTestInfo& aTestInfo );
       
   233  
       
   234         /**
       
   235         * Insert test case to test set.
       
   236         *
       
   237         * Returns Symbian OS error code.
       
   238         */
       
   239         IMPORT_C TInt InsertToTestSet( const TDesC& aSetName, 
       
   240                                        const CTestInfo& aTestInfo, 
       
   241                                        TInt aPos );
       
   242  
       
   243         /**
       
   244         * Remove test case from test set.
       
   245         *
       
   246         * Returns Symbian OS error code.
       
   247         */
       
   248         IMPORT_C TInt RemoveFromTestSet( const TDesC& aSetName, const CTestInfo& aTestInfo );
       
   249         
       
   250         /**
       
   251         * Save test set. Depreceated, SaveTestSet2 to be used instead
       
   252         *
       
   253         * Returns Symbian OS error code.
       
   254         */
       
   255         IMPORT_C TInt SaveTestSet( const TDesC& aSetName );
       
   256 
       
   257         /**
       
   258         * Save test set.
       
   259         *
       
   260         * Returns Symbian OS error code.
       
   261         */
       
   262         IMPORT_C TInt CUIStore::SaveTestSet2( TDes& aSetName );
       
   263         /**
       
   264         * Load test set.
       
   265         *
       
   266         * Returns Symbian OS error code.
       
   267         */
       
   268         IMPORT_C TInt LoadTestSet( const TDesC& aSetName );
       
   269 
       
   270         /**
       
   271         * Load saved test cases.
       
   272         *
       
   273         * Returns Symbian OS error code.
       
   274         */
       
   275         IMPORT_C TInt LoadSavedTestCases();
       
   276                 
       
   277         /**
       
   278         * Start selected test set identified with CTestSetInfo.
       
   279         * anIndex contains index in StartedTestSet array, 
       
   280         * which is valid only during execution of calling 
       
   281         * function.
       
   282         *
       
   283         * Returns Symbian OS error code.
       
   284         */
       
   285         IMPORT_C TInt StartTestSet( const CTestSetInfo& aTestSetInfo,
       
   286                                     TInt& anIndex,
       
   287                                     CStartedTestSet::TSetType aType = 
       
   288                                         CStartedTestSet::ESetSequential );
       
   289         IMPORT_C TInt StartTestSet( const CTestSetInfo& aTestSetInfo,
       
   290                                     TInt& anIndex,
       
   291                                     CStartedTestSet::TSetType aType,
       
   292                                     TBool aNotStartedCasesMode);
       
   293 
       
   294         /**
       
   295         * Abort running test set.
       
   296         *
       
   297         * Returns Symbian OS error code.
       
   298         */
       
   299         IMPORT_C TInt AbortTestSet( CStartedTestSet& aSetInfo );
       
   300 
       
   301         /**
       
   302         * Return started (running/runned) test set
       
   303         *
       
   304         * Returns Symbian OS error code.
       
   305         */
       
   306         IMPORT_C CStartedTestSet& StartedTestSetL( TInt anIndex );
       
   307       
       
   308         /**
       
   309         * Return started (running/runned) test cases
       
   310         *
       
   311         * Returns Symbian OS error code.
       
   312         */
       
   313         IMPORT_C TInt StartedTestSets( RRefArray<CStartedTestSet>& aTestCases,
       
   314                                        TInt aStatus = CUIStoreIf::ESetAll );       
       
   315 
       
   316         /**
       
   317         * Updates information stored about test set in file.
       
   318         *
       
   319         * Returns Symbian OS error code.
       
   320         */
       
   321         IMPORT_C TInt UpdateTestSet(CTestSetInfo& aSetInfo);
       
   322         
       
   323         /**
       
   324         * Reads filters (if any) from initialization file.
       
   325         */
       
   326         IMPORT_C void ReadFiltersL(RPointerArray<TDesC>& aFilters);
       
   327         
       
   328         /**
       
   329         * Creates list of available Test Sets.
       
   330         *
       
   331         * Returns Symbian OS error code.
       
   332         */
       
   333         
       
   334         IMPORT_C TInt GetTestSetsList( RRefArray<TDesC>& aArray );
       
   335         
       
   336 
       
   337     public: // Functions from base classes
       
   338 
       
   339 
       
   340     protected:  // New functions
       
   341         // None
       
   342 
       
   343     protected:  // Functions from base classes
       
   344         // None
       
   345 
       
   346     private:
       
   347 
       
   348         /** 
       
   349         * C++ default constructor.
       
   350         */
       
   351         CUIStore( CUIStoreIf* iUIStoreIf );
       
   352 
       
   353         /**
       
   354         * By default Symbian OS constructor is private.
       
   355         */
       
   356         void ConstructL();
       
   357         
       
   358         /**
       
   359         * Test case executed.
       
   360         *
       
   361         * Returns Symbian OS error code.
       
   362         */
       
   363         void TestExecuted ( CUIEngineContainer* aContainer,
       
   364                             TFullTestResult& aFullTestResult );
       
   365 
       
   366         /**
       
   367         * Progress information from Test case execution.
       
   368         *
       
   369         * Returns Symbian OS error code.
       
   370         */
       
   371         TInt PrintProg ( CUIEngineContainer* aContainer,
       
   372                          TTestProgress& aProgress );
       
   373 
       
   374         /**
       
   375         * Error information from Test framework.
       
   376         *
       
   377         * Returns Symbian OS error code.
       
   378         */
       
   379         TInt ErrorPrint( TErrorNotification& aError );
       
   380                          
       
   381         /**
       
   382         * Remote protocol messages handler.
       
   383         */
       
   384         TInt RemoteMsg( CUIEngineContainer* aContainer,
       
   385                         const TDesC& aMessage );
       
   386         /**
       
   387         * Reboot indication handler.
       
   388         */
       
   389         TInt GoingToReboot( CUIEngineContainer* aContainer,
       
   390                             TRequestStatus& aStatus );
       
   391         
       
   392         TInt MsgRemote( CUIEngineContainer* aContainer,
       
   393                         CStifTFwIfProt& aReq, 
       
   394                         CStifTFwIfProt& aResp );
       
   395         TInt MsgRemoteRun( CUIEngineContainer* aContainer,
       
   396                            CStifTFwIfProt& aReq, 
       
   397                            CStifTFwIfProt& aResp );
       
   398         TInt MsgRemoteTestCtl( CUIEngineContainer* aContainer,
       
   399                                CStifTFwIfProt& aReq, 
       
   400                                CStifTFwIfProt& aResp );
       
   401         TInt MsgRemoteEventCtl( CUIEngineContainer* aContainer,
       
   402                                 CStifTFwIfProt& aReq, 
       
   403                                 CStifTFwIfProt& aResp );
       
   404 
       
   405         /**
       
   406         * Asynchronous remote sendreceive message.
       
   407         */
       
   408         TInt MsgRemoteSendReceive( CUIEngineContainer* aContainer,
       
   409                            CStifTFwIfProt& aReq, 
       
   410                            CStifTFwIfProt& aResp );
       
   411         
       
   412         /**
       
   413         * Initialize logger from UI engine.
       
   414         */
       
   415         inline void InitializeLogger( CStifLogger* aLogger )
       
   416             { iLogger = aLogger; };
       
   417         
       
   418         /**
       
   419         * Set update flag.
       
   420         */
       
   421         inline void RefreshAllCases()
       
   422             { iUpdateNeeded = ETrue; };
       
   423             
       
   424         /**
       
   425         * Update test case list if required.
       
   426         */
       
   427         TInt UpdateCases();
       
   428         
       
   429         /**
       
   430         * Try to locate default initialization file.
       
   431         */
       
   432         void CheckIniL( TFileName& aIni );
       
   433         
       
   434         /**
       
   435         * Find testcase by container.
       
   436         */
       
   437         TInt FindByContainer( CUIEngineContainer* const aContainer,
       
   438                               CStartedTestCase*& aTestCase );
       
   439 
       
   440         /**
       
   441         * Loads all TestFramework test modules from \sys\bin\ directories .
       
   442         */
       
   443         void LoadAllModulesL();
       
   444         
       
   445         /**
       
   446         * Lists all TestFramework test modules from \sys\bin\ directories.
       
   447         */
       
   448         void ListAllModulesL( RPointerArray<TDesC>& aModuleNames );
       
   449         
       
   450         /**
       
   451         * Find test set by name.
       
   452         */
       
   453         TInt FindSetByName( const TDesC& aSetName, CTestSetInfo*& aSetInfo );
       
   454         
       
   455         /**
       
   456         * Find test set by CStartedTestCase.
       
   457         */
       
   458         TInt FindStartedSetByCase( const CStartedTestCase* aTestCase, 
       
   459                                    CStartedTestSet*& aSet  );
       
   460    
       
   461         /**
       
   462         * Load test set.
       
   463         */
       
   464         void LoadTestSetL( const TDesC& aSetName, const TDesC& aSetFileName );
       
   465         
       
   466         /**
       
   467         * Save test set.
       
   468         */ 
       
   469         void SaveTestSetL( CTestSetInfo& aSetInfo, const TDesC& aSetFileName );
       
   470 
       
   471         /**
       
   472         * Updates in file information about test set.
       
   473         */ 
       
   474         void UpdateTestSetL(CTestSetInfo& aSetInfo, const TDesC& aSetFileName);
       
   475         
       
   476         /**
       
   477         * Read the whole line from the file.
       
   478         */ 
       
   479         void ReadLineL(RFile &file, TDes& buffer);
       
   480 
       
   481         /**
       
   482         * Write given line to the file and adds end of line.
       
   483         */ 
       
   484         void WriteLineL(RFile &file, const TDesC& buffer);
       
   485 
       
   486         /**
       
   487         * Load saved executed test cases.
       
   488         *
       
   489         * Returns Symbian OS error code.
       
   490         */
       
   491         void LoadExecutedTestCasesL();
       
   492         
       
   493         /**
       
   494         * Load test modules and test case files used in 
       
   495         * aTestCases if not already done.
       
   496         */
       
   497         void LoadTestModulesAndTestCaseFilesL( const RRefArray<const CTestInfo>& aTestCases );
       
   498         
       
   499         /**
       
   500         * Parse test set name from test set file name.
       
   501         */
       
   502         TInt ParseTestSetName( const TDesC& aSetFileName, TPtrC& aSetName, TFileName& aFileName );
       
   503         
       
   504         /**
       
   505         * Do remote popup. Added aPopupPriority parameter for prioritizing popups @js      
       
   506         */
       
   507         TInt RemotePopup( CUIEngineContainer* aContainer,
       
   508                           const TDesC& aReq, 
       
   509                           CStifTFwIfProt* aResp,
       
   510                           TPopupPriority aPopupPriority = EPopupPriorityLow);        
       
   511         
       
   512         /**
       
   513         * Callback from UIStorePopup.
       
   514         */
       
   515         TInt RemotePopupComplete( CUIStorePopup* aPopup, 
       
   516                                   TInt aError,
       
   517                                   CUIEngineContainer* aContainer,
       
   518                                   CStifTFwIfProt* aResp,
       
   519                                   TKeyCode aKeyCode );
       
   520         /**
       
   521         * Return slave id.
       
   522         */
       
   523         inline TInt16 DevId(){ return 1; };
       
   524         
       
   525         /**
       
   526         * Prints the highest priority popup from queue
       
   527         */
       
   528         void SetRemotePopupFromQueue();
       
   529         
       
   530         /**
       
   531         * Shuffles remote run result popups
       
   532         */
       
   533         void ShuffleRemoteRunResultPopups( CUIStorePopup* aPopup );
       
   534         
       
   535     public:   //Data
       
   536         // Logger
       
   537         CStifLogger*                        iLogger;
       
   538 
       
   539     protected:  // Data
       
   540         // None
       
   541 
       
   542     private:    // Data
       
   543     	RPointerArray<HBufC> 				iFileList;
       
   544         // Pointer to UI (up)
       
   545         CUIStoreIf*                         iUIStoreIf;   
       
   546         
       
   547         // Pointer to UI engine (down)
       
   548         CUIEngine*                          iUIEngine;
       
   549 
       
   550     	// Available test cases   
       
   551         RPointerArray<CTestInfo>            iTestCases;    
       
   552         // Started test cases    
       
   553         RPointerArray<CStartedTestCase>     iStartedTestCases; 
       
   554  
       
   555     	// Available test sets   
       
   556         RPointerArray<CTestSetInfo>         iTestSets;    
       
   557         // Started test sets    
       
   558         RPointerArray<CStartedTestSet>      iStartedTestSets; 
       
   559         
       
   560         RPointerArray<CUIStorePopup>        iPopups;
       
   561                
       
   562         // Flag for update for test case list required
       
   563         TBool                               iUpdateNeeded;
       
   564         
       
   565         // Tells if popup is already active
       
   566         TBool                               iPopupActive;
       
   567         
       
   568         // Priority of the currently active popup
       
   569         TPopupPriority                      iActivePopupPriority;        
       
   570         
       
   571         TFileName                           iTestFrameworkIni;
       
   572         
       
   573     public:     // Friend classes
       
   574         // None
       
   575 
       
   576     protected:  // Friend classes
       
   577         // None
       
   578 
       
   579     private:    // Friend classes
       
   580         friend class CUIStorePopup;
       
   581 
       
   582     };
       
   583     
       
   584 #endif // UISTORE_H
       
   585 
       
   586 // End of File