0
|
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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// @internalComponent
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <e32std.h>
|
|
19 |
#include <e32std_private.h>
|
|
20 |
#include <u32std.h> // unicode builds
|
|
21 |
#include <e32base.h>
|
|
22 |
#include <e32base_private.h>
|
|
23 |
#include <e32Test.h> // RTest headder
|
|
24 |
#include "testcaseroot.h"
|
|
25 |
#include "testcasewd.h"
|
|
26 |
#include "testcase0469.h"
|
|
27 |
|
|
28 |
#define _REPEATS (oOpenIterations*3)
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
// the name below is used to add a pointer to our construction method to a pointer MAP in
|
|
33 |
// the class factory
|
|
34 |
_LIT(KTestCaseId,"PBASE-USB_OTGDI-0469");
|
|
35 |
const TTestCaseFactoryReceipt<CTestCase0469> CTestCase0469::iFactoryReceipt(KTestCaseId);
|
|
36 |
|
|
37 |
CTestCase0469* CTestCase0469::NewL(TBool aHost)
|
|
38 |
{
|
|
39 |
LOG_FUNC
|
|
40 |
CTestCase0469* self = new (ELeave) CTestCase0469(aHost);
|
|
41 |
CleanupStack::PushL(self);
|
|
42 |
self->ConstructL();
|
|
43 |
CleanupStack::Pop(self);
|
|
44 |
return self;
|
|
45 |
}
|
|
46 |
|
|
47 |
CTestCase0469::CTestCase0469(TBool aHost)
|
|
48 |
: CTestCaseB2BRoot(KTestCaseId, aHost, iStatus)
|
|
49 |
{
|
|
50 |
LOG_FUNC
|
|
51 |
|
|
52 |
}
|
|
53 |
|
|
54 |
/**
|
|
55 |
ConstructL
|
|
56 |
*/
|
|
57 |
void CTestCase0469::ConstructL()
|
|
58 |
{
|
|
59 |
LOG_FUNC
|
|
60 |
iDualRoleCase = EFalse; // Not back to back
|
|
61 |
BaseConstructL();
|
|
62 |
}
|
|
63 |
|
|
64 |
|
|
65 |
CTestCase0469::~CTestCase0469()
|
|
66 |
{
|
|
67 |
LOG_FUNC
|
|
68 |
iCollector.DestroyObservers();
|
|
69 |
Cancel();
|
|
70 |
}
|
|
71 |
|
|
72 |
|
|
73 |
void CTestCase0469::ExecuteTestCaseL()
|
|
74 |
{
|
|
75 |
LOG_FUNC
|
|
76 |
iCaseStep = EPreconditions;
|
|
77 |
iRepeats = 3;
|
|
78 |
|
|
79 |
CActiveScheduler::Add(this);
|
|
80 |
SelfComplete();
|
|
81 |
}
|
|
82 |
|
|
83 |
|
|
84 |
void CTestCase0469::DoCancel()
|
|
85 |
{
|
|
86 |
LOG_FUNC
|
|
87 |
// cancel our timer
|
|
88 |
iTimer.Cancel();
|
|
89 |
}
|
|
90 |
|
|
91 |
// handle event completion
|
|
92 |
void CTestCase0469::RunStepL()
|
|
93 |
{
|
|
94 |
LOG_FUNC
|
|
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;
|
|
100 |
|
|
101 |
switch(iCaseStep)
|
|
102 |
{
|
|
103 |
case EPreconditions:
|
|
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);
|
|
110 |
RequestCharacter();
|
|
111 |
break;
|
|
112 |
|
|
113 |
case ELoadLdd:
|
|
114 |
LOG_STEPNAME(_L("ELoadLdd"))
|
|
115 |
if (!StepLoadClient(0xF678/*use default settings for SRP/HNP support*/))
|
|
116 |
{
|
|
117 |
return TestFailed(KErrAbort, _L("Client Load Failure"));
|
|
118 |
}
|
|
119 |
|
|
120 |
if (!StepLoadLDD())
|
|
121 |
{
|
|
122 |
return TestFailed(KErrAbort, _L("OTG Load Failure"));
|
|
123 |
}
|
|
124 |
|
|
125 |
// subscribe to OTG states,events and messages now that it has loaded OK
|
|
126 |
TRAPD(result, iCollector.CreateObserversL(*this));
|
|
127 |
if (KErrNone != result)
|
|
128 |
{
|
|
129 |
return(TestFailed(KErrNoMemory, _L("Unable to create observers")));
|
|
130 |
}
|
|
131 |
iCollector.ClearAllEvents();
|
|
132 |
|
|
133 |
iCaseStep = ELoopControl;
|
|
134 |
|
|
135 |
iCollector.AddStepTimeout(KTestCase0469Timeout);
|
|
136 |
|
|
137 |
SelfComplete();
|
|
138 |
break;
|
|
139 |
|
|
140 |
case ELoopControl:
|
|
141 |
LOG_STEPNAME(_L("ELoopControl"))
|
|
142 |
|
|
143 |
// Check for timeout
|
|
144 |
if (KTestCaseWatchdogTO == iStatus.Int())
|
|
145 |
{
|
|
146 |
iCollector.DestroyObservers();
|
|
147 |
return TestFailed(KErrAbort, _L("Timeout"));
|
|
148 |
}
|
|
149 |
|
|
150 |
if (iRepeats--)
|
|
151 |
{
|
|
152 |
RDebug::Printf("ELoopControl around again %d", iRepeats);
|
|
153 |
iCaseStep = ETestVbusRise;
|
|
154 |
}
|
|
155 |
else
|
|
156 |
{
|
|
157 |
RDebug::Printf("ELoopControl we're done");
|
|
158 |
iCaseStep = EUnloadLdd;
|
|
159 |
}
|
|
160 |
SelfComplete();
|
|
161 |
break;
|
|
162 |
|
|
163 |
case ETestVbusRise:
|
|
164 |
LOG_STEPNAME(_L("ETestVbusRise"))
|
|
165 |
// Check for timeout
|
|
166 |
if (KTestCaseWatchdogTO == iStatus.Int())
|
|
167 |
{
|
|
168 |
iCollector.DestroyObservers();
|
|
169 |
return TestFailed(KErrAbort, _L("Timeout"));
|
|
170 |
}
|
|
171 |
|
|
172 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusRaised);
|
|
173 |
iCaseStep = ETestVbusFall;
|
|
174 |
test.Printf(KInsertAIntoPC);
|
|
175 |
SetActive();
|
|
176 |
break;
|
|
177 |
|
|
178 |
case ETestVbusFall:
|
|
179 |
LOG_STEPNAME(_L("ETestVbusFall"))
|
|
180 |
// Check for timeout
|
|
181 |
if (KTestCaseWatchdogTO == iStatus.Int())
|
|
182 |
{
|
|
183 |
iCollector.DestroyObservers();
|
|
184 |
return TestFailed(KErrAbort, _L("Timeout"));
|
|
185 |
}
|
|
186 |
|
|
187 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusDropped);
|
|
188 |
iCaseStep = ELoopControl;
|
|
189 |
test.Printf(KRemoveAFromPC);
|
|
190 |
SetActive();
|
|
191 |
break;
|
|
192 |
|
|
193 |
case EUnloadLdd:
|
|
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");
|
|
203 |
|
|
204 |
iCaseStep = ELastStep;
|
|
205 |
SelfComplete();
|
|
206 |
break;
|
|
207 |
|
|
208 |
case ELastStep:
|
|
209 |
LOG_STEPNAME(_L("ELastStep"))
|
|
210 |
TestPassed();
|
|
211 |
break;
|
|
212 |
|
|
213 |
default:
|
|
214 |
test.Printf(_L("<Error> unknown test step"));
|
|
215 |
Cancel();
|
|
216 |
return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
|
|
217 |
}
|
|
218 |
}
|
|
219 |
|