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 "testcase0466.h"
30 // the name below is used to add a pointer to our construction method to a pointer MAP in
32 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0466");
33 const TTestCaseFactoryReceipt<CTestCase0466> CTestCase0466::iFactoryReceipt(KTestCaseId);
35 CTestCase0466* CTestCase0466::NewL(TBool aHost)
38 CTestCase0466* self = new (ELeave) CTestCase0466(aHost);
39 CleanupStack::PushL(self);
41 CleanupStack::Pop(self);
46 CTestCase0466::CTestCase0466(TBool aHost)
47 : CTestCaseRoot(KTestCaseId, aHost)
57 void CTestCase0466::ConstructL()
60 iWDTimer = CTestCaseWatchdog::NewL();
66 CTestCase0466::~CTestCase0466()
75 void CTestCase0466::ExecuteTestCaseL()
78 iCaseStep = EPreconditions;
80 iRepeats = KOperationRetriesMax;
82 CActiveScheduler::Add(this);
88 void CTestCase0466::DescribePreconditions()
90 test.Printf(_L("BEFORE running this test\n"));
91 test.Printf(_L("\n"));
92 test.Printf(_L("Insert the connector\n"));
93 test.Printf(_L("from the OET with SW9\n"));
94 test.Printf(_L("set to 'A-DEVICE' and\n"));
95 test.Printf(_L("all other switches OFF\n"));
96 test.Printf(_L("\n"));
97 test.Printf(_L("Confirm passing tests\n"));
98 test.Printf(_L("\n"));
99 test.Printf(_L("ID_PIN detection\n"));
100 test.Printf(_L("VBus Driving\n"));
101 test.Printf(_L("\n"));
105 void CTestCase0466::DoCancel()
114 void CTestCase0466::CancelDrive(CTestCaseRoot *pThis)
116 CTestCase0466 * p = REINTERPRET_CAST(CTestCase0466 *,pThis);
117 // cancel any pending call, and then complete our active obj with a timeout value
118 p->SelfComplete(KTestCaseWatchdogTO);
123 // handle event completion
124 void CTestCase0466::RunStepL()
127 // Obtain the completion code for this CActive obj.
128 TInt completionCode(iStatus.Int());
129 TBuf<MAX_DSTRLEN> aDescription;
135 iCaseStep = ELoadLdd;
138 iCaseStep = ELoadLdd;
142 // prompt to insert connector
143 test.Printf(_L("\n"));
144 test.Printf(KInsertAConnectorPrompt);
145 test.Printf(_L("\n"));
146 test.Printf(KPressAnyKeyToContinue);
147 test.Printf(_L("\n"));
157 iCaseStep = EDriveBus;
163 // wait for 100 ms to allow the stack time to settle
167 // NOTE: A-Plug must be inserted because it is illegal to power VBus unless
168 // A-Plug is detected (ID pin is low). The Thunk checks this.
169 err = otgBusRequest();
173 return TestFailed(KErrAbort, _L("Raise VBus - RUsbOtgDriver::BusRequest() FAILED!"));
176 // wait for 1 second as described in the test document
177 User::After(1000000);
179 // subscribe to error events...
180 otgQueueOtgMessageRequest(iOTGMessage, iStatus);
183 // ...and tell user to apply load
184 test.Printf(_L("\n"));
185 test.Printf(_L("************************\n"));
186 test.Printf(_L("* Using SW4 on the OET *\n"));
187 test.Printf(_L("* Apply 100mA LOAD now *\n"));
188 test.Printf(_L("************************\n"));
189 test.Printf(_L("\n"));
191 iCaseStep = EVerifyBusFail;
197 OtgMessageString(iOTGMessage, aDescription);
198 test.Printf(_L("Received message %d '%S' status(%d)\n"), iOTGMessage, &aDescription, completionCode);
200 if (RUsbOtgDriver::EMessageVbusError == iOTGMessage)
202 err = otgBusClearError();
206 return TestFailed(KErrAbort, _L("VBUS Error Clear - FAILED!"));
209 iCaseStep = EUnloadLdd;
217 return TestFailed(KErrAbort, _L("VBUS Fall FAILED!"));
220 otgQueueOtgMessageRequest(iOTGMessage, iStatus);
223 iCaseStep = EVerifyBusFail;
230 if (EFalse == StepUnloadLDD())
232 return TestFailed(KErrAbort,_L("unload Ldd failure"));
235 // remove 100ma Load - this reminds the user
236 test.Printf(_L("\n"));
237 test.Printf(_L("************************\n"));
238 test.Printf(_L("* Using SW4 on the OET *\n"));
239 test.Printf(_L("* Remove 100mA LOAD! *\n"));
240 test.Printf(_L("************************\n"));
241 test.Printf(_L("\n"));
243 iCaseStep = ELastStep;
245 test.Printf(KPressAnyKeyToContinue);
253 test.Printf(_L("<Error> unknown test step"));
255 return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));