author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 256 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
256
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 |
// CTestCase0461.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 <e32Test.h> // RTest headder |
|
25 |
#include "testcaseroot.h" |
|
26 |
#include "testcasewd.h" |
|
27 |
#include "testcase0461.h" |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
28 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
29 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
30 |
#include "testcase0461Traces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
31 |
#endif |
0 | 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-0461"); |
|
38 |
const TTestCaseFactoryReceipt<CTestCase0461> CTestCase0461::iFactoryReceipt(KTestCaseId); |
|
39 |
||
40 |
CTestCase0461* CTestCase0461::NewL(TBool aHost) |
|
41 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
42 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
43 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
44 |
OstTraceFunctionEntry0(CTESTCASE0461_NEWL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
45 |
} |
0 | 46 |
CTestCase0461* self = new (ELeave) CTestCase0461(aHost); |
47 |
CleanupStack::PushL(self); |
|
48 |
self->ConstructL(); |
|
49 |
CleanupStack::Pop(self); |
|
50 |
return self; |
|
51 |
} |
|
52 |
||
53 |
||
54 |
CTestCase0461::CTestCase0461(TBool aHost) |
|
55 |
: CTestCaseRoot(KTestCaseId, aHost) |
|
56 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
57 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
58 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
59 |
OstTraceFunctionEntry0(CTESTCASE0461_CTESTCASE0461); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
60 |
} |
0 | 61 |
|
62 |
} |
|
63 |
||
64 |
||
65 |
/** |
|
66 |
ConstructL |
|
67 |
*/ |
|
68 |
void CTestCase0461::ConstructL() |
|
69 |
{ |
|
256
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(CTESTCASE0461_CONSTRUCTL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
73 |
} |
0 | 74 |
iRepeats = KOperationRetriesMax; |
75 |
BaseConstructL(); |
|
76 |
||
77 |
iWDTimer = CTestCaseWatchdog::NewL(); |
|
78 |
} |
|
79 |
||
80 |
||
81 |
CTestCase0461::~CTestCase0461() |
|
82 |
{ |
|
256
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(CTESTCASE0461_DCTESTCASE0461); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
86 |
} |
0 | 87 |
|
88 |
Cancel(); |
|
89 |
delete iWDTimer; |
|
90 |
} |
|
91 |
||
92 |
||
93 |
void CTestCase0461::ExecuteTestCaseL() |
|
94 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
95 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
96 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
97 |
OstTraceFunctionEntry0(CTESTCASE0461_EXECUTETESTCASEL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
98 |
} |
0 | 99 |
iCaseStep = ELoadLdd; |
100 |
||
101 |
CActiveScheduler::Add(this); |
|
102 |
SelfComplete(); |
|
103 |
||
104 |
} |
|
105 |
||
106 |
||
107 |
void CTestCase0461::DescribePreconditions() |
|
108 |
{ |
|
109 |
test.Printf(_L("Insert 'A' connector beforehand.\n")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
110 |
OstTrace0(TRACE_NORMAL, CTESTCASE0461_DESCRIBEPRECONDITIONS, "Insert 'A' connector beforehand.\n"); |
0 | 111 |
} |
112 |
||
113 |
||
114 |
void CTestCase0461::DoCancel() |
|
115 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
116 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
117 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
118 |
OstTraceFunctionEntry0(CTESTCASE0461_DOCANCEL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
119 |
} |
0 | 120 |
|
121 |
// cancel our timer |
|
122 |
iTimer.Cancel(); |
|
123 |
} |
|
124 |
||
125 |
void CTestCase0461::CancelKB(CTestCaseRoot *pThis) |
|
126 |
{ |
|
127 |
CTestCase0461 * p = REINTERPRET_CAST(CTestCase0461 *,pThis); |
|
128 |
// cancel any pending call, and then complete our active obj with a timeout value |
|
129 |
||
130 |
p->iConsole->ReadCancel(); |
|
131 |
||
132 |
} |
|
133 |
||
134 |
// handle event completion |
|
135 |
void CTestCase0461::RunStepL() |
|
136 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
138 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
139 |
OstTraceFunctionEntry0(CTESTCASE0461_RUNSTEPL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
140 |
} |
0 | 141 |
// Obtain the completion code for this CActive obj. |
142 |
TInt completionCode(iStatus.Int()); |
|
143 |
TBuf<MAX_DSTRLEN> aDescription; |
|
144 |
||
145 |
switch(iCaseStep) |
|
146 |
{ |
|
147 |
case EPreconditions: |
|
148 |
iCaseStep = ELoadLdd; |
|
149 |
if (iAutomated) |
|
150 |
{ |
|
151 |
iCaseStep = ELoadLdd; |
|
152 |
SelfComplete(); |
|
153 |
break; |
|
154 |
} |
|
155 |
// prompt to insert connector |
|
156 |
test.Printf(KInsertAConnectorPrompt); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
157 |
OstTrace0(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP01, KInsertAConnectorPrompt); |
0 | 158 |
test.Printf(KPressAnyKeyToContinue); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
159 |
OstTrace0(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP02, KPressAnyKeyToContinue); |
0 | 160 |
RequestCharacter(); |
161 |
break; |
|
162 |
||
163 |
case ELoadLdd: |
|
164 |
if (!StepLoadLDD()) |
|
165 |
{ |
|
166 |
break; |
|
167 |
} |
|
168 |
||
169 |
iCaseStep = ERegisterForEvents; |
|
170 |
SelfComplete(); |
|
171 |
iDequeAttempts = 0; |
|
172 |
break; |
|
173 |
||
174 |
// 2. Prepare to wait on ID_PIN |
|
175 |
case ERegisterForEvents: |
|
176 |
// prompt to remove connector |
|
177 |
test.Printf(KRemoveAConnectorPrompt); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
178 |
OstTrace0(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP03, KRemoveAConnectorPrompt); |
0 | 179 |
if (iDequeAttempts > 3) |
180 |
{ |
|
181 |
return (TestFailed(KErrCorrupt, _L("<Error> too many irrelevant/incorrect events"))); |
|
182 |
} |
|
183 |
||
184 |
otgQueueOtgEventRequest( iOTGEvent, iStatus); |
|
185 |
iIDcheckStart.HomeTime(); |
|
186 |
iCaseStep = EGetAndCancelEvent; |
|
187 |
SetActive(); |
|
188 |
break; |
|
189 |
||
190 |
// 3. pick up events already buffered when we start |
|
191 |
case EEmptyQueue: |
|
192 |
{ |
|
193 |
||
194 |
TInt aMillisec; |
|
195 |
iIDcheckEnd.HomeTime(); |
|
196 |
TTimeIntervalMicroSeconds ivlMicro(iIDcheckEnd.MicroSecondsFrom(iIDcheckStart)); |
|
197 |
aMillisec = (TInt)(ivlMicro.Int64())/1000; // USB times are in uSec, but in ms for the user layer |
|
198 |
iCaseStep = EGetAndCancelEvent; |
|
199 |
// test if too quick! |
|
200 |
if ((aMillisec < KDelayDurationForQEmpty) &&(!gSemiAutomated)) // use 200ms - clocked at 17ms |
|
201 |
{ |
|
202 |
iCaseStep = ERegisterForEvents; |
|
203 |
iDequeAttempts++; |
|
204 |
SelfComplete(); |
|
205 |
break; |
|
206 |
} |
|
207 |
}// drop through to next step |
|
208 |
case EGetAndCancelEvent: //4. |
|
209 |
OtgEventString(iOTGEvent, aDescription); |
|
210 |
test.Printf(_L("Received event %d '%S' status(%d)"), iOTGEvent, &aDescription, completionCode); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
211 |
OstTraceExt3(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP04, "Received event %d '%S' status(%d)", iOTGEvent, aDescription, completionCode); |
0 | 212 |
if (RUsbOtgDriver::EEventAPlugRemoved == iOTGEvent) |
213 |
{ |
|
214 |
otgQueueOtgEventRequest( iOTGEvent, iStatus); |
|
215 |
// cancel it and then go into a loop |
|
216 |
otgCancelOtgEventRequest(); |
|
217 |
// swallow the cancelation now |
|
218 |
User::WaitForRequest(iStatus); |
|
219 |
||
220 |
iCaseStep = ECancelNotify; |
|
221 |
} |
|
222 |
else |
|
223 |
{ |
|
224 |
// wrong event in the Q already, keep at it |
|
225 |
iCaseStep = ERegisterForEvents; |
|
226 |
iDequeAttempts++; |
|
227 |
} |
|
228 |
SelfComplete(); |
|
229 |
break; |
|
230 |
||
231 |
// 5. prepare to go into a loop |
|
232 |
case ECancelNotify: // insert 'A' |
|
233 |
iRepeats = 3; // #times to insert+remove |
|
234 |
iExpectedEvents = 0; |
|
235 |
iEventsInQueue = 0; |
|
236 |
iCaseStep = EInsertA; |
|
237 |
SelfComplete(); |
|
238 |
break; |
|
239 |
||
240 |
// 6 |
|
241 |
case EInsertA: // insert 'A' plug |
|
242 |
iWDTimer->Cancel(); |
|
243 |
iConsole->ReadCancel(); |
|
244 |
test.Printf(KInsertAConnectorPrompt); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
245 |
OstTrace0(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP05, KInsertAConnectorPrompt); |
0 | 246 |
iCaseStep = ERemoveA; |
247 |
test.Printf(KPressAnyKeyToContinue); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
248 |
OstTrace0(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP06, KPressAnyKeyToContinue); |
0 | 249 |
|
250 |
RequestCharacter(); |
|
251 |
iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &CancelKB); |
|
252 |
||
253 |
iExpectedEvents++; |
|
254 |
break; |
|
255 |
||
256 |
// 7. remove 'A' plug |
|
257 |
case ERemoveA: |
|
258 |
iWDTimer->Cancel(); |
|
259 |
iConsole->ReadCancel(); |
|
260 |
test.Printf(KRemoveAConnectorPrompt); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
261 |
OstTrace0(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP07, KRemoveAConnectorPrompt); |
0 | 262 |
if (iRepeats-- >0) |
263 |
{ |
|
264 |
// Do it again please |
|
265 |
iCaseStep = EInsertA; |
|
266 |
} |
|
267 |
else |
|
268 |
{ // got enough events in Q, let's count them up |
|
269 |
iCaseStep = ETallyEvents; |
|
270 |
} |
|
271 |
test.Printf(KPressAnyKeyToContinue); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
272 |
OstTrace0(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP08, KPressAnyKeyToContinue); |
0 | 273 |
|
274 |
RequestCharacter(); |
|
275 |
iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &CancelKB); |
|
276 |
iExpectedEvents++; |
|
277 |
break; |
|
278 |
||
279 |
// 8. |
|
280 |
case ETallyEvents: |
|
281 |
// Getting here tests if the object does not get double-signalled. |
|
282 |
// a stray signal anywhere would Panic the scheduler when we self complete |
|
283 |
iCaseStep = ETallyNewEvent; |
|
284 |
iStatus = KRequestPending; |
|
285 |
otgQueueOtgEventRequest( iOTGEvent, iStatus); |
|
286 |
SetActive(); |
|
287 |
break; |
|
288 |
// 9. |
|
289 |
case ETallyNewEvent: |
|
290 |
iEventsInQueue++; // got one, add it |
|
291 |
if (iExpectedEvents == iEventsInQueue) |
|
292 |
{ |
|
293 |
iCaseStep = EUnloadLdd; |
|
294 |
} |
|
295 |
else |
|
296 |
{ |
|
297 |
iCaseStep = ETallyEvents; |
|
298 |
} |
|
299 |
SelfComplete(); |
|
300 |
break; |
|
301 |
||
302 |
case EUnloadLdd: |
|
303 |
case ELastStep: |
|
304 |
if (EFalse == StepUnloadLDD()) |
|
305 |
return TestFailed(KErrAbort,_L("unload Ldd failure")); |
|
306 |
||
307 |
return TestPassed(); |
|
308 |
||
309 |
default: |
|
310 |
test.Printf(_L("<Error> unknown test step")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
311 |
OstTrace0(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP09, "<Error> unknown test step"); |
0 | 312 |
Cancel(); |
313 |
return (TestFailed(KErrCorrupt, _L("<Error> unknown test step"))); |
|
314 |
||
315 |
} |
|
316 |
} |
|
317 |
||
318 |