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 "testcase0466.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-0466"); sl@0: const TTestCaseFactoryReceipt CTestCase0466::iFactoryReceipt(KTestCaseId); sl@0: sl@0: CTestCase0466* CTestCase0466::NewL(TBool aHost) sl@0: { sl@0: LOG_FUNC sl@0: CTestCase0466* self = new (ELeave) CTestCase0466(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: CTestCase0466::CTestCase0466(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 CTestCase0466::ConstructL() sl@0: { sl@0: LOG_FUNC sl@0: iWDTimer = CTestCaseWatchdog::NewL(); sl@0: sl@0: BaseConstructL(); sl@0: } sl@0: sl@0: sl@0: CTestCase0466::~CTestCase0466() sl@0: { sl@0: LOG_FUNC sl@0: sl@0: Cancel(); sl@0: delete iWDTimer; sl@0: } sl@0: sl@0: sl@0: void CTestCase0466::ExecuteTestCaseL() sl@0: { sl@0: LOG_FUNC sl@0: iCaseStep = EPreconditions; sl@0: sl@0: iRepeats = KOperationRetriesMax; sl@0: sl@0: CActiveScheduler::Add(this); sl@0: SelfComplete(); sl@0: sl@0: } sl@0: sl@0: sl@0: void CTestCase0466::DescribePreconditions() sl@0: { sl@0: test.Printf(_L("BEFORE running this test\n")); sl@0: test.Printf(_L("\n")); sl@0: test.Printf(_L("Insert the connector\n")); sl@0: test.Printf(_L("from the OET with SW9\n")); sl@0: test.Printf(_L("set to 'A-DEVICE' and\n")); sl@0: test.Printf(_L("all other switches OFF\n")); sl@0: test.Printf(_L("\n")); sl@0: test.Printf(_L("Confirm passing tests\n")); sl@0: test.Printf(_L("\n")); sl@0: test.Printf(_L("ID_PIN detection\n")); sl@0: test.Printf(_L("VBus Driving\n")); sl@0: test.Printf(_L("\n")); sl@0: } sl@0: sl@0: sl@0: void CTestCase0466::DoCancel() sl@0: { sl@0: LOG_FUNC sl@0: sl@0: // cancel our timer sl@0: iTimer.Cancel(); sl@0: } sl@0: sl@0: // static cb helper sl@0: void CTestCase0466::CancelDrive(CTestCaseRoot *pThis) sl@0: { sl@0: CTestCase0466 * p = REINTERPRET_CAST(CTestCase0466 *,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: sl@0: // handle event completion sl@0: void CTestCase0466::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: TInt err(0); sl@0: sl@0: switch(iCaseStep) sl@0: { sl@0: case EPreconditions: sl@0: iCaseStep = ELoadLdd; sl@0: if (iAutomated) sl@0: { sl@0: iCaseStep = ELoadLdd; sl@0: SelfComplete(); sl@0: break; sl@0: } sl@0: // prompt to insert connector sl@0: test.Printf(_L("\n")); sl@0: test.Printf(KInsertAConnectorPrompt); sl@0: test.Printf(_L("\n")); sl@0: test.Printf(KPressAnyKeyToContinue); sl@0: test.Printf(_L("\n")); sl@0: RequestCharacter(); sl@0: break; sl@0: sl@0: case ELoadLdd: sl@0: if (!StepLoadLDD()) sl@0: { sl@0: break; sl@0: } sl@0: sl@0: iCaseStep = EDriveBus; sl@0: SelfComplete(); sl@0: break; sl@0: sl@0: // wait on sl@0: case EDriveBus: sl@0: // wait for 100 ms to allow the stack time to settle sl@0: User::After(100000); sl@0: sl@0: // drive VBus sl@0: // NOTE: A-Plug must be inserted because it is illegal to power VBus unless sl@0: // A-Plug is detected (ID pin is low). The Thunk checks this. sl@0: err = otgBusRequest(); sl@0: sl@0: if (KErrNone != err) sl@0: { sl@0: return TestFailed(KErrAbort, _L("Raise VBus - RUsbOtgDriver::BusRequest() FAILED!")); sl@0: } sl@0: sl@0: // wait for 1 second as described in the test document sl@0: User::After(1000000); sl@0: sl@0: // subscribe to error events... sl@0: otgQueueOtgMessageRequest(iOTGMessage, iStatus); sl@0: SetActive(); sl@0: sl@0: // ...and tell user to apply load sl@0: test.Printf(_L("\n")); sl@0: test.Printf(_L("************************\n")); sl@0: test.Printf(_L("* Using SW4 on the OET *\n")); sl@0: test.Printf(_L("* Apply 100mA LOAD now *\n")); sl@0: test.Printf(_L("************************\n")); sl@0: test.Printf(_L("\n")); sl@0: sl@0: iCaseStep = EVerifyBusFail; sl@0: sl@0: break; sl@0: sl@0: case EVerifyBusFail: sl@0: sl@0: OtgMessageString(iOTGMessage, aDescription); sl@0: test.Printf(_L("Received message %d '%S' status(%d)\n"), iOTGMessage, &aDescription, completionCode); sl@0: sl@0: if (RUsbOtgDriver::EMessageVbusError == iOTGMessage) sl@0: { sl@0: err = otgBusClearError(); sl@0: sl@0: if ( err ) sl@0: { sl@0: return TestFailed(KErrAbort, _L("VBUS Error Clear - FAILED!")); sl@0: } sl@0: sl@0: iCaseStep = EUnloadLdd; sl@0: SelfComplete(); sl@0: } sl@0: else sl@0: { sl@0: iRepeats--; sl@0: if (iRepeats <0) sl@0: { sl@0: return TestFailed(KErrAbort, _L("VBUS Fall FAILED!")); sl@0: } sl@0: sl@0: otgQueueOtgMessageRequest(iOTGMessage, iStatus); sl@0: SetActive(); sl@0: sl@0: iCaseStep = EVerifyBusFail; sl@0: } sl@0: sl@0: break; sl@0: sl@0: case EUnloadLdd: sl@0: sl@0: if (EFalse == StepUnloadLDD()) sl@0: { sl@0: return TestFailed(KErrAbort,_L("unload Ldd failure")); sl@0: } sl@0: sl@0: // remove 100ma Load - this reminds the user sl@0: test.Printf(_L("\n")); sl@0: test.Printf(_L("************************\n")); sl@0: test.Printf(_L("* Using SW4 on the OET *\n")); sl@0: test.Printf(_L("* Remove 100mA LOAD! *\n")); sl@0: test.Printf(_L("************************\n")); sl@0: test.Printf(_L("\n")); sl@0: sl@0: iCaseStep = ELastStep; sl@0: // press any key sl@0: test.Printf(KPressAnyKeyToContinue); sl@0: RequestCharacter(); sl@0: break; sl@0: sl@0: case ELastStep: sl@0: return TestPassed(); 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: sl@0: } sl@0: sl@0: