sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // @internalComponent sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include // unicode builds sl@0: #include sl@0: #include sl@0: #include // RTest headder sl@0: #include "testcaseroot.h" sl@0: #include "testcasewd.h" sl@0: #include "testcase0671.h" sl@0: sl@0: sl@0: sl@0: // the name below is used to add a pointer to our construction method to a pointer MAP in sl@0: // the class factory sl@0: _LIT(KTestCaseId,"PBASE-USB_OTGDI-0671"); sl@0: const TTestCaseFactoryReceipt CTestCase0671::iFactoryReceipt(KTestCaseId); sl@0: sl@0: CTestCase0671* CTestCase0671::NewL(TBool aHost) sl@0: { sl@0: LOG_FUNC sl@0: CTestCase0671* self = new (ELeave) CTestCase0671(aHost); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: sl@0: CTestCase0671::CTestCase0671(TBool aHost) sl@0: : CTestCaseRoot(KTestCaseId, aHost) sl@0: { sl@0: LOG_FUNC sl@0: sl@0: } sl@0: sl@0: sl@0: /** sl@0: ConstructL sl@0: */ sl@0: void CTestCase0671::ConstructL() sl@0: { sl@0: iWDTimer = CTestCaseWatchdog::NewL(); sl@0: sl@0: BaseConstructL(); sl@0: } sl@0: sl@0: sl@0: CTestCase0671::~CTestCase0671() sl@0: { sl@0: sl@0: Cancel(); sl@0: delete iWDTimer; sl@0: } sl@0: sl@0: sl@0: void CTestCase0671::ExecuteTestCaseL() sl@0: { sl@0: iCaseStep = EPreconditions; sl@0: iRepeats = KOperationRetriesMax; // VBus event rise retries sl@0: CActiveScheduler::Add(this); sl@0: SelfComplete(); sl@0: sl@0: } sl@0: sl@0: sl@0: void CTestCase0671::DoCancel() sl@0: { sl@0: LOG_FUNC sl@0: sl@0: // cancel our timer sl@0: iTimer.Cancel(); sl@0: } sl@0: sl@0: sl@0: void CTestCase0671::CancelKB(CTestCaseRoot *pThis) sl@0: { sl@0: CTestCase0671 * p = REINTERPRET_CAST(CTestCase0671 *,pThis); sl@0: sl@0: // cancel the pending call sl@0: p->iConsole->ReadCancel(); sl@0: } sl@0: sl@0: sl@0: void CTestCase0671::CancelDrive(CTestCaseRoot *pThis) sl@0: { sl@0: CTestCase0671 * p = REINTERPRET_CAST(CTestCase0671 *,pThis); sl@0: // cancel any pending call, and then complete our active obj with a timeout value sl@0: p->SelfComplete(KTestCaseWatchdogTO); sl@0: } sl@0: sl@0: sl@0: void CTestCase0671::DescribePreconditions() sl@0: { sl@0: // H4 width **************************** sl@0: test.Printf(_L("***************************\n")); sl@0: test.Printf(_L("* This test uses a Mini-A *\n")); sl@0: test.Printf(_L("* to Mini-B cable to link *\n")); sl@0: test.Printf(_L("* the H4 board to the OPT *\n")); sl@0: test.Printf(_L("* and makes use of the *\n")); sl@0: test.Printf(_L("* USB OPT test code *\n")); sl@0: test.Printf(_L("***************************\n")); sl@0: } sl@0: sl@0: sl@0: // handle event completion sl@0: void CTestCase0671::RunStepL() sl@0: { sl@0: LOG_FUNC sl@0: // Obtain the completion code for this CActive obj. sl@0: TInt completionCode(iStatus.Int()); sl@0: TBuf aDescription; sl@0: sl@0: switch(iCaseStep) sl@0: { sl@0: case EPreconditions: sl@0: if (iAutomated) sl@0: { sl@0: return TestFailed(KErrAbort,_L("This Test Cannot Run in Automated Mode")); sl@0: } sl@0: SelfComplete(); sl@0: iCaseStep = ELoadWithOptTestMode; sl@0: break; sl@0: sl@0: case ELoadWithOptTestMode: sl@0: if (!StepLoadClient(0x0671/*use default settings for SRP/HNP support*/)) sl@0: { sl@0: return TestFailed(KErrAbort,_L("Client Load Failure")); sl@0: } sl@0: StepSetOptActive(); sl@0: if (!StepLoadLDD()) sl@0: { sl@0: return TestFailed(KErrAbort,_L("OTG Load Failure")); sl@0: } sl@0: iCaseStep = EConnectAtoB; sl@0: SelfComplete(); sl@0: break; sl@0: sl@0: case EConnectAtoB: sl@0: // H4 width **************************** sl@0: test.Printf(_L("\n")); sl@0: test.Printf(_L("***********************\n")); sl@0: test.Printf(_L("Connect H4(B) to OPT(A)\n")); sl@0: test.Printf(KPressAnyKeyToContinue); sl@0: sl@0: iCaseStep = EStartOptTD5_5; sl@0: RequestCharacter(); sl@0: break; sl@0: sl@0: case EStartOptTD5_5: sl@0: // H4 width **************************** sl@0: test.Printf(_L("On the OPT, select:\n")); sl@0: test.Printf(_L(" Certified FS-B-UUT Test\n")); sl@0: test.Printf(_L(" Test TD.5.5\n")); sl@0: test.Printf(_L(" And then Click 'Run' ")); sl@0: test.Printf(_L(" When test starts, press any key")); sl@0: iCaseStep = EPromptYOpt5_5; sl@0: RequestCharacter(); sl@0: break; sl@0: sl@0: case EPromptYOpt5_5: sl@0: iCaseStep = EConfirmOpt5_5; sl@0: test.Printf(_L("Did it PASS (Y/N)?")); sl@0: RequestCharacter(); // 30 seconds for user input sl@0: iWDTimer->IssueRequest(KDelayDurationForTest4_5, this, &CancelKB); sl@0: break; sl@0: sl@0: case EConfirmOpt5_5: sl@0: // Check watchdog timeout, assume it failed sl@0: if (KTestCaseWatchdogTO == iStatus.Int()) sl@0: { sl@0: // H4 width **************************** sl@0: return TestFailed(KErrAbort, _L("OPT timeout - Test Failed")); sl@0: } sl@0: iWDTimer->Cancel(); sl@0: sl@0: // Check user response, look only for 'Y' sl@0: if (('y' == iKeyCodeInput) ||('Y' == iKeyCodeInput)) sl@0: { sl@0: iCaseStep = EUnloadLdd; sl@0: SelfComplete(); sl@0: } sl@0: else sl@0: { sl@0: return TestFailed(KErrAbort, _L("TD.5.5 - FAILED!")); sl@0: } sl@0: break; sl@0: sl@0: case EUnloadLdd: sl@0: // unload otg sl@0: if (!StepUnloadLDD()) sl@0: { sl@0: return TestFailed(KErrAbort,_L("OTG Unload Failure")); sl@0: } sl@0: // unload client sl@0: if (!StepUnloadClient()) sl@0: { sl@0: return TestFailed(KErrAbort,_L("Client Unload Failure")); sl@0: } sl@0: iCaseStep = ELastStep; sl@0: SelfComplete(); sl@0: break; sl@0: sl@0: case ELastStep: sl@0: TestPassed(); sl@0: break; sl@0: sl@0: default: sl@0: test.Printf(_L(" unknown test step")); sl@0: Cancel(); sl@0: return (TestFailed(KErrCorrupt, _L(" unknown test step"))); sl@0: } sl@0: } sl@0: