stif/ConsoleUI/inc/ConsoleUI.h
branchRCL_3
changeset 59 8ad140f3dd41
parent 0 a03f92240627
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description: This file contains the header file of the ConsoleUI.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CONSOLE_UI_H
       
    19 #define CONSOLE_UI_H
       
    20 
       
    21 
       
    22 //  INCLUDE
       
    23 #include <e32std.h>
       
    24 #include <e32base.h>
       
    25 
       
    26 #include <stifinternal/UIStoreIf.h>
       
    27 #include <stifinternal/UIStore.h>
       
    28 #include <stifinternal/UIEngine.h>
       
    29 
       
    30 #include "CallBack.h"
       
    31 
       
    32 #include "TestModuleInfo.h"
       
    33 
       
    34 #include "ConsoleMenus.h"
       
    35 
       
    36 // CONSTANTS
       
    37 const TInt KMaxLineLength = 80;            // Longest supported line length
       
    38 const TInt KScrollPeriod = 300000;		   // Scrolling speed
       
    39 
       
    40 // MACROS
       
    41 
       
    42 // DATA TYPES
       
    43 
       
    44 // Case state
       
    45 // Menu update type
       
    46 enum TConsoleUIPanic
       
    47     {
       
    48     EInvalidCaseCompletion,
       
    49     };
       
    50 
       
    51 // FUNCTION PROTOTYPES
       
    52 
       
    53 // FORWARD DECLARATIONS
       
    54 class CMenu;
       
    55 class CConsoleMain;
       
    56 class CConsoleReader;
       
    57 class CMenuDialog;
       
    58 
       
    59 // CLASS DECLARATION
       
    60 
       
    61 // DESCRIPTION
       
    62 // CModule contains a test module data
       
    63 
       
    64 class CScrollerTimer
       
    65         :public CActive
       
    66     {
       
    67     public:  // Enumerations
       
    68         // None
       
    69 
       
    70     private: // Enumerations
       
    71         
       
    72     public:  // Constructors and destructor
       
    73 
       
    74         /**
       
    75         * NewL is first phase of two-phased constructor.
       
    76         */
       
    77         static CScrollerTimer* NewL( CConsoleMain* aMain );
       
    78 
       
    79         /**
       
    80         * Destructor of CModule.
       
    81         */
       
    82         ~CScrollerTimer();
       
    83 
       
    84     public: // New functions
       
    85 
       
    86 		/** 
       
    87         * StartL
       
    88         */
       
    89 		void StartL();
       
    90 
       
    91 		/** 
       
    92         * RunL
       
    93         */
       
    94 		void RunL();
       
    95 
       
    96 		/** 
       
    97         * DoCancel
       
    98         */
       
    99 		void DoCancel();
       
   100 
       
   101 		/** 
       
   102         * RunError
       
   103         */
       
   104 		TInt RunError ( TInt aError );
       
   105 
       
   106     public: // Functions from base classes
       
   107 
       
   108     protected:  // New functions
       
   109         // None
       
   110 
       
   111     protected:  // Functions from base classes
       
   112         // None
       
   113 
       
   114     private:
       
   115 
       
   116         /** 
       
   117         * C++ default constructor.
       
   118         */
       
   119         CScrollerTimer();
       
   120 
       
   121         /**
       
   122         * By default Symbian OS constructor is private.
       
   123         */
       
   124         void ConstructL( CConsoleMain* aMain );
       
   125 
       
   126     public:   //Data
       
   127         // None
       
   128 
       
   129     protected:  // Data
       
   130         // None
       
   131 
       
   132     private:    // Data
       
   133         CConsoleMain*     iMain;            // Pointer to main console
       
   134 		RTimer            iTimer;
       
   135 
       
   136     public:     // Friend classes
       
   137         // None
       
   138 
       
   139     protected:  // Friend classes
       
   140         // None
       
   141 
       
   142     private:    // Friend classes
       
   143         // None
       
   144 
       
   145     };
       
   146 
       
   147 // DESCRIPTION
       
   148 // Console UI main class
       
   149 class CConsoleMain
       
   150         :public CUIStoreIf
       
   151     {
       
   152     public: // Enumerations
       
   153         // None
       
   154 
       
   155     private: // Enumerations
       
   156         enum TStartCasesOnStart
       
   157             {
       
   158             EStartCaseNo = 0,
       
   159             EStartSingleCase,
       
   160             EStartCasesSeq,
       
   161             EStartCasesPar,
       
   162             };
       
   163 
       
   164     public:  // Constructors and destructor
       
   165 
       
   166         /**
       
   167         * NewL is first phase of two-phased constructor.
       
   168         */
       
   169         static CConsoleMain* NewL();
       
   170 
       
   171         /**
       
   172         * Start
       
   173         */
       
   174         TInt StartL();
       
   175 
       
   176         /**
       
   177         * Destructor of CConsoleMain.
       
   178         */
       
   179         ~CConsoleMain();
       
   180 
       
   181 
       
   182     public: // New functions
       
   183     
       
   184     
       
   185         /**
       
   186         * Receives output update notification from CUIStore.
       
   187         */
       
   188         void Update( CStartedTestCase* aTestCase, 
       
   189                      TInt aFlags );
       
   190                                                                       
       
   191         /**
       
   192         * Function is called when test framework prints error.
       
   193         */
       
   194         void Error( TErrorNotification& aError );
       
   195         
       
   196         /**
       
   197         * Function is called when testframework 
       
   198         * wants to print a popup window.
       
   199         */
       
   200         TInt PopupMsg( const TDesC& aLine1, 
       
   201                        const TDesC& aLine2, 
       
   202                        TInt aTimeInSecs );
       
   203         
       
   204         /**
       
   205         * Function is called when testframework 
       
   206         * wants to print a popup window and 
       
   207         * get the key pressed.
       
   208         */
       
   209         TInt PopupMsg( const TDesC& aLine1, 
       
   210                        const TDesC& aLine2, 
       
   211                        TInt aTimeInSecs,
       
   212                        TKeyCode& aKey,
       
   213                        TRequestStatus& aStatus );
       
   214 
       
   215         /**
       
   216         * Close instance.
       
   217         */
       
   218         void Close( TInt aHandle );
       
   219                 
       
   220         /**
       
   221         * Console UI panic function
       
   222         */
       
   223         static void Panic( TConsoleUIPanic aPanic );
       
   224 
       
   225         /**
       
   226         * Return pointer to console
       
   227         */
       
   228         CConsoleBase* GetConsole();
       
   229 
       
   230         /**
       
   231         * Called from timer to perform scrolling
       
   232         */
       
   233         void TimerUpdate();
       
   234                 
       
   235         /**
       
   236         * Process keystokes.
       
   237         */
       
   238         void KeyPressed();
       
   239 
       
   240         /**
       
   241          * Displays no memory error message and closes ConsoleUI
       
   242          */
       
   243         void ExitWithNoMemoryErrorMessage();
       
   244         
       
   245         /**
       
   246          * Returns MainMenu of console
       
   247          */
       
   248         CMainMenu* GetMainMenu();
       
   249         
       
   250         /**
       
   251          * Get filter array for reading purpose
       
   252          */
       
   253         const RPointerArray<TDesC>& GetFilterArray(void) const;
       
   254         
       
   255         /**
       
   256          * Set info about which index filter is used
       
   257          */
       
   258         void SetFilterIndex(TInt aFilterIndex);
       
   259 
       
   260         /**
       
   261          * Get info about which index filter is used
       
   262          */
       
   263         TInt GetFilterIndex(void);
       
   264         
       
   265     public: // Functions from base classes
       
   266 
       
   267     protected:  // New functions
       
   268         // None
       
   269 
       
   270     protected:  // Functions from base classes
       
   271         // None
       
   272 
       
   273     private:
       
   274 
       
   275         /** 
       
   276         * C++ default constructor.
       
   277         */
       
   278         CConsoleMain();
       
   279 
       
   280         /**
       
   281         * By default Symbian OS constructor is private.
       
   282         */
       
   283         void ConstructL();
       
   284 
       
   285 
       
   286         /**
       
   287         * Print error from ConsoleUI.
       
   288         */  
       
   289         void UiError( const TDesC& aInfo );
       
   290         
       
   291         /**
       
   292         * Process command line parameters.
       
   293         */
       
   294         void ProcessCommandlineL( TFileName& aIniFile );
       
   295 
       
   296         /**
       
   297         * Parse and search for module info and fill list of modules.
       
   298         */
       
   299         void ParseTestModulesL(CStifParser* aParser, CTestModuleList* aModuleList, const TDesC& aSectionStart, const TDesC& aSectionEnd);
       
   300         
       
   301     public:   //Data
       
   302         RPointerArray<CMenuDialog> iDialogs;
       
   303         
       
   304     protected:  // Data
       
   305         // None
       
   306 
       
   307     private:    // Data
       
   308         CConsoleBase*       iConsole;       // Pointer to console
       
   309 
       
   310         CMenu*              iMainMenu;      // Root menu
       
   311         CMenu*              iCurrentMenu;   // Current menu
       
   312 
       
   313         CScrollerTimer*     iScroller;
       
   314         
       
   315         CConsoleReader*     iReader;        // Console reader                   
       
   316     
       
   317         // For starting runnning multiple cases upon start
       
   318         TStartCasesOnStart  iStartCases;
       
   319         HBufC*              iTestModule;
       
   320         HBufC*              iTestModuleIni;
       
   321         HBufC*              iTestCaseFile;
       
   322         TInt                iTestCaseNum;
       
   323         HBufC*              iTestSetName;
       
   324 
       
   325         // List of found modules (included from module given in parameters)
       
   326         CTestModuleList*    iModuleList;
       
   327         
       
   328         // List of filters (for test cases title)
       
   329         RPointerArray<TDesC> iFilters;
       
   330         
       
   331         // Chosen filter index
       
   332         TInt iChosenFilterIndex;
       
   333         
       
   334     public:     // Friend classes
       
   335         // None
       
   336 
       
   337     protected:  // Friend classes
       
   338         // None
       
   339 
       
   340     private:    // Friend classes
       
   341         // None
       
   342 
       
   343     };
       
   344     
       
   345 // DESCRIPTION
       
   346 // Read keystrokes from console
       
   347 class CConsoleReader
       
   348     :public CActive
       
   349     {
       
   350     public: // Enumerations
       
   351         // None
       
   352 
       
   353     private: // Enumerations
       
   354         // None
       
   355 
       
   356     public:  // Constructors and destructor
       
   357 
       
   358         /**
       
   359         * NewL is first phase of two-phased constructor.
       
   360         */
       
   361         static CConsoleReader* NewL( CConsoleMain* aMain, 
       
   362                                      CConsoleBase* aConsole );
       
   363 
       
   364         /**
       
   365         * Start
       
   366         */
       
   367         void StartL();
       
   368 
       
   369         /**
       
   370         * Destructor of CConsoleReader.
       
   371         */
       
   372         ~CConsoleReader();
       
   373 
       
   374 
       
   375     public: // New functions
       
   376 
       
   377     public: // Functions from base classes
       
   378 
       
   379         /**
       
   380         * RunL derived from CActive handles the completed requests.
       
   381         */
       
   382         void RunL();
       
   383 
       
   384         /**
       
   385         * DoCancel derived from CActive handles the Cancel
       
   386         */
       
   387         void DoCancel();
       
   388         /**
       
   389         * RunError derived from CActive handles errors from active object
       
   390         */        
       
   391         virtual TInt RunError(TInt aError);
       
   392 
       
   393     protected:  // New functions
       
   394         // None
       
   395 
       
   396     protected:  // Functions from base classes
       
   397         // None
       
   398 
       
   399     private:
       
   400 
       
   401         /** 
       
   402         * C++ default constructor.
       
   403         */
       
   404         CConsoleReader( CConsoleMain* aMain, 
       
   405                         CConsoleBase* iConsole );
       
   406 
       
   407         /**
       
   408         * By default Symbian OS constructor is private.
       
   409         */
       
   410         void ConstructL();
       
   411 
       
   412     public:   //Data
       
   413         // None
       
   414     
       
   415     protected:  // Data
       
   416         // None
       
   417 
       
   418     private:    // Data
       
   419         CConsoleBase*   iConsole;   // Pointer to console
       
   420         CConsoleMain*   iMain;      // Backpointer
       
   421 
       
   422     public:     // Friend classes
       
   423         // None
       
   424 
       
   425     protected:  // Friend classes
       
   426         // None
       
   427 
       
   428     private:    // Friend classes
       
   429         // None
       
   430 
       
   431     };
       
   432 
       
   433 #endif // CONSOLEUI_H
       
   434 
       
   435 // End of File