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
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"
44 static VOID WINAPI
callback(
47 DWORD dwInternetStatus
,
48 LPVOID lpvStatusInformation
,
49 DWORD dwStatusInformationLength
54 switch (dwInternetStatus
)
56 case INTERNET_STATUS_RESOLVING_NAME
:
57 strcpy(name
,"INTERNET_STATUS_RESOLVING_NAME");
59 case INTERNET_STATUS_NAME_RESOLVED
:
60 strcpy(name
,"INTERNET_STATUS_NAME_RESOLVED");
62 case INTERNET_STATUS_CONNECTING_TO_SERVER
:
63 strcpy(name
,"INTERNET_STATUS_CONNECTING_TO_SERVER");
65 case INTERNET_STATUS_CONNECTED_TO_SERVER
:
66 strcpy(name
,"INTERNET_STATUS_CONNECTED_TO_SERVER");
68 case INTERNET_STATUS_SENDING_REQUEST
:
69 strcpy(name
,"INTERNET_STATUS_SENDING_REQUEST");
71 case INTERNET_STATUS_REQUEST_SENT
:
72 strcpy(name
,"INTERNET_STATUS_REQUEST_SENT");
74 case INTERNET_STATUS_RECEIVING_RESPONSE
:
75 strcpy(name
,"INTERNET_STATUS_RECEIVING_RESPONSE");
77 case INTERNET_STATUS_RESPONSE_RECEIVED
:
78 strcpy(name
,"INTERNET_STATUS_RESPONSE_RECEIVED");
80 case INTERNET_STATUS_CTL_RESPONSE_RECEIVED
:
81 strcpy(name
,"INTERNET_STATUS_CTL_RESPONSE_RECEIVED");
83 case INTERNET_STATUS_PREFETCH
:
84 strcpy(name
,"INTERNET_STATUS_PREFETCH");
86 case INTERNET_STATUS_CLOSING_CONNECTION
:
87 strcpy(name
,"INTERNET_STATUS_CLOSING_CONNECTION");
89 case INTERNET_STATUS_CONNECTION_CLOSED
:
90 strcpy(name
,"INTERNET_STATUS_CONNECTION_CLOSED");
92 case INTERNET_STATUS_HANDLE_CREATED
:
93 strcpy(name
,"INTERNET_STATUS_HANDLE_CREATED");
95 case INTERNET_STATUS_HANDLE_CLOSING
:
96 strcpy(name
,"INTERNET_STATUS_HANDLE_CLOSING");
98 case INTERNET_STATUS_REQUEST_COMPLETE
:
99 strcpy(name
,"INTERNET_STATUS_REQUEST_COMPLETE");
102 case INTERNET_STATUS_REDIRECT
:
103 strcpy(name
,"INTERNET_STATUS_REDIRECT");
105 case INTERNET_STATUS_INTERMEDIATE_RESPONSE
:
106 strcpy(name
,"INTERNET_STATUS_INTERMEDIATE_RESPONSE");
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
)
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",
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
153 ok((hor
!= 0x0),"HttpOpenRequest Failed\n");
155 trace("HttpOpenRequestA -->\n");
157 if (hor
== 0x0) goto abort
;
159 trace("HttpSendRequestA -->\n");
161 rc
= HttpSendRequestA(hor
, "", 0xffffffff,0x0,0x0);
163 ok(((rc
== 0)&&(GetLastError()==997)),
164 "Asynchronous HttpSendRequest NOT returning 0 with error 997\n");
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
))
174 rc
= InternetQueryOptionA(hor
,0x17,&out
,&length
);
175 trace("Option 0x17 -> %li %li\n",rc
,out
);
178 rc
= InternetQueryOptionA(hor
,0x22,buffer
,&length
);
179 trace("Option 0x22 -> %li %s\n",rc
,buffer
);
182 rc
= HttpQueryInfoA(hor
,0x16,buffer
,&length
,0x0);
184 trace("Option 0x16 -> %li %s\n",rc
,buffer
);
187 rc
= InternetQueryOptionA(hor
,0x22,buffer
,&length
);
189 trace("Option 0x22 -> %li %s\n",rc
,buffer
);
192 rc
= HttpQueryInfoA(hor
,0x5,&buffer
,&length
,0x0);
193 trace("Option 0x5 -> %li %s (%li)\n",rc
,buffer
,GetLastError());
196 rc
= HttpQueryInfoA(hor
,0x1,buffer
,&length
,0x0);
198 trace("Option 0x1 -> %li %s\n",rc
,buffer
);
201 trace("Entering Query loop\n");
206 rc
= InternetQueryDataAvailable(hor
,&length
,0x0,0x0);
207 ok(!(rc
== 0 && length
!= 0),"InternetQueryDataAvailable failed\n");
212 buffer
= HeapAlloc(GetProcessHeap(),0,length
+1);
214 rc
= InternetReadFile(hor
,buffer
,length
,&length
);
218 trace("ReadFile -> %li %li\n",rc
,length
);
220 HeapFree(GetProcessHeap(),0,buffer
);
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");
231 rc
= InternetCloseHandle(hic
);
232 ok ((rc
!= 0), "InternetCloseHandle of handle opened by InternetConnectA failed\n");
235 rc
= InternetCloseHandle(hi
);
236 ok ((rc
!= 0), "InternetCloseHandle of handle opened by InternetOpenA failed\n");
242 static void InternetOpenUrlA_test(void)
244 HINTERNET myhinternet
, myhttp
;
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;
252 myhinternet
= InternetOpen("Winetest",0,NULL
,NULL
,INTERNET_FLAG_NO_CACHE_WRITE
);
253 ok((myhinternet
!= 0), "InternetOpen failed, error %lx\n",GetLastError());
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());
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
,
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
,
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];
335 ZeroMemory(&urlSrc
, sizeof(urlSrc
));
336 urlSrc
.dwStructSize
= sizeof(urlSrc
);
337 urlSrc
.lpszScheme
= protocol
;
338 urlSrc
.lpszHostName
= hostName
;
339 urlSrc
.lpszUserName
= userName
;
340 urlSrc
.lpszPassword
= password
;
341 urlSrc
.lpszUrlPath
= path
;
342 urlSrc
.lpszExtraInfo
= extra
;
344 copy_compsA(&urlSrc
, &urlComponents
, 32, 1024, 1024, 1024, 2048, 1024);
345 ret
= InternetCrackUrl(TEST_URL
, 0,0,&urlComponents
);
346 ok( ret
, "InternetCrackUrl failed, error %lx\n",GetLastError());
347 ok((strcmp(TEST_URL_PATH
,path
) == 0),"path cracked wrong\n");
349 /* Bug 1805: Confirm the returned lengths are correct: */
350 /* 1. When extra info split out explicitly */
351 zero_compsA(&urlComponents
, 0, 1, 0, 0, 1, 1);
352 ok(InternetCrackUrlA(TEST_URL2
, 0, 0, &urlComponents
),"InternetCrackUrl failed, error 0x%lx\n", GetLastError());
353 ok(urlComponents
.dwUrlPathLength
== strlen(TEST_URL2_PATH
),".dwUrlPathLength should be %ld, but is %ld\n", (DWORD
)strlen(TEST_URL2_PATH
), urlComponents
.dwUrlPathLength
);
354 ok(!strncmp(urlComponents
.lpszUrlPath
,TEST_URL2_PATH
,strlen(TEST_URL2_PATH
)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATH
, urlComponents
.lpszUrlPath
);
355 ok(urlComponents
.dwHostNameLength
== strlen(TEST_URL2_SERVER
),".dwHostNameLength should be %ld, but is %ld\n", (DWORD
)strlen(TEST_URL2_SERVER
), urlComponents
.dwHostNameLength
);
356 ok(!strncmp(urlComponents
.lpszHostName
,TEST_URL2_SERVER
,strlen(TEST_URL2_SERVER
)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER
, urlComponents
.lpszHostName
);
357 ok(urlComponents
.dwExtraInfoLength
== strlen(TEST_URL2_EXTRA
),".dwExtraInfoLength should be %ld, but is %ld\n", (DWORD
)strlen(TEST_URL2_EXTRA
), urlComponents
.dwExtraInfoLength
);
358 ok(!strncmp(urlComponents
.lpszExtraInfo
,TEST_URL2_EXTRA
,strlen(TEST_URL2_EXTRA
)),"lpszExtraInfo should be %s but is %s\n", TEST_URL2_EXTRA
, urlComponents
.lpszHostName
);
360 /* 2. When extra info is not split out explicitly and is in url path */
361 zero_compsA(&urlComponents
, 0, 1, 0, 0, 1, 0);
362 ok(InternetCrackUrlA(TEST_URL2
, 0, 0, &urlComponents
),"InternetCrackUrl failed with GLE 0x%lx\n",GetLastError());
363 ok(urlComponents
.dwUrlPathLength
== strlen(TEST_URL2_PATHEXTRA
),".dwUrlPathLength should be %ld, but is %ld\n", (DWORD
)strlen(TEST_URL2_PATHEXTRA
), urlComponents
.dwUrlPathLength
);
364 ok(!strncmp(urlComponents
.lpszUrlPath
,TEST_URL2_PATHEXTRA
,strlen(TEST_URL2_PATHEXTRA
)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATHEXTRA
, urlComponents
.lpszUrlPath
);
365 ok(urlComponents
.dwHostNameLength
== strlen(TEST_URL2_SERVER
),".dwHostNameLength should be %ld, but is %ld\n", (DWORD
)strlen(TEST_URL2_SERVER
), urlComponents
.dwHostNameLength
);
366 ok(!strncmp(urlComponents
.lpszHostName
,TEST_URL2_SERVER
,strlen(TEST_URL2_SERVER
)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER
, urlComponents
.lpszHostName
);
368 /*3. Check for %20 */
369 copy_compsA(&urlSrc
, &urlComponents
, 32, 1024, 1024, 1024, 2048, 1024);
370 ok(InternetCrackUrlA(TEST_URL3
, 0, ICU_DECODE
, &urlComponents
),"InternetCrackUrl failed with GLE 0x%lx\n",GetLastError());
373 /* Tests for lpsz* members pointing to real strings while
374 * some corresponding length members are set to zero */
375 copy_compsA(&urlSrc
, &urlComponents
, 0, 1024, 1024, 1024, 2048, 1024);
376 ret
= InternetCrackUrlA(TEST_URL3
, 0, ICU_DECODE
, &urlComponents
);
377 ok(ret
==1, "InternetCrackUrl returned %d with GLE=%ld (expected to return 1)\n",
378 ret
, GetLastError());
380 copy_compsA(&urlSrc
, &urlComponents
, 32, 0, 1024, 1024, 2048, 1024);
381 ret
= InternetCrackUrlA(TEST_URL3
, 0, ICU_DECODE
, &urlComponents
);
382 ok(ret
==1, "InternetCrackUrl returned %d with GLE=%ld (expected to return 1)\n",
383 ret
, GetLastError());
385 copy_compsA(&urlSrc
, &urlComponents
, 32, 1024, 0, 1024, 2048, 1024);
386 ret
= InternetCrackUrlA(TEST_URL3
, 0, ICU_DECODE
, &urlComponents
);
387 ok(ret
==1, "InternetCrackUrl returned %d with GLE=%ld (expected to return 1)\n",
388 ret
, GetLastError());
390 copy_compsA(&urlSrc
, &urlComponents
, 32, 1024, 1024, 0, 2048, 1024);
391 ret
= InternetCrackUrlA(TEST_URL3
, 0, ICU_DECODE
, &urlComponents
);
392 ok(ret
==1, "InternetCrackUrl returned %d with GLE=%ld (expected to return 1)\n",
393 ret
, GetLastError());
395 copy_compsA(&urlSrc
, &urlComponents
, 32, 1024, 1024, 1024, 0, 1024);
396 ret
= InternetCrackUrlA(TEST_URL3
, 0, ICU_DECODE
, &urlComponents
);
397 GLE
= GetLastError();
399 ok(ret
==0 && (GLE
==ERROR_INVALID_HANDLE
|| GLE
==ERROR_INSUFFICIENT_BUFFER
),
400 "InternetCrackUrl returned %d with GLE=%ld (expected to return 0 and ERROR_INVALID_HANDLE or ERROR_INSUFFICIENT_BUFFER)\n",
403 copy_compsA(&urlSrc
, &urlComponents
, 32, 1024, 1024, 1024, 2048, 0);
404 ret
= InternetCrackUrlA(TEST_URL3
, 0, ICU_DECODE
, &urlComponents
);
405 GLE
= GetLastError();
407 ok(ret
==0 && (GLE
==ERROR_INVALID_HANDLE
|| GLE
==ERROR_INSUFFICIENT_BUFFER
),
408 "InternetCrackUrl returned %d with GLE=%ld (expected to return 0 and ERROR_INVALID_HANDLE or ERROR_INSUFFICIENT_BUFFER)\n",
411 copy_compsA(&urlSrc
, &urlComponents
, 0, 0, 0, 0, 0, 0);
412 ret
= InternetCrackUrlA(TEST_URL3
, 0, ICU_DECODE
, &urlComponents
);
413 GLE
= GetLastError();
415 ok(ret
==0 && GLE
==ERROR_INVALID_PARAMETER
,
416 "InternetCrackUrl returned %d with GLE=%ld (expected to return 0 and ERROR_INVALID_PARAMETER)\n",
420 static void InternetCrackUrlW_test(void)
423 'h','t','t','p',':','/','/','1','9','2','.','1','6','8','.','0','.','2','2','/',
424 'C','F','I','D','E','/','m','a','i','n','.','c','f','m','?','C','F','S','V','R',
425 '=','I','D','E','&','A','C','T','I','O','N','=','I','D','E','_','D','E','F','A',
427 URL_COMPONENTSW comp
;
428 WCHAR scheme
[20], host
[20], user
[20], pwd
[20], urlpart
[50], extra
[50];
437 memset(&comp
, 0, sizeof comp
);
438 comp
.dwStructSize
= sizeof comp
;
439 comp
.lpszScheme
= scheme
;
440 comp
.dwSchemeLength
= sizeof scheme
;
441 comp
.lpszHostName
= host
;
442 comp
.dwHostNameLength
= sizeof host
;
443 comp
.lpszUserName
= user
;
444 comp
.dwUserNameLength
= sizeof user
;
445 comp
.lpszPassword
= pwd
;
446 comp
.dwPasswordLength
= sizeof pwd
;
447 comp
.lpszUrlPath
= urlpart
;
448 comp
.dwUrlPathLength
= sizeof urlpart
;
449 comp
.lpszExtraInfo
= extra
;
450 comp
.dwExtraInfoLength
= sizeof extra
;
452 r
= InternetCrackUrlW(url
, 0, 0, &comp
);
453 ok( r
, "failed to crack url\n");
454 ok( comp
.dwSchemeLength
== 4, "scheme length wrong\n");
455 ok( comp
.dwHostNameLength
== 12, "host length wrong\n");
456 ok( comp
.dwUserNameLength
== 0, "user length wrong\n");
457 ok( comp
.dwPasswordLength
== 0, "password length wrong\n");
458 ok( comp
.dwUrlPathLength
== 15, "url length wrong\n");
459 ok( comp
.dwExtraInfoLength
== 29, "extra length wrong\n");
467 memset(&comp
, 0, sizeof comp
);
468 comp
.dwStructSize
= sizeof comp
;
469 comp
.lpszHostName
= host
;
470 comp
.dwHostNameLength
= sizeof host
;
471 comp
.lpszUrlPath
= urlpart
;
472 comp
.dwUrlPathLength
= sizeof urlpart
;
474 r
= InternetCrackUrlW(url
, 0, 0, &comp
);
475 ok( r
, "failed to crack url\n");
476 ok( comp
.dwSchemeLength
== 0, "scheme length wrong\n");
477 ok( comp
.dwHostNameLength
== 12, "host length wrong\n");
478 ok( comp
.dwUserNameLength
== 0, "user length wrong\n");
479 ok( comp
.dwPasswordLength
== 0, "password length wrong\n");
480 ok( comp
.dwUrlPathLength
== 44, "url length wrong\n");
481 ok( comp
.dwExtraInfoLength
== 0, "extra length wrong\n");
489 memset(&comp
, 0, sizeof comp
);
490 comp
.dwStructSize
= sizeof comp
;
491 comp
.lpszHostName
= host
;
492 comp
.dwHostNameLength
= sizeof host
;
493 comp
.lpszUrlPath
= urlpart
;
494 comp
.dwUrlPathLength
= sizeof urlpart
;
495 comp
.lpszExtraInfo
= NULL
;
496 comp
.dwExtraInfoLength
= sizeof extra
;
498 r
= InternetCrackUrlW(url
, 0, 0, &comp
);
499 ok( r
, "failed to crack url\n");
500 ok( comp
.dwSchemeLength
== 0, "scheme length wrong\n");
501 ok( comp
.dwHostNameLength
== 12, "host length wrong\n");
502 ok( comp
.dwUserNameLength
== 0, "user length wrong\n");
503 ok( comp
.dwPasswordLength
== 0, "password length wrong\n");
504 ok( comp
.dwUrlPathLength
== 15, "url length wrong\n");
505 ok( comp
.dwExtraInfoLength
== 29, "extra length wrong\n");
508 static void InternetTimeFromSystemTimeA_test(void)
511 static const SYSTEMTIME time
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
512 char string
[INTERNET_RFC1123_BUFSIZE
];
513 static const char expect
[] = "Fri, 07 Jan 2005 12:06:35 GMT";
515 ret
= InternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
516 ok( ret
, "InternetTimeFromSystemTimeA failed (%ld)\n", GetLastError() );
518 ok( !memcmp( string
, expect
, sizeof(expect
) ),
519 "InternetTimeFromSystemTimeA failed (%ld)\n", GetLastError() );
522 static void InternetTimeFromSystemTimeW_test(void)
525 static const SYSTEMTIME time
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
526 WCHAR string
[INTERNET_RFC1123_BUFSIZE
+ 1];
527 static const WCHAR expect
[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
528 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
530 ret
= InternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
531 ok( ret
, "InternetTimeFromSystemTimeW failed (%ld)\n", GetLastError() );
533 ok( !memcmp( string
, expect
, sizeof(expect
) ),
534 "InternetTimeFromSystemTimeW failed (%ld)\n", GetLastError() );
537 static void InternetTimeToSystemTimeA_test(void)
541 static const SYSTEMTIME expect
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
542 static const char string
[] = "Fri, 07 Jan 2005 12:06:35 GMT";
543 static const char string2
[] = " fri 7 jan 2005 12 06 35";
545 ret
= InternetTimeToSystemTimeA( string
, &time
, 0 );
546 ok( ret
, "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
547 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
548 "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
550 ret
= InternetTimeToSystemTimeA( string2
, &time
, 0 );
551 ok( ret
, "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
552 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
553 "InternetTimeToSystemTimeA failed (%ld)\n", GetLastError() );
556 static void InternetTimeToSystemTimeW_test(void)
560 static const SYSTEMTIME expect
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
561 static const WCHAR string
[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
562 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
563 static const WCHAR string2
[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
564 '1','2',' ','0','6',' ','3','5',0 };
565 static const WCHAR string3
[] = { 'F','r',0 };
567 ret
= InternetTimeToSystemTimeW( NULL
, NULL
, 0 );
568 ok( !ret
, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
570 ret
= InternetTimeToSystemTimeW( NULL
, &time
, 0 );
571 ok( !ret
, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
573 ret
= InternetTimeToSystemTimeW( string
, NULL
, 0 );
574 ok( !ret
, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
576 ret
= InternetTimeToSystemTimeW( string
, &time
, 1 );
577 ok( ret
, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
579 ret
= InternetTimeToSystemTimeW( string
, &time
, 0 );
580 ok( ret
, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
581 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
582 "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
584 ret
= InternetTimeToSystemTimeW( string2
, &time
, 0 );
585 ok( ret
, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
586 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
587 "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
589 ret
= InternetTimeToSystemTimeW( string3
, &time
, 0 );
590 ok( ret
, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
595 winapi_test(0x10000000);
596 winapi_test(0x00000000);
597 InternetCrackUrl_test();
598 InternetOpenUrlA_test();
599 InternetCrackUrlW_test();
600 InternetTimeFromSystemTimeA_test();
601 InternetTimeFromSystemTimeW_test();
602 InternetTimeToSystemTimeA_test();
603 InternetTimeToSystemTimeW_test();