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 "testcase0469.h"
28 #define _REPEATS (oOpenIterations*3)
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-0469");
35 const TTestCaseFactoryReceipt<CTestCase0469> CTestCase0469::iFactoryReceipt(KTestCaseId);
37 CTestCase0469* CTestCase0469::NewL(TBool aHost)
40 CTestCase0469* self = new (ELeave) CTestCase0469(aHost);
41 CleanupStack::PushL(self);
43 CleanupStack::Pop(self);
47 CTestCase0469::CTestCase0469(TBool aHost)
48 : CTestCaseB2BRoot(KTestCaseId, aHost, iStatus)
57 void CTestCase0469::ConstructL()
60 iDualRoleCase = EFalse; // Not back to back
65 CTestCase0469::~CTestCase0469()
68 iCollector.DestroyObservers();
73 void CTestCase0469::ExecuteTestCaseL()
76 iCaseStep = EPreconditions;
79 CActiveScheduler::Add(this);
84 void CTestCase0469::DoCancel()
91 // handle event completion
92 void CTestCase0469::RunStepL()
95 // Obtain the completion code for this CActive obj.
96 TInt completionCode(iStatus.Int());
97 TBuf<MAX_DSTRLEN> aDescription;
98 // 15 seconds, should be plenty of time for 3 cycles of plug pulling
99 const TInt KTestCase0469Timeout = 15000;
104 LOG_STEPNAME(_L("EPreconditions"))
105 iCaseStep = ELoadLdd;
106 // prompt to insert connectors
107 test.Printf(KInsertBCablePrompt);
108 test.Printf(KRemoveAFromPC);
109 test.Printf(KPressAnyKeyToContinue);
114 LOG_STEPNAME(_L("ELoadLdd"))
115 if (!StepLoadClient(0xF678/*use default settings for SRP/HNP support*/))
117 return TestFailed(KErrAbort, _L("Client Load Failure"));
122 return TestFailed(KErrAbort, _L("OTG Load Failure"));
125 // subscribe to OTG states,events and messages now that it has loaded OK
126 TRAPD(result, iCollector.CreateObserversL(*this));
127 if (KErrNone != result)
129 return(TestFailed(KErrNoMemory, _L("Unable to create observers")));
131 iCollector.ClearAllEvents();
133 iCaseStep = ELoopControl;
135 iCollector.AddStepTimeout(KTestCase0469Timeout);
141 LOG_STEPNAME(_L("ELoopControl"))
144 if (KTestCaseWatchdogTO == iStatus.Int())
146 iCollector.DestroyObservers();
147 return TestFailed(KErrAbort, _L("Timeout"));
152 RDebug::Printf("ELoopControl around again %d", iRepeats);
153 iCaseStep = ETestVbusRise;
157 RDebug::Printf("ELoopControl we're done");
158 iCaseStep = EUnloadLdd;
164 LOG_STEPNAME(_L("ETestVbusRise"))
166 if (KTestCaseWatchdogTO == iStatus.Int())
168 iCollector.DestroyObservers();
169 return TestFailed(KErrAbort, _L("Timeout"));
172 iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusRaised);
173 iCaseStep = ETestVbusFall;
174 test.Printf(KInsertAIntoPC);
179 LOG_STEPNAME(_L("ETestVbusFall"))
181 if (KTestCaseWatchdogTO == iStatus.Int())
183 iCollector.DestroyObservers();
184 return TestFailed(KErrAbort, _L("Timeout"));
187 iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusDropped);
188 iCaseStep = ELoopControl;
189 test.Printf(KRemoveAFromPC);
194 LOG_STEPNAME(_L("EUnloadLdd"))
195 iCollector.DestroyObservers();
196 RDebug::Printf("Destroyed observers");
197 if (EFalse == StepUnloadLDD())
198 return TestFailed(KErrAbort,_L("unload Ldd failure"));
199 RDebug::Printf("unloaded ldd");
200 if (!StepUnloadClient())
201 return TestFailed(KErrAbort,_L("Client Unload Failure"));
202 RDebug::Printf("unloaded client");
204 iCaseStep = ELastStep;
209 LOG_STEPNAME(_L("ELastStep"))
214 test.Printf(_L("<Error> unknown test step"));
216 return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));