2 * Wininet - internet tests
4 * Copyright 2005 Vijay Kiran Kamuju
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "wine/test.h"
30 static void InternetQueryOptionA_test(void)
35 static const char useragent[] = {"Wininet Test"};
39 hinet = InternetOpenA(useragent,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
40 ok((hinet != 0x0),"InternetOpen Failed\n");
42 SetLastError(0xdeadbeef);
43 len=strlen(useragent)+1;
44 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
46 ok(len == strlen(useragent)+1,"Got wrong user agent length %ld instead of %d\n",len,strlen(useragent));
47 ok(retval == 0,"Got wrong return value %d\n",retval);
48 todo_wine ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%ld\n",err);
50 SetLastError(0xdeadbeef);
51 len=strlen(useragent)+1;
52 buffer=HeapAlloc(GetProcessHeap(),0,len);
53 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,buffer,&len);
55 todo_wine ok(!strcmp(useragent,buffer),"Got wrong user agent string %s instead of %s\n",buffer,useragent);
56 todo_wine ok(len == strlen(useragent),"Got wrong user agent length %ld instead of %d\n",len,strlen(useragent));
57 todo_wine ok(retval == 1,"Got wrong return value %d\n",retval);
58 ok(err == 0xdeadbeef, "Got wrong error code %ld\n",err);
59 HeapFree(GetProcessHeap(),0,buffer);
61 SetLastError(0xdeadbeef);
63 buffer=HeapAlloc(GetProcessHeap(),0,100);
64 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,buffer,&len);
66 todo_wine ok(len == strlen(useragent) + 1,"Got wrong user agent length %ld instead of %d\n", len, strlen(useragent) + 1);
67 ok(!retval, "Got wrong return value %d\n", retval);
68 todo_wine ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %ld\n", err);
69 HeapFree(GetProcessHeap(),0,buffer);
71 hurl = InternetConnectA(hinet,"www.winehq.com",INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,0,0);
73 SetLastError(0xdeadbeef);
75 retval = InternetQueryOptionA(hurl,INTERNET_OPTION_USER_AGENT,NULL,&len);
77 ok(len == 0,"Got wrong user agent length %ld instead of 0\n",len);
78 ok(retval == 0,"Got wrong return value %d\n",retval);
79 todo_wine ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %ld\n",err);
81 InternetCloseHandle(hurl);
82 InternetCloseHandle(hinet);
84 hinet = InternetOpenA("",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
85 ok((hinet != 0x0),"InternetOpen Failed\n");
87 SetLastError(0xdeadbeef);
89 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
91 todo_wine ok(len == 1,"Got wrong user agent length %ld instead of %d\n",len,1);
92 ok(retval == 0,"Got wrong return value %d\n",retval);
93 todo_wine ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%ld\n",err);
95 InternetCloseHandle(hinet);
97 hinet = InternetOpenA(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
98 ok((hinet != 0x0),"InternetOpen Failed\n");
99 SetLastError(0xdeadbeef);
101 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
103 todo_wine ok(len == 1,"Got wrong user agent length %ld instead of %d\n",len,1);
104 ok(retval == 0,"Got wrong return value %d\n",retval);
105 todo_wine ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%ld\n",err);
107 InternetCloseHandle(hinet);
110 static void test_get_cookie(void)
115 SetLastError(0xdeadbeef);
116 ret = InternetGetCookie("http://www.example.com", NULL, NULL, &len);
117 ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS,
118 "InternetGetCookie should have failed with %s and error %ld\n",
119 ret ? "TRUE" : "FALSE", GetLastError());
124 InternetQueryOptionA_test();