os/ossrv/syslibsapitest/syslibssvs/ecom/src/T_ImplementationInformationData.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 
    20 #include "T_ImplementationInformationData.h"
    21 
    22 /*@{*/
    23 ///	Parameters
    24 _LIT( KUid,													"uid" );
    25 _LIT( KExpectedString,										"expected_string" );
    26 _LIT( KExpectedResult,										"expected" );
    27 _LIT( KExpectedBool,										"expected_bool" );
    28 _LIT( KDisabled,											"disabled" );
    29 _LIT( KElement,												"element" );
    30 
    31 ///	CImplementationInformation
    32 _LIT( KCmdDisplayName,										"DisplayName" );
    33 _LIT( KCmdDataType,											"DataType" );
    34 _LIT( KCmdOpaqueData,										"OpaqueData" );
    35 _LIT( KCmdImplementationUid,								"ImplementationUid" );
    36 _LIT( KCmdVersion,											"Version" );
    37 _LIT( KCmdDisabled,											"Disabled" );
    38 _LIT( KCmdSetDisabled,										"SetDisabled" );
    39 _LIT( KCmdDrive,											"Drive" );
    40 _LIT( KCmdRomOnly,											"RomOnly" );
    41 _LIT( KCmdRomBased,											"RomBased" );
    42 _LIT( KCmdDestroy,											"~" );
    43 
    44 _LIT( KEmptyString,											"");
    45 /*@}*/
    46 
    47 //////////////////////////////////////////////////////////////////////
    48 // Construction/Destruction
    49 //////////////////////////////////////////////////////////////////////
    50 
    51 CT_ImplementationInformationData* CT_ImplementationInformationData::NewL( )
    52 	{
    53 	CT_ImplementationInformationData*	ret = new ( ELeave ) CT_ImplementationInformationData( );
    54 	CleanupStack::PushL( ret );
    55 	ret->ConstructL();
    56 	CleanupStack::Pop( ret );
    57 	return ret;
    58 	}
    59 
    60 CT_ImplementationInformationData::CT_ImplementationInformationData( )
    61 :	iImplementationInformation(NULL)
    62 	{
    63 	}
    64 
    65 void CT_ImplementationInformationData::ConstructL()
    66 	{
    67 	}
    68 
    69 CT_ImplementationInformationData::~CT_ImplementationInformationData()
    70 	{
    71 	DestroyData();
    72 	}
    73 
    74 void CT_ImplementationInformationData::DestroyData()
    75 	{
    76 	//	this does not own iImplementationInformation
    77 	iImplementationInformation=NULL;
    78 	}
    79 
    80 //////////////////////////////////////////////////////////////////////
    81 // Read data from INI file
    82 //////////////////////////////////////////////////////////////////////
    83 
    84 TBool CT_ImplementationInformationData::GetUid( const TDesC& aSection, TUid& aUid )
    85 	{
    86  	TInt	uidValue=0;
    87  	TBool	ret=GetHexFromConfig( aSection, KUid(), uidValue ) ;
    88  	aUid = TUid::Uid( uidValue );
    89  	return ret;
    90  	}
    91 
    92 TBool CT_ImplementationInformationData::GetExpectedString( const TDesC& aSection, TPtrC& aExpectedString)
    93 	{
    94 	aExpectedString.Set(KEmptyString);
    95 	return GetStringFromConfig( aSection, KExpectedString(), aExpectedString);
    96 	}
    97 
    98 TBool CT_ImplementationInformationData::GetExpectedResult( const TDesC& aSection, TInt& aExpectedResult )
    99 	{
   100 	aExpectedResult = 0;
   101 	return GetIntFromConfig( aSection, KExpectedResult(), aExpectedResult );
   102 	}
   103 
   104 TBool CT_ImplementationInformationData::GetExpectedHexResult( const TDesC& aSection, TInt& aExpectedResult)
   105 	{
   106 	aExpectedResult = 0;
   107 	return GetHexFromConfig( aSection, KExpectedResult(), aExpectedResult );
   108 	}
   109 
   110 TBool CT_ImplementationInformationData::GetArrayElement(const TDesC& aSection, TInt& aArrayElement)
   111 	{
   112 	aArrayElement = 0;
   113 	return GetIntFromConfig( aSection, KElement(), aArrayElement);
   114 	}
   115 
   116 TBool CT_ImplementationInformationData::GetExpectedBool( const TDesC& aSection, TBool& aBool )
   117 	{
   118 	aBool = EFalse;
   119 	return GetBoolFromConfig( aSection, KExpectedBool(), aBool );
   120 	}
   121 
   122 TBool CT_ImplementationInformationData::GetDisabled( const TDesC& aSection, TBool& aDisabled )
   123 	{
   124 	aDisabled = EFalse;
   125 	return GetBoolFromConfig( aSection, KDisabled(), aDisabled );
   126 	}
   127 
   128 /**
   129  Test script command entry point
   130  @internalComponent
   131 
   132  @return Explanation of the object returned
   133  @param aCommand descriptor containing the command value
   134  @param aSection descriptor containing the command parameter
   135  @pre N/A 
   136  @post N/A
   137 */
   138 TBool CT_ImplementationInformationData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
   139 	{
   140 	TBool								retVal = ETrue;
   141 	
   142 	if ( aCommand == KCmdDestroy )
   143 		{
   144 		DoCmdDestroy();
   145 		}
   146 	else if ( aCommand == KCmdDisplayName )
   147 		{
   148 		DoCmdDisplayName( aSection );
   149 		}
   150 	else if ( aCommand == KCmdDataType )
   151 		{
   152 		DoCmdDataType( aSection );
   153 		}
   154 	else if ( aCommand == KCmdOpaqueData )
   155 		{
   156 		DoCmdOpaqueData( aSection );
   157 		}
   158 	else if ( aCommand == KCmdImplementationUid )
   159 		{
   160 		DoCmdImplementationUid( aSection );
   161 		}
   162 	else if ( aCommand == KCmdVersion )
   163 		{
   164 		DoCmdVersion( aSection );
   165 		}
   166 	else if ( aCommand == KCmdDisabled )
   167 		{
   168 		DoCmdDisabled( aSection );
   169 		}
   170 	else if ( aCommand == KCmdSetDisabled )
   171 		{
   172 		DoCmdSetDisabled( aSection );
   173 		}
   174 	else if ( aCommand == KCmdDrive )
   175 		{
   176 		DoCmdDrive( aSection );
   177 		}
   178 	else if ( aCommand == KCmdRomOnly )
   179 		{
   180 		DoCmdRomOnly( aSection );
   181 		}
   182 	else if ( aCommand == KCmdRomBased )
   183 		{
   184 		DoCmdRomBased( aSection );
   185 		}
   186 	else
   187 		{
   188 		retVal = EFalse;
   189 		}
   190 
   191 	return retVal;
   192 	}
   193 
   194 void CT_ImplementationInformationData::DoCmdDisplayName(const TDesC& aSection)
   195 	{
   196 	TBuf<KMaxTestExecuteCommandLength>	actualValue;
   197 	actualValue.Copy(iImplementationInformation->DisplayName());
   198 	TInt	pos=actualValue.Find(_L("|"));
   199 	if (pos>0)
   200 		{
   201 		actualValue.Copy(actualValue.Left(pos));
   202 		};
   203 	INFO_PRINTF2(_L("DisplayName %S"), &actualValue);
   204 
   205 	TPtrC	expectedValue;
   206 	if (GetExpectedString(aSection, expectedValue))
   207 		{
   208 		if (actualValue!=expectedValue)
   209 			{
   210 			ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
   211 			SetBlockResult(EFail);
   212 			}
   213 		}
   214 	}
   215 
   216 void CT_ImplementationInformationData::DoCmdDataType(const TDesC& aSection)
   217 	{
   218 	TBuf<KMaxTestExecuteCommandLength>	actualValue;
   219 	actualValue.Copy(iImplementationInformation->DataType());
   220 	TInt	pos=actualValue.Find(_L("|"));
   221 	if (pos>0)
   222 		{
   223 		actualValue.Copy(actualValue.Left(pos));
   224 		};
   225 	INFO_PRINTF2(_L("DataType %S"), &actualValue);
   226 	
   227 	TPtrC	expectedValue;
   228 	if (GetExpectedString(aSection, expectedValue))
   229 		{
   230 		if (actualValue!=expectedValue)
   231 			{
   232 			ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
   233 			SetBlockResult(EFail);
   234 			}
   235 		}
   236 	}
   237 
   238 void CT_ImplementationInformationData::DoCmdOpaqueData(const TDesC& aSection)
   239 	{
   240 	TBuf<KMaxTestExecuteCommandLength>	actualValue;
   241 	actualValue.Copy(iImplementationInformation->OpaqueData());
   242 	TInt	pos=actualValue.Find(_L("|"));
   243 	if (pos>0)
   244 		{
   245 		actualValue.Copy(actualValue.Left(pos));
   246 		};
   247 	INFO_PRINTF2(_L("OpaqueData %S"), &actualValue);
   248 	
   249 	TPtrC	expectedValue;
   250 	if (GetExpectedString(aSection, expectedValue))
   251 		{
   252 		if (actualValue!=expectedValue)
   253 			{
   254 			ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
   255 			SetBlockResult(EFail);
   256 			}
   257 		}
   258 	}
   259 
   260 void CT_ImplementationInformationData::DoCmdImplementationUid(const TDesC& aSection)
   261 	{
   262 	TInt	actualValue=iImplementationInformation->ImplementationUid().iUid;
   263 	INFO_PRINTF2(_L("ImplementationUid %d"), actualValue);
   264 
   265 	TInt	expectedValue;
   266 	if (GetExpectedHexResult(aSection, expectedValue))
   267 		{
   268 		if (actualValue!=expectedValue)
   269 			{
   270 			ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
   271 			SetBlockResult(EFail);
   272 			}
   273 		}
   274 	}
   275 
   276 void CT_ImplementationInformationData::DoCmdVersion(const TDesC& aSection)
   277 	{
   278 	TInt	actualValue=iImplementationInformation->Version();
   279 	INFO_PRINTF2(_L("Version %d"), actualValue);
   280 
   281 	TInt	expectedValue;
   282 	if (GetExpectedResult(aSection, expectedValue))
   283 		{
   284 		if (actualValue!=expectedValue)
   285 			{
   286 			ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
   287 			SetBlockResult(EFail);
   288 			}
   289 		}
   290 	}
   291 
   292 void CT_ImplementationInformationData::DoCmdDisabled(const TDesC& aSection)
   293 	{
   294 	TBool	actualValue=iImplementationInformation->Disabled();
   295 	INFO_PRINTF2(_L("Disabled %d"), actualValue);
   296 
   297 	TBool	expectedValue;
   298 	if (GetExpectedBool(aSection, expectedValue))
   299 		{
   300 		if (actualValue!=expectedValue)
   301 			{
   302 			ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
   303 			SetBlockResult(EFail);
   304 			}
   305 		}
   306 	}
   307 
   308 void CT_ImplementationInformationData::DoCmdSetDisabled(const TDesC& aSection)
   309 	{
   310 	INFO_PRINTF1(_L("SetDisabled"));
   311 
   312 	TBool	disabled;
   313 	if (!GetDisabled(aSection, disabled))
   314 		{
   315 		ERR_PRINTF1(_L("Not enought arguments"));
   316 		SetBlockResult( EFail );
   317 		}
   318 	else
   319 		{
   320 		iImplementationInformation->SetDisabled(disabled);
   321 		}
   322 	}
   323 
   324 void CT_ImplementationInformationData::DoCmdDrive(const TDesC& aSection)
   325 	{
   326 	TDriveName	actualValue(iImplementationInformation->Drive().Name());
   327 	INFO_PRINTF2(_L("Drive Name %s"), &actualValue);
   328 
   329 	TPtrC	expectedValue;
   330 	if (GetExpectedString(aSection, expectedValue))
   331 		{
   332 		if (actualValue!=expectedValue)
   333 			{
   334 			ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
   335 			SetBlockResult(EFail);
   336 			}
   337 		}
   338 	}
   339 
   340 void CT_ImplementationInformationData::DoCmdRomOnly(const TDesC& aSection)
   341 	{
   342 	TBool	actualValue=iImplementationInformation->RomOnly();
   343 	INFO_PRINTF2(_L("RomOnly %d"), actualValue);
   344 
   345 	TBool	expectedValue;
   346 	if (GetExpectedBool(aSection, expectedValue))
   347 		{
   348 		if (actualValue!=expectedValue)
   349 			{
   350 			ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
   351 			SetBlockResult(EFail);
   352 			}
   353 		}
   354 	}
   355 
   356 void CT_ImplementationInformationData::DoCmdRomBased(const TDesC& aSection)
   357 	{
   358 	TBool	actualValue=iImplementationInformation->RomBased();
   359 	INFO_PRINTF2(_L("RomBased %d"), actualValue);
   360 
   361 	TBool	expectedValue;
   362 	if (GetExpectedBool(aSection, expectedValue))
   363 		{
   364 		if (actualValue!=expectedValue)
   365 			{
   366 			ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
   367 			SetBlockResult(EFail);
   368 			}
   369 		}
   370 	}
   371 
   372 void CT_ImplementationInformationData::DoCmdDestroy()
   373 	{
   374 	INFO_PRINTF1( _L( "Destroyed" ) );
   375 	DestroyData();
   376 	}