sl@0: /* sl@0: * Copyright (c) 2002-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 the License "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: #include "tconstructionvector.h" sl@0: #include "t_input.h" sl@0: #include sl@0: sl@0: class RIntegerTest : public RInteger sl@0: { sl@0: public: sl@0: RIntegerTest(void) {} sl@0: RIntegerTest(const RInteger& aInteger) {iSize = *((TUint*)&aInteger); iPtr = *(((TUint*)(&aInteger)+1)); } sl@0: TUint* Ptr(void) {return RInteger::Ptr();} sl@0: }; sl@0: sl@0: CTestAction* CConstructionVector::NewL(RFs& aFs, CConsoleBase& aConsole, sl@0: Output& aOut, const TTestActionSpec& aTestActionSpec) sl@0: { sl@0: CTestAction* self = CConstructionVector::NewLC(aFs, aConsole, sl@0: aOut, aTestActionSpec); sl@0: CleanupStack::Pop(); sl@0: return self; sl@0: } sl@0: sl@0: CTestAction* CConstructionVector::NewLC(RFs& aFs, CConsoleBase& aConsole, sl@0: Output& aOut, const TTestActionSpec& aTestActionSpec) sl@0: { sl@0: CConstructionVector* self = new(ELeave) CConstructionVector(aFs, aConsole, aOut); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aTestActionSpec); sl@0: return self; sl@0: } sl@0: sl@0: CConstructionVector::~CConstructionVector() sl@0: { sl@0: delete iBody; sl@0: delete iString; sl@0: delete iMemoryLayout; sl@0: } sl@0: sl@0: CConstructionVector::CConstructionVector(RFs& aFs, CConsoleBase& aConsole, Output& aOut) sl@0: : CTestAction(aConsole, aOut), iFs(aFs) sl@0: { sl@0: } sl@0: sl@0: void CConstructionVector::ConstructL(const TTestActionSpec& aTestActionSpec) sl@0: { sl@0: CTestAction::ConstructL(aTestActionSpec); sl@0: iBody = HBufC8::NewL(aTestActionSpec.iActionBody.Length()); sl@0: iBody->Des().Copy(aTestActionSpec.iActionBody); sl@0: sl@0: iString = Input::ParseElementHexL(*iBody, _L8("")); sl@0: iMemoryLayout = Input::ParseElementHexL(*iBody, _L8("")); sl@0: } sl@0: sl@0: void CConstructionVector::DoPerformPrerequisite(TRequestStatus& aStatus) sl@0: { sl@0: TRequestStatus* status = &aStatus; sl@0: User::RequestComplete(status, KErrNone); sl@0: iActionState = CTestAction::EAction; sl@0: } sl@0: sl@0: void CConstructionVector::DoPerformPostrequisite(TRequestStatus& aStatus) sl@0: { sl@0: TRequestStatus* status = &aStatus; sl@0: iFinished = ETrue; sl@0: User::RequestComplete(status, KErrNone); sl@0: } sl@0: sl@0: void CConstructionVector::DoReportAction(void) sl@0: { sl@0: } sl@0: sl@0: void CConstructionVector::DoCheckResult(TInt) sl@0: { sl@0: } sl@0: sl@0: void CConstructionVector::PerformAction(TRequestStatus& aStatus) sl@0: { sl@0: __UHEAP_MARK; sl@0: TRequestStatus* status = &aStatus; sl@0: iResult = ETrue; sl@0: sl@0: //This is just a derived class to get around the fact that iReg is sl@0: //protected in RInteger. See top of file for definition sl@0: RIntegerTest a; sl@0: //a = (RIntegerTest)(RInteger::NewL(*iString)); sl@0: a = static_cast(RIntegerTest::NewL(*iString)); sl@0: CleanupStack::PushL(a); sl@0: sl@0: //This test ensures that the internal memory layout of a number is correct sl@0: TUint compare = Mem::Compare((TUint8*)(a.Ptr()), a.ByteCount(), sl@0: iMemoryLayout->Ptr(), iMemoryLayout->Size()); sl@0: if( compare != 0 ) sl@0: { sl@0: iResult = EFalse; sl@0: } sl@0: sl@0: HBufC8* out = a.BufferLC(); sl@0: if( *out != *iString ) sl@0: { sl@0: iResult = EFalse; sl@0: } sl@0: CleanupStack::PopAndDestroy(out); sl@0: CleanupStack::PopAndDestroy(&a); sl@0: sl@0: User::RequestComplete(status, KErrNone); sl@0: iActionState = CTestAction::EPostrequisite; sl@0: __UHEAP_MARKEND; sl@0: } sl@0: