os/kernelhwsrv/baseapitest/basesvs/validation/f32/sfsrv/src/T_ParseBaseData.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2005-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: 
    15 *
    16 */
    17 
    18 
    19 #include "T_ParseBaseData.h"
    20 
    21 // Commands
    22 
    23 _LIT( KCmdDrive,					"Drive" );
    24 _LIT( KCmdDriveAndPath,				"DriveAndPath" );
    25 _LIT( KCmdDrivePresent,				"DrivePresent" );
    26 _LIT( KCmdExt,						"Ext" );
    27 _LIT( KCmdExtPresent,				"ExtPresent" );
    28 _LIT( KCmdFullName,					"FullName" );
    29 _LIT( KCmdIsExtWild,				"IsExtWild" );
    30 _LIT( KCmdIsKMatchAny,				"IsKMatchAny" );
    31 _LIT( KCmdIsKMatchOne,				"IsKMatchOne" );
    32 _LIT( KCmdIsNameWild,				"IsNameWild" );
    33 _LIT( KCmdIsRoot,					"IsRoot" );
    34 _LIT( KCmdIsWild,					"IsWild" );
    35 _LIT( KCmdName,						"Name" );
    36 _LIT( KCmdNameAndExt,				"NameAndExt" );
    37 _LIT( KCmdNameOrExtPresent,			"NameOrExtPresent" );
    38 _LIT( KCmdNamePresent,				"NamePresent" );
    39 _LIT( KCmdPath,						"Path" );
    40 _LIT( KCmdPathPresent,				"PathPresent" );
    41 
    42 // Parameters
    43 _LIT( KParamExpected,				"expected" );
    44 
    45 	
    46 CT_ParseBaseData::~CT_ParseBaseData()
    47 /**
    48 * Destructor.
    49 */
    50 	{
    51 	}
    52 	
    53 
    54 TAny* CT_ParseBaseData::GetObject()
    55 /**
    56 * Return a pointer to the object that the data wraps
    57 *
    58 * @return pointer to the object that the data wraps
    59 */
    60 	{
    61 	return GetParse();
    62 	}
    63 
    64 TBool CT_ParseBaseData::DoCommandL( const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/ )
    65 /**
    66 * Process a command read from the ini file
    67 *
    68 * @param aCommand	the command to process
    69 * @param aSection		the entry in the ini file requiring the command to be processed
    70 *
    71 * @return ETrue if the command is processed
    72 */
    73 	{
    74 	TBool retVal = ETrue;
    75 	
    76 
    77 	if ( aCommand == KCmdDrive )
    78 		{
    79 		DoCmdDrive( aSection );
    80 		}
    81 	else if ( aCommand == KCmdDriveAndPath )
    82 		{
    83 		DoCmdDriveAndPath( aSection );
    84 		}
    85 	else if ( aCommand == KCmdDrivePresent )
    86 		{
    87 		DoCmdDrivePresent( aSection );
    88 		}
    89 	else if ( aCommand == KCmdExt )
    90 		{
    91 		DoCmdExt( aSection );
    92 		}
    93 	else if ( aCommand == KCmdExtPresent )
    94 		{
    95 		DoCmdExtPresent( aSection );
    96 		}
    97 	else if ( aCommand == KCmdFullName )
    98 		{
    99 		DoCmdFullName( aSection );
   100 		}
   101 	else if ( aCommand == KCmdIsKMatchAny )
   102 		{
   103 		DoCmdIsKMatchAny( aSection );
   104 		}
   105 	else if ( aCommand == KCmdIsKMatchOne )
   106 		{
   107 		DoCmdIsKMatchOne( aSection );
   108 		}
   109 	else if ( aCommand == KCmdIsExtWild )
   110 		{
   111 		DoCmdIsExtWild( aSection );
   112 		}
   113 	else if ( aCommand == KCmdIsNameWild )
   114 		{
   115 		DoCmdIsNameWild( aSection );
   116 		}
   117 	else if ( aCommand == KCmdIsRoot)
   118 		{
   119 		DoCmdIsRoot( aSection );
   120 		}
   121 	else if ( aCommand == KCmdIsWild )
   122 		{
   123 		DoCmdIsWild( aSection );
   124 		}
   125 	else if ( aCommand == KCmdName )
   126 		{
   127 		DoCmdName( aSection );
   128 		}
   129 	else if ( aCommand == KCmdNameAndExt )
   130 		{
   131 		DoCmdNameAndExt( aSection );
   132 		}
   133 	else if ( aCommand == KCmdNameOrExtPresent )
   134 		{
   135 		DoCmdNameOrExtPresent( aSection );
   136 		}
   137 	else if ( aCommand == KCmdNamePresent )
   138 		{
   139 		DoCmdNamePresent( aSection );
   140 		}
   141 	else if ( aCommand == KCmdPath )
   142 		{
   143 		DoCmdPath( aSection );
   144 		}
   145 	else if ( aCommand == KCmdPathPresent )
   146 		{
   147 		DoCmdPathPresent( aSection );
   148 		}
   149 	else
   150 	    {
   151 	    retVal = EFalse;    
   152 	    }
   153 	
   154 	return retVal;
   155 	}
   156 	
   157 
   158 void CT_ParseBaseData::DoCmdDrive( const TDesC& aSection )
   159 /** Gets the drive letter using Drive(). */
   160 	{
   161 	INFO_PRINTF1( _L( "Drive()" ) );
   162 		
   163 	TPtrC result = GetParse()->Drive();
   164 	INFO_PRINTF2(_L("Drive() return: %S"), &result);
   165 	
   166 	TPtrC expected;
   167 	if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
   168 		{
   169 		if ( result != expected )
   170 			{
   171 			ERR_PRINTF3(_L("Drive() returns %S but expected %S"), &result, &expected);
   172 			SetBlockResult( EFail);
   173 			}
   174 		}
   175 	}
   176 	
   177 void CT_ParseBaseData::DoCmdDriveAndPath( const TDesC& aSection )
   178 /** Gets the path and drive letter using DriveAndPath(). */
   179 	{
   180 	INFO_PRINTF1( _L( "DriveAndPath()" ) );
   181 		
   182 	TPtrC result = GetParse()->DriveAndPath();
   183 	INFO_PRINTF2(_L("DriveAndPath() return: %S"), &result);
   184 	
   185 	TPtrC expected;
   186 	if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
   187 	{
   188 	if ( result != expected )
   189 		{
   190 		ERR_PRINTF3(_L("DriveAndPath() returns %S but expected %S"), &result, &expected);
   191 		SetBlockResult( EFail);
   192 		}
   193 	}
   194 	
   195 
   196 	}
   197 	
   198 void CT_ParseBaseData::DoCmdDrivePresent( const TDesC& aSection )
   199 /** Tests whether a drive is present using DrivePresent(). */
   200 	{
   201 	INFO_PRINTF1( _L( "DrivePresent()" ) );
   202 		
   203 	TBool result = GetParse()->DrivePresent();
   204 	
   205 	TPtrC strIsTrue = result ? _L("TRUE") : _L("FALSE");
   206 	INFO_PRINTF2(_L("DrivePresent() return: %S"), &strIsTrue);
   207 				
   208 	TBool expected;	
   209 	if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
   210 		{
   211 		if ( (result>0) != (expected>0) )
   212 			{
   213 			ERR_PRINTF3(_L("DrivePresent() returns %d but expected %d"), result, expected);
   214 			SetBlockResult( EFail);
   215 			}
   216 		}
   217 	}
   218 	
   219 void CT_ParseBaseData::DoCmdExt( const TDesC& aSection )
   220 /** Gets the file extension using Ext(). */
   221 	{
   222 	INFO_PRINTF1( _L( "Ext()" ) );
   223 		
   224 	TPtrC result = GetParse()->Ext();
   225 	INFO_PRINTF2(_L("Ext() returns: %S"), &result);
   226 	
   227 	TPtrC expected;
   228 	if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
   229 		{
   230 		if ( result != expected )
   231 			{
   232 			ERR_PRINTF3(_L("Ext() returns %S but expected %S"), &result, &expected);
   233 			SetBlockResult( EFail);
   234 			}
   235 		}
   236 	}
   237 	
   238 void CT_ParseBaseData::DoCmdExtPresent( const TDesC& aSection )
   239 /** Tests whether an extension is present using ExtPresent(). */
   240 	{
   241 	INFO_PRINTF1( _L( "ExtPresent()" ) );
   242 		
   243 	TBool result = GetParse()->ExtPresent();
   244 	
   245 	TPtrC strIsTrue = result ? _L("TRUE") : _L("FALSE");
   246 	INFO_PRINTF2(_L("ExtPresent() return: %S"), &strIsTrue);
   247 	
   248 	TBool expected;	
   249 	if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
   250 		{
   251 		if ( (result>0) != (expected>0) )
   252 			{
   253 			ERR_PRINTF3(_L("ExtPresent() returns %d but expected %d"), result, expected);
   254 			SetBlockResult( EFail);
   255 			}
   256 		}
   257 	}
   258 	
   259 void CT_ParseBaseData::DoCmdFullName( const TDesC& aSection )
   260 /** Gets the complete file specification using FullName(). */
   261 	{
   262 	INFO_PRINTF1( _L( "FullName()" ) );
   263 		
   264 	TPtrC result = GetParse()->FullName();
   265 	INFO_PRINTF2(_L("FullName() return: %S"), &result);
   266 	
   267 	TPtrC expected;
   268 	if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
   269 		{
   270 		if ( result != expected )
   271 			{
   272 			ERR_PRINTF3(_L("FullName() returns %S but expected %S"), &result, &expected);
   273 			SetBlockResult( EFail);
   274 			}
   275 		}
   276 	}
   277 	
   278 void CT_ParseBaseData::DoCmdIsExtWild( const TDesC& aSection )
   279 /** Tests whether the extension in the fully parsed specification contains one or 
   280  *  more wildcard characters using IsExtWild()
   281  */
   282 	{
   283 	INFO_PRINTF1( _L( "IsExtWild()" ) );
   284 		
   285 	TBool result = GetParse()->IsExtWild();
   286 	TPtrC temp = result ? _L("TRUE") : _L("FALSE");
   287 	INFO_PRINTF2(_L("IsExtWild() return: %S"), &temp);
   288 	
   289 	TBool expected;
   290 	if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
   291 		{
   292 		//NB! IsExtWild can return values >1
   293 		if ( (result>0) != (expected>0) )
   294 			{
   295 			ERR_PRINTF3(_L("IsExtWild() returns %S but expected %S"), &result, &expected);
   296 			SetBlockResult( EFail);
   297 			}
   298 		}
   299 	}
   300 	
   301 void CT_ParseBaseData::DoCmdIsKMatchAny( const TDesC& aSection )
   302 /** Tests whether the name or the extension contains asterisk wildcards usinbg IsKMatchAny(). */
   303 	{
   304 	INFO_PRINTF1( _L( "IsKMatchAny()" ) );
   305 
   306 	TBool result = GetParse()->IsKMatchAny();
   307 	TPtrC temp = result ? _L("TRUE") : _L("FALSE");
   308 	INFO_PRINTF2(_L("IsKMatchAny() return: %S"), &temp);
   309 	
   310 	TBool expected;	
   311 	if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
   312 		{
   313 		if ( (result>0) != (expected>0) )
   314 			{
   315 			ERR_PRINTF3(_L("IsKMatchAny() returns %d but expected %d"), result, expected);
   316 			SetBlockResult( EFail);
   317 			}
   318 		}
   319 	}
   320 	
   321 void CT_ParseBaseData::DoCmdIsKMatchOne( const TDesC& aSection )
   322 /** Tests whether the name or the extension contains a question mark wildcard using IsKMatchOne() */
   323 	{
   324 	INFO_PRINTF1( _L( "IsKMatchOne()" ) );
   325 
   326 	TBool result = GetParse()->IsKMatchOne();
   327 	TPtrC temp = result ? _L("TRUE") : _L("FALSE");
   328 	INFO_PRINTF2(_L("IsKMatchOne() return: %S"), &temp);
   329 
   330 	TBool expected;
   331 	if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
   332 		{
   333 		if ( (result>0) != (expected>0) )
   334 			{
   335 			ERR_PRINTF3(_L("IsKMatchOne() returns %d but expected %d"), result, expected);
   336 			SetBlockResult( EFail);
   337 			}
   338 		}
   339 	}
   340 	
   341 void CT_ParseBaseData::DoCmdIsNameWild( const TDesC& aSection )
   342 /** Tests whether the filename in the fully parsed specification contains one or more wildcard 
   343  *  characters using IsNameWild() 
   344  */
   345 	{
   346 	INFO_PRINTF1( _L( "IsNameWild()" ) );
   347 		
   348 	TBool result = GetParse()->IsNameWild();
   349 	TPtrC temp = result ? _L("TRUE") : _L("FALSE");
   350 	INFO_PRINTF2(_L("IsNameWild() return: %S"), &temp);
   351 
   352 	TBool expected;
   353 	if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
   354 		{
   355 		if ( (result>0) != (expected>0) )
   356 			{
   357 			ERR_PRINTF3(_L("IsNameWild() returns %d but expected %d"), result, expected);
   358 			SetBlockResult( EFail);
   359 			}
   360 		}
   361 	}
   362 
   363 void CT_ParseBaseData::DoCmdIsRoot( const TDesC& aSection )
   364 /** Tests whether the path in the fully parsed specification is the root directory using IsRoot(). */
   365 	{
   366 	INFO_PRINTF1( _L( "IsRoot()" ) );
   367 		
   368 	TBool result = GetParse()->IsRoot();
   369 	TPtrC temp = result ? _L("TRUE") : _L("FALSE");
   370 	INFO_PRINTF2(_L("IsRoot() return: %S"), &temp);
   371 
   372 	TBool expected;
   373 	if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
   374 		{
   375 		if ( (result>0) != (expected>0) )
   376 			{
   377 			ERR_PRINTF3(_L("IsRoot() returns %d but expected %d"), result, expected);
   378 			SetBlockResult( EFail);
   379 			}
   380 		}
   381 	}
   382 	
   383 void CT_ParseBaseData::DoCmdIsWild( const TDesC& aSection )
   384 /** Tests whether the filename or the extension in the fully parsed specification contains one or 
   385   * more wildcard characters using IsWild()
   386   */
   387 	{
   388 	INFO_PRINTF1( _L( "IsWild()" ) );
   389 		
   390 	TBool result = GetParse()->IsWild();
   391 	TPtrC temp = result ? _L("TRUE") : _L("FALSE");
   392 	INFO_PRINTF2(_L("IsWild() return: %S"), &temp);
   393 
   394 	TBool expected;	
   395 	if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
   396 		{
   397 		if ( (result>0) != (expected>0) )
   398 			{
   399 			ERR_PRINTF3(_L("IsWild() returns %d but expected %d"), result, expected);
   400 			SetBlockResult( EFail);
   401 			}
   402 		}
   403 	
   404 	}
   405 
   406 void CT_ParseBaseData::DoCmdName( const TDesC& aSection )
   407 /** Gets the file name using Name(). */
   408 	{
   409 	INFO_PRINTF1( _L( "Name()" ) );
   410 		
   411 	TPtrC result = GetParse()->Name();
   412 	INFO_PRINTF2(_L( "Name() return: %S" ), &result);
   413 
   414 	TPtrC expected;
   415 	if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
   416 		{
   417 		if ( result != expected )
   418 			{
   419 			ERR_PRINTF3(_L("Name() returns %S but expected %S"), &result, &expected);
   420 			SetBlockResult( EFail);
   421 			}
   422 		}
   423 	}
   424 	
   425 void CT_ParseBaseData::DoCmdNameOrExtPresent( const TDesC& aSection )
   426 /** Tests whether a name or an extension are present using NameOrExtPresent(). */
   427 	{
   428 	INFO_PRINTF1( _L( "NameOrExtPresent()" ) );
   429 		
   430 	TBool result = GetParse()->NameOrExtPresent();
   431 	TPtrC temp = result ? _L("TRUE") : _L("FALSE");
   432 	INFO_PRINTF2(_L("NameOrExtPresent() return: %S"), &temp);
   433 
   434 	TBool expected;
   435 	if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
   436 		{
   437 		if ( (result>0) != (expected>0) )
   438 			{
   439 			ERR_PRINTF3(_L("NameOrExtPresent() returns %d but expected %d"), result, expected);
   440 			SetBlockResult( EFail);
   441 			}
   442 		}
   443 	}
   444 	
   445 void CT_ParseBaseData::DoCmdNameAndExt( const TDesC& aSection )
   446 /** Gets the file name and extension using NameAndExt(). */
   447 	{
   448 	INFO_PRINTF1( _L( "NameAndExt()" ) );
   449 		
   450 	TPtrC result = GetParse()->NameAndExt();
   451 	INFO_PRINTF2( _L( "NameAndExt() return: %S" ), &result );
   452 
   453 	TPtrC expected;
   454 	if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
   455 		{
   456 		if ( result != expected )
   457 			{
   458 			ERR_PRINTF3(_L("NameAndExt() returns %S but expected %S"), &result, &expected);
   459 			SetBlockResult( EFail);
   460 			}
   461 		}
   462 	}
   463 	
   464 void CT_ParseBaseData::DoCmdNamePresent( const TDesC& aSection )
   465 /** Tests whether a file name is present using NamePresent(). */
   466 	{
   467 	INFO_PRINTF1( _L( "NamePresent()" ) );
   468 		
   469 	TBool result = GetParse()->NamePresent();
   470 	TPtrC temp = result ? _L("TRUE") : _L("FALSE");
   471 	INFO_PRINTF2(_L("NamePresent() return: %S"), &temp);
   472 
   473 	TBool expected;
   474 	if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
   475 		{
   476 		if ( (result>0) != (expected>0) )
   477 			{
   478 			ERR_PRINTF3(_L("NamePresent() returns %d but expected %d"), result, expected);
   479 			SetBlockResult( EFail);
   480 			}
   481 		}
   482 	}
   483 	
   484 void CT_ParseBaseData::DoCmdPath( const TDesC& aSection )
   485 /** Gets the path using Path(). */
   486 	{
   487 	INFO_PRINTF1( _L( "Path()" ) );
   488 		
   489 	TPtrC result = GetParse()->Path();
   490 	INFO_PRINTF2( _L( "Path() return: %S" ), &result );
   491 
   492 	TPtrC expected;
   493 	if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
   494 		{
   495 		if ( result != expected )
   496 			{
   497 			ERR_PRINTF3(_L("Path() returns %S but expected %S"), &result, &expected);
   498 			SetBlockResult( EFail);
   499 			}
   500 		}
   501 	}
   502 	
   503 void CT_ParseBaseData::DoCmdPathPresent( const TDesC& aSection )
   504 /** Tests whether a path is present using PathPresent(). */
   505 	{
   506 	INFO_PRINTF1( _L( "PathPresent()" ) );
   507 		
   508 	TBool result = GetParse()->PathPresent();
   509 	TPtrC temp = result ? _L("TRUE") : _L("FALSE");
   510 	INFO_PRINTF2(_L("PathPresent() return: %S"), &temp);		
   511 
   512 	TBool expected;
   513 	if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
   514 		{
   515 		if ( (result>0) != (expected>0) )
   516 			{
   517 			ERR_PRINTF3(_L("PathPresent() returns %d but expected %d"), result, expected);
   518 			SetBlockResult( EFail);
   519 			}
   520 		}
   521 	}
   522