stif/TestEngine/src/TestModuleInfo.cpp
changeset 0 a03f92240627
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 module contains implementation of 
       
    15 * CTestModuleList class and CTestModuleInfo class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "TestModuleInfo.h"
       
    21 #include <e32svr.h>
       
    22 #include "Logging.h"
       
    23 
       
    24 // EXTERNAL DATA STRUCTURES
       
    25 // None
       
    26 
       
    27 // EXTERNAL FUNCTION PROTOTYPES
       
    28 // None
       
    29 
       
    30 // CONSTANTS
       
    31 // None
       
    32 
       
    33 // MACROS
       
    34 // None
       
    35 
       
    36 // LOCAL CONSTANTS AND MACROS
       
    37 // None
       
    38 
       
    39 // MODULE DATA STRUCTURES
       
    40 // None
       
    41 
       
    42 // LOCAL FUNCTION PROTOTYPES
       
    43 // None
       
    44 
       
    45 // FORWARD DECLARATIONS
       
    46 // None
       
    47 
       
    48 // ==================== LOCAL FUNCTIONS =======================================
       
    49 // None
       
    50 
       
    51 #define LOGGER iLogger
       
    52 
       
    53 // ================= MEMBER FUNCTIONS =========================================
       
    54 
       
    55 /*
       
    56 -------------------------------------------------------------------------------
       
    57 
       
    58     Class: CTestModuleInfo
       
    59 
       
    60     Method: CTestModuleInfo
       
    61 
       
    62     Description: Default constructor
       
    63 
       
    64     C++ default constructor can NOT contain any code, that
       
    65     might leave.
       
    66 
       
    67     Parameters: None
       
    68 
       
    69     Return Values: None
       
    70 
       
    71     Errors/Exceptions: None
       
    72 
       
    73     Status: Approved
       
    74 
       
    75 -------------------------------------------------------------------------------
       
    76 */
       
    77 CTestModuleInfo::CTestModuleInfo()
       
    78     {
       
    79 	iLogger = NULL;
       
    80     iModuleName = NULL;
       
    81     iIniFileName = NULL;
       
    82     }
       
    83 
       
    84 /*
       
    85 -------------------------------------------------------------------------------
       
    86 
       
    87     Class: CTestModuleInfo
       
    88 
       
    89     Method: ConstructL
       
    90 
       
    91     Description: Symbian OS second phase constructor
       
    92 
       
    93     Symbian OS default constructor can leave.
       
    94 
       
    95     Parameters: aModuleName: module name
       
    96                 aLogger: pointer to stif logger
       
    97 
       
    98     Return Values: None
       
    99 
       
   100     Errors/Exceptions:
       
   101 
       
   102     Status: Approved
       
   103 
       
   104 -------------------------------------------------------------------------------
       
   105 */
       
   106 void CTestModuleInfo::ConstructL(TDesC& aModuleName, CStifLogger* aLogger)
       
   107     {
       
   108 	iLogger = aLogger;
       
   109 
       
   110 	if(iModuleName)
       
   111 	    {
       
   112         delete iModuleName;
       
   113 		iModuleName = NULL;
       
   114         }
       
   115     iModuleName = aModuleName.AllocL();
       
   116     }
       
   117 
       
   118 /*
       
   119 -------------------------------------------------------------------------------
       
   120 
       
   121     Class: CTestModuleInfo
       
   122 
       
   123     Method: NewL
       
   124 
       
   125     Description: Two-phased constructor.
       
   126 
       
   127     Parameters: aModuleName: module name
       
   128                 aLogger: pointer to stif logger
       
   129 
       
   130     Return Values: CTestModuleInfo* : pointer to created object
       
   131 
       
   132     Errors/Exceptions: Leaves if memory allocation for object fails
       
   133                        Leaves if ConstructL leaves
       
   134 
       
   135     Status: Approved
       
   136 
       
   137 -------------------------------------------------------------------------------
       
   138 */
       
   139 CTestModuleInfo* CTestModuleInfo::NewL(TDesC& aModuleName, CStifLogger* aLogger)
       
   140     {
       
   141     CTestModuleInfo* self = new (ELeave) CTestModuleInfo();
       
   142     CleanupStack::PushL(self);
       
   143     self->ConstructL(aModuleName, aLogger);
       
   144     CleanupStack::Pop(self);
       
   145     return self;
       
   146     }
       
   147 
       
   148 /*
       
   149 -------------------------------------------------------------------------------
       
   150 
       
   151     Class: CTestModuleInfo
       
   152 
       
   153     Method: ~CTestModuleInfo
       
   154 
       
   155     Description: Destructor.
       
   156 
       
   157     Parameters: None
       
   158 
       
   159     Return Values: None
       
   160 
       
   161     Errors/Exceptions: None
       
   162 
       
   163     Status: Approved
       
   164 
       
   165 -------------------------------------------------------------------------------
       
   166 */
       
   167 CTestModuleInfo::~CTestModuleInfo()
       
   168     {
       
   169     delete iModuleName;
       
   170     delete iIniFileName;
       
   171 
       
   172     iCfgFiles.ResetAndDestroy();
       
   173     iCfgFiles.Close();
       
   174     }
       
   175 
       
   176 /*
       
   177 -------------------------------------------------------------------------------
       
   178 
       
   179     Class: CTestModuleInfo
       
   180 
       
   181     Method: SetIniFile
       
   182 
       
   183     Description: Set ini file
       
   184 
       
   185     Parameters: aIniFileName: initialization file name
       
   186 
       
   187     Return Values: KErrNone if everything went ok
       
   188                    KErrAlreadyExists if ini file was already set
       
   189                    Symbian error code otherwise
       
   190 
       
   191     Errors/Exceptions: None
       
   192 
       
   193     Status: Approved
       
   194 
       
   195 -------------------------------------------------------------------------------
       
   196 */
       
   197 EXPORT_C TInt CTestModuleInfo::SetIniFile(TDesC& aIniFileName)
       
   198     {
       
   199 	if(iIniFileName)
       
   200 	    {
       
   201         return KErrAlreadyExists;
       
   202         }
       
   203 
       
   204     TRAPD(err, iIniFileName = aIniFileName.AllocL());
       
   205     if(err != KErrNone)
       
   206         {
       
   207         if(iLogger)
       
   208             {
       
   209             __TRACE(KError, (_L("Could not create descriptor (CTestModuleInfo::SetIniFile) for string '%S'. Error %d."), &aIniFileName, err));
       
   210             }
       
   211         else
       
   212             {
       
   213             RDebug::Print(_L("Could not create descriptor (CTestModuleInfo::SetIniFile) for string '%S'. Error %d."), &aIniFileName, err);
       
   214             }
       
   215         return err;
       
   216         }
       
   217 
       
   218     return KErrNone;
       
   219     }
       
   220 
       
   221 /*
       
   222 -------------------------------------------------------------------------------
       
   223 
       
   224     Class: CTestModuleInfo
       
   225 
       
   226     Method: AddCfgFile
       
   227 
       
   228     Description: Add config file if it is not yet added to the array
       
   229 
       
   230     Parameters: aCfgFileName: file name
       
   231 
       
   232     Return Values: KErrNone if everything went ok
       
   233                    KErrAlreadyExists if config file is already present
       
   234                    Symbian error code otherwise
       
   235 
       
   236     Errors/Exceptions: None
       
   237 
       
   238     Status: Approved
       
   239 
       
   240 -------------------------------------------------------------------------------
       
   241 */
       
   242 EXPORT_C TInt CTestModuleInfo::AddCfgFile(TDesC& aCfgFileName)
       
   243     {
       
   244     //Check if given file name does not exist already
       
   245     TInt cnt = iCfgFiles.Count();
       
   246     TInt i;
       
   247     TFileName cfgFileName;
       
   248 
       
   249     //Check if given module is already on the list
       
   250     for(i = 0; i < cnt; i++)
       
   251         {
       
   252         iCfgFiles[i]->GetCfgFileName(cfgFileName);
       
   253         if(cfgFileName == aCfgFileName)
       
   254             {
       
   255             return KErrAlreadyExists;
       
   256 			}
       
   257         }
       
   258 
       
   259     //Add to array
       
   260     TInt err = KErrNone;
       
   261     CTestCaseFileInfo* tmp = NULL;
       
   262     TRAP(err, tmp = CTestCaseFileInfo::NewL(aCfgFileName, iLogger));
       
   263     if(err != KErrNone)
       
   264         {
       
   265         if(iLogger)
       
   266             {
       
   267             __TRACE(KError, (_L("Could not create CTestCaseFileInfo object (CTestModuleInfo::AddCfgFile). Error %d."), err));
       
   268             }
       
   269         else
       
   270             {
       
   271             RDebug::Print(_L("Could not create CTestCaseFileInfo object (CTestModuleInfo::AddCfgFile). Error %d."), err);
       
   272             }
       
   273 		return err;
       
   274         }
       
   275     if(!tmp)
       
   276         {
       
   277         if(iLogger)
       
   278             {
       
   279             __TRACE(KError, (_L("Could not create CTestCaseFileInfo object (CTestModuleInfo::AddCfgFile)")));
       
   280             }
       
   281         else
       
   282             {
       
   283             RDebug::Print(_L("Could not create CTestCaseFileInfo object (CTestModuleInfo::AddCfgFile)"));
       
   284             }
       
   285 		return KErrGeneral;
       
   286         }
       
   287 
       
   288     err = iCfgFiles.Append(tmp);
       
   289     if(err != KErrNone)
       
   290         {
       
   291         if(iLogger)
       
   292             {
       
   293             __TRACE(KError, (_L("Could not append CTestCaseFileInfo object to array (CTestModuleInfo::AddCfgFile). Error %d."), err));
       
   294             }
       
   295         else
       
   296             {
       
   297             RDebug::Print(_L("Could not append CTestCaseFileInfo object to array (CTestModuleInfo::AddCfgFile). Error %d."), err);
       
   298             }
       
   299         delete tmp;
       
   300         return err;
       
   301         }
       
   302 
       
   303     return KErrNone;
       
   304     }
       
   305 
       
   306 /*
       
   307 -------------------------------------------------------------------------------
       
   308 
       
   309     Class: CTestModuleInfo
       
   310 
       
   311     Method: CountCfgFiles
       
   312 
       
   313     Description: Return number of config files
       
   314 
       
   315     Parameters: None
       
   316 
       
   317     Return Values: number of config files
       
   318 
       
   319     Errors/Exceptions: None
       
   320 
       
   321     Status: Approved
       
   322 
       
   323 -------------------------------------------------------------------------------
       
   324 */
       
   325 EXPORT_C TInt CTestModuleInfo::CountCfgFiles(void)
       
   326     {
       
   327     return iCfgFiles.Count();
       
   328     }
       
   329 
       
   330 /*
       
   331 -------------------------------------------------------------------------------
       
   332 
       
   333     Class: CTestModuleInfo
       
   334 
       
   335     Method: GetModuleName
       
   336 
       
   337     Description: Get module name
       
   338 
       
   339     Parameters: None
       
   340 
       
   341     Return Values:
       
   342 
       
   343     Errors/Exceptions: None
       
   344 
       
   345     Status: Approved
       
   346 
       
   347 -------------------------------------------------------------------------------
       
   348 */
       
   349 EXPORT_C TInt CTestModuleInfo::GetModuleName(TDes& aModuleName)
       
   350     {
       
   351     aModuleName.Zero();
       
   352     if(iModuleName)
       
   353         {
       
   354         aModuleName.Copy(*iModuleName);
       
   355         }
       
   356     return KErrNone;
       
   357     }
       
   358 
       
   359 /*
       
   360 -------------------------------------------------------------------------------
       
   361 
       
   362     Class: CTestModuleInfo
       
   363 
       
   364     Method: GetIniFileName
       
   365 
       
   366     Description: Get module ini file name
       
   367 
       
   368     Parameters: None
       
   369 
       
   370     Return Values:
       
   371 
       
   372     Errors/Exceptions: None
       
   373 
       
   374     Status: Approved
       
   375 
       
   376 -------------------------------------------------------------------------------
       
   377 */
       
   378 EXPORT_C TInt CTestModuleInfo::GetIniFileName(TDes& aIniFileName)
       
   379     {
       
   380     aIniFileName.Zero();
       
   381     if(iIniFileName)
       
   382         {
       
   383         aIniFileName.Copy(*iIniFileName);
       
   384         }
       
   385     return KErrNone;
       
   386     }
       
   387 
       
   388 /*
       
   389 -------------------------------------------------------------------------------
       
   390 
       
   391     Class: CTestModuleInfo
       
   392 
       
   393     Method: GetCfgFileName
       
   394 
       
   395     Description: Get config file name
       
   396 
       
   397     Parameters: aIndex: index of config file
       
   398 
       
   399     Return Values: TDesC&: config file name
       
   400 
       
   401     Errors/Exceptions: None
       
   402 
       
   403     Status: Approved
       
   404 
       
   405 -------------------------------------------------------------------------------
       
   406 */
       
   407 EXPORT_C TInt CTestModuleInfo::GetCfgFileName(TInt aIndex, TDes& aCfgFileName)
       
   408     {
       
   409     aCfgFileName.Zero();
       
   410     TInt cnt = iCfgFiles.Count();
       
   411 
       
   412     //Check index
       
   413     if(aIndex >= cnt || aIndex < 0)
       
   414         {
       
   415         if(iLogger)
       
   416             {
       
   417             __TRACE(KError, (_L("Given index reaches out of array (CTestModuleInfo::GetCfgFileName). Given index: %d. Max allowed index: %d"), aIndex, cnt - 1));
       
   418             }
       
   419         else
       
   420             {
       
   421             RDebug::Print(_L("Given index reaches out of array (CTestModuleInfo::GetCfgFileName). Given index: %d. Max allowed index: %d"), aIndex, cnt - 1);
       
   422             }
       
   423         return KErrArgument;
       
   424         }
       
   425 
       
   426     TInt ret = iCfgFiles[aIndex]->GetCfgFileName(aCfgFileName);
       
   427     return ret;
       
   428     }
       
   429 
       
   430 /*
       
   431 -------------------------------------------------------------------------------
       
   432 
       
   433     Class: CTestModuleInfo
       
   434 
       
   435     Method: GetUncheckedCfgFile
       
   436 
       
   437     Description: Get first unchecked test case file
       
   438 
       
   439     Parameters: None
       
   440 
       
   441     Return Values: Pointer to CTestCaseFileInfo object if found
       
   442                    Null otherwise
       
   443 
       
   444     Errors/Exceptions: None
       
   445 
       
   446     Status: Approved
       
   447 
       
   448 -------------------------------------------------------------------------------
       
   449 */
       
   450 CTestCaseFileInfo* CTestModuleInfo::GetUncheckedCfgFile(void)
       
   451     {
       
   452     TInt cnt = iCfgFiles.Count();
       
   453     TInt i;
       
   454 
       
   455     for(i = 0; i < cnt; i++)
       
   456         {
       
   457         if(!iCfgFiles[i]->IsChecked())
       
   458             {
       
   459             return iCfgFiles[i];
       
   460             }
       
   461         }
       
   462 
       
   463     return NULL;
       
   464     }
       
   465 
       
   466 // ================= MEMBER FUNCTIONS =========================================
       
   467 
       
   468 /*
       
   469 -------------------------------------------------------------------------------
       
   470 
       
   471     Class: CTestModuleList
       
   472 
       
   473     Method: CTestModuleList
       
   474 
       
   475     Description: Default constructor
       
   476 
       
   477     C++ default constructor can NOT contain any code, that
       
   478     might leave.
       
   479 
       
   480     Parameters: None
       
   481 
       
   482     Return Values: None
       
   483 
       
   484     Errors/Exceptions: None
       
   485 
       
   486     Status: Approved
       
   487 
       
   488 -------------------------------------------------------------------------------
       
   489 */
       
   490 CTestModuleList::CTestModuleList()
       
   491     {
       
   492 	iLogger = NULL;
       
   493     }
       
   494 
       
   495 /*
       
   496 -------------------------------------------------------------------------------
       
   497 
       
   498     Class: CTestModuleList
       
   499 
       
   500     Method: ConstructL
       
   501 
       
   502     Description: Symbian OS second phase constructor
       
   503 
       
   504     Symbian OS default constructor can leave.
       
   505 
       
   506     Parameters: aLogger: pointer to stif logger
       
   507 
       
   508     Return Values: None
       
   509 
       
   510     Errors/Exceptions:
       
   511 
       
   512     Status: Approved
       
   513 
       
   514 -------------------------------------------------------------------------------
       
   515 */
       
   516 void CTestModuleList::ConstructL(CStifLogger* aLogger)
       
   517     {
       
   518 	iLogger = aLogger;
       
   519     }
       
   520 
       
   521 /*
       
   522 -------------------------------------------------------------------------------
       
   523 
       
   524     Class: CTestModuleList
       
   525 
       
   526     Method: NewL
       
   527 
       
   528     Description: Two-phased constructor.
       
   529 
       
   530     Parameters: aLogger: pointer to stif logger
       
   531 
       
   532     Return Values: CTestModuleList* : pointer to created object
       
   533 
       
   534     Errors/Exceptions: Leaves if memory allocation for object fails
       
   535                        Leaves if ConstructL leaves
       
   536 
       
   537     Status: Approved
       
   538 
       
   539 -------------------------------------------------------------------------------
       
   540 */
       
   541 EXPORT_C CTestModuleList* CTestModuleList::NewL(CStifLogger* aLogger)
       
   542     {
       
   543     CTestModuleList* self = new (ELeave) CTestModuleList();
       
   544     CleanupStack::PushL(self);
       
   545     self->ConstructL(aLogger);
       
   546     CleanupStack::Pop(self);
       
   547     return self;
       
   548     }
       
   549 
       
   550 /*
       
   551 -------------------------------------------------------------------------------
       
   552 
       
   553     Class: CTestModuleList
       
   554 
       
   555     Method: ~CTestModuleList
       
   556 
       
   557     Description: Destructor.
       
   558 
       
   559     Parameters: None
       
   560 
       
   561     Return Values: None
       
   562 
       
   563     Errors/Exceptions: None
       
   564 
       
   565     Status: Approved
       
   566 
       
   567 -------------------------------------------------------------------------------
       
   568 */
       
   569 EXPORT_C CTestModuleList::~CTestModuleList()
       
   570     {
       
   571     iTestModules.ResetAndDestroy();
       
   572     iTestModules.Close();
       
   573     }
       
   574 
       
   575 /*
       
   576 -------------------------------------------------------------------------------
       
   577 
       
   578     Class: CTestModuleList
       
   579 
       
   580     Method: AddTestModule
       
   581 
       
   582     Description: Adds new test module to list if specified module is not already added.
       
   583 
       
   584     Parameters: aModuleName: module name
       
   585 
       
   586     Return Values: KErrNone if opereation succeeded
       
   587                    KErrAlreadyExists if module is already present on the list
       
   588                    Symbian error code otherwise
       
   589 
       
   590     Errors/Exceptions: None
       
   591 
       
   592     Status: Approved
       
   593 
       
   594 -------------------------------------------------------------------------------
       
   595 */
       
   596 EXPORT_C TInt CTestModuleList::AddTestModule(TDesC& aModuleName)
       
   597     {
       
   598     //Check if given module is already on the list
       
   599     CTestModuleInfo* tmp = GetModule(aModuleName);
       
   600     if(tmp)
       
   601         {
       
   602         return KErrAlreadyExists;
       
   603         }
       
   604 
       
   605     //There is no module on the list, so create new info object
       
   606     TInt err = KErrNone;
       
   607     TRAP(err, tmp = CTestModuleInfo::NewL(aModuleName, iLogger));
       
   608     if(err != KErrNone)
       
   609         {
       
   610         if(iLogger)
       
   611             {
       
   612             __TRACE(KError, (_L("Could not create CTestModuleInfo object (CTestModuleList::AddTestModule). Error %d."), err));
       
   613             }
       
   614         else
       
   615             {
       
   616             RDebug::Print(_L("Could not create CTestModuleInfo object (CTestModuleList::AddTestModule). Error %d."), err);
       
   617             }
       
   618 		return err;
       
   619         }
       
   620     if(!tmp)
       
   621         {
       
   622         if(iLogger)
       
   623             {
       
   624             __TRACE(KError, (_L("Could not create CTestModuleInfo object (CTestModuleList::AddTestModule)")));
       
   625             }
       
   626         else
       
   627             {
       
   628             RDebug::Print(_L("Could not create CTestModuleInfo object (CTestModuleList::AddTestModule)"));
       
   629             }
       
   630 		return KErrGeneral;
       
   631         }
       
   632 
       
   633     //Add to list
       
   634     err = iTestModules.Append(tmp);
       
   635     if(err != KErrNone)
       
   636         {
       
   637         if(iLogger)
       
   638             {
       
   639             __TRACE(KError, (_L("Could not append CTestModuleInfo object to array (CTestModuleList::AddTestModule). Error %d."), err));
       
   640             }
       
   641         else
       
   642             {
       
   643             RDebug::Print(_L("Could not append CTestModuleInfo object to array (CTestModuleList::AddTestModule). Error %d."), err);
       
   644             }
       
   645         delete tmp;
       
   646         return err;
       
   647         }
       
   648 
       
   649     return KErrNone;
       
   650     }
       
   651 
       
   652 /*
       
   653 -------------------------------------------------------------------------------
       
   654 
       
   655     Class: CTestModuleList
       
   656 
       
   657     Method: Count
       
   658 
       
   659     Description: Counts test modules
       
   660 
       
   661     Parameters: None
       
   662 
       
   663     Return Values: Number of test modules on list
       
   664 
       
   665     Errors/Exceptions: None
       
   666 
       
   667     Status: Approved
       
   668 
       
   669 -------------------------------------------------------------------------------
       
   670 */
       
   671 EXPORT_C TInt CTestModuleList::Count()
       
   672     {
       
   673 	return iTestModules.Count();
       
   674     }
       
   675 
       
   676 /*
       
   677 -------------------------------------------------------------------------------
       
   678 
       
   679     Class: CTestModuleList
       
   680 
       
   681     Method: GetModule
       
   682 
       
   683     Description: Searches test module with given name
       
   684 
       
   685     Parameters: aModuleName: module name
       
   686 
       
   687     Return Values: Pointer to found object or NULL when not found
       
   688 
       
   689     Errors/Exceptions: None
       
   690 
       
   691     Status: Approved
       
   692 
       
   693 -------------------------------------------------------------------------------
       
   694 */
       
   695 EXPORT_C CTestModuleInfo* CTestModuleList::GetModule(TDesC& aModuleName)
       
   696     {
       
   697     TInt cnt = iTestModules.Count();
       
   698     TInt i;
       
   699     CTestModuleInfo* tmp;
       
   700     TName moduleName;
       
   701 
       
   702     //Check if given module is already on the list
       
   703     for(i = 0; i < cnt; i++)
       
   704         {
       
   705         tmp = iTestModules[i];
       
   706         tmp->GetModuleName(moduleName);
       
   707         if(moduleName == aModuleName)
       
   708             {
       
   709             return tmp;
       
   710 			}
       
   711         }
       
   712     return NULL;
       
   713     }
       
   714 
       
   715 /*
       
   716 -------------------------------------------------------------------------------
       
   717 
       
   718     Class: CTestModuleList
       
   719 
       
   720     Method: GetModule
       
   721 
       
   722     Description: Searches test module with given index
       
   723 
       
   724     Parameters: aIndex: module index
       
   725 
       
   726     Return Values: Pointer to found object or NULL when not found
       
   727 
       
   728     Errors/Exceptions: None
       
   729 
       
   730     Status: Approved
       
   731 
       
   732 -------------------------------------------------------------------------------
       
   733 */
       
   734 EXPORT_C CTestModuleInfo* CTestModuleList::GetModule(TInt aIndex)
       
   735     {
       
   736     TInt cnt = iTestModules.Count();
       
   737 
       
   738     //Check index
       
   739     if(aIndex >= cnt || aIndex < 0)
       
   740         {
       
   741         if(iLogger)
       
   742             {
       
   743             __TRACE(KError, (_L("Given index reaches out of array (CTestModuleList::GetModule). Given index: %d. Max allowed index: %d"), aIndex, cnt - 1));
       
   744             }
       
   745         else
       
   746             {
       
   747             RDebug::Print(_L("Given index reaches out of array (CTestModuleList::GetModule). Given index: %d. Max allowed index: %d"), aIndex, cnt - 1);
       
   748             }
       
   749         return NULL;
       
   750         }
       
   751 
       
   752     //return module
       
   753     return iTestModules[aIndex];
       
   754     }
       
   755 
       
   756 /*
       
   757 -------------------------------------------------------------------------------
       
   758 
       
   759     Class: CTestModuleList
       
   760 
       
   761     Method: GetUncheckedCfgFile
       
   762 
       
   763     Description: Get first unchecked test case file (module: testscripter and testcombiner)
       
   764 
       
   765     Parameters: None
       
   766 
       
   767     Return Values: Pointer to CTestCaseFileInfo object if found
       
   768                    Null otherwise
       
   769 
       
   770     Errors/Exceptions: None
       
   771 
       
   772     Status: Approved
       
   773 
       
   774 -------------------------------------------------------------------------------
       
   775 */
       
   776 EXPORT_C CTestCaseFileInfo* CTestModuleList::GetUncheckedCfgFile(void)
       
   777     {
       
   778     CTestCaseFileInfo* ret = NULL;
       
   779 
       
   780     TBuf<12> modname(_L("testscripter"));
       
   781     CTestModuleInfo* mod = GetModule(modname);
       
   782 
       
   783     if(mod)
       
   784         {
       
   785         ret = mod->GetUncheckedCfgFile();
       
   786         }
       
   787 
       
   788     if(!ret)
       
   789 	    {
       
   790         modname.Copy(_L("testcombiner"));
       
   791         mod = GetModule(modname);
       
   792         if(mod)
       
   793             {
       
   794             ret = mod->GetUncheckedCfgFile();
       
   795             }
       
   796         }
       
   797 
       
   798     return ret;
       
   799     }
       
   800 
       
   801 // ================= MEMBER FUNCTIONS =========================================
       
   802 
       
   803 /*
       
   804 -------------------------------------------------------------------------------
       
   805 
       
   806     Class: CTestCaseFileInfo
       
   807 
       
   808     Method: CTestCaseFileInfo
       
   809 
       
   810     Description: Default constructor
       
   811 
       
   812     C++ default constructor can NOT contain any code, that
       
   813     might leave.
       
   814 
       
   815     Parameters: None
       
   816 
       
   817     Return Values: None
       
   818 
       
   819     Errors/Exceptions: None
       
   820 
       
   821     Status: Approved
       
   822 
       
   823 -------------------------------------------------------------------------------
       
   824 */
       
   825 CTestCaseFileInfo::CTestCaseFileInfo()
       
   826     {
       
   827 	iLogger = NULL;
       
   828     iCfgFileName = NULL;
       
   829     iChecked = EFalse;
       
   830     }
       
   831 
       
   832 /*
       
   833 -------------------------------------------------------------------------------
       
   834 
       
   835     Class: CTestCaseFileInfo
       
   836 
       
   837     Method: ConstructL
       
   838 
       
   839     Description: Symbian OS second phase constructor
       
   840 
       
   841     Symbian OS default constructor can leave.
       
   842 
       
   843     Parameters: aCfgFileName: config file name
       
   844                 aLogger: pointer to Stif logger
       
   845 
       
   846     Return Values: None
       
   847 
       
   848     Errors/Exceptions:
       
   849 
       
   850     Status: Approved
       
   851 
       
   852 -------------------------------------------------------------------------------
       
   853 */
       
   854 void CTestCaseFileInfo::ConstructL(TDesC& aCfgFileName, CStifLogger* aLogger)
       
   855     {
       
   856 	iLogger = aLogger;
       
   857 
       
   858 	if(iCfgFileName)
       
   859 	    {
       
   860         delete iCfgFileName;
       
   861 		iCfgFileName = NULL;
       
   862         }
       
   863     iCfgFileName = aCfgFileName.AllocL();
       
   864     }
       
   865 
       
   866 /*
       
   867 -------------------------------------------------------------------------------
       
   868 
       
   869     Class: CTestCaseFileInfo
       
   870 
       
   871     Method: NewL
       
   872 
       
   873     Description: Two-phased constructor.
       
   874 
       
   875     Parameters: aCfgFileName: config file name
       
   876                 aLogger: pointer to stif logger
       
   877 
       
   878     Return Values: CTestCaseFileInfo* : pointer to created object
       
   879 
       
   880     Errors/Exceptions: Leaves if memory allocation for object fails
       
   881                        Leaves if ConstructL leaves
       
   882 
       
   883     Status: Approved
       
   884 
       
   885 -------------------------------------------------------------------------------
       
   886 */
       
   887 CTestCaseFileInfo* CTestCaseFileInfo::NewL(TDesC& aCfgFileName, CStifLogger* aLogger)
       
   888     {
       
   889     CTestCaseFileInfo* self = new (ELeave) CTestCaseFileInfo();
       
   890     CleanupStack::PushL(self);
       
   891     self->ConstructL(aCfgFileName, aLogger);
       
   892     CleanupStack::Pop(self);
       
   893     return self;
       
   894     }
       
   895 
       
   896 /*
       
   897 -------------------------------------------------------------------------------
       
   898 
       
   899     Class: CTestCaseFileInfo
       
   900 
       
   901     Method: ~CTestCaseFileInfo
       
   902 
       
   903     Description: Destructor.
       
   904 
       
   905     Parameters: None
       
   906 
       
   907     Return Values: None
       
   908 
       
   909     Errors/Exceptions: None
       
   910 
       
   911     Status: Approved
       
   912 
       
   913 -------------------------------------------------------------------------------
       
   914 */
       
   915 CTestCaseFileInfo::~CTestCaseFileInfo()
       
   916     {
       
   917     delete iCfgFileName;
       
   918     }
       
   919 
       
   920 /*
       
   921 -------------------------------------------------------------------------------
       
   922 
       
   923     Class: CTestCaseFileInfo
       
   924 
       
   925     Method: GetCfgFileName
       
   926 
       
   927     Description: Get config file name
       
   928 
       
   929     Parameters: None
       
   930 
       
   931     Return Values: TDesC& : config file name
       
   932 
       
   933     Errors/Exceptions: None
       
   934 
       
   935     Status: Approved
       
   936 
       
   937 -------------------------------------------------------------------------------
       
   938 */
       
   939 EXPORT_C TInt CTestCaseFileInfo::GetCfgFileName(TDes& aCfgFileName)
       
   940     {
       
   941     aCfgFileName.Zero();
       
   942     if(iCfgFileName)
       
   943         {
       
   944         aCfgFileName.Copy(*iCfgFileName);
       
   945         }
       
   946     return KErrNone;
       
   947     }
       
   948 
       
   949 /*
       
   950 -------------------------------------------------------------------------------
       
   951 
       
   952     Class: CTestCaseFileInfo
       
   953 
       
   954     Method: SetChecked
       
   955 
       
   956     Description: Set configuration file as already checked
       
   957 
       
   958     Parameters: None
       
   959 
       
   960     Return Values: None
       
   961 
       
   962     Errors/Exceptions: None
       
   963 
       
   964     Status: Approved
       
   965 
       
   966 -------------------------------------------------------------------------------
       
   967 */
       
   968 EXPORT_C void CTestCaseFileInfo::SetChecked(void)
       
   969     {
       
   970     iChecked = ETrue;
       
   971     }
       
   972 
       
   973 /*
       
   974 -------------------------------------------------------------------------------
       
   975 
       
   976     Class: CTestCaseFileInfo
       
   977 
       
   978     Method: IsChecked
       
   979 
       
   980     Description: Return if config file has been checked
       
   981 
       
   982     Parameters: None
       
   983 
       
   984     Return Values: 0 if test case file has not been checked yet
       
   985                    other value otherwise
       
   986 
       
   987     Errors/Exceptions: None
       
   988 
       
   989     Status: Approved
       
   990 
       
   991 -------------------------------------------------------------------------------
       
   992 */
       
   993 TBool CTestCaseFileInfo::IsChecked(void)
       
   994     {
       
   995     return iChecked;
       
   996     }
       
   997 
       
   998 // ================= OTHER EXPORTED FUNCTIONS =================================
       
   999 // None
       
  1000 
       
  1001 // End of File