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 "testcase0670.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-0670");
33 const TTestCaseFactoryReceipt<CTestCase0670> CTestCase0670::iFactoryReceipt(KTestCaseId);
35 CTestCase0670* CTestCase0670::NewL(TBool aHost)
38 CTestCase0670* self = new (ELeave) CTestCase0670(aHost);
39 CleanupStack::PushL(self);
41 CleanupStack::Pop(self);
46 CTestCase0670::CTestCase0670(TBool aHost)
47 : CTestCaseRoot(KTestCaseId, aHost)
57 void CTestCase0670::ConstructL()
59 iWDTimer = CTestCaseWatchdog::NewL();
65 CTestCase0670::~CTestCase0670()
73 void CTestCase0670::ExecuteTestCaseL()
75 iCaseStep = EPreconditions;
76 iRepeats = KOperationRetriesMax; // VBus event rise retries
77 CActiveScheduler::Add(this);
83 void CTestCase0670::DoCancel()
92 void CTestCase0670::CancelKB(CTestCaseRoot *pThis)
94 CTestCase0670 * p = REINTERPRET_CAST(CTestCase0670 *,pThis);
96 // cancel the pending call
97 p->iConsole->ReadCancel();
101 void CTestCase0670::CancelDrive(CTestCaseRoot *pThis)
103 CTestCase0670 * p = REINTERPRET_CAST(CTestCase0670 *,pThis);
104 // cancel any pending call, and then complete our active obj with a timeout value
105 p->SelfComplete(KTestCaseWatchdogTO);
109 void CTestCase0670::DescribePreconditions()
111 // H4 width ****************************
112 test.Printf(_L("***************************\n"));
113 test.Printf(_L("* This test uses a Mini-A *\n"));
114 test.Printf(_L("* to Mini-B cable to link *\n"));
115 test.Printf(_L("* the H4 board to the OPT *\n"));
116 test.Printf(_L("* and makes use of the *\n"));
117 test.Printf(_L("* USB OPT test code *\n"));
118 test.Printf(_L("***************************\n"));
122 // handle event completion
123 void CTestCase0670::RunStepL()
126 // Obtain the completion code for this CActive obj.
127 TInt completionCode(iStatus.Int());
128 TBuf<MAX_DSTRLEN> aDescription;
135 return TestFailed(KErrAbort,_L("This Test Cannot Run in Automated Mode"));
138 iCaseStep = ELoadWithOptTestMode;
141 case ELoadWithOptTestMode:
142 if (!StepLoadClient(0x0670/*use default settings for SRP/HNP support*/))
144 return TestFailed(KErrAbort,_L("Client Load Failure"));
149 return TestFailed(KErrAbort,_L("OTG Load Failure"));
151 iCaseStep = EConnectAtoB;
156 // H4 width ****************************
157 test.Printf(_L("\n"));
158 test.Printf(_L("***********************\n"));
159 // WAIT_ON_KEYOP( "Connect H4(A) to OPT(B)\n");
160 test.Printf(_L("Connect H4(A) to OPT(B)\n"));
161 test.Printf(KPressAnyKeyToContinue);
163 iCaseStep = EStartOptTD4_5;
168 // H4 width ****************************
169 test.Printf(_L("On the OPT, select:\n"));
170 test.Printf(_L(" Certified FS-A-UUT Test\n"));
171 test.Printf(_L(" Test TD.4.5-2.9ms-100ms\n"));
172 test.Printf(_L(" And then Click 'Run' "));
173 test.Printf(_L(" When test starts, press any key"));
174 iCaseStep = EPromptYOpt4_5;
179 iCaseStep = EConfirmOpt4_5;
180 test.Printf(_L("Did it PASS (Y/N)?"));
181 RequestCharacter(); // 30 seconds for user input
182 iWDTimer->IssueRequest(KDelayDurationForTest4_5, this, &CancelKB);
186 // Check watchdog timeout, assume it failed
187 if (KTestCaseWatchdogTO == iStatus.Int())
189 // H4 width ****************************
190 return TestFailed(KErrAbort, _L("OPT timeout - Test Failed"));
194 // Check user response, look only for 'Y'
195 if (('y' == iKeyCodeInput) ||('Y' == iKeyCodeInput))
197 iCaseStep = EUnloadLdd;
202 return TestFailed(KErrAbort, _L("TD.4.5 - FAILED!"));
208 if (!StepUnloadLDD())
210 return TestFailed(KErrAbort,_L("OTG Unload Failure"));
213 if (!StepUnloadClient())
215 return TestFailed(KErrAbort,_L("Client Unload Failure"));
217 iCaseStep = ELastStep;
226 test.Printf(_L("<Error> unknown test step"));
228 return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));