1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/syslibsapitest/syslibssvs/ecom/src/T_ImplementationInformationData.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,376 @@
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 +
1.23 +#include "T_ImplementationInformationData.h"
1.24 +
1.25 +/*@{*/
1.26 +/// Parameters
1.27 +_LIT( KUid, "uid" );
1.28 +_LIT( KExpectedString, "expected_string" );
1.29 +_LIT( KExpectedResult, "expected" );
1.30 +_LIT( KExpectedBool, "expected_bool" );
1.31 +_LIT( KDisabled, "disabled" );
1.32 +_LIT( KElement, "element" );
1.33 +
1.34 +/// CImplementationInformation
1.35 +_LIT( KCmdDisplayName, "DisplayName" );
1.36 +_LIT( KCmdDataType, "DataType" );
1.37 +_LIT( KCmdOpaqueData, "OpaqueData" );
1.38 +_LIT( KCmdImplementationUid, "ImplementationUid" );
1.39 +_LIT( KCmdVersion, "Version" );
1.40 +_LIT( KCmdDisabled, "Disabled" );
1.41 +_LIT( KCmdSetDisabled, "SetDisabled" );
1.42 +_LIT( KCmdDrive, "Drive" );
1.43 +_LIT( KCmdRomOnly, "RomOnly" );
1.44 +_LIT( KCmdRomBased, "RomBased" );
1.45 +_LIT( KCmdDestroy, "~" );
1.46 +
1.47 +_LIT( KEmptyString, "");
1.48 +/*@}*/
1.49 +
1.50 +//////////////////////////////////////////////////////////////////////
1.51 +// Construction/Destruction
1.52 +//////////////////////////////////////////////////////////////////////
1.53 +
1.54 +CT_ImplementationInformationData* CT_ImplementationInformationData::NewL( )
1.55 + {
1.56 + CT_ImplementationInformationData* ret = new ( ELeave ) CT_ImplementationInformationData( );
1.57 + CleanupStack::PushL( ret );
1.58 + ret->ConstructL();
1.59 + CleanupStack::Pop( ret );
1.60 + return ret;
1.61 + }
1.62 +
1.63 +CT_ImplementationInformationData::CT_ImplementationInformationData( )
1.64 +: iImplementationInformation(NULL)
1.65 + {
1.66 + }
1.67 +
1.68 +void CT_ImplementationInformationData::ConstructL()
1.69 + {
1.70 + }
1.71 +
1.72 +CT_ImplementationInformationData::~CT_ImplementationInformationData()
1.73 + {
1.74 + DestroyData();
1.75 + }
1.76 +
1.77 +void CT_ImplementationInformationData::DestroyData()
1.78 + {
1.79 + // this does not own iImplementationInformation
1.80 + iImplementationInformation=NULL;
1.81 + }
1.82 +
1.83 +//////////////////////////////////////////////////////////////////////
1.84 +// Read data from INI file
1.85 +//////////////////////////////////////////////////////////////////////
1.86 +
1.87 +TBool CT_ImplementationInformationData::GetUid( const TDesC& aSection, TUid& aUid )
1.88 + {
1.89 + TInt uidValue=0;
1.90 + TBool ret=GetHexFromConfig( aSection, KUid(), uidValue ) ;
1.91 + aUid = TUid::Uid( uidValue );
1.92 + return ret;
1.93 + }
1.94 +
1.95 +TBool CT_ImplementationInformationData::GetExpectedString( const TDesC& aSection, TPtrC& aExpectedString)
1.96 + {
1.97 + aExpectedString.Set(KEmptyString);
1.98 + return GetStringFromConfig( aSection, KExpectedString(), aExpectedString);
1.99 + }
1.100 +
1.101 +TBool CT_ImplementationInformationData::GetExpectedResult( const TDesC& aSection, TInt& aExpectedResult )
1.102 + {
1.103 + aExpectedResult = 0;
1.104 + return GetIntFromConfig( aSection, KExpectedResult(), aExpectedResult );
1.105 + }
1.106 +
1.107 +TBool CT_ImplementationInformationData::GetExpectedHexResult( const TDesC& aSection, TInt& aExpectedResult)
1.108 + {
1.109 + aExpectedResult = 0;
1.110 + return GetHexFromConfig( aSection, KExpectedResult(), aExpectedResult );
1.111 + }
1.112 +
1.113 +TBool CT_ImplementationInformationData::GetArrayElement(const TDesC& aSection, TInt& aArrayElement)
1.114 + {
1.115 + aArrayElement = 0;
1.116 + return GetIntFromConfig( aSection, KElement(), aArrayElement);
1.117 + }
1.118 +
1.119 +TBool CT_ImplementationInformationData::GetExpectedBool( const TDesC& aSection, TBool& aBool )
1.120 + {
1.121 + aBool = EFalse;
1.122 + return GetBoolFromConfig( aSection, KExpectedBool(), aBool );
1.123 + }
1.124 +
1.125 +TBool CT_ImplementationInformationData::GetDisabled( const TDesC& aSection, TBool& aDisabled )
1.126 + {
1.127 + aDisabled = EFalse;
1.128 + return GetBoolFromConfig( aSection, KDisabled(), aDisabled );
1.129 + }
1.130 +
1.131 +/**
1.132 + Test script command entry point
1.133 + @internalComponent
1.134 +
1.135 + @return Explanation of the object returned
1.136 + @param aCommand descriptor containing the command value
1.137 + @param aSection descriptor containing the command parameter
1.138 + @pre N/A
1.139 + @post N/A
1.140 +*/
1.141 +TBool CT_ImplementationInformationData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
1.142 + {
1.143 + TBool retVal = ETrue;
1.144 +
1.145 + if ( aCommand == KCmdDestroy )
1.146 + {
1.147 + DoCmdDestroy();
1.148 + }
1.149 + else if ( aCommand == KCmdDisplayName )
1.150 + {
1.151 + DoCmdDisplayName( aSection );
1.152 + }
1.153 + else if ( aCommand == KCmdDataType )
1.154 + {
1.155 + DoCmdDataType( aSection );
1.156 + }
1.157 + else if ( aCommand == KCmdOpaqueData )
1.158 + {
1.159 + DoCmdOpaqueData( aSection );
1.160 + }
1.161 + else if ( aCommand == KCmdImplementationUid )
1.162 + {
1.163 + DoCmdImplementationUid( aSection );
1.164 + }
1.165 + else if ( aCommand == KCmdVersion )
1.166 + {
1.167 + DoCmdVersion( aSection );
1.168 + }
1.169 + else if ( aCommand == KCmdDisabled )
1.170 + {
1.171 + DoCmdDisabled( aSection );
1.172 + }
1.173 + else if ( aCommand == KCmdSetDisabled )
1.174 + {
1.175 + DoCmdSetDisabled( aSection );
1.176 + }
1.177 + else if ( aCommand == KCmdDrive )
1.178 + {
1.179 + DoCmdDrive( aSection );
1.180 + }
1.181 + else if ( aCommand == KCmdRomOnly )
1.182 + {
1.183 + DoCmdRomOnly( aSection );
1.184 + }
1.185 + else if ( aCommand == KCmdRomBased )
1.186 + {
1.187 + DoCmdRomBased( aSection );
1.188 + }
1.189 + else
1.190 + {
1.191 + retVal = EFalse;
1.192 + }
1.193 +
1.194 + return retVal;
1.195 + }
1.196 +
1.197 +void CT_ImplementationInformationData::DoCmdDisplayName(const TDesC& aSection)
1.198 + {
1.199 + TBuf<KMaxTestExecuteCommandLength> actualValue;
1.200 + actualValue.Copy(iImplementationInformation->DisplayName());
1.201 + TInt pos=actualValue.Find(_L("|"));
1.202 + if (pos>0)
1.203 + {
1.204 + actualValue.Copy(actualValue.Left(pos));
1.205 + };
1.206 + INFO_PRINTF2(_L("DisplayName %S"), &actualValue);
1.207 +
1.208 + TPtrC expectedValue;
1.209 + if (GetExpectedString(aSection, expectedValue))
1.210 + {
1.211 + if (actualValue!=expectedValue)
1.212 + {
1.213 + ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
1.214 + SetBlockResult(EFail);
1.215 + }
1.216 + }
1.217 + }
1.218 +
1.219 +void CT_ImplementationInformationData::DoCmdDataType(const TDesC& aSection)
1.220 + {
1.221 + TBuf<KMaxTestExecuteCommandLength> actualValue;
1.222 + actualValue.Copy(iImplementationInformation->DataType());
1.223 + TInt pos=actualValue.Find(_L("|"));
1.224 + if (pos>0)
1.225 + {
1.226 + actualValue.Copy(actualValue.Left(pos));
1.227 + };
1.228 + INFO_PRINTF2(_L("DataType %S"), &actualValue);
1.229 +
1.230 + TPtrC expectedValue;
1.231 + if (GetExpectedString(aSection, expectedValue))
1.232 + {
1.233 + if (actualValue!=expectedValue)
1.234 + {
1.235 + ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
1.236 + SetBlockResult(EFail);
1.237 + }
1.238 + }
1.239 + }
1.240 +
1.241 +void CT_ImplementationInformationData::DoCmdOpaqueData(const TDesC& aSection)
1.242 + {
1.243 + TBuf<KMaxTestExecuteCommandLength> actualValue;
1.244 + actualValue.Copy(iImplementationInformation->OpaqueData());
1.245 + TInt pos=actualValue.Find(_L("|"));
1.246 + if (pos>0)
1.247 + {
1.248 + actualValue.Copy(actualValue.Left(pos));
1.249 + };
1.250 + INFO_PRINTF2(_L("OpaqueData %S"), &actualValue);
1.251 +
1.252 + TPtrC expectedValue;
1.253 + if (GetExpectedString(aSection, expectedValue))
1.254 + {
1.255 + if (actualValue!=expectedValue)
1.256 + {
1.257 + ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
1.258 + SetBlockResult(EFail);
1.259 + }
1.260 + }
1.261 + }
1.262 +
1.263 +void CT_ImplementationInformationData::DoCmdImplementationUid(const TDesC& aSection)
1.264 + {
1.265 + TInt actualValue=iImplementationInformation->ImplementationUid().iUid;
1.266 + INFO_PRINTF2(_L("ImplementationUid %d"), actualValue);
1.267 +
1.268 + TInt expectedValue;
1.269 + if (GetExpectedHexResult(aSection, expectedValue))
1.270 + {
1.271 + if (actualValue!=expectedValue)
1.272 + {
1.273 + ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
1.274 + SetBlockResult(EFail);
1.275 + }
1.276 + }
1.277 + }
1.278 +
1.279 +void CT_ImplementationInformationData::DoCmdVersion(const TDesC& aSection)
1.280 + {
1.281 + TInt actualValue=iImplementationInformation->Version();
1.282 + INFO_PRINTF2(_L("Version %d"), actualValue);
1.283 +
1.284 + TInt expectedValue;
1.285 + if (GetExpectedResult(aSection, expectedValue))
1.286 + {
1.287 + if (actualValue!=expectedValue)
1.288 + {
1.289 + ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
1.290 + SetBlockResult(EFail);
1.291 + }
1.292 + }
1.293 + }
1.294 +
1.295 +void CT_ImplementationInformationData::DoCmdDisabled(const TDesC& aSection)
1.296 + {
1.297 + TBool actualValue=iImplementationInformation->Disabled();
1.298 + INFO_PRINTF2(_L("Disabled %d"), actualValue);
1.299 +
1.300 + TBool expectedValue;
1.301 + if (GetExpectedBool(aSection, expectedValue))
1.302 + {
1.303 + if (actualValue!=expectedValue)
1.304 + {
1.305 + ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
1.306 + SetBlockResult(EFail);
1.307 + }
1.308 + }
1.309 + }
1.310 +
1.311 +void CT_ImplementationInformationData::DoCmdSetDisabled(const TDesC& aSection)
1.312 + {
1.313 + INFO_PRINTF1(_L("SetDisabled"));
1.314 +
1.315 + TBool disabled;
1.316 + if (!GetDisabled(aSection, disabled))
1.317 + {
1.318 + ERR_PRINTF1(_L("Not enought arguments"));
1.319 + SetBlockResult( EFail );
1.320 + }
1.321 + else
1.322 + {
1.323 + iImplementationInformation->SetDisabled(disabled);
1.324 + }
1.325 + }
1.326 +
1.327 +void CT_ImplementationInformationData::DoCmdDrive(const TDesC& aSection)
1.328 + {
1.329 + TDriveName actualValue(iImplementationInformation->Drive().Name());
1.330 + INFO_PRINTF2(_L("Drive Name %s"), &actualValue);
1.331 +
1.332 + TPtrC expectedValue;
1.333 + if (GetExpectedString(aSection, expectedValue))
1.334 + {
1.335 + if (actualValue!=expectedValue)
1.336 + {
1.337 + ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
1.338 + SetBlockResult(EFail);
1.339 + }
1.340 + }
1.341 + }
1.342 +
1.343 +void CT_ImplementationInformationData::DoCmdRomOnly(const TDesC& aSection)
1.344 + {
1.345 + TBool actualValue=iImplementationInformation->RomOnly();
1.346 + INFO_PRINTF2(_L("RomOnly %d"), actualValue);
1.347 +
1.348 + TBool expectedValue;
1.349 + if (GetExpectedBool(aSection, expectedValue))
1.350 + {
1.351 + if (actualValue!=expectedValue)
1.352 + {
1.353 + ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
1.354 + SetBlockResult(EFail);
1.355 + }
1.356 + }
1.357 + }
1.358 +
1.359 +void CT_ImplementationInformationData::DoCmdRomBased(const TDesC& aSection)
1.360 + {
1.361 + TBool actualValue=iImplementationInformation->RomBased();
1.362 + INFO_PRINTF2(_L("RomBased %d"), actualValue);
1.363 +
1.364 + TBool expectedValue;
1.365 + if (GetExpectedBool(aSection, expectedValue))
1.366 + {
1.367 + if (actualValue!=expectedValue)
1.368 + {
1.369 + ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
1.370 + SetBlockResult(EFail);
1.371 + }
1.372 + }
1.373 + }
1.374 +
1.375 +void CT_ImplementationInformationData::DoCmdDestroy()
1.376 + {
1.377 + INFO_PRINTF1( _L( "Destroyed" ) );
1.378 + DestroyData();
1.379 + }