gdiplus: Implement GdipSetPathGradientBlend, with tests.
[wine/multimedia.git] / dlls / winhttp / tests / notification.c
blob84a35692b8f7075dc77d74c5d9c843760f8ff775
1 /*
2 * test status notifications
4 * Copyright 2008 Hans Leidekker for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <stdlib.h>
23 #include <windef.h>
24 #include <winbase.h>
25 #include <winhttp.h>
27 #include "wine/test.h"
29 static const WCHAR user_agent[] = {'w','i','n','e','t','e','s','t',0};
31 enum api
33 winhttp_connect = 1,
34 winhttp_open_request,
35 winhttp_send_request,
36 winhttp_receive_response,
37 winhttp_query_data,
38 winhttp_read_data,
39 winhttp_write_data,
40 winhttp_close_handle
43 struct notification
45 enum api function; /* api responsible for notification */
46 unsigned int status; /* status received */
47 int todo;
48 int ignore;
49 int skipped_for_proxy;
52 struct info
54 enum api function;
55 const struct notification *test;
56 unsigned int count;
57 unsigned int index;
58 HANDLE wait;
59 unsigned int line;
62 static BOOL proxy_active(void)
64 WINHTTP_PROXY_INFO proxy_info;
65 BOOL active = FALSE;
67 if (WinHttpGetDefaultProxyConfiguration(&proxy_info))
69 active = (proxy_info.lpszProxy != NULL);
70 if (active)
71 GlobalFree((HGLOBAL) proxy_info.lpszProxy);
72 if (proxy_info.lpszProxyBypass != NULL)
73 GlobalFree((HGLOBAL) proxy_info.lpszProxyBypass);
75 else
76 active = FALSE;
78 return active;
81 static void CALLBACK check_notification( HINTERNET handle, DWORD_PTR context, DWORD status, LPVOID buffer, DWORD buflen )
83 BOOL status_ok, function_ok;
84 struct info *info = (struct info *)context;
85 unsigned int i = info->index;
87 if (status == WINHTTP_CALLBACK_STATUS_HANDLE_CREATED)
89 DWORD size = sizeof(struct info *);
90 WinHttpQueryOption( handle, WINHTTP_OPTION_CONTEXT_VALUE, &info, &size );
92 ok(i < info->count, "unexpected notification 0x%08x\n", status);
93 if (i >= info->count) return;
95 status_ok = (info->test[i].status == status);
96 function_ok = (info->test[i].function == info->function);
97 if (!info->test[i].ignore && !info->test[i].todo)
99 ok(status_ok, "%u: expected status 0x%08x got 0x%08x\n", info->line, info->test[i].status, status);
100 ok(function_ok, "%u: expected function %u got %u\n", info->line, info->test[i].function, info->function);
102 else if (!info->test[i].ignore)
104 todo_wine ok(status_ok, "%u: expected status 0x%08x got 0x%08x\n", info->line, info->test[i].status, status);
105 if (status_ok)
107 todo_wine ok(function_ok, "%u: expected function %u got %u\n", info->line, info->test[i].function, info->function);
110 if (status_ok) info->index++;
111 if (proxy_active())
113 while (info->test[info->index].skipped_for_proxy)
114 info->index++;
117 if (status & (WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS | WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING))
119 SetEvent( info->wait );
123 static const struct notification cache_test[] =
125 { winhttp_connect, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, 0 },
126 { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, 0 },
127 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, 0 },
128 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, 0 },
129 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0 },
130 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, 0 },
131 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST, 0 },
132 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT, 0 },
133 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
134 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, 0 },
135 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, 0, 1 },
136 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, 0, 1 },
137 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, 0, 1 },
138 { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, 0 },
139 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0 },
140 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, 0 },
141 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST, 0 },
142 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT, 0 },
143 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
144 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, 0 },
145 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, 0, 1 },
146 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, 0, 1 },
147 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, 0, 1 },
148 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, 1, 1 },
149 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, 1, 1 }
152 static void setup_test( struct info *info, enum api function, unsigned int line )
154 info->function = function;
155 info->line = line;
158 static void test_connection_cache( void )
160 static const WCHAR codeweavers[] = {'w','w','w','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
162 HANDLE ses, con, req;
163 DWORD size, status;
164 BOOL ret;
165 struct info info, *context = &info;
167 info.test = cache_test;
168 info.count = sizeof(cache_test) / sizeof(cache_test[0]);
169 info.index = 0;
170 info.wait = NULL;
172 ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 );
173 ok(ses != NULL, "failed to open session %u\n", GetLastError());
175 WinHttpSetStatusCallback( ses, check_notification, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );
177 ret = WinHttpSetOption( ses, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
178 ok(ret, "failed to set context value %u\n", GetLastError());
180 setup_test( &info, winhttp_connect, __LINE__ );
181 con = WinHttpConnect( ses, codeweavers, 0, 0 );
182 ok(con != NULL, "failed to open a connection %u\n", GetLastError());
184 setup_test( &info, winhttp_open_request, __LINE__ );
185 req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
186 ok(req != NULL, "failed to open a request %u\n", GetLastError());
188 setup_test( &info, winhttp_send_request, __LINE__ );
189 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
190 ok(ret, "failed to send request %u\n", GetLastError());
192 setup_test( &info, winhttp_receive_response, __LINE__ );
193 ret = WinHttpReceiveResponse( req, NULL );
194 ok(ret, "failed to receive response %u\n", GetLastError());
196 size = sizeof(status);
197 ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
198 ok(ret, "failed unexpectedly %u\n", GetLastError());
199 ok(status == 200, "request failed unexpectedly %u\n", status);
201 setup_test( &info, winhttp_close_handle, __LINE__ );
202 WinHttpCloseHandle( req );
204 setup_test( &info, winhttp_open_request, __LINE__ );
205 req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
206 ok(req != NULL, "failed to open a request %u\n", GetLastError());
208 ret = WinHttpSetOption( req, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
209 ok(ret, "failed to set context value %u\n", GetLastError());
211 setup_test( &info, winhttp_send_request, __LINE__ );
212 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
213 ok(ret, "failed to send request %u\n", GetLastError());
215 setup_test( &info, winhttp_receive_response, __LINE__ );
216 ret = WinHttpReceiveResponse( req, NULL );
217 ok(ret, "failed to receive response %u\n", GetLastError());
219 size = sizeof(status);
220 ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
221 ok(ret, "failed unexpectedly %u\n", GetLastError());
222 ok(status == 200, "request failed unexpectedly %u\n", status);
224 setup_test( &info, winhttp_close_handle, __LINE__ );
225 WinHttpCloseHandle( req );
227 setup_test( &info, winhttp_close_handle, __LINE__ );
228 WinHttpCloseHandle( req );
229 WinHttpCloseHandle( con );
230 WinHttpCloseHandle( ses );
232 Sleep(2000); /* make sure connection is evicted from cache */
234 info.index = 0;
236 ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 );
237 ok(ses != NULL, "failed to open session %u\n", GetLastError());
239 WinHttpSetStatusCallback( ses, check_notification, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );
241 ret = WinHttpSetOption( ses, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
242 ok(ret, "failed to set context value %u\n", GetLastError());
244 setup_test( &info, winhttp_connect, __LINE__ );
245 con = WinHttpConnect( ses, codeweavers, 0, 0 );
246 ok(con != NULL, "failed to open a connection %u\n", GetLastError());
248 setup_test( &info, winhttp_open_request, __LINE__ );
249 req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
250 ok(req != NULL, "failed to open a request %u\n", GetLastError());
252 ret = WinHttpSetOption( req, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
253 ok(ret, "failed to set context value %u\n", GetLastError());
255 setup_test( &info, winhttp_send_request, __LINE__ );
256 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
257 ok(ret, "failed to send request %u\n", GetLastError());
259 setup_test( &info, winhttp_receive_response, __LINE__ );
260 ret = WinHttpReceiveResponse( req, NULL );
261 ok(ret, "failed to receive response %u\n", GetLastError());
263 size = sizeof(status);
264 ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
265 ok(ret, "failed unexpectedly %u\n", GetLastError());
266 ok(status == 200, "request failed unexpectedly %u\n", status);
268 setup_test( &info, winhttp_close_handle, __LINE__ );
269 WinHttpCloseHandle( req );
271 setup_test( &info, winhttp_open_request, __LINE__ );
272 req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
273 ok(req != NULL, "failed to open a request %u\n", GetLastError());
275 ret = WinHttpSetOption( req, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
276 ok(ret, "failed to set context value %u\n", GetLastError());
278 setup_test( &info, winhttp_send_request, __LINE__ );
279 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
280 ok(ret, "failed to send request %u\n", GetLastError());
282 setup_test( &info, winhttp_receive_response, __LINE__ );
283 ret = WinHttpReceiveResponse( req, NULL );
284 ok(ret, "failed to receive response %u\n", GetLastError());
286 size = sizeof(status);
287 ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
288 ok(ret, "failed unexpectedly %u\n", GetLastError());
289 ok(status == 200, "request failed unexpectedly %u\n", status);
291 setup_test( &info, winhttp_close_handle, __LINE__ );
292 WinHttpCloseHandle( req );
293 WinHttpCloseHandle( con );
294 WinHttpCloseHandle( ses );
297 static const struct notification redirect_test[] =
299 { winhttp_connect, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, 0 },
300 { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, 0 },
301 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, 0 },
302 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, 0 },
303 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0 },
304 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, 0 },
305 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST, 0 },
306 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT, 0 },
307 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
308 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, 0 },
309 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REDIRECT, 0 },
310 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, 0, 0, 1 },
311 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, 0, 0, 1 },
312 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0, 0, 1 },
313 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, 0, 0, 1 },
314 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST, 0 },
315 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REQUEST_SENT, 0 },
316 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
317 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, 0 },
318 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, 0, 1 },
319 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, 0, 1 },
320 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, 0, 1 },
321 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, 1, 1 },
322 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, 1, 1 }
325 static void test_redirect( void )
327 static const WCHAR codeweavers[] = {'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
329 HANDLE ses, con, req;
330 DWORD size, status;
331 BOOL ret;
332 struct info info, *context = &info;
334 info.test = redirect_test;
335 info.count = sizeof(redirect_test) / sizeof(redirect_test[0]);
336 info.index = 0;
337 info.wait = NULL;
339 ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 );
340 ok(ses != NULL, "failed to open session %u\n", GetLastError());
342 WinHttpSetStatusCallback( ses, check_notification, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );
344 ret = WinHttpSetOption( ses, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
345 ok(ret, "failed to set context value %u\n", GetLastError());
347 setup_test( &info, winhttp_connect, __LINE__ );
348 con = WinHttpConnect( ses, codeweavers, 0, 0 );
349 ok(con != NULL, "failed to open a connection %u\n", GetLastError());
351 setup_test( &info, winhttp_open_request, __LINE__ );
352 req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
353 ok(req != NULL, "failed to open a request %u\n", GetLastError());
355 setup_test( &info, winhttp_send_request, __LINE__ );
356 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
357 ok(ret, "failed to send request %u\n", GetLastError());
359 setup_test( &info, winhttp_receive_response, __LINE__ );
360 ret = WinHttpReceiveResponse( req, NULL );
361 ok(ret, "failed to receive response %u\n", GetLastError());
363 size = sizeof(status);
364 ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
365 ok(ret, "failed unexpectedly %u\n", GetLastError());
366 ok(status == 200, "request failed unexpectedly %u\n", status);
368 setup_test( &info, winhttp_close_handle, __LINE__ );
369 WinHttpCloseHandle( req );
370 WinHttpCloseHandle( con );
371 WinHttpCloseHandle( ses );
374 static const struct notification async_test[] =
376 { winhttp_connect, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, 0 },
377 { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, 0 },
378 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, 0 },
379 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, 0 },
380 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0 },
381 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, 0 },
382 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST, 0 },
383 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT, 0 },
384 { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE, 0 },
385 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
386 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, 0 },
387 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REDIRECT, 0 },
388 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, 0, 0, 1 },
389 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, 0, 0, 1 },
390 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0, 0, 1 },
391 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, 0, 0, 1 },
392 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST, 0 },
393 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REQUEST_SENT, 0 },
394 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
395 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, 0 },
396 { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE, 0 },
397 { winhttp_query_data, WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE, 0 },
398 { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0, 1 },
399 { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, 0, 1 },
400 { winhttp_read_data, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, 0, 1 },
401 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, 0, 1 },
402 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, 0, 1 },
403 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, 0, 1 },
404 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, 1, 1 },
405 { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, 1, 1 }
408 static void test_async( void )
410 static const WCHAR codeweavers[] = {'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
412 HANDLE ses, con, req;
413 DWORD size, status;
414 BOOL ret;
415 struct info info, *context = &info;
416 char buffer[1024];
418 info.test = async_test;
419 info.count = sizeof(async_test) / sizeof(async_test[0]);
420 info.index = 0;
421 info.wait = CreateEvent( NULL, FALSE, FALSE, NULL );
423 ses = WinHttpOpen( user_agent, 0, NULL, NULL, WINHTTP_FLAG_ASYNC );
424 ok(ses != NULL, "failed to open session %u\n", GetLastError());
426 WinHttpSetStatusCallback( ses, check_notification, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );
428 ret = WinHttpSetOption( ses, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
429 ok(ret, "failed to set context value %u\n", GetLastError());
431 setup_test( &info, winhttp_connect, __LINE__ );
432 con = WinHttpConnect( ses, codeweavers, 0, 0 );
433 ok(con != NULL, "failed to open a connection %u\n", GetLastError());
435 setup_test( &info, winhttp_open_request, __LINE__ );
436 req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
437 ok(req != NULL, "failed to open a request %u\n", GetLastError());
439 setup_test( &info, winhttp_send_request, __LINE__ );
440 ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
441 ok(ret, "failed to send request %u\n", GetLastError());
443 WaitForSingleObject( info.wait, INFINITE );
445 setup_test( &info, winhttp_receive_response, __LINE__ );
446 ret = WinHttpReceiveResponse( req, NULL );
447 ok(ret, "failed to receive response %u\n", GetLastError());
449 WaitForSingleObject( info.wait, INFINITE );
451 size = sizeof(status);
452 ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
453 ok(ret, "failed unexpectedly %u\n", GetLastError());
454 ok(status == 200, "request failed unexpectedly %u\n", status);
456 setup_test( &info, winhttp_query_data, __LINE__ );
457 ret = WinHttpQueryDataAvailable( req, NULL );
458 ok(ret, "failed to query data available %u\n", GetLastError());
460 WaitForSingleObject( info.wait, INFINITE );
462 setup_test( &info, winhttp_read_data, __LINE__ );
463 ret = WinHttpReadData( req, buffer, sizeof(buffer), NULL );
464 ok(ret, "failed to query data available %u\n", GetLastError());
466 WaitForSingleObject( info.wait, INFINITE );
468 setup_test( &info, winhttp_close_handle, __LINE__ );
469 WinHttpCloseHandle( req );
470 WinHttpCloseHandle( con );
471 WinHttpCloseHandle( ses );
473 WaitForSingleObject( info.wait, INFINITE );
474 CloseHandle( info.wait );
477 START_TEST (notification)
479 test_connection_cache();
480 test_redirect();
481 Sleep(2000); /* make sure previous connection is evicted from cache */
482 test_async();