Commit 70768564 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

wininet/tests: Cleanup INTERNET_OPTION_PER_CONNECTION_OPTION tests.

parent 9ea0a107
...@@ -1265,8 +1265,8 @@ static void test_Option_PerConnectionOption(void) ...@@ -1265,8 +1265,8 @@ static void test_Option_PerConnectionOption(void)
BOOL ret; BOOL ret;
DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTW); DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTW);
INTERNET_PER_CONN_OPTION_LISTW list = {size}; INTERNET_PER_CONN_OPTION_LISTW list = {size};
INTERNET_PER_CONN_OPTIONW *orig_settings; INTERNET_PER_CONN_OPTIONW orig_settings[2], options[2];
static WCHAR proxy_srvW[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0}; static WCHAR proxy_srvW[] = L"proxy.example";
HINTERNET ses; HINTERNET ses;
ses = InternetOpenA(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); ses = InternetOpenA(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
...@@ -1274,116 +1274,81 @@ static void test_Option_PerConnectionOption(void) ...@@ -1274,116 +1274,81 @@ static void test_Option_PerConnectionOption(void)
/* get the process IE proxy server info, to restore later */ /* get the process IE proxy server info, to restore later */
list.dwOptionCount = 2; list.dwOptionCount = 2;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW)); list.pOptions = orig_settings;
orig_settings[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER; orig_settings[1].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
ret = InternetQueryOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size); ret = InternetQueryOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n"); ok(ret, "InternetQueryOption should've succeeded\n");
orig_settings = list.pOptions;
/* set the process IE proxy server */ /* set the process IE proxy server */
list.dwOptionCount = 2; list.pOptions = options;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW)); options[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
options[0].Value.pszValue = proxy_srvW;
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER; options[1].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[0].Value.pszValue = proxy_srvW; options[1].Value.dwValue = PROXY_TYPE_PROXY;
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
ret = InternetSetOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size); ret = InternetSetOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n"); ok(ret, "InternetSetOption should've succeeded\n");
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* get & verify the process IE proxy server */ /* get & verify the process IE proxy server */
list.dwOptionCount = 2; options[0].Value.pszValue = NULL;
list.dwOptionError = 0; options[1].Value.dwValue = 0;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
ret = InternetQueryOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size); ret = InternetQueryOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n"); ok(ret, "InternetQueryOption should've succeeded\n");
ok(!lstrcmpW(list.pOptions[0].Value.pszValue, proxy_srvW), ok(!lstrcmpW(options[0].Value.pszValue, proxy_srvW),
"Retrieved proxy server should've been %s, was: %s\n", "Retrieved proxy server should've been %s, was: %s\n",
wine_dbgstr_w(proxy_srvW), wine_dbgstr_w(list.pOptions[0].Value.pszValue)); wine_dbgstr_w(proxy_srvW), wine_dbgstr_w(options[0].Value.pszValue));
ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY, ok(options[1].Value.dwValue == PROXY_TYPE_PROXY,
"Retrieved flags should've been PROXY_TYPE_PROXY, was: %ld\n", "Retrieved flags should've been PROXY_TYPE_PROXY, was: %ld\n",
list.pOptions[1].Value.dwValue); options[1].Value.dwValue);
ret = HeapValidate(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue); ret = HeapValidate(GetProcessHeap(), 0, options[0].Value.pszValue);
ok(ret, "HeapValidate failed, last error %lu\n", GetLastError()); ok(ret, "HeapValidate failed, last error %lu\n", GetLastError());
GlobalFree(options[0].Value.pszValue);
GlobalFree(list.pOptions[0].Value.pszValue);
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* disable the proxy server */ /* disable the proxy server */
list.dwOptionCount = 1; list.dwOptionCount = 1;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW)); options[0].dwOption = INTERNET_PER_CONN_FLAGS;
options[0].Value.dwValue = PROXY_TYPE_DIRECT;
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT;
ret = InternetSetOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size); ret = InternetSetOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n"); ok(ret, "InternetSetOption should've succeeded\n");
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* verify that the proxy is disabled */ /* verify that the proxy is disabled */
list.dwOptionCount = 1; options[0].Value.dwValue = 0;
list.dwOptionError = 0;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
ret = InternetQueryOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size); ret = InternetQueryOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n"); ok(ret, "InternetQueryOption should've succeeded\n");
ok(list.pOptions[0].Value.dwValue == PROXY_TYPE_DIRECT, ok(options[0].Value.dwValue == PROXY_TYPE_DIRECT,
"Retrieved flags should've been PROXY_TYPE_DIRECT, was: %ld\n", "Retrieved flags should've been PROXY_TYPE_DIRECT, was: %ld\n",
list.pOptions[0].Value.dwValue); options[0].Value.dwValue);
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* set the proxy flags to 'invalid' value */ /* set the proxy flags to 'invalid' value */
list.dwOptionCount = 1; options[0].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW)); options[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
ret = InternetSetOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size); ret = InternetSetOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n"); ok(ret, "InternetSetOption should've succeeded\n");
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* verify that the proxy is enabled */ /* verify that the proxy is enabled */
list.dwOptionCount = 1; options[0].Value.dwValue = 0;
list.dwOptionError = 0;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
ret = InternetQueryOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size); ret = InternetQueryOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n"); ok(ret, "InternetQueryOption should've succeeded\n");
todo_wine ok(list.pOptions[0].Value.dwValue == PROXY_TYPE_DIRECT, todo_wine ok(options[0].Value.dwValue == PROXY_TYPE_DIRECT,
"Retrieved flags should've been PROXY_TYPE_DIRECT, was: %ld\n", "Retrieved flags should've been PROXY_TYPE_DIRECT, was: %ld\n",
list.pOptions[0].Value.dwValue); options[0].Value.dwValue);
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* restore original settings */ /* restore original settings */
list.dwOptionCount = 2; list.dwOptionCount = 2;
list.pOptions = orig_settings; list.pOptions = orig_settings;
ret = InternetSetOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size); ret = InternetSetOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n"); ok(ret, "InternetSetOption should've succeeded\n");
GlobalFree(list.pOptions[0].Value.pszValue);
HeapFree(GetProcessHeap(), 0, list.pOptions);
GlobalFree(orig_settings[0].Value.pszValue);
InternetCloseHandle(ses); InternetCloseHandle(ses);
} }
...@@ -1392,7 +1357,7 @@ static void test_Option_PerConnectionOptionA(void) ...@@ -1392,7 +1357,7 @@ static void test_Option_PerConnectionOptionA(void)
BOOL ret; BOOL ret;
DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTA); DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTA);
INTERNET_PER_CONN_OPTION_LISTA list = {size}; INTERNET_PER_CONN_OPTION_LISTA list = {size};
INTERNET_PER_CONN_OPTIONA *orig_settings; INTERNET_PER_CONN_OPTIONA orig_settings[2], options[2];
char proxy_srv[] = "proxy.example"; char proxy_srv[] = "proxy.example";
HINTERNET ses; HINTERNET ses;
...@@ -1401,89 +1366,66 @@ static void test_Option_PerConnectionOptionA(void) ...@@ -1401,89 +1366,66 @@ static void test_Option_PerConnectionOptionA(void)
/* get the process IE proxy server info, to restore later */ /* get the process IE proxy server info, to restore later */
list.dwOptionCount = 2; list.dwOptionCount = 2;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA)); list.pOptions = orig_settings;
orig_settings[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER; orig_settings[1].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
ret = InternetQueryOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, ret = InternetQueryOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, &size); &list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n"); ok(ret, "InternetQueryOption should've succeeded\n");
orig_settings = list.pOptions;
/* set the process IE proxy server */ /* set the process IE proxy server */
list.dwOptionCount = 2; list.pOptions = options;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA)); options[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
options[0].Value.pszValue = proxy_srv;
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER; options[1].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[0].Value.pszValue = proxy_srv; options[1].Value.dwValue = PROXY_TYPE_PROXY;
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
ret = InternetSetOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, ret = InternetSetOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, size); &list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n"); ok(ret, "InternetSetOption should've succeeded\n");
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* get & verify the process IE proxy server */ /* get & verify the process IE proxy server */
list.dwOptionCount = 2; options[0].Value.pszValue = NULL;
list.dwOptionError = 0; options[1].Value.dwValue = 0;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
ret = InternetQueryOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, ret = InternetQueryOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, &size); &list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n"); ok(ret, "InternetQueryOption should've succeeded\n");
ok(!lstrcmpA(list.pOptions[0].Value.pszValue, "proxy.example"), ok(!lstrcmpA(options[0].Value.pszValue, "proxy.example"),
"Retrieved proxy server should've been \"%s\", was: \"%s\"\n", "Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
proxy_srv, list.pOptions[0].Value.pszValue); proxy_srv, options[0].Value.pszValue);
ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY, ok(options[1].Value.dwValue == PROXY_TYPE_PROXY,
"Retrieved flags should've been PROXY_TYPE_PROXY, was: %ld\n", "Retrieved flags should've been PROXY_TYPE_PROXY, was: %ld\n",
list.pOptions[1].Value.dwValue); options[1].Value.dwValue);
GlobalFree(list.pOptions[0].Value.pszValue); GlobalFree(options[0].Value.pszValue);
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* test with NULL as proxy server */ /* test with NULL as proxy server */
list.dwOptionCount = 1; list.dwOptionCount = 1;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA)); options[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER; options[0].Value.pszValue = NULL;
list.pOptions[0].Value.pszValue = NULL;
ret = InternetSetOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size); ret = InternetSetOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n"); ok(ret, "InternetSetOption should've succeeded\n");
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* get & verify the proxy server */ /* get & verify the proxy server */
list.dwOptionCount = 1; options[0].Value.dwValue = 0xdeadbeef;
list.dwOptionError = 0;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA));
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
ret = InternetQueryOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size); ret = InternetQueryOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n"); ok(ret, "InternetQueryOption should've succeeded\n");
ok(!list.pOptions[0].Value.pszValue, ok(!options[0].Value.pszValue,
"Retrieved proxy server should've been NULL, was: \"%s\"\n", "Retrieved proxy server should've been NULL, was: \"%s\"\n",
list.pOptions[0].Value.pszValue); options[0].Value.pszValue);
GlobalFree(list.pOptions[0].Value.pszValue);
HeapFree(GetProcessHeap(), 0, list.pOptions);
/* restore original settings */ /* restore original settings */
list.dwOptionCount = 2; list.dwOptionCount = 2;
list.pOptions = orig_settings; list.pOptions = orig_settings;
ret = InternetSetOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, ret = InternetSetOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size);
&list, size); ok(ret, "InternetSetOption should've succeeded\n");
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
GlobalFree(list.pOptions[0].Value.pszValue);
HeapFree(GetProcessHeap(), 0, list.pOptions);
GlobalFree(orig_settings[0].Value.pszValue);
InternetCloseHandle(ses); InternetCloseHandle(ses);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment