1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/baseapitest/basesvs/validation/f32/sfsrv/src/T_ParseBaseData.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,522 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include "T_ParseBaseData.h"
1.23 +
1.24 +// Commands
1.25 +
1.26 +_LIT( KCmdDrive, "Drive" );
1.27 +_LIT( KCmdDriveAndPath, "DriveAndPath" );
1.28 +_LIT( KCmdDrivePresent, "DrivePresent" );
1.29 +_LIT( KCmdExt, "Ext" );
1.30 +_LIT( KCmdExtPresent, "ExtPresent" );
1.31 +_LIT( KCmdFullName, "FullName" );
1.32 +_LIT( KCmdIsExtWild, "IsExtWild" );
1.33 +_LIT( KCmdIsKMatchAny, "IsKMatchAny" );
1.34 +_LIT( KCmdIsKMatchOne, "IsKMatchOne" );
1.35 +_LIT( KCmdIsNameWild, "IsNameWild" );
1.36 +_LIT( KCmdIsRoot, "IsRoot" );
1.37 +_LIT( KCmdIsWild, "IsWild" );
1.38 +_LIT( KCmdName, "Name" );
1.39 +_LIT( KCmdNameAndExt, "NameAndExt" );
1.40 +_LIT( KCmdNameOrExtPresent, "NameOrExtPresent" );
1.41 +_LIT( KCmdNamePresent, "NamePresent" );
1.42 +_LIT( KCmdPath, "Path" );
1.43 +_LIT( KCmdPathPresent, "PathPresent" );
1.44 +
1.45 +// Parameters
1.46 +_LIT( KParamExpected, "expected" );
1.47 +
1.48 +
1.49 +CT_ParseBaseData::~CT_ParseBaseData()
1.50 +/**
1.51 +* Destructor.
1.52 +*/
1.53 + {
1.54 + }
1.55 +
1.56 +
1.57 +TAny* CT_ParseBaseData::GetObject()
1.58 +/**
1.59 +* Return a pointer to the object that the data wraps
1.60 +*
1.61 +* @return pointer to the object that the data wraps
1.62 +*/
1.63 + {
1.64 + return GetParse();
1.65 + }
1.66 +
1.67 +TBool CT_ParseBaseData::DoCommandL( const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/ )
1.68 +/**
1.69 +* Process a command read from the ini file
1.70 +*
1.71 +* @param aCommand the command to process
1.72 +* @param aSection the entry in the ini file requiring the command to be processed
1.73 +*
1.74 +* @return ETrue if the command is processed
1.75 +*/
1.76 + {
1.77 + TBool retVal = ETrue;
1.78 +
1.79 +
1.80 + if ( aCommand == KCmdDrive )
1.81 + {
1.82 + DoCmdDrive( aSection );
1.83 + }
1.84 + else if ( aCommand == KCmdDriveAndPath )
1.85 + {
1.86 + DoCmdDriveAndPath( aSection );
1.87 + }
1.88 + else if ( aCommand == KCmdDrivePresent )
1.89 + {
1.90 + DoCmdDrivePresent( aSection );
1.91 + }
1.92 + else if ( aCommand == KCmdExt )
1.93 + {
1.94 + DoCmdExt( aSection );
1.95 + }
1.96 + else if ( aCommand == KCmdExtPresent )
1.97 + {
1.98 + DoCmdExtPresent( aSection );
1.99 + }
1.100 + else if ( aCommand == KCmdFullName )
1.101 + {
1.102 + DoCmdFullName( aSection );
1.103 + }
1.104 + else if ( aCommand == KCmdIsKMatchAny )
1.105 + {
1.106 + DoCmdIsKMatchAny( aSection );
1.107 + }
1.108 + else if ( aCommand == KCmdIsKMatchOne )
1.109 + {
1.110 + DoCmdIsKMatchOne( aSection );
1.111 + }
1.112 + else if ( aCommand == KCmdIsExtWild )
1.113 + {
1.114 + DoCmdIsExtWild( aSection );
1.115 + }
1.116 + else if ( aCommand == KCmdIsNameWild )
1.117 + {
1.118 + DoCmdIsNameWild( aSection );
1.119 + }
1.120 + else if ( aCommand == KCmdIsRoot)
1.121 + {
1.122 + DoCmdIsRoot( aSection );
1.123 + }
1.124 + else if ( aCommand == KCmdIsWild )
1.125 + {
1.126 + DoCmdIsWild( aSection );
1.127 + }
1.128 + else if ( aCommand == KCmdName )
1.129 + {
1.130 + DoCmdName( aSection );
1.131 + }
1.132 + else if ( aCommand == KCmdNameAndExt )
1.133 + {
1.134 + DoCmdNameAndExt( aSection );
1.135 + }
1.136 + else if ( aCommand == KCmdNameOrExtPresent )
1.137 + {
1.138 + DoCmdNameOrExtPresent( aSection );
1.139 + }
1.140 + else if ( aCommand == KCmdNamePresent )
1.141 + {
1.142 + DoCmdNamePresent( aSection );
1.143 + }
1.144 + else if ( aCommand == KCmdPath )
1.145 + {
1.146 + DoCmdPath( aSection );
1.147 + }
1.148 + else if ( aCommand == KCmdPathPresent )
1.149 + {
1.150 + DoCmdPathPresent( aSection );
1.151 + }
1.152 + else
1.153 + {
1.154 + retVal = EFalse;
1.155 + }
1.156 +
1.157 + return retVal;
1.158 + }
1.159 +
1.160 +
1.161 +void CT_ParseBaseData::DoCmdDrive( const TDesC& aSection )
1.162 +/** Gets the drive letter using Drive(). */
1.163 + {
1.164 + INFO_PRINTF1( _L( "Drive()" ) );
1.165 +
1.166 + TPtrC result = GetParse()->Drive();
1.167 + INFO_PRINTF2(_L("Drive() return: %S"), &result);
1.168 +
1.169 + TPtrC expected;
1.170 + if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
1.171 + {
1.172 + if ( result != expected )
1.173 + {
1.174 + ERR_PRINTF3(_L("Drive() returns %S but expected %S"), &result, &expected);
1.175 + SetBlockResult( EFail);
1.176 + }
1.177 + }
1.178 + }
1.179 +
1.180 +void CT_ParseBaseData::DoCmdDriveAndPath( const TDesC& aSection )
1.181 +/** Gets the path and drive letter using DriveAndPath(). */
1.182 + {
1.183 + INFO_PRINTF1( _L( "DriveAndPath()" ) );
1.184 +
1.185 + TPtrC result = GetParse()->DriveAndPath();
1.186 + INFO_PRINTF2(_L("DriveAndPath() return: %S"), &result);
1.187 +
1.188 + TPtrC expected;
1.189 + if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
1.190 + {
1.191 + if ( result != expected )
1.192 + {
1.193 + ERR_PRINTF3(_L("DriveAndPath() returns %S but expected %S"), &result, &expected);
1.194 + SetBlockResult( EFail);
1.195 + }
1.196 + }
1.197 +
1.198 +
1.199 + }
1.200 +
1.201 +void CT_ParseBaseData::DoCmdDrivePresent( const TDesC& aSection )
1.202 +/** Tests whether a drive is present using DrivePresent(). */
1.203 + {
1.204 + INFO_PRINTF1( _L( "DrivePresent()" ) );
1.205 +
1.206 + TBool result = GetParse()->DrivePresent();
1.207 +
1.208 + TPtrC strIsTrue = result ? _L("TRUE") : _L("FALSE");
1.209 + INFO_PRINTF2(_L("DrivePresent() return: %S"), &strIsTrue);
1.210 +
1.211 + TBool expected;
1.212 + if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
1.213 + {
1.214 + if ( (result>0) != (expected>0) )
1.215 + {
1.216 + ERR_PRINTF3(_L("DrivePresent() returns %d but expected %d"), result, expected);
1.217 + SetBlockResult( EFail);
1.218 + }
1.219 + }
1.220 + }
1.221 +
1.222 +void CT_ParseBaseData::DoCmdExt( const TDesC& aSection )
1.223 +/** Gets the file extension using Ext(). */
1.224 + {
1.225 + INFO_PRINTF1( _L( "Ext()" ) );
1.226 +
1.227 + TPtrC result = GetParse()->Ext();
1.228 + INFO_PRINTF2(_L("Ext() returns: %S"), &result);
1.229 +
1.230 + TPtrC expected;
1.231 + if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
1.232 + {
1.233 + if ( result != expected )
1.234 + {
1.235 + ERR_PRINTF3(_L("Ext() returns %S but expected %S"), &result, &expected);
1.236 + SetBlockResult( EFail);
1.237 + }
1.238 + }
1.239 + }
1.240 +
1.241 +void CT_ParseBaseData::DoCmdExtPresent( const TDesC& aSection )
1.242 +/** Tests whether an extension is present using ExtPresent(). */
1.243 + {
1.244 + INFO_PRINTF1( _L( "ExtPresent()" ) );
1.245 +
1.246 + TBool result = GetParse()->ExtPresent();
1.247 +
1.248 + TPtrC strIsTrue = result ? _L("TRUE") : _L("FALSE");
1.249 + INFO_PRINTF2(_L("ExtPresent() return: %S"), &strIsTrue);
1.250 +
1.251 + TBool expected;
1.252 + if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
1.253 + {
1.254 + if ( (result>0) != (expected>0) )
1.255 + {
1.256 + ERR_PRINTF3(_L("ExtPresent() returns %d but expected %d"), result, expected);
1.257 + SetBlockResult( EFail);
1.258 + }
1.259 + }
1.260 + }
1.261 +
1.262 +void CT_ParseBaseData::DoCmdFullName( const TDesC& aSection )
1.263 +/** Gets the complete file specification using FullName(). */
1.264 + {
1.265 + INFO_PRINTF1( _L( "FullName()" ) );
1.266 +
1.267 + TPtrC result = GetParse()->FullName();
1.268 + INFO_PRINTF2(_L("FullName() return: %S"), &result);
1.269 +
1.270 + TPtrC expected;
1.271 + if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
1.272 + {
1.273 + if ( result != expected )
1.274 + {
1.275 + ERR_PRINTF3(_L("FullName() returns %S but expected %S"), &result, &expected);
1.276 + SetBlockResult( EFail);
1.277 + }
1.278 + }
1.279 + }
1.280 +
1.281 +void CT_ParseBaseData::DoCmdIsExtWild( const TDesC& aSection )
1.282 +/** Tests whether the extension in the fully parsed specification contains one or
1.283 + * more wildcard characters using IsExtWild()
1.284 + */
1.285 + {
1.286 + INFO_PRINTF1( _L( "IsExtWild()" ) );
1.287 +
1.288 + TBool result = GetParse()->IsExtWild();
1.289 + TPtrC temp = result ? _L("TRUE") : _L("FALSE");
1.290 + INFO_PRINTF2(_L("IsExtWild() return: %S"), &temp);
1.291 +
1.292 + TBool expected;
1.293 + if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
1.294 + {
1.295 + //NB! IsExtWild can return values >1
1.296 + if ( (result>0) != (expected>0) )
1.297 + {
1.298 + ERR_PRINTF3(_L("IsExtWild() returns %S but expected %S"), &result, &expected);
1.299 + SetBlockResult( EFail);
1.300 + }
1.301 + }
1.302 + }
1.303 +
1.304 +void CT_ParseBaseData::DoCmdIsKMatchAny( const TDesC& aSection )
1.305 +/** Tests whether the name or the extension contains asterisk wildcards usinbg IsKMatchAny(). */
1.306 + {
1.307 + INFO_PRINTF1( _L( "IsKMatchAny()" ) );
1.308 +
1.309 + TBool result = GetParse()->IsKMatchAny();
1.310 + TPtrC temp = result ? _L("TRUE") : _L("FALSE");
1.311 + INFO_PRINTF2(_L("IsKMatchAny() return: %S"), &temp);
1.312 +
1.313 + TBool expected;
1.314 + if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
1.315 + {
1.316 + if ( (result>0) != (expected>0) )
1.317 + {
1.318 + ERR_PRINTF3(_L("IsKMatchAny() returns %d but expected %d"), result, expected);
1.319 + SetBlockResult( EFail);
1.320 + }
1.321 + }
1.322 + }
1.323 +
1.324 +void CT_ParseBaseData::DoCmdIsKMatchOne( const TDesC& aSection )
1.325 +/** Tests whether the name or the extension contains a question mark wildcard using IsKMatchOne() */
1.326 + {
1.327 + INFO_PRINTF1( _L( "IsKMatchOne()" ) );
1.328 +
1.329 + TBool result = GetParse()->IsKMatchOne();
1.330 + TPtrC temp = result ? _L("TRUE") : _L("FALSE");
1.331 + INFO_PRINTF2(_L("IsKMatchOne() return: %S"), &temp);
1.332 +
1.333 + TBool expected;
1.334 + if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
1.335 + {
1.336 + if ( (result>0) != (expected>0) )
1.337 + {
1.338 + ERR_PRINTF3(_L("IsKMatchOne() returns %d but expected %d"), result, expected);
1.339 + SetBlockResult( EFail);
1.340 + }
1.341 + }
1.342 + }
1.343 +
1.344 +void CT_ParseBaseData::DoCmdIsNameWild( const TDesC& aSection )
1.345 +/** Tests whether the filename in the fully parsed specification contains one or more wildcard
1.346 + * characters using IsNameWild()
1.347 + */
1.348 + {
1.349 + INFO_PRINTF1( _L( "IsNameWild()" ) );
1.350 +
1.351 + TBool result = GetParse()->IsNameWild();
1.352 + TPtrC temp = result ? _L("TRUE") : _L("FALSE");
1.353 + INFO_PRINTF2(_L("IsNameWild() return: %S"), &temp);
1.354 +
1.355 + TBool expected;
1.356 + if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
1.357 + {
1.358 + if ( (result>0) != (expected>0) )
1.359 + {
1.360 + ERR_PRINTF3(_L("IsNameWild() returns %d but expected %d"), result, expected);
1.361 + SetBlockResult( EFail);
1.362 + }
1.363 + }
1.364 + }
1.365 +
1.366 +void CT_ParseBaseData::DoCmdIsRoot( const TDesC& aSection )
1.367 +/** Tests whether the path in the fully parsed specification is the root directory using IsRoot(). */
1.368 + {
1.369 + INFO_PRINTF1( _L( "IsRoot()" ) );
1.370 +
1.371 + TBool result = GetParse()->IsRoot();
1.372 + TPtrC temp = result ? _L("TRUE") : _L("FALSE");
1.373 + INFO_PRINTF2(_L("IsRoot() return: %S"), &temp);
1.374 +
1.375 + TBool expected;
1.376 + if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
1.377 + {
1.378 + if ( (result>0) != (expected>0) )
1.379 + {
1.380 + ERR_PRINTF3(_L("IsRoot() returns %d but expected %d"), result, expected);
1.381 + SetBlockResult( EFail);
1.382 + }
1.383 + }
1.384 + }
1.385 +
1.386 +void CT_ParseBaseData::DoCmdIsWild( const TDesC& aSection )
1.387 +/** Tests whether the filename or the extension in the fully parsed specification contains one or
1.388 + * more wildcard characters using IsWild()
1.389 + */
1.390 + {
1.391 + INFO_PRINTF1( _L( "IsWild()" ) );
1.392 +
1.393 + TBool result = GetParse()->IsWild();
1.394 + TPtrC temp = result ? _L("TRUE") : _L("FALSE");
1.395 + INFO_PRINTF2(_L("IsWild() return: %S"), &temp);
1.396 +
1.397 + TBool expected;
1.398 + if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
1.399 + {
1.400 + if ( (result>0) != (expected>0) )
1.401 + {
1.402 + ERR_PRINTF3(_L("IsWild() returns %d but expected %d"), result, expected);
1.403 + SetBlockResult( EFail);
1.404 + }
1.405 + }
1.406 +
1.407 + }
1.408 +
1.409 +void CT_ParseBaseData::DoCmdName( const TDesC& aSection )
1.410 +/** Gets the file name using Name(). */
1.411 + {
1.412 + INFO_PRINTF1( _L( "Name()" ) );
1.413 +
1.414 + TPtrC result = GetParse()->Name();
1.415 + INFO_PRINTF2(_L( "Name() return: %S" ), &result);
1.416 +
1.417 + TPtrC expected;
1.418 + if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
1.419 + {
1.420 + if ( result != expected )
1.421 + {
1.422 + ERR_PRINTF3(_L("Name() returns %S but expected %S"), &result, &expected);
1.423 + SetBlockResult( EFail);
1.424 + }
1.425 + }
1.426 + }
1.427 +
1.428 +void CT_ParseBaseData::DoCmdNameOrExtPresent( const TDesC& aSection )
1.429 +/** Tests whether a name or an extension are present using NameOrExtPresent(). */
1.430 + {
1.431 + INFO_PRINTF1( _L( "NameOrExtPresent()" ) );
1.432 +
1.433 + TBool result = GetParse()->NameOrExtPresent();
1.434 + TPtrC temp = result ? _L("TRUE") : _L("FALSE");
1.435 + INFO_PRINTF2(_L("NameOrExtPresent() return: %S"), &temp);
1.436 +
1.437 + TBool expected;
1.438 + if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
1.439 + {
1.440 + if ( (result>0) != (expected>0) )
1.441 + {
1.442 + ERR_PRINTF3(_L("NameOrExtPresent() returns %d but expected %d"), result, expected);
1.443 + SetBlockResult( EFail);
1.444 + }
1.445 + }
1.446 + }
1.447 +
1.448 +void CT_ParseBaseData::DoCmdNameAndExt( const TDesC& aSection )
1.449 +/** Gets the file name and extension using NameAndExt(). */
1.450 + {
1.451 + INFO_PRINTF1( _L( "NameAndExt()" ) );
1.452 +
1.453 + TPtrC result = GetParse()->NameAndExt();
1.454 + INFO_PRINTF2( _L( "NameAndExt() return: %S" ), &result );
1.455 +
1.456 + TPtrC expected;
1.457 + if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
1.458 + {
1.459 + if ( result != expected )
1.460 + {
1.461 + ERR_PRINTF3(_L("NameAndExt() returns %S but expected %S"), &result, &expected);
1.462 + SetBlockResult( EFail);
1.463 + }
1.464 + }
1.465 + }
1.466 +
1.467 +void CT_ParseBaseData::DoCmdNamePresent( const TDesC& aSection )
1.468 +/** Tests whether a file name is present using NamePresent(). */
1.469 + {
1.470 + INFO_PRINTF1( _L( "NamePresent()" ) );
1.471 +
1.472 + TBool result = GetParse()->NamePresent();
1.473 + TPtrC temp = result ? _L("TRUE") : _L("FALSE");
1.474 + INFO_PRINTF2(_L("NamePresent() return: %S"), &temp);
1.475 +
1.476 + TBool expected;
1.477 + if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
1.478 + {
1.479 + if ( (result>0) != (expected>0) )
1.480 + {
1.481 + ERR_PRINTF3(_L("NamePresent() returns %d but expected %d"), result, expected);
1.482 + SetBlockResult( EFail);
1.483 + }
1.484 + }
1.485 + }
1.486 +
1.487 +void CT_ParseBaseData::DoCmdPath( const TDesC& aSection )
1.488 +/** Gets the path using Path(). */
1.489 + {
1.490 + INFO_PRINTF1( _L( "Path()" ) );
1.491 +
1.492 + TPtrC result = GetParse()->Path();
1.493 + INFO_PRINTF2( _L( "Path() return: %S" ), &result );
1.494 +
1.495 + TPtrC expected;
1.496 + if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
1.497 + {
1.498 + if ( result != expected )
1.499 + {
1.500 + ERR_PRINTF3(_L("Path() returns %S but expected %S"), &result, &expected);
1.501 + SetBlockResult( EFail);
1.502 + }
1.503 + }
1.504 + }
1.505 +
1.506 +void CT_ParseBaseData::DoCmdPathPresent( const TDesC& aSection )
1.507 +/** Tests whether a path is present using PathPresent(). */
1.508 + {
1.509 + INFO_PRINTF1( _L( "PathPresent()" ) );
1.510 +
1.511 + TBool result = GetParse()->PathPresent();
1.512 + TPtrC temp = result ? _L("TRUE") : _L("FALSE");
1.513 + INFO_PRINTF2(_L("PathPresent() return: %S"), &temp);
1.514 +
1.515 + TBool expected;
1.516 + if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
1.517 + {
1.518 + if ( (result>0) != (expected>0) )
1.519 + {
1.520 + ERR_PRINTF3(_L("PathPresent() returns %d but expected %d"), result, expected);
1.521 + SetBlockResult( EFail);
1.522 + }
1.523 + }
1.524 + }
1.525 +