Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include <e32std_private.h>
20 #include <u32std.h> // unicode builds
22 #include <e32base_private.h>
23 #include <e32Test.h> // RTest headder
24 #include "testcaseroot.h"
25 #include "testcasewd.h"
26 #include "testcase0465.h"
31 // the name below is used to add a pointer to our construction method to a pointer MAP in
33 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0465");
34 const TTestCaseFactoryReceipt<CTestCase0465> CTestCase0465::iFactoryReceipt(KTestCaseId);
36 CTestCase0465* CTestCase0465::NewL(TBool aHost)
39 CTestCase0465* self = new (ELeave) CTestCase0465(aHost);
40 CleanupStack::PushL(self);
42 CleanupStack::Pop(self);
47 CTestCase0465::CTestCase0465(TBool aHost)
48 : CTestCaseRoot(KTestCaseId, aHost)
58 void CTestCase0465::ConstructL()
61 iWDTimer = CTestCaseWatchdog::NewL();
67 CTestCase0465::~CTestCase0465()
77 void CTestCase0465::ExecuteTestCaseL()
80 iCaseStep = EPreconditions;
82 iRepeats = KOperationRetriesMax; // VBus event rise retries
84 CActiveScheduler::Add(this);
90 void CTestCase0465::DoCancel()
99 void CTestCase0465::CancelKB(CTestCaseRoot *pThis)
101 CTestCase0465 * p = REINTERPRET_CAST(CTestCase0465 *,pThis);
102 // cancel the pending call
104 p->iConsole->ReadCancel();
109 void CTestCase0465::CancelDrive(CTestCaseRoot *pThis)
111 CTestCase0465 * p = REINTERPRET_CAST(CTestCase0465 *,pThis);
112 // cancel any pending call, and then complete our active obj with a timeout value
113 p->SelfComplete(KTestCaseWatchdogTO);
117 // This test result depends on all the ID detection tests and the VBus driving and dropping tests have not yet passed
118 void CTestCase0465::DescribePreconditions()
120 test.Printf(_L("BEFORE running this test\n"));
121 test.Printf(_L("\n"));
122 test.Printf(_L("Insert 'A' connector\n"));
123 test.Printf(_L("\n"));
124 test.Printf(_L("Confirm passing tests\n"));
125 test.Printf(_L("\n"));
126 test.Printf(_L("ID_PIN detection\n"));
127 test.Printf(_L("VBus Driving\n"));
128 test.Printf(_L("\n"));
132 // handle event completion
133 void CTestCase0465::RunStepL()
136 // Obtain the completion code for this CActive obj.
137 TInt completionCode(iStatus.Int());
138 TBuf<MAX_DSTRLEN> aDescription;
144 iCaseStep = ELoadLdd;
147 iCaseStep = ELoadLdd;
151 // prompt to insert connector
152 test.Printf(_L("\n"));
153 test.Printf(KInsertAConnectorPrompt);
154 test.Printf(_L("\n"));
155 test.Printf(KPressAnyKeyToContinue);
156 test.Printf(_L("\n"));
161 // 1. load the LDD and init.
166 iCaseStep = EDriveVBus;
172 // wait for 100 ms to allow the stack time to settle
174 err = otgBusRequest();
177 return TestFailed(KErrAbort, _L("Raise VBus - RUsbOtgDriver::BusRequest() FAILED!"));
180 // wait for 1000 ms as per test document
181 User::After(1000000);
183 // test for VBus rise next
184 otgQueueOtgEventRequest( iOTGEvent, iStatus );
186 iCaseStep = EVerifyVBus;
190 // 3. get VBus rise event
191 iCaseStep = EUnloadLdd;
192 OtgEventString(iOTGEvent, aDescription);
193 test.Printf(_L("Received event %d '%S' status(%d)\n"), iOTGEvent, &aDescription, completionCode);
195 if (iOTGEvent != RUsbOtgDriver::EEventVbusRaised)
197 iCaseStep = EVerifyVBus;
201 return TestFailed(KErrAbort, _L("Raise VBus event not detected. FAILED!"));
204 otgQueueOtgEventRequest( iOTGEvent, iStatus );
208 test.Printf(_L("VBus seen OK.\n"));
215 if (EFalse == StepUnloadLDD())
217 return TestFailed(KErrAbort,_L("unload Ldd failure"));
220 // wait for 100 ms to allow the stack time to settle
223 test.Printf(_L("Use meter or oscilloscope\n"));
224 test.Printf(_L("to measure VBUS, which should\n"));
225 test.Printf(_L("have dropped\n"));
226 test.Printf(_L("\n"));
227 test.Printf(_L("Is it below 0.2 volts?\n"));
228 test.Printf(_L("\n"));
229 test.Printf(_L("Select Y or N to continue\n"));
231 iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &CancelKB);
232 iCaseStep = EVerifyBusGone;
236 // since the LDD is gone, there is no OTGDI API from here on
237 if (KTestCaseWatchdogTO == iStatus.Int())
239 return TestFailed(KErrAbort, _L("Operator response timeout"));
243 if (('y' == iKeyCodeInput) ||('Y' == iKeyCodeInput))
245 test.Printf(_L("VBUS 'drop' seen\n"));
250 return TestFailed(KErrAbort, _L("VBus drop NOT 'seen' - FAILED!"));
252 iCaseStep = ELastStep;
260 test.Printf(_L("<Error> unknown test step\n"));
262 return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));