|
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 "testcase0464.h" |
|
26 |
|
27 |
|
28 |
|
29 // the name below is used to add a pointer to our construction method to a pointer MAP in |
|
30 // the class factory |
|
31 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0464"); |
|
32 const TTestCaseFactoryReceipt<CTestCase0464> CTestCase0464::iFactoryReceipt(KTestCaseId); |
|
33 |
|
34 CTestCase0464* CTestCase0464::NewL(TBool aHost) |
|
35 { |
|
36 LOG_FUNC |
|
37 CTestCase0464* self = new (ELeave) CTestCase0464(aHost); |
|
38 CleanupStack::PushL(self); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop(self); |
|
41 return self; |
|
42 } |
|
43 |
|
44 |
|
45 CTestCase0464::CTestCase0464(TBool aHost) |
|
46 : CTestCaseRoot(KTestCaseId, aHost) |
|
47 { |
|
48 LOG_FUNC |
|
49 |
|
50 } |
|
51 |
|
52 |
|
53 /** |
|
54 ConstructL |
|
55 */ |
|
56 void CTestCase0464::ConstructL() |
|
57 { |
|
58 LOG_FUNC |
|
59 |
|
60 BaseConstructL(); |
|
61 } |
|
62 |
|
63 |
|
64 CTestCase0464::~CTestCase0464() |
|
65 { |
|
66 LOG_FUNC |
|
67 |
|
68 Cancel(); |
|
69 } |
|
70 |
|
71 |
|
72 void CTestCase0464::ExecuteTestCaseL() |
|
73 { |
|
74 LOG_FUNC |
|
75 iCaseStep = EPreconditions; |
|
76 |
|
77 CActiveScheduler::Add(this); |
|
78 SelfComplete(); |
|
79 } |
|
80 |
|
81 |
|
82 void CTestCase0464::DescribePreconditions() |
|
83 { |
|
84 test.Printf(_L("Insert 'A' connector beforehand.\n")); |
|
85 } |
|
86 |
|
87 |
|
88 void CTestCase0464::DoCancel() |
|
89 { |
|
90 LOG_FUNC |
|
91 |
|
92 // cancel our timer |
|
93 iTimer.Cancel(); |
|
94 } |
|
95 |
|
96 |
|
97 void CTestCase0464::CancelKB(CTestCaseRoot *pThis) |
|
98 { |
|
99 CTestCase0464 * p = REINTERPRET_CAST(CTestCase0464 *,pThis); |
|
100 // cancel any pending call, and then complete our active obj with a timeout value |
|
101 |
|
102 p->iConsole->ReadCancel(); |
|
103 |
|
104 } |
|
105 |
|
106 |
|
107 // handle event completion |
|
108 void CTestCase0464::RunStepL() |
|
109 { |
|
110 LOG_FUNC |
|
111 // Obtain the completion code for this CActive obj. |
|
112 TInt completionCode(iStatus.Int()); |
|
113 TBuf<MAX_DSTRLEN> aDescription; |
|
114 TInt err(0); |
|
115 |
|
116 switch(iCaseStep) |
|
117 { |
|
118 case EPreconditions: |
|
119 iCaseStep = ELoadLdd; |
|
120 if (iAutomated) |
|
121 { |
|
122 iCaseStep = ELoadLdd; |
|
123 SelfComplete(); |
|
124 break; |
|
125 } |
|
126 // prompt to insert 'A' connector |
|
127 test.Printf(KInsertAConnectorPrompt); |
|
128 test.Printf(KPressAnyKeyToContinue); |
|
129 RequestCharacter(); |
|
130 break; |
|
131 |
|
132 case ELoadLdd: |
|
133 if (!StepLoadLDD()) |
|
134 { |
|
135 break; |
|
136 } |
|
137 |
|
138 iCaseStep = EDriveBus; |
|
139 SelfComplete(); |
|
140 break; |
|
141 |
|
142 case EDriveBus: |
|
143 LOG_VERBOSE1(_L("Turn ON VBus\n")) |
|
144 err = otgBusRequest(); |
|
145 if (KErrNone != err) |
|
146 { |
|
147 return TestFailed(KErrAbort, _L("Raise VBus - RUsbOtgDriver::BusRequest() FAILED!")); |
|
148 } |
|
149 iCaseStep = EUnloadLdd; |
|
150 SelfComplete(); |
|
151 break; |
|
152 |
|
153 case EUnloadLdd: |
|
154 LOG_VERBOSE1(_L("Unload.\n")) |
|
155 if (EFalse == StepUnloadLDD()) |
|
156 return TestFailed(KErrAbort,_L("unload Ldd failure")); |
|
157 test.Printf(_L("Measure VBus =0 and then press Y or N to continue.")); |
|
158 RequestCharacter(); |
|
159 iCaseStep = EVerifyVBusGone; |
|
160 break; |
|
161 |
|
162 case EVerifyVBusGone: |
|
163 LOG_VERBOSE1(_L("Test !VBus after unload.\n")) |
|
164 // test key response (or via an API) |
|
165 if (('y' == iKeyCodeInput) ||('Y' == iKeyCodeInput)) |
|
166 { |
|
167 test.Printf(_L("VBUS drop 'seen' \n")); |
|
168 SelfComplete(); |
|
169 } |
|
170 else |
|
171 { |
|
172 return TestFailed(KErrAbort, _L("VBus drop not 'seen' - FAILED!")); |
|
173 } |
|
174 iCaseStep = ELastStep; |
|
175 break; |
|
176 |
|
177 case ELastStep: |
|
178 return TestPassed(); |
|
179 |
|
180 default: |
|
181 test.Printf(_L("<Error> unknown test step")); |
|
182 Cancel(); |
|
183 return (TestFailed(KErrCorrupt, _L("<Error> unknown test step"))); |
|
184 |
|
185 } |
|
186 } |
|
187 |
|
188 |