Move repetitive code to two helper functions.
[wine/multimedia.git] / dlls / wininet / tests / http.c
blobe33976f973e9dacc1620ad59c1755db7c30f1ed3
1 /*
2 * Wininet - Http tests
4 * Copyright 2002 Aric Stewart
5 * Copyright 2004 Mike McCormack
6 * Copyright 2005 Hans Leidekker
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <stdarg.h>
24 #include <stdio.h>
25 #include <stdlib.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wininet.h"
31 #include "wine/test.h"
33 #define TEST_URL "http://www.winehq.org/site/about"
34 #define TEST_URL_PATH "/site/about"
35 #define TEST_URL2 "http://www.myserver.com/myscript.php?arg=1"
36 #define TEST_URL2_SERVER "www.myserver.com"
37 #define TEST_URL2_PATH "/myscript.php"
38 #define TEST_URL2_PATHEXTRA "/myscript.php?arg=1"
39 #define TEST_URL2_EXTRA "?arg=1"
40 #define TEST_URL3 "file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml"
42 int goon = 0;
44 static VOID WINAPI callback(
45 HINTERNET hInternet,
46 DWORD dwContext,
47 DWORD dwInternetStatus,
48 LPVOID lpvStatusInformation,
49 DWORD dwStatusInformationLength
52 char name[124];
54 switch (dwInternetStatus)
56 case INTERNET_STATUS_RESOLVING_NAME:
57 strcpy(name,"INTERNET_STATUS_RESOLVING_NAME");
58 break;
59 case INTERNET_STATUS_NAME_RESOLVED:
60 strcpy(name,"INTERNET_STATUS_NAME_RESOLVED");
61 break;
62 case INTERNET_STATUS_CONNECTING_TO_SERVER:
63 strcpy(name,"INTERNET_STATUS_CONNECTING_TO_SERVER");
64 break;
65 case INTERNET_STATUS_CONNECTED_TO_SERVER:
66 strcpy(name,"INTERNET_STATUS_CONNECTED_TO_SERVER");
67 break;
68 case INTERNET_STATUS_SENDING_REQUEST:
69 strcpy(name,"INTERNET_STATUS_SENDING_REQUEST");
70 break;
71 case INTERNET_STATUS_REQUEST_SENT:
72 strcpy(name,"INTERNET_STATUS_REQUEST_SENT");
73 break;
74 case INTERNET_STATUS_RECEIVING_RESPONSE:
75 strcpy(name,"INTERNET_STATUS_RECEIVING_RESPONSE");
76 break;
77 case INTERNET_STATUS_RESPONSE_RECEIVED:
78 strcpy(name,"INTERNET_STATUS_RESPONSE_RECEIVED");
79 break;
80 case INTERNET_STATUS_CTL_RESPONSE_RECEIVED:
81 strcpy(name,"INTERNET_STATUS_CTL_RESPONSE_RECEIVED");
82 break;
83 case INTERNET_STATUS_PREFETCH:
84 strcpy(name,"INTERNET_STATUS_PREFETCH");
85 break;
86 case INTERNET_STATUS_CLOSING_CONNECTION:
87 strcpy(name,"INTERNET_STATUS_CLOSING_CONNECTION");
88 break;
89 case INTERNET_STATUS_CONNECTION_CLOSED:
90 strcpy(name,"INTERNET_STATUS_CONNECTION_CLOSED");
91 break;
92 case INTERNET_STATUS_HANDLE_CREATED:
93 strcpy(name,"INTERNET_STATUS_HANDLE_CREATED");
94 break;
95 case INTERNET_STATUS_HANDLE_CLOSING:
96 strcpy(name,"INTERNET_STATUS_HANDLE_CLOSING");
97 break;
98 case INTERNET_STATUS_REQUEST_COMPLETE:
99 strcpy(name,"INTERNET_STATUS_REQUEST_COMPLETE");
100 goon = 1;
101 break;
102 case INTERNET_STATUS_REDIRECT:
103 strcpy(name,"INTERNET_STATUS_REDIRECT");
104 break;
105 case INTERNET_STATUS_INTERMEDIATE_RESPONSE:
106 strcpy(name,"INTERNET_STATUS_INTERMEDIATE_RESPONSE");
107 break;
110 trace("Callback %p 0x%lx %s(%li) %p %ld\n",hInternet,dwContext,name,
111 dwInternetStatus,lpvStatusInformation,dwStatusInformationLength);
114 static void winapi_test(int flags)
116 DWORD rc;
117 CHAR buffer[4000];
118 DWORD length;
119 DWORD out;
120 const char *types[2] = { "*", NULL };
121 HINTERNET hi, hic = 0, hor = 0;
123 trace("Starting with flags 0x%x\n",flags);
125 trace("InternetOpenA <--\n");
126 hi = InternetOpenA("",0x0,0x0,0x0,flags);
127 ok((hi != 0x0),"InternetOpen Failed\n");
128 trace("InternetOpenA -->\n");
130 if (hi == 0x0) goto abort;
132 InternetSetStatusCallback(hi,&callback);
134 trace("InternetConnectA <--\n");
135 hic=InternetConnectA(hi,"www.winehq.org",0x0,0x0,0x0,0x3,0x0,0xdeadbeef);
136 ok((hic != 0x0),"InternetConnect Failed\n");
137 trace("InternetConnectA -->\n");
139 if (hic == 0x0) goto abort;
141 trace("HttpOpenRequestA <--\n");
142 hor = HttpOpenRequestA(hic, "GET",
143 "/about/",
144 0x0,0x0,types,0x00400800,0xdeadbead);
145 if (hor == 0x0 && GetLastError() == 12007 /* ERROR_INTERNET_NAME_NOT_RESOLVED */) {
147 * If the internet name can't be resolved we are probably behind
148 * a firewall or in some other way not directly connected to the
149 * Internet. Not enough reason to fail the test. Just ignore and
150 * abort.
152 } else {
153 ok((hor != 0x0),"HttpOpenRequest Failed\n");
155 trace("HttpOpenRequestA -->\n");
157 if (hor == 0x0) goto abort;
159 trace("HttpSendRequestA -->\n");
160 SetLastError(0);
161 rc = HttpSendRequestA(hor, "", 0xffffffff,0x0,0x0);
162 if (flags)
163 ok(((rc == 0)&&(GetLastError()==997)),
164 "Asynchronous HttpSendRequest NOT returning 0 with error 997\n");
165 else
166 ok((rc != 0) || GetLastError() == 12007, /* 12007 == XP */
167 "Synchronous HttpSendRequest returning 0, error %ld\n", GetLastError());
168 trace("HttpSendRequestA <--\n");
170 while ((flags)&&(!goon))
171 Sleep(100);
173 length = 4;
174 rc = InternetQueryOptionA(hor,0x17,&out,&length);
175 trace("Option 0x17 -> %li %li\n",rc,out);
177 length = 100;
178 rc = InternetQueryOptionA(hor,0x22,buffer,&length);
179 trace("Option 0x22 -> %li %s\n",rc,buffer);
181 length = 4000;
182 rc = HttpQueryInfoA(hor,0x16,buffer,&length,0x0);
183 buffer[length]=0;
184 trace("Option 0x16 -> %li %s\n",rc,buffer);
186 length = 4000;
187 rc = InternetQueryOptionA(hor,0x22,buffer,&length);
188 buffer[length]=0;
189 trace("Option 0x22 -> %li %s\n",rc,buffer);
191 length = 16;
192 rc = HttpQueryInfoA(hor,0x5,&buffer,&length,0x0);
193 trace("Option 0x5 -> %li %s (%li)\n",rc,buffer,GetLastError());
195 length = 100;
196 rc = HttpQueryInfoA(hor,0x1,buffer,&length,0x0);
197 buffer[length]=0;
198 trace("Option 0x1 -> %li %s\n",rc,buffer);
200 length = 100;
201 trace("Entering Query loop\n");
203 while (length)
206 rc = InternetQueryDataAvailable(hor,&length,0x0,0x0);
207 ok(!(rc == 0 && length != 0),"InternetQueryDataAvailable failed\n");
209 if (length)
211 char *buffer;
212 buffer = HeapAlloc(GetProcessHeap(),0,length+1);
214 rc = InternetReadFile(hor,buffer,length,&length);
216 buffer[length]=0;
218 trace("ReadFile -> %li %li\n",rc,length);
220 HeapFree(GetProcessHeap(),0,buffer);
223 abort:
224 if (hor != 0x0) {
225 rc = InternetCloseHandle(hor);
226 ok ((rc != 0), "InternetCloseHandle of handle opened by HttpOpenRequestA failed\n");
227 rc = InternetCloseHandle(hor);
228 ok ((rc == 0), "Double close of handle opened by HttpOpenRequestA succeeded\n");
230 if (hic != 0x0) {
231 rc = InternetCloseHandle(hic);
232 ok ((rc != 0), "InternetCloseHandle of handle opened by InternetConnectA failed\n");
234 if (hi != 0x0) {
235 rc = InternetCloseHandle(hi);
236 ok ((rc != 0), "InternetCloseHandle of handle opened by InternetOpenA failed\n");
237 if (flags)
238 Sleep(100);
242 static void InternetOpenUrlA_test(void)
244 HINTERNET myhinternet, myhttp;
245 char buffer[0x400];
246 URL_COMPONENTSA urlComponents;
247 char protocol[32], hostName[1024], userName[1024];
248 char password[1024], extra[1024], path[1024];
249 DWORD size, readbytes, totalbytes=0;
250 BOOL ret;
252 myhinternet = InternetOpen("Winetest",0,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE);
253 ok((myhinternet != 0), "InternetOpen failed, error %lx\n",GetLastError());
254 size = 0x400;
255 ret = InternetCanonicalizeUrl(TEST_URL, buffer, &size,ICU_BROWSER_MODE);
256 ok( ret, "InternetCanonicalizeUrl failed, error %lx\n",GetLastError());
258 urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
259 urlComponents.lpszScheme = protocol;
260 urlComponents.dwSchemeLength = 32;
261 urlComponents.lpszHostName = hostName;
262 urlComponents.dwHostNameLength = 1024;
263 urlComponents.lpszUserName = userName;
264 urlComponents.dwUserNameLength = 1024;
265 urlComponents.lpszPassword = password;
266 urlComponents.dwPasswordLength = 1024;
267 urlComponents.lpszUrlPath = path;
268 urlComponents.dwUrlPathLength = 2048;
269 urlComponents.lpszExtraInfo = extra;
270 urlComponents.dwExtraInfoLength = 1024;
271 ret = InternetCrackUrl(TEST_URL, 0,0,&urlComponents);
272 ok( ret, "InternetCrackUrl failed, error %lx\n",GetLastError());
273 SetLastError(0);
274 myhttp = InternetOpenUrl(myhinternet, TEST_URL, 0, 0,
275 INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_TRANSFER_BINARY,0);
276 if (GetLastError() == 12007)
277 return; /* WinXP returns this when not connected to the net */
278 ok((myhttp != 0),"InternetOpenUrl failed, error %lx\n",GetLastError());
279 ret = InternetReadFile(myhttp, buffer,0x400,&readbytes);
280 ok( ret, "InternetReadFile failed, error %lx\n",GetLastError());
281 totalbytes += readbytes;
282 while (readbytes && InternetReadFile(myhttp, buffer,0x400,&readbytes))
283 totalbytes += readbytes;
284 trace("read 0x%08lx bytes\n",totalbytes);
287 static inline void copy_compsA(
288 URL_COMPONENTSA *src,
289 URL_COMPONENTSA *dst,
290 DWORD scheLen,
291 DWORD hostLen,
292 DWORD userLen,
293 DWORD passLen,
294 DWORD pathLen,
295 DWORD extrLen )
297 *dst = *src;
298 dst->dwSchemeLength = scheLen;
299 dst->dwHostNameLength = hostLen;
300 dst->dwUserNameLength = userLen;
301 dst->dwPasswordLength = passLen;
302 dst->dwUrlPathLength = pathLen;
303 dst->dwExtraInfoLength = extrLen;
304 SetLastError(0xfaceabad);
307 static inline void zero_compsA(
308 URL_COMPONENTSA *dst,
309 DWORD scheLen,
310 DWORD hostLen,
311 DWORD userLen,
312 DWORD passLen,
313 DWORD pathLen,
314 DWORD extrLen )
316 ZeroMemory(dst, sizeof(URL_COMPONENTSA));
317 dst->dwStructSize = sizeof(URL_COMPONENTSA);
318 dst->dwSchemeLength = scheLen;
319 dst->dwHostNameLength = hostLen;
320 dst->dwUserNameLength = userLen;
321 dst->dwPasswordLength = passLen;
322 dst->dwUrlPathLength = pathLen;
323 dst->dwExtraInfoLength = extrLen;
324 SetLastError(0xfaceabad);
327 static void InternetCrackUrl_test(void)
329 URL_COMPONENTSA urlSrc, urlComponents;
330 char protocol[32], hostName[1024], userName[1024];
331 char password[1024], extra[1024], path[1024];
332 BOOL ret;
334 ZeroMemory(&urlSrc, sizeof(urlSrc));
335 urlSrc.dwStructSize = sizeof(urlSrc);
336 urlSrc.lpszScheme = protocol;
337 urlSrc.lpszHostName = hostName;
338 urlSrc.lpszUserName = userName;
339 urlSrc.lpszPassword = password;
340 urlSrc.lpszUrlPath = path;
341 urlSrc.lpszExtraInfo = extra;
343 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024);
344 ret = InternetCrackUrl(TEST_URL, 0,0,&urlComponents);
345 ok( ret, "InternetCrackUrl failed, error %lx\n",GetLastError());
346 ok((strcmp(TEST_URL_PATH,path) == 0),"path cracked wrong\n");
348 /* Bug 1805: Confirm the returned lengths are correct: */
349 /* 1. When extra info split out explicitly */
350 zero_compsA(&urlComponents, 0, 1, 0, 0, 1, 1);
351 ok(InternetCrackUrlA(TEST_URL2, 0, 0, &urlComponents),"InternetCrackUrl failed, error 0x%lx\n", GetLastError());
352 ok(urlComponents.dwUrlPathLength == strlen(TEST_URL2_PATH),".dwUrlPathLength should be %d, but is %ld\n", strlen(TEST_URL2_PATH), urlComponents.dwUrlPathLength);
353 ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATH,strlen(TEST_URL2_PATH)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATH, urlComponents.lpszUrlPath);
354 ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %d, but is %ld\n", strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength);
355 ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName);
356 ok(urlComponents.dwExtraInfoLength == strlen(TEST_URL2_EXTRA),".dwExtraInfoLength should be %d, but is %ld\n", strlen(TEST_URL2_EXTRA), urlComponents.dwExtraInfoLength);
357 ok(!strncmp(urlComponents.lpszExtraInfo,TEST_URL2_EXTRA,strlen(TEST_URL2_EXTRA)),"lpszExtraInfo should be %s but is %s\n", TEST_URL2_EXTRA, urlComponents.lpszHostName);
359 /* 2. When extra info is not split out explicitly and is in url path */
360 zero_compsA(&urlComponents, 0, 1, 0, 0, 1, 0);
361 ok(InternetCrackUrlA(TEST_URL2, 0, 0, &urlComponents),"InternetCrackUrl failed with GLE 0x%lx\n",GetLastError());
362 ok(urlComponents.dwUrlPathLength == strlen(TEST_URL2_PATHEXTRA),".dwUrlPathLength should be %d, but is %ld\n", strlen(TEST_URL2_PATHEXTRA), urlComponents.dwUrlPathLength);
363 ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATHEXTRA,strlen(TEST_URL2_PATHEXTRA)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATHEXTRA, urlComponents.lpszUrlPath);
364 ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %d, but is %ld\n", strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength);
365 ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName);
367 /*3. Check for %20 */
368 copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 0);
369 ok(InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents),"InternetCrackUrl failed with GLE 0x%lx\n",GetLastError());
372 static void InternetCrackUrlW_test(void)
374 WCHAR url[] = {
375 'h','t','t','p',':','/','/','1','9','2','.','1','6','8','.','0','.','2','2','/',
376 'C','F','I','D','E','/','m','a','i','n','.','c','f','m','?','C','F','S','V','R',
377 '=','I','D','E','&','A','C','T','I','O','N','=','I','D','E','_','D','E','F','A',
378 'U','L','T', 0 };
379 URL_COMPONENTSW comp;
380 WCHAR scheme[20], host[20], user[20], pwd[20], urlpart[50], extra[50];
381 BOOL r;
383 urlpart[0]=0;
384 scheme[0]=0;
385 extra[0]=0;
386 host[0]=0;
387 user[0]=0;
388 pwd[0]=0;
389 memset(&comp, 0, sizeof comp);
390 comp.dwStructSize = sizeof comp;
391 comp.lpszScheme = scheme;
392 comp.dwSchemeLength = sizeof scheme;
393 comp.lpszHostName = host;
394 comp.dwHostNameLength = sizeof host;
395 comp.lpszUserName = user;
396 comp.dwUserNameLength = sizeof user;
397 comp.lpszPassword = pwd;
398 comp.dwPasswordLength = sizeof pwd;
399 comp.lpszUrlPath = urlpart;
400 comp.dwUrlPathLength = sizeof urlpart;
401 comp.lpszExtraInfo = extra;
402 comp.dwExtraInfoLength = sizeof extra;
404 r = InternetCrackUrlW(url, 0, 0, &comp );
405 ok( r, "failed to crack url\n");
406 ok( comp.dwSchemeLength == 4, "scheme length wrong\n");
407 ok( comp.dwHostNameLength == 12, "host length wrong\n");
408 ok( comp.dwUserNameLength == 0, "user length wrong\n");
409 ok( comp.dwPasswordLength == 0, "password length wrong\n");
410 ok( comp.dwUrlPathLength == 15, "url length wrong\n");
411 ok( comp.dwExtraInfoLength == 29, "extra length wrong\n");
413 urlpart[0]=0;
414 scheme[0]=0;
415 extra[0]=0;
416 host[0]=0;
417 user[0]=0;
418 pwd[0]=0;
419 memset(&comp, 0, sizeof comp);
420 comp.dwStructSize = sizeof comp;
421 comp.lpszHostName = host;
422 comp.dwHostNameLength = sizeof host;
423 comp.lpszUrlPath = urlpart;
424 comp.dwUrlPathLength = sizeof urlpart;
426 r = InternetCrackUrlW(url, 0, 0, &comp );
427 ok( r, "failed to crack url\n");
428 ok( comp.dwSchemeLength == 0, "scheme length wrong\n");
429 ok( comp.dwHostNameLength == 12, "host length wrong\n");
430 ok( comp.dwUserNameLength == 0, "user length wrong\n");
431 ok( comp.dwPasswordLength == 0, "password length wrong\n");
432 ok( comp.dwUrlPathLength == 44, "url length wrong\n");
433 ok( comp.dwExtraInfoLength == 0, "extra length wrong\n");
435 urlpart[0]=0;
436 scheme[0]=0;
437 extra[0]=0;
438 host[0]=0;
439 user[0]=0;
440 pwd[0]=0;
441 memset(&comp, 0, sizeof comp);
442 comp.dwStructSize = sizeof comp;
443 comp.lpszHostName = host;
444 comp.dwHostNameLength = sizeof host;
445 comp.lpszUrlPath = urlpart;
446 comp.dwUrlPathLength = sizeof urlpart;
447 comp.lpszExtraInfo = NULL;
448 comp.dwExtraInfoLength = sizeof extra;
450 r = InternetCrackUrlW(url, 0, 0, &comp );
451 ok( r, "failed to crack url\n");
452 ok( comp.dwSchemeLength == 0, "scheme length wrong\n");
453 ok( comp.dwHostNameLength == 12, "host length wrong\n");
454 ok( comp.dwUserNameLength == 0, "user length wrong\n");
455 ok( comp.dwPasswordLength == 0, "password length wrong\n");
456 ok( comp.dwUrlPathLength == 15, "url length wrong\n");
457 ok( comp.dwExtraInfoLength == 29, "extra length wrong\n");
460 static void InternetTimeFromSystemTimeA_test(void)
462 BOOL ret;
463 static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
464 char string[INTERNET_RFC1123_BUFSIZE];
465 static const char expect[] = "Fri, 07 Jan 2005 12:06:35 GMT";
467 ret = InternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
468 ok( ret, "InternetTimeFromSystemTimeA failed (%ld)\n", GetLastError() );
470 ok( !memcmp( string, expect, sizeof(expect) ),
471 "InternetTimeFromSystemTimeA failed (%ld)\n", GetLastError() );
474 static void InternetTimeFromSystemTimeW_test(void)
476 BOOL ret;
477 static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
478 WCHAR string[INTERNET_RFC1123_BUFSIZE + 1];
479 static const WCHAR expect[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
480 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
482 ret = InternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
483 ok( ret, "InternetTimeFromSystemTimeW failed (%ld)\n", GetLastError() );
485 ok( !memcmp( string, expect, sizeof(expect) ),
486 "InternetTimeFromSystemTimeW failed (%ld)\n", GetLastError() );
489 static void InternetTimeToSystemTimeA_test(void)
491 BOOL ret;
492 SYSTEMTIME time;
493 static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
494 static const char string[] = "Fri, 07 Jan 2005 12:06:35 GMT";
495 static const char string2[] = " fri 7 jan 2005 12 06 35";
497 ret = InternetTimeToSystemTimeA( string, &time, 0 );
498 ok( ret, "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
499 ok( !memcmp( &time, &expect, sizeof(expect) ),
500 "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
502 ret = InternetTimeToSystemTimeA( string2, &time, 0 );
503 ok( ret, "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
504 ok( !memcmp( &time, &expect, sizeof(expect) ),
505 "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
508 static void InternetTimeToSystemTimeW_test(void)
510 BOOL ret;
511 SYSTEMTIME time;
512 static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
513 static const WCHAR string[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
514 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
515 static const WCHAR string2[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
516 '1','2',' ','0','6',' ','3','5',0 };
517 static const WCHAR string3[] = { 'F','r',0 };
519 ret = InternetTimeToSystemTimeW( NULL, NULL, 0 );
520 ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
522 ret = InternetTimeToSystemTimeW( NULL, &time, 0 );
523 ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
525 ret = InternetTimeToSystemTimeW( string, NULL, 0 );
526 ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
528 ret = InternetTimeToSystemTimeW( string, &time, 1 );
529 ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
531 ret = InternetTimeToSystemTimeW( string, &time, 0 );
532 ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
533 ok( !memcmp( &time, &expect, sizeof(expect) ),
534 "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
536 ret = InternetTimeToSystemTimeW( string2, &time, 0 );
537 ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
538 ok( !memcmp( &time, &expect, sizeof(expect) ),
539 "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
541 ret = InternetTimeToSystemTimeW( string3, &time, 0 );
542 ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
545 START_TEST(http)
547 winapi_test(0x10000000);
548 winapi_test(0x00000000);
549 InternetCrackUrl_test();
550 InternetOpenUrlA_test();
551 InternetCrackUrlW_test();
552 InternetTimeFromSystemTimeA_test();
553 InternetTimeFromSystemTimeW_test();
554 InternetTimeToSystemTimeA_test();
555 InternetTimeToSystemTimeW_test();