stif/TestServer/inc/TestThreadContainerRunner.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 
       
    15 * TestThreadContainerRunner class.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef TESTTHREADCONTAINERRUNNER_H_
       
    20 #define TESTTHREADCONTAINERRUNNER_H_
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 
       
    25 // CONSTANTS
       
    26 // None
       
    27 
       
    28 // MACROS
       
    29 // None
       
    30 
       
    31 // DATA TYPES
       
    32 // None
       
    33 
       
    34 // FUNCTION PROTOTYPES
       
    35 // None
       
    36 
       
    37 // FORWARD DECLARATIONS
       
    38 class CTestThreadContainer;
       
    39 class CTestModuleContainer;
       
    40 
       
    41 // CLASS DECLARATION
       
    42 
       
    43 // DESCRIPTION
       
    44 // This class is used to emulate CTestThreadContainer::ExecutionThread method
       
    45 // as an active object run in main thread of uitestserverstarter.
       
    46 class CTestThreadContainerRunner: public CActive
       
    47 	{
       
    48 	public: // Enumerations
       
    49 	    // None
       
    50 	
       
    51 	private: // Enumerations
       
    52 		// Current operation type
       
    53 		enum TOperationType { ENone,			// None 
       
    54 							  ESetup, 			// Setup
       
    55 							  ETearDown,		// TearDown
       
    56 							  ERunOneIteration,	// Emulate one iteration of while loop placed 
       
    57 							  					// in CTestThreadContainer::ExecutionThread   
       
    58 							};
       
    59 	
       
    60 	public:  // Constructors and destructor
       
    61 		/**
       
    62 		 * Performs first phase of two-phased constructor.
       
    63 		 */
       
    64 		IMPORT_C static CTestThreadContainerRunner* NewL( TThreadId aMainThreadId, 
       
    65 				CActiveScheduler* aMainThreadActiveScheduler );
       
    66 
       
    67 		/**
       
    68 		 * C++ destructor.
       
    69 		 */
       
    70 		~CTestThreadContainerRunner();
       
    71 	
       
    72 	private:  // Constructors and destructor
       
    73 		/**
       
    74 		 * C++ constructor.
       
    75 		 */
       
    76 		CTestThreadContainerRunner();
       
    77 		
       
    78 		/**
       
    79 		 * Performs second phase of two-phased constructor.
       
    80 		 */
       
    81 		void ConstructL( TThreadId aMainThreadId, 
       
    82 				CActiveScheduler* aMainThreadActiveScheduler );
       
    83 	
       
    84 	public: // New functions
       
    85 		/**
       
    86 		 * Performs TestThreadContainer setup.
       
    87 		 */
       
    88 		void Setup( CTestModuleContainer* aTestModuleContainer );
       
    89 		
       
    90 		/**
       
    91 		 * Runs one iteration of emulated CTestThreadContainer::ExecutionThread while loop.
       
    92 		 */
       
    93 		void RunOneIteration();
       
    94 		
       
    95 		/**
       
    96 		 * Performs cleanup of TestThreadContainer.
       
    97 		 */
       
    98 		void TeareDown();
       
    99 		
       
   100 		/**
       
   101 		 * Checks if operation change signal was signaled from suspend state. 
       
   102 		 */
       
   103 		void CheckSignalFromSuspend();
       
   104 
       
   105 		/**
       
   106 		 * Checks if test thread is reusable.
       
   107 		 */
       
   108 		TBool IsReusable();
       
   109 
       
   110 
       
   111 	public: // Functions from base classes
       
   112 		/**
       
   113 		 * RunL derived from CActive handles the completed requests.
       
   114 		 */
       
   115 		void RunL();
       
   116 
       
   117 		/**
       
   118 		 * DoCancel derived from CActive handles the Cancel.
       
   119 		 */
       
   120 		void DoCancel();
       
   121 
       
   122     protected:	// New functions
       
   123         // None
       
   124         
       
   125     protected:	// Functions from base classes
       
   126         // None
       
   127         
       
   128     private:	// New functions
       
   129     	/**
       
   130     	 * Test thread exception handler. 
       
   131     	 */
       
   132 		static void ExceptionHandler ( TExcType aType );
       
   133 	
       
   134 		/**
       
   135 		 * Raises panic.
       
   136 		 */
       
   137 		void Panic( TInt aReason );
       
   138 		
       
   139 		/**
       
   140 		 * Complets current operation request, what causes execution of RunL method 
       
   141 		 * in main thread of UITestServerStarter.
       
   142 		 */
       
   143 		void CompleteRequest();
       
   144     private:	// Functions from base classes
       
   145         // None    
       
   146     
       
   147 	public:		//Data
       
   148 	    // None
       
   149         
       
   150 	protected:	// Data
       
   151         // None
       
   152         
       
   153     private:	// Data
       
   154 		TThreadId iMainThreadId;					// UITestServerStarter main thread id.
       
   155 		CActiveScheduler* iMainThreadActiveScheduler;	// Pointer to UITestServerStarter main thread active scheduler.		
       
   156 	    RLibrary iModule;							// Handle to test module library.
       
   157 		CTestModuleContainer* iTestModuleContainer; // Pointer to test module container.		
       
   158 		TOperationType iCurrentOperation;			// Current operation type.
       
   159 		CTestThreadContainer* iTestThreadContainer;	// Pointer to test thread container.
       
   160 	
       
   161 		RSemaphore iOperationOngoing;				// Current operation end semaphore.
       
   162 		
       
   163 	    TBool iReusable;             				// Is test module reusable.
       
   164 	    TBool iSignalFromSuspend;   				// Send signal from suspend state.
       
   165 	    TBool iInitialized;         				// Is module initialized.
       
   166 	    TInt iReturnCode;							// Lasst loop result code
       
   167 		
       
   168     public:		// Friend classes
       
   169         // None
       
   170 
       
   171     protected:	// Friend classes
       
   172         // None
       
   173 
       
   174     private:	// Friend classes
       
   175         // None
       
   176 	};
       
   177 
       
   178 #endif // TESTTHREADCONTAINERRUNNER_H_
       
   179 
       
   180 // End of File