|
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 // 'A' connector removal test |
|
16 // |
|
17 // |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <e32std_private.h> |
|
21 #include <u32std.h> // unicode builds |
|
22 #include <e32base.h> |
|
23 #include <e32base_private.h> |
|
24 #include <e32Test.h> // RTest headder |
|
25 #include "testcaseroot.h" |
|
26 #include "testcasefactory.h" |
|
27 #include "testcase0460.h" |
|
28 |
|
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-0460"); |
|
35 const TTestCaseFactoryReceipt<CTestCase0460> CTestCase0460::iFactoryReceipt(KTestCaseId); |
|
36 |
|
37 CTestCase0460* CTestCase0460::NewL(TBool aHost) |
|
38 { |
|
39 LOG_FUNC |
|
40 CTestCase0460* self = new (ELeave) CTestCase0460(aHost); |
|
41 CleanupStack::PushL(self); |
|
42 self->ConstructL(); |
|
43 CleanupStack::Pop(self); |
|
44 return self; |
|
45 } |
|
46 |
|
47 |
|
48 CTestCase0460::CTestCase0460(TBool aHost) |
|
49 : CTestCaseRoot(KTestCaseId, aHost) |
|
50 { |
|
51 LOG_FUNC |
|
52 |
|
53 } |
|
54 |
|
55 |
|
56 /** |
|
57 ConstructL |
|
58 */ |
|
59 void CTestCase0460::ConstructL() |
|
60 { |
|
61 LOG_FUNC |
|
62 |
|
63 BaseConstructL(); |
|
64 } |
|
65 |
|
66 |
|
67 CTestCase0460::~CTestCase0460() |
|
68 { |
|
69 LOG_FUNC |
|
70 |
|
71 Cancel(); |
|
72 } |
|
73 |
|
74 |
|
75 void CTestCase0460::ExecuteTestCaseL() |
|
76 { |
|
77 LOG_FUNC |
|
78 iCaseStep = EPreconditions; |
|
79 |
|
80 CActiveScheduler::Add(this); |
|
81 SelfComplete(); |
|
82 |
|
83 } |
|
84 |
|
85 |
|
86 void CTestCase0460::DescribePreconditions() |
|
87 { |
|
88 test.Printf(_L("Insert 'A' connector beforehand.\n")); |
|
89 } |
|
90 |
|
91 |
|
92 void CTestCase0460::DoCancel() |
|
93 { |
|
94 LOG_FUNC |
|
95 |
|
96 // cancel our timer |
|
97 iTimer.Cancel(); |
|
98 } |
|
99 |
|
100 |
|
101 // handle event completion |
|
102 void CTestCase0460::RunStepL() |
|
103 { |
|
104 LOG_FUNC |
|
105 // Obtain the completion code for this CActive obj. |
|
106 TInt completionCode(iStatus.Int()); |
|
107 TBuf<MAX_DSTRLEN> aDescription; |
|
108 |
|
109 switch(iCaseStep) |
|
110 { |
|
111 case EPreconditions: |
|
112 iCaseStep = ELoadLdd; |
|
113 if (iAutomated) |
|
114 { |
|
115 iCaseStep = ELoadLdd; |
|
116 SelfComplete(); |
|
117 break; |
|
118 } |
|
119 // prompt to remove connector |
|
120 test.Printf(KRemoveAConnectorPrompt); |
|
121 test.Printf(KPressAnyKeyToContinue); |
|
122 RequestCharacter(); |
|
123 break; |
|
124 |
|
125 case ELoadLdd: |
|
126 if (!StepLoadLDD()) |
|
127 { |
|
128 break; |
|
129 } |
|
130 |
|
131 iCaseStep = ERegisterForEvents; |
|
132 iDequeAttempts = 0; |
|
133 |
|
134 // prompt to insert connector |
|
135 test.Printf(KInsertAConnectorPrompt); |
|
136 test.Printf(KPressAnyKeyToContinue); |
|
137 RequestCharacter(); |
|
138 break; |
|
139 // wait on ID_PIN |
|
140 case ERegisterForEvents: |
|
141 if (iDequeAttempts > KOperationRetriesMax) |
|
142 { |
|
143 return (TestFailed(KErrCorrupt, _L("<Error> too many irrelevant/incorrect events"))); |
|
144 } |
|
145 iCaseStep = ETestStateA; |
|
146 |
|
147 test.Printf(_L("Waiting for OTG Event\n")); |
|
148 otgQueueOtgEventRequest( iOTGEvent, iStatus); |
|
149 |
|
150 SetActive(); |
|
151 break; |
|
152 |
|
153 case EDriveID_PIN: |
|
154 // API call for simulating ID_PIN is not implemented, so the user plugs in the cable, |
|
155 // then test for A plug |
|
156 SetActive(); |
|
157 break; |
|
158 |
|
159 case EWait5: |
|
160 case ETestStateA: |
|
161 OtgEventString(iOTGEvent, aDescription); |
|
162 test.Printf(_L("Received event %d '%S' status(%d)"), iOTGEvent, &aDescription, completionCode); |
|
163 if (RUsbOtgDriver::EEventAPlugInserted == iOTGEvent) |
|
164 { |
|
165 iCaseStep = EUnloadLdd; |
|
166 } |
|
167 else |
|
168 { |
|
169 // wrong event in the Q already, keep at it |
|
170 iCaseStep = ERegisterForEvents; |
|
171 iDequeAttempts++; |
|
172 } |
|
173 |
|
174 SelfComplete(); |
|
175 break; |
|
176 |
|
177 case EUnloadLdd: |
|
178 case ELastStep: |
|
179 if (EFalse == StepUnloadLDD()) |
|
180 return TestFailed(KErrAbort,_L("unload Ldd failure")); |
|
181 |
|
182 return TestPassed(); |
|
183 |
|
184 default: |
|
185 test.Printf(_L("<Error> unknown test step")); |
|
186 Cancel(); |
|
187 return (TestFailed(KErrCorrupt, _L("<Error> unknown test step"))); |
|
188 |
|
189 } |
|
190 } |
|
191 |