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 |
// @internalComponent |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include <e32std.h> |
|
19 |
#include <e32std_private.h> |
|
20 |
#include <u32std.h> // unicode builds |
|
21 |
#include <e32base.h> |
|
22 |
#include <e32base_private.h> |
|
23 |
#include <e32Test.h> // RTest headder |
|
24 |
#include "testcaseroot.h" |
|
25 |
#include "testcasewd.h" |
|
26 |
#include "testcase0469.h" |
|
256
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 "testcase0469Traces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
30 |
#endif |
0 | 31 |
|
32 |
#define _REPEATS (oOpenIterations*3) |
|
33 |
||
34 |
||
35 |
||
36 |
// the name below is used to add a pointer to our construction method to a pointer MAP in |
|
37 |
// the class factory |
|
38 |
_LIT(KTestCaseId,"PBASE-USB_OTGDI-0469"); |
|
39 |
const TTestCaseFactoryReceipt<CTestCase0469> CTestCase0469::iFactoryReceipt(KTestCaseId); |
|
40 |
||
41 |
CTestCase0469* CTestCase0469::NewL(TBool aHost) |
|
42 |
{ |
|
256
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(CTESTCASE0469_NEWL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
46 |
} |
0 | 47 |
CTestCase0469* self = new (ELeave) CTestCase0469(aHost); |
48 |
CleanupStack::PushL(self); |
|
49 |
self->ConstructL(); |
|
50 |
CleanupStack::Pop(self); |
|
51 |
return self; |
|
52 |
} |
|
53 |
||
54 |
CTestCase0469::CTestCase0469(TBool aHost) |
|
55 |
: CTestCaseB2BRoot(KTestCaseId, aHost, iStatus) |
|
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(CTESTCASE0469_CTESTCASE0469); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
60 |
} |
0 | 61 |
|
62 |
} |
|
63 |
||
64 |
/** |
|
65 |
ConstructL |
|
66 |
*/ |
|
67 |
void CTestCase0469::ConstructL() |
|
68 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
69 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
70 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
71 |
OstTraceFunctionEntry0(CTESTCASE0469_CONSTRUCTL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
} |
0 | 73 |
iDualRoleCase = EFalse; // Not back to back |
74 |
BaseConstructL(); |
|
75 |
} |
|
76 |
||
77 |
||
78 |
CTestCase0469::~CTestCase0469() |
|
79 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
81 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
82 |
OstTraceFunctionEntry0(CTESTCASE0469_DCTESTCASE0469); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
83 |
} |
0 | 84 |
iCollector.DestroyObservers(); |
85 |
Cancel(); |
|
86 |
} |
|
87 |
||
88 |
||
89 |
void CTestCase0469::ExecuteTestCaseL() |
|
90 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
91 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
92 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
93 |
OstTraceFunctionEntry0(CTESTCASE0469_EXECUTETESTCASEL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
94 |
} |
0 | 95 |
iCaseStep = EPreconditions; |
96 |
iRepeats = 3; |
|
97 |
||
98 |
CActiveScheduler::Add(this); |
|
99 |
SelfComplete(); |
|
100 |
} |
|
101 |
||
102 |
||
103 |
void CTestCase0469::DoCancel() |
|
104 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
105 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
106 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
107 |
OstTraceFunctionEntry0(CTESTCASE0469_DOCANCEL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
108 |
} |
0 | 109 |
// cancel our timer |
110 |
iTimer.Cancel(); |
|
111 |
} |
|
112 |
||
113 |
// handle event completion |
|
114 |
void CTestCase0469::RunStepL() |
|
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(CTESTCASE0469_RUNSTEPL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
119 |
} |
0 | 120 |
// Obtain the completion code for this CActive obj. |
121 |
TInt completionCode(iStatus.Int()); |
|
122 |
TBuf<MAX_DSTRLEN> aDescription; |
|
123 |
// 15 seconds, should be plenty of time for 3 cycles of plug pulling |
|
124 |
const TInt KTestCase0469Timeout = 15000; |
|
125 |
||
126 |
switch(iCaseStep) |
|
127 |
{ |
|
128 |
case EPreconditions: |
|
129 |
LOG_STEPNAME(_L("EPreconditions")) |
|
130 |
iCaseStep = ELoadLdd; |
|
131 |
// prompt to insert connectors |
|
132 |
test.Printf(KInsertBCablePrompt); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP01, KInsertBCablePrompt); |
0 | 134 |
test.Printf(KRemoveAFromPC); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP02, KRemoveAFromPC); |
0 | 136 |
test.Printf(KPressAnyKeyToContinue); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP03, KPressAnyKeyToContinue); |
0 | 138 |
RequestCharacter(); |
139 |
break; |
|
140 |
||
141 |
case ELoadLdd: |
|
142 |
LOG_STEPNAME(_L("ELoadLdd")) |
|
143 |
if (!StepLoadClient(0xF678/*use default settings for SRP/HNP support*/)) |
|
144 |
{ |
|
145 |
return TestFailed(KErrAbort, _L("Client Load Failure")); |
|
146 |
} |
|
147 |
||
148 |
if (!StepLoadLDD()) |
|
149 |
{ |
|
150 |
return TestFailed(KErrAbort, _L("OTG Load Failure")); |
|
151 |
} |
|
152 |
||
153 |
// subscribe to OTG states,events and messages now that it has loaded OK |
|
154 |
TRAPD(result, iCollector.CreateObserversL(*this)); |
|
155 |
if (KErrNone != result) |
|
156 |
{ |
|
157 |
return(TestFailed(KErrNoMemory, _L("Unable to create observers"))); |
|
158 |
} |
|
159 |
iCollector.ClearAllEvents(); |
|
160 |
||
161 |
iCaseStep = ELoopControl; |
|
162 |
||
163 |
iCollector.AddStepTimeout(KTestCase0469Timeout); |
|
164 |
||
165 |
SelfComplete(); |
|
166 |
break; |
|
167 |
||
168 |
case ELoopControl: |
|
169 |
LOG_STEPNAME(_L("ELoopControl")) |
|
170 |
||
171 |
// Check for timeout |
|
172 |
if (KTestCaseWatchdogTO == iStatus.Int()) |
|
173 |
{ |
|
174 |
iCollector.DestroyObservers(); |
|
175 |
return TestFailed(KErrAbort, _L("Timeout")); |
|
176 |
} |
|
177 |
||
178 |
if (iRepeats--) |
|
179 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
180 |
OstTrace1(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP04, "ELoopControl around again %d", iRepeats); |
0 | 181 |
iCaseStep = ETestVbusRise; |
182 |
} |
|
183 |
else |
|
184 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
185 |
OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP05, "ELoopControl we're done"); |
0 | 186 |
iCaseStep = EUnloadLdd; |
187 |
} |
|
188 |
SelfComplete(); |
|
189 |
break; |
|
190 |
||
191 |
case ETestVbusRise: |
|
192 |
LOG_STEPNAME(_L("ETestVbusRise")) |
|
193 |
// Check for timeout |
|
194 |
if (KTestCaseWatchdogTO == iStatus.Int()) |
|
195 |
{ |
|
196 |
iCollector.DestroyObservers(); |
|
197 |
return TestFailed(KErrAbort, _L("Timeout")); |
|
198 |
} |
|
199 |
||
200 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusRaised); |
|
201 |
iCaseStep = ETestVbusFall; |
|
202 |
test.Printf(KInsertAIntoPC); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
203 |
OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP06, KInsertAIntoPC); |
0 | 204 |
SetActive(); |
205 |
break; |
|
206 |
||
207 |
case ETestVbusFall: |
|
208 |
LOG_STEPNAME(_L("ETestVbusFall")) |
|
209 |
// Check for timeout |
|
210 |
if (KTestCaseWatchdogTO == iStatus.Int()) |
|
211 |
{ |
|
212 |
iCollector.DestroyObservers(); |
|
213 |
return TestFailed(KErrAbort, _L("Timeout")); |
|
214 |
} |
|
215 |
||
216 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusDropped); |
|
217 |
iCaseStep = ELoopControl; |
|
218 |
test.Printf(KRemoveAFromPC); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
219 |
OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP07, KRemoveAFromPC); |
0 | 220 |
SetActive(); |
221 |
break; |
|
222 |
||
223 |
case EUnloadLdd: |
|
224 |
LOG_STEPNAME(_L("EUnloadLdd")) |
|
225 |
iCollector.DestroyObservers(); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
226 |
OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP08, "Destroyed observers"); |
0 | 227 |
if (EFalse == StepUnloadLDD()) |
228 |
return TestFailed(KErrAbort,_L("unload Ldd failure")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
229 |
OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP09, "unloaded ldd"); |
0 | 230 |
if (!StepUnloadClient()) |
231 |
return TestFailed(KErrAbort,_L("Client Unload Failure")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
232 |
OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP10, "unloaded client"); |
0 | 233 |
|
234 |
iCaseStep = ELastStep; |
|
235 |
SelfComplete(); |
|
236 |
break; |
|
237 |
||
238 |
case ELastStep: |
|
239 |
LOG_STEPNAME(_L("ELastStep")) |
|
240 |
TestPassed(); |
|
241 |
break; |
|
242 |
||
243 |
default: |
|
244 |
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
|
245 |
OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP11, "<Error> unknown test step"); |
0 | 246 |
Cancel(); |
247 |
return (TestFailed(KErrCorrupt, _L("<Error> unknown test step"))); |
|
248 |
} |
|
249 |
} |
|
250 |