sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* tconstruction.cpp
|
sl@0
|
16 |
*
|
sl@0
|
17 |
*/
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
#include "tconstructionfb.h"
|
sl@0
|
21 |
#include "t_input.h"
|
sl@0
|
22 |
#include <bigint.h>
|
sl@0
|
23 |
#include <random.h>
|
sl@0
|
24 |
|
sl@0
|
25 |
CTestAction* CConstructionFB::NewL(RFs& aFs, CConsoleBase& aConsole,
|
sl@0
|
26 |
Output& aOut, const TTestActionSpec& aTestActionSpec)
|
sl@0
|
27 |
{
|
sl@0
|
28 |
CTestAction* self = CConstructionFB::NewLC(aFs, aConsole,
|
sl@0
|
29 |
aOut, aTestActionSpec);
|
sl@0
|
30 |
CleanupStack::Pop();
|
sl@0
|
31 |
return self;
|
sl@0
|
32 |
}
|
sl@0
|
33 |
|
sl@0
|
34 |
CTestAction* CConstructionFB::NewLC(RFs& aFs, CConsoleBase& aConsole,
|
sl@0
|
35 |
Output& aOut, const TTestActionSpec& aTestActionSpec)
|
sl@0
|
36 |
{
|
sl@0
|
37 |
CConstructionFB* self = new(ELeave) CConstructionFB(aFs, aConsole, aOut);
|
sl@0
|
38 |
CleanupStack::PushL(self);
|
sl@0
|
39 |
self->ConstructL(aTestActionSpec);
|
sl@0
|
40 |
return self;
|
sl@0
|
41 |
}
|
sl@0
|
42 |
|
sl@0
|
43 |
CConstructionFB::~CConstructionFB()
|
sl@0
|
44 |
{
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
CConstructionFB::CConstructionFB(RFs& aFs, CConsoleBase& aConsole, Output& aOut)
|
sl@0
|
48 |
: CTestAction(aConsole, aOut), iFs(aFs)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
}
|
sl@0
|
51 |
|
sl@0
|
52 |
void CConstructionFB::ConstructL(const TTestActionSpec& aTestActionSpec)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
CTestAction::ConstructL(aTestActionSpec);
|
sl@0
|
55 |
}
|
sl@0
|
56 |
|
sl@0
|
57 |
void CConstructionFB::DoPerformPrerequisite(TRequestStatus& aStatus)
|
sl@0
|
58 |
{
|
sl@0
|
59 |
TRequestStatus* status = &aStatus;
|
sl@0
|
60 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
61 |
iActionState = CTestAction::EAction;
|
sl@0
|
62 |
}
|
sl@0
|
63 |
|
sl@0
|
64 |
void CConstructionFB::DoPerformPostrequisite(TRequestStatus& aStatus)
|
sl@0
|
65 |
{
|
sl@0
|
66 |
TRequestStatus* status = &aStatus;
|
sl@0
|
67 |
iFinished = ETrue;
|
sl@0
|
68 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
69 |
}
|
sl@0
|
70 |
|
sl@0
|
71 |
void CConstructionFB::DoReportAction(void)
|
sl@0
|
72 |
{
|
sl@0
|
73 |
}
|
sl@0
|
74 |
|
sl@0
|
75 |
void CConstructionFB::DoCheckResult(TInt)
|
sl@0
|
76 |
{
|
sl@0
|
77 |
}
|
sl@0
|
78 |
|
sl@0
|
79 |
void CConstructionFB::PerformAction(TRequestStatus& aStatus)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
__UHEAP_MARK;
|
sl@0
|
82 |
TRequestStatus* status = &aStatus;
|
sl@0
|
83 |
iResult = ETrue;
|
sl@0
|
84 |
|
sl@0
|
85 |
//Generate 100 i*5 byte random sequences
|
sl@0
|
86 |
//This tests:
|
sl@0
|
87 |
// - NewLC(const TDesC8&)
|
sl@0
|
88 |
// - NewLC(const RInteger&)
|
sl@0
|
89 |
// - BufferLC()
|
sl@0
|
90 |
// By comparing the output of BufferLC we can have (some) assurance
|
sl@0
|
91 |
// that the internal integer code is intrepreting strings in the correct
|
sl@0
|
92 |
// order and endianess
|
sl@0
|
93 |
for(TUint i=0; i<100; i++)
|
sl@0
|
94 |
{
|
sl@0
|
95 |
HBufC8* buf = HBufC8::NewMaxLC(i*5);
|
sl@0
|
96 |
TPtr8 ptr = buf->Des();
|
sl@0
|
97 |
TRandom::RandomL(ptr);
|
sl@0
|
98 |
|
sl@0
|
99 |
RInteger a = RInteger::NewL(ptr);
|
sl@0
|
100 |
CleanupStack::PushL(a);
|
sl@0
|
101 |
HBufC8* out = a.BufferLC();
|
sl@0
|
102 |
if( *out != *buf )
|
sl@0
|
103 |
{
|
sl@0
|
104 |
iResult = EFalse;
|
sl@0
|
105 |
}
|
sl@0
|
106 |
CleanupStack::PopAndDestroy(out);
|
sl@0
|
107 |
|
sl@0
|
108 |
RInteger b = RInteger::NewL(a);
|
sl@0
|
109 |
CleanupStack::PushL(b);
|
sl@0
|
110 |
if( a != b )
|
sl@0
|
111 |
{
|
sl@0
|
112 |
iResult = EFalse;
|
sl@0
|
113 |
}
|
sl@0
|
114 |
out = b.BufferLC();
|
sl@0
|
115 |
if( *out != *buf )
|
sl@0
|
116 |
{
|
sl@0
|
117 |
iResult = EFalse;
|
sl@0
|
118 |
}
|
sl@0
|
119 |
CleanupStack::PopAndDestroy(out);
|
sl@0
|
120 |
CleanupStack::PopAndDestroy(); //b
|
sl@0
|
121 |
CleanupStack::PopAndDestroy();//a
|
sl@0
|
122 |
CleanupStack::PopAndDestroy(buf);
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
126 |
iActionState = CTestAction::EPostrequisite;
|
sl@0
|
127 |
__UHEAP_MARKEND;
|
sl@0
|
128 |
}
|
sl@0
|
129 |
|