equal
deleted
inserted
replaced
1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
23 #include <e32base_private.h> |
23 #include <e32base_private.h> |
24 #include <e32Test.h> // RTest headder |
24 #include <e32Test.h> // RTest headder |
25 #include "testcaseroot.h" |
25 #include "testcaseroot.h" |
26 #include "testcasefactory.h" |
26 #include "testcasefactory.h" |
27 #include "testcase0460.h" |
27 #include "testcase0460.h" |
28 #include "OstTraceDefinitions.h" |
|
29 #ifdef OST_TRACE_COMPILER_IN_USE |
|
30 #include "testcase0460Traces.h" |
|
31 #endif |
|
32 |
28 |
33 |
29 |
34 |
30 |
35 |
31 |
36 // the name below is used to add a pointer to our construction method to a pointer MAP in |
32 // the name below is used to add a pointer to our construction method to a pointer MAP in |
38 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0460"); |
34 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0460"); |
39 const TTestCaseFactoryReceipt<CTestCase0460> CTestCase0460::iFactoryReceipt(KTestCaseId); |
35 const TTestCaseFactoryReceipt<CTestCase0460> CTestCase0460::iFactoryReceipt(KTestCaseId); |
40 |
36 |
41 CTestCase0460* CTestCase0460::NewL(TBool aHost) |
37 CTestCase0460* CTestCase0460::NewL(TBool aHost) |
42 { |
38 { |
43 if(gVerboseOutput) |
39 LOG_FUNC |
44 { |
|
45 OstTraceFunctionEntry0(CTESTCASE0460_NEWL); |
|
46 } |
|
47 CTestCase0460* self = new (ELeave) CTestCase0460(aHost); |
40 CTestCase0460* self = new (ELeave) CTestCase0460(aHost); |
48 CleanupStack::PushL(self); |
41 CleanupStack::PushL(self); |
49 self->ConstructL(); |
42 self->ConstructL(); |
50 CleanupStack::Pop(self); |
43 CleanupStack::Pop(self); |
51 return self; |
44 return self; |
53 |
46 |
54 |
47 |
55 CTestCase0460::CTestCase0460(TBool aHost) |
48 CTestCase0460::CTestCase0460(TBool aHost) |
56 : CTestCaseRoot(KTestCaseId, aHost) |
49 : CTestCaseRoot(KTestCaseId, aHost) |
57 { |
50 { |
58 if(gVerboseOutput) |
51 LOG_FUNC |
59 { |
|
60 OstTraceFunctionEntry0(CTESTCASE0460_CTESTCASE0460); |
|
61 } |
|
62 |
52 |
63 } |
53 } |
64 |
54 |
65 |
55 |
66 /** |
56 /** |
67 ConstructL |
57 ConstructL |
68 */ |
58 */ |
69 void CTestCase0460::ConstructL() |
59 void CTestCase0460::ConstructL() |
70 { |
60 { |
71 if(gVerboseOutput) |
61 LOG_FUNC |
72 { |
|
73 OstTraceFunctionEntry0(CTESTCASE0460_CONSTRUCTL); |
|
74 } |
|
75 |
62 |
76 BaseConstructL(); |
63 BaseConstructL(); |
77 } |
64 } |
78 |
65 |
79 |
66 |
80 CTestCase0460::~CTestCase0460() |
67 CTestCase0460::~CTestCase0460() |
81 { |
68 { |
82 if(gVerboseOutput) |
69 LOG_FUNC |
83 { |
|
84 OstTraceFunctionEntry0(CTESTCASE0460_DCTESTCASE0460); |
|
85 } |
|
86 |
70 |
87 Cancel(); |
71 Cancel(); |
88 } |
72 } |
89 |
73 |
90 |
74 |
91 void CTestCase0460::ExecuteTestCaseL() |
75 void CTestCase0460::ExecuteTestCaseL() |
92 { |
76 { |
93 if(gVerboseOutput) |
77 LOG_FUNC |
94 { |
|
95 OstTraceFunctionEntry0(CTESTCASE0460_EXECUTETESTCASEL); |
|
96 } |
|
97 iCaseStep = EPreconditions; |
78 iCaseStep = EPreconditions; |
98 |
79 |
99 CActiveScheduler::Add(this); |
80 CActiveScheduler::Add(this); |
100 SelfComplete(); |
81 SelfComplete(); |
101 |
82 |
103 |
84 |
104 |
85 |
105 void CTestCase0460::DescribePreconditions() |
86 void CTestCase0460::DescribePreconditions() |
106 { |
87 { |
107 test.Printf(_L("Insert 'A' connector beforehand.\n")); |
88 test.Printf(_L("Insert 'A' connector beforehand.\n")); |
108 OstTrace0(TRACE_NORMAL, CTESTCASE0460_DESCRIBEPRECONDITIONS, "Insert 'A' connector beforehand.\n"); |
|
109 } |
89 } |
110 |
90 |
111 |
91 |
112 void CTestCase0460::DoCancel() |
92 void CTestCase0460::DoCancel() |
113 { |
93 { |
114 if(gVerboseOutput) |
94 LOG_FUNC |
115 { |
|
116 OstTraceFunctionEntry0(CTESTCASE0460_DOCANCEL); |
|
117 } |
|
118 |
95 |
119 // cancel our timer |
96 // cancel our timer |
120 iTimer.Cancel(); |
97 iTimer.Cancel(); |
121 } |
98 } |
122 |
99 |
123 |
100 |
124 // handle event completion |
101 // handle event completion |
125 void CTestCase0460::RunStepL() |
102 void CTestCase0460::RunStepL() |
126 { |
103 { |
127 if(gVerboseOutput) |
104 LOG_FUNC |
128 { |
|
129 OstTraceFunctionEntry0(CTESTCASE0460_RUNSTEPL); |
|
130 } |
|
131 // Obtain the completion code for this CActive obj. |
105 // Obtain the completion code for this CActive obj. |
132 TInt completionCode(iStatus.Int()); |
106 TInt completionCode(iStatus.Int()); |
133 TBuf<MAX_DSTRLEN> aDescription; |
107 TBuf<MAX_DSTRLEN> aDescription; |
134 |
108 |
135 switch(iCaseStep) |
109 switch(iCaseStep) |
142 SelfComplete(); |
116 SelfComplete(); |
143 break; |
117 break; |
144 } |
118 } |
145 // prompt to remove connector |
119 // prompt to remove connector |
146 test.Printf(KRemoveAConnectorPrompt); |
120 test.Printf(KRemoveAConnectorPrompt); |
147 OstTrace0(TRACE_NORMAL, CTESTCASE0460_RUNSTEPL_DUP01, KRemoveAConnectorPrompt); |
|
148 test.Printf(KPressAnyKeyToContinue); |
121 test.Printf(KPressAnyKeyToContinue); |
149 OstTrace0(TRACE_NORMAL, CTESTCASE0460_RUNSTEPL_DUP02, KPressAnyKeyToContinue); |
|
150 RequestCharacter(); |
122 RequestCharacter(); |
151 break; |
123 break; |
152 |
124 |
153 case ELoadLdd: |
125 case ELoadLdd: |
154 if (!StepLoadLDD()) |
126 if (!StepLoadLDD()) |
159 iCaseStep = ERegisterForEvents; |
131 iCaseStep = ERegisterForEvents; |
160 iDequeAttempts = 0; |
132 iDequeAttempts = 0; |
161 |
133 |
162 // prompt to insert connector |
134 // prompt to insert connector |
163 test.Printf(KInsertAConnectorPrompt); |
135 test.Printf(KInsertAConnectorPrompt); |
164 OstTrace0(TRACE_NORMAL, CTESTCASE0460_RUNSTEPL_DUP03, KInsertAConnectorPrompt); |
|
165 test.Printf(KPressAnyKeyToContinue); |
136 test.Printf(KPressAnyKeyToContinue); |
166 OstTrace0(TRACE_NORMAL, CTESTCASE0460_RUNSTEPL_DUP04, KPressAnyKeyToContinue); |
|
167 RequestCharacter(); |
137 RequestCharacter(); |
168 break; |
138 break; |
169 // wait on ID_PIN |
139 // wait on ID_PIN |
170 case ERegisterForEvents: |
140 case ERegisterForEvents: |
171 if (iDequeAttempts > KOperationRetriesMax) |
141 if (iDequeAttempts > KOperationRetriesMax) |
173 return (TestFailed(KErrCorrupt, _L("<Error> too many irrelevant/incorrect events"))); |
143 return (TestFailed(KErrCorrupt, _L("<Error> too many irrelevant/incorrect events"))); |
174 } |
144 } |
175 iCaseStep = ETestStateA; |
145 iCaseStep = ETestStateA; |
176 |
146 |
177 test.Printf(_L("Waiting for OTG Event\n")); |
147 test.Printf(_L("Waiting for OTG Event\n")); |
178 OstTrace0(TRACE_NORMAL, CTESTCASE0460_RUNSTEPL_DUP05, "Waiting for OTG Event\n"); |
|
179 otgQueueOtgEventRequest( iOTGEvent, iStatus); |
148 otgQueueOtgEventRequest( iOTGEvent, iStatus); |
180 |
149 |
181 SetActive(); |
150 SetActive(); |
182 break; |
151 break; |
183 |
152 |
189 |
158 |
190 case EWait5: |
159 case EWait5: |
191 case ETestStateA: |
160 case ETestStateA: |
192 OtgEventString(iOTGEvent, aDescription); |
161 OtgEventString(iOTGEvent, aDescription); |
193 test.Printf(_L("Received event %d '%S' status(%d)"), iOTGEvent, &aDescription, completionCode); |
162 test.Printf(_L("Received event %d '%S' status(%d)"), iOTGEvent, &aDescription, completionCode); |
194 OstTraceExt3(TRACE_NORMAL, CTESTCASE0460_RUNSTEPL_DUP06, "Received event %d '%S' status(%d)", iOTGEvent, aDescription, completionCode); |
|
195 if (RUsbOtgDriver::EEventAPlugInserted == iOTGEvent) |
163 if (RUsbOtgDriver::EEventAPlugInserted == iOTGEvent) |
196 { |
164 { |
197 iCaseStep = EUnloadLdd; |
165 iCaseStep = EUnloadLdd; |
198 } |
166 } |
199 else |
167 else |
213 |
181 |
214 return TestPassed(); |
182 return TestPassed(); |
215 |
183 |
216 default: |
184 default: |
217 test.Printf(_L("<Error> unknown test step")); |
185 test.Printf(_L("<Error> unknown test step")); |
218 OstTrace0(TRACE_NORMAL, CTESTCASE0460_RUNSTEPL_DUP07, "<Error> unknown test step"); |
|
219 Cancel(); |
186 Cancel(); |
220 return (TestFailed(KErrCorrupt, _L("<Error> unknown test step"))); |
187 return (TestFailed(KErrCorrupt, _L("<Error> unknown test step"))); |
221 |
188 |
222 } |
189 } |
223 } |
190 } |