sl@0
|
1 |
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// UsbcvControl.cpp: implementation of the UsbcvControl class.
|
sl@0
|
15 |
//
|
sl@0
|
16 |
|
sl@0
|
17 |
#include "stdafx.h"
|
sl@0
|
18 |
#include "t_usb_win.h"
|
sl@0
|
19 |
#include "UsbcvControl.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
#include "usbio.h" // USBIO Dev Kit
|
sl@0
|
22 |
|
sl@0
|
23 |
#include "global.h"
|
sl@0
|
24 |
|
sl@0
|
25 |
#ifdef _DEBUG
|
sl@0
|
26 |
#undef THIS_FILE
|
sl@0
|
27 |
static char THIS_FILE[]=__FILE__;
|
sl@0
|
28 |
#define new DEBUG_NEW
|
sl@0
|
29 |
#endif
|
sl@0
|
30 |
|
sl@0
|
31 |
extern void PrintOut(BOOL screenFlag, BOOL logFlag, BOOL timeFlag, const char *format, ...);
|
sl@0
|
32 |
|
sl@0
|
33 |
extern BOOL gAbort;
|
sl@0
|
34 |
|
sl@0
|
35 |
// define the CreateProcess strings for the Usbcv test app
|
sl@0
|
36 |
#define APPNAME "C:\\Program Files\\USB-IF Test Suite\\USBCommandVerifier\\UsbCV13.exe"
|
sl@0
|
37 |
#define APPTITLE "Automated USBCV"
|
sl@0
|
38 |
#define CMDLINE " /title \"Automated USBCV\" /drv hcdriver"
|
sl@0
|
39 |
#define CURDIR "C:\\Program Files\\USB-IF Test Suite\\USBCommandVerifier\\lib"
|
sl@0
|
40 |
|
sl@0
|
41 |
#define DIALOG_CLASS "#32770"
|
sl@0
|
42 |
#define BUTTON_CLASS "Button"
|
sl@0
|
43 |
#define STATIC_CLASS "Static"
|
sl@0
|
44 |
|
sl@0
|
45 |
#define ID_COMPLIANCE 0x3EC
|
sl@0
|
46 |
#define ID_RUN 0x3F5
|
sl@0
|
47 |
#define ID_EXIT 0x1
|
sl@0
|
48 |
|
sl@0
|
49 |
#define DEVLIST_TITLE ""
|
sl@0
|
50 |
#define ID_OKBUTTON 0x3E8
|
sl@0
|
51 |
#define ID_TESTLIST 0x3E9
|
sl@0
|
52 |
#define ID_DEVLIST 0x3EA
|
sl@0
|
53 |
#define ID_TEXTBOX 0x3EB
|
sl@0
|
54 |
#define ID_CONFIRM 0x3EC
|
sl@0
|
55 |
#define ID_ABORT 0x3ED
|
sl@0
|
56 |
|
sl@0
|
57 |
#define TESTRESULT_TITLE "Test Results"
|
sl@0
|
58 |
#define ID_RESULT_TEXT 0xFFFF
|
sl@0
|
59 |
#define ID_RESULT_OK 0x2
|
sl@0
|
60 |
|
sl@0
|
61 |
#define BUFFER_SIZE 256
|
sl@0
|
62 |
#define VIDPID_SIZE 16
|
sl@0
|
63 |
#define TEST_PASSED "Passed"
|
sl@0
|
64 |
#define TEST_FAILED "Failed"
|
sl@0
|
65 |
|
sl@0
|
66 |
// Wait sleep in milliseconds, other waits as repetitions of the sleep time
|
sl@0
|
67 |
#define WAIT_SLEEP 250
|
sl@0
|
68 |
#define CREATE_WAIT 40
|
sl@0
|
69 |
#define SELECT_WAIT 20
|
sl@0
|
70 |
#define CONTINUE_WAIT 120
|
sl@0
|
71 |
#define RESULT_WAIT 1200
|
sl@0
|
72 |
#define EXIT_WAIT 40
|
sl@0
|
73 |
|
sl@0
|
74 |
#define USBMS_DEVICE_REQUEST_CONTINUES 6
|
sl@0
|
75 |
|
sl@0
|
76 |
//////////////////////////////////////////////////////////////////////
|
sl@0
|
77 |
// Construction/Destruction
|
sl@0
|
78 |
//////////////////////////////////////////////////////////////////////
|
sl@0
|
79 |
|
sl@0
|
80 |
UsbcvControl::UsbcvControl()
|
sl@0
|
81 |
{
|
sl@0
|
82 |
|
sl@0
|
83 |
ZeroMemory( &si, sizeof(si) );
|
sl@0
|
84 |
si.cb = sizeof(si);
|
sl@0
|
85 |
ZeroMemory( &pi, sizeof(pi) );
|
sl@0
|
86 |
|
sl@0
|
87 |
}
|
sl@0
|
88 |
|
sl@0
|
89 |
UsbcvControl::~UsbcvControl()
|
sl@0
|
90 |
{
|
sl@0
|
91 |
DWORD exitCode;
|
sl@0
|
92 |
|
sl@0
|
93 |
if (GetExitCodeProcess(pi.hProcess,(LPDWORD)&exitCode))
|
sl@0
|
94 |
{
|
sl@0
|
95 |
if (exitCode == STILL_ACTIVE)
|
sl@0
|
96 |
{
|
sl@0
|
97 |
SendMessage (mainWindow,WM_COMMAND,MAKEWPARAM(ID_EXIT,BN_CLICKED),(LPARAM)exitButton);
|
sl@0
|
98 |
}
|
sl@0
|
99 |
int i = 0;
|
sl@0
|
100 |
while (exitCode == STILL_ACTIVE && i++ < EXIT_WAIT)
|
sl@0
|
101 |
{
|
sl@0
|
102 |
Sleep (WAIT_SLEEP);
|
sl@0
|
103 |
GetExitCodeProcess(pi.hProcess,(LPDWORD)&exitCode);
|
sl@0
|
104 |
}
|
sl@0
|
105 |
// Force an unclean process termination only if necessary
|
sl@0
|
106 |
if (exitCode == STILL_ACTIVE)
|
sl@0
|
107 |
{
|
sl@0
|
108 |
TerminateProcess(pi.hProcess,0);
|
sl@0
|
109 |
}
|
sl@0
|
110 |
}
|
sl@0
|
111 |
}
|
sl@0
|
112 |
|
sl@0
|
113 |
DWORD UsbcvControl::Create()
|
sl@0
|
114 |
{
|
sl@0
|
115 |
mainWindow = NULL;
|
sl@0
|
116 |
exitButton = NULL;
|
sl@0
|
117 |
|
sl@0
|
118 |
if (!CreateProcess (APPNAME,CMDLINE,NULL,NULL,FALSE,0,NULL,CURDIR,&si,&pi))
|
sl@0
|
119 |
return USBIO_ERR_FAILED;
|
sl@0
|
120 |
|
sl@0
|
121 |
HWND complianceButton;
|
sl@0
|
122 |
|
sl@0
|
123 |
for (int i=0; i < CREATE_WAIT && !mainWindow; i++)
|
sl@0
|
124 |
{
|
sl@0
|
125 |
mainWindow = FindWindow(DIALOG_CLASS,APPTITLE);
|
sl@0
|
126 |
if (mainWindow)
|
sl@0
|
127 |
{
|
sl@0
|
128 |
complianceButton = GetDlgItem(mainWindow,ID_COMPLIANCE);
|
sl@0
|
129 |
runButton = GetDlgItem(mainWindow,ID_RUN);
|
sl@0
|
130 |
exitButton = GetDlgItem(mainWindow,ID_EXIT);
|
sl@0
|
131 |
if (!complianceButton || !runButton || !exitButton)
|
sl@0
|
132 |
{
|
sl@0
|
133 |
mainWindow = NULL;
|
sl@0
|
134 |
}
|
sl@0
|
135 |
}
|
sl@0
|
136 |
if (!mainWindow)
|
sl@0
|
137 |
Sleep(WAIT_SLEEP);
|
sl@0
|
138 |
}
|
sl@0
|
139 |
|
sl@0
|
140 |
if (mainWindow)
|
sl@0
|
141 |
{
|
sl@0
|
142 |
SendMessage (mainWindow,WM_COMMAND,MAKEWPARAM(ID_COMPLIANCE,BN_CLICKED),(LPARAM)complianceButton);
|
sl@0
|
143 |
|
sl@0
|
144 |
return USBIO_ERR_SUCCESS;
|
sl@0
|
145 |
}
|
sl@0
|
146 |
else
|
sl@0
|
147 |
{
|
sl@0
|
148 |
return USBIO_ERR_FAILED;
|
sl@0
|
149 |
}
|
sl@0
|
150 |
}
|
sl@0
|
151 |
|
sl@0
|
152 |
DWORD UsbcvControl::TestAllDevices(USHORT aVendorId, USHORT aProductId1, USHORT aProductId2)
|
sl@0
|
153 |
{
|
sl@0
|
154 |
DWORD dwRC = USBIO_ERR_SUCCESS;
|
sl@0
|
155 |
HWND testList;
|
sl@0
|
156 |
int chapter9_TestIndex = -1;
|
sl@0
|
157 |
int MSC_TestIndex = -1;
|
sl@0
|
158 |
LRESULT lResult;
|
sl@0
|
159 |
|
sl@0
|
160 |
testList = GetDlgItem(mainWindow,ID_TESTLIST);
|
sl@0
|
161 |
|
sl@0
|
162 |
LRESULT itemCount = SendMessage (testList,LB_GETCOUNT,0,0);
|
sl@0
|
163 |
if (!itemCount)
|
sl@0
|
164 |
return USBIO_ERR_FAILED;
|
sl@0
|
165 |
|
sl@0
|
166 |
char strBuffer[BUFFER_SIZE];
|
sl@0
|
167 |
for (int i = 0; i < itemCount; i++)
|
sl@0
|
168 |
{
|
sl@0
|
169 |
LRESULT lResult = SendMessage (testList,LB_GETTEXT,(WPARAM)i,(LPARAM)&strBuffer);
|
sl@0
|
170 |
if (lResult > 0)
|
sl@0
|
171 |
{
|
sl@0
|
172 |
if (strstr (strBuffer,"Chapter 9 Tests"))
|
sl@0
|
173 |
chapter9_TestIndex = i;
|
sl@0
|
174 |
if (strstr (strBuffer,"MSC Tests"))
|
sl@0
|
175 |
MSC_TestIndex = i;
|
sl@0
|
176 |
}
|
sl@0
|
177 |
}
|
sl@0
|
178 |
|
sl@0
|
179 |
|
sl@0
|
180 |
if (chapter9_TestIndex < 0 || MSC_TestIndex < 0)
|
sl@0
|
181 |
return USBIO_ERR_FAILED;
|
sl@0
|
182 |
|
sl@0
|
183 |
|
sl@0
|
184 |
int ch9DeviceIndex = 0;
|
sl@0
|
185 |
int numCh9Devices = 1;
|
sl@0
|
186 |
int mscDeviceIndex = 0;
|
sl@0
|
187 |
int numMscDevices = 1;
|
sl@0
|
188 |
int testResult;
|
sl@0
|
189 |
bool msDevice = false;
|
sl@0
|
190 |
while (numCh9Devices > 0 && dwRC == USBIO_ERR_SUCCESS)
|
sl@0
|
191 |
{
|
sl@0
|
192 |
// select the chapter 9 tests
|
sl@0
|
193 |
lResult = SendMessage (testList,LB_SETCURSEL,(WPARAM)chapter9_TestIndex,0);
|
sl@0
|
194 |
lResult = SendMessage (mainWindow,WM_COMMAND,MAKEWPARAM(ID_TESTLIST,LBN_SELCHANGE),(LPARAM)testList);
|
sl@0
|
195 |
|
sl@0
|
196 |
// then run it
|
sl@0
|
197 |
lResult = SendMessage (mainWindow,WM_COMMAND,MAKEWPARAM(ID_RUN,BN_CLICKED),(LPARAM)runButton);
|
sl@0
|
198 |
|
sl@0
|
199 |
dwRC = SelectDevice (aVendorId,aProductId1,aProductId2,&ch9DeviceIndex,&numCh9Devices,&msDevice);
|
sl@0
|
200 |
if (ch9DeviceIndex >= 0 && dwRC == USBIO_ERR_SUCCESS)
|
sl@0
|
201 |
{
|
sl@0
|
202 |
|
sl@0
|
203 |
dwRC = WaitForTestResult(&testResult);
|
sl@0
|
204 |
if (dwRC == USBIO_ERR_SUCCESS)
|
sl@0
|
205 |
{
|
sl@0
|
206 |
if (!testResult)
|
sl@0
|
207 |
{
|
sl@0
|
208 |
gAbort = TRUE;
|
sl@0
|
209 |
}
|
sl@0
|
210 |
PRINT_TIME "USBCV Chapter 9 Test Complete - %s ",testResult ? "Passed" : "Failed");
|
sl@0
|
211 |
ch9DeviceIndex++;
|
sl@0
|
212 |
}
|
sl@0
|
213 |
else
|
sl@0
|
214 |
{
|
sl@0
|
215 |
PRINT_ALWAYS "Error in Running USBCV\n");
|
sl@0
|
216 |
return dwRC;
|
sl@0
|
217 |
}
|
sl@0
|
218 |
}
|
sl@0
|
219 |
|
sl@0
|
220 |
if (msDevice && numMscDevices > 0 && dwRC == USBIO_ERR_SUCCESS)
|
sl@0
|
221 |
{
|
sl@0
|
222 |
// select the mass storage tests
|
sl@0
|
223 |
lResult = SendMessage (testList,LB_SETCURSEL,(WPARAM)MSC_TestIndex,0);
|
sl@0
|
224 |
lResult = SendMessage (mainWindow,WM_COMMAND,MAKEWPARAM(ID_TESTLIST,LBN_SELCHANGE),(LPARAM)testList);
|
sl@0
|
225 |
|
sl@0
|
226 |
// then run it
|
sl@0
|
227 |
lResult = SendMessage (mainWindow,WM_COMMAND,MAKEWPARAM(ID_RUN,BN_CLICKED),(LPARAM)runButton);
|
sl@0
|
228 |
|
sl@0
|
229 |
if (dwRC == USBIO_ERR_SUCCESS)
|
sl@0
|
230 |
dwRC = SelectDevice (aVendorId,aProductId1,aProductId2,&mscDeviceIndex,&numMscDevices,&msDevice);
|
sl@0
|
231 |
if (mscDeviceIndex >= 0 && dwRC == USBIO_ERR_SUCCESS)
|
sl@0
|
232 |
{
|
sl@0
|
233 |
dwRC = ContinueOk ("The following test might destroy",ID_CONFIRM);
|
sl@0
|
234 |
for (int i = 0; i < USBMS_DEVICE_REQUEST_CONTINUES; i++)
|
sl@0
|
235 |
{
|
sl@0
|
236 |
if (dwRC == USBIO_ERR_SUCCESS)
|
sl@0
|
237 |
dwRC = ContinueOk ("Processing device request",ID_OKBUTTON);
|
sl@0
|
238 |
}
|
sl@0
|
239 |
if (dwRC == USBIO_ERR_SUCCESS)
|
sl@0
|
240 |
dwRC = ContinueOk ("Disconnect and power off",ID_CONFIRM);
|
sl@0
|
241 |
|
sl@0
|
242 |
if (dwRC == USBIO_ERR_SUCCESS)
|
sl@0
|
243 |
{
|
sl@0
|
244 |
dwRC = WaitForTestResult(&testResult);
|
sl@0
|
245 |
if (dwRC == USBIO_ERR_SUCCESS)
|
sl@0
|
246 |
{
|
sl@0
|
247 |
if (!testResult)
|
sl@0
|
248 |
{
|
sl@0
|
249 |
gAbort = TRUE;
|
sl@0
|
250 |
}
|
sl@0
|
251 |
PRINT_TIME "USBCV Mass Storage Class Test Complete - %s ",testResult ? "Passed" : "Failed");
|
sl@0
|
252 |
mscDeviceIndex++;
|
sl@0
|
253 |
}
|
sl@0
|
254 |
else
|
sl@0
|
255 |
{
|
sl@0
|
256 |
PRINT_ALWAYS "Error in Running USBCV\n");
|
sl@0
|
257 |
return dwRC;
|
sl@0
|
258 |
}
|
sl@0
|
259 |
}
|
sl@0
|
260 |
}
|
sl@0
|
261 |
}
|
sl@0
|
262 |
}
|
sl@0
|
263 |
|
sl@0
|
264 |
return dwRC;
|
sl@0
|
265 |
}
|
sl@0
|
266 |
|
sl@0
|
267 |
DWORD UsbcvControl::ContinueOk (char * choiceText, int buttonId)
|
sl@0
|
268 |
{
|
sl@0
|
269 |
HWND choiceDialog = NULL;
|
sl@0
|
270 |
HWND okButton;
|
sl@0
|
271 |
char strBuffer[BUFFER_SIZE];
|
sl@0
|
272 |
|
sl@0
|
273 |
for (int i=0; i < CONTINUE_WAIT && !choiceDialog; i++)
|
sl@0
|
274 |
{
|
sl@0
|
275 |
choiceDialog = FindWindow(DIALOG_CLASS,"");
|
sl@0
|
276 |
if (choiceDialog)
|
sl@0
|
277 |
{
|
sl@0
|
278 |
UINT textSize = GetDlgItemText (choiceDialog,ID_TEXTBOX,strBuffer,BUFFER_SIZE);
|
sl@0
|
279 |
okButton = GetDlgItem(choiceDialog,buttonId);
|
sl@0
|
280 |
if (!textSize || !okButton || !strstr (strBuffer,choiceText))
|
sl@0
|
281 |
{
|
sl@0
|
282 |
choiceDialog = NULL;
|
sl@0
|
283 |
}
|
sl@0
|
284 |
}
|
sl@0
|
285 |
if (!choiceDialog)
|
sl@0
|
286 |
Sleep(WAIT_SLEEP);
|
sl@0
|
287 |
}
|
sl@0
|
288 |
|
sl@0
|
289 |
if (!choiceDialog)
|
sl@0
|
290 |
return USBIO_ERR_FAILED;
|
sl@0
|
291 |
|
sl@0
|
292 |
SendMessage (choiceDialog,WM_COMMAND,MAKEWPARAM(buttonId,BN_CLICKED),(LPARAM)okButton);
|
sl@0
|
293 |
|
sl@0
|
294 |
return USBIO_ERR_SUCCESS;
|
sl@0
|
295 |
|
sl@0
|
296 |
}
|
sl@0
|
297 |
|
sl@0
|
298 |
DWORD UsbcvControl::SelectDevice(USHORT aVendorId, USHORT aProductId1, USHORT aProductId2, int * deviceIndex, int * numDevices, bool * msDevice)
|
sl@0
|
299 |
{
|
sl@0
|
300 |
HWND devListDialog = NULL;
|
sl@0
|
301 |
HWND devList;
|
sl@0
|
302 |
HWND okButton;
|
sl@0
|
303 |
LRESULT lResult;
|
sl@0
|
304 |
int i;
|
sl@0
|
305 |
|
sl@0
|
306 |
for (i=0; i < SELECT_WAIT && !devListDialog; i++)
|
sl@0
|
307 |
{
|
sl@0
|
308 |
devListDialog = FindWindow(DIALOG_CLASS,DEVLIST_TITLE);
|
sl@0
|
309 |
if (devListDialog)
|
sl@0
|
310 |
{
|
sl@0
|
311 |
devList = GetDlgItem(devListDialog,ID_DEVLIST);
|
sl@0
|
312 |
okButton = GetDlgItem(devListDialog,ID_OKBUTTON);
|
sl@0
|
313 |
if (!devList || !okButton)
|
sl@0
|
314 |
{
|
sl@0
|
315 |
devListDialog = NULL;
|
sl@0
|
316 |
}
|
sl@0
|
317 |
}
|
sl@0
|
318 |
if (!devListDialog)
|
sl@0
|
319 |
Sleep(WAIT_SLEEP);
|
sl@0
|
320 |
}
|
sl@0
|
321 |
|
sl@0
|
322 |
if (!devListDialog)
|
sl@0
|
323 |
return USBIO_ERR_FAILED;
|
sl@0
|
324 |
|
sl@0
|
325 |
LRESULT itemCount = SendMessage (devList,LB_GETCOUNT,0,0);
|
sl@0
|
326 |
if (!itemCount)
|
sl@0
|
327 |
return USBIO_ERR_FAILED;
|
sl@0
|
328 |
|
sl@0
|
329 |
* numDevices = 0;
|
sl@0
|
330 |
if (* deviceIndex >= itemCount)
|
sl@0
|
331 |
return USBIO_ERR_SUCCESS;
|
sl@0
|
332 |
|
sl@0
|
333 |
char strBuffer[BUFFER_SIZE];
|
sl@0
|
334 |
char strVID [VIDPID_SIZE];
|
sl@0
|
335 |
char strPID1 [VIDPID_SIZE];
|
sl@0
|
336 |
char strPID2 [VIDPID_SIZE];
|
sl@0
|
337 |
bool deviceFound = false;
|
sl@0
|
338 |
|
sl@0
|
339 |
for (i = * deviceIndex; i < itemCount; i++)
|
sl@0
|
340 |
{
|
sl@0
|
341 |
lResult = SendMessage (devList,LB_GETTEXT,(WPARAM)i,(LPARAM)&strBuffer);
|
sl@0
|
342 |
if (lResult > 0)
|
sl@0
|
343 |
{
|
sl@0
|
344 |
sprintf (strVID,"VID=%04x",aVendorId);
|
sl@0
|
345 |
sprintf (strPID1,"PID=%04x",aProductId1);
|
sl@0
|
346 |
sprintf (strPID2,"PID=%04x",aProductId2);
|
sl@0
|
347 |
if (strstr (strBuffer,strVID) && (strstr (strBuffer,strPID1) || strstr (strBuffer,strPID2)))
|
sl@0
|
348 |
{
|
sl@0
|
349 |
if (deviceFound)
|
sl@0
|
350 |
{
|
sl@0
|
351 |
(* numDevices)++;
|
sl@0
|
352 |
}
|
sl@0
|
353 |
else
|
sl@0
|
354 |
{
|
sl@0
|
355 |
deviceFound = true;
|
sl@0
|
356 |
* msDevice = strstr (strBuffer,strPID2) != NULL;
|
sl@0
|
357 |
* deviceIndex = i;
|
sl@0
|
358 |
lResult = SendMessage (devList,LB_SETCURSEL,(WPARAM)i,0);
|
sl@0
|
359 |
}
|
sl@0
|
360 |
}
|
sl@0
|
361 |
}
|
sl@0
|
362 |
}
|
sl@0
|
363 |
|
sl@0
|
364 |
|
sl@0
|
365 |
if (deviceFound)
|
sl@0
|
366 |
{
|
sl@0
|
367 |
if (lResult == LB_ERR)
|
sl@0
|
368 |
{
|
sl@0
|
369 |
return USBIO_ERR_FAILED;
|
sl@0
|
370 |
}
|
sl@0
|
371 |
else
|
sl@0
|
372 |
{
|
sl@0
|
373 |
lResult = SendMessage (devListDialog,WM_COMMAND,MAKEWPARAM(ID_OKBUTTON,BN_CLICKED),(LPARAM)okButton);
|
sl@0
|
374 |
|
sl@0
|
375 |
return USBIO_ERR_SUCCESS;
|
sl@0
|
376 |
}
|
sl@0
|
377 |
}
|
sl@0
|
378 |
else
|
sl@0
|
379 |
{
|
sl@0
|
380 |
* deviceIndex = -1;
|
sl@0
|
381 |
|
sl@0
|
382 |
return USBIO_ERR_FAILED;
|
sl@0
|
383 |
}
|
sl@0
|
384 |
|
sl@0
|
385 |
}
|
sl@0
|
386 |
|
sl@0
|
387 |
|
sl@0
|
388 |
DWORD UsbcvControl::WaitForTestResult(BOOL * passFail)
|
sl@0
|
389 |
{
|
sl@0
|
390 |
HWND testResultDialog = NULL;
|
sl@0
|
391 |
HWND okButton;
|
sl@0
|
392 |
char strBuffer[BUFFER_SIZE];
|
sl@0
|
393 |
|
sl@0
|
394 |
for (int i=0; i < RESULT_WAIT && !testResultDialog; i++)
|
sl@0
|
395 |
{
|
sl@0
|
396 |
testResultDialog = FindWindow(DIALOG_CLASS,TESTRESULT_TITLE);
|
sl@0
|
397 |
if (testResultDialog)
|
sl@0
|
398 |
{
|
sl@0
|
399 |
UINT textSize = GetDlgItemText(testResultDialog,ID_RESULT_TEXT,(LPTSTR)&strBuffer,BUFFER_SIZE);
|
sl@0
|
400 |
okButton = GetDlgItem(testResultDialog,ID_RESULT_OK);
|
sl@0
|
401 |
if (!textSize || !okButton)
|
sl@0
|
402 |
{
|
sl@0
|
403 |
testResultDialog = NULL;
|
sl@0
|
404 |
}
|
sl@0
|
405 |
}
|
sl@0
|
406 |
if (!testResultDialog)
|
sl@0
|
407 |
Sleep(WAIT_SLEEP);
|
sl@0
|
408 |
}
|
sl@0
|
409 |
|
sl@0
|
410 |
if (!testResultDialog)
|
sl@0
|
411 |
return USBIO_ERR_FAILED;
|
sl@0
|
412 |
|
sl@0
|
413 |
if (strstr (strBuffer,TEST_PASSED))
|
sl@0
|
414 |
{
|
sl@0
|
415 |
* passFail = TRUE;
|
sl@0
|
416 |
}
|
sl@0
|
417 |
else
|
sl@0
|
418 |
{
|
sl@0
|
419 |
if (strstr (strBuffer,TEST_FAILED))
|
sl@0
|
420 |
{
|
sl@0
|
421 |
* passFail = FALSE;
|
sl@0
|
422 |
}
|
sl@0
|
423 |
else
|
sl@0
|
424 |
{
|
sl@0
|
425 |
return USBIO_ERR_FAILED;
|
sl@0
|
426 |
}
|
sl@0
|
427 |
}
|
sl@0
|
428 |
|
sl@0
|
429 |
SendMessage (testResultDialog,WM_COMMAND,MAKEWPARAM(ID_RESULT_OK,BN_CLICKED),(LPARAM)okButton);
|
sl@0
|
430 |
|
sl@0
|
431 |
return USBIO_ERR_SUCCESS;
|
sl@0
|
432 |
|
sl@0
|
433 |
}
|