1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2007-2010 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". |
100 // LOAD OTG- User-driver |
104 // LOAD OTG- User-driver |
101 err = User::LoadLogicalDevice(KOTGDeviceInterfaceDriverName); |
105 err = User::LoadLogicalDevice(KOTGDeviceInterfaceDriverName); |
102 if ( (err != KErrNone) && (err != KErrAlreadyExists) ) |
106 if ( (err != KErrNone) && (err != KErrAlreadyExists) ) |
103 { |
107 { |
104 test.Printf(_L("<Error %d> Unable to load driver: %S"), err, &KOTGDeviceInterfaceDriverName); |
108 test.Printf(_L("<Error %d> Unable to load driver: %S"), err, &KOTGDeviceInterfaceDriverName); |
|
109 OstTraceExt2(TRACE_NORMAL, PROTOTYPECODE_PROTOTYPECODE, "<Error %d> Unable to load driver: %S", err, KOTGDeviceInterfaceDriverName); |
105 } |
110 } |
106 err = oUsbOtgDriver.Open(); |
111 err = oUsbOtgDriver.Open(); |
107 if (err != KErrNone) |
112 if (err != KErrNone) |
|
113 { |
108 test.Printf(_L("<Error %d> Unable to OPEN driver: %S"), err, &KOTGDeviceInterfaceDriverName); |
114 test.Printf(_L("<Error %d> Unable to OPEN driver: %S"), err, &KOTGDeviceInterfaceDriverName); |
109 else |
115 OstTraceExt2(TRACE_NORMAL, PROTOTYPECODE_PROTOTYPECODE_DUP01, "<Error %d> Unable to OPEN driver: %S", err, KOTGDeviceInterfaceDriverName); |
|
116 } |
|
117 else |
|
118 { |
110 test.Printf(_L("OPEN driver: %S OK!"), &KOTGDeviceInterfaceDriverName); |
119 test.Printf(_L("OPEN driver: %S OK!"), &KOTGDeviceInterfaceDriverName); |
|
120 OstTraceExt1(TRACE_NORMAL, PROTOTYPECODE_PROTOTYPECODE_DUP02, "OPEN driver: %S OK!", KOTGDeviceInterfaceDriverName); |
|
121 } |
111 |
122 |
112 oUsbOtgDriver.StartStacks(); |
123 oUsbOtgDriver.StartStacks(); |
113 test.Printf(_L("Stack started\n")); |
124 test.Printf(_L("Stack started\n")); |
114 |
125 OstTrace0(TRACE_NORMAL, PROTOTYPECODE_PROTOTYPECODE_DUP03, "Stack started\n"); |
115 /* |
126 |
|
127 |
|
128 test.Printf(_L("API QueueOtgIdPinNotification test:\n")); |
|
129 OstTrace0(TRACE_NORMAL, PROTOTYPECODE_PROTOTYPECODE_DUP06, "API QueueOtgIdPinNotification test:\n"); |
|
130 |
116 for (TInt loop=0; loop <6; loop++) |
131 for (TInt loop=0; loop <6; loop++) |
117 // TEST Events |
132 // TEST Events |
118 do |
133 do |
119 { |
134 { |
120 test.Printf(_L("Waiting for OTG...\n")); |
135 test.Printf(_L("Waiting for OTG...\n")); |
121 status1 = KRequestPending; // reset the status object |
136 OstTrace0(TRACE_NORMAL, PROTOTYPECODE_PROTOTYPECODE_DUP07, "Waiting for OTG...\n"); |
122 oUsbOtgDriver.QueueOtgEventRequest( event, status1 ); |
|
123 |
|
124 // wait |
|
125 User::WaitForRequest(status1); |
|
126 TInt completionCode(status1.Int()); |
|
127 CTestCaseRoot::OtgEventString(event, aDescription); |
|
128 test.Printf(_L("Received event %d '%S' status(%d) \n"), event, &aDescription, completionCode); |
|
129 } |
|
130 while (event != RUsbOtgDriver::EEventAPlugInserted); // 'A' plug found |
|
131 |
|
132 */ |
|
133 test.Printf(_L("API QueueOtgIdPinNotification test:\n")); |
|
134 |
|
135 for (TInt loop=0; loop <6; loop++) |
|
136 // TEST Events |
|
137 do |
|
138 { |
|
139 test.Printf(_L("Waiting for OTG...\n")); |
|
140 status1 = KRequestPending; // reset the status object |
137 status1 = KRequestPending; // reset the status object |
141 oUsbOtgDriver.QueueOtgIdPinNotification( OTGIdPin, status1 ); |
138 oUsbOtgDriver.QueueOtgIdPinNotification( OTGIdPin, status1 ); |
142 test.Printf(_L("Current pin %d \n"), OTGIdPin); |
139 test.Printf(_L("Current pin %d \n"), OTGIdPin); |
|
140 OstTrace1(TRACE_NORMAL, PROTOTYPECODE_PROTOTYPECODE_DUP08, "Current pin %d \n", OTGIdPin); |
143 |
141 |
144 // wait |
142 // wait |
145 User::WaitForRequest(status1); |
143 User::WaitForRequest(status1); |
146 TInt completionCode(status1.Int()); |
144 TInt completionCode(status1.Int()); |
147 switch(OTGIdPin) |
145 switch(OTGIdPin) |
155 default: |
153 default: |
156 aDescription = _L("other"); |
154 aDescription = _L("other"); |
157 break; |
155 break; |
158 } |
156 } |
159 test.Printf(_L("Received pin %d '%S' status(%d) \n"), OTGIdPin, &aDescription, completionCode); |
157 test.Printf(_L("Received pin %d '%S' status(%d) \n"), OTGIdPin, &aDescription, completionCode); |
|
158 OstTraceExt3(TRACE_NORMAL, PROTOTYPECODE_PROTOTYPECODE_DUP09, "Received pin %d '%S' status(%d) \n", OTGIdPin, aDescription, completionCode); |
160 } |
159 } |
161 while (OTGIdPin != RUsbOtgDriver::EIdPinAPlug); // 'A' plug found |
160 while (OTGIdPin != RUsbOtgDriver::EIdPinAPlug); // 'A' plug found |
162 |
161 |
163 test.Printf(_L("Press any key.\n")); |
162 test.Printf(_L("Press any key.\n")); |
|
163 OstTrace0(TRACE_NORMAL, PROTOTYPECODE_PROTOTYPECODE_DUP10, "Press any key.\n"); |
164 test.Getch(); |
164 test.Getch(); |
165 |
165 |
166 test.Printf(_L("Shutting down stack.\n")); |
166 test.Printf(_L("Shutting down stack.\n")); |
|
167 OstTrace0(TRACE_NORMAL, PROTOTYPECODE_PROTOTYPECODE_DUP11, "Shutting down stack.\n"); |
167 oUsbOtgDriver.StopStacks(); |
168 oUsbOtgDriver.StopStacks(); |
168 |
169 |
169 oUsbOtgDriver.Close(); |
170 oUsbOtgDriver.Close(); |
170 |
171 |
171 test.Printf(_L("Free the LDD.\n")); |
172 test.Printf(_L("Free the LDD.\n")); |
|
173 OstTrace0(TRACE_NORMAL, PROTOTYPECODE_PROTOTYPECODE_DUP12, "Free the LDD.\n"); |
172 err = User::FreeLogicalDevice( RUsbOtgDriver::Name() ); |
174 err = User::FreeLogicalDevice( RUsbOtgDriver::Name() ); |
173 if (err != KErrNone) |
175 if (err != KErrNone) |
174 { |
176 { |
175 test.Printf(_L("<Error %d> Unable to UN-load driver: %S"), err, &KOTGDeviceInterfaceDriverName); |
177 test.Printf(_L("<Error %d> Unable to UN-load driver: %S"), err, &KOTGDeviceInterfaceDriverName); |
|
178 OstTraceExt2(TRACE_NORMAL, PROTOTYPECODE_PROTOTYPECODE_DUP13, "<Error %d> Unable to UN-load driver: %S", err, KOTGDeviceInterfaceDriverName); |
176 } |
179 } |
177 test.Printf(_L("#############\nPress any key.\n")); |
180 test.Printf(_L("#############\nPress any key.\n")); |
|
181 OstTrace0(TRACE_NORMAL, PROTOTYPECODE_PROTOTYPECODE_DUP14, "#############\nPress any key.\n"); |
178 } |
182 } |
179 test.Getch(); |
183 test.Getch(); |
180 |
184 |
181 test.Printf(_L("Free the LDD.\n")); |
185 test.Printf(_L("Free the LDD.\n")); |
|
186 OstTrace0(TRACE_NORMAL, PROTOTYPECODE_PROTOTYPECODE_DUP15, "Free the LDD.\n"); |
182 // end this process, if we do not want to run a test now as well |
187 // end this process, if we do not want to run a test now as well |
183 RProcess process; |
188 RProcess process; |
184 process.Open(RProcess().Id()); |
189 process.Open(RProcess().Id()); |
185 process.Terminate(0); |
190 process.Terminate(0); |
186 } |
191 } |
244 CleanupStack::PopAndDestroy(testEngine); |
252 CleanupStack::PopAndDestroy(testEngine); |
245 } |
253 } |
246 else |
254 else |
247 { |
255 { |
248 if (-2 == err) |
256 if (-2 == err) |
|
257 { |
249 test.Printf(_L("Warning, no tests were selected!: %d\n"), err); |
258 test.Printf(_L("Warning, no tests were selected!: %d\n"), err); |
|
259 OstTrace1(TRACE_NORMAL, MAINL_MAINL_DUP01, "Warning, no tests were selected!: %d\n", err); |
|
260 } |
250 else |
261 else |
|
262 { |
251 test.Printf(_L("Unable to create the test engine: %d\n"), err); |
263 test.Printf(_L("Unable to create the test engine: %d\n"), err); |
|
264 OstTrace1(TRACE_NORMAL, MAINL_MAINL_DUP02, "Unable to create the test engine: %d\n", err); |
|
265 } |
252 } |
266 } |
253 |
267 |
254 // test DONE, if we are running manual, have a delay |
268 // test DONE, if we are running manual, have a delay |
255 if (!gSemiAutomated) |
269 if (!gSemiAutomated) |
256 { |
270 { |
257 // Get the engine to hang around so we can look at the screen output |
271 // Get the engine to hang around so we can look at the screen output |
258 test.Printf(KPressAnyKeyToEnd); |
272 test.Printf(KPressAnyKeyToEnd); |
|
273 OstTrace0(TRACE_NORMAL, MAINL_MAINL_DUP03, KPressAnyKeyToEnd); |
259 test.Getch(); |
274 test.Getch(); |
260 } |
275 } |
261 |
276 |
262 __UHEAP_MARKEND; |
277 __UHEAP_MARKEND; |
263 #ifdef _DEBUG |
278 #ifdef _DEBUG |
264 test.Printf(_L("Test heap leaks #1 OK\n")); |
279 test.Printf(_L("Test heap leaks #1 OK\n")); |
|
280 OstTrace0(TRACE_NORMAL, MAINL_MAINL_DUP04, "Test heap leaks #1 OK\n"); |
265 #endif |
281 #endif |
266 |
282 |
267 CleanupStack::PopAndDestroy(sched); |
283 CleanupStack::PopAndDestroy(sched); |
268 __UHEAP_MARKEND; |
284 __UHEAP_MARKEND; |
269 #ifdef _DEBUG |
285 #ifdef _DEBUG |
270 test.Printf(_L("Test heap leaks #2 OK\n")); |
286 test.Printf(_L("Test heap leaks #2 OK\n")); |
|
287 OstTrace0(TRACE_NORMAL, MAINL_MAINL_DUP05, "Test heap leaks #2 OK\n"); |
271 #endif |
288 #endif |
272 |
289 |
273 // Finish test and release resources - this ends up closing the console (our application window) |
290 // Finish test and release resources - this ends up closing the console (our application window) |
274 test.End(); |
291 test.End(); |
275 test.Close(); |
292 test.Close(); |