1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
23 #include <e32Test.h> // RTest headder |
23 #include <e32Test.h> // RTest headder |
24 #include "testcaseroot.h" |
24 #include "testcaseroot.h" |
25 //#include "testcasewd.h" |
25 //#include "testcasewd.h" |
26 #include "b2bwatchers.h" |
26 #include "b2bwatchers.h" |
27 #include "testcase0678.h" |
27 #include "testcase0678.h" |
|
28 #include "OstTraceDefinitions.h" |
|
29 #ifdef OST_TRACE_COMPILER_IN_USE |
|
30 #include "testcase0678Traces.h" |
|
31 #endif |
28 |
32 |
29 #define _REPEATS (oOpenIterations*3) |
33 #define _REPEATS (oOpenIterations*3) |
30 |
34 |
31 |
35 |
32 /* ************************************************************************************** |
36 /* ************************************************************************************** |
36 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0678"); |
40 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0678"); |
37 const TTestCaseFactoryReceipt<CTestCase0678> CTestCase0678::iFactoryReceipt(KTestCaseId); |
41 const TTestCaseFactoryReceipt<CTestCase0678> CTestCase0678::iFactoryReceipt(KTestCaseId); |
38 |
42 |
39 CTestCase0678* CTestCase0678::NewL(TBool aHost) |
43 CTestCase0678* CTestCase0678::NewL(TBool aHost) |
40 { |
44 { |
41 LOG_FUNC |
45 if(gVerboseOutput) |
|
46 { |
|
47 OstTraceFunctionEntry0(CTESTCASE0678_NEWL); |
|
48 } |
42 CTestCase0678* self = new (ELeave) CTestCase0678(aHost); |
49 CTestCase0678* self = new (ELeave) CTestCase0678(aHost); |
43 CleanupStack::PushL(self); |
50 CleanupStack::PushL(self); |
44 self->ConstructL(); |
51 self->ConstructL(); |
45 CleanupStack::Pop(self); |
52 CleanupStack::Pop(self); |
46 return self; |
53 return self; |
48 |
55 |
49 |
56 |
50 CTestCase0678::CTestCase0678(TBool aHost) |
57 CTestCase0678::CTestCase0678(TBool aHost) |
51 : CTestCaseB2BRoot(KTestCaseId, aHost, iStatus) |
58 : CTestCaseB2BRoot(KTestCaseId, aHost, iStatus) |
52 { |
59 { |
53 LOG_FUNC |
60 if(gVerboseOutput) |
|
61 { |
|
62 OstTraceFunctionEntry0(CTESTCASE0678_CTESTCASE0678); |
|
63 } |
54 |
64 |
55 } |
65 } |
56 |
66 |
57 |
67 |
58 /** |
68 /** |
59 ConstructL |
69 ConstructL |
60 */ |
70 */ |
61 void CTestCase0678::ConstructL() |
71 void CTestCase0678::ConstructL() |
62 { |
72 { |
63 LOG_FUNC |
73 if(gVerboseOutput) |
|
74 { |
|
75 OstTraceFunctionEntry0(CTESTCASE0678_CONSTRUCTL); |
|
76 } |
64 |
77 |
65 iDualRoleCase = ETrue; // another back-back |
78 iDualRoleCase = ETrue; // another back-back |
66 |
79 |
67 BaseConstructL(); |
80 BaseConstructL(); |
68 } |
81 } |
69 |
82 |
70 |
83 |
71 CTestCase0678::~CTestCase0678() |
84 CTestCase0678::~CTestCase0678() |
72 { |
85 { |
73 LOG_FUNC |
86 if(gVerboseOutput) |
|
87 { |
|
88 OstTraceFunctionEntry0(CTESTCASE0678_DCTESTCASE0678); |
|
89 } |
74 iCollector.DestroyObservers(); |
90 iCollector.DestroyObservers(); |
75 Cancel(); |
91 Cancel(); |
76 } |
92 } |
77 |
93 |
78 |
94 |
79 void CTestCase0678::ExecuteTestCaseL() |
95 void CTestCase0678::ExecuteTestCaseL() |
80 { |
96 { |
81 LOG_FUNC |
97 if(gVerboseOutput) |
|
98 { |
|
99 OstTraceFunctionEntry0(CTESTCASE0678_EXECUTETESTCASEL); |
|
100 } |
82 iCaseStep = EPreconditions; |
101 iCaseStep = EPreconditions; |
83 iHNPCounter = 3; // To be decremented to govern the number of times we do HNP. |
102 iHNPCounter = 3; // To be decremented to govern the number of times we do HNP. |
84 CActiveScheduler::Add(this); |
103 CActiveScheduler::Add(this); |
85 SelfComplete(); |
104 SelfComplete(); |
86 } |
105 } |
87 |
106 |
88 |
107 |
89 void CTestCase0678::DoCancel() |
108 void CTestCase0678::DoCancel() |
90 { |
109 { |
91 LOG_FUNC |
110 if(gVerboseOutput) |
|
111 { |
|
112 OstTraceFunctionEntry0(CTESTCASE0678_DOCANCEL); |
|
113 } |
92 // cancel our timer |
114 // cancel our timer |
93 iTimer.Cancel(); |
115 iTimer.Cancel(); |
94 } |
116 } |
95 |
117 |
96 |
118 |
97 // handle event completion |
119 // handle event completion |
98 void CTestCase0678::RunStepL() |
120 void CTestCase0678::RunStepL() |
99 { |
121 { |
100 LOG_FUNC |
122 if(gVerboseOutput) |
|
123 { |
|
124 OstTraceFunctionEntry0(CTESTCASE0678_RUNSTEPL); |
|
125 } |
101 // Obtain the completion code for this CActive obj. |
126 // Obtain the completion code for this CActive obj. |
102 TInt completionCode(iStatus.Int()); |
127 TInt completionCode(iStatus.Int()); |
103 TBuf<MAX_DSTRLEN> aDescription; |
128 TBuf<MAX_DSTRLEN> aDescription; |
104 TInt err(0); |
129 TInt err(0); |
105 |
130 |
208 |
234 |
209 |
235 |
210 case EBConfigured: // A B-Device only step! |
236 case EBConfigured: // A B-Device only step! |
211 { |
237 { |
212 test.Printf(_L("Into EBConfigured step...\n")); |
238 test.Printf(_L("Into EBConfigured step...\n")); |
|
239 OstTrace0(TRACE_NORMAL, CTESTCASE0678_RUNSTEPL_DUP02, "Into EBConfigured step...\n"); |
213 if (KTestCaseWatchdogTO == iStatus.Int()) |
240 if (KTestCaseWatchdogTO == iStatus.Int()) |
214 { |
241 { |
215 iCollector.DestroyObservers(); |
242 iCollector.DestroyObservers(); |
216 return TestFailed(KErrAbort, _L("Timeout")); |
243 return TestFailed(KErrAbort, _L("Timeout")); |
217 } |
244 } |
222 } |
249 } |
223 |
250 |
224 case EBSuspended: |
251 case EBSuspended: |
225 { |
252 { |
226 test.Printf(_L("Into EBSuspended step...\n")); |
253 test.Printf(_L("Into EBSuspended step...\n")); |
|
254 OstTrace0(TRACE_NORMAL, CTESTCASE0678_RUNSTEPL_DUP03, "Into EBSuspended step...\n"); |
227 if (KTestCaseWatchdogTO == iStatus.Int()) |
255 if (KTestCaseWatchdogTO == iStatus.Int()) |
228 { |
256 { |
229 iCollector.DestroyObservers(); |
257 iCollector.DestroyObservers(); |
230 return TestFailed(KErrAbort, _L("Timeout")); |
258 return TestFailed(KErrAbort, _L("Timeout")); |
231 } |
259 } |
232 |
260 |
233 // issue HNP |
261 // issue HNP |
234 test.Printf(_L("VBus present, attempting a swap.\n")); |
262 test.Printf(_L("VBus present, attempting a swap.\n")); |
|
263 OstTrace0(TRACE_NORMAL, CTESTCASE0678_RUNSTEPL_DUP04, "VBus present, attempting a swap.\n"); |
235 iCollector.AddRequiredNotification(EWatcherState, RUsbOtgDriver::EStateBHost); |
264 iCollector.AddRequiredNotification(EWatcherState, RUsbOtgDriver::EStateBHost); |
236 |
265 |
237 err = otgBusRequest(); // Request the host role |
266 err = otgBusRequest(); // Request the host role |
238 |
267 |
239 if (KErrNone != err) |
268 if (KErrNone != err) |
240 { |
269 { |
241 test.Printf(_L("BusRequest returned %d\n"),err); |
270 test.Printf(_L("BusRequest returned %d\n"),err); |
|
271 OstTrace1(TRACE_NORMAL, CTESTCASE0678_RUNSTEPL_DUP05, "BusRequest returned %d\n",err); |
242 return TestFailed(KErrAbort, _L("BusRequest() failed!")); |
272 return TestFailed(KErrAbort, _L("BusRequest() failed!")); |
243 } |
273 } |
244 |
274 |
245 iCaseStep = ESwappedRoles; |
275 iCaseStep = ESwappedRoles; |
246 SetActive(); |
276 SetActive(); |
248 } |
278 } |
249 |
279 |
250 case ESwappedRoles: |
280 case ESwappedRoles: |
251 { |
281 { |
252 test.Printf(_L("Into ESwappedRoles step...\n")); |
282 test.Printf(_L("Into ESwappedRoles step...\n")); |
|
283 OstTrace0(TRACE_NORMAL, CTESTCASE0678_RUNSTEPL_DUP06, "Into ESwappedRoles step...\n"); |
253 if (KTestCaseWatchdogTO == iStatus.Int()) |
284 if (KTestCaseWatchdogTO == iStatus.Int()) |
254 { |
285 { |
255 iCollector.DestroyObservers(); |
286 iCollector.DestroyObservers(); |
256 return TestFailed(KErrAbort, _L("Timeout")); |
287 return TestFailed(KErrAbort, _L("Timeout")); |
257 } |
288 } |
273 } |
304 } |
274 |
305 |
275 case EAConfigured: // A-Device only step |
306 case EAConfigured: // A-Device only step |
276 { |
307 { |
277 test.Printf(_L("Into EWaitTillAConfigured step...\n")); |
308 test.Printf(_L("Into EWaitTillAConfigured step...\n")); |
|
309 OstTrace0(TRACE_NORMAL, CTESTCASE0678_RUNSTEPL_DUP07, "Into EWaitTillAConfigured step...\n"); |
278 if (KTestCaseWatchdogTO == iStatus.Int()) |
310 if (KTestCaseWatchdogTO == iStatus.Int()) |
279 { |
311 { |
280 iCollector.DestroyObservers(); |
312 iCollector.DestroyObservers(); |
281 return TestFailed(KErrAbort, _L("Timeout")); |
313 return TestFailed(KErrAbort, _L("Timeout")); |
282 } |
314 } |
288 } |
320 } |
289 |
321 |
290 case EASuspended: // A-Device only step |
322 case EASuspended: // A-Device only step |
291 { |
323 { |
292 test.Printf(_L("Into EWaitTillASuspended step...\n")); |
324 test.Printf(_L("Into EWaitTillASuspended step...\n")); |
|
325 OstTrace0(TRACE_NORMAL, CTESTCASE0678_RUNSTEPL_DUP08, "Into EWaitTillASuspended step...\n"); |
293 if (KTestCaseWatchdogTO == iStatus.Int()) |
326 if (KTestCaseWatchdogTO == iStatus.Int()) |
294 { |
327 { |
295 iCollector.DestroyObservers(); |
328 iCollector.DestroyObservers(); |
296 return TestFailed(KErrAbort, _L("Timeout")); |
329 return TestFailed(KErrAbort, _L("Timeout")); |
297 } |
330 } |