stif/TestInterface/src/TestModuleIf.cpp
changeset 0 a03f92240627
child 8 cfe32394fcd5
equal deleted inserted replaced
-1:000000000000 0:a03f92240627
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description: This file contains TestModuleIf implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <e32svr.h>
       
    20 #include "StifTFwIfProt.h"
       
    21 #include "StifTestInterface.h"
       
    22 #include "TestServerModuleIf.h"
       
    23 #include "StifTestModule.h"
       
    24 #include "TestThreadContainer.h"
       
    25 #include "STIFMeasurement.h"
       
    26 
       
    27 // EXTERNAL DATA STRUCTURES
       
    28 // None
       
    29 
       
    30 // EXTERNAL FUNCTION PROTOTYPES  
       
    31 // None
       
    32 
       
    33 // CONSTANTS
       
    34 // None
       
    35 
       
    36 // MACROS
       
    37 // Debugging is enabled with next define
       
    38 #define __TRACING_ENABLED
       
    39 #ifdef __TRACING_ENABLED
       
    40 #define __RDEBUG(p) RDebug::Print p 
       
    41 #else
       
    42 #define __RDEBUG(p)
       
    43 #endif
       
    44 
       
    45 // LOCAL CONSTANTS AND MACROS
       
    46 // None
       
    47 
       
    48 // MODULE DATA STRUCTURES
       
    49 // None
       
    50 
       
    51 // LOCAL FUNCTION PROTOTYPES
       
    52 // None
       
    53 
       
    54 // FORWARD DECLARATIONS
       
    55 // None
       
    56 
       
    57 // ==================== LOCAL FUNCTIONS =======================================
       
    58 
       
    59 /*
       
    60 -------------------------------------------------------------------------------
       
    61 
       
    62     DESCRIPTION
       
    63 
       
    64     TDesOverflowHandler class contains a simple overflow handler implementation.
       
    65 
       
    66 -------------------------------------------------------------------------------
       
    67 */
       
    68 class TDesOverflowHandler : public TDes16Overflow
       
    69     {
       
    70     public:
       
    71         TDesOverflowHandler( CTestModuleIf* aModuleIf, 
       
    72                              const TInt aPriority, 
       
    73                              const TDesC& aDefinition)
       
    74             {
       
    75             iModuleIf = aModuleIf;
       
    76             iPriority = aPriority;
       
    77             iDefinition = aDefinition;
       
    78             }
       
    79 
       
    80         void Overflow(TDes16& /*aDes*/ )
       
    81             { 
       
    82             }
       
    83     
       
    84         CTestModuleIf* iModuleIf;
       
    85         TInt iPriority;
       
    86         TStifInfoName iDefinition;
       
    87     };
       
    88 
       
    89 /*
       
    90 -------------------------------------------------------------------------------
       
    91 
       
    92     DESCRIPTION
       
    93 
       
    94     This module contains the implementation of CTestModuleIf class 
       
    95     member functions.
       
    96 
       
    97 -------------------------------------------------------------------------------
       
    98 */
       
    99 
       
   100 // ================= MEMBER FUNCTIONS =========================================
       
   101 
       
   102 /*
       
   103 -------------------------------------------------------------------------------
       
   104 
       
   105     Class: CTestModuleIf
       
   106 
       
   107     Method: CTestModuleIf
       
   108 
       
   109     Description: Default constructor
       
   110 
       
   111     C++ default constructor can NOT contain any code, that
       
   112     might leave.
       
   113     
       
   114     Parameters: None
       
   115     
       
   116     Return Values: None
       
   117     
       
   118     Errors/Exceptions: None
       
   119     
       
   120     Status: Approved
       
   121     
       
   122 -------------------------------------------------------------------------------
       
   123 */
       
   124 CTestModuleIf::CTestModuleIf( CTestThreadContainer* aTestExecution ) :
       
   125     iTestExecution( aTestExecution )
       
   126     {
       
   127     }
       
   128 
       
   129 /*
       
   130 -------------------------------------------------------------------------------
       
   131 
       
   132     Class: CTestModuleIf
       
   133 
       
   134     Method: ConstructL
       
   135 
       
   136     Description: Symbian OS second phase constructor
       
   137 
       
   138     Symbian OS default constructor can leave.
       
   139 
       
   140     Parameters: CTestExecution* aTestExecution: in: Pointer to TestExecution
       
   141                 CTestModuleBase* aTestModule: in: Pointer to TestModule
       
   142     
       
   143     Return Values: None
       
   144     
       
   145     Errors/Exceptions: None
       
   146     
       
   147     Status: Approved
       
   148     
       
   149 -------------------------------------------------------------------------------
       
   150 */
       
   151 void CTestModuleIf::ConstructL( CTestModuleBase* aTestModule )
       
   152     {
       
   153 
       
   154     if ( aTestModule->iTestModuleIf != NULL)
       
   155         {
       
   156         delete aTestModule->iTestModuleIf;
       
   157         aTestModule->iTestModuleIf = NULL;
       
   158         }
       
   159     aTestModule->iTestModuleIf = this; 
       
   160 
       
   161     iIsRebootReady = EFalse;
       
   162     iStoreStateCounter = 0;
       
   163 
       
   164     // Used to "resets" iTestCaseResults array
       
   165     iAllowTestCaseResultsCount = 0;
       
   166 
       
   167     }
       
   168 
       
   169 /*
       
   170 -------------------------------------------------------------------------------
       
   171 
       
   172     Class: CTestModuleIf
       
   173 
       
   174     Method: NewL
       
   175 
       
   176     Description: Two-phased constructor.
       
   177 
       
   178     Parameters: CTestExecution* aTestExecution: in: Pointer to TestExecution
       
   179                 CTestModuleBase* aTestModule: in: Pointer to TestModule
       
   180     
       
   181     Return Values: CTestModuleIf object.
       
   182 
       
   183     Errors/Exceptions: Leaves if memory allocation fails
       
   184                        Leaves if ConstructL leaves
       
   185 
       
   186     Status: Approved
       
   187     
       
   188 -------------------------------------------------------------------------------
       
   189 */
       
   190 EXPORT_C CTestModuleIf* CTestModuleIf::NewL( CTestThreadContainer* aExecutionSession, 
       
   191                                              CTestModuleBase* aTestModule )
       
   192     {
       
   193 
       
   194     CTestModuleIf* self = 
       
   195         new (ELeave) CTestModuleIf( aExecutionSession );
       
   196     
       
   197     CleanupStack::PushL( self );
       
   198     self->ConstructL( aTestModule );
       
   199 
       
   200     CleanupStack::Pop();
       
   201 
       
   202     return self;
       
   203 
       
   204     }
       
   205 
       
   206 /*
       
   207 -------------------------------------------------------------------------------
       
   208 
       
   209     Class: CTestModuleIf
       
   210 
       
   211     Method: ~CTestModuleIf
       
   212 
       
   213     Description: Destructor
       
   214     
       
   215     Parameters: None
       
   216     
       
   217     Return Values: None
       
   218 
       
   219     Errors/Exceptions: None
       
   220     
       
   221     Status: Approved
       
   222     
       
   223 -------------------------------------------------------------------------------
       
   224 */    
       
   225 CTestModuleIf::~CTestModuleIf()
       
   226     {
       
   227     iTestExecution = NULL;
       
   228 
       
   229     // Used to "resets" iTestCaseResults array
       
   230     iAllowTestCaseResultsCount = 0;
       
   231 
       
   232     }
       
   233 
       
   234 /*
       
   235 -------------------------------------------------------------------------------
       
   236 
       
   237     Class: CTestModuleIf
       
   238 
       
   239     Method: Printf
       
   240 
       
   241     Description: Printing
       
   242 
       
   243     Printf is used to provide different information up to the UI 
       
   244     that can be then printed e.g. to the Console Screen. 
       
   245     The priority can be used in the UI to decide if the information 
       
   246     received from the Test DLL will be discarded or not in 
       
   247     the different performance situations. The priority is also 
       
   248     used in the Test DLL server and in the Test Engine to queue 
       
   249     the Printf responses.
       
   250     This method is implemented in Test DLL Server and the Test DLL 
       
   251     can call it to provide printable information to the UI.
       
   252 
       
   253     Parameters:  const TInt aPriority: in: 
       
   254                     Importance of the returned information
       
   255                  const TDesC& aDefinition: in: 
       
   256                     Definition of data to be printed 
       
   257                  TRefByValue<const TDesC> aFmt: in: Printed data
       
   258     
       
   259     Return Values: None
       
   260     
       
   261     Errors/Exceptions: None
       
   262     
       
   263     Status: Approved
       
   264     
       
   265 -------------------------------------------------------------------------------
       
   266 */
       
   267 EXPORT_C void CTestModuleIf::Printf( const TInt aPriority, 
       
   268                                      const TDesC& aDefinition, 
       
   269                                      TRefByValue<const TDesC> aFmt,
       
   270                                      ... 
       
   271                                    )
       
   272     {           
       
   273 
       
   274     if( !IsServerAlive() )
       
   275         {
       
   276         return;
       
   277         }
       
   278 
       
   279     VA_LIST list;
       
   280     VA_START(list,aFmt);
       
   281     TName aBuf;
       
   282 
       
   283     // Cut the description length
       
   284     TInt len = aDefinition.Length();
       
   285     if ( len > KMaxInfoName )
       
   286         {
       
   287         len = KMaxInfoName;
       
   288         }
       
   289 
       
   290     TStifInfoName shortDescription = aDefinition.Left(len);
       
   291 
       
   292     // Create overflow handler
       
   293     TDesOverflowHandler overFlowHandler (this, aPriority, shortDescription);
       
   294 
       
   295     // Parse parameters
       
   296     aBuf.AppendFormatList(aFmt,list, &overFlowHandler);        
       
   297 
       
   298     // Print
       
   299     iTestExecution->DoNotifyPrint( aPriority, shortDescription, aBuf );
       
   300 
       
   301     }
       
   302 
       
   303 /*
       
   304 -------------------------------------------------------------------------------
       
   305 
       
   306     Class: CTestModuleIf
       
   307 
       
   308     Method: Event
       
   309 
       
   310     Description: Event control.
       
   311 
       
   312     Event function is used to control and use the event system. 
       
   313     TEventIf &aEvent encapsulates the request type and 
       
   314     the event name, see StifTestEventInterface.h for more information.
       
   315     This method is implemented in Test DLL Server and the Test DLL 
       
   316     can call it to control the event system.
       
   317   
       
   318     Parameters: TEventIf& aEvent: in: Event command
       
   319     
       
   320     Return Values: Symbian OS error code.
       
   321 
       
   322     Errors/Exceptions: None
       
   323 
       
   324     Status: Approved
       
   325     
       
   326 -------------------------------------------------------------------------------
       
   327 */      
       
   328 EXPORT_C TInt CTestModuleIf::Event( TEventIf& aEvent )
       
   329     {
       
   330 
       
   331     if( !IsServerAlive() )
       
   332         {
       
   333         return KErrGeneral;
       
   334         }
       
   335 
       
   336     // All event commands are handled in testserver and testengine
       
   337     return iTestExecution->DoNotifyEvent( aEvent );
       
   338     
       
   339     }
       
   340 
       
   341 /*
       
   342 -------------------------------------------------------------------------------
       
   343 
       
   344     Class: CTestModuleIf
       
   345 
       
   346     Method: Event
       
   347 
       
   348     Description: Event control.
       
   349 
       
   350     Asynchronous version of event control function.
       
   351     It is used to control and use the event system asynchronously. 
       
   352     TEventIf &aEvent encapsulates the request type and 
       
   353     the event number, see StifTestEventInterface.h for more information.
       
   354     This method is implemented in Test DLL Server and the Test DLL 
       
   355     can call it to control the event system.
       
   356   
       
   357     Parameters: TEventIf& aEvent: in: Event command
       
   358                 TRequestStatus& aStatus: in: Request status parameter
       
   359 
       
   360     Return Values: None. 
       
   361     
       
   362     Errors/Exceptions: None
       
   363 
       
   364     Status: Approved
       
   365     
       
   366 -------------------------------------------------------------------------------
       
   367 */      
       
   368 EXPORT_C void CTestModuleIf::Event( TEventIf& aEvent, TRequestStatus& aStatus )
       
   369     {
       
   370     TInt ret = KErrNone;
       
   371 
       
   372     if( !IsServerAlive() )
       
   373         {
       
   374         __RDEBUG( (_L("iTestExecution not initialised")));
       
   375         ret = KErrGeneral;
       
   376         }
       
   377     else
       
   378         {        
       
   379         aStatus = KRequestPending;
       
   380 
       
   381         // All event commands are handled in testserver and testengine
       
   382         ret = iTestExecution->DoNotifyEvent( aEvent, &aStatus );
       
   383         }
       
   384     if( ret != KErrNone )
       
   385         {
       
   386         TRequestStatus* rs = &aStatus;
       
   387         User::RequestComplete( rs, ret );
       
   388         }
       
   389     
       
   390     }
       
   391     
       
   392 /*
       
   393 -------------------------------------------------------------------------------
       
   394 
       
   395     Class: CTestModuleIf
       
   396 
       
   397     Method: CancelEvent
       
   398 
       
   399     Description: Cancel asynchronous event control call.
       
   400   
       
   401     Parameters: TEventIf& aEvent: in: Event command to be cancelled.
       
   402                 const TRequestStatus* aStatus: in: 
       
   403                     Pointer to TRequestStatus parameter that is cancelled
       
   404 
       
   405     Return Values: Symbian OS error code.
       
   406     
       
   407     Errors/Exceptions: None
       
   408     
       
   409     Status: Approved
       
   410     
       
   411 -------------------------------------------------------------------------------
       
   412 */      
       
   413 EXPORT_C TInt CTestModuleIf::CancelEvent( TEventIf& aEvent,
       
   414                                           TRequestStatus* aStatus )
       
   415     {
       
   416      if( !IsServerAlive() )
       
   417         {
       
   418         __RDEBUG( (_L("iTestExecution not initialised")));
       
   419         return KErrGeneral;
       
   420         }
       
   421 
       
   422     // All event commands are handled in testserver and testengine
       
   423     iTestExecution->CancelEvent( aEvent, aStatus );
       
   424     
       
   425     return KErrNone;
       
   426     
       
   427     }
       
   428 
       
   429 
       
   430 /*
       
   431 -------------------------------------------------------------------------------
       
   432 
       
   433     Class: CTestModuleIf
       
   434 
       
   435     Method: SetExitReason
       
   436 
       
   437     Description: Set exit reason
       
   438   
       
   439     Parameters: const TExitReason aExitReason in: Exit reason
       
   440                 const TInt aExitCode in: Exit code
       
   441 
       
   442     Return Values: None
       
   443     
       
   444     Errors/Exceptions: None
       
   445     
       
   446     Status: Proposal
       
   447     
       
   448 -------------------------------------------------------------------------------
       
   449 */      
       
   450 EXPORT_C void CTestModuleIf::SetExitReason( const CTestModuleIf::TExitReason aExitReason, 
       
   451                                             const TInt aExitCode )
       
   452         
       
   453     {
       
   454 
       
   455      if( !IsServerAlive() )
       
   456         {
       
   457         __RDEBUG( (_L("iTestExecution not initialised")));
       
   458         return;
       
   459         }
       
   460     
       
   461     iTestExecution->SetExitReason( aExitReason, aExitCode );
       
   462     
       
   463     }
       
   464 
       
   465 /*
       
   466 -------------------------------------------------------------------------------
       
   467 
       
   468     Class: CTestModuleIf
       
   469 
       
   470     Method: RemoteSend
       
   471 
       
   472     Description: RemoteSend is used to send control protocol messages to slaves
       
   473         (e.g. another phone, call box, ...). 
       
   474     
       
   475     Parameters:  const TDesC& aRemoteMsg: in: 
       
   476                     Remote command protocol message 
       
   477                  
       
   478     Return Values: None
       
   479     
       
   480     Errors/Exceptions: None
       
   481     
       
   482     Status: Proposal
       
   483     
       
   484 -------------------------------------------------------------------------------
       
   485 */
       
   486 EXPORT_C TInt CTestModuleIf::RemoteSend( const TDesC& aRemoteMsg )
       
   487     {           
       
   488 
       
   489     if( !IsServerAlive() )
       
   490         {
       
   491         __RDEBUG( ( _L("iTestExecution not initialised") ) );
       
   492         return KErrNotReady;
       
   493         }
       
   494 
       
   495     TParams params;
       
   496     params.aRemoteMsgConstRef = &aRemoteMsg;
       
   497 
       
   498     TRequestStatus status = KRequestPending; 
       
   499 
       
   500     // Forward
       
   501     iTestExecution->DoRemoteReceive( EStifCmdSend, params, 
       
   502                                      aRemoteMsg.Length(), status );
       
   503     
       
   504     User::WaitForRequest( status );
       
   505 
       
   506     return status.Int();
       
   507 
       
   508     }
       
   509     
       
   510 /*
       
   511 -------------------------------------------------------------------------------
       
   512 
       
   513     Class: CTestModuleIf
       
   514 
       
   515     Method: RemoteReceive
       
   516 
       
   517     Description: RemoteReceive is used to receive control protocol messages to 
       
   518         slaves (e.g. another phone, call box, ...). 
       
   519     
       
   520     Parameters:  const TDesC& aRemoteMsg: in: 
       
   521                     Remote command protocol message 
       
   522                  TRequestStatus& aStatus: in: Request status parameter
       
   523 
       
   524     Return Values: None
       
   525     
       
   526     Errors/Exceptions: None
       
   527     
       
   528     Status: Proposal
       
   529     
       
   530 -------------------------------------------------------------------------------
       
   531 */
       
   532 EXPORT_C void CTestModuleIf::RemoteReceive( TDes& aRemoteMsg, 
       
   533                                             TRequestStatus& aStatus )
       
   534     {           
       
   535     aStatus = KRequestPending;
       
   536     if( !IsServerAlive() )
       
   537         {
       
   538         __RDEBUG( ( _L("iTestExecution not initialised") ) );
       
   539         TRequestStatus* rs = &aStatus;
       
   540         User::RequestComplete( rs, KErrNotReady );
       
   541         }
       
   542 
       
   543     TParams params;
       
   544     params.aRemoteMsgRef = &aRemoteMsg;
       
   545 
       
   546     iTestExecution->DoRemoteReceive( EStifCmdReceive, params, 
       
   547                                      aRemoteMsg.Length(), aStatus );
       
   548 
       
   549     }
       
   550     
       
   551 /*
       
   552 -------------------------------------------------------------------------------
       
   553 
       
   554     Class: CTestModuleIf
       
   555 
       
   556     Method: RemoteReceiveCancel
       
   557 
       
   558     Description: RemoteReceiveCancel is used to cancel RemoteReceive.
       
   559      
       
   560     Parameters:  None
       
   561     
       
   562     Return Values: None
       
   563     
       
   564     Errors/Exceptions: None
       
   565     
       
   566     Status: Proposal
       
   567     
       
   568 -------------------------------------------------------------------------------
       
   569 */
       
   570 EXPORT_C void CTestModuleIf::RemoteReceiveCancel()
       
   571     {           
       
   572     if( !IsServerAlive() )
       
   573         {
       
   574         __RDEBUG( ( _L("iTestExecution not initialised") ) );
       
   575         return;
       
   576         }
       
   577 
       
   578     // Forward
       
   579     iTestExecution->DoRemoteReceiveCancel();
       
   580 
       
   581     }
       
   582 
       
   583 /*
       
   584 -------------------------------------------------------------------------------
       
   585 
       
   586     Class: CTestModuleIf
       
   587 
       
   588     Method: Reboot
       
   589 
       
   590     Description: Start a reboot operation.
       
   591 
       
   592     Parameters: TInt aType: in: Reboot type
       
   593 
       
   594     Return Values: TInt: Symbian OS error code.
       
   595 
       
   596     Errors/Exceptions: KErrNotReady returned if iTestExecution is NULL.
       
   597                        KErrNotReady returned if reboot not allowed(Store state
       
   598                        not called).
       
   599 
       
   600     Status: Proposal
       
   601 
       
   602 -------------------------------------------------------------------------------
       
   603 */
       
   604 EXPORT_C TInt CTestModuleIf::Reboot( TInt aType )
       
   605     {           
       
   606     if ( !IsServerAlive() )
       
   607         {
       
   608         __RDEBUG( ( _L( "iTestExecution not initialised" ) ) );
       
   609         return KErrNotReady;
       
   610         }
       
   611     if( !iIsRebootReady )
       
   612         {
       
   613         __RDEBUG( ( _L( "Reboot operation not ready" ) ) );
       
   614         return KErrNotReady;
       
   615         }
       
   616      
       
   617 /*    switch( aType )
       
   618         {
       
   619         case EDefaultReset:
       
   620             __RDEBUG( ( _L( "Reboot, type default" )) );
       
   621             break;
       
   622         case EKernelReset:
       
   623             __RDEBUG( ( _L( "Reboot, type KernelReset" )) );
       
   624             break;
       
   625         case EDeviceReset0:
       
   626             __RDEBUG( ( _L( "Reboot, type Reset 0" )) );
       
   627             break;
       
   628         case EDeviceReset1:
       
   629             __RDEBUG( ( _L( "Reboot, type Reset 1" )) );
       
   630             break;
       
   631         case EDeviceReset2:
       
   632             __RDEBUG( ( _L( "Reboot, type Reset 2" )) );
       
   633             break;
       
   634         case EDeviceReset3:
       
   635             __RDEBUG( ( _L( "Reboot, type Reset 3" )) );
       
   636             break;
       
   637         case EDeviceReset4:
       
   638             __RDEBUG( ( _L( "Reboot, type Reset 4" )) );
       
   639             break;
       
   640         case EDeviceReset5:
       
   641             __RDEBUG( ( _L( "Reboot, type Reset 5" )) );
       
   642             break;
       
   643         default:
       
   644             __RDEBUG( ( _L( "Reboot type %d not supported" ), aType ) );
       
   645             return KErrNotSupported;    
       
   646         }
       
   647 */
       
   648 
       
   649     TParams params;
       
   650     TRebootParams rebootParams;
       
   651     
       
   652     params.aRebootType = &rebootParams;
       
   653     rebootParams.aType = ( TRebootType )aType;
       
   654     
       
   655     TRequestStatus status = KRequestPending; 
       
   656 
       
   657     // Forward
       
   658     iTestExecution->DoRemoteReceive( EStifCmdReboot, params, sizeof( aType ), status );
       
   659     
       
   660     User::WaitForRequest( status );
       
   661 
       
   662     return status.Int();
       
   663     
       
   664     }
       
   665 
       
   666 /*
       
   667 -------------------------------------------------------------------------------
       
   668 
       
   669     Class: CTestModuleIf
       
   670 
       
   671     Method: StoreState
       
   672 
       
   673     Description: Stores the current state before reboot.
       
   674 
       
   675     Parameters: TInt aCode: in: Reboot releated integer value.
       
   676                 TName& aName: in: Reboot related string value.
       
   677 
       
   678     Return Values: TInt: Symbian OS error code.
       
   679 
       
   680     Errors/Exceptions: KErrNotReady returned if iTestExecution is NULL.
       
   681                        KErrOverflow returned if aName length is over TName.
       
   682                        KErrInUse returned if method is called more than once.
       
   683 
       
   684     Status: Proposal
       
   685 
       
   686 -------------------------------------------------------------------------------
       
   687 */
       
   688 EXPORT_C TInt CTestModuleIf::StoreState( TInt aCode, TName& aName )
       
   689     {
       
   690     iStoreStateCounter++;   // Store state counter
       
   691 
       
   692     if ( !IsServerAlive() )
       
   693         {
       
   694         __RDEBUG( ( _L( "iTestExecution not initialised" ) ) );
       
   695         return KErrNotReady;
       
   696         }
       
   697     // Check aName length
       
   698     if ( aName.Length() > KMaxName )
       
   699         {
       
   700         __RDEBUG( ( _L( "CTestModuleIf::StoreState(): aName length is not valid" ) ) );
       
   701         return KErrOverflow;
       
   702         }
       
   703     // Only one store state call may be done
       
   704     if( iStoreStateCounter > 1 )
       
   705         {
       
   706         __RDEBUG( ( _L( "Store state allready called" ) ) );
       
   707         return KErrInUse;
       
   708         }
       
   709 
       
   710     TParams params;
       
   711     TRebootStateParams rebootStateParams;
       
   712     params.aRebootState = &rebootStateParams;
       
   713     rebootStateParams.aCode = aCode;
       
   714     rebootStateParams.aName = aName;
       
   715 
       
   716     TRequestStatus status = KRequestPending; 
       
   717 
       
   718     // Forward
       
   719     iTestExecution->DoRemoteReceive( EStifCmdStoreState, params,
       
   720                                      sizeof( TRebootStateParams), status );
       
   721     
       
   722     User::WaitForRequest( status );
       
   723 
       
   724     // If store state is done successfully reboot operation is allowed
       
   725     if( status.Int() == KErrNone )
       
   726         {
       
   727         iIsRebootReady = ETrue;
       
   728         }
       
   729 
       
   730     return status.Int();
       
   731 
       
   732     }
       
   733 
       
   734 /*
       
   735 -------------------------------------------------------------------------------
       
   736 
       
   737     Class: CTestModuleIf
       
   738 
       
   739     Method: GetStoredState
       
   740 
       
   741     Description: Get saved store information after the reboot.
       
   742 
       
   743     Parameters: TInt aCode: inout: Get reboot releated integer value.
       
   744                 TName& aName: inout: Get reboot related string value.
       
   745 
       
   746     Return Values: TInt: Symbian OS error code.
       
   747 
       
   748     Errors/Exceptions: KErrNotReady returned if iTestExecution is NULL.
       
   749 
       
   750     Status: Proposal
       
   751 
       
   752 -------------------------------------------------------------------------------
       
   753 */
       
   754 EXPORT_C TInt CTestModuleIf::GetStoredState( TInt& aCode, TName& aName )
       
   755     {           
       
   756     if( !IsServerAlive() )
       
   757         {
       
   758         __RDEBUG( ( _L( "iTestExecution not initialised" ) ) );
       
   759         return KErrNotReady;
       
   760         }
       
   761 
       
   762     TInt code;
       
   763     TName name;
       
   764     
       
   765     TParams params;
       
   766     TGetRebootStoredParamsRef getRebootStoredParamsRef( code, name );
       
   767     
       
   768     params.aRebootStoredRef = &getRebootStoredParamsRef;
       
   769 
       
   770     TRequestStatus status = KRequestPending; 
       
   771 
       
   772     // Forward
       
   773     iTestExecution->DoRemoteReceive( EStifCmdGetStoredState, params,
       
   774                                      sizeof( TRebootStateParams), status );
       
   775     
       
   776     User::WaitForRequest( status );
       
   777 
       
   778     // Return results if getting state is done without error
       
   779     if(status.Int() == KErrNone)
       
   780         {
       
   781         aCode = code;
       
   782         aName = name;
       
   783         }
       
   784 
       
   785     return status.Int();
       
   786 
       
   787     }
       
   788 
       
   789 /*
       
   790 -------------------------------------------------------------------------------
       
   791 
       
   792     Class: CTestModuleIf
       
   793 
       
   794     Method: SetBehavior
       
   795 
       
   796     Description: Set test case behavior.
       
   797 
       
   798     Parameters: TInt aCode: inout: Get reboot releated integer value.
       
   799                 TName& aName: inout: Get reboot related string value.
       
   800 
       
   801     Return Values: TInt: Symbian OS error code.
       
   802 
       
   803     Errors/Exceptions: KErrNotReady returned if iTestExecution is NULL.
       
   804 
       
   805     Status: Proposal
       
   806 
       
   807 -------------------------------------------------------------------------------
       
   808 */
       
   809 EXPORT_C TInt CTestModuleIf::SetBehavior( TTestBehavior aType, TAny* aPtr )
       
   810     {         
       
   811     
       
   812     if( !IsServerAlive() )
       
   813         {
       
   814         return KErrGeneral;
       
   815         }
       
   816 
       
   817     // All event commands are handled in testserver and testengine
       
   818     return iTestExecution->SetBehavior( aType, aPtr );
       
   819     
       
   820     }
       
   821 
       
   822 /*
       
   823 -------------------------------------------------------------------------------
       
   824 
       
   825     Class: CTestModuleIf
       
   826 
       
   827     Method: StifMacroError
       
   828 
       
   829     Description: STIF TF's macros. Saves information for later use.
       
   830 
       
   831     Parameters: TInt aMacroType: in: Macro type(0:TL, 1:T1L, 2:T2L, etc.)
       
   832                 const TText8* aFile: in: Uses __FILE__ macro and this includes
       
   833                 path and file name. Maximun length for this is
       
   834                 KStifMacroMaxFile. If length is more then cutted from left.
       
   835                 char* aFunction: in: Uses __FUNCTION__ macro and this includes
       
   836                 function name. Maximun length for this is
       
   837                 KStifMacroMaxFunction. If length is more then cutted from
       
   838                 rigth.
       
   839                 TInt aLine: in: Uses __LINE__ macro and includes line number.
       
   840                 TInt aResult: in: Result from called operations.
       
   841                 TInt aExpected1: in: Users expected result.
       
   842                 TInt aExpected2: in: Users expected result.
       
   843                 TInt aExpected3: in: Users expected result.
       
   844                 TInt aExpected4: in: Users expected result.
       
   845                 TInt aExpected5: in: Users expected result.
       
   846 
       
   847     Return Values: Symbian OS error code.
       
   848 
       
   849     Errors/Exceptions: None
       
   850 
       
   851     Status: Proposal
       
   852 
       
   853 -------------------------------------------------------------------------------
       
   854 */
       
   855 EXPORT_C TInt CTestModuleIf::StifMacroError( TInt aMacroType, 
       
   856                                              const TText8* aFile,
       
   857                                              const char* aFunction,
       
   858                                              TInt aLine,
       
   859                                              TInt aResult,
       
   860                                              TInt aExpected1,
       
   861                                              TInt aExpected2,
       
   862                                              TInt aExpected3,
       
   863                                              TInt aExpected4,
       
   864                                              TInt aExpected5 )
       
   865     {
       
   866     if( !IsServerAlive() )
       
   867         {
       
   868         return KErrGeneral;
       
   869         }
       
   870 
       
   871     return iTestExecution->StifMacroError( aMacroType, aFile,
       
   872                                            aFunction, aLine,
       
   873                                            aResult, aExpected1,
       
   874                                            aExpected2, aExpected3,
       
   875                                            aExpected4, aExpected5 );
       
   876 
       
   877     }
       
   878 
       
   879 /*
       
   880 -------------------------------------------------------------------------------
       
   881 
       
   882     Class: CTestModuleIf
       
   883 
       
   884     Method: ServerAlive
       
   885 
       
   886     Description: Get saved store information after the reboot.
       
   887 
       
   888     Parameters: TInt aCode: inout: Get reboot releated integer value.
       
   889                 TName& aName: inout: Get reboot related string value.
       
   890 
       
   891     Return Values: TInt: Symbian OS error code.
       
   892 
       
   893     Errors/Exceptions: KErrNotReady returned if iTestExecution is NULL.
       
   894 
       
   895     Status: Proposal
       
   896 
       
   897 -------------------------------------------------------------------------------
       
   898 */
       
   899 TBool CTestModuleIf::IsServerAlive()
       
   900     {
       
   901     
       
   902     if( iTestExecution == NULL )
       
   903         {
       
   904         __RDEBUG( ( _L( "iTestExecution not initialised" ) ) );
       
   905         // Execution not initialized
       
   906         return EFalse;
       
   907         }
       
   908        
       
   909     return ETrue;
       
   910     
       
   911     }
       
   912 
       
   913 /*
       
   914 -------------------------------------------------------------------------------
       
   915 
       
   916     Class: CTestModuleIf
       
   917 
       
   918     Method: AddInterferenceThread
       
   919 
       
   920     Description: 
       
   921 
       
   922     Parameters: RThread aSTIFTestInterference: in: Handle to RThread
       
   923 
       
   924     Return Values: TInt: Symbian OS error code.
       
   925 
       
   926     Errors/Exceptions: 
       
   927 
       
   928     Status: Proposal
       
   929 
       
   930 -------------------------------------------------------------------------------
       
   931 */
       
   932 TInt CTestModuleIf::AddInterferenceThread( RThread aSTIFTestInterference )
       
   933     {
       
   934     // Add thread to Array. Via array can handle test interference thread's
       
   935     // kill in panic etc. cases
       
   936     return iTestExecution->AddInterferenceThread( aSTIFTestInterference );
       
   937 
       
   938     }
       
   939 
       
   940 /*
       
   941 -------------------------------------------------------------------------------
       
   942 
       
   943     Class: CTestModuleIf
       
   944 
       
   945     Method: RemoveInterferenceThread
       
   946 
       
   947     Description: 
       
   948 
       
   949     Parameters: RThread aSTIFTestInterference: in: Handle to RThread
       
   950 
       
   951     Return Values: TInt: Symbian OS error code.
       
   952 
       
   953     Errors/Exceptions: 
       
   954 
       
   955     Status: Proposal
       
   956 
       
   957 -------------------------------------------------------------------------------
       
   958 */
       
   959 TInt CTestModuleIf::RemoveInterferenceThread( RThread aSTIFTestInterference )
       
   960     {
       
   961     // Remove thread from Array.Test interference thread is stopped and killed
       
   962     // successfully
       
   963     return iTestExecution->RemoveInterferenceThread( aSTIFTestInterference );
       
   964 
       
   965     }
       
   966 
       
   967 /*
       
   968 -------------------------------------------------------------------------------
       
   969 
       
   970     Class: CTestModuleIf
       
   971 
       
   972     Method: HandleMeasurementProcess
       
   973 
       
   974     Description: With this can be stored information about test measurement
       
   975                  to TestServer space.
       
   976 
       
   977     Parameters: RProcess aTestMeasurement: in: Handle to RProcess
       
   978 
       
   979     Return Values: TInt: Symbian OS error code.
       
   980 
       
   981     Errors/Exceptions: 
       
   982 
       
   983     Status: Approved
       
   984 
       
   985 -------------------------------------------------------------------------------
       
   986 */
       
   987 TInt CTestModuleIf::HandleMeasurementProcess( 
       
   988             CSTIFTestMeasurement::TStifMeasurementStruct aSTIFMeasurementInfo )
       
   989     {
       
   990     // Add process to Array. Via array can handle test measurement process's
       
   991     // kill in panic etc. cases
       
   992     return iTestExecution->HandleMeasurementProcess( aSTIFMeasurementInfo );
       
   993 
       
   994     }
       
   995 
       
   996 /*
       
   997 -------------------------------------------------------------------------------
       
   998 
       
   999     Class: CTestModuleIf
       
  1000 
       
  1001     Method: GetMeasurementOptions
       
  1002 
       
  1003     Description: Get measurement option(s) given from initialization file etc.
       
  1004 
       
  1005     Parameters: TInt& aOptions: inout: Get measurement option(s)
       
  1006 
       
  1007     Return Values: TInt: Symbian OS error code.
       
  1008 
       
  1009     Errors/Exceptions: KErrNotReady returned if iTestExecution is NULL.
       
  1010 
       
  1011     Status: Approved
       
  1012 
       
  1013 -------------------------------------------------------------------------------
       
  1014 */
       
  1015 EXPORT_C TInt CTestModuleIf::GetMeasurementOptions( TInt& aOptions )
       
  1016     {           
       
  1017     if( !IsServerAlive() )
       
  1018         {
       
  1019         __RDEBUG( ( _L( "iTestExecution not initialised" ) ) );
       
  1020         return KErrNotReady;
       
  1021         }
       
  1022 
       
  1023     TParams params;
       
  1024     TGetMeasurementOptionsRef getMeasurementOptionsRef( aOptions );
       
  1025     params.aMeasurementOption = &getMeasurementOptionsRef;
       
  1026 
       
  1027     TRequestStatus status = KRequestPending; 
       
  1028 
       
  1029     // Forward
       
  1030     iTestExecution->DoRemoteReceive( EStifCmdMeasurement, params,
       
  1031                                      sizeof( TGetMeasurementOptions ), status );
       
  1032     
       
  1033     User::WaitForRequest( status );
       
  1034 
       
  1035     aOptions = getMeasurementOptionsRef.iOptions;
       
  1036     
       
  1037     return status.Int();
       
  1038 
       
  1039     }
       
  1040 
       
  1041 /*
       
  1042 -------------------------------------------------------------------------------
       
  1043 
       
  1044     Class: CTestModuleIf
       
  1045 
       
  1046     Method: SetAllowResult
       
  1047 
       
  1048     Description: Use with TAL, TA1L, TA2L, TA3L, TA4L and TA5L macros to allow
       
  1049                  results.
       
  1050                  Set test case allow result given by user. In TestScripter
       
  1051                  cases allow result can set by 'allownextresult' or
       
  1052                  'allowerrorcodes' keywords. In Normal and Hardcoded test
       
  1053                  modules allow result can be set with this method, reset should
       
  1054                  be done with ResetAllowResult method.
       
  1055 
       
  1056     Parameters: TInt aResult: in: Result value to be appended.
       
  1057 
       
  1058     Return Values: TInt: Symbian OS error code.
       
  1059 
       
  1060     Errors/Exceptions: None
       
  1061 
       
  1062     Status: Approved
       
  1063 
       
  1064 -------------------------------------------------------------------------------
       
  1065 */
       
  1066 EXPORT_C TInt CTestModuleIf::SetAllowResult( TInt aResult )
       
  1067     {
       
  1068     for( TInt a = 0; a < iAllowTestCaseResultsCount; a++ )
       
  1069         {
       
  1070         // Check that result is not given already
       
  1071         if ( iTestCaseResults[a] == aResult )
       
  1072             {
       
  1073             return KErrNone;
       
  1074             }
       
  1075         }
       
  1076     // If values are given more that allow(see KSTIFMacroResultArraySize).
       
  1077     // Array starts from 0...9 -> 10 => 10th should fail
       
  1078     if( iAllowTestCaseResultsCount >= KSTIFMacroResultArraySize )
       
  1079         {
       
  1080         __RDEBUG( ( 
       
  1081             _L( "STIF macro's SetAllowResult() allow only %d results, fails with %d" ),
       
  1082             KSTIFMacroResultArraySize, KErrOverflow  ) );
       
  1083         return KErrOverflow;
       
  1084         }
       
  1085 
       
  1086     // New result
       
  1087     iAllowTestCaseResultsCount++;
       
  1088     iTestCaseResults[iAllowTestCaseResultsCount-1] = aResult;
       
  1089 
       
  1090     return KErrNone;
       
  1091 
       
  1092     }
       
  1093 
       
  1094 /*
       
  1095 -------------------------------------------------------------------------------
       
  1096 
       
  1097     Class: CTestModuleIf
       
  1098 
       
  1099     Method: CheckAllowResult
       
  1100 
       
  1101     Description: This is mainly used by STIF's TAL-TA5L macros internally.
       
  1102                  Check is macros result allowed result.
       
  1103 
       
  1104     Parameters: TInt aResult: in: Result value to be checked.
       
  1105 
       
  1106     Return Values: TInt: Symbian OS error code.
       
  1107 
       
  1108     Errors/Exceptions: None
       
  1109 
       
  1110     Status: Approved
       
  1111 
       
  1112 -------------------------------------------------------------------------------
       
  1113 */
       
  1114 EXPORT_C TInt CTestModuleIf::CheckAllowResult( TInt aResult )
       
  1115     {
       
  1116     // Check is result allowed
       
  1117     for( TInt a = 0; a < iAllowTestCaseResultsCount; a++ )
       
  1118         {
       
  1119         if ( iTestCaseResults[a] == aResult )
       
  1120             {
       
  1121             // Result is allow
       
  1122             __RDEBUG( ( _L( "STIF TAL-TA5L macro's result check. Test case result[%d] allowed" ),
       
  1123                 aResult ) );
       
  1124             return KErrNone;
       
  1125             }
       
  1126         }
       
  1127 
       
  1128     __RDEBUG( ( 
       
  1129         _L( "STIF TAL-TA5L macro's result check. Test case result[%d] not allowed" ),
       
  1130         aResult ) );
       
  1131     // No match with allow result
       
  1132     return KErrGeneral;
       
  1133 
       
  1134     }
       
  1135 
       
  1136 /*
       
  1137 -------------------------------------------------------------------------------
       
  1138 
       
  1139     Class: CTestModuleIf
       
  1140 
       
  1141     Method: ResetAllowResult
       
  1142 
       
  1143     Description: Use with TAL, TA1L, TA2L, TA3L, TA4L and TA5L macros to reset
       
  1144                  allowed results.
       
  1145                  Reset allow result(s) given with SetAllowResult. In
       
  1146                  TestScripter cases this will be called automatically by STIF.
       
  1147                  Normal and Hardcoded cases this should be called by user.
       
  1148 
       
  1149     Parameters: None.
       
  1150 
       
  1151     Return Values: TInt: Symbian OS error code.
       
  1152 
       
  1153     Errors/Exceptions: None
       
  1154 
       
  1155     Status: Approved
       
  1156 
       
  1157 -------------------------------------------------------------------------------
       
  1158 */
       
  1159 EXPORT_C TInt CTestModuleIf::ResetAllowResult()
       
  1160     {
       
  1161     // Used to "resets" iTestCaseResults array
       
  1162     iAllowTestCaseResultsCount = 0;
       
  1163 
       
  1164     return KErrNone;
       
  1165 
       
  1166     }
       
  1167 
       
  1168 /*
       
  1169 -------------------------------------------------------------------------------
       
  1170 
       
  1171     Class: CTestModuleIf
       
  1172 
       
  1173     Method: StopExecution
       
  1174 
       
  1175     Description: Causes that test case is going to be cancelled.
       
  1176 
       
  1177     Parameters: None
       
  1178 
       
  1179     Return Values: Symbian OS error code.
       
  1180 
       
  1181     Errors/Exceptions: None
       
  1182 
       
  1183     Status: Approved
       
  1184 
       
  1185 -------------------------------------------------------------------------------
       
  1186 */
       
  1187 EXPORT_C TInt CTestModuleIf::StopExecution(TStopExecutionType aType, TInt aCode)
       
  1188     {
       
  1189 
       
  1190     //Check parameters
       
  1191     if((aType == EOk) && (aCode != KErrNone))
       
  1192         {
       
  1193         return KErrArgument;
       
  1194         }
       
  1195     else if((aType != EOk) && (aCode == KErrNone))
       
  1196         {
       
  1197         return KErrArgument;
       
  1198         }
       
  1199 
       
  1200     //Check server
       
  1201     if(!IsServerAlive())
       
  1202         {
       
  1203         return KErrGeneral;
       
  1204         }
       
  1205 
       
  1206     //Everything is ok, we can continue with processing command
       
  1207     _LIT(KStopExecution, "StopExecution");
       
  1208     const TInt KPrintPriority = 30;
       
  1209 
       
  1210     switch(aType)
       
  1211         {
       
  1212         case EOk:
       
  1213             Printf(KPrintPriority, KStopExecution, _L("***Test case PASSED***\n\n"));
       
  1214             break;
       
  1215         case EFail:
       
  1216             Printf(KPrintPriority, KStopExecution, _L("***Test case FAILED***\n\n"));
       
  1217             break;
       
  1218         case EAbort:
       
  1219             Printf(KPrintPriority, KStopExecution, _L("***Test case KILLED***\n\n"));
       
  1220             break;
       
  1221         default:
       
  1222             return KErrNotFound;
       
  1223         }
       
  1224 
       
  1225     TStopExecutionCommandParams params;
       
  1226     params.iType = aType;
       
  1227     params.iCode = aCode;
       
  1228     __RDEBUG((_L("CTestModuleIf::StopExecution(): type [%d] code [%d]"), TInt(aType), aCode));
       
  1229 
       
  1230     TStopExecutionCommandParamsPckg pckg(params);
       
  1231 
       
  1232     TInt res = Command(EStopExecution, pckg);
       
  1233     return res;
       
  1234     }
       
  1235 
       
  1236 /*
       
  1237 ------------------------------------------------------------------------------
       
  1238 
       
  1239 	Class: CTestModuleIf
       
  1240 
       
  1241     Method: SendTestModuleVersion
       
  1242     
       
  1243     Description: SendTestModuleVersion method is used to pass version of test module
       
  1244     
       
  1245 ------------------------------------------------------------------------------
       
  1246  */
       
  1247 EXPORT_C TInt CTestModuleIf::SendTestModuleVersion(TVersion aVersion, TFileName aModuleName)
       
  1248 	{
       
  1249 	if( aModuleName.Length() == 0 )
       
  1250 		{
       
  1251 		return KErrArgument;
       
  1252 		}
       
  1253 	
       
  1254 	//Check server
       
  1255 	if(!IsServerAlive())
       
  1256 	    {
       
  1257 	    return KErrGeneral;
       
  1258 	    }
       
  1259 	
       
  1260 	const TInt KPrintPriority = 30;
       
  1261 	_LIT(KVersion ,"SendTestModuleVersion");
       
  1262 	Printf(KPrintPriority, KVersion, _L("Sending test module version"));
       
  1263 	
       
  1264 	TSendTestModuleVesionCommandParams params;
       
  1265 	params.iMajor = aVersion.iMajor;
       
  1266 	params.iMinor = aVersion.iMinor;
       
  1267 	params.iBuild = aVersion.iBuild;
       
  1268 	params.iTestModuleName = aModuleName;
       
  1269 	
       
  1270 	TSendTestModuleVesionCommandParamsPckg pckg(params);
       
  1271 	TInt res = Command( ESendTestModuleVersion, pckg );
       
  1272 	return res;
       
  1273 	}
       
  1274 
       
  1275 
       
  1276 /*
       
  1277 ------------------------------------------------------------------------------
       
  1278 
       
  1279 	Class: CTestModuleIf
       
  1280 
       
  1281     Method: SendTestModuleVersion
       
  1282     
       
  1283     Description: SendTestModuleVersion method is used to pass version of test module.
       
  1284     			This version uses three parameters to enable the overloading of version with
       
  1285     			two parameters. The version with two params has params passed by value which
       
  1286     			is incorrect. The "old" version (with two parameters) is left here not to cause
       
  1287     			binary break. Only this version (with three parameters) should be used.
       
  1288     
       
  1289 ------------------------------------------------------------------------------
       
  1290  */
       
  1291 EXPORT_C TInt CTestModuleIf::SendTestModuleVersion(TVersion& aVersion, const TDesC& aModuleName, TBool /*aNewVersion*/)
       
  1292 	{
       
  1293 	if( aModuleName.Length() == 0 )
       
  1294 		{
       
  1295 		return KErrArgument;
       
  1296 		}
       
  1297 	
       
  1298 	//Check server
       
  1299 	if(!IsServerAlive())
       
  1300 	    {
       
  1301 	    return KErrGeneral;
       
  1302 	    }
       
  1303 	
       
  1304 	const TInt KPrintPriority = 30;
       
  1305 	_LIT(KVersion ,"SendTestModuleVersion");
       
  1306 	Printf(KPrintPriority, KVersion, _L("Sending test module version"));
       
  1307 	
       
  1308 	TSendTestModuleVesionCommandParams params;
       
  1309 	params.iMajor = aVersion.iMajor;
       
  1310 	params.iMinor = aVersion.iMinor;
       
  1311 	params.iBuild = aVersion.iBuild;
       
  1312 	params.iTestModuleName = aModuleName;
       
  1313 	
       
  1314 	TSendTestModuleVesionCommandParamsPckg pckg(params);
       
  1315 	TInt res = Command( ESendTestModuleVersion, pckg );
       
  1316 	return res;
       
  1317 	}
       
  1318 
       
  1319 /*
       
  1320 -------------------------------------------------------------------------------
       
  1321 
       
  1322     Class: CTestModuleIf
       
  1323 
       
  1324     Method: Command
       
  1325 
       
  1326     Description: Sends specific command to TestServer.
       
  1327 
       
  1328     Parameters: aCommand - command to be send
       
  1329 
       
  1330     Return Values: Symbian OS error code.
       
  1331 
       
  1332     Errors/Exceptions: None
       
  1333 
       
  1334     Status: Approved
       
  1335 
       
  1336 -------------------------------------------------------------------------------
       
  1337 */
       
  1338 TInt CTestModuleIf::Command(TCommand aCommand, const TDesC8& aParamsPckg)
       
  1339     {
       
  1340     TInt res = KErrNone;
       
  1341 
       
  1342     if( !IsServerAlive() )
       
  1343         {
       
  1344         return KErrGeneral;
       
  1345         }
       
  1346 
       
  1347     switch(aCommand)
       
  1348         {
       
  1349         case EStopExecution:
       
  1350             iTestExecution->DoNotifyCommand(aCommand, aParamsPckg);
       
  1351             break;
       
  1352         case ESendTestModuleVersion:
       
  1353         	iTestExecution->DoNotifyCommand(aCommand, aParamsPckg);
       
  1354         	break;
       
  1355         default:
       
  1356             __RDEBUG((_L("Command [%d] not recognized."), aCommand));
       
  1357         }
       
  1358 
       
  1359     return res;
       
  1360     }
       
  1361 
       
  1362 /*
       
  1363 -------------------------------------------------------------------------------
       
  1364 
       
  1365     Class: CTestModuleIf
       
  1366 
       
  1367     Method: GetTestCaseTitleL
       
  1368 
       
  1369     Description: Returns title of current test case.
       
  1370 
       
  1371     Parameters: aCommand - command to be send
       
  1372 
       
  1373     Return Values: Symbian OS error code.
       
  1374 
       
  1375     Errors/Exceptions: None
       
  1376 
       
  1377     Status: Approved
       
  1378 
       
  1379 -------------------------------------------------------------------------------
       
  1380 */
       
  1381 EXPORT_C void CTestModuleIf::GetTestCaseTitleL(TDes& aTestCaseTitle)
       
  1382     {
       
  1383     iTestExecution->GetTestCaseTitleL(aTestCaseTitle);
       
  1384     }
       
  1385 
       
  1386 /*
       
  1387 -------------------------------------------------------------------------------
       
  1388 
       
  1389     Class: CTestModuleIf
       
  1390 
       
  1391     Method: UITesting
       
  1392 
       
  1393     Description: Gets information if it is UI test or not
       
  1394 
       
  1395     Parameters: none
       
  1396 
       
  1397     Return Values: True if it is UI test, in other case it returns false.
       
  1398 
       
  1399     Errors/Exceptions: None
       
  1400 
       
  1401     Status: Approved
       
  1402 
       
  1403 -------------------------------------------------------------------------------
       
  1404 */
       
  1405 EXPORT_C TBool CTestModuleIf::UITesting()
       
  1406 	{
       
  1407 	return iTestExecution->UITesting();
       
  1408 	}
       
  1409 
       
  1410 /*
       
  1411 -------------------------------------------------------------------------------
       
  1412 
       
  1413     Class: CTestModuleIf
       
  1414 
       
  1415     Method: GetUiEnvProxy
       
  1416 
       
  1417     Description: Gets UiEnvProxy
       
  1418 
       
  1419     Parameters: none
       
  1420 
       
  1421     Return Values: Pointer to UiEnvProxy
       
  1422 
       
  1423     Errors/Exceptions: None
       
  1424 
       
  1425     Status: Approved
       
  1426 
       
  1427 -------------------------------------------------------------------------------
       
  1428 */
       
  1429 EXPORT_C CUiEnvProxy* CTestModuleIf::GetUiEnvProxy()
       
  1430 	{
       
  1431 	return iTestExecution->GetUiEnvProxy();
       
  1432 	}
       
  1433 
       
  1434 // ================= OTHER EXPORTED FUNCTIONS =================================
       
  1435 
       
  1436 
       
  1437 /*
       
  1438 -------------------------------------------------------------------------------
       
  1439 
       
  1440     DESCRIPTION
       
  1441 
       
  1442     This module contains the implementation of CSTIFTestMeasurement class 
       
  1443     member functions.
       
  1444 
       
  1445 -------------------------------------------------------------------------------
       
  1446 */
       
  1447 
       
  1448 // ================= MEMBER FUNCTIONS =========================================
       
  1449 
       
  1450 /*
       
  1451 -------------------------------------------------------------------------------
       
  1452 
       
  1453     Class: CSTIFTestMeasurement
       
  1454 
       
  1455     Method: CSTIFTestMeasurement
       
  1456 
       
  1457     Description: Default constructor
       
  1458 
       
  1459     C++ default constructor can NOT contain any code, that
       
  1460     might leave.
       
  1461 
       
  1462     Parameters: CTestModuleBase* aTestModuleBase: in: Pointer to STIF
       
  1463 
       
  1464     Return Values: None
       
  1465 
       
  1466     Errors/Exceptions: None
       
  1467 
       
  1468     Status: Approved
       
  1469 
       
  1470 -------------------------------------------------------------------------------
       
  1471 */
       
  1472 CSTIFTestMeasurement::CSTIFTestMeasurement( CTestModuleBase* aTestModuleBase ) :
       
  1473     iTestModuleBase( aTestModuleBase ),
       
  1474     iMeasurementOption( 0 )
       
  1475     {
       
  1476 
       
  1477     }
       
  1478 
       
  1479 /*
       
  1480 -------------------------------------------------------------------------------
       
  1481 
       
  1482     Class: CSTIFTestMeasurement
       
  1483 
       
  1484     Method: ConstructL
       
  1485 
       
  1486     Description: Symbian OS second phase constructor
       
  1487 
       
  1488     Symbian OS default constructor can leave.
       
  1489 
       
  1490     Parameters: TSTIFMeasurement aType: in: Measurement type
       
  1491                 const TDesC& aConfigurationInfo: in: Configuration issues
       
  1492 
       
  1493     Return Values: None
       
  1494 
       
  1495     Errors/Exceptions: Leaves if HandleMeasurementProcess returns error code
       
  1496 
       
  1497     Status: Approved
       
  1498 
       
  1499 -------------------------------------------------------------------------------
       
  1500 */
       
  1501 void CSTIFTestMeasurement::ConstructL( TSTIFMeasurementType aType,
       
  1502                                     const TDesC& aConfigurationInfo )
       
  1503     {
       
  1504     // aType into struct here. This is compared to
       
  1505     iMeasurementStruct.iMeasurementType = aType;
       
  1506 
       
  1507     // Check that measurement is not disabled(This is given from UI level or
       
  1508     // from TestFramework.ini file)
       
  1509     TInt ret( 0 );
       
  1510     ret = iTestModuleBase->TestModuleIf().GetMeasurementOptions( 
       
  1511                                                         iMeasurementOption );
       
  1512     if( ret != KErrNone )
       
  1513         {
       
  1514         __RDEBUG( ( _L( "GetMeasurementOptions() return an error[%d]" ), ret ) );
       
  1515         User::Leave( ret );
       
  1516         }
       
  1517 
       
  1518     // Check that measurement is not disabled
       
  1519     if( ( iMeasurementOption & EDisableAll ) == EDisableAll )
       
  1520         {
       
  1521         __RDEBUG( _L( "Measurement disable option [KStifMeasurementDisableAll] is given by user" ) );
       
  1522         return;
       
  1523         }
       
  1524     if( ( ( iMeasurementOption & EMeasurement01 ) == EMeasurement01 ) && aType == KStifMeasurementPlugin01 )
       
  1525         {
       
  1526         __RDEBUG( _L( "Measurement disable option [KStifMeasurement01] is given by user" ) );
       
  1527         return;
       
  1528         }
       
  1529     if( ( ( iMeasurementOption & EMeasurement02 ) == EMeasurement02 ) && aType == KStifMeasurementPlugin02 )
       
  1530         {
       
  1531         __RDEBUG( _L( "Measurement disable option [KStifMeasurement02] is given by user" ) );
       
  1532         return;
       
  1533         }
       
  1534     if( ( ( iMeasurementOption & EMeasurement03 ) == EMeasurement03 ) && aType == KStifMeasurementPlugin03 )
       
  1535         {
       
  1536         __RDEBUG( _L( "Measurement disable option [KStifMeasurement03] is given by user" ) );
       
  1537         return;
       
  1538         }
       
  1539     if( ( ( iMeasurementOption & EMeasurement04 ) == EMeasurement04 ) && aType == KStifMeasurementPlugin04 )
       
  1540         {
       
  1541         __RDEBUG( _L( "Measurement disable option [KStifMeasurement04] is given by user" ) );
       
  1542         return;
       
  1543         }
       
  1544     if( ( ( iMeasurementOption & EMeasurement05 ) == EMeasurement05 ) && aType == KStifMeasurementPlugin05 )
       
  1545         {
       
  1546         __RDEBUG( _L( "Measurement disable option [KStifMeasurement05] is given by user" ) );
       
  1547         return;
       
  1548         }
       
  1549     if( ( ( iMeasurementOption & EBappea ) == EBappea ) && aType == KStifMeasurementBappeaProfiler )
       
  1550         {
       
  1551         __RDEBUG( _L( "Measurement disable option [KStifMeasurementBappea] is given by user" ) );
       
  1552         return;
       
  1553         }
       
  1554 
       
  1555     iMeasurementStruct.iConfigurationInfo = aConfigurationInfo;
       
  1556     iMeasurementStruct.iMeasurementOperation = KMeasurementNew;
       
  1557     iMeasurementStruct.iPointerToMeasurementModule = iTestModuleBase;
       
  1558 
       
  1559     // Move measurement execution initialization forward to TestServer.
       
  1560     User::LeaveIfError( iTestModuleBase->iTestModuleIf->HandleMeasurementProcess(
       
  1561             iMeasurementStruct ) );
       
  1562 
       
  1563     }
       
  1564 
       
  1565 /*
       
  1566 -------------------------------------------------------------------------------
       
  1567 
       
  1568     Class: CSTIFTestMeasurement
       
  1569 
       
  1570     Method: NewL
       
  1571 
       
  1572     Description: Two-phased constructor.
       
  1573 
       
  1574     Parameters: CTestModuleBase* aTestModuleBase: in: Pointer to STIF.
       
  1575                 TSTIFMeasurement aType: in: Measurement type.
       
  1576                 const TDesC& aConfigurationInfo: in: Configuration info.
       
  1577     
       
  1578     Return Values: CSTIFTestMeasurement object.
       
  1579 
       
  1580     Errors/Exceptions: Leaves if memory allocation fails
       
  1581                        Leaves if ConstructL leaves
       
  1582 
       
  1583     Status: Approved
       
  1584 
       
  1585 -------------------------------------------------------------------------------
       
  1586 */
       
  1587 EXPORT_C CSTIFTestMeasurement* CSTIFTestMeasurement::NewL( 
       
  1588                                             CTestModuleBase* aTestModuleBase,
       
  1589                                             TSTIFMeasurementType aType, 
       
  1590                                             const TDesC& aConfigurationInfo )
       
  1591     {
       
  1592     CSTIFTestMeasurement* self = 
       
  1593             new (ELeave) CSTIFTestMeasurement( aTestModuleBase );
       
  1594 
       
  1595     CleanupStack::PushL( self );
       
  1596     self->ConstructL( aType, aConfigurationInfo );
       
  1597 
       
  1598     CleanupStack::Pop();
       
  1599 
       
  1600     return self;
       
  1601 
       
  1602     }
       
  1603 
       
  1604 /*
       
  1605 -------------------------------------------------------------------------------
       
  1606 
       
  1607     Class: CSTIFTestMeasurement
       
  1608 
       
  1609     Method: ~CSTIFTestMeasurement
       
  1610 
       
  1611     Description: Destructor
       
  1612 
       
  1613     Parameters: None
       
  1614 
       
  1615     Return Values: None
       
  1616 
       
  1617     Errors/Exceptions: None
       
  1618 
       
  1619     Status: Approved
       
  1620 
       
  1621 -------------------------------------------------------------------------------
       
  1622 */
       
  1623 CSTIFTestMeasurement::~CSTIFTestMeasurement()
       
  1624     {
       
  1625     // None
       
  1626 
       
  1627     }
       
  1628 
       
  1629 /*
       
  1630 -------------------------------------------------------------------------------
       
  1631 
       
  1632     Class: CSTIFTestMeasurement
       
  1633 
       
  1634     Method: Start
       
  1635 
       
  1636     Description: Start commant for measurement.
       
  1637 
       
  1638     Parameters: None
       
  1639 
       
  1640     Return Values: Symbian error code
       
  1641 
       
  1642     Errors/Exceptions: None
       
  1643 
       
  1644     Status: Approved
       
  1645 
       
  1646 -------------------------------------------------------------------------------
       
  1647 */
       
  1648 EXPORT_C TInt CSTIFTestMeasurement::Start()
       
  1649     {
       
  1650     // Check that measurement is not disabled
       
  1651     if( iMeasurementOption  == iMeasurementStruct.iMeasurementType )
       
  1652         {
       
  1653         __RDEBUG( ( _L( "Measurement with type[%d] is disabled by user" ), iMeasurementOption ) );
       
  1654         // Cannot return error code because this causes problems in
       
  1655         // TestScripter and TestCombiner error handling. Now testing continue
       
  1656         // without measurement.
       
  1657         return KErrNone;
       
  1658         }
       
  1659 
       
  1660     iMeasurementStruct.iMeasurementOperation = KMeasurementStart;
       
  1661 
       
  1662     // Move measurement start execution forward to TestServer.
       
  1663     return iTestModuleBase->iTestModuleIf->HandleMeasurementProcess(
       
  1664                                                         iMeasurementStruct );
       
  1665 
       
  1666     }
       
  1667 
       
  1668 /*
       
  1669 -------------------------------------------------------------------------------
       
  1670 
       
  1671     Class: CTestMeasurement
       
  1672 
       
  1673     Method: Stop
       
  1674 
       
  1675     Description: Stop command for measurement.
       
  1676 
       
  1677     Parameters: None
       
  1678 
       
  1679     Return Values: Symbian error code
       
  1680 
       
  1681     Errors/Exceptions: None
       
  1682 
       
  1683     Status: Approved
       
  1684 
       
  1685 -------------------------------------------------------------------------------
       
  1686 */
       
  1687 EXPORT_C TInt CSTIFTestMeasurement::Stop()
       
  1688     {
       
  1689     // Check that measurement is not disabled
       
  1690     if( iMeasurementOption  == iMeasurementStruct.iMeasurementType )
       
  1691         {
       
  1692         __RDEBUG( ( _L( "Measurement with type[%d] is disabled by user" ), iMeasurementOption ) );
       
  1693         // Cannot return error code because this causes problems in
       
  1694         // TestScripter and TestCombiner error handling. Now testing continue
       
  1695         // without measurement.
       
  1696         return KErrNone;
       
  1697         }
       
  1698 
       
  1699     iMeasurementStruct.iMeasurementOperation = KMeasurementStop;
       
  1700 
       
  1701     // Move measurement stop execution forward to TestServer.
       
  1702     return iTestModuleBase->iTestModuleIf->HandleMeasurementProcess(
       
  1703                                                         iMeasurementStruct );
       
  1704 
       
  1705     }
       
  1706 
       
  1707 //  End of File