testexecfw/stf/stffw/testsrv/src/Testexecution.cpp
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 module contains implementation of CTestExecution 
       
    15 * class member functions. CTestExecution class handles a test 
       
    16 * execution subsession specific operations.
       
    17 *
       
    18 */
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32std.h>
       
    22 #include <e32svr.h>
       
    23 #include "TestEngineClient.h"
       
    24 #include "StifTFwIfProt.h"
       
    25 #include <stifinternal/TestServerClient.h>
       
    26 #include "TestServer.h"
       
    27 #include "TestServerModuleIf.h"
       
    28 #include "TestServerCommon.h"
       
    29 #include "PrintQueue.h"
       
    30 #include "TestServerEvent.h"
       
    31 #include "TestThreadContainer.h"
       
    32 #include "STIFMeasurement.h"
       
    33 
       
    34 // EXTERNAL DATA STRUCTURES
       
    35 
       
    36 // EXTERNAL FUNCTION PROTOTYPES  
       
    37 
       
    38 // CONSTANTS
       
    39 
       
    40 // MACROS
       
    41 
       
    42 // LOCAL CONSTANTS AND MACROS
       
    43 
       
    44 // MODULE DATA STRUCTURES
       
    45 
       
    46 // LOCAL FUNCTION PROTOTYPES
       
    47 
       
    48 // FORWARD DECLARATIONS
       
    49 
       
    50 // ==================== LOCAL FUNCTIONS =======================================
       
    51 
       
    52 // ================= MEMBER FUNCTIONS =========================================
       
    53 
       
    54 /*
       
    55 -------------------------------------------------------------------------------
       
    56 
       
    57     Class: CTestExecution
       
    58 
       
    59     Method: NewL
       
    60 
       
    61     Description: Returns new CTestExecution instance.
       
    62 
       
    63     Parameters: CTestModule* aModuleSession   :in:  "Parent" module
       
    64                 TInt aCaseNumber              :in:  Test case number
       
    65                 const TFileName& aConfig      :in:  Configuration filename
       
    66 
       
    67     Return Values: CTestExecution*                  New instance
       
    68 
       
    69     Errors/Exceptions: Function leaves if memory allocation fails or
       
    70                        CTestExecution construction leaves.
       
    71                        Panics is aModuleSession is NULL.
       
    72 
       
    73     Status: Proposal
       
    74 
       
    75 -------------------------------------------------------------------------------
       
    76 */
       
    77 CTestExecution* CTestExecution::NewL( CTestModule* aModuleSession,
       
    78                                       TInt aCaseNumber, 
       
    79                                       const TFileName& aConfig )
       
    80     {
       
    81 
       
    82     __ASSERT_ALWAYS ( aModuleSession, 
       
    83                       CTestServer::PanicServer( ENullModuleSession ) );
       
    84 
       
    85     CTestExecution* self=new( ELeave ) CTestExecution;
       
    86     CleanupClosePushL( *self );
       
    87     self->ConstructL( aModuleSession, aCaseNumber, aConfig );
       
    88     CleanupStack::Pop();
       
    89 
       
    90     return self;
       
    91 
       
    92     }
       
    93 
       
    94 
       
    95 /*
       
    96 -------------------------------------------------------------------------------
       
    97 
       
    98     Class: CTestExecution
       
    99 
       
   100     Method: CTestExecution
       
   101 
       
   102     Description: Constructor.
       
   103     Initialises member variables whose default state is not zero or NULL.
       
   104 
       
   105     Parameters:  None
       
   106     
       
   107     Return Values: None
       
   108 
       
   109     Errors/Exceptions: None
       
   110 
       
   111     Status: Proposal
       
   112     
       
   113 -------------------------------------------------------------------------------
       
   114 */
       
   115 CTestExecution::CTestExecution() : 
       
   116     iConfig( 0, 0 ),
       
   117     iTestThreadOpen( EFalse ),
       
   118     iTestThreadFailure( ETestThreadOk )
       
   119     {
       
   120 
       
   121     iPrintNotifyAvailable = EFalse;
       
   122     iThreadState = ENotStarted;
       
   123     iRemoteSendAvailable = EFalse;
       
   124     iRemoteReceiveAvailable = EFalse;
       
   125     iEventNotifyAvailable = EFalse;
       
   126     iCommandNotifyAvailable = EFalse;
       
   127 
       
   128     }
       
   129 
       
   130 /*
       
   131 -------------------------------------------------------------------------------
       
   132 
       
   133     Class: CTestExecution
       
   134 
       
   135     Method: ~CTestExecution
       
   136 
       
   137     Description: Destructor
       
   138 
       
   139     Parameters: None
       
   140     
       
   141     Return Values: None
       
   142 
       
   143     Errors/Exceptions: Panics is threadmutex is taken.
       
   144 
       
   145     Status: Approved
       
   146     
       
   147 -------------------------------------------------------------------------------
       
   148 */
       
   149 CTestExecution::~CTestExecution()
       
   150     {
       
   151     // Cancel (remove) all requested events of current test case
       
   152     REventSystem es;
       
   153     es.RemoveInRequestedState(reinterpret_cast<TInt>(this));
       
   154 
       
   155     // Thread must be stopped before CTestExecution can be deleted
       
   156     if( iThreadState == EOnGoing ) 
       
   157 		{
       
   158 			if( iModuleContainer != NULL )
       
   159 				{
       
   160 				iModuleContainer->KillThread( KErrCancel );
       
   161 				}
       
   162 			delete iModuleContainer;
       
   163 			iModuleContainer = NULL;
       
   164 			CTestServer::PanicServer( EClosingWhileTestRunning );
       
   165 		}
       
   166 
       
   167     delete iPrintHandler;
       
   168     iPrintHandler = NULL;
       
   169     delete iEventHandler;
       
   170     iEventHandler = NULL;
       
   171     delete iSndHandler;
       
   172     iSndHandler = NULL;
       
   173     delete iRcvHandler;
       
   174     iRcvHandler = NULL;
       
   175     delete iInterferenceHandler;
       
   176     iInterferenceHandler = NULL;
       
   177     delete iMeasurementHandler;
       
   178     iMeasurementHandler = NULL;
       
   179     delete iCommandHandler;
       
   180     iCommandHandler = NULL;
       
   181 
       
   182     // Test interference array(Needed cases when test interference thread is
       
   183     // needed to Kill())
       
   184     iSTIFTestInterferenceArray.Reset();
       
   185     iSTIFTestInterferenceArray.Close();
       
   186 
       
   187     // Reset test measurement array
       
   188     iMeasurementHandlingArray.Reset();
       
   189     iMeasurementHandlingArray.Close();
       
   190 
       
   191     // iPrintQueue must be emptied here, because it items are allocated from server heap
       
   192     delete iPrintQueue;
       
   193     iPrintQueue = NULL;
       
   194 
       
   195     // Delete name buffer
       
   196     delete iConfigNameBuffer;
       
   197     iConfigNameBuffer = NULL;
       
   198     
       
   199     iStateEvents.ResetAndDestroy();
       
   200     iStateEvents.Close();
       
   201 
       
   202     iEventArray.ResetAndDestroy();
       
   203     iEventArray.Close();
       
   204 
       
   205     // Close mutexes
       
   206     if ( iPrintMutex.Handle() != 0 ) iPrintMutex.Close();
       
   207     if ( iEventMutex.Handle() != 0 ) iEventMutex.Close();
       
   208     if ( iSndMutex.Handle() != 0 ) iSndMutex.Close();
       
   209     if ( iRcvMutex.Handle() != 0 ) iRcvMutex.Close();
       
   210     if ( iInterferenceMutex.Handle() != 0 ) iInterferenceMutex.Close();
       
   211     if ( iMeasurementMutex.Handle() != 0 ) iMeasurementMutex.Close();
       
   212     if ( iCommandMutex.Handle() != 0 ) iCommandMutex.Close();
       
   213 
       
   214     // Mutex for testcomplete and cancel operations. Close mutex
       
   215     if ( iTestThreadMutex.Handle() != 0 ) iTestThreadMutex.Close();
       
   216 
       
   217     // Close semaphores
       
   218     if ( iPrintSem.Handle() != 0 ) iPrintSem.Close();
       
   219     if ( iEventSem.Handle() != 0 ) iEventSem.Close();
       
   220     if ( iSndSem.Handle() != 0 ) iSndSem.Close();
       
   221     if ( iRcvSem.Handle() != 0 ) iRcvSem.Close();
       
   222     if ( iInterferenceSem.Handle() != 0 ) iInterferenceSem.Close();
       
   223     if ( iMeasurementSem.Handle() != 0 ) iMeasurementSem.Close();
       
   224     //if ( iReceiverSem.Handle() != 0 ) iReceiverSem.Close();
       
   225     if ( iCommandSem.Handle() != 0 ) iCommandSem.Close();
       
   226     
       
   227     iMessageQueue.Close();
       
   228     
       
   229     iTestThread.Close();
       
   230 
       
   231     delete iCommandDef;
       
   232     iCommandDef = NULL;
       
   233     
       
   234     delete iAsyncEventActive;
       
   235     iAsyncEventActive = NULL;
       
   236     }
       
   237 
       
   238 
       
   239 /*
       
   240 -------------------------------------------------------------------------------
       
   241 
       
   242     Class: CTestExecution
       
   243 
       
   244     Method: ConstructL
       
   245 
       
   246     Description: Second level constructor
       
   247 
       
   248     Parameters: CTestModule* aModuleSession   :in:  "Parent" module
       
   249                 TInt aCaseNumber ::           :in:  Test case number
       
   250                 const TFileName& aConfig      :in:  Configuration filename
       
   251 
       
   252     Return Values: None
       
   253 
       
   254     Errors/Exceptions: None
       
   255 
       
   256     Status: Approved
       
   257 
       
   258 -------------------------------------------------------------------------------
       
   259 */
       
   260 void CTestExecution::ConstructL( CTestModule *aModuleSession,
       
   261                                  TInt aCaseNumber,
       
   262                                  const TFileName& aConfig )
       
   263     {
       
   264 
       
   265     // Get the parameters
       
   266     iModuleSession = aModuleSession;
       
   267     iCaseNumber = aCaseNumber;
       
   268 
       
   269     // Construct heap buffer for configuration file
       
   270     iConfigNameBuffer = HBufC::NewL( aConfig.Length() );
       
   271     iConfig.Set ( iConfigNameBuffer->Des() );
       
   272     iConfig.Copy ( aConfig );
       
   273 
       
   274     // Create mutexes
       
   275     User::LeaveIfError( iPrintMutex.CreateLocal() );
       
   276     User::LeaveIfError( iEventMutex.CreateLocal() );
       
   277     User::LeaveIfError( iSndMutex.CreateLocal() );
       
   278     User::LeaveIfError( iRcvMutex.CreateLocal() );
       
   279     User::LeaveIfError( iInterferenceMutex.CreateLocal() );
       
   280     User::LeaveIfError( iMeasurementMutex.CreateLocal() );
       
   281     User::LeaveIfError( iCommandMutex.CreateLocal() );
       
   282 
       
   283     // Mutex for testcomplete and cancel operations. Create mutex
       
   284     User::LeaveIfError( iTestThreadMutex.CreateLocal() );
       
   285 
       
   286     // Create semaphores
       
   287     User::LeaveIfError( iPrintSem.CreateLocal( 0 ) );
       
   288     User::LeaveIfError( iEventSem.CreateLocal( 0 ) );
       
   289     User::LeaveIfError( iSndSem.CreateLocal( 0 ) );
       
   290     User::LeaveIfError( iRcvSem.CreateLocal( 0 ) );
       
   291     User::LeaveIfError( iInterferenceSem.CreateLocal( 0 ) );
       
   292     User::LeaveIfError( iMeasurementSem.CreateLocal( 0 ) );
       
   293     //User::LeaveIfError( iReceiverSem.CreateLocal( 0 ) );
       
   294     User::LeaveIfError( iCommandSem.CreateLocal( 0 ) );
       
   295 
       
   296     // Create handlers
       
   297     iPrintHandler = CPrintHandler::NewL( *this );
       
   298     iEventHandler = CEventHandler::NewL( *this );
       
   299     iSndHandler  = CSndHandler::NewL( *this );
       
   300     iRcvHandler  = CRcvHandler::NewL( *this );
       
   301     iInterferenceHandler = CInterferenceHandler::NewL( *this );
       
   302     iMeasurementHandler = CMeasurementHandler::NewL( *this );
       
   303     iCommandHandler = CCommandHandler::NewL( *this );
       
   304 
       
   305     // Create print queue
       
   306     iPrintQueue = CPrintQueue::NewL();
       
   307 
       
   308     // Start print handler   
       
   309     iPrintHandler->StartL();
       
   310     
       
   311     // Start rcv handler
       
   312     iRcvHandler->StartL();
       
   313 
       
   314     // Start interference handler
       
   315     iInterferenceHandler->StartL();
       
   316 
       
   317     // Start measurement handler
       
   318     iMeasurementHandler->StartL();
       
   319 
       
   320     iCommandDef = CCommandDef::NewL();
       
   321     }
       
   322 
       
   323 
       
   324 /*
       
   325 -------------------------------------------------------------------------------
       
   326 
       
   327     Class: CTestExecution
       
   328 
       
   329     Method: RunTestCase
       
   330 
       
   331     Description: Starts to execute test case in separate thread.
       
   332 
       
   333     Parameters: const RMessage& aMessage  :in:      Message from client.
       
   334 
       
   335     Return Values: TInt                             Error code
       
   336 
       
   337     Errors/Exceptions: None
       
   338 
       
   339     Status: Proposal
       
   340 
       
   341 -------------------------------------------------------------------------------
       
   342 */
       
   343 TInt CTestExecution::RunTestCase( const RMessage2& aMessage )
       
   344     {
       
   345 
       
   346     __TRACE ( KInit, ( _L( "CTestExecution::RunTestCase in" ) ) );
       
   347 
       
   348     // Store message to be completed when case is finished
       
   349     iTestExeMessage = aMessage;
       
   350 
       
   351     iFullResult.iStartTime.HomeTime();
       
   352 
       
   353     // Get a test module, which executes the test case.
       
   354     // The test module will be freed either when the test case
       
   355     // completes, or the test case is aborted.
       
   356     TInt ret = iModuleSession->GetTestModule( iModuleContainer, iConfig );
       
   357     if ( ret != KErrNone || iModuleContainer == NULL )
       
   358         {
       
   359         _LIT(KRunError,"Can't get test module");
       
   360         __TRACE ( KError, ( CStifLogger::ERed, KRunError() ) );
       
   361         CompleteTestExecution( KErrNone,
       
   362                                TFullTestResult::ECaseException,
       
   363                                ret,
       
   364                                KErrGeneral,
       
   365                                KRunError );
       
   366         return KErrNone;
       
   367         }
       
   368     
       
   369 
       
   370     // Thread is created, so all thread specific operations are possible, 
       
   371     // even if thread is not yet resumed, so mark thread to be "Running"
       
   372     SetThreadState ( EOnGoing );
       
   373 
       
   374     // Start the test
       
   375     iModuleContainer->SetExecutionSubSession( this );
       
   376     iModuleContainer->RunTestCase( iConfig, iCaseNumber, aMessage );
       
   377 
       
   378     __TRACE ( KRunTestCase, ( _L( "CTestExecution::RunTestCase out. Case ongoing" ) ) );
       
   379 
       
   380     return KErrNone;
       
   381 
       
   382     }
       
   383 
       
   384 
       
   385 /*
       
   386 -------------------------------------------------------------------------------
       
   387 
       
   388     Class: CTestExecution
       
   389 
       
   390     Method: NotifyPrint
       
   391 
       
   392     Description: Handles print request from engine. If print queue is empty,
       
   393                  message is stored to be used later when there is something to
       
   394                  print, otherwise the first queue item is returned and request
       
   395                  completes immediately.
       
   396 
       
   397     Parameters: const RMessage& aMessage      :in:  Message from client.
       
   398 
       
   399     Return Values: None
       
   400 
       
   401     Errors/Exceptions: None
       
   402 
       
   403     Status: Proposal
       
   404     
       
   405 -------------------------------------------------------------------------------
       
   406 */
       
   407 TInt CTestExecution::NotifyPrint( const RMessage2& aMessage )
       
   408     {
       
   409 
       
   410     __ASSERT_ALWAYS( iPrintNotifyAvailable == EFalse, 
       
   411                      CTestServer::PanicServer( EPrintQueueBroken ) );
       
   412 
       
   413     // Get first item from queue
       
   414     TPrintQueueItem *item = iPrintQueue->Pop();
       
   415 
       
   416     if ( item == NULL )
       
   417         {
       
   418 
       
   419         // If thread can't print anymore, and queue is empty, then 
       
   420         // complete with Eof, because there will not be any new prints
       
   421         if ( iThreadState == EFinished || iThreadState == ECancelled )
       
   422             {
       
   423             __TRACE ( KPrint, ( _L( "CTestExecution::NotifyPrint to finished thread" ) ) );
       
   424             aMessage.Complete ( KErrEof );
       
   425             }
       
   426         else
       
   427             {
       
   428             // Print request available, do not complete request
       
   429             iNotifyPrintMessage = aMessage;
       
   430             iPrintNotifyAvailable = ETrue;
       
   431             }
       
   432 
       
   433         }
       
   434     else
       
   435         {
       
   436         // Construct message
       
   437         TTestProgress progress;
       
   438         progress.iPosition = item->iPriority;
       
   439         progress.iDescription = item->iData1;
       
   440         progress.iText = item->iData2;
       
   441 
       
   442         iNotifyPrintMessage = aMessage;
       
   443         // Write message to client space and complete request
       
   444         WritePrint( progress );
       
   445 
       
   446         delete item; 
       
   447         }
       
   448 
       
   449 
       
   450     return KErrNone;
       
   451 
       
   452     }
       
   453 /*
       
   454 -------------------------------------------------------------------------------
       
   455 
       
   456     Class: CTestExecution
       
   457 
       
   458     Method: DoNotifyPrint
       
   459 
       
   460     Description: If print notification available, notification is copied to
       
   461                     client memory space and request is completed.
       
   462                  Else new print queue item is created and appended to print 
       
   463                     queue. If queue is full or memory can't be allocated,
       
   464                     then message will be discarded.
       
   465         
       
   466     Parameters: None
       
   467     
       
   468     Return Values: None
       
   469 
       
   470     Errors/Exceptions: None
       
   471 
       
   472     Status: Proposal
       
   473     
       
   474 -------------------------------------------------------------------------------
       
   475 */
       
   476 void CTestExecution::DoNotifyPrint()
       
   477     {    
       
   478 
       
   479     if ( iPrintNotifyAvailable )
       
   480         {
       
   481         // Write message to client space
       
   482         WritePrint( iProgress );
       
   483         }
       
   484     else
       
   485         {
       
   486 
       
   487         TPrintQueueItem *item = 
       
   488             new TPrintQueueItem( iProgress.iPosition, 
       
   489                                  iProgress.iDescription, 
       
   490                                  iProgress.iText );
       
   491 
       
   492         if ( item != NULL )
       
   493             {
       
   494             // Item constructed ok, add it to queue
       
   495             if ( iPrintQueue->Push( *item ) != KErrNone )
       
   496                 { 
       
   497                 // Queue is full, clean-up
       
   498                 delete item;
       
   499                 }
       
   500             }
       
   501         // else: Could not construct TPrintQueueItem, no free memory.
       
   502         // drop printing            
       
   503         }
       
   504     
       
   505     }
       
   506 
       
   507 /*
       
   508 -------------------------------------------------------------------------------
       
   509 
       
   510     Class: CTestExecution
       
   511 
       
   512     Method: DoNotifyInterference
       
   513 
       
   514     Description: Handles Test Interference thread append and remove operations.
       
   515         
       
   516     Parameters: None
       
   517     
       
   518     Return Values: None
       
   519 
       
   520     Errors/Exceptions: None
       
   521 
       
   522     Status: Proposal
       
   523     
       
   524 -------------------------------------------------------------------------------
       
   525 */
       
   526 void CTestExecution::DoNotifyInterference()
       
   527     {    
       
   528     // Information for this context => information is in this thread's heap and
       
   529     // if CUndertaker::RunL is called then test interface thread can called
       
   530     // with function call and kill() test interference thread
       
   531 
       
   532     // Take information from struct given in 
       
   533     // CTestThreadContainer::AddInterferenceThread or
       
   534     // CTestThreadContainer::RemoveInterferenceThread
       
   535     
       
   536     RThread thread;
       
   537     TInt ret = thread.Open ( iTestInterference.iThreadId );
       
   538     if( ret != KErrNone )
       
   539     	{
       
   540     	RDebug::Print( _L("CTestExecution::DoNotifyInterference %d"), ret );
       
   541         User::Panic( _L("CTestExecution::DoNotifyInterference"), ret );
       
   542     	}
       
   543     
       
   544     if ( iTestInterference.iOperation == TTestInterference::EAppend )
       
   545         {
       
   546         iSTIFTestInterferenceArray.Append( thread );
       
   547         }
       
   548     else if (iTestInterference.iOperation == TTestInterference::ERemove )
       
   549         {
       
   550         // Remove thread from Array.Test interference thread is stopped and killed
       
   551         // successfully
       
   552         for( TInt i = 0; i < iSTIFTestInterferenceArray.Count(); i++ )
       
   553             {
       
   554             if( iSTIFTestInterferenceArray[i].Id() == thread.Id() )
       
   555                 {
       
   556                 iSTIFTestInterferenceArray.Remove( i );
       
   557                 break;
       
   558                 }
       
   559             }
       
   560         }
       
   561     else
       
   562         {
       
   563         return;
       
   564         }
       
   565 
       
   566     }
       
   567 
       
   568 /*
       
   569 -------------------------------------------------------------------------------
       
   570 
       
   571     Class: CTestExecution
       
   572 
       
   573     Method: DoNotifyMeasurement
       
   574 
       
   575     Description: Handles test measurement operations: NewL, Start and Stop.
       
   576         
       
   577     Parameters: None
       
   578     
       
   579     Return Values: None
       
   580 
       
   581     Errors/Exceptions: None
       
   582 
       
   583     Status: Approved
       
   584     
       
   585 -------------------------------------------------------------------------------
       
   586 */
       
   587 TInt CTestExecution::DoNotifyMeasurement()
       
   588     {    
       
   589     // Information for this context => information is in this thread's heap:
       
   590     // From CUndertaker::RunL() or CTestModuleContainer::RunL() method can
       
   591     // handle stop and clean operations if these operations are not done 
       
   592     // before.
       
   593     // Erronous cases(CUndertaker::RunL will be called) or when test case is
       
   594     // executed(CTestModuleContainer::RunL() will be called) there can handle
       
   595     // test measurement stop and clean operation. 
       
   596 
       
   597     if( iTestMeasurement.iMeasurementStruct.iMeasurementOperation == 
       
   598                                         CSTIFTestMeasurement::KMeasurementNew)
       
   599         {
       
   600         // Check that same measurement module don't try to create several times
       
   601         // Only one measurement type per test is allowed
       
   602         for( TInt i = 0; i < iMeasurementHandlingArray.Count(); i++ )
       
   603             {
       
   604             if( iMeasurementHandlingArray[i]->iMeasurementModulePtr->MeasurementType() ==
       
   605                         iTestMeasurement.iMeasurementStruct.iMeasurementType )
       
   606                 {
       
   607                 return KErrAlreadyExists;
       
   608                 }
       
   609             }
       
   610 
       
   611         TMeasurementHandling* measurementHandling = NULL;
       
   612         measurementHandling = new TMeasurementHandling();
       
   613 
       
   614         TBuf<KStifMeasurementTypeLength> modulename;
       
   615         if( iTestMeasurement.iMeasurementStruct.iMeasurementType == 1 )
       
   616             {
       
   617             modulename.Copy( KStifMeasurement01 );
       
   618             }
       
   619         else if( iTestMeasurement.iMeasurementStruct.iMeasurementType == 2 )
       
   620             {
       
   621             modulename.Copy( KStifMeasurement02 );
       
   622             }
       
   623         else if( iTestMeasurement.iMeasurementStruct.iMeasurementType == 3 )
       
   624             {
       
   625             modulename.Copy( KStifMeasurement03 );
       
   626             }
       
   627         else if( iTestMeasurement.iMeasurementStruct.iMeasurementType == 4 )
       
   628             {
       
   629             modulename.Copy( KStifMeasurement04 );
       
   630             }
       
   631         else if( iTestMeasurement.iMeasurementStruct.iMeasurementType == 5 )
       
   632             {
       
   633             modulename.Copy( KStifMeasurement05 );
       
   634             }
       
   635         else if( iTestMeasurement.iMeasurementStruct.iMeasurementType == 6 )
       
   636             {
       
   637             modulename.Copy( KStifMeasurementBappea );
       
   638             }
       
   639         else
       
   640             {
       
   641             __TRACE( KError, (  _L("CTestExecution::DoNotifyMeasurement(): unknown measurement type" ) ) );
       
   642             return KErrArgument;
       
   643             }
       
   644 
       
   645         // Loading should work with and without '.dll' extension.
       
   646         TInt r = measurementHandling->iMeasurementModule.Load( modulename );
       
   647         if ( r != KErrNone )
       
   648             {
       
   649             __TRACE( KError, ( CStifLogger::EError, _L("Can't load test measurement module[%S], code = %d"),
       
   650                 &modulename, r ) );
       
   651             delete measurementHandling;
       
   652             return KErrNotFound;
       
   653             }
       
   654         else
       
   655             {
       
   656             //Print test measururement module name
       
   657             __TRACE( KInit, (  _L("Loaded test measurement module[%S]"),
       
   658                 &modulename ) );
       
   659             }
       
   660 
       
   661         // Get pointer to first exported function
       
   662         // Verify that there is function
       
   663         measurementHandling->iMeasurementLibEntry = (CTestMeasurementFactory) measurementHandling->iMeasurementModule.Lookup( 1 );
       
   664         if ( measurementHandling->iMeasurementLibEntry == NULL )
       
   665             {
       
   666             // New instance can't be created
       
   667             __TRACE( KInit, (_L( "Test measurement module instance cannot create." ) ) );
       
   668             measurementHandling->iMeasurementModule.Close();
       
   669             delete measurementHandling;
       
   670             return KErrNotFound;
       
   671             }
       
   672         else
       
   673             {
       
   674             __TRACE ( KInit, ( _L("Pointer to 1st exported received")));
       
   675             }
       
   676 
       
   677         CSTIFTestMeasurementImplementation* measurement;
       
   678         measurement = NULL;
       
   679 
       
   680         // initialize test measurement module
       
   681         __TRACE ( KVerbose, (_L("Calling 1st exported at 0x%x"), (TUint32) measurementHandling->iMeasurementLibEntry ));
       
   682         TRAPD ( err, measurement = (*measurementHandling->iMeasurementLibEntry)( 
       
   683                             iTestMeasurement.iMeasurementStruct.iConfigurationInfo, iTestMeasurement.iMeasurementStruct.iMeasurementType ) );
       
   684 
       
   685          // Handle leave from test module
       
   686         if ( err != KErrNone )
       
   687             {
       
   688             __TRACE (KError, ( CStifLogger::EError, _L( "Leave when calling 1st exported function, code %d"), err ) );
       
   689             delete measurementHandling;
       
   690             return err;
       
   691             }
       
   692         else if ( measurementHandling->iMeasurementLibEntry == NULL )     // Handle NULL from test measurement
       
   693             {
       
   694             __TRACE (KError, ( CStifLogger::EError, _L( "NULL pointer received when constructing test measurement module" ) ) );
       
   695             delete measurementHandling;
       
   696             // Set error codes
       
   697             return KErrNoMemory;
       
   698             }
       
   699         else
       
   700             {
       
   701             measurementHandling->iMeasurementModulePtr = measurement;
       
   702             __TRACE (KInit, (_L("Entrypoint successfully called, Measurement module instance at 0x%x"),
       
   703                 (TUint32)measurementHandling->iMeasurementLibEntry ) );
       
   704             }
       
   705         iMeasurementHandlingArray.Append( measurementHandling );
       
   706         } // End of NewL operations
       
   707 
       
   708     else if( iTestMeasurement.iMeasurementStruct.iMeasurementOperation == 
       
   709                                         CSTIFTestMeasurement::KMeasurementStart)
       
   710         {
       
   711         for( TInt i = 0; i < iMeasurementHandlingArray.Count(); i++ )
       
   712             {
       
   713             if( iMeasurementHandlingArray[i]->iMeasurementModulePtr->MeasurementType() == iTestMeasurement.iMeasurementStruct.iMeasurementType )
       
   714                 {
       
   715                 return iMeasurementHandlingArray[i]->iMeasurementModulePtr->Start();
       
   716                 }
       
   717             }
       
   718 
       
   719         }
       
   720     else if( iTestMeasurement.iMeasurementStruct.iMeasurementOperation == 
       
   721                                         CSTIFTestMeasurement::KMeasurementStop)
       
   722         {
       
   723         for( TInt i = 0; i < iMeasurementHandlingArray.Count(); i++ )
       
   724             {
       
   725             if( iMeasurementHandlingArray[i]->iMeasurementModulePtr->MeasurementType() == iTestMeasurement.iMeasurementStruct.iMeasurementType )
       
   726                 {
       
   727                 TInt stop_ret = iMeasurementHandlingArray[i]->iMeasurementModulePtr->Stop();
       
   728                 delete iMeasurementHandlingArray[i];
       
   729                 iMeasurementHandlingArray.Remove(i);
       
   730                 return stop_ret;
       
   731                 }
       
   732             }
       
   733         }
       
   734     else 
       
   735         {
       
   736         __TRACE (KError, ( CStifLogger::EError, _L("CTestExecution::DoNotifyMeasurement(): Not supported operation") ) );
       
   737         return KErrNotSupported;
       
   738         }
       
   739     
       
   740     return KErrNone;
       
   741 
       
   742     }
       
   743 
       
   744 /*
       
   745 -------------------------------------------------------------------------------
       
   746 
       
   747     Class: CTestExecution
       
   748 
       
   749     Method: WritePrint
       
   750 
       
   751     Description: Writes print notification to client memory space.                 
       
   752         
       
   753     Parameters: const TInt aPriority          :in:  Priority
       
   754                 const TStifInfoName& aDes         :in:  Description
       
   755                 const TName& aBuffer          :in:  Value
       
   756     
       
   757     Return Values: TInt                             Return value from message write
       
   758 
       
   759     Errors/Exceptions: None
       
   760 
       
   761     Status: Proposal
       
   762     
       
   763 -------------------------------------------------------------------------------
       
   764 */
       
   765 TInt CTestExecution::WritePrint( TTestProgress& aProgress )
       
   766     {
       
   767 
       
   768     TTestProgressPckg progressPckg( aProgress );
       
   769  
       
   770     // Write message to client space    
       
   771     TRAPD( res, iNotifyPrintMessage.WriteL( 0, progressPckg ) );
       
   772 
       
   773     iPrintNotifyAvailable = EFalse;
       
   774 
       
   775     // Complete request with possible error code
       
   776     iNotifyPrintMessage.Complete( res );
       
   777 
       
   778     return res;
       
   779 
       
   780     }
       
   781 
       
   782 /*
       
   783 -------------------------------------------------------------------------------
       
   784 
       
   785     Class: CTestExecution
       
   786 
       
   787     Method: NotifyEvent
       
   788 
       
   789     Description: Handles event request from engine. 
       
   790 
       
   791     ESetEvent and EUnsetEvent change event status. EEnable enables 
       
   792     event notify.
       
   793 
       
   794     Parameters: const RMessage& aMessage      :in:  Message from client.
       
   795                     
       
   796     Return Values: None
       
   797 
       
   798     Errors/Exceptions: None
       
   799 
       
   800     Status: Proposal
       
   801     
       
   802 -------------------------------------------------------------------------------
       
   803 */
       
   804 TInt CTestExecution::NotifyEvent( const RMessage2& aMessage )
       
   805     {   
       
   806 
       
   807     TEventIf event;
       
   808     TEventIfPckg eventPckg( event );
       
   809     
       
   810     TRAPD( res, aMessage.ReadL( 0, eventPckg ) );
       
   811 
       
   812     if( res != KErrNone )
       
   813         {
       
   814         __TRACE( KError, ( _L( "CTestExecution::NotifyEvent: ReadL failed" ) ));
       
   815         return res;
       
   816         }
       
   817     
       
   818     switch( event.Type() )
       
   819         {
       
   820         case TEventIf::ESetEvent: 
       
   821             {
       
   822             TInt ind = 0;
       
   823             TInt count = iEventArray.Count();
       
   824             for( ind=0; ind < count; ind++ )
       
   825                 {
       
   826                 if( iEventArray[ind]->Name() == event.Name() )
       
   827                     {
       
   828                     __TRACE( KMessage, ( _L( "CTestExecution::NotifyEvent(%d): SetEvent %S ( count %i )" ), 
       
   829                         this, &event.Name(), count ) );
       
   830                     TEventIf::TEventType etype = TEventIf::EIndication;
       
   831                     // To get state events working with testcombiner
       
   832                     if( ( event.EventType() == TEventIf::EState ) ||                            
       
   833                         ( iEventArray[ind]->EventType() == TEventIf::EState ) )
       
   834                         {
       
   835                         etype = TEventIf::EState;
       
   836                         }
       
   837                     iEventArray[ind]->Set( etype );
       
   838                     }
       
   839                 }
       
   840             }
       
   841             break;
       
   842         case TEventIf::EUnsetEvent:
       
   843             { 
       
   844             return UnsetEvent( event, aMessage );
       
   845             }
       
   846         case TEventIf::EEnable:
       
   847             {
       
   848             // Store event message
       
   849             iNotifyEventMessage = aMessage;
       
   850             iEventNotifyAvailable = ETrue;
       
   851             TInt errorFromPreviousCmd =  aMessage.Int1();
       
   852 
       
   853             __TRACE( KMessage, ( _L( "CTestExecution::NotifyEvent: enable (%d) notify %d" ), 
       
   854                 errorFromPreviousCmd, this ) );
       
   855 
       
   856             // Complete previous Event command
       
   857             CompleteEvent( errorFromPreviousCmd );    
       
   858             iEventHandler->StartL();
       
   859             
       
   860             // iNotifyEventMessage is completed from DoNotifyEvent
       
   861             return KErrNone; 
       
   862             }
       
   863         
       
   864         default:
       
   865             __TRACE( KError, ( _L( "CTestExecution::NotifyEvent: Unknown command %i" ), 
       
   866                 event.Type() ));
       
   867             return KErrArgument;
       
   868         }
       
   869 
       
   870     __TRACE( KMessage, ( _L( "CTestExecution::NotifyEvent(%d): Done" ), this ) );
       
   871 
       
   872     aMessage.Complete( KErrNone );
       
   873     //User::After(1000); //Stif-95 This pause is needed to let Info::TestFrameworkEngine thread
       
   874                        //get some processor time and run exactly at this moment (by calling
       
   875                        //CTestEventController::EventCallBack). When Stif is focused on the screen,
       
   876                        //there is no problem if this line is absent, however when another
       
   877                        //application (like screen saver) is focused this is required.
       
   878     return KErrNone;
       
   879 
       
   880     }
       
   881 
       
   882 /*
       
   883 -------------------------------------------------------------------------------
       
   884 
       
   885     Class: CTestExecution
       
   886 
       
   887     Method: DoNotifyEvent
       
   888 
       
   889     Description: Forward event request.
       
   890         
       
   891     Parameters: None
       
   892    
       
   893     Return Values: None
       
   894 
       
   895     Errors/Exceptions: Panics if event array can't be created
       
   896 
       
   897     Status: Proposal
       
   898     
       
   899 -------------------------------------------------------------------------------
       
   900 */
       
   901 TInt CTestExecution::DoNotifyEvent()
       
   902     {
       
   903     // Handle asynchronous wait by using asynchronous active object available from stf event system.
       
   904     RDebug::Print(_L("STF [ES]: CTestExecution::DoNotifyEvent()"));
       
   905 
       
   906     // First check current situation.
       
   907     if(iAsyncEventActive)
       
   908         {
       
   909         RDebug::Print(_L("STF [ES]: CTestExecution::DoNotifyEvent() iAsyncEventActive is already created"));
       
   910         if(iAsyncEventActive->IsPending())
       
   911             {
       
   912             RDebug::Print(_L("STF [ES]: CTestExecution::DoNotifyEvent() iAsyncEventActive is pending, returning KErrInUse"));
       
   913             return KErrInUse;
       
   914             }
       
   915         else
       
   916             {
       
   917             RDebug::Print(_L("STF [ES]: CTestExecution::DoNotifyEvent() iAsyncEventActive is not pending, deleting"));
       
   918             // Event is not in pending state, so it can be deleted because it must be completed
       
   919             delete iAsyncEventActive;
       
   920             iAsyncEventActive = NULL;
       
   921             }
       
   922         }
       
   923     
       
   924     // Check if we deal with asynchronous wait
       
   925     if(!(iEventDef.iEvent.Type() == TEventIf::EWaitEvent && iEventDef.iStatus))
       
   926         {
       
   927         RDebug::Print(_L("STF [ES]: CTestExecution::DoNotifyEvent() only state waits will be handled here, returning KErrArgument"));
       
   928         return KErrArgument;
       
   929         }
       
   930     
       
   931     TInt ret = KErrNone;
       
   932     
       
   933     // Create asynchronous object and start query to event server
       
   934     RDebug::Print(_L("STF [ES]: CTestExecution::DoNotifyEvent() creating iAsyncEventActive"));
       
   935     TRAP(ret, iAsyncEventActive = CAsyncEventActive::NewL(reinterpret_cast<TInt>(this)));
       
   936     if(ret == KErrNone)
       
   937         {
       
   938         RDebug::Print(_L("STF [ES]: CTestExecution::DoNotifyEvent() starting iAsyncEventActive with event name [%S]"), &iEventDef.iEvent.Name());
       
   939         TRAP(ret, iAsyncEventActive->StartL(iEventDef.iStatus, iTestThreadId, iEventDef.iEvent.Name(), NULL);
       
   940                   iEventDef.iStatus = NULL; // iStatus transferred to AO
       
   941             );
       
   942         }
       
   943 
       
   944     if(ret == KErrNone)
       
   945         {
       
   946         RDebug::Print(_L("STF [ES]: CTestExecution::DoNotifyEvent() restarting iEventHandler"));
       
   947         TRAP(ret, iEventHandler->StartL());
       
   948         }
       
   949         
       
   950     RDebug::Print(_L("STF [ES]: CTestExecution::DoNotifyEvent() finished with [%d]"), ret);
       
   951     return ret;
       
   952         
       
   953     /*
       
   954     TInt ret = KErrNone;
       
   955         
       
   956     switch( iEventDef.iEvent.Type() )
       
   957         {
       
   958         case TEventIf::EReqEvent:
       
   959             {
       
   960             __TRACE( KMessage, 
       
   961                 ( _L( "CTestExecution::DoNotifyEvent(%d): ReqEvent %S" ), 
       
   962                     this, &iEventDef.iEvent.Name() ) );
       
   963             ret = RequestEvent( iEventDef.iEvent );
       
   964             // If error, return error, 
       
   965             // otherwise proceed with sending information to engine
       
   966             if( ret != KErrNone )
       
   967                 {
       
   968                 iEventHandler->StartL();
       
   969                 return ret;
       
   970                 }
       
   971             }
       
   972             break;
       
   973         case TEventIf::EWaitEvent:
       
   974         case TEventIf::ESetWaitPending:
       
   975             {
       
   976             __TRACE( KMessage, 
       
   977                 ( _L( "CTestExecution::DoNotifyEvent(%d): WaitEvent %S" ), 
       
   978                     this, &iEventDef.iEvent.Name() ) );
       
   979             // We return from here, i.e. nothing is sent to engine
       
   980             ret = WaitEvent( iEventDef.iEvent, iEventDef.iStatus );
       
   981             iEventHandler->StartL();
       
   982             return ret;
       
   983             }
       
   984         // Add state events to internal array  
       
   985         case TEventIf::ESetEvent: 
       
   986         case TEventIf::EUnsetEvent:
       
   987             {
       
   988             __TRACE( KMessage, 
       
   989                 ( _L( "CTestExecution::DoNotifyEvent(%d): Set/UnsetEvent %S" ), 
       
   990                     this, &iEventDef.iEvent.Name() ) );
       
   991             EventStateChange( iEventDef.iEvent );
       
   992             }
       
   993             break;
       
   994         case TEventIf::ERelEvent:
       
   995             // This is handled later
       
   996             __TRACE( KMessage, 
       
   997                 ( _L( "CTestExecution::DoNotifyEvent(%d): RelEvent %S" ), 
       
   998                     this, &iEventDef.iEvent.Name() ) );
       
   999             break;
       
  1000         default:
       
  1001             iEventHandler->StartL();
       
  1002             return KErrArgument;
       
  1003         }
       
  1004     
       
  1005     // Construct message
       
  1006     TEventIfPckg eventPckg( iEventDef.iEvent );
       
  1007 
       
  1008     // Write message to client space
       
  1009     TRAPD( res, iNotifyEventMessage.WriteL( 0, eventPckg ) );
       
  1010 
       
  1011     if( res != KErrNone )
       
  1012         {
       
  1013         __TRACE( KError, ( _L( "CTestExecution::DoNotifyEvent: WriteL failed" ) ) );
       
  1014         ret = res;
       
  1015         }
       
  1016     // Complete request
       
  1017     // Complete with WriteL result
       
  1018     // MUST be done before ERelEvent
       
  1019     iEventNotifyAvailable = EFalse;
       
  1020     iNotifyEventMessage.Complete( res );
       
  1021     User::After(1000); //Stif-95 This pause is needed to let Info::TestFrameworkEngine thread
       
  1022                        //get some processor time and run exactly at this moment (by calling
       
  1023                        //CTestEventNotifier::RunL). When Stif is focused on the screen,
       
  1024                        //there is no problem if this line is absent, however when another
       
  1025                        //application (like screen saver) is focused this is required.
       
  1026 
       
  1027     if( iEventDef.iEvent.Type() == TEventIf::ERelEvent )
       
  1028         {
       
  1029         ret = ReleaseEvent( iEventDef.iEvent );
       
  1030         if( ret != KErrNone )
       
  1031             {
       
  1032             // If error, return immediately
       
  1033             return ret;
       
  1034             }
       
  1035         }
       
  1036 
       
  1037     __TRACE( KMessage, ( _L( "CTestExecution::DoNotifyEvent(%d): Done" ), this ) );
       
  1038 
       
  1039     return ret;
       
  1040     */
       
  1041     }
       
  1042 
       
  1043 /*
       
  1044 -------------------------------------------------------------------------------
       
  1045 
       
  1046     Class: CTestExecution
       
  1047 
       
  1048     Method: RequestEvent
       
  1049 
       
  1050     Description: Handles TestModule event requests. 
       
  1051         
       
  1052     Parameters: const TEventIf& aEvent: in: Event requested  
       
  1053     
       
  1054     Return Values: TInt: Success/Error code
       
  1055 
       
  1056     Errors/Exceptions: None
       
  1057 
       
  1058     Status: Proposal
       
  1059     
       
  1060 -------------------------------------------------------------------------------
       
  1061 */    
       
  1062 TInt CTestExecution::RequestEvent( TEventIf& aEvent )
       
  1063     {
       
  1064 
       
  1065     // Requested events are added to iEventArray
       
  1066     // There can be multiple simultaneous requests for the same event                    
       
  1067     TEvent* event = new TEvent( iTestThreadId );    
       
  1068     if( !event )
       
  1069         {
       
  1070         return KErrNoMemory;
       
  1071         }
       
  1072     event->Copy( aEvent );
       
  1073     if( iEventArray.Append( event ) != KErrNone )
       
  1074         {
       
  1075         delete event;
       
  1076         return KErrNoMemory;
       
  1077         }
       
  1078         
       
  1079     __TRACE( KMessage,( _L( "CTestExecution::DoNotifyEvent: Req added %S ( count %i )" ), 
       
  1080          &aEvent.Name(), iEventArray.Count() ));
       
  1081     
       
  1082     return KErrNone;
       
  1083     }
       
  1084 
       
  1085 /*
       
  1086 -------------------------------------------------------------------------------
       
  1087 
       
  1088     Class: CTestExecution
       
  1089 
       
  1090     Method: WaitEvent
       
  1091 
       
  1092     Description: Handles TestModule event waits. Waiting is implemented here 
       
  1093                 and completed in NotifyEvent    
       
  1094 
       
  1095         
       
  1096     Parameters: const TEventIf& aEvent: in: Event wait  
       
  1097     
       
  1098     Return Values: TInt: Success/Error code
       
  1099 
       
  1100     Errors/Exceptions: None
       
  1101 
       
  1102     Status: Proposal
       
  1103     
       
  1104 -------------------------------------------------------------------------------
       
  1105 */    
       
  1106 TInt CTestExecution::WaitEvent( TEventIf& aEvent, TRequestStatus* aStatus )
       
  1107     {
       
  1108       
       
  1109     // Get first "free" event entry from requested events
       
  1110     TInt ind = 0;
       
  1111     TInt count = iEventArray.Count();
       
  1112     TEvent* event = NULL;
       
  1113     for( ind=0; ind < count; ind++ )
       
  1114         {
       
  1115         if( ( iEventArray[ind]->Name() == aEvent.Name() ) &&
       
  1116             ( iEventArray[ind]->WaitEventPending() == EFalse ) )
       
  1117             {
       
  1118             // Found event with correct name and one that is still free
       
  1119             // i.e. nobody is waiting for it.
       
  1120             event = iEventArray[ind];
       
  1121             if( aEvent.Type() == TEventIf::EWaitEvent )
       
  1122                 {
       
  1123                 // For EWaitEvent we complete immediately if event is pending
       
  1124                 if( event->EventPending() )
       
  1125                     {
       
  1126                     // Event was already pending, so we may return immediately
       
  1127                     if( aStatus )
       
  1128                         {
       
  1129                         TestThreadRequestComplete( aStatus, KErrNone );
       
  1130                         }
       
  1131                     return KErrNone;           
       
  1132                     }
       
  1133                 }
       
  1134             }
       
  1135         }
       
  1136     if( event == NULL )
       
  1137         {
       
  1138         // Event is not in the iEventArray, 
       
  1139         // so event is not currently requested
       
  1140         return KErrNotFound;
       
  1141         }
       
  1142         
       
  1143     __TRACE( KMessage,( _L( "CTestExecution::DoNotifyEvent: Waiting %S ( count %i )" ), 
       
  1144         &aEvent.Name(), count ));
       
  1145     
       
  1146     // Event is not pending so we have to wait for it
       
  1147     // Set wait pending            
       
  1148     TInt ret = event->SetWaitPending( aStatus );
       
  1149     // event cannot be freed by the test module, 
       
  1150     // because it is waiting the event, 
       
  1151 
       
  1152     if( ( aStatus == NULL ) &&
       
  1153         ( ret == KErrNone ) &&
       
  1154         ( aEvent.Type() == TEventIf::EWaitEvent ) ) 
       
  1155         {
       
  1156         // This is synchronous wait
       
  1157         // Go waiting, completed from set event            
       
  1158         event->Wait();
       
  1159         }
       
  1160 
       
  1161     return ret;
       
  1162     
       
  1163     } 
       
  1164     
       
  1165 /*
       
  1166 -------------------------------------------------------------------------------
       
  1167 
       
  1168     Class: CTestExecution
       
  1169 
       
  1170     Method: ReleaseEvent
       
  1171 
       
  1172     Description: Handles TestModule event releases. 
       
  1173         
       
  1174     Parameters: const TEventIf& aEvent: in: Event released  
       
  1175     
       
  1176     Return Values: TInt: Success/Error code
       
  1177 
       
  1178     Errors/Exceptions: None
       
  1179 
       
  1180     Status: Proposal
       
  1181     
       
  1182 -------------------------------------------------------------------------------
       
  1183 */   
       
  1184 TInt CTestExecution::ReleaseEvent( TEventIf& aEvent )
       
  1185     {
       
  1186     
       
  1187     // Get last event entry from requested events
       
  1188     TInt ind = 0;
       
  1189     TInt freeFound = 0;
       
  1190     TInt eventIndex = 0;
       
  1191     TInt count = iEventArray.Count();
       
  1192     for( ind=0; ind < count; ind++ )
       
  1193         {
       
  1194         if( iEventArray[ind]->Name() == aEvent.Name() )
       
  1195             {
       
  1196             if( iEventArray[ind]->WaitEventPending() == EFalse )
       
  1197                 {
       
  1198                 freeFound++;
       
  1199                 eventIndex = ind;
       
  1200                 }
       
  1201             }
       
  1202         }
       
  1203 
       
  1204     if( freeFound == 0 )
       
  1205         {
       
  1206         return KErrNotFound;
       
  1207         }
       
  1208     __TRACE( KMessage,( 
       
  1209         _L( "CTestExecution::DoNotifyEvent: Release event %S ( count %i )" ), 
       
  1210             &aEvent.Name(), iEventArray.Count() ));
       
  1211 
       
  1212     TEvent* event = iEventArray[eventIndex];
       
  1213     iEventArray.Remove( eventIndex );
       
  1214     // Release and free event entry
       
  1215     event->Release(); 
       
  1216 
       
  1217     // Delete used event entry
       
  1218     delete event;
       
  1219     
       
  1220     return KErrNone;
       
  1221 }
       
  1222 
       
  1223 /*
       
  1224 -------------------------------------------------------------------------------
       
  1225 
       
  1226     Class: CTestExecution
       
  1227 
       
  1228     Method: UnsetEvent
       
  1229 
       
  1230     Description: Handles TestModule event unsets. 
       
  1231         
       
  1232     Parameters: const TEventIf& aEvent: in: Event unset  
       
  1233     
       
  1234     Return Values: TInt: Success/Error code
       
  1235 
       
  1236     Errors/Exceptions: None
       
  1237 
       
  1238     Status: Proposal
       
  1239     
       
  1240 -------------------------------------------------------------------------------
       
  1241 */
       
  1242 TInt CTestExecution::UnsetEvent( TEventIf& aEvent, const RMessage2& aMessage )
       
  1243     {
       
  1244     
       
  1245     TInt ret = KErrNone;
       
  1246     TInt ind = 0;
       
  1247     TInt count = iEventArray.Count();
       
  1248     TBool activeEventReq = EFalse;
       
  1249     for( ind=0; ind < count; ind++ )
       
  1250         {
       
  1251         if( iEventArray[ind]->Name() == aEvent.Name() )
       
  1252             {
       
  1253              __TRACE( KMessage, ( 
       
  1254                 _L( "CTestExecution::NotifyEvent(%d): UnsetEvent %S ( count %i )" ), 
       
  1255                 this, &aEvent.Name(), count ) );
       
  1256                 
       
  1257             ret = iEventArray[ind]->Unset( aMessage, this );
       
  1258             if( ret == KErrNone )
       
  1259                 {
       
  1260                 activeEventReq = ETrue;
       
  1261                 }
       
  1262             break;
       
  1263             }
       
  1264         }
       
  1265     if( activeEventReq )
       
  1266         {
       
  1267         // Unset is completed by release   
       
  1268         return KErrNone;
       
  1269         }
       
  1270         
       
  1271     // No pending requests or error from unset
       
  1272     aMessage.Complete( ret );
       
  1273     
       
  1274     return KErrNone;
       
  1275     
       
  1276     }
       
  1277     
       
  1278 /*
       
  1279 -------------------------------------------------------------------------------
       
  1280 
       
  1281     Class: CTestExecution
       
  1282 
       
  1283     Method: EventStateChange
       
  1284 
       
  1285     Description: Handles event setting and unsetting. Saves status of
       
  1286                 state events to enable unsetting of set state events when 
       
  1287                 killing the testcase abnormally.
       
  1288         
       
  1289     Parameters: const TEventIf& aEvent: in: Event set/unset  
       
  1290     
       
  1291     Return Values: TInt: Success/Error code
       
  1292 
       
  1293     Errors/Exceptions: None
       
  1294 
       
  1295     Status: Proposal
       
  1296     
       
  1297 -------------------------------------------------------------------------------
       
  1298 */   
       
  1299 TInt CTestExecution::EventStateChange( TEventIf& aEvent )
       
  1300     {
       
  1301     
       
  1302     TInt ret = KErrNotFound;
       
  1303     if( aEvent.EventType() == TEventIf::EState )
       
  1304         {
       
  1305         
       
  1306         TInt count = iStateEvents.Count();
       
  1307         TInt index = 0;
       
  1308         for(; index < count; index++ )   
       
  1309             {
       
  1310             TPtrC name = *(iStateEvents[index]);
       
  1311             if( name == aEvent.Name() )
       
  1312                 {
       
  1313                 break;
       
  1314                 }
       
  1315             } 
       
  1316             
       
  1317                 
       
  1318         if( aEvent.Type() == TEventIf::ESetEvent )
       
  1319             {
       
  1320             if( index < count )
       
  1321                 {
       
  1322                 ret = KErrAlreadyExists;
       
  1323                 }
       
  1324             else
       
  1325                 {
       
  1326                 // add event to iStateEvents
       
  1327                 HBufC* name = aEvent.Name().Alloc();
       
  1328                 if( name == NULL )
       
  1329                     {
       
  1330                     ret = KErrNoMemory;
       
  1331                     }
       
  1332                 else if( iStateEvents.Append( name ) != KErrNone )
       
  1333                     {
       
  1334                     delete name;
       
  1335                     ret = KErrNoMemory;
       
  1336                     }
       
  1337                 else
       
  1338                     {
       
  1339                     ret = KErrNone;
       
  1340                     }
       
  1341                 }                
       
  1342             }
       
  1343         else if( aEvent.Type() == TEventIf::EUnsetEvent )
       
  1344             {
       
  1345             if( index == count )
       
  1346                 {
       
  1347                 ret = KErrNotFound;
       
  1348                 }
       
  1349             else
       
  1350                 {
       
  1351                 ret = KErrNone;
       
  1352                 delete iStateEvents[index];
       
  1353                 iStateEvents.Remove( index );
       
  1354                 }
       
  1355             }
       
  1356         }
       
  1357     
       
  1358     return ret;
       
  1359     
       
  1360     }
       
  1361 /*
       
  1362 -------------------------------------------------------------------------------
       
  1363 
       
  1364     Class: CTestExecution
       
  1365 
       
  1366     Method: CancelEvent
       
  1367 
       
  1368     Description: Cancels pending event request.
       
  1369         
       
  1370     Parameters: None
       
  1371     
       
  1372     Return Values: None
       
  1373 
       
  1374     Errors/Exceptions: None
       
  1375     
       
  1376     Status: Proposal
       
  1377     
       
  1378 -------------------------------------------------------------------------------
       
  1379 */
       
  1380 void CTestExecution::CancelEvent()
       
  1381     {
       
  1382     RDebug::Print(_L("STF [ES]: CTestExecution::CancelEvent()"));
       
  1383     
       
  1384     // Delete AO. This will cancel event if necessary.
       
  1385     if(iAsyncEventActive)
       
  1386         {
       
  1387         RDebug::Print(_L("STF [ES]: CTestExecution::CancelEvent() iAsyncEventActive exists, deleting"));
       
  1388         delete iAsyncEventActive;
       
  1389         iAsyncEventActive = NULL;
       
  1390         }
       
  1391 
       
  1392     iEventHandler->StartL();
       
  1393     
       
  1394     /*    
       
  1395     TInt ret = KErrNotFound;
       
  1396 
       
  1397     __TRACE( KMessage, ( _L( "CTestThreadContainer::CancelEvent(%d): %S [%p]" ), 
       
  1398             iEventDef.iEvent.Type(), &iEventDef.iEvent.Name(), iEventDef.iStatus ) );
       
  1399 
       
  1400     switch( iEventDef.iEvent.Type() )
       
  1401         {
       
  1402         case TEventIf::EReqEvent:
       
  1403         case TEventIf::ERelEvent:
       
  1404         case TEventIf::ESetEvent:
       
  1405         case TEventIf::EUnsetEvent:   
       
  1406             CompleteEvent( KErrCancel );  
       
  1407             break;
       
  1408         case TEventIf::EWaitEvent:
       
  1409         case TEventIf::ESetWaitPending:
       
  1410             {
       
  1411             // Get waited event entry from requested events
       
  1412             TInt ind = 0;
       
  1413             TInt count = iEventArray.Count();
       
  1414             for( ind=0; ind < count; ind++ )
       
  1415                 {
       
  1416                 if( ( iEventArray[ind]->Name() == iEventDef.iEvent.Name() ) &&
       
  1417                     ( iEventArray[ind]->WaitEventPending() != EFalse ) &&
       
  1418                     ( iEventArray[ind]->RequestStatus() == iEventDef.iStatus ) )
       
  1419                     {
       
  1420                     TEvent* event = iEventArray[ind];
       
  1421                     // Found event with correct name and one that is waited.
       
  1422                     event->CompletePendingWait( KErrCancel ); 
       
  1423                     ret = KErrNone;
       
  1424                     break;
       
  1425                     }
       
  1426                 }
       
  1427             if( ret != KErrNone )
       
  1428                 {
       
  1429                 // Request has been already completed, not handled 
       
  1430                 // by ActiveScheduler yet.
       
  1431                 // DoCancel will do the job, don't worry.
       
  1432                 __TRACE( KError, ( _L( "CTestThreadContainer::CancelEvent(%d): %S, not found 2" ), 
       
  1433                     iEventDef.iEvent.Type(), &iEventDef.iEvent.Name() ) ); 
       
  1434                 }
       
  1435             }
       
  1436             break;
       
  1437         default:
       
  1438             CTestServer::PanicServer( EUnknownEventCmd );
       
  1439             break;
       
  1440         }
       
  1441         
       
  1442     // Synchonize
       
  1443     iEventHandler->StartL();
       
  1444     */
       
  1445     }
       
  1446 
       
  1447 /*
       
  1448 -------------------------------------------------------------------------------
       
  1449 
       
  1450     Class: CTestExecution
       
  1451 
       
  1452     Method: NotifyRemoteCmd
       
  1453 
       
  1454     Description: Handles the first phase of the RemoteCmd request from engine.
       
  1455 
       
  1456     Parameters: const RMessage& aMessage: in: Message from client.
       
  1457                     
       
  1458     Return Values: Symbian OS error code.
       
  1459 
       
  1460     Errors/Exceptions: None
       
  1461 
       
  1462     Status: Proposal
       
  1463     
       
  1464 -------------------------------------------------------------------------------
       
  1465 */
       
  1466 TInt CTestExecution::NotifyRemoteCmd( const RMessage2& aMessage )
       
  1467     {   
       
  1468 
       
  1469     // Store RemoteCmd message
       
  1470     // and the length buffer address
       
  1471     iNotifyRemoteCmdMessage = aMessage;
       
  1472     iRemoteSendAvailable = ETrue;
       
  1473     iSndHandler->StartL();
       
  1474 
       
  1475     return KErrNone;
       
  1476 
       
  1477     }
       
  1478 
       
  1479 /*
       
  1480 -------------------------------------------------------------------------------
       
  1481 
       
  1482     Class: CTestExecution
       
  1483 
       
  1484     Method: DoRemoteReceive
       
  1485 
       
  1486     Description: Enable remote receive.
       
  1487     
       
  1488     Parameters: None 
       
  1489     
       
  1490     Return Values: None
       
  1491 
       
  1492     Errors/Exceptions: None
       
  1493 
       
  1494     Status: Proposal
       
  1495     
       
  1496 -------------------------------------------------------------------------------
       
  1497 */
       
  1498 void CTestExecution::DoRemoteReceive()
       
  1499     {    
       
  1500 
       
  1501     switch( iRcvCmdDef.iCommand )
       
  1502         {
       
  1503         case EStifCmdReceive:          // "Receive"
       
  1504             {
       
  1505             // @js If there's pointer in array, we'll send it down
       
  1506             if(iMessageQueue.Count() > 0)
       
  1507                 {
       
  1508                 HBufC8 * buf =  iMessageQueue[0];
       
  1509                 iRcvCmdDef.iParam.aRemoteMsgRef->Copy( iMessageQueue[0]->Des() );
       
  1510                 iMessageQueue.Remove(0);
       
  1511                 delete buf; 
       
  1512                 __TRACE( KMessage, 
       
  1513                         (_L("CTestExecution::ReadRemoteCmdInfo: complete receive 0x%x"), 
       
  1514                             iRcvCmdDef.iStatus ));
       
  1515                        
       
  1516                  // calls the TestCombiner's CRemoteReceiver::RunL()
       
  1517                  TestThreadRequestComplete( iRcvCmdDef.iStatus, KErrNone );
       
  1518                 }
       
  1519             else
       
  1520                 {
       
  1521                 iRemoteReceiveAvailable = ETrue;            
       
  1522                 }
       
  1523 
       
  1524             break;
       
  1525             }
       
  1526         case EStifCmdReceiveCancel:
       
  1527             if( iRemoteReceiveAvailable )
       
  1528                 {
       
  1529                 iRemoteReceiveAvailable = EFalse;
       
  1530                 TestThreadRequestComplete( iRcvCmdDef.iStatus, KErrCancel );
       
  1531                 }                
       
  1532             break;
       
  1533         default:
       
  1534             CTestServer::PanicServer( EUnknownRemoteCmd );
       
  1535             break;
       
  1536         }
       
  1537     // Signal test thread
       
  1538     iRcvHandler->StartL();
       
  1539 
       
  1540     }
       
  1541 
       
  1542 /*
       
  1543 -------------------------------------------------------------------------------
       
  1544 
       
  1545     Class: CTestExecution
       
  1546 
       
  1547     Method: DoRemoteSend
       
  1548 
       
  1549     Description: Send remote messages.
       
  1550     
       
  1551     Parameters: None 
       
  1552     
       
  1553     Return Values: None
       
  1554 
       
  1555     Errors/Exceptions: None
       
  1556 
       
  1557     Status: Approved
       
  1558     
       
  1559 -------------------------------------------------------------------------------
       
  1560 */
       
  1561 void CTestExecution::DoRemoteSend()
       
  1562     {  
       
  1563     switch( iCmdDef.iCommand )
       
  1564         {  
       
  1565         case EStifCmdSend:             // "Send"
       
  1566         case EStifCmdReboot:           // "Send"
       
  1567         case EStifCmdStoreState:       // "Send"
       
  1568         case EStifCmdGetStoredState:   // "Receive, this must be done with two phase"
       
  1569         case EStifCmdMeasurement:      // "Receive, this must be done with two phase"
       
  1570             {
       
  1571             if( iRemoteSendAvailable )
       
  1572                 {
       
  1573                 TInt ret = KErrNone;
       
  1574                 TPckg<TStifCommand> remoteCommandPckg( iCmdDef.iCommand );
       
  1575 
       
  1576                 // Start first phase of the writing message to client space
       
  1577                 TRAP( ret, 
       
  1578                     iNotifyRemoteCmdMessage.WriteL( 0, remoteCommandPckg ) );
       
  1579 
       
  1580                 if( ret != KErrNone )
       
  1581                     {
       
  1582                     __TRACE( KError, ( _L( "CTestExecution::DoRemoteSend: WriteL failed" ) ) );
       
  1583                     }
       
  1584                 TPckg<TInt> lenPckg( iCmdDef.iLen );
       
  1585 
       
  1586                 TRAP( ret, 
       
  1587                     iNotifyRemoteCmdMessage.WriteL( 1, lenPckg ) );
       
  1588 
       
  1589                 if( ret != KErrNone )
       
  1590                     {
       
  1591                     __TRACE( KError, ( _L( "CTestExecution::DoRemoteSend: WriteL failed" ) ) );
       
  1592                     }
       
  1593 
       
  1594                 // Complete request
       
  1595                 // Complete with WriteL result
       
  1596                 // CTestRemoteCmdNotifier::RunL() will called
       
  1597                 iRemoteSendAvailable = EFalse;
       
  1598                 iNotifyRemoteCmdMessage.Complete( ret );
       
  1599                 break;
       
  1600                 }
       
  1601             }
       
  1602             TestThreadRequestComplete( iCmdDef.iStatus, KErrNotSupported );
       
  1603             break;
       
  1604         default:
       
  1605             CTestServer::PanicServer( EUnknownRemoteCmd );
       
  1606             break;
       
  1607         }
       
  1608 
       
  1609     }
       
  1610 
       
  1611 
       
  1612 /*
       
  1613 -------------------------------------------------------------------------------
       
  1614 
       
  1615     Class: CTestExecution
       
  1616 
       
  1617     Method: ReadRemoteCmdInfo
       
  1618 
       
  1619     Description: Handles the second phase of the RemoteCmd request from engine.
       
  1620 
       
  1621     Parameters: const RMessage& aMessage: in: Message from client.
       
  1622                     
       
  1623     Return Values: Symbian OS error code.
       
  1624 
       
  1625     Errors/Exceptions: None
       
  1626 
       
  1627     Status: Proposal
       
  1628     
       
  1629 -------------------------------------------------------------------------------
       
  1630 */
       
  1631 TInt CTestExecution::ReadRemoteCmdInfo( const RMessage2& aMessage )
       
  1632     {   
       
  1633     
       
  1634     TInt ret( KErrNone );
       
  1635     TInt completeSend = EFalse;
       
  1636     TInt returnedErrorCode = KErrNone;
       
  1637     TInt len = 0;
       
  1638     TInt value( aMessage.Int2() );
       
  1639     if( value < 0 )
       
  1640         {
       
  1641         returnedErrorCode = value;
       
  1642         }
       
  1643     else
       
  1644         {
       
  1645         len = value;
       
  1646         }
       
  1647   
       
  1648     switch( aMessage.Int1() )
       
  1649         {
       
  1650         case EStifCmdReceive:              // "Receive"
       
  1651             {
       
  1652 
       
  1653                 if( len <= 0 )
       
  1654                     {
       
  1655                     __TRACE( KError, 
       
  1656                         (_L("CTestExecution::ReadRemoteCmdInfo: empty message")));
       
  1657                     ret = KErrGeneral;
       
  1658                     break;
       
  1659                     }
       
  1660                 if( iRcvCmdDef.iParam.aRemoteMsgRef->MaxLength() < len )
       
  1661                     {
       
  1662                     __TRACE( KError, 
       
  1663                         (_L("CTestExecution::ReadRemoteCmdInfo: message overflow")));
       
  1664                     ret = KErrGeneral;
       
  1665                     break;
       
  1666                     }
       
  1667 
       
  1668                 HBufC8* buf = HBufC8::New( len );
       
  1669                 if( buf == NULL )
       
  1670                     { 
       
  1671                     ret = KErrNoMemory;
       
  1672                     break;
       
  1673                     }
       
  1674                 TPtr8 tmp = buf->Des();
       
  1675                 // Read message from client space
       
  1676                 TRAP( ret, aMessage.ReadL( 0, tmp ) );
       
  1677 
       
  1678                 
       
  1679                 if( ret != KErrNone )
       
  1680                     {
       
  1681                     __TRACE( KError, 
       
  1682                         (_L("CTestExecution::ReadRemoteCmdInfo: ReadL failed")));
       
  1683                     break;
       
  1684                     }
       
  1685                     
       
  1686                 if( iRemoteReceiveAvailable )
       
  1687                 // @js Checking moved here
       
  1688                     {                                   
       
  1689                     iRcvCmdDef.iParam.aRemoteMsgRef->Copy( buf->Des() );
       
  1690                     delete buf;
       
  1691                 
       
  1692                     __TRACE( KMessage, 
       
  1693                         (_L("CTestExecution::ReadRemoteCmdInfo: complete receive 0x%x"), 
       
  1694                             iRcvCmdDef.iStatus ));
       
  1695                     // calls the TestCombiner's CRemoteReceiver::RunL()
       
  1696                     TestThreadRequestComplete( iRcvCmdDef.iStatus, ret );
       
  1697                     
       
  1698                     iRemoteReceiveAvailable = EFalse;
       
  1699                     }
       
  1700                 else
       
  1701                 // @js Adding buf to RPointerArray, handling it in DoRemoteReceive function
       
  1702                     {
       
  1703                    iMessageQueue.Append( buf );
       
  1704                     } 
       
  1705                 
       
  1706             break;
       
  1707             }
       
  1708         case EStifCmdSend:                 // "Send"
       
  1709             {
       
  1710             HBufC8* buf = HBufC8::New( iCmdDef.iParam.aRemoteMsgConstRef->Length() );
       
  1711             if( buf == NULL )
       
  1712                 { 
       
  1713                 ret = KErrNoMemory;
       
  1714                 break;
       
  1715                 }
       
  1716             TPtr8 tmp = buf->Des();
       
  1717             tmp.Copy( *iCmdDef.iParam.aRemoteMsgConstRef );
       
  1718             // Second phase of the writing. Write information to the Engine.
       
  1719             TRAP( ret, aMessage.WriteL( 0, tmp ) );
       
  1720 
       
  1721             delete buf;
       
  1722             
       
  1723             if( ret != KErrNone )
       
  1724                 {
       
  1725                 __TRACE( KError, ( _L( "CTestExecution::ReadRemoteCmdInfo: WriteL failed" ) ) );
       
  1726                 }
       
  1727             completeSend = ETrue;
       
  1728             break;
       
  1729             }
       
  1730         case EStifCmdReboot:               // "Send"
       
  1731             {
       
  1732             TRebootParamsPckg remoteTypePckg( *iCmdDef.iParam.aRebootType );
       
  1733 
       
  1734             // Second phase of the writing. Write information to the Engine.
       
  1735             TRAP( ret, aMessage.WriteL( 0, remoteTypePckg ) );
       
  1736 
       
  1737             if( ret != KErrNone )
       
  1738                 {
       
  1739                 __TRACE( KError, ( _L( "CTestExecution::ReadRemoteCmdInfo: WriteL failed" ) ) );
       
  1740                 }
       
  1741             // Because Reboot must block...Don't complete, so now we wait for
       
  1742             // ever phone booting operation !!!!!
       
  1743             break;
       
  1744             }
       
  1745         case EStifCmdStoreState:          // "Send"
       
  1746             {
       
  1747             TRebootStateParamsPckg remoteStatePckg( *iCmdDef.iParam.aRebootState );
       
  1748 
       
  1749             // Second phase of the writing. Write information to the Engine.
       
  1750             TRAP( ret, aMessage.WriteL( 0, remoteStatePckg ) );
       
  1751 
       
  1752             if( ret != KErrNone )
       
  1753                 {
       
  1754                 __TRACE( KError, ( _L( "CTestExecution::ReadRemoteCmdInfo: WriteL failed" ) ) );
       
  1755                 }
       
  1756             // Completed from EStifCmdRebootProceed
       
  1757             break;
       
  1758             }
       
  1759         case EStifCmdMeasurement:   // "Receive"
       
  1760             {
       
  1761             TGetMeasurementOptions getMeasurementOptions;
       
  1762             TGetMeasurementOptionsPckg measurementParamsPckg( getMeasurementOptions );
       
  1763 
       
  1764             // Read message from client space
       
  1765             TRAP( ret, aMessage.ReadL( 0, measurementParamsPckg ) );
       
  1766 
       
  1767             if( ret != KErrNone )
       
  1768                 {
       
  1769                 __TRACE( KError, ( _L( "CTestExecution::ReadRemoteCmdInfo: ReadL failed" ) ) );
       
  1770                 }
       
  1771             iCmdDef.iParam.aMeasurementOption->iOptions = getMeasurementOptions.iOptions;
       
  1772 
       
  1773             completeSend = ETrue;
       
  1774             break;
       
  1775             }
       
  1776         case EStifCmdGetStoredState:   // "Receive"
       
  1777             {
       
  1778             TGetRebootStoredParams getRebootStoredParams;
       
  1779             TGetRebootStoredParamsPckg rebootStoredParamsPckg( getRebootStoredParams );
       
  1780 
       
  1781             // Read message from client space
       
  1782             TRAP( ret, aMessage.ReadL( 0, rebootStoredParamsPckg ) );
       
  1783 
       
  1784             if( ret != KErrNone )
       
  1785                 {
       
  1786                 __TRACE( KError, ( _L( "CTestExecution::ReadRemoteCmdInfo: ReadL failed" ) ) );
       
  1787                 }
       
  1788             iCmdDef.iParam.aRebootStoredRef->iCode = getRebootStoredParams.aCode;
       
  1789             iCmdDef.iParam.aRebootStoredRef->iName = getRebootStoredParams.aName;
       
  1790 
       
  1791             completeSend = ETrue;
       
  1792             break;
       
  1793             }
       
  1794         case EStifCmdRebootProceed:          
       
  1795             {
       
  1796             completeSend = ETrue; // Complete EStifCmdStoreState
       
  1797             }
       
  1798             break;
       
  1799         default:
       
  1800             {
       
  1801             iModuleSession->PanicClient( EUnknownRemoteCmd, aMessage );
       
  1802             break;
       
  1803             }
       
  1804         }
       
  1805     // Complete request with ret
       
  1806     aMessage.Complete( ret ); 
       
  1807 
       
  1808     if( completeSend )
       
  1809         {
       
  1810         // Calls the TestCombiner's CRemoteReceiver::RunL() and
       
  1811         // returns error code to test module.
       
  1812         TestThreadRequestComplete( iCmdDef.iStatus, returnedErrorCode );
       
  1813         }
       
  1814         
       
  1815     return KErrNone;
       
  1816 
       
  1817     }
       
  1818 
       
  1819 /*
       
  1820 -------------------------------------------------------------------------------
       
  1821 
       
  1822     Class: CTestExecution
       
  1823 
       
  1824     Method: Pause
       
  1825 
       
  1826     Description: Pauses a test case
       
  1827 
       
  1828     Only ongoing tests can be paused. If test is not ongoing, then
       
  1829     function does nothing.
       
  1830 
       
  1831     Parameters: const RMessage& aMessage      :in:  Message from client.
       
  1832     
       
  1833     Return Values: TInt                             Always KErrNone
       
  1834 
       
  1835     Errors/Exceptions: None
       
  1836 
       
  1837     Status: Proposal
       
  1838 
       
  1839 -------------------------------------------------------------------------------
       
  1840 */
       
  1841 TInt CTestExecution::Pause( const RMessage2& aMessage )
       
  1842     {
       
  1843 
       
  1844     __TRACE ( KThreadOperation, ( _L( "CTestExecution::Pause" ) ) );
       
  1845 
       
  1846     TInt completionCode = KErrNone;
       
  1847 
       
  1848     // Note that it is allowed to suspend already suspended thread, so
       
  1849     // there is no need for states to verify that thread is really in
       
  1850     // resumed state.
       
  1851     switch ( iThreadState )
       
  1852         {
       
  1853         case EOnGoing:
       
  1854             completionCode = iModuleContainer->PauseThread();
       
  1855             break;
       
  1856 
       
  1857         case ENotStarted:
       
  1858             completionCode = KErrNotReady;
       
  1859             break;
       
  1860 
       
  1861         case EFinished:
       
  1862         case ECancelled:
       
  1863             completionCode = KErrCompletion;
       
  1864             break;
       
  1865 
       
  1866         default:
       
  1867             CTestServer::PanicServer( EInvalidThreadState );
       
  1868             break;
       
  1869         }
       
  1870 
       
  1871 
       
  1872     // Complete the request
       
  1873     aMessage.Complete( completionCode );
       
  1874 
       
  1875     return KErrNone;
       
  1876 
       
  1877     }
       
  1878 
       
  1879 
       
  1880 /*
       
  1881 -------------------------------------------------------------------------------
       
  1882 
       
  1883     Class: CTestExecution
       
  1884 
       
  1885     Method: Resume
       
  1886 
       
  1887     Description: Resumes a test case. If test is not ongoing,
       
  1888     then do not resume.
       
  1889 
       
  1890     Parameters: const RMessage& aMessage      :in:  Message from client.
       
  1891     
       
  1892     Return Values: TInt                             Always KErrNone
       
  1893 
       
  1894     Errors/Exceptions: None
       
  1895 
       
  1896     Status: Proposal
       
  1897 
       
  1898 -------------------------------------------------------------------------------
       
  1899 */
       
  1900 TInt CTestExecution::Resume( const RMessage2& aMessage )
       
  1901     {
       
  1902 
       
  1903     __TRACE ( KThreadOperation, ( _L( "CTestExecution::Resume" ) ) );
       
  1904 
       
  1905     TInt completionCode = KErrNone;
       
  1906 
       
  1907     // Note that it is allowed to resume already resumed thread, so
       
  1908     // there is no need for states to verify that thread is really in
       
  1909     // suspended state.
       
  1910     switch ( iThreadState )
       
  1911         {
       
  1912         case EOnGoing:
       
  1913             completionCode = iModuleContainer->ResumeThread();
       
  1914             break;
       
  1915 
       
  1916         case ENotStarted:
       
  1917             completionCode = KErrNotReady;
       
  1918             break;
       
  1919 
       
  1920         case EFinished:
       
  1921         case ECancelled:
       
  1922             completionCode = KErrCompletion;
       
  1923             break;
       
  1924 
       
  1925         default:
       
  1926             CTestServer::PanicServer( EInvalidThreadState );
       
  1927             break;
       
  1928         }
       
  1929 
       
  1930 
       
  1931     // Complete the request
       
  1932     aMessage.Complete( completionCode );
       
  1933 
       
  1934     return KErrNone;
       
  1935 
       
  1936     }
       
  1937 
       
  1938 /*
       
  1939 -------------------------------------------------------------------------------
       
  1940 
       
  1941     Class: CTestExecution
       
  1942 
       
  1943     Method: CloseTestExecution
       
  1944 
       
  1945     Description: Closes Test Execution subsession
       
  1946 
       
  1947     Parameters: const RMessage& aMessage      :in:  Message from client.
       
  1948     
       
  1949     Return Values: TInt                             Always KErrNone
       
  1950 
       
  1951     Errors/Exceptions: None
       
  1952 
       
  1953     Status: Proposal
       
  1954     
       
  1955 -------------------------------------------------------------------------------
       
  1956 */
       
  1957 TInt CTestExecution::CloseTestExecution( const RMessage2& aMessage )
       
  1958     {
       
  1959 
       
  1960     // Cancel test request
       
  1961     CancelTestRequest();
       
  1962 
       
  1963     // Cancel print request
       
  1964     CancelPrintRequest();
       
  1965     
       
  1966     // Cancel event request
       
  1967     CancelEventRequest();
       
  1968 
       
  1969     // Delete this subsession
       
  1970     const TUint subsession = aMessage.Int3();
       
  1971     iModuleSession->DeleteTestExecution( subsession, aMessage );
       
  1972 
       
  1973     // Complete the request
       
  1974     aMessage.Complete( KErrNone );
       
  1975 
       
  1976     return KErrNone;
       
  1977 
       
  1978     }
       
  1979 
       
  1980 
       
  1981 /*
       
  1982 -------------------------------------------------------------------------------
       
  1983 
       
  1984     Class: CTestExecution
       
  1985 
       
  1986     Method: CancelPrintRequest
       
  1987 
       
  1988     Description: Cancel print request. Completes ongoing print request
       
  1989     with KErrCancel.
       
  1990 
       
  1991     Parameters: None
       
  1992     
       
  1993     Return Values: TInt                             Always KErrNone
       
  1994 
       
  1995     Errors/Exceptions: None
       
  1996 
       
  1997     Status: Proposal
       
  1998     
       
  1999 -------------------------------------------------------------------------------
       
  2000 */
       
  2001 TInt CTestExecution::CancelPrintRequest()
       
  2002     {
       
  2003 
       
  2004     if ( iPrintNotifyAvailable )
       
  2005         {
       
  2006         iPrintHandler->Cancel();
       
  2007         
       
  2008         iPrintNotifyAvailable = EFalse;
       
  2009         iNotifyPrintMessage.Complete ( KErrCancel );
       
  2010         //@spe iPrintNotifyAvailable = EFalse;
       
  2011         }
       
  2012 
       
  2013     return KErrNone;
       
  2014 
       
  2015     }
       
  2016 
       
  2017 /*
       
  2018 -------------------------------------------------------------------------------
       
  2019 
       
  2020     Class: CTestExecution
       
  2021 
       
  2022     Method: CancelEventRequest
       
  2023 
       
  2024     Description: Cancel event request. Completes ongoing event request
       
  2025     with KErrCancel.
       
  2026 
       
  2027     Parameters: None
       
  2028     
       
  2029     Return Values: TInt                             Always KErrNone
       
  2030 
       
  2031     Errors/Exceptions: None
       
  2032 
       
  2033     Status: Proposal
       
  2034     
       
  2035 -------------------------------------------------------------------------------
       
  2036 */
       
  2037 TInt CTestExecution::CancelEventRequest()
       
  2038     {
       
  2039     iEventHandler->Cancel();
       
  2040 
       
  2041     if( iEventNotifyAvailable )
       
  2042         {
       
  2043         // Cancel request
       
  2044         iEventNotifyAvailable = EFalse;
       
  2045         iNotifyEventMessage.Complete ( KErrCancel );
       
  2046         }
       
  2047 
       
  2048     return KErrNone;
       
  2049 
       
  2050     }
       
  2051 
       
  2052 /*
       
  2053 -------------------------------------------------------------------------------
       
  2054 
       
  2055     Class: CTestExecution
       
  2056 
       
  2057     Method: CancelInterferenceRequest
       
  2058 
       
  2059     Description: Cancel print request. Completes ongoing print request
       
  2060     with KErrCancel.
       
  2061 
       
  2062     Parameters: None
       
  2063 
       
  2064     Return Values: TInt: Always KErrNone
       
  2065 
       
  2066     Errors/Exceptions: None
       
  2067 
       
  2068     Status: Proposal
       
  2069     
       
  2070 -------------------------------------------------------------------------------
       
  2071 */
       
  2072 TInt CTestExecution::CancelInterferenceRequest()
       
  2073     {
       
  2074 
       
  2075     if ( iInterferenceNotifyAvailable )
       
  2076         {
       
  2077         iInterferenceHandler->Cancel();
       
  2078         
       
  2079         iInterferenceNotifyAvailable = EFalse;
       
  2080         iNotifyInterferenceMessage.Complete ( KErrCancel );
       
  2081         }
       
  2082 
       
  2083     return KErrNone;
       
  2084 
       
  2085     }
       
  2086 
       
  2087 /*
       
  2088 -------------------------------------------------------------------------------
       
  2089 
       
  2090     Class: CTestExecution
       
  2091 
       
  2092     Method: CancelRemoteCmdRequest
       
  2093 
       
  2094     Description: Cancel RemoteCmd request. Completes ongoing RemoteCmd request
       
  2095         with KErrCancel.
       
  2096 
       
  2097     Parameters: None
       
  2098     
       
  2099     Return Values: TInt: Always KErrNone
       
  2100 
       
  2101     Errors/Exceptions: None
       
  2102 
       
  2103     Status: Proposal
       
  2104     
       
  2105 -------------------------------------------------------------------------------
       
  2106 */
       
  2107 TInt CTestExecution::CancelRemoteCmdRequest()
       
  2108     {
       
  2109     iSndHandler->Cancel();
       
  2110 
       
  2111     // Cancel request
       
  2112     if( iRemoteSendAvailable )
       
  2113         {
       
  2114         iRemoteSendAvailable = EFalse;
       
  2115         iNotifyRemoteCmdMessage.Complete ( KErrCancel );
       
  2116         }
       
  2117 
       
  2118     return KErrNone;
       
  2119 
       
  2120     }
       
  2121 
       
  2122 /*
       
  2123 -------------------------------------------------------------------------------
       
  2124 
       
  2125     Class: CTestExecution
       
  2126 
       
  2127     Method: NotifyCommand
       
  2128 
       
  2129     Description: Handles the first phase of the Command request from engine.
       
  2130 
       
  2131     Parameters: const RMessage& aMessage: in: Message from client.
       
  2132 
       
  2133     Return Values: Symbian OS error code.
       
  2134 
       
  2135     Errors/Exceptions: None
       
  2136 
       
  2137     Status: Proposal
       
  2138 
       
  2139 -------------------------------------------------------------------------------
       
  2140 */
       
  2141 TInt CTestExecution::NotifyCommand( const RMessage2& aMessage )
       
  2142     {
       
  2143     iNotifyCommandMessage = aMessage;
       
  2144     iCommandNotifyAvailable = ETrue;
       
  2145     iCommandHandler->StartL();
       
  2146 
       
  2147     return KErrNone;
       
  2148     }
       
  2149 
       
  2150 /*
       
  2151 -------------------------------------------------------------------------------
       
  2152 
       
  2153     Class: CTestExecution
       
  2154 
       
  2155     Method: CancelCommandRequest
       
  2156 
       
  2157     Description: Cancel Command request. Completes ongoing Command request
       
  2158         with KErrCancel.
       
  2159 
       
  2160     Parameters: None
       
  2161 
       
  2162     Return Values: TInt: Always KErrNone
       
  2163 
       
  2164     Errors/Exceptions: None
       
  2165 
       
  2166     Status: Proposal
       
  2167 
       
  2168 -------------------------------------------------------------------------------
       
  2169 */
       
  2170 TInt CTestExecution::CancelCommandRequest()
       
  2171     {
       
  2172     iCommandHandler->Cancel();
       
  2173 
       
  2174     // Cancel request
       
  2175     if(iCommandNotifyAvailable)
       
  2176         {
       
  2177         iCommandNotifyAvailable = EFalse;
       
  2178         iNotifyCommandMessage.Complete(KErrCancel);
       
  2179         }
       
  2180 
       
  2181     return KErrNone;
       
  2182     }
       
  2183 
       
  2184 /*
       
  2185 -------------------------------------------------------------------------------
       
  2186 
       
  2187     Class: CTestExecution
       
  2188 
       
  2189     Method: CancelTestRequest
       
  2190 
       
  2191     Description: Cancel test execution request.
       
  2192     If thread is not in OnGoing state, function does not do anything.
       
  2193 
       
  2194     Otherwise following operations are done:
       
  2195     1 ) Obtain access to both  PrintMutex and EventMutex to make sure that
       
  2196        thread can't be accessing print queue or events.
       
  2197     2 ) Kill the thread
       
  2198     3 ) Complete original "RunTestCase" request with KErrCancel
       
  2199     4 ) If print queue is empty, complete print request
       
  2200     5 ) Give up mutexes
       
  2201     6 ) Delete module container
       
  2202 
       
  2203     Parameters: None
       
  2204     
       
  2205     Return Values: TInt: Always KErrNone
       
  2206 
       
  2207     Errors/Exceptions: None
       
  2208 
       
  2209     Status: Approved
       
  2210     
       
  2211 -------------------------------------------------------------------------------
       
  2212 */
       
  2213 TInt CTestExecution::CancelTestRequest()
       
  2214     {
       
  2215     // This mutex block and make sure that cancel operation is done succesfully
       
  2216     // and test case e.g. cannot complete at the same time. Get mutex.
       
  2217     iTestThreadMutex.Wait();
       
  2218 
       
  2219     // iModuleContainer is an active object, check is active.
       
  2220     if ( iModuleContainer == NULL || ( iModuleContainer != NULL && !iModuleContainer->IsActive() ) )
       
  2221         {
       
  2222         // Test case is already ready, return.
       
  2223         iTestThreadMutex.Signal();
       
  2224         return KErrNone;
       
  2225         }
       
  2226 
       
  2227     if ( iThreadState == EOnGoing )
       
  2228         {
       
  2229         // Print mutex access is required to make sure that the dying thread
       
  2230         // does not have access to print queue. Same is true for event queue.
       
  2231 
       
  2232         // NOTE: iEventArrayMutex is now taken, so the ongoing thread
       
  2233         // can't set any events so queue will be empty.
       
  2234         iPrintHandler->Cancel();
       
  2235         iEventHandler->Cancel();
       
  2236         iInterferenceHandler->Cancel();
       
  2237         iCommandHandler->Cancel();
       
  2238 
       
  2239         // Kill the thread
       
  2240         iModuleContainer->KillThread( KErrCancel );
       
  2241 
       
  2242         // Complete the test execution request
       
  2243         CompleteTestExecution( KErrCancel, TFullTestResult::ECaseCancelled, 
       
  2244                                KErrCancel, KErrCancel, _L( "Cancelled" ) );
       
  2245         iThreadState = ECancelled;
       
  2246 
       
  2247        
       
  2248         /**        
       
  2249         * Removed, because may block in certain situations. Implemented now in
       
  2250         * TestCombiner instead.
       
  2251         // Unset all pending state events, 
       
  2252         // because we have killed the testcase abnormally
       
  2253         // UnsetStateEvents();
       
  2254         */
       
  2255         
       
  2256         // Complete print request if queue is empty
       
  2257         CompletePrintRequestIfQueueEmpty();
       
  2258         
       
  2259         // Delete the module containter
       
  2260         delete iModuleContainer;
       
  2261         iModuleContainer = NULL;
       
  2262         }
       
  2263         
       
  2264     // Relinquish mutex.
       
  2265     iTestThreadMutex.Signal();
       
  2266 
       
  2267     return KErrNone;
       
  2268 
       
  2269     }
       
  2270 
       
  2271 /*
       
  2272 -------------------------------------------------------------------------------
       
  2273 
       
  2274     Class: CTestExecution
       
  2275 
       
  2276     Method: CancelRequestL
       
  2277 
       
  2278     Description: Cancel asynchronous request
       
  2279 
       
  2280     Parameters: const RMessage& aMessage      :in:  Message from client.
       
  2281     
       
  2282     Return Values: TInt                             Error code from CancelXXX-
       
  2283                                                     function
       
  2284 
       
  2285     Errors/Exceptions: Function panics the client, if invalid message
       
  2286                        received.
       
  2287 
       
  2288     Status: Proposal
       
  2289     
       
  2290 -------------------------------------------------------------------------------
       
  2291 */
       
  2292 TInt CTestExecution::CancelRequestL( const RMessage2& aMessage )
       
  2293     {
       
  2294     TInt r = KErrNone;
       
  2295 
       
  2296     switch ( aMessage.Int0() )
       
  2297         {
       
  2298         case ETestExecutionRunTestCase:
       
  2299             {
       
  2300             r = CancelTestRequest();
       
  2301             break;
       
  2302             }
       
  2303         case ETestExecutionNotifyProgress:
       
  2304             {
       
  2305             r = CancelPrintRequest();
       
  2306             break;
       
  2307             }
       
  2308         case ETestExecutionNotifyEvent:
       
  2309             {
       
  2310             r = CancelEventRequest();
       
  2311             break;
       
  2312             }
       
  2313         case ETestExecutionNotifyRemoteCmd:
       
  2314             {
       
  2315             r = CancelRemoteCmdRequest();
       
  2316             break;
       
  2317             }
       
  2318         case ETestExecutionNotifyCommand:
       
  2319             {
       
  2320             r = CancelCommandRequest();
       
  2321             break;
       
  2322             }
       
  2323         default:
       
  2324             iModuleSession->PanicClient( EInvalidRequestCancel, aMessage );
       
  2325             break;
       
  2326         }
       
  2327 
       
  2328     aMessage.Complete( r );
       
  2329 
       
  2330     return r;
       
  2331 
       
  2332     }
       
  2333 
       
  2334 /*
       
  2335 -------------------------------------------------------------------------------
       
  2336 
       
  2337     Class: CTestExecution
       
  2338 
       
  2339     Method: SetThreadState
       
  2340 
       
  2341     Description: A multithread safe thread state modification function
       
  2342 
       
  2343     Parameters: const TTestState aState       :in:  New state
       
  2344     
       
  2345     Return Values: None
       
  2346 
       
  2347     Errors/Exceptions: None
       
  2348 
       
  2349     Status: Proposal
       
  2350     
       
  2351 -------------------------------------------------------------------------------
       
  2352 */
       
  2353 void CTestExecution::SetThreadState( const TTestState aState )
       
  2354     {
       
  2355 
       
  2356     iThreadState = aState;
       
  2357 
       
  2358     }
       
  2359 
       
  2360 /*
       
  2361 -------------------------------------------------------------------------------
       
  2362 
       
  2363     Class: CTestExecution
       
  2364 
       
  2365     Method: Complete event
       
  2366 
       
  2367     Description: Completes pending event request. Must be 
       
  2368         called with iEventSem taken.
       
  2369         
       
  2370     Parameters: None
       
  2371     
       
  2372     Return Values: None
       
  2373 
       
  2374     Errors/Exceptions: None
       
  2375     
       
  2376     Status: Proposal
       
  2377     
       
  2378 -------------------------------------------------------------------------------
       
  2379 */
       
  2380 void CTestExecution::CompleteEvent( TInt aError )
       
  2381     {
       
  2382     RDebug::Print(_L("STF [ES]: CTestExecution::CompleteEvent()"));
       
  2383     if( iEventDef.iStatus )
       
  2384         {
       
  2385         __TRACE( KMessage,(_L("Comp Stat %d, %x (error %d)"), 
       
  2386             this, iEventDef.iStatus, aError));
       
  2387     RDebug::Print(_L("STF [ES]: CTestExecution::CompleteEvent() completing status [%x]"), iEventDef.iStatus);
       
  2388         TestThreadRequestComplete( iEventDef.iStatus, aError );
       
  2389         
       
  2390         iEventDef.iStatus = NULL;
       
  2391         
       
  2392         }
       
  2393         
       
  2394     }
       
  2395     
       
  2396 /*
       
  2397 -------------------------------------------------------------------------------
       
  2398 
       
  2399     Class: CTestExecution
       
  2400 
       
  2401     Method: CompletePrintRequestIfQueueEmpty
       
  2402 
       
  2403     Description: Completes print request if queue is empty.
       
  2404 
       
  2405     Parameters: None
       
  2406     
       
  2407     Return Values: None
       
  2408 
       
  2409     Errors/Exceptions: None
       
  2410 
       
  2411     Status: Proposal
       
  2412     
       
  2413 -------------------------------------------------------------------------------
       
  2414 */
       
  2415 void CTestExecution::CompletePrintRequestIfQueueEmpty()
       
  2416     {
       
  2417 
       
  2418     if ( iPrintNotifyAvailable &&  iPrintQueue->Count() == 0 )
       
  2419         {
       
  2420         iNotifyPrintMessage.Complete ( KErrEof );
       
  2421         iPrintNotifyAvailable = EFalse;
       
  2422         }
       
  2423 
       
  2424     }
       
  2425 
       
  2426 /*
       
  2427 -------------------------------------------------------------------------------
       
  2428 
       
  2429     Class: CTestExecution
       
  2430 
       
  2431     Method: CleanupEvents
       
  2432 
       
  2433     Description: Cleanups Events.
       
  2434 
       
  2435     Parameters: None
       
  2436     
       
  2437     Return Values: None
       
  2438 
       
  2439     Errors/Exceptions: None
       
  2440 
       
  2441     Status: Proposal
       
  2442     
       
  2443 -------------------------------------------------------------------------------
       
  2444 */
       
  2445 void CTestExecution::CleanupEvents()
       
  2446     {
       
  2447     
       
  2448     iEventArray.ResetAndDestroy();
       
  2449     
       
  2450     }
       
  2451     
       
  2452 /*
       
  2453 -------------------------------------------------------------------------------
       
  2454 
       
  2455     Class: CTestExecution
       
  2456 
       
  2457     Method: GetRq
       
  2458 
       
  2459     Description: Get request pointers.
       
  2460 
       
  2461     Parameters: None
       
  2462 
       
  2463     Return Values: TRequestStatus*
       
  2464 
       
  2465     Errors/Exceptions: None
       
  2466 
       
  2467     Status: Approved
       
  2468     
       
  2469 -------------------------------------------------------------------------------
       
  2470 */
       
  2471 TRequestStatus* CTestExecution::GetRq( TRequestType aType )
       
  2472     {
       
  2473 
       
  2474     TRequestStatus* status = NULL;
       
  2475 
       
  2476     switch( aType )
       
  2477         {
       
  2478         case ERqPrint:
       
  2479             status = &iPrintHandler->iStatus;
       
  2480             break;
       
  2481         case ERqEvent:
       
  2482             status = &iEventHandler->iStatus;
       
  2483             break;
       
  2484         case ERqSnd:
       
  2485             status = &iSndHandler->iStatus;
       
  2486             break;
       
  2487         case ERqRcv:
       
  2488             status = &iRcvHandler->iStatus;
       
  2489             break;
       
  2490         case ERqInterference:
       
  2491             status = &iInterferenceHandler->iStatus;
       
  2492             break;
       
  2493         case ERqMeasurement:
       
  2494             status = &iMeasurementHandler->iStatus;
       
  2495             break;
       
  2496         case ERqCommand:
       
  2497             status = &iCommandHandler->iStatus;
       
  2498             break;
       
  2499         default:
       
  2500             break;
       
  2501         }
       
  2502 
       
  2503     return status;
       
  2504 
       
  2505     }
       
  2506 
       
  2507 
       
  2508 /*
       
  2509 -------------------------------------------------------------------------------
       
  2510 
       
  2511     Class: CTestExecution
       
  2512 
       
  2513     Method: CompleteTestExecution
       
  2514 
       
  2515     Description: Completes test execution
       
  2516 
       
  2517     Parameters: const TInt aCompletionCode    :in:  Request completion code
       
  2518                 const TInt aCaseExecutionCode  in:  Case execution code
       
  2519                 const TFullTestResult::TCaseExecutionResult aCaseExecutionType,
       
  2520                 const TInt aCaseResult        :in:  Case result
       
  2521                 const TDesC& aText            :in:  Completion text
       
  2522 
       
  2523     Return Values: None
       
  2524 
       
  2525     Errors/Exceptions: None
       
  2526 
       
  2527     Status: Proposal
       
  2528 
       
  2529 -------------------------------------------------------------------------------
       
  2530 */
       
  2531 void CTestExecution::CompleteTestExecution( const TInt aCompletionCode,
       
  2532     const TFullTestResult::TCaseExecutionResult aCaseExecutionType,
       
  2533     const TInt aCaseExecutionCode,
       
  2534     const TInt aCaseResult,
       
  2535     const TDesC& aText )
       
  2536     {
       
  2537     
       
  2538     TInt completionCode = aCompletionCode;
       
  2539     
       
  2540     if( iModuleContainer != NULL )
       
  2541         {
       
  2542         // Fill the description
       
  2543         iFullResult.iEndTime.HomeTime();
       
  2544         iFullResult.iCaseExecutionResultType = aCaseExecutionType;
       
  2545         iFullResult.iCaseExecutionResultCode = aCaseExecutionCode;
       
  2546         iFullResult.iTestResult.iResult = aCaseResult;
       
  2547         iFullResult.iTestResult.iResultDes = aText;
       
  2548         CompleteTestExecution( aCompletionCode );
       
  2549         return;
       
  2550         }
       
  2551     else
       
  2552         {   
       
  2553         completionCode = KErrGeneral;
       
  2554         __TRACE ( KError, ( CStifLogger::ERed, 
       
  2555             _L("CTestExecution::CompleteTestExecution: ModuleContainer NULL") ) );
       
  2556         }
       
  2557 
       
  2558     iTestExeMessage.Complete ( completionCode );
       
  2559 
       
  2560     }
       
  2561 
       
  2562 /*
       
  2563 -------------------------------------------------------------------------------
       
  2564 
       
  2565     Class: CTestExecution
       
  2566 
       
  2567     Method: CompleteTestExecution
       
  2568 
       
  2569     Description: Completes test execution
       
  2570 
       
  2571     Parameters: const TInt aCompletionCode: in: completion code
       
  2572                 TFullTestResult&: in: test case result
       
  2573 
       
  2574     Return Values: None
       
  2575 
       
  2576     Errors/Exceptions: None
       
  2577 
       
  2578     Status: Proposal
       
  2579 
       
  2580 -------------------------------------------------------------------------------
       
  2581 */
       
  2582 void CTestExecution::CompleteTestExecution( const TInt aCompletionCode )
       
  2583     {
       
  2584     
       
  2585     TInt completionCode = aCompletionCode;
       
  2586     
       
  2587     TFullTestResultPckg fullResultPckg( iFullResult );
       
  2588     TRAPD( res, iTestExeMessage.WriteL( 0, fullResultPckg ) );
       
  2589     if ( res != KErrNone )
       
  2590         {
       
  2591         completionCode = res;
       
  2592         }
       
  2593 
       
  2594     iTestExeMessage.Complete ( completionCode );
       
  2595     
       
  2596     // @js Now it returns completionCode, used to return res
       
  2597 
       
  2598     }
       
  2599 
       
  2600 /*
       
  2601 -------------------------------------------------------------------------------
       
  2602 
       
  2603     Class: CTestExecution
       
  2604 
       
  2605     Method: UnsetStateEvents
       
  2606 
       
  2607     Description: Unsets all state events. Must be done if testcase is exited 
       
  2608                 abnormally (i.e. aborted by the user).
       
  2609 
       
  2610     Parameters: None
       
  2611     
       
  2612     Return Values: None
       
  2613 
       
  2614     Errors/Exceptions: None
       
  2615 
       
  2616     Status: Proposal
       
  2617     
       
  2618 -------------------------------------------------------------------------------
       
  2619 */
       
  2620 void CTestExecution::UnsetStateEvents()
       
  2621     {
       
  2622 
       
  2623 
       
  2624     // Unset all state events that are set currently
       
  2625     TInt count = iStateEvents.Count();
       
  2626     TEventIf event;
       
  2627     for( TInt i = 0; i < count; i++ )   
       
  2628         {
       
  2629         TPtrC name = *(iStateEvents[i]);
       
  2630         event.Set( TEventIf::EUnsetEvent, name, TEventIf::EState );
       
  2631         
       
  2632         // Construct message
       
  2633         TEventIfPckg eventPckg( event );
       
  2634 
       
  2635         // Write message to client space
       
  2636         TRAPD( res, iNotifyEventMessage.WriteL( 0, eventPckg ) );
       
  2637 
       
  2638         // Complete with WriteL result
       
  2639         iEventNotifyAvailable = EFalse;
       
  2640         iNotifyEventMessage.Complete( res );
       
  2641         if( res != KErrNone )
       
  2642             {
       
  2643             __TRACE( KError,( _L( "CTestExecution::UnsetStateEvents: WriteL failed" ) ));
       
  2644             break;
       
  2645             } 
       
  2646         }
       
  2647     
       
  2648     }
       
  2649 
       
  2650 /*
       
  2651 -------------------------------------------------------------------------------
       
  2652 
       
  2653     Class: CTestExecution
       
  2654 
       
  2655     Method: TestThreadRequestComplete
       
  2656 
       
  2657     Description: Complete test thread request.
       
  2658 
       
  2659     Parameters: None
       
  2660     
       
  2661     Return Values: None
       
  2662 
       
  2663     Errors/Exceptions: None
       
  2664 
       
  2665     Status: Proposal
       
  2666     
       
  2667 -------------------------------------------------------------------------------
       
  2668 */
       
  2669 void CTestExecution::TestThreadRequestComplete( TRequestStatus* aStatus, 
       
  2670                                                 TInt aCode)
       
  2671     {                                        
       
  2672     
       
  2673     if( iThreadState != EOnGoing )
       
  2674         {
       
  2675         __TRACE( KError,
       
  2676             ( _L( "CTestExecution::TestThreadRequestComplete: test thread killed" ) ));
       
  2677         return;
       
  2678         }
       
  2679 
       
  2680     if( iTestThreadOpen == EFalse )
       
  2681         {        
       
  2682         if( iTestThread.Open( iTestThreadId ) != KErrNone )
       
  2683             {
       
  2684             __TRACE( KError,
       
  2685                 ( _L( "CTestExecution::TestThreadRequestComplete: test thread cannot be opened" ) ));
       
  2686             return;
       
  2687             }
       
  2688         iTestThreadOpen = ETrue;
       
  2689         }
       
  2690     if( iTestThread.ExitType() != EExitPending ) 
       
  2691         {
       
  2692         // test thread has died
       
  2693         __TRACE( KError,
       
  2694             ( _L( "CTestExecution::TestThreadRequestComplete: test thread has died" ) ));
       
  2695         return;
       
  2696         }    
       
  2697      
       
  2698     iTestThread.RequestComplete( aStatus, aCode );
       
  2699     
       
  2700     }
       
  2701 
       
  2702 /*
       
  2703 -------------------------------------------------------------------------------
       
  2704 
       
  2705     Class: CTestExecution
       
  2706 
       
  2707     Method: CancelTestExecution
       
  2708 
       
  2709     Description: Cancels test(s) execution in special cases e.g. timeout,
       
  2710                  exit etc.
       
  2711 
       
  2712     Parameters: None
       
  2713     
       
  2714     Return Values: TInt: Symbian error code.
       
  2715 
       
  2716     Errors/Exceptions: None
       
  2717 
       
  2718     Status: Approved
       
  2719     
       
  2720 -------------------------------------------------------------------------------
       
  2721 */
       
  2722 TInt CTestExecution::CancelTestExecution()
       
  2723     {
       
  2724     TInt ret( KErrNone );
       
  2725     ret = CancelTestRequest();
       
  2726 
       
  2727     return ret;
       
  2728 
       
  2729     }
       
  2730 
       
  2731 /*
       
  2732 -------------------------------------------------------------------------------
       
  2733 
       
  2734     Class: CTestExecution
       
  2735 
       
  2736     Method: KillTestinterferenceThread
       
  2737 
       
  2738     Description: Make sure that any of the test interference thread's won't
       
  2739                  stay to run if test case is crashed of test interference
       
  2740                  object is not deleted.
       
  2741 
       
  2742     Parameters: None
       
  2743 
       
  2744     Return Values: TInt: Symbian OS error code.
       
  2745 
       
  2746     Errors/Exceptions: None
       
  2747 
       
  2748     Status: Proposal
       
  2749 
       
  2750 -------------------------------------------------------------------------------
       
  2751 */
       
  2752 TInt CTestExecution::KillTestinterferenceThread()
       
  2753     {
       
  2754     for( TInt i = 0; i < iSTIFTestInterferenceArray.Count(); i++ )
       
  2755         {
       
  2756         RDebug::Print( 
       
  2757             _L( "Test interference's thread[%x] killed by STIF" ), (TInt)iSTIFTestInterferenceArray[i].Id() );
       
  2758         __TRACE( KInit,
       
  2759             ( _L( "Test interference's thread[%x] killed by STIF" ), (TInt)iSTIFTestInterferenceArray[i].Id() ) );
       
  2760         iSTIFTestInterferenceArray[i].Kill( KErrCancel );
       
  2761         //iSTIFTestInterferenceArray.Remove( i );
       
  2762         }
       
  2763 
       
  2764     iSTIFTestInterferenceArray.Reset();
       
  2765     iSTIFTestInterferenceArray.Close();
       
  2766 
       
  2767     return KErrNone;
       
  2768 
       
  2769     }
       
  2770 
       
  2771 /*
       
  2772 -------------------------------------------------------------------------------
       
  2773 
       
  2774     Class: CTestExecution
       
  2775 
       
  2776     Method: DoNotifyCommand
       
  2777 
       
  2778     Description: Completes command message.
       
  2779 
       
  2780     Parameters: None.
       
  2781 
       
  2782     Return Values: Symbian OS error code.
       
  2783 
       
  2784     Errors/Exceptions: None
       
  2785 
       
  2786     Status: Proposal
       
  2787 
       
  2788 -------------------------------------------------------------------------------
       
  2789 */
       
  2790 TInt CTestExecution::DoNotifyCommand()
       
  2791     {
       
  2792     if(!iCommandNotifyAvailable)
       
  2793     	{
       
  2794     	__TRACE(KPrint, (_L("CTestExecution::DoNotifyCommand(): unable to complete notification")))
       
  2795     	return KErrNone;
       
  2796     	}
       
  2797 
       
  2798     TInt ret = KErrNone;
       
  2799 
       
  2800     switch(iCommandDef->iCommand)
       
  2801         {
       
  2802         case EStopExecution:
       
  2803             {
       
  2804             //Unpack received parameters
       
  2805             TStopExecutionCommandParams par;
       
  2806             TStopExecutionCommandParamsPckg parPack(par);
       
  2807             parPack.Copy(iCommandDef->iParamsPckg);
       
  2808 
       
  2809             //Set test case handle
       
  2810             par.iTestCaseHandle = iNotifyCommandMessage.Int3();
       
  2811 
       
  2812             __TRACE(KPrint, (_L("CTestExecution::DoNotifyCommand(): command [%d] type [%d] code [%d] test handle [%d]"), TInt(iCommandDef->iCommand), TInt(par.iType), TInt(par.iCode), par.iTestCaseHandle));
       
  2813             iCommandDef->iParamsPckg.Copy(parPack);
       
  2814             break;
       
  2815             }
       
  2816         case ESendTestModuleVersion:
       
  2817         	{
       
  2818         	TSendTestModuleVesionCommandParams par;
       
  2819         	TSendTestModuleVesionCommandParamsPckg parPack(par);
       
  2820         	parPack.Copy(iCommandDef->iParamsPckg);
       
  2821         	
       
  2822         	__TRACE(KPrint, (_L("CTestExecution::DoNotifyCommand(): command ESendTestModuleVersion")));
       
  2823         	break;
       
  2824         	}
       
  2825         default:
       
  2826             __TRACE(KError, (_L("CTestExecution::DoNotifyCommand(): Unknown command [%d]"), TInt(iCommandDef->iCommand)));
       
  2827             return KErrNotFound;
       
  2828         }
       
  2829     // Construct message
       
  2830     TPckg<TCommand> commandPckg(iCommandDef->iCommand);
       
  2831 
       
  2832     // Start first phase of the writing message to client space
       
  2833     TRAP(ret, iNotifyCommandMessage.WriteL(0, commandPckg));
       
  2834     if(ret != KErrNone)
       
  2835        {
       
  2836        __TRACE(KError, (_L( "CTestExecution::DoNotifyCommand(): WriteL failed (0)")));
       
  2837        }
       
  2838 
       
  2839     TRAP(ret, iNotifyCommandMessage.WriteL(1, iCommandDef->iParamsPckg));
       
  2840     if(ret != KErrNone)
       
  2841        {
       
  2842        __TRACE(KError, (_L( "CTestExecution::DoNotifyCommand(): WriteL failed (1)")));
       
  2843        }
       
  2844 
       
  2845     // Complete request with WriteL result
       
  2846     iCommandNotifyAvailable = EFalse;
       
  2847     iNotifyCommandMessage.Complete(ret);
       
  2848 
       
  2849     return KErrNone;
       
  2850     }
       
  2851 
       
  2852 /*
       
  2853 -------------------------------------------------------------------------------
       
  2854 
       
  2855     Class: CTestExecution
       
  2856 
       
  2857     Method: KillTestMeasurement
       
  2858 
       
  2859     Description: Make sure that any of the test measurement operations won't
       
  2860                  stay to run if test case is crashed or test measurement object
       
  2861                  is not stopped by user.
       
  2862 
       
  2863     Parameters: None
       
  2864 
       
  2865     Return Values: TInt: Symbian OS error code.
       
  2866 
       
  2867     Errors/Exceptions: None
       
  2868 
       
  2869     Status: Approved
       
  2870 
       
  2871 -------------------------------------------------------------------------------
       
  2872 */
       
  2873 TInt CTestExecution::KillTestMeasurement()
       
  2874     {
       
  2875     for( TInt i = 0; i < iMeasurementHandlingArray.Count(); i++ )
       
  2876         {
       
  2877         iMeasurementHandlingArray[i]->iMeasurementModulePtr->Stop();
       
  2878         }
       
  2879 
       
  2880     iMeasurementHandlingArray.ResetAndDestroy();
       
  2881     iMeasurementHandlingArray.Close();
       
  2882 
       
  2883     return KErrNone;
       
  2884 
       
  2885     }
       
  2886 
       
  2887 /*
       
  2888 -------------------------------------------------------------------------------
       
  2889 
       
  2890     DESCRIPTION
       
  2891 
       
  2892     This module contains implementation of CPrintHandler class member functions.
       
  2893     CPrintHandler listens print notifications from test thread.
       
  2894 
       
  2895 -------------------------------------------------------------------------------
       
  2896 */
       
  2897 
       
  2898 // ================= MEMBER FUNCTIONS =========================================
       
  2899 
       
  2900 
       
  2901 /*
       
  2902 -------------------------------------------------------------------------------
       
  2903 
       
  2904     Class: CPrintHandler
       
  2905 
       
  2906     Method: NewL
       
  2907 
       
  2908     Description: Constructs a new CPrintHandler object.
       
  2909 
       
  2910     Parameters: CTestExecution& aExecution: in: "Parent"
       
  2911 
       
  2912     Return Values: CPrintHandler*: New undertaker
       
  2913 
       
  2914     Errors/Exceptions: Leaves if memory allocation or ConstructL leaves.
       
  2915 
       
  2916     Status: Proposal
       
  2917 
       
  2918 -------------------------------------------------------------------------------
       
  2919 */
       
  2920 CPrintHandler* CPrintHandler::NewL( CTestExecution& aExecution )
       
  2921     {
       
  2922 
       
  2923     CPrintHandler* self = new( ELeave ) CPrintHandler( aExecution );
       
  2924     CleanupStack::PushL( self );
       
  2925     self->ConstructL();
       
  2926     CleanupStack::Pop( self );
       
  2927     return self;
       
  2928 
       
  2929     }
       
  2930 
       
  2931 /*
       
  2932 -------------------------------------------------------------------------------
       
  2933 
       
  2934     Class: CPrintHandler
       
  2935 
       
  2936     Method: ConstructL
       
  2937 
       
  2938     Description: Second level constructor.
       
  2939 
       
  2940     Parameters: None
       
  2941 
       
  2942     Return Values: None
       
  2943 
       
  2944     Errors/Exceptions: None
       
  2945 
       
  2946     Status: Proposal
       
  2947 
       
  2948 -------------------------------------------------------------------------------
       
  2949 */
       
  2950 void CPrintHandler::ConstructL()
       
  2951     {
       
  2952 
       
  2953     }
       
  2954 
       
  2955 /*
       
  2956 -------------------------------------------------------------------------------
       
  2957 
       
  2958     Class: CPrintHandler
       
  2959 
       
  2960     Method: CPrintHandler
       
  2961 
       
  2962     Description: Constructor
       
  2963 
       
  2964     Parameters: CTestModuleContainer& aExecution :in:   "Parent"
       
  2965 
       
  2966     Return Values: None
       
  2967 
       
  2968     Errors/Exceptions: None
       
  2969 
       
  2970     Status: Proposal
       
  2971     
       
  2972 -------------------------------------------------------------------------------
       
  2973 */
       
  2974 CPrintHandler::CPrintHandler( CTestExecution& aExecution ) :
       
  2975     CActive( CActive::EPriorityStandard ),
       
  2976     iExecution( aExecution )
       
  2977     {
       
  2978     
       
  2979     CActiveScheduler::Add ( this );
       
  2980     
       
  2981     }
       
  2982 
       
  2983 /*
       
  2984 -------------------------------------------------------------------------------
       
  2985 
       
  2986     Class: CPrintHandler
       
  2987 
       
  2988     Method: ~CPrintHandler
       
  2989 
       
  2990     Description: Destructor. 
       
  2991     Cancels active request.
       
  2992 
       
  2993     Parameters: None
       
  2994 
       
  2995     Return Values: None
       
  2996 
       
  2997     Errors/Exceptions: None
       
  2998 
       
  2999     Status: Proposal
       
  3000     
       
  3001 -------------------------------------------------------------------------------
       
  3002 */
       
  3003 CPrintHandler::~CPrintHandler()
       
  3004     {
       
  3005 
       
  3006     Cancel();
       
  3007 
       
  3008     }
       
  3009 
       
  3010 
       
  3011 
       
  3012 
       
  3013 /*
       
  3014 -------------------------------------------------------------------------------
       
  3015 
       
  3016     Class: CPrintHandler
       
  3017 
       
  3018     Method: StartL
       
  3019 
       
  3020     Description: Starts to monitor thread.
       
  3021 
       
  3022     Parameters: None
       
  3023 
       
  3024     Return Values: TInt                             Always KErrNone
       
  3025 
       
  3026     Errors/Exceptions: None
       
  3027 
       
  3028     Status: Proposal
       
  3029     
       
  3030 -------------------------------------------------------------------------------
       
  3031 */
       
  3032 void CPrintHandler::StartL()
       
  3033     {
       
  3034     
       
  3035     __TRACE( KPrint, ( _L( "CPrintHandler::StartL" ) ) );
       
  3036     
       
  3037     if( IsActive() ) 
       
  3038         {
       
  3039         CTestServer::PanicServer( EAlreadyActive );
       
  3040         }
       
  3041 
       
  3042     iStatus = KRequestPending;
       
  3043     SetActive();
       
  3044     
       
  3045     // Signal test thread
       
  3046     iExecution.iPrintSem.Signal();
       
  3047 
       
  3048     }
       
  3049 
       
  3050 /*
       
  3051 -------------------------------------------------------------------------------
       
  3052 
       
  3053     Class: CPrintHandler
       
  3054 
       
  3055     Method: RunL
       
  3056 
       
  3057     Description: Handles thread death.
       
  3058     Function does:
       
  3059     1 ) Stops monitoring thread
       
  3060     1 ) Marks thread death
       
  3061     2 ) Completes ongoing requests
       
  3062     3 ) Cleans the memory
       
  3063 
       
  3064     Parameters: None
       
  3065 
       
  3066     Return Values: None
       
  3067 
       
  3068     Errors/Exceptions: None
       
  3069 
       
  3070     Status: Proposal
       
  3071 
       
  3072 -------------------------------------------------------------------------------
       
  3073 */
       
  3074 void CPrintHandler::RunL()
       
  3075     {
       
  3076 
       
  3077     __TRACE( KPrint, ( _L( "CPrintHandler::RunL [%d]" ), iStatus.Int() ) );
       
  3078     
       
  3079     iExecution.DoNotifyPrint();
       
  3080     
       
  3081     // enable print request
       
  3082     //@speiExecution.iPrintHandler->StartL();
       
  3083     StartL();
       
  3084     }
       
  3085 
       
  3086 
       
  3087 /*
       
  3088 -------------------------------------------------------------------------------
       
  3089 
       
  3090     Class: CPrintHandler
       
  3091 
       
  3092     Method: DoCancel
       
  3093 
       
  3094     Description: Stops print notification listening.
       
  3095 
       
  3096     Parameters: None
       
  3097 
       
  3098     Return Values: None
       
  3099 
       
  3100     Errors/Exceptions: None
       
  3101 
       
  3102     Status: Proposal
       
  3103     
       
  3104 -------------------------------------------------------------------------------
       
  3105 */
       
  3106 
       
  3107 void CPrintHandler::DoCancel()
       
  3108     {
       
  3109 
       
  3110     __TRACE( KPrint, ( _L( "CPrintHandler::DoCancel" ) ) );
       
  3111 
       
  3112     iExecution.iPrintMutex.Wait();  // Take mutex and check test case print
       
  3113                                     // operation. If pending take print semaphore
       
  3114                                     // and complete
       
  3115     if( iStatus == KRequestPending )
       
  3116         {
       
  3117         // Signal test thread
       
  3118         // @remove iExecution.iPrintSem.Wait();
       
  3119     
       
  3120         TRequestStatus* status = &iStatus;    
       
  3121         User::RequestComplete( status, KErrCancel );        
       
  3122         }
       
  3123 
       
  3124     iExecution.iPrintMutex.Signal();
       
  3125     }
       
  3126 
       
  3127 /*
       
  3128 -------------------------------------------------------------------------------
       
  3129 
       
  3130     Class: CPrintHandler
       
  3131 
       
  3132     Method: RunError
       
  3133 
       
  3134     Description: Handle errors. RunL function does not leave, so one should
       
  3135     never come here. 
       
  3136 
       
  3137     Print trace and let framework handle error( i.e to do Panic )
       
  3138 
       
  3139     Parameters: TInt aError:                  :in:  Error code
       
  3140 
       
  3141     Return Values:  TInt                            Error code
       
  3142 
       
  3143     Errors/Exceptions: None
       
  3144 
       
  3145     Status: Proposal
       
  3146 
       
  3147 -------------------------------------------------------------------------------
       
  3148 */
       
  3149 TInt CPrintHandler::RunError( TInt aError )
       
  3150     {
       
  3151     
       
  3152     __TRACE( KError,( _L( "CPrintHandler::RunError" ) ) );
       
  3153 
       
  3154     return aError;
       
  3155     
       
  3156     }
       
  3157 
       
  3158 /*
       
  3159 -------------------------------------------------------------------------------
       
  3160 
       
  3161     DESCRIPTION
       
  3162 
       
  3163     This module contains implementation of CEventHandler class member functions.
       
  3164     CEventHandler listens print notifications from test thread.
       
  3165 
       
  3166 -------------------------------------------------------------------------------
       
  3167 */
       
  3168 
       
  3169 // ================= MEMBER FUNCTIONS =========================================
       
  3170 
       
  3171 
       
  3172 /*
       
  3173 -------------------------------------------------------------------------------
       
  3174 
       
  3175     Class: CEventHandler
       
  3176 
       
  3177     Method: NewL
       
  3178 
       
  3179     Description: Constructs a new CEventHandler object.
       
  3180 
       
  3181     Parameters: CTestExecution& aExecution: in: "Parent"
       
  3182 
       
  3183     Return Values: CEventHandler*: New undertaker
       
  3184 
       
  3185     Errors/Exceptions: Leaves if memory allocation or ConstructL leaves.
       
  3186 
       
  3187     Status: Proposal
       
  3188 
       
  3189 -------------------------------------------------------------------------------
       
  3190 */
       
  3191 CEventHandler* CEventHandler::NewL( CTestExecution& aExecution )
       
  3192     {
       
  3193 
       
  3194     CEventHandler* self = new( ELeave ) CEventHandler( aExecution );
       
  3195     CleanupStack::PushL( self );
       
  3196     self->ConstructL();
       
  3197     CleanupStack::Pop( self );
       
  3198     return self;
       
  3199 
       
  3200     }
       
  3201 
       
  3202 /*
       
  3203 -------------------------------------------------------------------------------
       
  3204 
       
  3205     Class: CEventHandler
       
  3206 
       
  3207     Method: ConstructL
       
  3208 
       
  3209     Description: Second level constructor.
       
  3210 
       
  3211     Parameters: None
       
  3212 
       
  3213     Return Values: None
       
  3214 
       
  3215     Errors/Exceptions: None
       
  3216 
       
  3217     Status: Proposal
       
  3218 
       
  3219 -------------------------------------------------------------------------------
       
  3220 */
       
  3221 void CEventHandler::ConstructL()
       
  3222     {
       
  3223 
       
  3224     }
       
  3225 
       
  3226 /*
       
  3227 -------------------------------------------------------------------------------
       
  3228 
       
  3229     Class: CEventHandler
       
  3230 
       
  3231     Method: CEventHandler
       
  3232 
       
  3233     Description: Constructor
       
  3234 
       
  3235     Parameters: CTestModuleContainer& aExecution :in:   "Parent"
       
  3236 
       
  3237     Return Values: None
       
  3238 
       
  3239     Errors/Exceptions: None
       
  3240 
       
  3241     Status: Proposal
       
  3242     
       
  3243 -------------------------------------------------------------------------------
       
  3244 */
       
  3245 CEventHandler::CEventHandler( CTestExecution& aExecution ) :
       
  3246     CActive( CActive::EPriorityStandard ),
       
  3247     iExecution( aExecution )
       
  3248     {
       
  3249     
       
  3250     CActiveScheduler::Add ( this );
       
  3251     
       
  3252     }
       
  3253 
       
  3254 /*
       
  3255 -------------------------------------------------------------------------------
       
  3256 
       
  3257     Class: CEventHandler
       
  3258 
       
  3259     Method: ~CEventHandler
       
  3260 
       
  3261     Description: Destructor. 
       
  3262     Cancels active request.
       
  3263 
       
  3264     Parameters: None
       
  3265 
       
  3266     Return Values: None
       
  3267 
       
  3268     Errors/Exceptions: None
       
  3269 
       
  3270     Status: Proposal
       
  3271     
       
  3272 -------------------------------------------------------------------------------
       
  3273 */
       
  3274 CEventHandler::~CEventHandler()
       
  3275     {
       
  3276 
       
  3277     Cancel();
       
  3278 
       
  3279     }
       
  3280 
       
  3281 
       
  3282 
       
  3283 
       
  3284 /*
       
  3285 -------------------------------------------------------------------------------
       
  3286 
       
  3287     Class: CEventHandler
       
  3288 
       
  3289     Method: StartL
       
  3290 
       
  3291     Description: Starts to monitor thread.
       
  3292 
       
  3293     Parameters: None
       
  3294 
       
  3295     Return Values: TInt                             Always KErrNone
       
  3296 
       
  3297     Errors/Exceptions: None
       
  3298 
       
  3299     Status: Proposal
       
  3300     
       
  3301 -------------------------------------------------------------------------------
       
  3302 */
       
  3303 void CEventHandler::StartL()
       
  3304     {
       
  3305     
       
  3306     __TRACE( KPrint, ( _L( "CEventHandler::StartL" ) ) );
       
  3307 
       
  3308     if( IsActive() ) 
       
  3309         {
       
  3310         CTestServer::PanicServer( EAlreadyActive );
       
  3311         }
       
  3312     
       
  3313     iStatus = KRequestPending;
       
  3314     SetActive();
       
  3315     
       
  3316     // Signal test thread
       
  3317     iExecution.iEventSem.Signal();
       
  3318 
       
  3319     }
       
  3320 
       
  3321 /*
       
  3322 -------------------------------------------------------------------------------
       
  3323 
       
  3324     Class: CEventHandler
       
  3325 
       
  3326     Method: RunL
       
  3327 
       
  3328     Description: Handles thread death.
       
  3329     Function does:
       
  3330     1 ) Stops monitoring thread
       
  3331     1 ) Marks thread death
       
  3332     2 ) Completes ongoing requests
       
  3333     3 ) Cleans the memory
       
  3334 
       
  3335     Parameters: None
       
  3336 
       
  3337     Return Values: None
       
  3338 
       
  3339     Errors/Exceptions: None
       
  3340 
       
  3341     Status: Proposal
       
  3342 
       
  3343 -------------------------------------------------------------------------------
       
  3344 */
       
  3345 void CEventHandler::RunL()
       
  3346     {
       
  3347     RDebug::Print(_L("STF [ES]: CEventHandler::RunL()"));
       
  3348 
       
  3349     __TRACE( KPrint, ( _L( "CEventHandler::RunL [%d]" ), iStatus.Int() ) );
       
  3350 
       
  3351     switch( iExecution.EventDef().iType )
       
  3352         {
       
  3353         case TEventDef::EEventCmd:
       
  3354             iExecution.DoNotifyEvent();
       
  3355             break;
       
  3356         case TEventDef::EEventCmdCancel:
       
  3357             iExecution.CancelEvent();
       
  3358             break;
       
  3359         default:
       
  3360             CTestServer::PanicServer( EUnknownEventCmd );
       
  3361             break;  
       
  3362         }
       
  3363          
       
  3364     }
       
  3365 
       
  3366 
       
  3367 /*
       
  3368 -------------------------------------------------------------------------------
       
  3369 
       
  3370     Class: CEventHandler
       
  3371 
       
  3372     Method: DoCancel
       
  3373 
       
  3374     Description: Stops print notification listening.
       
  3375 
       
  3376     Parameters: None
       
  3377 
       
  3378     Return Values: None
       
  3379 
       
  3380     Errors/Exceptions: None
       
  3381 
       
  3382     Status: Proposal
       
  3383     
       
  3384 -------------------------------------------------------------------------------
       
  3385 */
       
  3386 
       
  3387 void CEventHandler::DoCancel()
       
  3388     {
       
  3389 
       
  3390     __TRACE( KPrint, ( _L( "CEventHandler::DoCancel" ) ) );
       
  3391     
       
  3392     iExecution.iEventMutex.Wait();  // Take mutex and check test case event
       
  3393                                     // operation. If pending take event
       
  3394                                     // semaphore and complete
       
  3395     if( iStatus == KRequestPending )
       
  3396         {
       
  3397         // Signal test thread
       
  3398         // @remove iExecution.iEventSem.Wait();
       
  3399 
       
  3400         TRequestStatus* status = &iStatus;    
       
  3401         User::RequestComplete( status, KErrCancel );
       
  3402 
       
  3403         }
       
  3404 
       
  3405     iExecution.iEventMutex.Signal();
       
  3406 
       
  3407     }
       
  3408 
       
  3409 /*
       
  3410 -------------------------------------------------------------------------------
       
  3411 
       
  3412     Class: CEventHandler
       
  3413 
       
  3414     Method: RunError
       
  3415 
       
  3416     Description: Handle errors. RunL function does not leave, so one should
       
  3417     never come here. 
       
  3418 
       
  3419     Print trace and let framework handle error( i.e to do Panic )
       
  3420 
       
  3421     Parameters: TInt aError:                  :in:  Error code
       
  3422 
       
  3423     Return Values:  TInt                            Error code
       
  3424 
       
  3425     Errors/Exceptions: None
       
  3426 
       
  3427     Status: Proposal
       
  3428 
       
  3429 -------------------------------------------------------------------------------
       
  3430 */
       
  3431 TInt CEventHandler::RunError( TInt aError )
       
  3432     {
       
  3433     
       
  3434     __TRACE( KError,( _L( "CEventHandler::RunError" ) ) );
       
  3435 
       
  3436     return aError;
       
  3437     
       
  3438     }
       
  3439 
       
  3440 /*
       
  3441 -------------------------------------------------------------------------------
       
  3442 
       
  3443     DESCRIPTION
       
  3444 
       
  3445     This module contains implementation of CSndHandler class member functions.
       
  3446     CSndHandler listens print notifications from test thread.
       
  3447 
       
  3448 -------------------------------------------------------------------------------
       
  3449 */
       
  3450 
       
  3451 // ================= MEMBER FUNCTIONS =========================================
       
  3452 
       
  3453 
       
  3454 /*
       
  3455 -------------------------------------------------------------------------------
       
  3456 
       
  3457     Class: CSndHandler
       
  3458 
       
  3459     Method: NewL
       
  3460 
       
  3461     Description: Constructs a new CSndHandler object.
       
  3462 
       
  3463     Parameters: CTestExecution& aExecution: in: "Parent"
       
  3464 
       
  3465     Return Values: CSndHandler*: New undertaker
       
  3466 
       
  3467     Errors/Exceptions: Leaves if memory allocation or ConstructL leaves.
       
  3468 
       
  3469     Status: Proposal
       
  3470 
       
  3471 -------------------------------------------------------------------------------
       
  3472 */
       
  3473 CSndHandler* CSndHandler::NewL( CTestExecution& aExecution )
       
  3474     {
       
  3475 
       
  3476     CSndHandler* self = new( ELeave ) CSndHandler( aExecution );
       
  3477     CleanupStack::PushL( self );
       
  3478     self->ConstructL();
       
  3479     CleanupStack::Pop( self );
       
  3480     return self;
       
  3481 
       
  3482     }
       
  3483 
       
  3484 /*
       
  3485 -------------------------------------------------------------------------------
       
  3486 
       
  3487     Class: CSndHandler
       
  3488 
       
  3489     Method: ConstructL
       
  3490 
       
  3491     Description: Second level constructor.
       
  3492 
       
  3493     Parameters: None
       
  3494 
       
  3495     Return Values: None
       
  3496 
       
  3497     Errors/Exceptions: None
       
  3498 
       
  3499     Status: Proposal
       
  3500 
       
  3501 -------------------------------------------------------------------------------
       
  3502 */
       
  3503 void CSndHandler::ConstructL()
       
  3504     {
       
  3505 
       
  3506     }
       
  3507 
       
  3508 /*
       
  3509 -------------------------------------------------------------------------------
       
  3510 
       
  3511     Class: CSndHandler
       
  3512 
       
  3513     Method: CSndHandler
       
  3514 
       
  3515     Description: Constructor
       
  3516 
       
  3517     Parameters: CTestModuleContainer& aExecution :in:   "Parent"
       
  3518 
       
  3519     Return Values: None
       
  3520 
       
  3521     Errors/Exceptions: None
       
  3522 
       
  3523     Status: Proposal
       
  3524     
       
  3525 -------------------------------------------------------------------------------
       
  3526 */
       
  3527 CSndHandler::CSndHandler( CTestExecution& aExecution ) :
       
  3528     CActive( CActive::EPriorityStandard ),
       
  3529     iExecution( aExecution )
       
  3530     {
       
  3531     
       
  3532     CActiveScheduler::Add ( this );
       
  3533     
       
  3534     }
       
  3535 
       
  3536 /*
       
  3537 -------------------------------------------------------------------------------
       
  3538 
       
  3539     Class: CSndHandler
       
  3540 
       
  3541     Method: ~CSndHandler
       
  3542 
       
  3543     Description: Destructor. 
       
  3544     Cancels active request.
       
  3545 
       
  3546     Parameters: None
       
  3547 
       
  3548     Return Values: None
       
  3549 
       
  3550     Errors/Exceptions: None
       
  3551 
       
  3552     Status: Proposal
       
  3553     
       
  3554 -------------------------------------------------------------------------------
       
  3555 */
       
  3556 CSndHandler::~CSndHandler()
       
  3557     {
       
  3558 
       
  3559     Cancel();
       
  3560 
       
  3561     }
       
  3562 
       
  3563 
       
  3564 
       
  3565 
       
  3566 /*
       
  3567 -------------------------------------------------------------------------------
       
  3568 
       
  3569     Class: CSndHandler
       
  3570 
       
  3571     Method: StartL
       
  3572 
       
  3573     Description: Starts to monitor thread.
       
  3574 
       
  3575     Parameters: None
       
  3576 
       
  3577     Return Values: TInt                             Always KErrNone
       
  3578 
       
  3579     Errors/Exceptions: None
       
  3580 
       
  3581     Status: Proposal
       
  3582     
       
  3583 -------------------------------------------------------------------------------
       
  3584 */
       
  3585 void CSndHandler::StartL()
       
  3586     {
       
  3587     
       
  3588     __TRACE( KPrint, ( _L( "CSndHandler::StartL" ) ) );
       
  3589 
       
  3590     if( IsActive() ) 
       
  3591         {
       
  3592         CTestServer::PanicServer( EAlreadyActive );
       
  3593         }
       
  3594     
       
  3595     iStatus = KRequestPending;
       
  3596     SetActive();
       
  3597     
       
  3598     // Signal test thread
       
  3599     iExecution.iSndSem.Signal();
       
  3600 
       
  3601     }
       
  3602 
       
  3603 /*
       
  3604 -------------------------------------------------------------------------------
       
  3605 
       
  3606     Class: CSndHandler
       
  3607 
       
  3608     Method: RunL
       
  3609 
       
  3610     Description: Handles thread death.
       
  3611     Function does:
       
  3612     1 ) Stops monitoring thread
       
  3613     1 ) Marks thread death
       
  3614     2 ) Completes ongoing requests
       
  3615     3 ) Cleans the memory
       
  3616 
       
  3617     Parameters: None
       
  3618 
       
  3619     Return Values: None
       
  3620 
       
  3621     Errors/Exceptions: None
       
  3622 
       
  3623     Status: Proposal
       
  3624 
       
  3625 -------------------------------------------------------------------------------
       
  3626 */
       
  3627 void CSndHandler::RunL()
       
  3628     {
       
  3629 
       
  3630     __TRACE( KPrint, ( _L( "CSndHandler::RunL [%d]" ), iStatus.Int() ) );
       
  3631     
       
  3632     iExecution.DoRemoteSend();
       
  3633        
       
  3634     }
       
  3635 
       
  3636 
       
  3637 /*
       
  3638 -------------------------------------------------------------------------------
       
  3639 
       
  3640     Class: CSndHandler
       
  3641 
       
  3642     Method: DoCancel
       
  3643 
       
  3644     Description: Stops print notification listening.
       
  3645 
       
  3646     Parameters: None
       
  3647 
       
  3648     Return Values: None
       
  3649 
       
  3650     Errors/Exceptions: None
       
  3651 
       
  3652     Status: Proposal
       
  3653     
       
  3654 -------------------------------------------------------------------------------
       
  3655 */
       
  3656 
       
  3657 void CSndHandler::DoCancel()
       
  3658     {
       
  3659 
       
  3660     __TRACE( KPrint, ( _L( "CSndHandler::DoCancel" ) ) );
       
  3661 
       
  3662     iExecution.iSndMutex.Wait();  // Take mutex and check test case send
       
  3663                                   // operation. If pending take send
       
  3664                                   // semaphore and complete
       
  3665     if( iStatus == KRequestPending )
       
  3666         {
       
  3667         // Signal test thread
       
  3668         // @remove iExecution.iSndSem.Wait();
       
  3669 
       
  3670         TRequestStatus* status = &iStatus;    
       
  3671         User::RequestComplete( status, KErrCancel );
       
  3672 
       
  3673         }
       
  3674 
       
  3675     iExecution.iSndMutex.Signal();
       
  3676     
       
  3677     }
       
  3678 
       
  3679 /*
       
  3680 -------------------------------------------------------------------------------
       
  3681 
       
  3682     Class: CSndHandler
       
  3683 
       
  3684     Method: RunError
       
  3685 
       
  3686     Description: Handle errors. RunL function does not leave, so one should
       
  3687     never come here. 
       
  3688 
       
  3689     Print trace and let framework handle error( i.e to do Panic )
       
  3690 
       
  3691     Parameters: TInt aError:                  :in:  Error code
       
  3692 
       
  3693     Return Values:  TInt                            Error code
       
  3694 
       
  3695     Errors/Exceptions: None
       
  3696 
       
  3697     Status: Proposal
       
  3698 
       
  3699 -------------------------------------------------------------------------------
       
  3700 */
       
  3701 TInt CSndHandler::RunError( TInt aError )
       
  3702     {
       
  3703     
       
  3704     __TRACE( KError,( _L( "CSndHandler::RunError" ) ) );
       
  3705 
       
  3706     return aError;
       
  3707     
       
  3708     }
       
  3709 
       
  3710 /*
       
  3711 -------------------------------------------------------------------------------
       
  3712 
       
  3713     DESCRIPTION
       
  3714 
       
  3715     This module contains implementation of CSndHandler class member functions.
       
  3716     CRcvHandler listens print notifications from test thread.
       
  3717 
       
  3718 -------------------------------------------------------------------------------
       
  3719 */
       
  3720 
       
  3721 // ================= MEMBER FUNCTIONS =========================================
       
  3722 
       
  3723 
       
  3724 /*
       
  3725 -------------------------------------------------------------------------------
       
  3726 
       
  3727     Class: CRcvHandler
       
  3728 
       
  3729     Method: NewL
       
  3730 
       
  3731     Description: Constructs a new CRcvHandler object.
       
  3732 
       
  3733     Parameters: CTestExecution& aExecution: in: "Parent"
       
  3734 
       
  3735     Return Values: CRcvHandler*: New undertaker
       
  3736 
       
  3737     Errors/Exceptions: Leaves if memory allocation or ConstructL leaves.
       
  3738 
       
  3739     Status: Proposal
       
  3740 
       
  3741 -------------------------------------------------------------------------------
       
  3742 */
       
  3743 CRcvHandler* CRcvHandler::NewL( CTestExecution& aExecution )
       
  3744     {
       
  3745 
       
  3746     CRcvHandler* self = new( ELeave ) CRcvHandler( aExecution );
       
  3747     CleanupStack::PushL( self );
       
  3748     self->ConstructL();
       
  3749     CleanupStack::Pop( self );
       
  3750     return self;
       
  3751 
       
  3752     }
       
  3753 
       
  3754 /*
       
  3755 -------------------------------------------------------------------------------
       
  3756 
       
  3757     Class: CRcvHandler
       
  3758 
       
  3759     Method: ConstructL
       
  3760 
       
  3761     Description: Second level constructor.
       
  3762 
       
  3763     Parameters: None
       
  3764 
       
  3765     Return Values: None
       
  3766 
       
  3767     Errors/Exceptions: None
       
  3768 
       
  3769     Status: Proposal
       
  3770 
       
  3771 -------------------------------------------------------------------------------
       
  3772 */
       
  3773 void CRcvHandler::ConstructL()
       
  3774     {
       
  3775 
       
  3776     }
       
  3777 
       
  3778 /*
       
  3779 -------------------------------------------------------------------------------
       
  3780 
       
  3781     Class: CRcvHandler
       
  3782 
       
  3783     Method: CRcvHandler
       
  3784 
       
  3785     Description: Constructor
       
  3786 
       
  3787     Parameters: CTestModuleContainer& aExecution :in:   "Parent"
       
  3788 
       
  3789     Return Values: None
       
  3790 
       
  3791     Errors/Exceptions: None
       
  3792 
       
  3793     Status: Proposal
       
  3794     
       
  3795 -------------------------------------------------------------------------------
       
  3796 */
       
  3797 CRcvHandler::CRcvHandler( CTestExecution& aExecution ) :
       
  3798     CActive( CActive::EPriorityStandard ),
       
  3799     iExecution( aExecution )
       
  3800     {
       
  3801     
       
  3802     CActiveScheduler::Add ( this );
       
  3803     
       
  3804     }
       
  3805 
       
  3806 /*
       
  3807 -------------------------------------------------------------------------------
       
  3808 
       
  3809     Class: CRcvHandler
       
  3810 
       
  3811     Method: ~CRcvHandler
       
  3812 
       
  3813     Description: Destructor. 
       
  3814     Cancels active request.
       
  3815 
       
  3816     Parameters: None
       
  3817 
       
  3818     Return Values: None
       
  3819 
       
  3820     Errors/Exceptions: None
       
  3821 
       
  3822     Status: Proposal
       
  3823     
       
  3824 -------------------------------------------------------------------------------
       
  3825 */
       
  3826 CRcvHandler::~CRcvHandler()
       
  3827     {
       
  3828 
       
  3829     Cancel();
       
  3830 
       
  3831     }
       
  3832 
       
  3833 
       
  3834 
       
  3835 
       
  3836 /*
       
  3837 -------------------------------------------------------------------------------
       
  3838 
       
  3839     Class: CRcvHandler
       
  3840 
       
  3841     Method: StartL
       
  3842 
       
  3843     Description: Starts to monitor thread.
       
  3844 
       
  3845     Parameters: None
       
  3846 
       
  3847     Return Values: TInt                             Always KErrNone
       
  3848 
       
  3849     Errors/Exceptions: None
       
  3850 
       
  3851     Status: Proposal
       
  3852     
       
  3853 -------------------------------------------------------------------------------
       
  3854 */
       
  3855 void CRcvHandler::StartL()
       
  3856     {
       
  3857     
       
  3858     __TRACE( KPrint, ( _L( "CRcvHandler::StartL" ) ) );
       
  3859     
       
  3860     if( IsActive() ) 
       
  3861         {
       
  3862         CTestServer::PanicServer( EAlreadyActive );
       
  3863         }
       
  3864     iStatus = KRequestPending;
       
  3865     SetActive();
       
  3866     
       
  3867     // Signal test thread
       
  3868     iExecution.iRcvSem.Signal();
       
  3869 
       
  3870     }
       
  3871 
       
  3872 /*
       
  3873 -------------------------------------------------------------------------------
       
  3874 
       
  3875     Class: CRcvHandler
       
  3876 
       
  3877     Method: RunL
       
  3878 
       
  3879     Description: Handles thread death.
       
  3880     Function does:
       
  3881     1 ) Stops monitoring thread
       
  3882     1 ) Marks thread death
       
  3883     2 ) Completes ongoing requests
       
  3884     3 ) Cleans the memory
       
  3885 
       
  3886     Parameters: None
       
  3887 
       
  3888     Return Values: None
       
  3889 
       
  3890     Errors/Exceptions: None
       
  3891 
       
  3892     Status: Proposal
       
  3893 
       
  3894 -------------------------------------------------------------------------------
       
  3895 */
       
  3896 void CRcvHandler::RunL()
       
  3897     {
       
  3898 
       
  3899     __TRACE( KPrint, ( _L( "CRcvHandler::RunL [%d]" ), iStatus.Int() ) );
       
  3900     
       
  3901     iExecution.DoRemoteReceive();
       
  3902        
       
  3903     }
       
  3904 
       
  3905 
       
  3906 /*
       
  3907 -------------------------------------------------------------------------------
       
  3908 
       
  3909     Class: CRcvHandler
       
  3910 
       
  3911     Method: DoCancel
       
  3912 
       
  3913     Description: Stops print notification listening.
       
  3914 
       
  3915     Parameters: None
       
  3916 
       
  3917     Return Values: None
       
  3918 
       
  3919     Errors/Exceptions: None
       
  3920 
       
  3921     Status: Proposal
       
  3922     
       
  3923 -------------------------------------------------------------------------------
       
  3924 */
       
  3925 
       
  3926 void CRcvHandler::DoCancel()
       
  3927     {
       
  3928 
       
  3929     __TRACE( KPrint, ( _L( "CRcvHandler::DoCancel" ) ) );
       
  3930 
       
  3931     iExecution.iRcvMutex.Wait();  // Take mutex and check test case receive
       
  3932                                   // operation. If pending take reveive
       
  3933                                   // semaphore and complete
       
  3934     if( iStatus == KRequestPending )
       
  3935         {
       
  3936         // Signal test thread
       
  3937         // @remove iExecution.iRcvSem.Wait();
       
  3938 
       
  3939         TRequestStatus* status = &iStatus;    
       
  3940         User::RequestComplete( status, KErrCancel );
       
  3941         }
       
  3942         
       
  3943     iExecution.iRcvMutex.Signal();
       
  3944 
       
  3945     }
       
  3946 
       
  3947 /*
       
  3948 -------------------------------------------------------------------------------
       
  3949 
       
  3950     Class: CRcvHandler
       
  3951 
       
  3952     Method: RunError
       
  3953 
       
  3954     Description: Handle errors. RunL function does not leave, so one should
       
  3955     never come here. 
       
  3956 
       
  3957     Print trace and let framework handle error( i.e to do Panic )
       
  3958 
       
  3959     Parameters: TInt aError:                  :in:  Error code
       
  3960 
       
  3961     Return Values:  TInt                            Error code
       
  3962 
       
  3963     Errors/Exceptions: None
       
  3964 
       
  3965     Status: Proposal
       
  3966 
       
  3967 -------------------------------------------------------------------------------
       
  3968 */
       
  3969 TInt CRcvHandler::RunError( TInt aError )
       
  3970     {
       
  3971     
       
  3972     __TRACE( KError,( _L( "CRcvHandler::RunError" ) ) );
       
  3973 
       
  3974     return aError;
       
  3975     
       
  3976     }
       
  3977 
       
  3978 
       
  3979 /*
       
  3980 -------------------------------------------------------------------------------
       
  3981 
       
  3982     DESCRIPTION
       
  3983 
       
  3984     This module contains implementation of CTestInterferenceHandler class 
       
  3985     member functions. CTestInterferenceHandler listens print notifications from
       
  3986     test thread.
       
  3987 
       
  3988 -------------------------------------------------------------------------------
       
  3989 */
       
  3990 
       
  3991 // ================= MEMBER FUNCTIONS =========================================
       
  3992 
       
  3993 
       
  3994 /*
       
  3995 -------------------------------------------------------------------------------
       
  3996 
       
  3997     Class: CInterferenceHandler
       
  3998 
       
  3999     Method: NewL
       
  4000 
       
  4001     Description: Constructs a new CInterferenceHandler object.
       
  4002 
       
  4003     Parameters: CTestExecution& aExecution: in: "Parent"
       
  4004 
       
  4005     Return Values: CInterferenceHandler*: New undertaker
       
  4006 
       
  4007     Errors/Exceptions: Leaves if memory allocation or ConstructL leaves.
       
  4008 
       
  4009     Status: Proposal
       
  4010 
       
  4011 -------------------------------------------------------------------------------
       
  4012 */
       
  4013 CInterferenceHandler* CInterferenceHandler::NewL( 
       
  4014                                                 CTestExecution& aExecution )
       
  4015     {
       
  4016     CInterferenceHandler* self = 
       
  4017                         new( ELeave ) CInterferenceHandler( aExecution );
       
  4018     CleanupStack::PushL( self );
       
  4019     self->ConstructL();
       
  4020     CleanupStack::Pop( self );
       
  4021     return self;
       
  4022 
       
  4023     }
       
  4024 
       
  4025 /*
       
  4026 -------------------------------------------------------------------------------
       
  4027 
       
  4028     Class: CInterferenceHandler
       
  4029 
       
  4030     Method: ConstructL
       
  4031 
       
  4032     Description: Second level constructor.
       
  4033 
       
  4034     Parameters: None
       
  4035 
       
  4036     Return Values: None
       
  4037 
       
  4038     Errors/Exceptions: None
       
  4039 
       
  4040     Status: Proposal
       
  4041 
       
  4042 -------------------------------------------------------------------------------
       
  4043 */
       
  4044 void CInterferenceHandler::ConstructL()
       
  4045     {
       
  4046 
       
  4047     }
       
  4048 
       
  4049 /*
       
  4050 -------------------------------------------------------------------------------
       
  4051 
       
  4052     Class: CInterferenceHandler
       
  4053 
       
  4054     Method: CInterferenceHandler
       
  4055 
       
  4056     Description: Constructor
       
  4057 
       
  4058     Parameters: CTestModuleContainer& aExecution :in: "Parent"
       
  4059 
       
  4060     Return Values: None
       
  4061 
       
  4062     Errors/Exceptions: None
       
  4063 
       
  4064     Status: Proposal
       
  4065     
       
  4066 -------------------------------------------------------------------------------
       
  4067 */
       
  4068 CInterferenceHandler::CInterferenceHandler( CTestExecution& aExecution ) :
       
  4069     CActive( CActive::EPriorityStandard ),
       
  4070     iExecution( aExecution )
       
  4071     {
       
  4072     CActiveScheduler::Add ( this );
       
  4073     
       
  4074     }
       
  4075 
       
  4076 /*
       
  4077 -------------------------------------------------------------------------------
       
  4078 
       
  4079     Class: CInterferenceHandler
       
  4080 
       
  4081     Method: ~CInterferenceHandler
       
  4082 
       
  4083     Description: Destructor. 
       
  4084     Cancels active request.
       
  4085 
       
  4086     Parameters: None
       
  4087 
       
  4088     Return Values: None
       
  4089 
       
  4090     Errors/Exceptions: None
       
  4091 
       
  4092     Status: Proposal
       
  4093     
       
  4094 -------------------------------------------------------------------------------
       
  4095 */
       
  4096 CInterferenceHandler::~CInterferenceHandler()
       
  4097     {
       
  4098     Cancel();
       
  4099 
       
  4100     }
       
  4101 
       
  4102 /*
       
  4103 -------------------------------------------------------------------------------
       
  4104 
       
  4105     Class: CInterferenceHandler
       
  4106 
       
  4107     Method: StartL
       
  4108 
       
  4109     Description: Starts to monitor thread.
       
  4110 
       
  4111     Parameters: None
       
  4112 
       
  4113     Return Values: TInt: Always KErrNone
       
  4114 
       
  4115     Errors/Exceptions: None
       
  4116 
       
  4117     Status: Proposal
       
  4118     
       
  4119 -------------------------------------------------------------------------------
       
  4120 */
       
  4121 void CInterferenceHandler::StartL()
       
  4122     {
       
  4123     __TRACE( KPrint, ( _L( "CInterferenceHandler::StartL" ) ) );
       
  4124     
       
  4125     if( IsActive() ) 
       
  4126         {
       
  4127         CTestServer::PanicServer( EAlreadyActive );
       
  4128         }
       
  4129 
       
  4130     iStatus = KRequestPending;
       
  4131     SetActive();
       
  4132     
       
  4133     // Signal test thread, Notify test thread that operation is done.
       
  4134     iExecution.iInterferenceSem.Signal();
       
  4135 
       
  4136     }
       
  4137 
       
  4138 /*
       
  4139 -------------------------------------------------------------------------------
       
  4140 
       
  4141     Class: CInterferenceHandler
       
  4142 
       
  4143     Method: RunL
       
  4144 
       
  4145     Description: Handles thread death.
       
  4146     Function does:
       
  4147     1 ) Stops monitoring thread
       
  4148     1 ) Marks thread death
       
  4149     2 ) Completes ongoing requests
       
  4150     3 ) Cleans the memory
       
  4151 
       
  4152     Parameters: None
       
  4153 
       
  4154     Return Values: None
       
  4155 
       
  4156     Errors/Exceptions: None
       
  4157 
       
  4158     Status: Proposal
       
  4159 
       
  4160 -------------------------------------------------------------------------------
       
  4161 */
       
  4162 void CInterferenceHandler::RunL()
       
  4163     {
       
  4164     __TRACE( KPrint, ( _L( "CInterferenceHandler::RunL [%d]" ), iStatus.Int() ) );
       
  4165     
       
  4166     iExecution.DoNotifyInterference();
       
  4167     
       
  4168     StartL();
       
  4169 
       
  4170     }
       
  4171 
       
  4172 /*
       
  4173 -------------------------------------------------------------------------------
       
  4174 
       
  4175     Class: CInterferenceHandler
       
  4176 
       
  4177     Method: DoCancel
       
  4178 
       
  4179     Description: Stops interference notification listening.
       
  4180 
       
  4181     Parameters: None
       
  4182 
       
  4183     Return Values: None
       
  4184 
       
  4185     Errors/Exceptions: None
       
  4186 
       
  4187     Status: Proposal
       
  4188     
       
  4189 -------------------------------------------------------------------------------
       
  4190 */
       
  4191 void CInterferenceHandler::DoCancel()
       
  4192     {
       
  4193     __TRACE( KPrint, ( _L( "CInterferenceHandler::DoCancel" ) ) );
       
  4194 
       
  4195     iExecution.iInterferenceMutex.Wait();   // Take mutex and check test
       
  4196                                             // interference operation. If
       
  4197                                             // pending take interference
       
  4198                                             // semaphore and complete
       
  4199     if( iStatus == KRequestPending )
       
  4200         {
       
  4201     
       
  4202         TRequestStatus* status = &iStatus;    
       
  4203         User::RequestComplete( status, KErrCancel );
       
  4204         }
       
  4205 
       
  4206     iExecution.iInterferenceMutex.Signal();
       
  4207 
       
  4208     }
       
  4209 
       
  4210 /*
       
  4211 -------------------------------------------------------------------------------
       
  4212 
       
  4213     Class: CInterferenceHandler
       
  4214 
       
  4215     Method: RunError
       
  4216 
       
  4217     Description: Handle errors. RunL function does not leave, so one should
       
  4218     never come here. 
       
  4219 
       
  4220     Print trace and let framework handle error( i.e to do Panic )
       
  4221 
       
  4222     Parameters: TInt aError: in: Error code
       
  4223 
       
  4224     Return Values:  TInt: Error code
       
  4225 
       
  4226     Errors/Exceptions: None
       
  4227 
       
  4228     Status: Proposal
       
  4229 
       
  4230 -------------------------------------------------------------------------------
       
  4231 */
       
  4232 TInt CInterferenceHandler::RunError( TInt aError )
       
  4233     {
       
  4234     __TRACE( KError,( _L( "CTestInterferenceHandler::RunError" ) ) );
       
  4235 
       
  4236     return aError;
       
  4237 
       
  4238     }
       
  4239 
       
  4240 /*
       
  4241 -------------------------------------------------------------------------------
       
  4242 
       
  4243     DESCRIPTION
       
  4244 
       
  4245     This module contains implementation of CMeasurementHandler class 
       
  4246     member functions. CMeasurementHandler handles test measurement operations
       
  4247     that comes from test execution side to TestServer side.
       
  4248 
       
  4249 -------------------------------------------------------------------------------
       
  4250 */
       
  4251 
       
  4252 // ================= MEMBER FUNCTIONS =========================================
       
  4253 
       
  4254 
       
  4255 /*
       
  4256 -------------------------------------------------------------------------------
       
  4257 
       
  4258     Class: CMeasurementHandler
       
  4259 
       
  4260     Method: NewL
       
  4261 
       
  4262     Description: Constructs a new CMeasurementHandler object.
       
  4263 
       
  4264     Parameters: CTestExecution& aExecution: in: Pointer to test execution side.
       
  4265 
       
  4266     Return Values: CMeasurementHandler*: New undertaker
       
  4267 
       
  4268     Errors/Exceptions: Leaves if memory allocation or ConstructL leaves.
       
  4269 
       
  4270     Status: Approved
       
  4271 
       
  4272 -------------------------------------------------------------------------------
       
  4273 */
       
  4274 CMeasurementHandler* CMeasurementHandler::NewL( CTestExecution& aExecution )
       
  4275     {
       
  4276     CMeasurementHandler* self = 
       
  4277                         new( ELeave ) CMeasurementHandler( aExecution );
       
  4278     CleanupStack::PushL( self );
       
  4279     self->ConstructL();
       
  4280     CleanupStack::Pop( self );
       
  4281     return self;
       
  4282 
       
  4283     }
       
  4284 
       
  4285 /*
       
  4286 -------------------------------------------------------------------------------
       
  4287 
       
  4288     Class: CMeasurementHandler
       
  4289 
       
  4290     Method: ConstructL
       
  4291 
       
  4292     Description: Second level constructor.
       
  4293 
       
  4294     Parameters: None
       
  4295 
       
  4296     Return Values: None
       
  4297 
       
  4298     Errors/Exceptions: None
       
  4299 
       
  4300     Status: Approved
       
  4301 
       
  4302 -------------------------------------------------------------------------------
       
  4303 */
       
  4304 void CMeasurementHandler::ConstructL()
       
  4305     {
       
  4306 
       
  4307     }
       
  4308 
       
  4309 /*
       
  4310 -------------------------------------------------------------------------------
       
  4311 
       
  4312     Class: CMeasurementHandler
       
  4313 
       
  4314     Method: CMeasurementHandler
       
  4315 
       
  4316     Description: Constructor
       
  4317 
       
  4318     Parameters: CTestModuleContainer& aExecution :in: Pointer to test
       
  4319                 execution side.
       
  4320 
       
  4321     Return Values: None
       
  4322 
       
  4323     Errors/Exceptions: None
       
  4324 
       
  4325     Status: Approved
       
  4326 
       
  4327 -------------------------------------------------------------------------------
       
  4328 */
       
  4329 CMeasurementHandler::CMeasurementHandler( CTestExecution& aExecution ) :
       
  4330     CActive( CActive::EPriorityStandard ),
       
  4331     iExecution( aExecution )
       
  4332     {
       
  4333     CActiveScheduler::Add ( this );
       
  4334 
       
  4335     }
       
  4336 
       
  4337 /*
       
  4338 -------------------------------------------------------------------------------
       
  4339 
       
  4340     Class: CMeasurementHandler
       
  4341 
       
  4342     Method: ~CMeasurementHandler
       
  4343 
       
  4344     Description: Destructor. 
       
  4345     Cancels active request.
       
  4346 
       
  4347     Parameters: None
       
  4348 
       
  4349     Return Values: None
       
  4350 
       
  4351     Errors/Exceptions: None
       
  4352 
       
  4353     Status: Approved
       
  4354 
       
  4355 -------------------------------------------------------------------------------
       
  4356 */
       
  4357 CMeasurementHandler::~CMeasurementHandler()
       
  4358     {
       
  4359     Cancel();
       
  4360 
       
  4361     }
       
  4362 
       
  4363 /*
       
  4364 -------------------------------------------------------------------------------
       
  4365 
       
  4366     Class: CMeasurementHandler
       
  4367 
       
  4368     Method: StartL
       
  4369 
       
  4370     Description: Starts to monitor thread.
       
  4371 
       
  4372     Parameters: None
       
  4373 
       
  4374     Return Values: TInt: Always KErrNone
       
  4375 
       
  4376     Errors/Exceptions: None
       
  4377 
       
  4378     Status: Approved
       
  4379 
       
  4380 -------------------------------------------------------------------------------
       
  4381 */
       
  4382 void CMeasurementHandler::StartL()
       
  4383     {
       
  4384     __TRACE( KPrint, ( _L( "CMeasurementHandler::StartL" ) ) );
       
  4385 
       
  4386     if( IsActive() ) 
       
  4387         {
       
  4388         CTestServer::PanicServer( EAlreadyActive );
       
  4389         }
       
  4390 
       
  4391     iStatus = KRequestPending;
       
  4392     SetActive();
       
  4393 
       
  4394     // Do not Signal here because synchronous operations will be executed and we
       
  4395     // don't want to signal at first time: iExecution.iMeasurementSem.Signal();
       
  4396     // Signal() operation will be handled in RunL in this case.
       
  4397 
       
  4398     }
       
  4399 
       
  4400 /*
       
  4401 -------------------------------------------------------------------------------
       
  4402 
       
  4403     Class: CMeasurementHandler
       
  4404 
       
  4405     Method: RunL
       
  4406 
       
  4407     Description: Derived from CActive, handles test measurement execution.
       
  4408 
       
  4409     Parameters: None
       
  4410 
       
  4411     Return Values: None
       
  4412 
       
  4413     Errors/Exceptions: None
       
  4414 
       
  4415     Status: Approved
       
  4416 
       
  4417 -------------------------------------------------------------------------------
       
  4418 */
       
  4419 void CMeasurementHandler::RunL()
       
  4420     {
       
  4421     __TRACE( KPrint, ( _L( "CMeasurementHandler::RunL [%d]" ), iStatus.Int() ) );
       
  4422     
       
  4423     TInt ret( 0 );
       
  4424     ret = iExecution.DoNotifyMeasurement();
       
  4425 
       
  4426     // ret value is copied to struct so it can be handled later.
       
  4427     iExecution.iTestMeasurement.iMeasurementStruct.iOperationResult = ret;
       
  4428     
       
  4429     // SetActive again
       
  4430     StartL();
       
  4431 
       
  4432     // TestServer side operations are done, Signal that operation is done.
       
  4433     iExecution.iMeasurementSem.Signal();
       
  4434 
       
  4435     }
       
  4436 
       
  4437 /*
       
  4438 -------------------------------------------------------------------------------
       
  4439 
       
  4440     Class: CMeasurementHandler
       
  4441 
       
  4442     Method: DoCancel
       
  4443 
       
  4444     Description: Stops measurement notification listening.
       
  4445 
       
  4446     Parameters: None
       
  4447 
       
  4448     Return Values: None
       
  4449 
       
  4450     Errors/Exceptions: None
       
  4451 
       
  4452     Status: Approved
       
  4453     
       
  4454 -------------------------------------------------------------------------------
       
  4455 */
       
  4456 void CMeasurementHandler::DoCancel()
       
  4457     {
       
  4458     __TRACE( KPrint, ( _L( "CMeasurementHandler::DoCancel" ) ) );
       
  4459 
       
  4460     iExecution.iMeasurementMutex.Wait();    // Take mutex and check test
       
  4461                                             // measurement operation. If
       
  4462                                             // pending take measurement
       
  4463                                             // semaphore and complete
       
  4464     if( iStatus == KRequestPending )
       
  4465         {
       
  4466     
       
  4467         TRequestStatus* status = &iStatus;    
       
  4468         User::RequestComplete( status, KErrCancel );
       
  4469         }
       
  4470 
       
  4471     iExecution.iMeasurementMutex.Signal();
       
  4472 
       
  4473     }
       
  4474 
       
  4475 /*
       
  4476 -------------------------------------------------------------------------------
       
  4477 
       
  4478     Class: CMeasurementHandler
       
  4479 
       
  4480     Method: RunError
       
  4481 
       
  4482     Description: Handle errors. RunL function does not leave, so one should
       
  4483     never come here. 
       
  4484 
       
  4485     Print trace and let framework handle error( i.e to do Panic )
       
  4486 
       
  4487     Parameters: TInt aError: in: Error code
       
  4488 
       
  4489     Return Values:  TInt: Error code
       
  4490 
       
  4491     Errors/Exceptions: None
       
  4492 
       
  4493     Status: Approved
       
  4494 
       
  4495 -------------------------------------------------------------------------------
       
  4496 */
       
  4497 TInt CMeasurementHandler::RunError( TInt aError )
       
  4498     {
       
  4499     __TRACE( KError,( 
       
  4500         _L( "CMeasurementHandler::RunError with error: %d" ), aError ) );
       
  4501 
       
  4502     return aError;
       
  4503 
       
  4504     }
       
  4505 
       
  4506 /*
       
  4507 -------------------------------------------------------------------------------
       
  4508 
       
  4509     DESCRIPTION
       
  4510 
       
  4511     This module contains implementation of CCommandHandler class member functions.
       
  4512     CCommandHandler listens command notifications from test thread.
       
  4513 
       
  4514 -------------------------------------------------------------------------------
       
  4515 */
       
  4516 
       
  4517 // ================= MEMBER FUNCTIONS =========================================
       
  4518 
       
  4519 
       
  4520 /*
       
  4521 -------------------------------------------------------------------------------
       
  4522 
       
  4523     Class: CCommandHandler
       
  4524 
       
  4525     Method: NewL
       
  4526 
       
  4527     Description: Constructs a new CCommandHandler object.
       
  4528 
       
  4529     Parameters: CTestExecution& aExecution: in: "Parent"
       
  4530 
       
  4531     Return Values: CCommandHandler*: New object
       
  4532 
       
  4533     Errors/Exceptions: Leaves if memory allocation or ConstructL leaves.
       
  4534 
       
  4535     Status: Proposal
       
  4536 
       
  4537 -------------------------------------------------------------------------------
       
  4538 */
       
  4539 CCommandHandler* CCommandHandler::NewL(CTestExecution& aExecution)
       
  4540     {
       
  4541     CCommandHandler* self = new (ELeave) CCommandHandler(aExecution);
       
  4542     CleanupStack::PushL(self);
       
  4543     self->ConstructL();
       
  4544     CleanupStack::Pop(self);
       
  4545     return self;
       
  4546     }
       
  4547 
       
  4548 /*
       
  4549 -------------------------------------------------------------------------------
       
  4550 
       
  4551     Class: CCommandHandler
       
  4552 
       
  4553     Method: ConstructL
       
  4554 
       
  4555     Description: Second level constructor.
       
  4556 
       
  4557     Parameters: None
       
  4558 
       
  4559     Return Values: None
       
  4560 
       
  4561     Errors/Exceptions: None
       
  4562 
       
  4563     Status: Proposal
       
  4564 
       
  4565 -------------------------------------------------------------------------------
       
  4566 */
       
  4567 void CCommandHandler::ConstructL()
       
  4568     {
       
  4569     }
       
  4570 
       
  4571 /*
       
  4572 -------------------------------------------------------------------------------
       
  4573 
       
  4574     Class: CCommandHandler
       
  4575 
       
  4576     Method: CCommandHandler
       
  4577 
       
  4578     Description: Constructor
       
  4579 
       
  4580     Parameters: CTestExecution& aExecution :in:   "Parent"
       
  4581 
       
  4582     Return Values: None
       
  4583 
       
  4584     Errors/Exceptions: None
       
  4585 
       
  4586     Status: Proposal
       
  4587 
       
  4588 -------------------------------------------------------------------------------
       
  4589 */
       
  4590 CCommandHandler::CCommandHandler(CTestExecution& aExecution):
       
  4591     CActive(CActive::EPriorityStandard),
       
  4592     iExecution(aExecution)
       
  4593     {
       
  4594     CActiveScheduler::Add (this);
       
  4595     }
       
  4596 
       
  4597 /*
       
  4598 -------------------------------------------------------------------------------
       
  4599 
       
  4600     Class: CCommandHandler
       
  4601 
       
  4602     Method: ~CCommandHandler
       
  4603 
       
  4604     Description: Destructor.
       
  4605     Cancels active request.
       
  4606 
       
  4607     Parameters: None
       
  4608 
       
  4609     Return Values: None
       
  4610 
       
  4611     Errors/Exceptions: None
       
  4612 
       
  4613     Status: Proposal
       
  4614 
       
  4615 -------------------------------------------------------------------------------
       
  4616 */
       
  4617 CCommandHandler::~CCommandHandler()
       
  4618     {
       
  4619     Cancel();
       
  4620     }
       
  4621 
       
  4622 /*
       
  4623 -------------------------------------------------------------------------------
       
  4624 
       
  4625     Class: CCommandHandler
       
  4626 
       
  4627     Method: StartL
       
  4628 
       
  4629     Description: Starts to monitor thread.
       
  4630 
       
  4631     Parameters: None
       
  4632 
       
  4633     Return Values: None
       
  4634 
       
  4635     Errors/Exceptions: None
       
  4636 
       
  4637     Status: Proposal
       
  4638 
       
  4639 -------------------------------------------------------------------------------
       
  4640 */
       
  4641 void CCommandHandler::StartL()
       
  4642     {
       
  4643     __TRACE(KPrint, (_L( "CCommandHandler::StartL" )));
       
  4644 
       
  4645     if(IsActive())
       
  4646         {
       
  4647         CTestServer::PanicServer(EAlreadyActive);
       
  4648         }
       
  4649     iStatus = KRequestPending;
       
  4650     SetActive();
       
  4651 
       
  4652     // Signal test thread
       
  4653     iExecution.iCommandSem.Signal();
       
  4654     }
       
  4655 
       
  4656 /*
       
  4657 -------------------------------------------------------------------------------
       
  4658 
       
  4659     Class: CCommandHandler
       
  4660 
       
  4661     Method: RunL
       
  4662 
       
  4663     Description:
       
  4664 
       
  4665     Parameters: None
       
  4666 
       
  4667     Return Values: None
       
  4668 
       
  4669     Errors/Exceptions: None
       
  4670 
       
  4671     Status: Proposal
       
  4672 
       
  4673 -------------------------------------------------------------------------------
       
  4674 */
       
  4675 void CCommandHandler::RunL()
       
  4676     {
       
  4677     __TRACE(KPrint, (_L( "CCommandHandler::RunL [%d]"), iStatus.Int()));
       
  4678 
       
  4679     iExecution.DoNotifyCommand();
       
  4680 //    StartL();
       
  4681     }
       
  4682 
       
  4683 
       
  4684 /*
       
  4685 -------------------------------------------------------------------------------
       
  4686 
       
  4687     Class: CCommandHandler
       
  4688 
       
  4689     Method: DoCancel
       
  4690 
       
  4691     Description: Stops command notification listening.
       
  4692 
       
  4693     Parameters: None
       
  4694 
       
  4695     Return Values: None
       
  4696 
       
  4697     Errors/Exceptions: None
       
  4698 
       
  4699     Status: Proposal
       
  4700 
       
  4701 -------------------------------------------------------------------------------
       
  4702 */
       
  4703 
       
  4704 void CCommandHandler::DoCancel()
       
  4705     {
       
  4706     __TRACE(KPrint, (_L("CCommandHandler::DoCancel")));
       
  4707 
       
  4708     iExecution.iCommandMutex.Wait();  // Take mutex and check test case receive
       
  4709                                       // operation. If pending take reveive
       
  4710                                       // semaphore and complete
       
  4711     if(iStatus == KRequestPending)
       
  4712         {
       
  4713         TRequestStatus* status = &iStatus;
       
  4714         User::RequestComplete(status, KErrCancel);
       
  4715         }
       
  4716 
       
  4717     iExecution.iCommandMutex.Signal();
       
  4718     }
       
  4719 
       
  4720 /*
       
  4721 -------------------------------------------------------------------------------
       
  4722 
       
  4723     Class: CCommandHandler
       
  4724 
       
  4725     Method: RunError
       
  4726 
       
  4727     Description: Handle errors. RunL function does not leave, so one should
       
  4728     never come here.
       
  4729 
       
  4730     Print trace and let framework handle error( i.e to do Panic )
       
  4731 
       
  4732     Parameters: TInt aError:                  :in:  Error code
       
  4733 
       
  4734     Return Values:  TInt                            Error code
       
  4735 
       
  4736     Errors/Exceptions: None
       
  4737 
       
  4738     Status: Proposal
       
  4739 
       
  4740 -------------------------------------------------------------------------------
       
  4741 */
       
  4742 TInt CCommandHandler::RunError(TInt aError)
       
  4743     {
       
  4744     __TRACE(KError, (_L("CCommandHandler::RunError")));
       
  4745 
       
  4746     return aError;
       
  4747     }
       
  4748 
       
  4749 /*
       
  4750 -------------------------------------------------------------------------------
       
  4751 
       
  4752     Class: CCommandDef
       
  4753 
       
  4754     Method: CCommandDef
       
  4755 
       
  4756     Description: private constructor
       
  4757 
       
  4758     Return Values:  void
       
  4759 
       
  4760 -------------------------------------------------------------------------------
       
  4761 */
       
  4762 
       
  4763 CCommandDef::CCommandDef()
       
  4764 	{
       
  4765 	}
       
  4766 
       
  4767 /*
       
  4768 -------------------------------------------------------------------------------
       
  4769 
       
  4770     Class: CCommandDef
       
  4771 
       
  4772     Method: ConstructL
       
  4773 
       
  4774     Description: Second phase constructor
       
  4775 
       
  4776     Return Values:  void
       
  4777 
       
  4778 -------------------------------------------------------------------------------
       
  4779 */
       
  4780 
       
  4781 void CCommandDef::ConstructL()
       
  4782 	{
       
  4783 
       
  4784 	}
       
  4785 
       
  4786 /*
       
  4787 -------------------------------------------------------------------------------
       
  4788 
       
  4789     Class: CCommandDef
       
  4790 
       
  4791     Method: NewL
       
  4792 
       
  4793     Description: First phase constructor
       
  4794 
       
  4795     Return Values:  void
       
  4796 
       
  4797 -------------------------------------------------------------------------------
       
  4798 */
       
  4799 
       
  4800 CCommandDef* CCommandDef::NewL()
       
  4801 	{
       
  4802 	CCommandDef* self = new(ELeave) CCommandDef;
       
  4803 	CleanupStack::PushL(self);
       
  4804 	self->ConstructL();
       
  4805 	CleanupStack::Pop(self);
       
  4806 	return self;
       
  4807 	}
       
  4808 
       
  4809 /*
       
  4810 -------------------------------------------------------------------------------
       
  4811 
       
  4812     Class: CCommandDef
       
  4813 
       
  4814     Method: ~CCommandDef
       
  4815 
       
  4816     Description: destructor
       
  4817 
       
  4818 -------------------------------------------------------------------------------
       
  4819 */
       
  4820 
       
  4821 CCommandDef::~CCommandDef()
       
  4822 	{
       
  4823 
       
  4824 	}
       
  4825 
       
  4826 //  End of File