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 removal test
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 "testcase0460.h"
32 // the name below is used to add a pointer to our construction method to a pointer MAP in
34 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0460");
35 const TTestCaseFactoryReceipt<CTestCase0460> CTestCase0460::iFactoryReceipt(KTestCaseId);
37 CTestCase0460* CTestCase0460::NewL(TBool aHost)
40 CTestCase0460* self = new (ELeave) CTestCase0460(aHost);
41 CleanupStack::PushL(self);
43 CleanupStack::Pop(self);
48 CTestCase0460::CTestCase0460(TBool aHost)
49 : CTestCaseRoot(KTestCaseId, aHost)
59 void CTestCase0460::ConstructL()
67 CTestCase0460::~CTestCase0460()
75 void CTestCase0460::ExecuteTestCaseL()
78 iCaseStep = EPreconditions;
80 CActiveScheduler::Add(this);
86 void CTestCase0460::DescribePreconditions()
88 test.Printf(_L("Insert 'A' connector beforehand.\n"));
92 void CTestCase0460::DoCancel()
101 // handle event completion
102 void CTestCase0460::RunStepL()
105 // Obtain the completion code for this CActive obj.
106 TInt completionCode(iStatus.Int());
107 TBuf<MAX_DSTRLEN> aDescription;
112 iCaseStep = ELoadLdd;
115 iCaseStep = ELoadLdd;
119 // prompt to remove connector
120 test.Printf(KRemoveAConnectorPrompt);
121 test.Printf(KPressAnyKeyToContinue);
131 iCaseStep = ERegisterForEvents;
134 // prompt to insert connector
135 test.Printf(KInsertAConnectorPrompt);
136 test.Printf(KPressAnyKeyToContinue);
140 case ERegisterForEvents:
141 if (iDequeAttempts > KOperationRetriesMax)
143 return (TestFailed(KErrCorrupt, _L("<Error> too many irrelevant/incorrect events")));
145 iCaseStep = ETestStateA;
147 test.Printf(_L("Waiting for OTG Event\n"));
148 otgQueueOtgEventRequest( iOTGEvent, iStatus);
154 // API call for simulating ID_PIN is not implemented, so the user plugs in the cable,
155 // then test for A plug
161 OtgEventString(iOTGEvent, aDescription);
162 test.Printf(_L("Received event %d '%S' status(%d)"), iOTGEvent, &aDescription, completionCode);
163 if (RUsbOtgDriver::EEventAPlugInserted == iOTGEvent)
165 iCaseStep = EUnloadLdd;
169 // wrong event in the Q already, keep at it
170 iCaseStep = ERegisterForEvents;
179 if (EFalse == StepUnloadLDD())
180 return TestFailed(KErrAbort,_L("unload Ldd failure"));
185 test.Printf(_L("<Error> unknown test step"));
187 return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));