stif/TestServer/src/TestServerClient.cpp
branchRCL_3
changeset 59 8ad140f3dd41
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description: This module contains implementation of RTestServer, 
       
    15 * RTestModule and RTestExecution class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32svr.h>
       
    21 #include <stifinternal/TestServerClient.h>
       
    22 #include "TestServerCommon.h"
       
    23 //--PYTHON-- begin
       
    24 #include "StifPython.h"
       
    25 //--PYTHON-- end
       
    26 
       
    27 // EXTERNAL DATA STRUCTURES
       
    28 
       
    29 // EXTERNAL FUNCTION PROTOTYPES
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 // MACROS
       
    34 
       
    35 // LOCAL CONSTANTS AND MACROS
       
    36 
       
    37 // MODULE DATA STRUCTURES
       
    38 
       
    39 // LOCAL FUNCTION PROTOTYPES
       
    40 
       
    41 // FORWARD DECLARATIONS
       
    42 
       
    43 
       
    44 // ==================== LOCAL FUNCTIONS =======================================
       
    45 
       
    46 // None
       
    47 
       
    48 // ================= MEMBER FUNCTIONS =========================================
       
    49 
       
    50 
       
    51 /*
       
    52 -------------------------------------------------------------------------------
       
    53 
       
    54     Class: RTestServer
       
    55 
       
    56     Method: RTestServer
       
    57 
       
    58     Description: Default constructor
       
    59 
       
    60     C++ default constructor can NOT contain any code, that
       
    61     might leave.
       
    62 
       
    63     Parameters: None
       
    64 
       
    65     Return Values: None
       
    66 
       
    67     Errors/Exceptions: None
       
    68 
       
    69     Status: Approved
       
    70 
       
    71 -------------------------------------------------------------------------------
       
    72 */
       
    73 EXPORT_C RTestServer::RTestServer()
       
    74     {
       
    75     }
       
    76 
       
    77 
       
    78 /*
       
    79 -------------------------------------------------------------------------------
       
    80 
       
    81     Class: RTestServer
       
    82 
       
    83     Method: Connect
       
    84 
       
    85     Description: Connect method creates new RTestServer session.
       
    86     RTestServer session is used to manage the test case execution.
       
    87     
       
    88     Parameters: const TFileName& aModuleName: in: Module to be loaded
       
    89                 const TDesC& aConfigFile: in: Test case(config) file
       
    90                 name(Used in TestScripter case for parsing STIF settings).
       
    91 
       
    92     Return Values: TInt Error code
       
    93 
       
    94     Errors/Exceptions: None
       
    95 
       
    96     Status: Proposal
       
    97 
       
    98 -------------------------------------------------------------------------------
       
    99 */
       
   100 EXPORT_C TInt RTestServer::Connect( const TFileName& aModuleName,
       
   101                                     const TDesC& aConfigFile
       
   102                                     )
       
   103     {
       
   104     TFileName serverName;
       
   105 
       
   106     TInt ret = KErrNone;
       
   107 
       
   108     // Create global semaphore start-up. It will be indexed (if given name already exsists, index will be increased)
       
   109     RSemaphore startSemaphore;
       
   110     TName semaphoreName = _L("startupSemaphore");
       
   111     semaphoreName.Append( aModuleName );
       
   112     TInt x = 0;
       
   113     RBuf semName;
       
   114     ret = semName.Create(KMaxName);
       
   115     if(ret != KErrNone)
       
   116         {
       
   117         RDebug::Print(_L("RTestServer::Connect() Could not create buffer for semaphore name [%d]"), ret);
       
   118         return ret;
       
   119         }
       
   120     do
       
   121         {
       
   122         semName.Format(_L("%S%d"), &semaphoreName, x);
       
   123         if (semName.Length() > KMaxKernelName)
       
   124             {
       
   125             // if the cfg file name is larger than maximum length of acceptable length of semaphore .
       
   126             RDebug::Print(_L("Test Module name or Configuration File name is too long."));
       
   127             
       
   128             semName.Close();
       
   129             return KErrBadName;
       
   130             }
       
   131         
       
   132         ret = startSemaphore.CreateGlobal(semName, 0);
       
   133         RDebug::Print(_L("RTestServer::Connect() Creating global semaphore [%S] with result [%d]"), &semName, ret);
       
   134         if(ret != KErrAlreadyExists)
       
   135             {
       
   136             semaphoreName.Copy(semName);
       
   137             break;
       
   138             }
       
   139         x++;
       
   140         } while (ETrue);
       
   141     semName.Close();
       
   142     
       
   143     if ( ret != KErrNone )
       
   144         {
       
   145         startSemaphore.Close();
       
   146         return ret;
       
   147         }
       
   148 
       
   149     // By default start 'testserverstarter.exe'
       
   150     TFileName pathAndExeModule;
       
   151     if ( aModuleName.Find( _L( "testscripter_ui_" ) ) == 0 ) 
       
   152     	{
       
   153         pathAndExeModule.Copy( KDefaultUiExeName );    	
       
   154     	}
       
   155     else
       
   156     	{
       
   157         pathAndExeModule.Copy( KDefaultExeName );    	
       
   158     	}
       
   159 
       
   160     RProcess pr;
       
   161 
       
   162     // Data to be passed to new process. It will contain module name and synchronization semaphore name separated with space.
       
   163     // I.e. it will be: "mymodule startupSemaphore0"
       
   164     RBuf data; 
       
   165     ret = data.Create(KMaxFileName);
       
   166     if(ret != KErrNone)
       
   167         {
       
   168         RDebug::Print(_L("RTestServer::Connect() Could not create buffer for data to be passed to process [%d]"), ret);
       
   169         return ret;
       
   170         }
       
   171     data.Format(_L("%S %S"), &aModuleName, &semaphoreName);
       
   172     RDebug::Print(_L("RTestServer::Connect() Data for new process prepared [%S]"), &data);
       
   173     
       
   174 
       
   175     // Indication is Create() operation needed
       
   176     TBool doCreate( ETrue );
       
   177 
       
   178     #ifdef __WINS__ // CodeWarrior(emulator)
       
   179         // Create without path(Uses Symbian default path).
       
   180         // Note: If TestScriter used then module name is format:
       
   181         // testscripter_testcasefilename
       
   182         
       
   183         ret = pr.Create( aModuleName, data );
       
   184         if( ret == KErrNone )
       
   185             {
       
   186             RDebug::Print(_L("RTestServer::Connect() Combination (1): Caps modifier [%S], Data [%S]"), &aModuleName, &data);
       
   187             doCreate = EFalse;
       
   188             }
       
   189     #endif // __WINS__
       
   190 
       
   191     if ( doCreate )
       
   192         {
       
   193         TInt find_ret( KErrNone );
       
   194         TInt trapd_ret( KErrNone );
       
   195         // Check is TestScripter and is caps modifíer name given
       
   196         if( aModuleName.Find( KTestScripterName ) != KErrNotFound && aConfigFile != KNullDesC )
       
   197             {
       
   198             TInt ret_caps;
       
   199             TFileName capsModifierName;
       
   200             // In TestClass's test case (config) file can give name to caps
       
   201             // modifier module.
       
   202             ret_caps = GetCapsModifier( aConfigFile, capsModifierName );
       
   203             if( ret_caps != KErrNone )
       
   204                 {
       
   205                 RDebug::Print( _L( "RTestServer::Connect() Caps modifier was not defined. Default modifier will be used" ) );
       
   206                 }
       
   207             else
       
   208                 {
       
   209                 #ifdef __WINS__ // CodeWarrior(emulator)
       
   210                     // Create without path(Uses Symbian default path)
       
   211                     ret = pr.Create( capsModifierName, data );
       
   212                     if( ret == KErrNone )
       
   213                         {
       
   214                         RDebug::Print( _L( "RTestServer::Connect() Combination (2): Caps modifier [%S], Data [%S]"), &capsModifierName, &data);
       
   215                         doCreate = EFalse;
       
   216                         }
       
   217                 #endif // __WINS__
       
   218                 if ( doCreate )
       
   219                     {
       
   220                     TRAP( trapd_ret, find_ret = FindExeL(
       
   221                                     capsModifierName, pathAndExeModule ) );
       
   222                     }
       
   223                 }
       
   224             }
       
   225         //--PYTHON-- begin
       
   226         // If this is python module, use caps modifier
       
   227         else if(aModuleName.Length() >= KPythonScripterLength && aModuleName.Mid(0, KPythonScripterLength).Compare(KPythonScripter) == 0)
       
   228            {
       
   229            pathAndExeModule.Copy(KPythonScripter);
       
   230            }
       
   231         //--PYTHON-- end
       
   232         // Find exe from file system
       
   233         else if( aModuleName != _L( "testcombiner" ) )
       
   234            {
       
   235            // Check if e.g. TestModule.exe is available
       
   236            TRAP( trapd_ret, find_ret = FindExeL( aModuleName, pathAndExeModule  ) );
       
   237            }
       
   238 
       
   239         // Check FindExeL error codes
       
   240         if( find_ret != KErrNone )
       
   241 			{
       
   242 			// Module was not found, using default exe: testserverstarter.exe
       
   243 			RDebug::Print( _L( "RTestServer::Connect() Correct caps modifier module not found, capabilities cannot set" ) );
       
   244 			if ( aModuleName.Find( _L( "testscripter_ui_" ) ) == 0 ) 
       
   245 				{
       
   246 				pathAndExeModule.Copy( KDefaultUiExeName );    	
       
   247 				}
       
   248 			else
       
   249 				{
       
   250 				pathAndExeModule.Copy( KDefaultExeName );    	
       
   251 				}           
       
   252 			}
       
   253         if( trapd_ret != KErrNone )
       
   254            {
       
   255            // FindExeL fails
       
   256            RDebug::Print( _L( "RTestServer::Connect() Caps modifier module searching fails with error: %d" ), trapd_ret );
       
   257            startSemaphore.Close();
       
   258            data.Close();
       
   259            return trapd_ret;
       
   260            }
       
   261 
       
   262         }
       
   263 
       
   264     if ( doCreate )
       
   265         {
       
   266         ret = pr.Create( pathAndExeModule, data );
       
   267         RDebug::Print(
       
   268             _L( "RTestServer::Connect() Combination (3): Caps modifier [%S], Data [%S], Result [%d]" ),
       
   269             &pathAndExeModule, &data, ret );
       
   270         }
       
   271 
       
   272     data.Close();
       
   273     
       
   274     if ( ret != KErrNone )
       
   275         {
       
   276         startSemaphore.Close();  
       
   277         return ret;
       
   278         }
       
   279 
       
   280     // Process created, continue start-up
       
   281     pr.Resume();
       
   282     pr.Close();
       
   283 
       
   284     // Wait until server is started
       
   285     startSemaphore.Wait();
       
   286     startSemaphore.Close();     // Close semaphore
       
   287 
       
   288     serverName = aModuleName;
       
   289 
       
   290     // Server is up and running, connect to it    
       
   291     ret = CreateSession( serverName, Version() );    
       
   292     return ret;
       
   293 
       
   294     }
       
   295 
       
   296 
       
   297 /*
       
   298 -------------------------------------------------------------------------------
       
   299 
       
   300     Class: RTestServer
       
   301 
       
   302     Method: Version
       
   303 
       
   304     Description: Return client side version.
       
   305 
       
   306     Parameters: None
       
   307 
       
   308     Return Values: TVersion: Version number
       
   309 
       
   310     Errors/Exceptions: None
       
   311 
       
   312     Status: Approved
       
   313 
       
   314 -------------------------------------------------------------------------------
       
   315 */
       
   316 EXPORT_C TVersion RTestServer::Version() const
       
   317     {
       
   318 
       
   319     return( TVersion( KTestServerMajorVersionNumber,
       
   320                        KTestServerMinorVersionNumber, 
       
   321                        KTestServerBuildVersionNumber 
       
   322                      ) );
       
   323 
       
   324     }
       
   325 
       
   326 
       
   327 /*
       
   328 -------------------------------------------------------------------------------
       
   329 
       
   330     Class: RTestServer
       
   331 
       
   332     Method: Close
       
   333 
       
   334     Description: Closes the RTestServer session.
       
   335 
       
   336     Parameters: None
       
   337 
       
   338     Return Values: None
       
   339 
       
   340     Errors/Exceptions: None
       
   341 
       
   342     Status: Approved
       
   343     
       
   344 -------------------------------------------------------------------------------
       
   345 */
       
   346 EXPORT_C void RTestServer::Close()
       
   347     {
       
   348 
       
   349     // Check that server is connected
       
   350     if( Handle() != 0 )
       
   351         {
       
   352         TIpcArgs args( TIpcArgs::ENothing, TIpcArgs::ENothing, TIpcArgs::ENothing );
       
   353         SendReceive( ETestServerCloseSession, args );
       
   354         }
       
   355 
       
   356     RSessionBase::Close();
       
   357 
       
   358     }
       
   359  /*
       
   360 -------------------------------------------------------------------------------
       
   361 
       
   362     Class: RTestServer
       
   363 
       
   364     Method: GetServerThreadId
       
   365 
       
   366     Description: Get server thread id
       
   367 
       
   368     Parameters: None
       
   369 
       
   370     Return Values: None
       
   371 
       
   372     Errors/Exceptions: None
       
   373 
       
   374     Status: Approved
       
   375     
       
   376 -------------------------------------------------------------------------------
       
   377 */
       
   378 EXPORT_C TInt RTestServer::GetServerThreadId(TThreadId& aThreadId)
       
   379     {
       
   380 
       
   381     TInt ret(0);
       
   382 
       
   383     // Check that server is connected
       
   384     if( Handle() != 0 )
       
   385         {
       
   386         TThreadId id;
       
   387         TPckg<TThreadId> threadIdPckg( id );
       
   388         TIpcArgs args( &threadIdPckg, TIpcArgs::ENothing, TIpcArgs::ENothing );
       
   389         ret = SendReceive( ETestServerGetServerThreadId, args );  
       
   390         
       
   391         aThreadId = threadIdPckg();        
       
   392         }
       
   393         
       
   394     return ret;
       
   395 
       
   396     }            
       
   397 
       
   398 /*
       
   399 -------------------------------------------------------------------------------
       
   400 
       
   401     Class: RTestServer
       
   402 
       
   403     Method: FindExeL
       
   404 
       
   405     Description: Find exe(CapsModifier) from file system(Used in EKA2)
       
   406 
       
   407     Parameters: TFileName aModuleName: in: Module name.
       
   408                 TFileName& aPathAndExeModule: inout: Module's exe(CapsModifier)
       
   409                 path information.
       
   410 
       
   411     Return Values: TBool: Symbian error code: If exe(CapsModifier) is found
       
   412                           return KErrNone else other error code will return.
       
   413 
       
   414     Errors/Exceptions: None
       
   415 
       
   416     Status: Proposal
       
   417     
       
   418 -------------------------------------------------------------------------------
       
   419 */
       
   420 TBool RTestServer::FindExeL( TFileName aModuleName,
       
   421                                 TFileName& aPathAndExeModule )
       
   422     {
       
   423     RFs fsSession;  // For the file session handling
       
   424     RFile file;
       
   425 
       
   426     // Connect to file server
       
   427 	User::LeaveIfError( fsSession.Connect() ); // Start session
       
   428 
       
   429     TDriveList drivelist; 
       
   430 	User::LeaveIfError( fsSession.DriveList(drivelist) );
       
   431 	// A TDriveList (the list of available drives), is an array of 
       
   432 	// 26 bytes. Each byte with a non zero value signifies that the 
       
   433 	// corresponding drive is available.
       
   434     TInt driveNumber; 
       
   435 	TChar driveLetter;
       
   436     
       
   437 	for( driveNumber=EDriveA; driveNumber<=EDriveZ; driveNumber++ )
       
   438 		{
       
   439 		if( !drivelist[driveNumber] ) 
       
   440 			{
       
   441 			// If drive-list entry is zero, drive is not available
       
   442 			continue;
       
   443 			}
       
   444         User::LeaveIfError(fsSession.DriveToChar(driveNumber,driveLetter));
       
   445 
       
   446         aPathAndExeModule.Zero();
       
   447         aPathAndExeModule.Append( driveLetter );
       
   448 
       
   449         aPathAndExeModule.Append( _L(":\\sys\\bin\\") );
       
   450 
       
   451         aPathAndExeModule.Append( aModuleName );
       
   452         aPathAndExeModule.Append( _L( ".exe" ) );
       
   453 
       
   454         TInt found( KErrNone );
       
   455         found = file.Open( fsSession, aPathAndExeModule, EFileRead );
       
   456         if( found == KErrNone )
       
   457             {
       
   458             // exe(capsmodifier module) is founded.
       
   459             file.Close();
       
   460             fsSession.Close();
       
   461             return KErrNone;
       
   462             }
       
   463         }
       
   464 
       
   465     // If exe not found use testserverstarter.exe but capabilities cannot
       
   466     // set.
       
   467     if ( aModuleName.Find( _L( "testscripter_ui_" ) ) == 0 ) 
       
   468     	{
       
   469         aPathAndExeModule.Copy( KDefaultUiExeName );    	
       
   470     	}
       
   471     else
       
   472     	{
       
   473         aPathAndExeModule.Copy( KDefaultExeName );    	
       
   474     	}	
       
   475     file.Close();
       
   476     fsSession.Close();
       
   477  
       
   478     return KErrNotFound;
       
   479     
       
   480     }
       
   481 
       
   482 /*
       
   483 -------------------------------------------------------------------------------
       
   484 
       
   485     Class: RTestServer
       
   486 
       
   487     Method: GetCapsModifierName
       
   488 
       
   489     Description: Get caps modifier module name from TestScripter's test
       
   490                  case(config) file.
       
   491 
       
   492     Parameters: const TDesC& aConfigFile: in: TestScripter's test case(config)
       
   493                 file path and name.
       
   494                 TFileName& aCapsModifierName: inout: Parsed caps modifier name.
       
   495 
       
   496     Return Values: TInt: Symbian error code: Return KErrNone if caps modifier
       
   497                                              module name is successfully parsed
       
   498                                              or given else other error code
       
   499                                              will return.
       
   500 
       
   501     Errors/Exceptions: None
       
   502 
       
   503     Status: Proposal
       
   504     
       
   505 -------------------------------------------------------------------------------
       
   506 */
       
   507 TInt RTestServer::GetCapsModifier( const TDesC& aConfigFile,
       
   508                                         TFileName& aCapsModifierName )
       
   509     {
       
   510     // Create parser
       
   511     CStifParser* parser = NULL;
       
   512     TRAPD( err, parser = CStifParser::NewL( _L(""), aConfigFile ) );
       
   513     if( err != KErrNone )
       
   514         {
       
   515         return err;
       
   516         }
       
   517 
       
   518     CleanupStack::PushL( parser );
       
   519 
       
   520     // Create section
       
   521     CStifSectionParser* section = NULL;
       
   522     TRAP( err, section = parser->SectionL( KStifSettingsStartTag,
       
   523                                             KStifSettingsEndTag ) );
       
   524     if( err != KErrNone || section == NULL)
       
   525         {
       
   526         CleanupStack::PopAndDestroy( parser );
       
   527         return KErrNotFound;
       
   528         }
       
   529 
       
   530     CleanupStack::PushL( section );
       
   531 
       
   532     // Create item
       
   533     CStifItemParser* item = NULL;
       
   534     TRAP( err, item = section->GetItemLineL( KCapsModifier ) );
       
   535     if( err != KErrNone || item == NULL )
       
   536         {
       
   537         CleanupStack::PopAndDestroy( section );
       
   538         CleanupStack::PopAndDestroy( parser );
       
   539         return KErrNotFound;
       
   540         }
       
   541     CleanupStack::PushL( item );
       
   542 
       
   543     // Get caps modifier module name
       
   544     TPtrC capsModifierName;
       
   545     err = item->GetString( KCapsModifier, capsModifierName );
       
   546     if( err != KErrNone )
       
   547         {
       
   548         CleanupStack::PopAndDestroy( item );
       
   549         CleanupStack::PopAndDestroy( section );
       
   550         CleanupStack::PopAndDestroy( parser );
       
   551         return err;
       
   552         }
       
   553 
       
   554     aCapsModifierName.Copy( capsModifierName );
       
   555 
       
   556     // Remove optional '.EXE' from the name
       
   557     aCapsModifierName.LowerCase();
       
   558     TParse parse;
       
   559     parse.Set( aCapsModifierName, NULL, NULL );
       
   560 
       
   561     if ( parse.Ext() == _L(".exe") )
       
   562         {
       
   563         const TInt len = parse.Ext().Length();
       
   564         aCapsModifierName.Delete ( aCapsModifierName.Length()-len, len );
       
   565         }
       
   566 
       
   567     CleanupStack::PopAndDestroy( item );
       
   568     CleanupStack::PopAndDestroy( section );
       
   569     CleanupStack::PopAndDestroy( parser );
       
   570 
       
   571     return KErrNone;
       
   572 
       
   573     }
       
   574 
       
   575 /*
       
   576 -------------------------------------------------------------------------------
       
   577 
       
   578     Class: RTestModule
       
   579 
       
   580     Method: Open
       
   581 
       
   582     Description: Create new subsession with the RTestServer server
       
   583 
       
   584     Parameters: RTestServer& aServer          :inout: Server
       
   585                 TFileName& aIniFile           :in:    Initialization file
       
   586 
       
   587     Return Values: None
       
   588 
       
   589     Errors/Exceptions: None
       
   590 
       
   591     Status: Approved
       
   592     
       
   593 -------------------------------------------------------------------------------
       
   594 */
       
   595 EXPORT_C TInt RTestModule::Open( RTestServer& aServer,
       
   596                                  TFileName& aIniFile
       
   597                                )
       
   598     {
       
   599     TIpcArgs args( &aIniFile, TIpcArgs::ENothing, TIpcArgs::ENothing );
       
   600     return CreateSubSession( aServer, ETestModuleCreateSubSession, args );
       
   601     }
       
   602 
       
   603 
       
   604 /*
       
   605 -------------------------------------------------------------------------------
       
   606 
       
   607     Class: RTestModule
       
   608 
       
   609     Method: Close
       
   610 
       
   611     Description: Close a subsession
       
   612 
       
   613     Parameters: None
       
   614 
       
   615     Return Values: None
       
   616 
       
   617     Errors/Exceptions: None
       
   618 
       
   619     Status: Approved
       
   620 
       
   621 -------------------------------------------------------------------------------
       
   622 */
       
   623 EXPORT_C void RTestModule::Close()
       
   624     {
       
   625 
       
   626     RSubSessionBase::CloseSubSession( ETestModuleCloseSubSession );
       
   627 
       
   628     }
       
   629 
       
   630 
       
   631 /*
       
   632 -------------------------------------------------------------------------------
       
   633 
       
   634     Class: RTestModule
       
   635 
       
   636     Method: EnumerateTestCases
       
   637 
       
   638     Description: Enumerates test cases
       
   639 
       
   640     Parameters: TFileName aConfigFile         :in:  Configuration file name
       
   641                 TCaseSize& aCount             :out: Package for storing count
       
   642                 TRequestStatus& aStatus       :out: Status
       
   643 
       
   644     Return Values: None
       
   645 
       
   646     Errors/Exceptions: None
       
   647 
       
   648     Status: Approved
       
   649 
       
   650 -------------------------------------------------------------------------------
       
   651 */
       
   652 EXPORT_C void RTestModule::EnumerateTestCases( TDesC& aConfigFile,
       
   653                                                TCaseSize& aCount,
       
   654                                                TRequestStatus& aStatus
       
   655                                              )
       
   656     {
       
   657     TIpcArgs args( &aConfigFile, &aCount, TIpcArgs::ENothing );
       
   658     SendReceive( ETestModuleEnumerateTestCases, args, aStatus );
       
   659     }
       
   660 
       
   661 /*
       
   662 -------------------------------------------------------------------------------
       
   663 
       
   664     Class: RTestModule
       
   665 
       
   666     Method: GetTestCases
       
   667 
       
   668     Description: Get test cases
       
   669 
       
   670     Parameters: CFixedFlatArray<TTestCaseInfo>& aTestCaseBuffer :Out:    Cases
       
   671 
       
   672     Return Values: TInt                             Return value from operation
       
   673 
       
   674     Errors/Exceptions: None
       
   675 
       
   676     Status: Approved
       
   677 
       
   678 -------------------------------------------------------------------------------
       
   679 */
       
   680 EXPORT_C TInt RTestModule::GetTestCases( CFixedFlatArray<TTestCaseInfo>& aTestCaseBuffer )
       
   681     {
       
   682     TIpcArgs args( &aTestCaseBuffer.Des(), TIpcArgs::ENothing, TIpcArgs::ENothing );
       
   683     return SendReceive( ETestModuleGetTestCases, args );
       
   684     }
       
   685 
       
   686 /*
       
   687 -------------------------------------------------------------------------------
       
   688 
       
   689     Class: RTestModule
       
   690 
       
   691     Method: ErrorNotification
       
   692 
       
   693     Description: Request error notification
       
   694 
       
   695     Parameters: None
       
   696 
       
   697     Return Values: None
       
   698 
       
   699     Errors/Exceptions: None
       
   700 
       
   701     Status: Proposal
       
   702     
       
   703 -------------------------------------------------------------------------------
       
   704 */
       
   705 EXPORT_C void RTestModule::ErrorNotification( TErrorNotificationPckg& aError,                                           
       
   706                                               TRequestStatus& aStatus )
       
   707     {
       
   708     TIpcArgs args( &aError, TIpcArgs::ENothing, TIpcArgs::ENothing );
       
   709     SendReceive( ETestModuleErrorNotification, args, aStatus );
       
   710     }
       
   711 
       
   712 /*
       
   713 -------------------------------------------------------------------------------
       
   714 
       
   715     Class: RTestModule
       
   716 
       
   717     Method: CancelAsyncRequest
       
   718 
       
   719     Description: Cancel ongoing request
       
   720 
       
   721     Parameters: TInt aReqToCancel             :in:  Request to be cancelled
       
   722 
       
   723     Return Values: TInt                             Return value from operation
       
   724 
       
   725     Errors/Exceptions: None
       
   726 
       
   727     Status: Approved
       
   728     
       
   729 -------------------------------------------------------------------------------
       
   730 */
       
   731 EXPORT_C TInt RTestModule::CancelAsyncRequest( TInt aReqToCancel )
       
   732     {
       
   733     TIpcArgs args( aReqToCancel, TIpcArgs::ENothing, TIpcArgs::ENothing );
       
   734     return SendReceive( ETestModuleCancelAsyncRequest, args );
       
   735     }
       
   736 
       
   737 /*
       
   738 -------------------------------------------------------------------------------
       
   739 
       
   740     Class: RTestExecution
       
   741 
       
   742     Method: Open
       
   743 
       
   744     Description: create new subsession with the RTestModule
       
   745 
       
   746     Parameters: RTestServer& aServer          :in:  Handle to server
       
   747                 const TInt aCaseNumber        :in:  Case number
       
   748                 const TFileName& aConfig      :in:  Configuration file
       
   749 
       
   750     Return Values: TInt                             Return value from operation
       
   751 
       
   752     Errors/Exceptions: None
       
   753 
       
   754     Status: Approved
       
   755     
       
   756 -------------------------------------------------------------------------------
       
   757 */
       
   758 EXPORT_C TInt RTestExecution::Open( RTestServer& aServer,
       
   759                                     const TInt aCaseNumber,
       
   760                                     const TFileName& aConfig
       
   761                                   )
       
   762     {
       
   763     TIpcArgs args( aCaseNumber, &aConfig, TIpcArgs::ENothing );
       
   764     return CreateSubSession( aServer, ETestExecutionCreateSubSession, args );
       
   765     }
       
   766 
       
   767 /*
       
   768 -------------------------------------------------------------------------------
       
   769 
       
   770     Class: RTestModule
       
   771 
       
   772     Method: Close
       
   773 
       
   774     Description: close a subsession
       
   775 
       
   776     Parameters: None
       
   777 
       
   778     Return Values: None
       
   779 
       
   780     Errors/Exceptions: None
       
   781 
       
   782     Status: Approved
       
   783     
       
   784 -------------------------------------------------------------------------------
       
   785 */
       
   786 EXPORT_C void RTestExecution::Close()
       
   787     {
       
   788 
       
   789     // Close subsession
       
   790     RSubSessionBase::CloseSubSession( ETestExecutionCloseSubSession );
       
   791 
       
   792     }
       
   793 
       
   794 
       
   795 
       
   796 
       
   797 /*
       
   798 -------------------------------------------------------------------------------
       
   799 
       
   800     Class: RTestExecution
       
   801 
       
   802     Method: RunTestCase
       
   803 
       
   804     Description: Runs a test case
       
   805 
       
   806     Parameters: TFullTestResultPckg& aResult  :out: Case result
       
   807                 TRequestStatus& aStatus       :out: Request to be completed
       
   808 
       
   809     Return Values: None
       
   810 
       
   811     Errors/Exceptions: None
       
   812 
       
   813     Status: Approved
       
   814     
       
   815 -------------------------------------------------------------------------------
       
   816 */
       
   817 EXPORT_C void RTestExecution::RunTestCase( TFullTestResultPckg& aResult,
       
   818                                            TRequestStatus& aStatus 
       
   819                                          )
       
   820     {
       
   821     TIpcArgs args( &aResult, TIpcArgs::ENothing, TIpcArgs::ENothing );
       
   822     SendReceive( ETestExecutionRunTestCase, args, aStatus );
       
   823     }
       
   824 
       
   825 /*
       
   826 -------------------------------------------------------------------------------
       
   827 
       
   828     Class: RTestExecution
       
   829 
       
   830     Method: RunTestCase
       
   831 
       
   832     Description: Runs a test case
       
   833 
       
   834     Parameters: TFullTestResultPckg& aResult  :out: Case result
       
   835                 const TDesC& aTestCaseArgs: Test case arguments
       
   836                 TRequestStatus& aStatus       :out: Request to be completed
       
   837 
       
   838     Return Values: None
       
   839 
       
   840     Errors/Exceptions: None
       
   841 
       
   842     Status: Approved
       
   843     
       
   844 -------------------------------------------------------------------------------
       
   845 */
       
   846 EXPORT_C void RTestExecution::RunTestCase( TFullTestResultPckg& aResult,
       
   847                                            const TDesC& aTestCaseArgs,
       
   848                                            TRequestStatus& aStatus 
       
   849                                          )
       
   850     {
       
   851     TIpcArgs args( &aResult, &aTestCaseArgs, TIpcArgs::ENothing );
       
   852     SendReceive( ETestExecutionRunTestCase, args, aStatus );
       
   853     }
       
   854 
       
   855 /*
       
   856 -------------------------------------------------------------------------------
       
   857 
       
   858     Class: RTestExecution
       
   859 
       
   860     Method: NotifyProgress
       
   861 
       
   862     Description: Notify about test case progress, i.e test case prints.
       
   863 
       
   864     Parameters: TTestProgressPckg& aProgress  :out: Print info
       
   865                 TRequestStatus& aStatus       :out: Request to be completed
       
   866 
       
   867     Return Values: TInt                             Always KErrNone
       
   868 
       
   869     Errors/Exceptions: None
       
   870 
       
   871     Status: Approved
       
   872 
       
   873 -------------------------------------------------------------------------------
       
   874 */
       
   875 EXPORT_C TInt RTestExecution::NotifyProgress( TTestProgressPckg& aProgress,
       
   876                                               TRequestStatus& aStatus 
       
   877                                             )
       
   878     {
       
   879     TIpcArgs args( &aProgress, TIpcArgs::ENothing, TIpcArgs::ENothing );
       
   880     SendReceive( ETestExecutionNotifyProgress, args, aStatus );
       
   881     return KErrNone;
       
   882     }
       
   883 
       
   884 
       
   885 /*
       
   886 -------------------------------------------------------------------------------
       
   887 
       
   888     Class: RTestModule
       
   889 
       
   890     Method: Pause
       
   891 
       
   892     Description: Pauses a test case
       
   893 
       
   894     Parameters: None
       
   895 
       
   896     Return Values: TInt                             Return value from operation
       
   897 
       
   898     Errors/Exceptions: None
       
   899 
       
   900     Status: Approved
       
   901 
       
   902 -------------------------------------------------------------------------------
       
   903 */
       
   904 EXPORT_C TInt RTestExecution::Pause()
       
   905     {
       
   906     TIpcArgs args( TIpcArgs::ENothing, TIpcArgs::ENothing, TIpcArgs::ENothing );
       
   907     return SendReceive( ETestExecutionPause, args );
       
   908     }
       
   909 
       
   910 /*
       
   911 -------------------------------------------------------------------------------
       
   912 
       
   913     Class: RTestModule
       
   914 
       
   915     Method: Resume
       
   916 
       
   917     Description: Resumes a test case
       
   918 
       
   919     Parameters: None
       
   920 
       
   921     Return Values: TInt                             Return value from operation
       
   922 
       
   923     Errors/Exceptions: None
       
   924 
       
   925     Status: Approved
       
   926     
       
   927 -------------------------------------------------------------------------------
       
   928 */
       
   929 EXPORT_C TInt RTestExecution::Resume()
       
   930     {
       
   931     TIpcArgs args( TIpcArgs::ENothing, TIpcArgs::ENothing, TIpcArgs::ENothing );
       
   932     return SendReceive( ETestExecutionResume, args );
       
   933     }
       
   934 
       
   935 /*
       
   936 -------------------------------------------------------------------------------
       
   937 
       
   938     Class: RTestModule
       
   939 
       
   940     Method: CancelAsyncRequest
       
   941 
       
   942     Description: Cancels an asynchronous request.
       
   943 
       
   944     Parameters: TInt aReqToCancel             :in:  Request to be cancelled.
       
   945 
       
   946     Return Values: TInt                             Return value from operation
       
   947 
       
   948     Errors/Exceptions: None
       
   949 
       
   950     Status: Approved
       
   951 
       
   952 -------------------------------------------------------------------------------
       
   953 */
       
   954 EXPORT_C TInt RTestExecution::CancelAsyncRequest( TInt aReqToCancel )
       
   955     {
       
   956     TIpcArgs args( aReqToCancel, TIpcArgs::ENothing, TIpcArgs::ENothing );
       
   957     return SendReceive( ETestExecutionCancelAsyncRequest, args );
       
   958     }
       
   959 
       
   960 /*
       
   961 -------------------------------------------------------------------------------
       
   962 
       
   963     Class: RTestModule
       
   964 
       
   965     Method: NotifyEvent
       
   966 
       
   967     Description: NotifyEvent is used to receive event requests
       
   968                  from the Test module.
       
   969 
       
   970     Parameters: TEventIfPckg& aEvent          :inout:  Event package.
       
   971                 TRequestStatus& aStatus       :out:    Request to be completed
       
   972                 TInt aError                   :in:     Error from event system
       
   973 
       
   974     Return Values: TInt                                Always KErrNone
       
   975 
       
   976     Errors/Exceptions: None
       
   977 
       
   978     Status: Proposal
       
   979     
       
   980 -------------------------------------------------------------------------------
       
   981 */
       
   982 EXPORT_C TInt RTestExecution::NotifyEvent( TEventIfPckg& aEvent,
       
   983                                            TRequestStatus& aStatus,
       
   984                                            TInt aError )
       
   985     {
       
   986     TIpcArgs args( &aEvent, aError, TIpcArgs::ENothing );
       
   987     SendReceive( ETestExecutionNotifyEvent, args, aStatus );
       
   988     return KErrNone;
       
   989     }
       
   990 
       
   991 /*
       
   992 -------------------------------------------------------------------------------
       
   993 
       
   994     Class: RTestModule
       
   995 
       
   996     Method: NotifyRemoteCmd
       
   997 
       
   998     Description: NotifyRemoteCmd is used to receive RemoteCmd requests
       
   999                  from the Test module.
       
  1000 
       
  1001     Parameters: TRemoteCmdPckg& aRemoteCommand: nout: Remote command's packege.
       
  1002                 TRemoteCmdType aType: in: Remote type.
       
  1003                 TRequestStatus& aStatus: inout: Request to be completed
       
  1004 
       
  1005     Return Values: TInt: Always KErrNone
       
  1006 
       
  1007     Errors/Exceptions: None
       
  1008 
       
  1009     Status: Proposal
       
  1010     
       
  1011 -------------------------------------------------------------------------------
       
  1012 */
       
  1013 EXPORT_C TInt RTestExecution::NotifyRemoteCmd( TStifCommandPckg& aRemoteCommand,
       
  1014                                                TPckg<TInt>& aMsgSizePckg,
       
  1015                                                TRequestStatus& aStatus )
       
  1016     {
       
  1017 // Construct message
       
  1018     TIpcArgs args( &aRemoteCommand, &aMsgSizePckg, TIpcArgs::ENothing );
       
  1019     SendReceive( ETestExecutionNotifyRemoteCmd, args, aStatus );
       
  1020     return KErrNone;
       
  1021     }
       
  1022 
       
  1023 /*
       
  1024 -------------------------------------------------------------------------------
       
  1025 
       
  1026     Class: RTestExecution
       
  1027 
       
  1028     Method: ReadRemoteCmdInfo
       
  1029 
       
  1030     Description: ReadRemoteCmdInfo is used to receive RemoteCmd requests
       
  1031                  from the Test module.
       
  1032 
       
  1033     Parameters: TDesC& aMsg :inout: message.
       
  1034                 TRemoteCommand aType :in: Remote command's type
       
  1035                 TInt aError: in: Symbian error code
       
  1036 
       
  1037     Return Values: TInt: Always KErrNone
       
  1038 
       
  1039     Errors/Exceptions: None
       
  1040 
       
  1041     Status: Proposal
       
  1042     
       
  1043 -------------------------------------------------------------------------------
       
  1044 */
       
  1045 EXPORT_C TInt RTestExecution::ReadRemoteCmdInfo( TDes8& aMsg,
       
  1046                                                  TStifCommand aType,
       
  1047                                                  TInt aError )
       
  1048     {
       
  1049     TInt value = 0;
       
  1050     if( aError != KErrNone )
       
  1051         {
       
  1052         value = aError;
       
  1053         }
       
  1054     else
       
  1055         {
       
  1056         value = aMsg.Length();
       
  1057         }
       
  1058 
       
  1059 // Construct message
       
  1060     TIpcArgs args( &aMsg, aType, value );
       
  1061      // Synchronous method so return a value
       
  1062     return SendReceive( ETestExecutionReadRemoteCmdInfo, args );
       
  1063     }
       
  1064     
       
  1065 #if 0
       
  1066 /*
       
  1067 -------------------------------------------------------------------------------
       
  1068 
       
  1069     Class: RTestExecution
       
  1070 
       
  1071     Method: ReadRemoteCmdInfo
       
  1072 
       
  1073     Description: ReadRemoteCmdInfo is used to receive RemoteCmd requests
       
  1074                  from the Test module.
       
  1075 
       
  1076     Parameters: TRebootParamsPckg& aRemoteType :inout: Remote type.
       
  1077                 TRemoteCommand aType :in: Remote command's type
       
  1078                 TInt aError: in: Symbian error code
       
  1079 
       
  1080     Return Values: TInt: Always KErrNone
       
  1081 
       
  1082     Errors/Exceptions: None
       
  1083 
       
  1084     Status: Proposal
       
  1085     
       
  1086 -------------------------------------------------------------------------------
       
  1087 */
       
  1088 EXPORT_C TInt RTestExecution::ReadRemoteCmdInfo( 
       
  1089                                             TRebootParamsPckg& aRemoteType,
       
  1090                                             TRemoteCommand aType,
       
  1091                                             TInt aError )
       
  1092     {
       
  1093 // Construct message
       
  1094     TIpcArgs args( &aRemoteType, aType, aError );
       
  1095     // Synchronous method so return a value
       
  1096     return SendReceive( ETestExecutionReadRemoteCmdInfo, args );
       
  1097     }
       
  1098 
       
  1099 /*
       
  1100 -------------------------------------------------------------------------------
       
  1101 
       
  1102     Class: RTestExecution
       
  1103 
       
  1104     Method: ReadRemoteCmdInfo
       
  1105 
       
  1106     Description: ReadRemoteCmdInfo is used to receive RemoteCmd requests
       
  1107                  from the Test module.
       
  1108 
       
  1109     Parameters: TRebootStateParamsPckg& aRemoteState :inout: Remote state.
       
  1110                 TRemoteCommand aType :in: Remote command's type
       
  1111                 TInt aError: in: Symbian error code
       
  1112 
       
  1113     Return Values: TInt: Always KErrNone
       
  1114 
       
  1115     Errors/Exceptions: None
       
  1116 
       
  1117     Status: Proposal
       
  1118     
       
  1119 -------------------------------------------------------------------------------
       
  1120 */
       
  1121 EXPORT_C TInt RTestExecution::ReadRemoteCmdInfo( 
       
  1122                                         TRebootStateParamsPckg& aRemoteState,
       
  1123                                         TRemoteCommand aType,
       
  1124                                         TInt aError )
       
  1125     {
       
  1126     // Construct message
       
  1127     TIpcArgs args( &aRemoteState, aType, aError );
       
  1128     // Synchronous method so return a value
       
  1129     return SendReceive( ETestExecutionReadRemoteCmdInfo, args );
       
  1130     }
       
  1131 
       
  1132 /*
       
  1133 -------------------------------------------------------------------------------
       
  1134 
       
  1135     Class: RTestExecution
       
  1136 
       
  1137     Method: ReadRemoteCmdInfo
       
  1138 
       
  1139     Description: ReadRemoteCmdInfo is used to receive RemoteCmd requests
       
  1140                  from the Test module.
       
  1141 
       
  1142     Parameters: TGetRebootStoredParamsPckg& aRemoteStoredState :inout: Stored
       
  1143                 state.
       
  1144                 TRemoteCommand aType :in: Remote command's type
       
  1145                 TInt aError: in: Symbian error code
       
  1146 
       
  1147     Return Values: TInt: Always KErrNone
       
  1148 
       
  1149     Errors/Exceptions: None
       
  1150 
       
  1151     Status: Proposal
       
  1152     
       
  1153 -------------------------------------------------------------------------------
       
  1154 */
       
  1155 EXPORT_C TInt RTestExecution::ReadRemoteCmdInfo( 
       
  1156                                 TGetRebootStoredParamsPckg& aRemoteStoredState,
       
  1157                                 TRemoteCommand aType,
       
  1158                                 TInt aError )
       
  1159     {
       
  1160     // Construct message
       
  1161     TIpcArgs args( &aRemoteStoredState, aType, aError );
       
  1162     // Synchronous method so return a value
       
  1163     return SendReceive( ETestExecutionReadRemoteCmdInfo, args );
       
  1164     }
       
  1165 #endif // 0
       
  1166 
       
  1167 /*
       
  1168 -------------------------------------------------------------------------------
       
  1169 
       
  1170     Class: RTestExecution
       
  1171 
       
  1172     Method: NotifyCommand
       
  1173 
       
  1174     Description: NotifyCommand is used to receive command requests
       
  1175                  from the Test module. DEPRECATED !!
       
  1176                  Use NotifyCommand2 instead.
       
  1177 
       
  1178     Parameters: aStifCommandPckg:     command
       
  1179                 aParam1Pckg:          parameter of command
       
  1180                 aTestCaseHandlePckg:  handle to test case
       
  1181                 aStatus:              request status
       
  1182                 aError:               error
       
  1183 
       
  1184     Return Values: TInt               Always KErrNone
       
  1185 
       
  1186     Errors/Exceptions: None
       
  1187 
       
  1188     Status: Proposal
       
  1189 
       
  1190 -------------------------------------------------------------------------------
       
  1191 */
       
  1192 EXPORT_C TInt RTestExecution::NotifyCommand(TCommandPckg& /*aCommandPckg*/,
       
  1193                                             TBuf8<KMaxCommandParamsLength>& /*aParamsPckg*/,
       
  1194                                             TRequestStatus& /*aStatus*/,
       
  1195                                             TInt /*aError*/)
       
  1196     {
       
  1197     /*TIpcArgs args(&aCommandPckg, &aParamsPckg, TIpcArgs::ENothing);
       
  1198     SendReceive(ETestExecutionNotifyCommand, args, aStatus);
       
  1199     return KErrNone;*/
       
  1200     return KErrNotSupported;
       
  1201     }
       
  1202 
       
  1203 /*
       
  1204 -------------------------------------------------------------------------------
       
  1205 
       
  1206     Class: RTestExecution
       
  1207 
       
  1208     Method: NotifyCommand2
       
  1209 
       
  1210     Description: NotifyCommand is used to receive command requests
       
  1211                  from the Test module.
       
  1212 
       
  1213     Parameters: aStifCommandPckg:     command
       
  1214                 aParam1Pckg:          parameter of command
       
  1215                 aTestCaseHandlePckg:  handle to test case
       
  1216                 aStatus:              request status
       
  1217                 aError:               error
       
  1218 
       
  1219     Return Values: TInt               Always KErrNone
       
  1220 
       
  1221     Errors/Exceptions: None
       
  1222 
       
  1223     Status: Proposal
       
  1224 
       
  1225 -------------------------------------------------------------------------------
       
  1226 */
       
  1227 EXPORT_C TInt RTestExecution::NotifyCommand2(TCommandPckg& aCommandPckg,
       
  1228                                             TDes8& aParamsPckg,
       
  1229                                             TRequestStatus& aStatus,
       
  1230                                             TInt /*aError*/)
       
  1231     {
       
  1232     TIpcArgs args(&aCommandPckg, &aParamsPckg, TIpcArgs::ENothing);
       
  1233     SendReceive(ETestExecutionNotifyCommand, args, aStatus);
       
  1234     return KErrNone;
       
  1235     }
       
  1236 
       
  1237 // End of File