stif/TestEngine/src/STIFTestFrameworkSettings.cpp
changeset 0 a03f92240627
child 18 3406c99bc375
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 * CSTIFTestFrameworkSettings class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "STIFTestFrameworkSettings.h"
       
    21 #include "TestReport.h"
       
    22 
       
    23 // EXTERNAL DATA STRUCTURES
       
    24 // None
       
    25 
       
    26 // EXTERNAL FUNCTION PROTOTYPES  
       
    27 // None
       
    28 
       
    29 // CONSTANTS
       
    30 // None
       
    31 
       
    32 // MACROS
       
    33 // None
       
    34 
       
    35 // LOCAL CONSTANTS AND MACROS
       
    36 // None
       
    37 
       
    38 // MODULE DATA STRUCTURES
       
    39 // None
       
    40 
       
    41 // LOCAL FUNCTION PROTOTYPES
       
    42 // None
       
    43 
       
    44 // FORWARD DECLARATIONS
       
    45 // None
       
    46 
       
    47 // ==================== LOCAL FUNCTIONS =======================================
       
    48 // None
       
    49 
       
    50 // ================= MEMBER FUNCTIONS =========================================
       
    51 
       
    52 /*
       
    53 -------------------------------------------------------------------------------
       
    54 
       
    55     Class: CSTIFTestFrameworkSettings
       
    56 
       
    57     Method: CSTIFTestFrameworkSettings
       
    58 
       
    59     Description: Default constructor
       
    60 
       
    61     C++ default constructor can NOT contain any code, that
       
    62     might leave.
       
    63 
       
    64     Parameters: None
       
    65     
       
    66     Return Values: None
       
    67 
       
    68     Errors/Exceptions: None
       
    69 
       
    70     Status: Approved
       
    71 
       
    72 -------------------------------------------------------------------------------
       
    73 */
       
    74 CSTIFTestFrameworkSettings::CSTIFTestFrameworkSettings()
       
    75     {
       
    76 
       
    77     }
       
    78 
       
    79 /*
       
    80 -------------------------------------------------------------------------------
       
    81 
       
    82     Class: CSTIFTestFrameworkSettings
       
    83 
       
    84     Method: ConstructL
       
    85 
       
    86     Description: Symbian OS second phase constructor
       
    87 
       
    88     Symbian OS default constructor can leave.
       
    89 
       
    90     Parameters: None
       
    91 
       
    92     Return Values: None
       
    93 
       
    94     Errors/Exceptions: None
       
    95 
       
    96     Status: Approved
       
    97 
       
    98 -------------------------------------------------------------------------------
       
    99 */
       
   100 void CSTIFTestFrameworkSettings::ConstructL()
       
   101     {
       
   102 
       
   103     }
       
   104 
       
   105 /*
       
   106 -------------------------------------------------------------------------------
       
   107 
       
   108     Class: CSTIFTestFrameworkSettings
       
   109 
       
   110     Method: NewL
       
   111 
       
   112     Description: Two-phased constructor.
       
   113 
       
   114     Parameters: None
       
   115 
       
   116     Return Values: CSTIFTestFrameworkSettings*: pointer to 
       
   117                                                 CSTIFTestFrameworkSettings
       
   118                                                 object
       
   119 
       
   120     Errors/Exceptions: None 
       
   121 
       
   122     Status: Approved
       
   123 
       
   124 -------------------------------------------------------------------------------
       
   125 */
       
   126 EXPORT_C CSTIFTestFrameworkSettings* CSTIFTestFrameworkSettings::NewL()
       
   127     {
       
   128     CSTIFTestFrameworkSettings* self = 
       
   129                         new ( ELeave ) CSTIFTestFrameworkSettings();
       
   130     CleanupStack::PushL( self );
       
   131     self->ConstructL();
       
   132     CleanupStack::Pop();
       
   133     return self;
       
   134 
       
   135     }
       
   136 
       
   137 /*
       
   138 -------------------------------------------------------------------------------
       
   139 
       
   140     Class: CSTIFTestFrameworkSettings
       
   141 
       
   142     Method: ~CSTIFTestFrameworkSettings
       
   143 
       
   144     Description: Destructor
       
   145 
       
   146     Parameters: None
       
   147 
       
   148     Return Values: None
       
   149 
       
   150     Errors/Exceptions: None
       
   151 
       
   152     Status: Approved
       
   153 
       
   154 -------------------------------------------------------------------------------
       
   155 */
       
   156 EXPORT_C CSTIFTestFrameworkSettings::~CSTIFTestFrameworkSettings()
       
   157     {
       
   158 
       
   159     }
       
   160 
       
   161 /*
       
   162 -------------------------------------------------------------------------------
       
   163 
       
   164     Class: CSTIFTestFrameworkSettings
       
   165 
       
   166     Method: GetReportModeL
       
   167 
       
   168     Description: Get report mode settings
       
   169 
       
   170     Parameters: CStifSectionParser* aSectionParser: in: CStifSectionParser
       
   171                 object.
       
   172                 TPtrC aTag: in: Tag to setting to be found.
       
   173                 TUint& aSetting: inout: Parsed setting.
       
   174 
       
   175     Return Values: TInt: Error code
       
   176 
       
   177     Errors/Exceptions: Leaves is memory allocation fails
       
   178 
       
   179     Status: Approved
       
   180 
       
   181 -------------------------------------------------------------------------------
       
   182 */
       
   183 EXPORT_C TInt CSTIFTestFrameworkSettings::GetReportModeL( 
       
   184                                         CStifSectionParser* aSectionParser,
       
   185                                         TPtrC aTag,
       
   186                                         TUint& aSetting )
       
   187     {
       
   188     TPtrC string;
       
   189 
       
   190     CStifItemParser* item = NULL;
       
   191     TRAPD( ret, item = aSectionParser->GetItemLineL( aTag, ENoTag ) );
       
   192     if( ret != KErrNone )
       
   193         {
       
   194         delete item;
       
   195         return ret;
       
   196         }
       
   197     if( !item )
       
   198         {
       
   199         delete item;
       
   200         return KErrNotFound;
       
   201         }
       
   202     else
       
   203         {
       
   204         ret = item->GetString( _L( "" ), string );
       
   205         while( ret == KErrNone )
       
   206             {
       
   207             HBufC* stringHbuf = string.AllocL();
       
   208             TPtr modifiableString = stringHbuf->Des();
       
   209             modifiableString.UpperCase();
       
   210 
       
   211             if( modifiableString == _L( "EMPTY" ) )
       
   212                 {
       
   213                 // No test report
       
   214                 aSetting = CTestReport::ETestReportBlank;
       
   215                 }
       
   216             else if( modifiableString == _L( "SUMMARY" ) )
       
   217                 {
       
   218                 // Increment aSetting
       
   219                 aSetting += CTestReport::ETestReportSummary;
       
   220                 }
       
   221             else if( modifiableString == _L( "ENVIRONMENT" ) )
       
   222                 {
       
   223                 // Increment aSetting
       
   224                 aSetting += CTestReport::ETestReportEnvironment;
       
   225                 }
       
   226             else if( modifiableString == _L( "TESTCASES" ) )
       
   227                 {
       
   228                 // Increment aSetting
       
   229                 aSetting += CTestReport::ETestReportCases;
       
   230                 }
       
   231             else if( modifiableString == _L( "FULLREPORT" ) )
       
   232                 {
       
   233                 // Set aSettings to max value and break
       
   234                 aSetting = CTestReport::ETestReportFull;
       
   235                 delete stringHbuf;
       
   236                 break;
       
   237                 }
       
   238             else if( modifiableString == _L( "#" ) )
       
   239                 {
       
   240                 delete stringHbuf;
       
   241                 break;
       
   242                 }
       
   243             else
       
   244                 {
       
   245                 delete stringHbuf;
       
   246                 delete item;
       
   247                 return KErrArgument;
       
   248                 }
       
   249             delete stringHbuf;
       
   250             ret = item->GetNextString( string );
       
   251             }
       
   252         }
       
   253 
       
   254     delete item;
       
   255 
       
   256     return KErrNone;
       
   257 
       
   258     }
       
   259 
       
   260 /*
       
   261 -------------------------------------------------------------------------------
       
   262 
       
   263     Class: CSTIFTestFrameworkSettings
       
   264 
       
   265     Method: GetFileSetting
       
   266 
       
   267     Description: Get file settings
       
   268 
       
   269     Parameters: CStifSectionParser* aSectionParser: in: CStifSectionParser
       
   270                 object.
       
   271                 TPtrC aTag: in: Tag to setting to be found.
       
   272                 TPtrC& aFilePath: inout: Test file setting.
       
   273 
       
   274     Return Values: TInt: Error code
       
   275 
       
   276     Errors/Exceptions: None
       
   277 
       
   278     Status: Approved
       
   279 
       
   280 -------------------------------------------------------------------------------
       
   281 */
       
   282 EXPORT_C TInt CSTIFTestFrameworkSettings::GetFileSetting( 
       
   283                                         CStifSectionParser* aSectionParser,
       
   284                                         TPtrC aTag,
       
   285                                         TPtrC& aSetting )
       
   286     {
       
   287     CStifItemParser* item = NULL;
       
   288     TRAPD( ret, item = aSectionParser->GetItemLineL( 
       
   289                                             aTag,
       
   290                                             ENoTag ) );
       
   291     if( ret != KErrNone )
       
   292         {
       
   293         delete item;
       
   294         return ret;
       
   295         }
       
   296     if( !item )
       
   297         {
       
   298         delete item;
       
   299         return KErrNotFound;
       
   300         }
       
   301     else
       
   302         {
       
   303         ret = item->GetString( _L( "" ), aSetting );
       
   304         }
       
   305 
       
   306     delete item;
       
   307 
       
   308     return ret;
       
   309 
       
   310     }
       
   311 
       
   312 /*
       
   313 -------------------------------------------------------------------------------
       
   314 
       
   315     Class: CSTIFTestFrameworkSettings
       
   316 
       
   317     Method: GetFormatL
       
   318 
       
   319     Description: Get Test report format settings
       
   320 
       
   321     Parameters: CStifSectionParser* aSectionParser: in: CStifSectionParser
       
   322                 object.
       
   323                 TPtrC aTag: in: Tag to setting to be found.
       
   324                 CStifLogger::TLoggerType& aLoggerType: inout: Test report type
       
   325                 setting.
       
   326 
       
   327     Return Values: TInt: Error code
       
   328 
       
   329     Errors/Exceptions: Leaves is memory allocation fails
       
   330 
       
   331     Status: Approved
       
   332 
       
   333 -------------------------------------------------------------------------------
       
   334 */
       
   335 EXPORT_C TInt CSTIFTestFrameworkSettings::GetFormatL( 
       
   336                                         CStifSectionParser* aSectionParser,
       
   337                                         TPtrC aTag, 
       
   338                                         CStifLogger::TLoggerType& aLoggerType )
       
   339     {
       
   340     TBool xml;
       
   341     return GetFormatL(aSectionParser, aTag, aLoggerType, xml);
       
   342     }
       
   343 
       
   344 /*
       
   345 -------------------------------------------------------------------------------
       
   346 
       
   347     Class: CSTIFTestFrameworkSettings
       
   348 
       
   349     Method: GetFormatL
       
   350 
       
   351     Description: Get Test report format settings
       
   352 
       
   353     Parameters: CStifSectionParser* aSectionParser: in: CStifSectionParser
       
   354                 object.
       
   355                 TPtrC aTag: in: Tag to setting to be found.
       
   356                 CStifLogger::TLoggerType& aLoggerType: inout: Test report type setting.
       
   357                 TBool& aXML: inout: true if xml format is set
       
   358 
       
   359     Return Values: TInt: Error code
       
   360 
       
   361     Errors/Exceptions: Leaves is memory allocation fails
       
   362 
       
   363     Status: Approved
       
   364 
       
   365 -------------------------------------------------------------------------------
       
   366 */
       
   367 EXPORT_C TInt CSTIFTestFrameworkSettings::GetFormatL( 
       
   368                                         CStifSectionParser* aSectionParser,
       
   369                                         TPtrC aTag, 
       
   370                                         CStifLogger::TLoggerType& aLoggerType,
       
   371                                         TBool& aXML )
       
   372     {
       
   373     aXML = EFalse;
       
   374     CStifItemParser* item = NULL;
       
   375     TRAPD( ret, item = aSectionParser->GetItemLineL( aTag, ENoTag ) );
       
   376 
       
   377     TPtrC string;
       
   378 
       
   379     if( ret != KErrNone )
       
   380         {
       
   381         delete item;
       
   382         return ret;
       
   383         }
       
   384     if( !item )
       
   385         {
       
   386         delete item;
       
   387         return KErrNotFound;
       
   388         }
       
   389     else
       
   390         {
       
   391         ret = item->GetString( _L( "" ), string );
       
   392         if ( ret != KErrNone )
       
   393             {
       
   394             delete item;
       
   395             return ret;
       
   396             }
       
   397         }
       
   398 
       
   399     HBufC* stringHbuf = string.AllocL();
       
   400     TPtr modifiableString = stringHbuf->Des();
       
   401     modifiableString.UpperCase();
       
   402 
       
   403     if( modifiableString == _L( "TXT" ) )
       
   404         {
       
   405         aLoggerType = CStifLogger::ETxt;
       
   406         }
       
   407     else if( modifiableString == _L( "HTML" ) )
       
   408         {
       
   409         aLoggerType = CStifLogger::EHtml;
       
   410         }
       
   411     else if( modifiableString == _L( "DATA" ) )
       
   412         {
       
   413         aLoggerType = CStifLogger::EData;
       
   414         }
       
   415     else if( modifiableString == _L( "XML" ) )
       
   416         {
       
   417         aLoggerType = CStifLogger::ETxt;
       
   418         aXML = ETrue;
       
   419         }
       
   420     else
       
   421         {
       
   422         delete stringHbuf;
       
   423         delete item;
       
   424         return KErrArgument;
       
   425         }
       
   426 
       
   427     delete stringHbuf;
       
   428     delete item;
       
   429 
       
   430     return KErrNone;
       
   431 
       
   432     }
       
   433 
       
   434 /*
       
   435 -------------------------------------------------------------------------------
       
   436 
       
   437     Class: CSTIFTestFrameworkSettings
       
   438 
       
   439     Method: GetOutputL
       
   440 
       
   441     Description: Get Test report output settings
       
   442 
       
   443     Parameters: CStifSectionParser* aSectionParser: in: CStifSectionParser
       
   444                 object.
       
   445                 TPtrC aTag: in: Tag to setting to be found.
       
   446                 CStifLogger::TOutput& aOutput: inout: Test report output setting.
       
   447 
       
   448     Return Values: TInt: Error code
       
   449 
       
   450     Errors/Exceptions: Leaves is memory allocation fails
       
   451 
       
   452     Status: Approved
       
   453 
       
   454 -------------------------------------------------------------------------------
       
   455 */
       
   456 EXPORT_C TInt CSTIFTestFrameworkSettings::GetOutputL( 
       
   457                                         CStifSectionParser* aSectionParser,
       
   458                                         TPtrC aTag,
       
   459                                         CStifLogger::TOutput& aOutput )
       
   460     {
       
   461     CStifItemParser* item = NULL;
       
   462     TRAPD( ret, item = aSectionParser->GetItemLineL( aTag, ENoTag ) );
       
   463 
       
   464     TPtrC string;
       
   465 
       
   466     if( ret != KErrNone )
       
   467         {
       
   468         delete item;
       
   469         return ret;
       
   470         }
       
   471     if( !item )
       
   472         {
       
   473         delete item;
       
   474         return KErrNotFound;
       
   475         }
       
   476     else
       
   477         {
       
   478         ret = item->GetString( _L( "" ), string );
       
   479         if ( ret != KErrNone )
       
   480             {
       
   481             delete item;
       
   482             return ret;
       
   483             }
       
   484         }
       
   485 
       
   486     HBufC* stringHbuf = string.AllocL();
       
   487     TPtr modifiableString = stringHbuf->Des();
       
   488     modifiableString.UpperCase();
       
   489 
       
   490     if( modifiableString == _L( "FILE" ) )
       
   491         {
       
   492         aOutput = CStifLogger::EFile;
       
   493         }
       
   494     else if( modifiableString == _L( "RDEBUG" ) )
       
   495         {
       
   496         aOutput = CStifLogger::ERDebug;
       
   497         }
       
   498     else
       
   499         {
       
   500         delete stringHbuf;
       
   501         delete item;
       
   502         return KErrArgument;
       
   503         }
       
   504 
       
   505     delete stringHbuf;
       
   506     delete item;
       
   507 
       
   508     return KErrNone;
       
   509 
       
   510     }
       
   511 
       
   512 
       
   513 /*
       
   514 -------------------------------------------------------------------------------
       
   515 
       
   516     Class: CSTIFTestFrameworkSettings
       
   517 
       
   518     Method: GetBooleanSettingsL
       
   519 
       
   520     Description: Get boolean type of settings
       
   521 
       
   522     Parameters: CStifSectionParser* aSectionParser: in: CStifSectionParser
       
   523                 object.
       
   524                 TPtrC aTag: in: Tag to setting to be found.
       
   525                 TBool& aSetting: inout: Parsed setting.
       
   526 
       
   527     Return Values: TInt: Error code
       
   528 
       
   529     Errors/Exceptions: Leaves is memory allocation fails
       
   530 
       
   531     Status: Approved
       
   532 
       
   533 -------------------------------------------------------------------------------
       
   534 */
       
   535 EXPORT_C TInt CSTIFTestFrameworkSettings::GetBooleanSettingsL( 
       
   536                                         CStifSectionParser* aSectionParser,
       
   537                                         TPtrC aTag,
       
   538                                         TBool& aSetting )
       
   539     {
       
   540     TPtrC string;
       
   541 
       
   542     CStifItemParser* item = NULL;
       
   543     TRAPD( ret, item = aSectionParser->GetItemLineL( aTag, ENoTag ) );
       
   544     if( ret != KErrNone )
       
   545         {
       
   546         delete item;
       
   547         return ret;
       
   548         }
       
   549     if( !item )
       
   550         {
       
   551         delete item;
       
   552         return KErrNotFound;
       
   553         }
       
   554     else
       
   555         {
       
   556         ret = item->GetString( _L( "" ), string );
       
   557         if( ret != KErrNone )
       
   558             {
       
   559             delete item;
       
   560             return ret;
       
   561             }
       
   562 
       
   563         HBufC* stringHbuf = string.AllocL();
       
   564         TPtr modifiableString = stringHbuf->Des();
       
   565         modifiableString.UpperCase();
       
   566 
       
   567         // Parsed parameter is false
       
   568         if( modifiableString == _L( "NO" ) )
       
   569             {
       
   570             aSetting = EFalse;
       
   571             }
       
   572         // Parsed parameter is true
       
   573         else if( modifiableString == _L( "YES" ) )
       
   574             {
       
   575             aSetting = ETrue;
       
   576             }
       
   577         else
       
   578             {
       
   579             delete stringHbuf;
       
   580             delete item;
       
   581             return KErrArgument;
       
   582             }
       
   583         delete stringHbuf;
       
   584         }
       
   585 
       
   586     delete item;
       
   587 
       
   588     return KErrNone;
       
   589 
       
   590     }
       
   591 
       
   592 /*
       
   593 -------------------------------------------------------------------------------
       
   594 
       
   595     Class: CSTIFTestFrameworkSettings
       
   596 
       
   597     Method: GetOverwriteL
       
   598 
       
   599     Description: Get Test report file creation mode settings
       
   600                  (overwrite settings)
       
   601 
       
   602     Parameters: CStifSectionParser* aSectionParser: in: CStifSectionParser
       
   603                 object.
       
   604                 TPtrC aTag: in: Tag to setting to be found.
       
   605                 TBool& aOverwrite: inout: Overwrite setting.
       
   606 
       
   607     Return Values: TInt: Error code
       
   608 
       
   609     Errors/Exceptions: Leaves is memory allocation fails
       
   610 
       
   611     Status: Approved
       
   612 
       
   613 -------------------------------------------------------------------------------
       
   614 */
       
   615 EXPORT_C TInt CSTIFTestFrameworkSettings::GetOverwriteL( 
       
   616                                         CStifSectionParser* aSectionParser,
       
   617                                         TPtrC aTag,
       
   618                                         TBool& aOverwrite )
       
   619     {
       
   620     CStifItemParser* item = NULL;
       
   621     TRAPD( ret, item = aSectionParser->GetItemLineL( aTag, ENoTag ) );
       
   622     if( ret != KErrNone )
       
   623         {
       
   624         delete item;
       
   625         return ret;
       
   626         }
       
   627     if( !item )
       
   628         {
       
   629         delete item;
       
   630         return KErrNotFound;
       
   631         }
       
   632     else
       
   633         {
       
   634         TPtrC string;
       
   635         ret = item->GetString( _L( "" ), string );
       
   636         if( ret != KErrNone )
       
   637             {
       
   638             delete item;
       
   639             return ret;
       
   640             }
       
   641 
       
   642         HBufC* stringHbuf = string.AllocL();
       
   643         TPtr modifiableString = stringHbuf->Des();
       
   644         modifiableString.UpperCase();
       
   645 
       
   646         if( modifiableString == _L( "APPEND" ) )
       
   647             {
       
   648             aOverwrite = EFalse;
       
   649             }
       
   650         else if( modifiableString == _L( "OVERWRITE") )
       
   651             {
       
   652             aOverwrite = ETrue;
       
   653             }
       
   654         else
       
   655             {
       
   656             delete stringHbuf;
       
   657             delete item;
       
   658             return KErrArgument;
       
   659             }
       
   660         delete stringHbuf;
       
   661         }
       
   662 
       
   663     delete item;
       
   664 
       
   665     return KErrNone;
       
   666 
       
   667     }
       
   668 
       
   669 // ================= OTHER EXPORTED FUNCTIONS =================================
       
   670 // None
       
   671 
       
   672 //  End of File