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 |
// @file testcaseroot.cpp |
|
15 |
// @internalComponent |
|
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 <e32cons.h> |
|
25 |
#include <e32Test.h> // RTest header |
|
26 |
//#include <e32ver.h> |
|
27 |
#include <e32def.h> |
|
28 |
#include <e32def_private.h> |
|
29 |
#include <d32otgdi.h> // OTGDI header |
|
30 |
#include <d32usbc.h> // USBCC header |
|
31 |
#include "testcaseroot.h" |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
32 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
33 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
34 |
#include "testcaserootTraces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
35 |
#endif |
0 | 36 |
|
37 |
/* Implemention of classes CTestCaseRoot, CTestCaseB2BRoot |
|
38 |
* |
|
39 |
*/ |
|
40 |
||
41 |
/* =============================================================== |
|
42 |
* The root test-case class, provides test-framework features |
|
43 |
*/ |
|
44 |
CTestCaseRoot::CTestCaseRoot(const TDesC& aTestCaseId, TBool aAutomation) |
|
45 |
: CActive(EPriorityUserInput), |
|
46 |
COtgRoot(), |
|
47 |
iAutomated(aAutomation) |
|
48 |
{ |
|
49 |
iTestCaseId.Copy(aTestCaseId); |
|
50 |
} |
|
51 |
||
52 |
||
53 |
void CTestCaseRoot::BaseConstructL() |
|
54 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
55 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
56 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
57 |
OstTraceFunctionEntry0(CTESTCASEROOT_BASECONSTRUCTL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
58 |
} |
0 | 59 |
|
60 |
||
61 |
TInt err(iTimer.CreateLocal()); |
|
62 |
if (err == KErrNone) |
|
63 |
{ |
|
64 |
LOG_VERBOSE1(_L("Test case timer created")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
65 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
66 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
67 |
OstTrace0(TRACE_VERBOSE, CTESTCASEROOT_BASECONSTRUCTL_DUP01, "Test case timer created"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
68 |
} |
0 | 69 |
} |
70 |
else |
|
71 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
OstTrace1(TRACE_NORMAL, CTESTCASEROOT_BASECONSTRUCTL_DUP02, "<Error %d> Test case timer could not be created",err); |
0 | 73 |
User::Leave(err); |
74 |
} |
|
75 |
// |
|
76 |
iConsole = test.Console(); |
|
77 |
iRequestedChar = EFalse; |
|
78 |
} |
|
79 |
||
80 |
||
81 |
CTestCaseRoot::~CTestCaseRoot() |
|
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(CTESTCASEROOT_DCTESTCASEROOT); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
86 |
} |
0 | 87 |
Cancel(); |
88 |
} |
|
89 |
||
90 |
// utility GUI methods |
|
91 |
void CTestCaseRoot::DisplayTestCaseOptions() |
|
92 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
93 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
94 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
95 |
OstTraceFunctionEntry0(CTESTCASEROOT_DISPLAYTESTCASEOPTIONS); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
96 |
} |
0 | 97 |
|
98 |
// commonly overridden to display any options for that test |
|
99 |
test.Printf(_L("Press <ESC> to end the test.\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
100 |
OstTrace0(TRACE_NORMAL, CTESTCASEROOT_DISPLAYTESTCASEOPTIONS_DUP01, "Press <ESC> to end the test.\n"); |
0 | 101 |
} |
102 |
||
103 |
||
104 |
/***********************************************************************/ |
|
105 |
// |
|
106 |
void CTestCaseRoot::SetTestPolicy(CBasicTestPolicy* aTestPolicy) |
|
107 |
{ |
|
108 |
iTestPolicy = aTestPolicy; |
|
109 |
iAutomated = gSemiAutomated; // read the global flag at this time |
|
110 |
} |
|
111 |
||
112 |
||
113 |
CBasicTestPolicy& CTestCaseRoot::TestPolicy() |
|
114 |
{ |
|
115 |
return *iTestPolicy; |
|
116 |
} |
|
117 |
||
118 |
||
119 |
void CTestCaseRoot::DoCancel() |
|
120 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
121 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
122 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
123 |
OstTraceFunctionEntry0(CTESTCASEROOT_DOCANCEL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
124 |
} |
0 | 125 |
} |
126 |
||
127 |
||
128 |
/** ProcessKey |
|
129 |
override this method to perform other tasks, the base-class does nothing so that |
|
130 |
child classes can use it as an any-key-to-continue helper |
|
131 |
*/ |
|
132 |
void CTestCaseRoot::ProcessKey(TKeyCode &aKey) |
|
133 |
{// default implementation - reads the key. |
|
134 |
iKeyCodeInput = aKey; |
|
135 |
} |
|
136 |
||
137 |
||
138 |
void CTestCaseRoot::ProcessEngineKey(TKeyCode &aKey) |
|
139 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
140 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
141 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
142 |
OstTraceFunctionEntry0(CTESTCASEROOT_PROCESSENGINEKEY); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
143 |
} |
0 | 144 |
|
145 |
if (EKeyEscape == aKey) |
|
146 |
{ |
|
147 |
AssertionFailed( 1, _L("Test aborted by the user <ESC>\n")); |
|
148 |
CActiveScheduler::Stop(); |
|
149 |
} |
|
150 |
else |
|
151 |
{ |
|
152 |
||
153 |
// call virtual method here to invoke the test's overridden method |
|
154 |
ProcessKey(aKey); |
|
155 |
// note, we do not go ask for another, that is done by the console handler |
|
156 |
} |
|
157 |
} |
|
158 |
||
159 |
||
160 |
void CTestCaseRoot::RequestCharacter() |
|
161 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
162 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
163 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
164 |
OstTraceFunctionEntry0(CTESTCASEROOT_REQUESTCHARACTER); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
165 |
} |
0 | 166 |
// A request is issued to the CConsoleBase to accept a |
167 |
// character from the keyboard. |
|
168 |
||
169 |
__ASSERT_ALWAYS(!IsActive(), User::Panic(KMsgAlreadyActive, EPanicAlreadyActive)); |
|
170 |
||
171 |
iConsole->Read(iStatus); |
|
172 |
SetActive(); |
|
173 |
iRequestedChar = ETrue; |
|
174 |
} |
|
175 |
||
176 |
||
177 |
void CTestCaseRoot::RunL() |
|
178 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
179 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
180 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
181 |
OstTraceFunctionEntry0(CTESTCASEROOT_RUNL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
182 |
} |
0 | 183 |
TInt complCode(iStatus.Int()); |
184 |
if (iRequestedChar) |
|
185 |
{ |
|
186 |
||
187 |
TKeyCode k(iConsole->KeyCode()); |
|
188 |
||
189 |
// WARNING! |
|
190 |
// EMULATOR QUIRK! |
|
191 |
// When debugging if you have a breakpoint just before you read/process a key, |
|
192 |
// the EMULATOR will read the key sent to the IDE and you get a (F5) key that |
|
193 |
// you did not want from the IDE not the emulator. |
|
194 |
||
195 |
ProcessEngineKey(k); |
|
196 |
iRequestedChar = EFalse; |
|
197 |
||
198 |
// complete so that other tasks (there are none) can run |
|
199 |
// we will then be scheduled by the ActiveScheduler again to run the next test step. |
|
200 |
SelfComplete(); |
|
201 |
} |
|
202 |
else |
|
203 |
{ |
|
204 |
// run the next test step |
|
205 |
TInt currentStep(GetStepIndex()); |
|
206 |
PreRunStep(); |
|
207 |
LOG_VERBOSE2(_L("\n<< RunStepL() step=%d\n"), currentStep); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
208 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
209 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
210 |
OstTrace1(TRACE_VERBOSE, CTESTCASEROOT_RUNL_DUP01, "\n<< RunStepL() step=%d\n", currentStep); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
211 |
} |
0 | 212 |
RunStepL(); |
213 |
LOG_VERBOSE3(_L(">> RunStepL() step=%d->%d\n"), currentStep, GetStepIndex()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
214 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
215 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
216 |
OstTraceExt2(TRACE_VERBOSE, CTESTCASEROOT_RUNL_DUP02, ">> RunStepL() step=%d->%d\n", currentStep, GetStepIndex()); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
217 |
} |
0 | 218 |
PostRunStep(); |
219 |
} |
|
220 |
} |
|
221 |
||
222 |
||
223 |
void CTestCaseRoot::PostRunStep() |
|
224 |
{ |
|
225 |
// default impl. |
|
226 |
} |
|
227 |
||
228 |
void CTestCaseRoot::PreRunStep() |
|
229 |
{ |
|
230 |
// default impl. |
|
231 |
} |
|
232 |
||
233 |
TInt CTestCaseRoot::RunError(TInt aError) |
|
234 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
235 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
236 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
237 |
OstTraceFunctionEntry0(CTESTCASEROOT_RUNERROR); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
238 |
} |
0 | 239 |
test.Printf(_L("Test case C%lS::RunL left with %d"), &iTestCaseId, aError); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
240 |
OstTraceExt2(TRACE_NORMAL, CTESTCASEROOT_RUNERROR_DUP01, "Test case C%lS::RunL left with %d", iTestCaseId, aError); |
0 | 241 |
AssertionFailed(aError, _L("RunError")); |
242 |
return KErrNone; |
|
243 |
} |
|
244 |
||
245 |
||
246 |
TDesC& CTestCaseRoot::TestCaseId() |
|
247 |
{ |
|
248 |
return iTestCaseId; |
|
249 |
} |
|
250 |
||
251 |
||
252 |
TInt CTestCaseRoot::TestResult() const |
|
253 |
{ |
|
254 |
return iTestResult; |
|
255 |
} |
|
256 |
||
257 |
||
258 |
void CTestCaseRoot::PerformTestL() |
|
259 |
{ |
|
260 |
// tell user what they should have done before starting! |
|
261 |
DescribePreconditions(); |
|
262 |
// run it |
|
263 |
ExecuteTestCaseL(); |
|
264 |
} |
|
265 |
||
266 |
||
267 |
void CTestCaseRoot::TestFailed(TInt aFailResult, const TDesC &aErrorDescription) |
|
268 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
269 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
270 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
271 |
OstTraceFunctionEntry0(CTESTCASEROOT_TESTFAILED); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
272 |
} |
0 | 273 |
iTestResult = aFailResult; |
274 |
test.Printf(_L("Test %S\n"), &TestCaseId()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
275 |
OstTraceExt1(TRACE_NORMAL, CTESTCASEROOT_TESTFAILED_DUP01, "Test %S\n", TestCaseId()); |
0 | 276 |
test.Printf(_L("Failed (%d)\n"), aFailResult); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
277 |
OstTrace1(TRACE_NORMAL, CTESTCASEROOT_TESTFAILED_DUP02, "Failed (%d)\n", aFailResult); |
0 | 278 |
test.Printf(_L("%S!\n"), &aErrorDescription); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
279 |
OstTraceExt1(TRACE_NORMAL, CTESTCASEROOT_TESTFAILED_DUP03, "%S!\n", aErrorDescription); |
0 | 280 |
if (!iAutomated) |
281 |
{ |
|
282 |
test.Printf(_L("\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
283 |
OstTrace0(TRACE_NORMAL, CTESTCASEROOT_TESTFAILED_DUP04, "\n"); |
0 | 284 |
test.Printf(KPressAnyKeyToContinue); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
285 |
OstTrace0(TRACE_NORMAL, CTESTCASEROOT_TESTFAILED_DUP05, KPressAnyKeyToContinue); |
0 | 286 |
iConsole->Getch(); |
287 |
} |
|
288 |
// the next call panics the framework! |
|
289 |
TestPolicy().SignalTestComplete(iTestResult); |
|
290 |
} |
|
291 |
||
292 |
||
293 |
void CTestCaseRoot::TestFailed2(TInt aFailResult, const TDesC &aErrorDescription, TInt errorCode) |
|
294 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
295 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
296 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
297 |
OstTraceFunctionEntry0(CTESTCASEROOT_TESTFAILED2); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
298 |
} |
0 | 299 |
iTestResult = aFailResult; |
300 |
test.Printf(_L("Test %S FAILED %d '%S %d'!\n"), |
|
301 |
&TestCaseId(), |
|
302 |
aFailResult, |
|
303 |
&aErrorDescription, |
|
304 |
errorCode); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
305 |
OstTraceExt4(TRACE_NORMAL, CTESTCASEROOT_TESTFAILED2_DUP01, "Test %S FAILED %d '%S %d'!\n", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
306 |
TestCaseId(), |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
307 |
aFailResult, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
308 |
aErrorDescription, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
309 |
errorCode); |
0 | 310 |
// the next call panics the framework! |
311 |
TestPolicy().SignalTestComplete(iTestResult); |
|
312 |
} |
|
313 |
||
314 |
||
315 |
||
316 |
void CTestCaseRoot::TestPassed() |
|
317 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
318 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
319 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
320 |
OstTraceFunctionEntry0(CTESTCASEROOT_TESTPASSED); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
321 |
} |
0 | 322 |
iTestResult = KErrNone; |
323 |
TestPolicy().SignalTestComplete(iTestResult); |
|
324 |
} |
|
325 |
||
326 |
||
327 |
||
328 |
||
329 |
/** Complete the servicing of the Active object and signal it ready to run again |
|
330 |
in next scheduler slot. This method works as drop-through when a test step has |
|
331 |
nothing more to do . |
|
332 |
*/ |
|
333 |
void CTestCaseRoot::SelfComplete(TInt aCode) |
|
334 |
{ |
|
335 |
TRequestStatus* s = &iStatus; |
|
336 |
iStatus = KRequestPending; |
|
337 |
User::RequestComplete(s, aCode); |
|
338 |
SetActive(); |
|
339 |
} |
|
340 |
||
341 |
/* Prints a little banner at the top of a test-step : |
|
342 |
* B2B tests also display the duration of the last step, and the current OTG state |
|
343 |
*/ |
|
344 |
void CTestCaseRoot::PrintStepName(const TDesC &aStepName) |
|
345 |
{ |
|
346 |
if (gVerboseOutput) |
|
347 |
{ |
|
348 |
test.Printf(_L("--------------\n %S "), &aStepName); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
349 |
OstTraceExt1(TRACE_NORMAL, CTESTCASEROOT_PRINTSTEPNAME, "--------------\n %S ", aStepName); |
0 | 350 |
// B2B class method dumps the engine state |
351 |
// |
|
352 |
test.Printf(_L("\n--------------\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
353 |
OstTrace0(TRACE_NORMAL, CTESTCASEROOT_PRINTSTEPNAME_DUP01, "\n--------------\n"); |
0 | 354 |
} |
355 |
} |
|
356 |
||
357 |
||
358 |
/* ************************************************************************************** |
|
359 |
* |
|
360 |
*/ |
|
361 |
CTestCaseB2BRoot::CTestCaseB2BRoot(const TDesC& aTestCaseId, TBool aHost, TRequestStatus &aStatus) |
|
362 |
: CTestCaseRoot(aTestCaseId, aHost) , iCollector(aStatus) |
|
363 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
364 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
365 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
366 |
OstTraceFunctionEntry0(CTESTCASEB2BROOT_CTESTCASEB2BROOT); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
367 |
} |
0 | 368 |
|
369 |
} |
|
370 |
||
371 |
||
372 |
CTestCaseB2BRoot::~CTestCaseB2BRoot() |
|
373 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
374 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
375 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
376 |
OstTraceFunctionEntry0(CTESTCASEB2BROOT_DCTESTCASEB2BROOT); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
377 |
} |
0 | 378 |
|
379 |
} |
|
380 |
||
381 |
/* Print step name : B2B override displays the OTG Engine state as well |
|
382 |
*/ |
|
383 |
void CTestCaseB2BRoot::PrintStepName(const TDesC &aStepName) |
|
384 |
{ |
|
385 |
if (gVerboseOutput) |
|
386 |
{ |
|
387 |
test.Printf(_L("--------------\n %S "), &aStepName); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
388 |
OstTraceExt1(TRACE_NORMAL, CTESTCASEB2BROOT_PRINTSTEPNAME, "--------------\n %S ", aStepName); |
0 | 389 |
// engine state |
390 |
CNotifyWatcherBase *pWatcher = iCollector.GetWatcher(EWatcherState); |
|
391 |
if (pWatcher) |
|
392 |
{ |
|
393 |
TBuf<MAX_DSTRLEN> aDescription; |
|
394 |
RUsbOtgDriver::TOtgState aState = static_cast<RUsbOtgDriver::TOtgState>(pWatcher->GetEventValue()); |
|
395 |
||
396 |
OtgStateString(aState, aDescription); |
|
397 |
LOG_VERBOSE3(_L("OTGState %d '%S' \n"), aState, &aDescription); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
398 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
399 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
400 |
OstTraceExt2(TRACE_VERBOSE, CTESTCASEB2BROOT_PRINTSTEPNAME_DUP01, "OTGState %d '%S' \n", aState, aDescription); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
401 |
} |
0 | 402 |
} |
403 |
test.Printf(_L(" : time = %dms\n--------------\n"), iCollector.DurationElapsed()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
404 |
OstTrace1(TRACE_NORMAL, CTESTCASEB2BROOT_PRINTSTEPNAME_DUP02, " : time = %dms\n--------------\n", iCollector.DurationElapsed()); |
0 | 405 |
} |
406 |
} |
|
407 |
||
408 |
/* Default implementation which describes this as a B2B test-case |
|
409 |
*/ |
|
410 |
void CTestCaseB2BRoot::DescribePreconditions() |
|
411 |
{ |
|
412 |
test.Printf(KTestTypeB2BMsg); // B2B |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
413 |
OstTrace0(TRACE_NORMAL, CTESTCASEB2BROOT_DESCRIBEPRECONDITIONS, KTestTypeB2BMsg); // B2B |
0 | 414 |
if (gTestRoleMaster) |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
415 |
{ |
0 | 416 |
test.Printf(KRoleMasterMsg); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
417 |
OstTrace0(TRACE_NORMAL, CTESTCASEB2BROOT_DESCRIBEPRECONDITIONS_DUP01, KRoleMasterMsg); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
418 |
} |
0 | 419 |
else |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
420 |
{ |
0 | 421 |
test.Printf(KRoleSlaveMsg); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
422 |
OstTrace0(TRACE_NORMAL, CTESTCASEB2BROOT_DESCRIBEPRECONDITIONS_DUP02, KRoleSlaveMsg); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
423 |
} |
0 | 424 |
} |
425 |
||
426 |
||
427 |
void CTestCaseB2BRoot::StepB2BPreconditions() |
|
428 |
{ |
|
429 |
// prompt to insert connector |
|
430 |
if (gTestRoleMaster) |
|
431 |
{ // "B" device |
|
432 |
test.Printf(KInsertBCablePrompt); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
433 |
OstTrace0(TRACE_NORMAL, CTESTCASEB2BROOT_STEPB2BPRECONDITIONS, KInsertBCablePrompt); |
0 | 434 |
} |
435 |
else |
|
436 |
{ |
|
437 |
test.Printf(KInsertACablePrompt); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
438 |
OstTrace0(TRACE_NORMAL, CTESTCASEB2BROOT_STEPB2BPRECONDITIONS_DUP01, KInsertACablePrompt); |
0 | 439 |
} |
440 |
if (iAutomated) |
|
441 |
{ |
|
442 |
||
443 |
SelfComplete(); |
|
444 |
return; |
|
445 |
} |
|
446 |
test.Printf(KPressAnyKeyToContinue); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
447 |
OstTrace0(TRACE_NORMAL, CTESTCASEB2BROOT_STEPB2BPRECONDITIONS_DUP02, KPressAnyKeyToContinue); |
0 | 448 |
RequestCharacter(); |
449 |
} |
|
450 |
||
451 |
||
452 |
/* Test for A or B plug as relevant for MASTER/SLAVE role, fail the test if wrong |
|
453 |
*/ |
|
454 |
void CTestCaseB2BRoot::CheckRoleConnections() |
|
455 |
{ |
|
456 |
if (gTestRoleMaster) |
|
457 |
{ |
|
458 |
if (otgIdPinPresent()) |
|
459 |
{ // oops |
|
460 |
test.Printf(KMsgErrorPreconditionFailed); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
461 |
OstTrace0(TRACE_NORMAL, CTESTCASEB2BROOT_CHECKROLECONNECTIONS, KMsgErrorPreconditionFailed); |
0 | 462 |
return TestFailed(KErrAbort, KMsgBPlugNotFound); |
463 |
} |
|
464 |
} |
|
465 |
else |
|
466 |
{ |
|
467 |
if (!otgIdPinPresent()) |
|
468 |
{ // oops |
|
469 |
test.Printf(KMsgErrorPreconditionFailed); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
470 |
OstTrace0(TRACE_NORMAL, CTESTCASEB2BROOT_CHECKROLECONNECTIONS_DUP01, KMsgErrorPreconditionFailed); |
0 | 471 |
return TestFailed(KErrAbort, KMsgAPlugNotFound); |
472 |
} |
|
473 |
} |
|
474 |
} |
|
475 |
||
476 |
||
477 |
/* Clears the expected event Q just before calling the step, but not the |
|
478 |
* recieved Q since the step may still inspect it using the EventReceivedAlready() method. |
|
479 |
*/ |
|
480 |
void CTestCaseB2BRoot::PreRunStep() |
|
481 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
482 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
483 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
484 |
OstTraceFunctionEntry0(CTESTCASEB2BROOT_PRERUNSTEP); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
485 |
} |
0 | 486 |
|
487 |
iCollector.ClearAllEvents(EFalse, ETrue); |
|
488 |
} |
|
489 |
||
490 |
||
491 |
void CTestCaseB2BRoot::PostRunStep() |
|
492 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
493 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
494 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
495 |
OstTraceFunctionEntry0(CTESTCASEB2BROOT_POSTRUNSTEP); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
496 |
} |
0 | 497 |
// clear the recieved event Q, but not the expected Q |
498 |
iCollector.ClearAllEvents(ETrue, EFalse); |
|
499 |
||
500 |
} |
|
501 |
||
502 |
||
503 |