sl@0: /* sl@0: * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include "T_ImplementationInformationData.h" sl@0: sl@0: /*@{*/ sl@0: /// Parameters sl@0: _LIT( KUid, "uid" ); sl@0: _LIT( KExpectedString, "expected_string" ); sl@0: _LIT( KExpectedResult, "expected" ); sl@0: _LIT( KExpectedBool, "expected_bool" ); sl@0: _LIT( KDisabled, "disabled" ); sl@0: _LIT( KElement, "element" ); sl@0: sl@0: /// CImplementationInformation sl@0: _LIT( KCmdDisplayName, "DisplayName" ); sl@0: _LIT( KCmdDataType, "DataType" ); sl@0: _LIT( KCmdOpaqueData, "OpaqueData" ); sl@0: _LIT( KCmdImplementationUid, "ImplementationUid" ); sl@0: _LIT( KCmdVersion, "Version" ); sl@0: _LIT( KCmdDisabled, "Disabled" ); sl@0: _LIT( KCmdSetDisabled, "SetDisabled" ); sl@0: _LIT( KCmdDrive, "Drive" ); sl@0: _LIT( KCmdRomOnly, "RomOnly" ); sl@0: _LIT( KCmdRomBased, "RomBased" ); sl@0: _LIT( KCmdDestroy, "~" ); sl@0: sl@0: _LIT( KEmptyString, ""); sl@0: /*@}*/ sl@0: sl@0: ////////////////////////////////////////////////////////////////////// sl@0: // Construction/Destruction sl@0: ////////////////////////////////////////////////////////////////////// sl@0: sl@0: CT_ImplementationInformationData* CT_ImplementationInformationData::NewL( ) sl@0: { sl@0: CT_ImplementationInformationData* ret = new ( ELeave ) CT_ImplementationInformationData( ); sl@0: CleanupStack::PushL( ret ); sl@0: ret->ConstructL(); sl@0: CleanupStack::Pop( ret ); sl@0: return ret; sl@0: } sl@0: sl@0: CT_ImplementationInformationData::CT_ImplementationInformationData( ) sl@0: : iImplementationInformation(NULL) sl@0: { sl@0: } sl@0: sl@0: void CT_ImplementationInformationData::ConstructL() sl@0: { sl@0: } sl@0: sl@0: CT_ImplementationInformationData::~CT_ImplementationInformationData() sl@0: { sl@0: DestroyData(); sl@0: } sl@0: sl@0: void CT_ImplementationInformationData::DestroyData() sl@0: { sl@0: // this does not own iImplementationInformation sl@0: iImplementationInformation=NULL; sl@0: } sl@0: sl@0: ////////////////////////////////////////////////////////////////////// sl@0: // Read data from INI file sl@0: ////////////////////////////////////////////////////////////////////// sl@0: sl@0: TBool CT_ImplementationInformationData::GetUid( const TDesC& aSection, TUid& aUid ) sl@0: { sl@0: TInt uidValue=0; sl@0: TBool ret=GetHexFromConfig( aSection, KUid(), uidValue ) ; sl@0: aUid = TUid::Uid( uidValue ); sl@0: return ret; sl@0: } sl@0: sl@0: TBool CT_ImplementationInformationData::GetExpectedString( const TDesC& aSection, TPtrC& aExpectedString) sl@0: { sl@0: aExpectedString.Set(KEmptyString); sl@0: return GetStringFromConfig( aSection, KExpectedString(), aExpectedString); sl@0: } sl@0: sl@0: TBool CT_ImplementationInformationData::GetExpectedResult( const TDesC& aSection, TInt& aExpectedResult ) sl@0: { sl@0: aExpectedResult = 0; sl@0: return GetIntFromConfig( aSection, KExpectedResult(), aExpectedResult ); sl@0: } sl@0: sl@0: TBool CT_ImplementationInformationData::GetExpectedHexResult( const TDesC& aSection, TInt& aExpectedResult) sl@0: { sl@0: aExpectedResult = 0; sl@0: return GetHexFromConfig( aSection, KExpectedResult(), aExpectedResult ); sl@0: } sl@0: sl@0: TBool CT_ImplementationInformationData::GetArrayElement(const TDesC& aSection, TInt& aArrayElement) sl@0: { sl@0: aArrayElement = 0; sl@0: return GetIntFromConfig( aSection, KElement(), aArrayElement); sl@0: } sl@0: sl@0: TBool CT_ImplementationInformationData::GetExpectedBool( const TDesC& aSection, TBool& aBool ) sl@0: { sl@0: aBool = EFalse; sl@0: return GetBoolFromConfig( aSection, KExpectedBool(), aBool ); sl@0: } sl@0: sl@0: TBool CT_ImplementationInformationData::GetDisabled( const TDesC& aSection, TBool& aDisabled ) sl@0: { sl@0: aDisabled = EFalse; sl@0: return GetBoolFromConfig( aSection, KDisabled(), aDisabled ); sl@0: } sl@0: sl@0: /** sl@0: Test script command entry point sl@0: @internalComponent sl@0: sl@0: @return Explanation of the object returned sl@0: @param aCommand descriptor containing the command value sl@0: @param aSection descriptor containing the command parameter sl@0: @pre N/A sl@0: @post N/A sl@0: */ sl@0: TBool CT_ImplementationInformationData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) sl@0: { sl@0: TBool retVal = ETrue; sl@0: sl@0: if ( aCommand == KCmdDestroy ) sl@0: { sl@0: DoCmdDestroy(); sl@0: } sl@0: else if ( aCommand == KCmdDisplayName ) sl@0: { sl@0: DoCmdDisplayName( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdDataType ) sl@0: { sl@0: DoCmdDataType( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdOpaqueData ) sl@0: { sl@0: DoCmdOpaqueData( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdImplementationUid ) sl@0: { sl@0: DoCmdImplementationUid( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdVersion ) sl@0: { sl@0: DoCmdVersion( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdDisabled ) sl@0: { sl@0: DoCmdDisabled( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdSetDisabled ) sl@0: { sl@0: DoCmdSetDisabled( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdDrive ) sl@0: { sl@0: DoCmdDrive( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdRomOnly ) sl@0: { sl@0: DoCmdRomOnly( aSection ); sl@0: } sl@0: else if ( aCommand == KCmdRomBased ) sl@0: { sl@0: DoCmdRomBased( aSection ); sl@0: } sl@0: else sl@0: { sl@0: retVal = EFalse; sl@0: } sl@0: sl@0: return retVal; sl@0: } sl@0: sl@0: void CT_ImplementationInformationData::DoCmdDisplayName(const TDesC& aSection) sl@0: { sl@0: TBuf actualValue; sl@0: actualValue.Copy(iImplementationInformation->DisplayName()); sl@0: TInt pos=actualValue.Find(_L("|")); sl@0: if (pos>0) sl@0: { sl@0: actualValue.Copy(actualValue.Left(pos)); sl@0: }; sl@0: INFO_PRINTF2(_L("DisplayName %S"), &actualValue); sl@0: sl@0: TPtrC expectedValue; sl@0: if (GetExpectedString(aSection, expectedValue)) sl@0: { sl@0: if (actualValue!=expectedValue) sl@0: { sl@0: ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ImplementationInformationData::DoCmdDataType(const TDesC& aSection) sl@0: { sl@0: TBuf actualValue; sl@0: actualValue.Copy(iImplementationInformation->DataType()); sl@0: TInt pos=actualValue.Find(_L("|")); sl@0: if (pos>0) sl@0: { sl@0: actualValue.Copy(actualValue.Left(pos)); sl@0: }; sl@0: INFO_PRINTF2(_L("DataType %S"), &actualValue); sl@0: sl@0: TPtrC expectedValue; sl@0: if (GetExpectedString(aSection, expectedValue)) sl@0: { sl@0: if (actualValue!=expectedValue) sl@0: { sl@0: ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ImplementationInformationData::DoCmdOpaqueData(const TDesC& aSection) sl@0: { sl@0: TBuf actualValue; sl@0: actualValue.Copy(iImplementationInformation->OpaqueData()); sl@0: TInt pos=actualValue.Find(_L("|")); sl@0: if (pos>0) sl@0: { sl@0: actualValue.Copy(actualValue.Left(pos)); sl@0: }; sl@0: INFO_PRINTF2(_L("OpaqueData %S"), &actualValue); sl@0: sl@0: TPtrC expectedValue; sl@0: if (GetExpectedString(aSection, expectedValue)) sl@0: { sl@0: if (actualValue!=expectedValue) sl@0: { sl@0: ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ImplementationInformationData::DoCmdImplementationUid(const TDesC& aSection) sl@0: { sl@0: TInt actualValue=iImplementationInformation->ImplementationUid().iUid; sl@0: INFO_PRINTF2(_L("ImplementationUid %d"), actualValue); sl@0: sl@0: TInt expectedValue; sl@0: if (GetExpectedHexResult(aSection, expectedValue)) sl@0: { sl@0: if (actualValue!=expectedValue) sl@0: { sl@0: ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ImplementationInformationData::DoCmdVersion(const TDesC& aSection) sl@0: { sl@0: TInt actualValue=iImplementationInformation->Version(); sl@0: INFO_PRINTF2(_L("Version %d"), actualValue); sl@0: sl@0: TInt expectedValue; sl@0: if (GetExpectedResult(aSection, expectedValue)) sl@0: { sl@0: if (actualValue!=expectedValue) sl@0: { sl@0: ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ImplementationInformationData::DoCmdDisabled(const TDesC& aSection) sl@0: { sl@0: TBool actualValue=iImplementationInformation->Disabled(); sl@0: INFO_PRINTF2(_L("Disabled %d"), actualValue); sl@0: sl@0: TBool expectedValue; sl@0: if (GetExpectedBool(aSection, expectedValue)) sl@0: { sl@0: if (actualValue!=expectedValue) sl@0: { sl@0: ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ImplementationInformationData::DoCmdSetDisabled(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("SetDisabled")); sl@0: sl@0: TBool disabled; sl@0: if (!GetDisabled(aSection, disabled)) sl@0: { sl@0: ERR_PRINTF1(_L("Not enought arguments")); sl@0: SetBlockResult( EFail ); sl@0: } sl@0: else sl@0: { sl@0: iImplementationInformation->SetDisabled(disabled); sl@0: } sl@0: } sl@0: sl@0: void CT_ImplementationInformationData::DoCmdDrive(const TDesC& aSection) sl@0: { sl@0: TDriveName actualValue(iImplementationInformation->Drive().Name()); sl@0: INFO_PRINTF2(_L("Drive Name %s"), &actualValue); sl@0: sl@0: TPtrC expectedValue; sl@0: if (GetExpectedString(aSection, expectedValue)) sl@0: { sl@0: if (actualValue!=expectedValue) sl@0: { sl@0: ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ImplementationInformationData::DoCmdRomOnly(const TDesC& aSection) sl@0: { sl@0: TBool actualValue=iImplementationInformation->RomOnly(); sl@0: INFO_PRINTF2(_L("RomOnly %d"), actualValue); sl@0: sl@0: TBool expectedValue; sl@0: if (GetExpectedBool(aSection, expectedValue)) sl@0: { sl@0: if (actualValue!=expectedValue) sl@0: { sl@0: ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ImplementationInformationData::DoCmdRomBased(const TDesC& aSection) sl@0: { sl@0: TBool actualValue=iImplementationInformation->RomBased(); sl@0: INFO_PRINTF2(_L("RomBased %d"), actualValue); sl@0: sl@0: TBool expectedValue; sl@0: if (GetExpectedBool(aSection, expectedValue)) sl@0: { sl@0: if (actualValue!=expectedValue) sl@0: { sl@0: ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_ImplementationInformationData::DoCmdDestroy() sl@0: { sl@0: INFO_PRINTF1( _L( "Destroyed" ) ); sl@0: DestroyData(); sl@0: }