author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 2 |
// All rights reserved. |
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// @internalComponent |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
||
19 |
#include <e32std.h> |
|
20 |
#include <e32std_private.h> |
|
21 |
#include <u32std.h> // unicode builds |
|
22 |
#include <e32base.h> |
|
23 |
#include <e32base_private.h> |
|
24 |
#include <e32Test.h> // RTest headder |
|
25 |
#include "testcaseroot.h" |
|
26 |
#include "testcase0463.h" |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
27 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
28 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
29 |
#include "testcase0463Traces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
30 |
#endif |
0 | 31 |
|
32 |
||
33 |
||
34 |
||
35 |
// the name below is used to add a pointer to our construction method to a pointer MAP in |
|
36 |
// the class factory |
|
37 |
_LIT(KTestCaseId,"PBASE-USB_OTGDI-0463"); |
|
38 |
const TTestCaseFactoryReceipt<CTestCase0463> CTestCase0463::iFactoryReceipt(KTestCaseId); |
|
39 |
||
40 |
||
41 |
CTestCase0463* CTestCase0463::NewL(TBool aHost) |
|
42 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
43 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
44 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
45 |
OstTraceFunctionEntry0(CTESTCASE0463_NEWL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
46 |
} |
0 | 47 |
CTestCase0463* self = new (ELeave) CTestCase0463(aHost); |
48 |
CleanupStack::PushL(self); |
|
49 |
self->ConstructL(); |
|
50 |
CleanupStack::Pop(self); |
|
51 |
return self; |
|
52 |
} |
|
53 |
||
54 |
||
55 |
CTestCase0463::CTestCase0463(TBool aHost) |
|
56 |
: CTestCaseRoot(KTestCaseId, aHost) |
|
57 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
58 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
59 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
60 |
OstTraceFunctionEntry0(CTESTCASE0463_CTESTCASE0463); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
61 |
} |
0 | 62 |
} |
63 |
||
64 |
||
65 |
/** |
|
66 |
ConstructL |
|
67 |
*/ |
|
68 |
void CTestCase0463::ConstructL() |
|
69 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
70 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
71 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
OstTraceFunctionEntry0(CTESTCASE0463_CONSTRUCTL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
73 |
} |
0 | 74 |
iRepeats = OOMOPEN_REPEATS; |
75 |
iAllocFailNumber = OOMOPEN_REPEATS + 1; // allocs 1..11 fail |
|
76 |
||
77 |
BaseConstructL(); |
|
78 |
} |
|
79 |
||
80 |
||
81 |
CTestCase0463::~CTestCase0463() |
|
82 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
83 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
84 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
85 |
OstTraceFunctionEntry0(CTESTCASE0463_DCTESTCASE0463); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
86 |
} |
0 | 87 |
|
88 |
Cancel(); |
|
89 |
} |
|
90 |
||
91 |
||
92 |
void CTestCase0463::ExecuteTestCaseL() |
|
93 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
94 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
95 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
96 |
OstTraceFunctionEntry0(CTESTCASE0463_EXECUTETESTCASEL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
97 |
} |
0 | 98 |
iCaseStep = EMarkStack; |
99 |
CActiveScheduler::Add(this); |
|
100 |
||
101 |
SelfComplete(); |
|
102 |
||
103 |
} |
|
104 |
||
105 |
void CTestCase0463::DescribePreconditions() |
|
106 |
{ |
|
107 |
test.Printf(_L("Insert A connector beforehand.\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
108 |
OstTrace0(TRACE_NORMAL, CTESTCASE0463_DESCRIBEPRECONDITIONS, "Insert A connector beforehand.\n"); |
0 | 109 |
} |
110 |
||
111 |
||
112 |
void CTestCase0463::DoCancel() |
|
113 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
114 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
115 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
116 |
OstTraceFunctionEntry0(CTESTCASE0463_DOCANCEL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
117 |
} |
0 | 118 |
|
119 |
// cancel our timer |
|
120 |
iTimer.Cancel(); |
|
121 |
} |
|
122 |
||
123 |
||
124 |
// handle event completion |
|
125 |
void CTestCase0463::RunStepL() |
|
126 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
127 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
128 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
129 |
OstTraceFunctionEntry0(CTESTCASE0463_RUNSTEPL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
130 |
} |
0 | 131 |
|
132 |
// Obtain the completion code for this CActive obj. |
|
133 |
TInt completionCode(iStatus.Int()); |
|
134 |
||
135 |
switch(iCaseStep) |
|
136 |
{ |
|
137 |
case EMarkStack: |
|
138 |
SelfComplete(); |
|
139 |
iCaseStep = ELoadLdd; |
|
140 |
break; |
|
141 |
||
142 |
case ELoadLdd: |
|
143 |
__UHEAP_SETFAIL(RHeap::EDeterministic, iAllocFailNumber); |
|
144 |
__UHEAP_MARK; |
|
145 |
test.Printf(_L("Load the LDD iteration %d/%d\n"), OOMOPEN_REPEATS-iRepeats+1, OOMOPEN_REPEATS); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
146 |
OstTraceExt2(TRACE_NORMAL, CTESTCASE0463_RUNSTEPL_DUP01, "Load the LDD iteration %d/%d\n", OOMOPEN_REPEATS-iRepeats+1, OOMOPEN_REPEATS); |
0 | 147 |
aIntegerP = new TInt; |
148 |
CleanupStack::PushL(aIntegerP); |
|
149 |
if (!StepLoadLDD()) |
|
150 |
{ |
|
151 |
break; |
|
152 |
} |
|
153 |
// panic if the cleanupstack was messed |
|
154 |
CleanupStack::PopAndDestroy(aIntegerP); |
|
155 |
||
156 |
// SAMPLE : some code to test that the __HEAP macros did their stuff |
|
157 |
// uncomment this to verify the test flow would fail |
|
158 |
// { |
|
159 |
// TInt *aInt = new TInt; |
|
160 |
// if (NULL ==aInt) |
|
161 |
// test.Printf(_L("Alloc failed!!!!!!\n")); |
|
162 |
// delete aInt; |
|
163 |
// } |
|
164 |
iCaseStep = EUnloadLdd; |
|
165 |
SelfComplete(); |
|
166 |
break; |
|
167 |
||
168 |
case EUnloadLdd: |
|
169 |
if (EFalse == StepUnloadLDD()) |
|
170 |
return TestFailed(KErrAbort,_L("Unload Ldd failure")); |
|
171 |
__UHEAP_MARKEND; |
|
172 |
test.Printf(_L("Heap intact: Asize %d\n"), iAllocFailNumber); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
173 |
OstTrace1(TRACE_NORMAL, CTESTCASE0463_RUNSTEPL_DUP03, "Heap intact: Asize %d\n", iAllocFailNumber); |
0 | 174 |
iCaseStep = ELoopDecrement; |
175 |
SelfComplete(); |
|
176 |
break; |
|
177 |
||
178 |
case ELoopDecrement: |
|
179 |
test.Printf(_L("Repeat test\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
180 |
OstTrace0(TRACE_NORMAL, CTESTCASE0463_RUNSTEPL_DUP04, "Repeat test\n"); |
0 | 181 |
__UHEAP_RESET; |
182 |
iAllocFailNumber--; |
|
183 |
||
184 |
if (iRepeats--) |
|
185 |
iCaseStep = ELoadLdd; |
|
186 |
else |
|
187 |
iCaseStep = ELastStep; |
|
188 |
SelfComplete(); |
|
189 |
break; |
|
190 |
||
191 |
case ELastStep: |
|
192 |
||
193 |
TestPolicy().SignalTestComplete(KErrNone); |
|
194 |
break; |
|
195 |
||
196 |
default: |
|
197 |
test.Printf(_L("<Error> unknown test step")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
198 |
OstTrace0(TRACE_NORMAL, CTESTCASE0463_RUNSTEPL_DUP05, "<Error> unknown test step"); |
0 | 199 |
Cancel(); |
200 |
TestPolicy().SignalTestComplete(KErrCorrupt); |
|
201 |
break; |
|
202 |
} |
|
203 |
} |
|
204 |
||
205 |