First public contribution.
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 "testcase0671.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-0671");
33 const TTestCaseFactoryReceipt<CTestCase0671> CTestCase0671::iFactoryReceipt(KTestCaseId);
35 CTestCase0671* CTestCase0671::NewL(TBool aHost)
38 CTestCase0671* self = new (ELeave) CTestCase0671(aHost);
39 CleanupStack::PushL(self);
41 CleanupStack::Pop(self);
46 CTestCase0671::CTestCase0671(TBool aHost)
47 : CTestCaseRoot(KTestCaseId, aHost)
57 void CTestCase0671::ConstructL()
59 iWDTimer = CTestCaseWatchdog::NewL();
65 CTestCase0671::~CTestCase0671()
73 void CTestCase0671::ExecuteTestCaseL()
75 iCaseStep = EPreconditions;
76 iRepeats = KOperationRetriesMax; // VBus event rise retries
77 CActiveScheduler::Add(this);
83 void CTestCase0671::DoCancel()
92 void CTestCase0671::CancelKB(CTestCaseRoot *pThis)
94 CTestCase0671 * p = REINTERPRET_CAST(CTestCase0671 *,pThis);
96 // cancel the pending call
97 p->iConsole->ReadCancel();
101 void CTestCase0671::CancelDrive(CTestCaseRoot *pThis)
103 CTestCase0671 * p = REINTERPRET_CAST(CTestCase0671 *,pThis);
104 // cancel any pending call, and then complete our active obj with a timeout value
105 p->SelfComplete(KTestCaseWatchdogTO);
109 void CTestCase0671::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 CTestCase0671::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(0x0671/*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 test.Printf(_L("Connect H4(B) to OPT(A)\n"));
160 test.Printf(KPressAnyKeyToContinue);
162 iCaseStep = EStartOptTD5_5;
167 // H4 width ****************************
168 test.Printf(_L("On the OPT, select:\n"));
169 test.Printf(_L(" Certified FS-B-UUT Test\n"));
170 test.Printf(_L(" Test TD.5.5\n"));
171 test.Printf(_L(" And then Click 'Run' "));
172 test.Printf(_L(" When test starts, press any key"));
173 iCaseStep = EPromptYOpt5_5;
178 iCaseStep = EConfirmOpt5_5;
179 test.Printf(_L("Did it PASS (Y/N)?"));
180 RequestCharacter(); // 30 seconds for user input
181 iWDTimer->IssueRequest(KDelayDurationForTest4_5, this, &CancelKB);
185 // Check watchdog timeout, assume it failed
186 if (KTestCaseWatchdogTO == iStatus.Int())
188 // H4 width ****************************
189 return TestFailed(KErrAbort, _L("OPT timeout - Test Failed"));
193 // Check user response, look only for 'Y'
194 if (('y' == iKeyCodeInput) ||('Y' == iKeyCodeInput))
196 iCaseStep = EUnloadLdd;
201 return TestFailed(KErrAbort, _L("TD.5.5 - FAILED!"));
207 if (!StepUnloadLDD())
209 return TestFailed(KErrAbort,_L("OTG Unload Failure"));
212 if (!StepUnloadClient())
214 return TestFailed(KErrAbort,_L("Client Unload Failure"));
216 iCaseStep = ELastStep;
225 test.Printf(_L("<Error> unknown test step"));
227 return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));