|
1 /* |
|
2 * Copyright (c) 2002-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 the License "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 #include "tconstructionvector.h" |
|
20 #include "t_input.h" |
|
21 #include <bigint.h> |
|
22 |
|
23 class RIntegerTest : public RInteger |
|
24 { |
|
25 public: |
|
26 RIntegerTest(void) {} |
|
27 RIntegerTest(const RInteger& aInteger) {iSize = *((TUint*)&aInteger); iPtr = *(((TUint*)(&aInteger)+1)); } |
|
28 TUint* Ptr(void) {return RInteger::Ptr();} |
|
29 }; |
|
30 |
|
31 CTestAction* CConstructionVector::NewL(RFs& aFs, CConsoleBase& aConsole, |
|
32 Output& aOut, const TTestActionSpec& aTestActionSpec) |
|
33 { |
|
34 CTestAction* self = CConstructionVector::NewLC(aFs, aConsole, |
|
35 aOut, aTestActionSpec); |
|
36 CleanupStack::Pop(); |
|
37 return self; |
|
38 } |
|
39 |
|
40 CTestAction* CConstructionVector::NewLC(RFs& aFs, CConsoleBase& aConsole, |
|
41 Output& aOut, const TTestActionSpec& aTestActionSpec) |
|
42 { |
|
43 CConstructionVector* self = new(ELeave) CConstructionVector(aFs, aConsole, aOut); |
|
44 CleanupStack::PushL(self); |
|
45 self->ConstructL(aTestActionSpec); |
|
46 return self; |
|
47 } |
|
48 |
|
49 CConstructionVector::~CConstructionVector() |
|
50 { |
|
51 delete iBody; |
|
52 delete iString; |
|
53 delete iMemoryLayout; |
|
54 } |
|
55 |
|
56 CConstructionVector::CConstructionVector(RFs& aFs, CConsoleBase& aConsole, Output& aOut) |
|
57 : CTestAction(aConsole, aOut), iFs(aFs) |
|
58 { |
|
59 } |
|
60 |
|
61 void CConstructionVector::ConstructL(const TTestActionSpec& aTestActionSpec) |
|
62 { |
|
63 CTestAction::ConstructL(aTestActionSpec); |
|
64 iBody = HBufC8::NewL(aTestActionSpec.iActionBody.Length()); |
|
65 iBody->Des().Copy(aTestActionSpec.iActionBody); |
|
66 |
|
67 iString = Input::ParseElementHexL(*iBody, _L8("<input>")); |
|
68 iMemoryLayout = Input::ParseElementHexL(*iBody, _L8("<memorylayout>")); |
|
69 } |
|
70 |
|
71 void CConstructionVector::DoPerformPrerequisite(TRequestStatus& aStatus) |
|
72 { |
|
73 TRequestStatus* status = &aStatus; |
|
74 User::RequestComplete(status, KErrNone); |
|
75 iActionState = CTestAction::EAction; |
|
76 } |
|
77 |
|
78 void CConstructionVector::DoPerformPostrequisite(TRequestStatus& aStatus) |
|
79 { |
|
80 TRequestStatus* status = &aStatus; |
|
81 iFinished = ETrue; |
|
82 User::RequestComplete(status, KErrNone); |
|
83 } |
|
84 |
|
85 void CConstructionVector::DoReportAction(void) |
|
86 { |
|
87 } |
|
88 |
|
89 void CConstructionVector::DoCheckResult(TInt) |
|
90 { |
|
91 } |
|
92 |
|
93 void CConstructionVector::PerformAction(TRequestStatus& aStatus) |
|
94 { |
|
95 __UHEAP_MARK; |
|
96 TRequestStatus* status = &aStatus; |
|
97 iResult = ETrue; |
|
98 |
|
99 //This is just a derived class to get around the fact that iReg is |
|
100 //protected in RInteger. See top of file for definition |
|
101 RIntegerTest a; |
|
102 //a = (RIntegerTest)(RInteger::NewL(*iString)); |
|
103 a = static_cast<RIntegerTest>(RIntegerTest::NewL(*iString)); |
|
104 CleanupStack::PushL(a); |
|
105 |
|
106 //This test ensures that the internal memory layout of a number is correct |
|
107 TUint compare = Mem::Compare((TUint8*)(a.Ptr()), a.ByteCount(), |
|
108 iMemoryLayout->Ptr(), iMemoryLayout->Size()); |
|
109 if( compare != 0 ) |
|
110 { |
|
111 iResult = EFalse; |
|
112 } |
|
113 |
|
114 HBufC8* out = a.BufferLC(); |
|
115 if( *out != *iString ) |
|
116 { |
|
117 iResult = EFalse; |
|
118 } |
|
119 CleanupStack::PopAndDestroy(out); |
|
120 CleanupStack::PopAndDestroy(&a); |
|
121 |
|
122 User::RequestComplete(status, KErrNone); |
|
123 iActionState = CTestAction::EPostrequisite; |
|
124 __UHEAP_MARKEND; |
|
125 } |
|
126 |