Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
20 #include "T_ImplementationInformationData.h"
25 _LIT( KExpectedString, "expected_string" );
26 _LIT( KExpectedResult, "expected" );
27 _LIT( KExpectedBool, "expected_bool" );
28 _LIT( KDisabled, "disabled" );
29 _LIT( KElement, "element" );
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, "~" );
44 _LIT( KEmptyString, "");
47 //////////////////////////////////////////////////////////////////////
48 // Construction/Destruction
49 //////////////////////////////////////////////////////////////////////
51 CT_ImplementationInformationData* CT_ImplementationInformationData::NewL( )
53 CT_ImplementationInformationData* ret = new ( ELeave ) CT_ImplementationInformationData( );
54 CleanupStack::PushL( ret );
56 CleanupStack::Pop( ret );
60 CT_ImplementationInformationData::CT_ImplementationInformationData( )
61 : iImplementationInformation(NULL)
65 void CT_ImplementationInformationData::ConstructL()
69 CT_ImplementationInformationData::~CT_ImplementationInformationData()
74 void CT_ImplementationInformationData::DestroyData()
76 // this does not own iImplementationInformation
77 iImplementationInformation=NULL;
80 //////////////////////////////////////////////////////////////////////
81 // Read data from INI file
82 //////////////////////////////////////////////////////////////////////
84 TBool CT_ImplementationInformationData::GetUid( const TDesC& aSection, TUid& aUid )
87 TBool ret=GetHexFromConfig( aSection, KUid(), uidValue ) ;
88 aUid = TUid::Uid( uidValue );
92 TBool CT_ImplementationInformationData::GetExpectedString( const TDesC& aSection, TPtrC& aExpectedString)
94 aExpectedString.Set(KEmptyString);
95 return GetStringFromConfig( aSection, KExpectedString(), aExpectedString);
98 TBool CT_ImplementationInformationData::GetExpectedResult( const TDesC& aSection, TInt& aExpectedResult )
101 return GetIntFromConfig( aSection, KExpectedResult(), aExpectedResult );
104 TBool CT_ImplementationInformationData::GetExpectedHexResult( const TDesC& aSection, TInt& aExpectedResult)
107 return GetHexFromConfig( aSection, KExpectedResult(), aExpectedResult );
110 TBool CT_ImplementationInformationData::GetArrayElement(const TDesC& aSection, TInt& aArrayElement)
113 return GetIntFromConfig( aSection, KElement(), aArrayElement);
116 TBool CT_ImplementationInformationData::GetExpectedBool( const TDesC& aSection, TBool& aBool )
119 return GetBoolFromConfig( aSection, KExpectedBool(), aBool );
122 TBool CT_ImplementationInformationData::GetDisabled( const TDesC& aSection, TBool& aDisabled )
125 return GetBoolFromConfig( aSection, KDisabled(), aDisabled );
129 Test script command entry point
132 @return Explanation of the object returned
133 @param aCommand descriptor containing the command value
134 @param aSection descriptor containing the command parameter
138 TBool CT_ImplementationInformationData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
140 TBool retVal = ETrue;
142 if ( aCommand == KCmdDestroy )
146 else if ( aCommand == KCmdDisplayName )
148 DoCmdDisplayName( aSection );
150 else if ( aCommand == KCmdDataType )
152 DoCmdDataType( aSection );
154 else if ( aCommand == KCmdOpaqueData )
156 DoCmdOpaqueData( aSection );
158 else if ( aCommand == KCmdImplementationUid )
160 DoCmdImplementationUid( aSection );
162 else if ( aCommand == KCmdVersion )
164 DoCmdVersion( aSection );
166 else if ( aCommand == KCmdDisabled )
168 DoCmdDisabled( aSection );
170 else if ( aCommand == KCmdSetDisabled )
172 DoCmdSetDisabled( aSection );
174 else if ( aCommand == KCmdDrive )
176 DoCmdDrive( aSection );
178 else if ( aCommand == KCmdRomOnly )
180 DoCmdRomOnly( aSection );
182 else if ( aCommand == KCmdRomBased )
184 DoCmdRomBased( aSection );
194 void CT_ImplementationInformationData::DoCmdDisplayName(const TDesC& aSection)
196 TBuf<KMaxTestExecuteCommandLength> actualValue;
197 actualValue.Copy(iImplementationInformation->DisplayName());
198 TInt pos=actualValue.Find(_L("|"));
201 actualValue.Copy(actualValue.Left(pos));
203 INFO_PRINTF2(_L("DisplayName %S"), &actualValue);
206 if (GetExpectedString(aSection, expectedValue))
208 if (actualValue!=expectedValue)
210 ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
211 SetBlockResult(EFail);
216 void CT_ImplementationInformationData::DoCmdDataType(const TDesC& aSection)
218 TBuf<KMaxTestExecuteCommandLength> actualValue;
219 actualValue.Copy(iImplementationInformation->DataType());
220 TInt pos=actualValue.Find(_L("|"));
223 actualValue.Copy(actualValue.Left(pos));
225 INFO_PRINTF2(_L("DataType %S"), &actualValue);
228 if (GetExpectedString(aSection, expectedValue))
230 if (actualValue!=expectedValue)
232 ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
233 SetBlockResult(EFail);
238 void CT_ImplementationInformationData::DoCmdOpaqueData(const TDesC& aSection)
240 TBuf<KMaxTestExecuteCommandLength> actualValue;
241 actualValue.Copy(iImplementationInformation->OpaqueData());
242 TInt pos=actualValue.Find(_L("|"));
245 actualValue.Copy(actualValue.Left(pos));
247 INFO_PRINTF2(_L("OpaqueData %S"), &actualValue);
250 if (GetExpectedString(aSection, expectedValue))
252 if (actualValue!=expectedValue)
254 ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
255 SetBlockResult(EFail);
260 void CT_ImplementationInformationData::DoCmdImplementationUid(const TDesC& aSection)
262 TInt actualValue=iImplementationInformation->ImplementationUid().iUid;
263 INFO_PRINTF2(_L("ImplementationUid %d"), actualValue);
266 if (GetExpectedHexResult(aSection, expectedValue))
268 if (actualValue!=expectedValue)
270 ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
271 SetBlockResult(EFail);
276 void CT_ImplementationInformationData::DoCmdVersion(const TDesC& aSection)
278 TInt actualValue=iImplementationInformation->Version();
279 INFO_PRINTF2(_L("Version %d"), actualValue);
282 if (GetExpectedResult(aSection, expectedValue))
284 if (actualValue!=expectedValue)
286 ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
287 SetBlockResult(EFail);
292 void CT_ImplementationInformationData::DoCmdDisabled(const TDesC& aSection)
294 TBool actualValue=iImplementationInformation->Disabled();
295 INFO_PRINTF2(_L("Disabled %d"), actualValue);
298 if (GetExpectedBool(aSection, expectedValue))
300 if (actualValue!=expectedValue)
302 ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
303 SetBlockResult(EFail);
308 void CT_ImplementationInformationData::DoCmdSetDisabled(const TDesC& aSection)
310 INFO_PRINTF1(_L("SetDisabled"));
313 if (!GetDisabled(aSection, disabled))
315 ERR_PRINTF1(_L("Not enought arguments"));
316 SetBlockResult( EFail );
320 iImplementationInformation->SetDisabled(disabled);
324 void CT_ImplementationInformationData::DoCmdDrive(const TDesC& aSection)
326 TDriveName actualValue(iImplementationInformation->Drive().Name());
327 INFO_PRINTF2(_L("Drive Name %s"), &actualValue);
330 if (GetExpectedString(aSection, expectedValue))
332 if (actualValue!=expectedValue)
334 ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
335 SetBlockResult(EFail);
340 void CT_ImplementationInformationData::DoCmdRomOnly(const TDesC& aSection)
342 TBool actualValue=iImplementationInformation->RomOnly();
343 INFO_PRINTF2(_L("RomOnly %d"), actualValue);
346 if (GetExpectedBool(aSection, expectedValue))
348 if (actualValue!=expectedValue)
350 ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
351 SetBlockResult(EFail);
356 void CT_ImplementationInformationData::DoCmdRomBased(const TDesC& aSection)
358 TBool actualValue=iImplementationInformation->RomBased();
359 INFO_PRINTF2(_L("RomBased %d"), actualValue);
362 if (GetExpectedBool(aSection, expectedValue))
364 if (actualValue!=expectedValue)
366 ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
367 SetBlockResult(EFail);
372 void CT_ImplementationInformationData::DoCmdDestroy()
374 INFO_PRINTF1( _L( "Destroyed" ) );