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.
15 // 'A' connector detection
20 #include <e32std_private.h>
21 #include <u32std.h> // unicode builds
23 #include <e32base_private.h>
24 #include <e32Test.h> // RTest headder
25 #include "testcaseroot.h"
26 #include "testcasefactory.h"
27 #include "testcase0459.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-0459");
34 const TTestCaseFactoryReceipt<CTestCase0459> CTestCase0459::iFactoryReceipt(KTestCaseId);
36 CTestCase0459* CTestCase0459::NewL(TBool aHost)
39 CTestCase0459* self = new (ELeave) CTestCase0459(aHost);
40 CleanupStack::PushL(self);
42 CleanupStack::Pop(self);
47 CTestCase0459::CTestCase0459(TBool aHost)
48 : CTestCaseRoot(KTestCaseId, aHost)
58 void CTestCase0459::ConstructL()
66 CTestCase0459::~CTestCase0459()
74 void CTestCase0459::ExecuteTestCaseL()
77 iCaseStep = EPreconditions;
79 CActiveScheduler::Add(this);
85 void CTestCase0459::DescribePreconditions()
87 test.Printf(_L("Remove 'A' connector beforehand.\n"));
91 void CTestCase0459::DoCancel()
100 // handle event completion
101 void CTestCase0459::RunStepL()
104 // Obtain the completion code for this CActive obj.
105 TInt completionCode(iStatus.Int());
106 TBuf<MAX_DSTRLEN> aDescription;
111 iCaseStep = ELoadLdd;
114 iCaseStep = ELoadLdd;
118 // prompt to remove connector
119 test.Printf(KRemoveAConnectorPrompt);
120 test.Printf(KPressAnyKeyToContinue);
130 iCaseStep = ERegisterForEvents;
136 case ERegisterForEvents:
137 if (iDequeAttempts > 3)
139 return (TestFailed(KErrCorrupt, _L("<Error> too many irrelevant/incorrect events")));
142 test.Printf(KInsertAConnectorPrompt);
143 iCaseStep = ETestStateA;
144 test.Printf(_L("Waiting for OTG Event\n"));
146 otgQueueOtgEventRequest( iOTGEvent, iStatus);
149 iIDcheckStart.HomeTime();
154 // please turn on ID_PIN prompt (or programming API call)
155 // skipped untill we can do this.
163 OtgEventString(iOTGEvent, aDescription);
165 iIDcheckEnd.HomeTime();
166 TTimeIntervalMicroSeconds ivlMicro(iIDcheckEnd.MicroSecondsFrom(iIDcheckStart));
167 aMillisec = (TInt)(ivlMicro.Int64())/1000; // USB times are in uSec, but in ms for the user layer
168 test.Printf(_L("Received event %d '%S' status(%d) in %d ms"), iOTGEvent, &aDescription, completionCode, aMillisec);
170 // check the parameters gathered
171 if (RUsbOtgDriver::EEventAPlugInserted == iOTGEvent)
173 iCaseStep = EUnloadLdd;
174 // test if too quick!
175 if(aMillisec < KDelayDurationForQEmpty) // use 200ms - clocked at 17ms
177 // 'A' was in the receptacle when we started the stack, so it fires immediately, consume it and wait for another.
178 test.Printf(_L("Please first remove and then replace the A connector.\n"));
179 // wrong event in the Q already, keep at it
180 iCaseStep = ERegisterForEvents;
185 // wrong event in the Q already, keep at it
186 iCaseStep = ERegisterForEvents;
194 if (EFalse == StepUnloadLDD())
196 return TestFailed(KErrAbort,_L("unload Ldd failure"));
201 test.Printf(_L("<Error> unknown test step"));
203 return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));