50 } |
46 } |
51 |
47 |
52 |
48 |
53 void CTestCaseRoot::BaseConstructL() |
49 void CTestCaseRoot::BaseConstructL() |
54 { |
50 { |
55 if(gVerboseOutput) |
51 LOG_FUNC |
56 { |
|
57 OstTraceFunctionEntry0(CTESTCASEROOT_BASECONSTRUCTL); |
|
58 } |
|
59 |
52 |
60 |
53 |
61 TInt err(iTimer.CreateLocal()); |
54 TInt err(iTimer.CreateLocal()); |
62 if (err == KErrNone) |
55 if (err == KErrNone) |
63 { |
56 { |
64 LOG_VERBOSE1(_L("Test case timer created")); |
57 LOG_VERBOSE1(_L("Test case timer created")); |
65 if(gVerboseOutput) |
58 } |
66 { |
59 else |
67 OstTrace0(TRACE_VERBOSE, CTESTCASEROOT_BASECONSTRUCTL_DUP01, "Test case timer created"); |
60 { |
68 } |
61 RDebug::Printf("<Error %d> Test case timer could not be created",err); |
69 } |
|
70 else |
|
71 { |
|
72 OstTrace1(TRACE_NORMAL, CTESTCASEROOT_BASECONSTRUCTL_DUP02, "<Error %d> Test case timer could not be created",err); |
|
73 User::Leave(err); |
62 User::Leave(err); |
74 } |
63 } |
75 // |
64 // |
76 iConsole = test.Console(); |
65 iConsole = test.Console(); |
77 iRequestedChar = EFalse; |
66 iRequestedChar = EFalse; |
78 } |
67 } |
79 |
68 |
80 |
69 |
81 CTestCaseRoot::~CTestCaseRoot() |
70 CTestCaseRoot::~CTestCaseRoot() |
82 { |
71 { |
83 if(gVerboseOutput) |
72 LOG_FUNC |
84 { |
|
85 OstTraceFunctionEntry0(CTESTCASEROOT_DCTESTCASEROOT); |
|
86 } |
|
87 Cancel(); |
73 Cancel(); |
88 } |
74 } |
89 |
75 |
90 // utility GUI methods |
76 // utility GUI methods |
91 void CTestCaseRoot::DisplayTestCaseOptions() |
77 void CTestCaseRoot::DisplayTestCaseOptions() |
92 { |
78 { |
93 if(gVerboseOutput) |
79 LOG_FUNC |
94 { |
|
95 OstTraceFunctionEntry0(CTESTCASEROOT_DISPLAYTESTCASEOPTIONS); |
|
96 } |
|
97 |
80 |
98 // commonly overridden to display any options for that test |
81 // commonly overridden to display any options for that test |
99 test.Printf(_L("Press <ESC> to end the test.\n")); |
82 test.Printf(_L("Press <ESC> to end the test.\n")); |
100 OstTrace0(TRACE_NORMAL, CTESTCASEROOT_DISPLAYTESTCASEOPTIONS_DUP01, "Press <ESC> to end the test.\n"); |
|
101 } |
83 } |
102 |
84 |
103 |
85 |
104 /***********************************************************************/ |
86 /***********************************************************************/ |
105 // |
87 // |
264 } |
222 } |
265 |
223 |
266 |
224 |
267 void CTestCaseRoot::TestFailed(TInt aFailResult, const TDesC &aErrorDescription) |
225 void CTestCaseRoot::TestFailed(TInt aFailResult, const TDesC &aErrorDescription) |
268 { |
226 { |
269 if(gVerboseOutput) |
227 LOG_FUNC |
270 { |
|
271 OstTraceFunctionEntry0(CTESTCASEROOT_TESTFAILED); |
|
272 } |
|
273 iTestResult = aFailResult; |
228 iTestResult = aFailResult; |
274 test.Printf(_L("Test %S\n"), &TestCaseId()); |
229 test.Printf(_L("Test %S\n"), &TestCaseId()); |
275 OstTraceExt1(TRACE_NORMAL, CTESTCASEROOT_TESTFAILED_DUP01, "Test %S\n", TestCaseId()); |
|
276 test.Printf(_L("Failed (%d)\n"), aFailResult); |
230 test.Printf(_L("Failed (%d)\n"), aFailResult); |
277 OstTrace1(TRACE_NORMAL, CTESTCASEROOT_TESTFAILED_DUP02, "Failed (%d)\n", aFailResult); |
|
278 test.Printf(_L("%S!\n"), &aErrorDescription); |
231 test.Printf(_L("%S!\n"), &aErrorDescription); |
279 OstTraceExt1(TRACE_NORMAL, CTESTCASEROOT_TESTFAILED_DUP03, "%S!\n", aErrorDescription); |
|
280 if (!iAutomated) |
232 if (!iAutomated) |
281 { |
233 { |
282 test.Printf(_L("\n")); |
234 test.Printf(_L("\n")); |
283 OstTrace0(TRACE_NORMAL, CTESTCASEROOT_TESTFAILED_DUP04, "\n"); |
|
284 test.Printf(KPressAnyKeyToContinue); |
235 test.Printf(KPressAnyKeyToContinue); |
285 OstTrace0(TRACE_NORMAL, CTESTCASEROOT_TESTFAILED_DUP05, KPressAnyKeyToContinue); |
|
286 iConsole->Getch(); |
236 iConsole->Getch(); |
287 } |
237 } |
288 // the next call panics the framework! |
238 // the next call panics the framework! |
289 TestPolicy().SignalTestComplete(iTestResult); |
239 TestPolicy().SignalTestComplete(iTestResult); |
290 } |
240 } |
291 |
241 |
292 |
242 |
293 void CTestCaseRoot::TestFailed2(TInt aFailResult, const TDesC &aErrorDescription, TInt errorCode) |
243 void CTestCaseRoot::TestFailed2(TInt aFailResult, const TDesC &aErrorDescription, TInt errorCode) |
294 { |
244 { |
295 if(gVerboseOutput) |
245 LOG_FUNC |
296 { |
|
297 OstTraceFunctionEntry0(CTESTCASEROOT_TESTFAILED2); |
|
298 } |
|
299 iTestResult = aFailResult; |
246 iTestResult = aFailResult; |
300 test.Printf(_L("Test %S FAILED %d '%S %d'!\n"), |
247 test.Printf(_L("Test %S FAILED %d '%S %d'!\n"), |
301 &TestCaseId(), |
248 &TestCaseId(), |
302 aFailResult, |
249 aFailResult, |
303 &aErrorDescription, |
250 &aErrorDescription, |
304 errorCode); |
251 errorCode); |
305 OstTraceExt4(TRACE_NORMAL, CTESTCASEROOT_TESTFAILED2_DUP01, "Test %S FAILED %d '%S %d'!\n", |
|
306 TestCaseId(), |
|
307 aFailResult, |
|
308 aErrorDescription, |
|
309 errorCode); |
|
310 // the next call panics the framework! |
252 // the next call panics the framework! |
311 TestPolicy().SignalTestComplete(iTestResult); |
253 TestPolicy().SignalTestComplete(iTestResult); |
312 } |
254 } |
313 |
255 |
314 |
256 |
315 |
257 |
316 void CTestCaseRoot::TestPassed() |
258 void CTestCaseRoot::TestPassed() |
317 { |
259 { |
318 if(gVerboseOutput) |
260 LOG_FUNC |
319 { |
|
320 OstTraceFunctionEntry0(CTESTCASEROOT_TESTPASSED); |
|
321 } |
|
322 iTestResult = KErrNone; |
261 iTestResult = KErrNone; |
323 TestPolicy().SignalTestComplete(iTestResult); |
262 TestPolicy().SignalTestComplete(iTestResult); |
324 } |
263 } |
325 |
264 |
326 |
265 |
344 void CTestCaseRoot::PrintStepName(const TDesC &aStepName) |
283 void CTestCaseRoot::PrintStepName(const TDesC &aStepName) |
345 { |
284 { |
346 if (gVerboseOutput) |
285 if (gVerboseOutput) |
347 { |
286 { |
348 test.Printf(_L("--------------\n %S "), &aStepName); |
287 test.Printf(_L("--------------\n %S "), &aStepName); |
349 OstTraceExt1(TRACE_NORMAL, CTESTCASEROOT_PRINTSTEPNAME, "--------------\n %S ", aStepName); |
|
350 // B2B class method dumps the engine state |
288 // B2B class method dumps the engine state |
351 // |
289 // |
352 test.Printf(_L("\n--------------\n")); |
290 test.Printf(_L("\n--------------\n")); |
353 OstTrace0(TRACE_NORMAL, CTESTCASEROOT_PRINTSTEPNAME_DUP01, "\n--------------\n"); |
|
354 } |
291 } |
355 } |
292 } |
356 |
293 |
357 |
294 |
358 /* ************************************************************************************** |
295 /* ************************************************************************************** |
359 * |
296 * |
360 */ |
297 */ |
361 CTestCaseB2BRoot::CTestCaseB2BRoot(const TDesC& aTestCaseId, TBool aHost, TRequestStatus &aStatus) |
298 CTestCaseB2BRoot::CTestCaseB2BRoot(const TDesC& aTestCaseId, TBool aHost, TRequestStatus &aStatus) |
362 : CTestCaseRoot(aTestCaseId, aHost) , iCollector(aStatus) |
299 : CTestCaseRoot(aTestCaseId, aHost) , iCollector(aStatus) |
363 { |
300 { |
364 if(gVerboseOutput) |
301 LOG_FUNC |
365 { |
|
366 OstTraceFunctionEntry0(CTESTCASEB2BROOT_CTESTCASEB2BROOT); |
|
367 } |
|
368 |
302 |
369 } |
303 } |
370 |
304 |
371 |
305 |
372 CTestCaseB2BRoot::~CTestCaseB2BRoot() |
306 CTestCaseB2BRoot::~CTestCaseB2BRoot() |
373 { |
307 { |
374 if(gVerboseOutput) |
308 LOG_FUNC |
375 { |
|
376 OstTraceFunctionEntry0(CTESTCASEB2BROOT_DCTESTCASEB2BROOT); |
|
377 } |
|
378 |
309 |
379 } |
310 } |
380 |
311 |
381 /* Print step name : B2B override displays the OTG Engine state as well |
312 /* Print step name : B2B override displays the OTG Engine state as well |
382 */ |
313 */ |
383 void CTestCaseB2BRoot::PrintStepName(const TDesC &aStepName) |
314 void CTestCaseB2BRoot::PrintStepName(const TDesC &aStepName) |
384 { |
315 { |
385 if (gVerboseOutput) |
316 if (gVerboseOutput) |
386 { |
317 { |
387 test.Printf(_L("--------------\n %S "), &aStepName); |
318 test.Printf(_L("--------------\n %S "), &aStepName); |
388 OstTraceExt1(TRACE_NORMAL, CTESTCASEB2BROOT_PRINTSTEPNAME, "--------------\n %S ", aStepName); |
|
389 // engine state |
319 // engine state |
390 CNotifyWatcherBase *pWatcher = iCollector.GetWatcher(EWatcherState); |
320 CNotifyWatcherBase *pWatcher = iCollector.GetWatcher(EWatcherState); |
391 if (pWatcher) |
321 if (pWatcher) |
392 { |
322 { |
393 TBuf<MAX_DSTRLEN> aDescription; |
323 TBuf<MAX_DSTRLEN> aDescription; |
394 RUsbOtgDriver::TOtgState aState = static_cast<RUsbOtgDriver::TOtgState>(pWatcher->GetEventValue()); |
324 RUsbOtgDriver::TOtgState aState = static_cast<RUsbOtgDriver::TOtgState>(pWatcher->GetEventValue()); |
395 |
325 |
396 OtgStateString(aState, aDescription); |
326 OtgStateString(aState, aDescription); |
397 LOG_VERBOSE3(_L("OTGState %d '%S' \n"), aState, &aDescription); |
327 LOG_VERBOSE3(_L("OTGState %d '%S' \n"), aState, &aDescription); |
398 if(gVerboseOutput) |
|
399 { |
|
400 OstTraceExt2(TRACE_VERBOSE, CTESTCASEB2BROOT_PRINTSTEPNAME_DUP01, "OTGState %d '%S' \n", aState, aDescription); |
|
401 } |
|
402 } |
328 } |
403 test.Printf(_L(" : time = %dms\n--------------\n"), iCollector.DurationElapsed()); |
329 test.Printf(_L(" : time = %dms\n--------------\n"), iCollector.DurationElapsed()); |
404 OstTrace1(TRACE_NORMAL, CTESTCASEB2BROOT_PRINTSTEPNAME_DUP02, " : time = %dms\n--------------\n", iCollector.DurationElapsed()); |
|
405 } |
330 } |
406 } |
331 } |
407 |
332 |
408 /* Default implementation which describes this as a B2B test-case |
333 /* Default implementation which describes this as a B2B test-case |
409 */ |
334 */ |
410 void CTestCaseB2BRoot::DescribePreconditions() |
335 void CTestCaseB2BRoot::DescribePreconditions() |
411 { |
336 { |
412 test.Printf(KTestTypeB2BMsg); // B2B |
337 test.Printf(KTestTypeB2BMsg); // B2B |
413 OstTrace0(TRACE_NORMAL, CTESTCASEB2BROOT_DESCRIBEPRECONDITIONS, KTestTypeB2BMsg); // B2B |
|
414 if (gTestRoleMaster) |
338 if (gTestRoleMaster) |
415 { |
|
416 test.Printf(KRoleMasterMsg); |
339 test.Printf(KRoleMasterMsg); |
417 OstTrace0(TRACE_NORMAL, CTESTCASEB2BROOT_DESCRIBEPRECONDITIONS_DUP01, KRoleMasterMsg); |
340 else |
418 } |
|
419 else |
|
420 { |
|
421 test.Printf(KRoleSlaveMsg); |
341 test.Printf(KRoleSlaveMsg); |
422 OstTrace0(TRACE_NORMAL, CTESTCASEB2BROOT_DESCRIBEPRECONDITIONS_DUP02, KRoleSlaveMsg); |
|
423 } |
|
424 } |
342 } |
425 |
343 |
426 |
344 |
427 void CTestCaseB2BRoot::StepB2BPreconditions() |
345 void CTestCaseB2BRoot::StepB2BPreconditions() |
428 { |
346 { |
429 // prompt to insert connector |
347 // prompt to insert connector |
430 if (gTestRoleMaster) |
348 if (gTestRoleMaster) |
431 { // "B" device |
349 { // "B" device |
432 test.Printf(KInsertBCablePrompt); |
350 test.Printf(KInsertBCablePrompt); |
433 OstTrace0(TRACE_NORMAL, CTESTCASEB2BROOT_STEPB2BPRECONDITIONS, KInsertBCablePrompt); |
|
434 } |
351 } |
435 else |
352 else |
436 { |
353 { |
437 test.Printf(KInsertACablePrompt); |
354 test.Printf(KInsertACablePrompt); |
438 OstTrace0(TRACE_NORMAL, CTESTCASEB2BROOT_STEPB2BPRECONDITIONS_DUP01, KInsertACablePrompt); |
|
439 } |
355 } |
440 if (iAutomated) |
356 if (iAutomated) |
441 { |
357 { |
442 |
358 |
443 SelfComplete(); |
359 SelfComplete(); |
444 return; |
360 return; |
445 } |
361 } |
446 test.Printf(KPressAnyKeyToContinue); |
362 test.Printf(KPressAnyKeyToContinue); |
447 OstTrace0(TRACE_NORMAL, CTESTCASEB2BROOT_STEPB2BPRECONDITIONS_DUP02, KPressAnyKeyToContinue); |
|
448 RequestCharacter(); |
363 RequestCharacter(); |
449 } |
364 } |
450 |
365 |
451 |
366 |
452 /* Test for A or B plug as relevant for MASTER/SLAVE role, fail the test if wrong |
367 /* Test for A or B plug as relevant for MASTER/SLAVE role, fail the test if wrong |
477 /* Clears the expected event Q just before calling the step, but not the |
390 /* 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. |
391 * recieved Q since the step may still inspect it using the EventReceivedAlready() method. |
479 */ |
392 */ |
480 void CTestCaseB2BRoot::PreRunStep() |
393 void CTestCaseB2BRoot::PreRunStep() |
481 { |
394 { |
482 if(gVerboseOutput) |
395 LOG_FUNC |
483 { |
|
484 OstTraceFunctionEntry0(CTESTCASEB2BROOT_PRERUNSTEP); |
|
485 } |
|
486 |
396 |
487 iCollector.ClearAllEvents(EFalse, ETrue); |
397 iCollector.ClearAllEvents(EFalse, ETrue); |
488 } |
398 } |
489 |
399 |
490 |
400 |
491 void CTestCaseB2BRoot::PostRunStep() |
401 void CTestCaseB2BRoot::PostRunStep() |
492 { |
402 { |
493 if(gVerboseOutput) |
403 LOG_FUNC |
494 { |
|
495 OstTraceFunctionEntry0(CTESTCASEB2BROOT_POSTRUNSTEP); |
|
496 } |
|
497 // clear the recieved event Q, but not the expected Q |
404 // clear the recieved event Q, but not the expected Q |
498 iCollector.ClearAllEvents(ETrue, EFalse); |
405 iCollector.ClearAllEvents(ETrue, EFalse); |
499 |
406 |
500 } |
407 } |
501 |
408 |