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)
BOOL ret;
DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTW);
INTERNET_PER_CONN_OPTION_LISTW list = {size};
INTERNET_PER_CONN_OPTIONW *orig_settings;
static WCHAR proxy_srvW[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0};
INTERNET_PER_CONN_OPTIONW orig_settings[2], options[2];
static WCHAR proxy_srvW[] = L"proxy.example";
HINTERNET ses;
ses = InternetOpenA(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
......@@ -1274,116 +1274,81 @@ static void test_Option_PerConnectionOption(void)
/* get the process IE proxy server info, to restore later */
list.dwOptionCount = 2;
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;
list.pOptions = orig_settings;
orig_settings[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
orig_settings[1].dwOption = INTERNET_PER_CONN_FLAGS;
ret = InternetQueryOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
orig_settings = list.pOptions;
ok(ret, "InternetQueryOption should've succeeded\n");
/* set the process IE proxy server */
list.dwOptionCount = 2;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[0].Value.pszValue = proxy_srvW;
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
list.pOptions = options;
options[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
options[0].Value.pszValue = proxy_srvW;
options[1].dwOption = INTERNET_PER_CONN_FLAGS;
options[1].Value.dwValue = PROXY_TYPE_PROXY;
ret = InternetSetOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
HeapFree(GetProcessHeap(), 0, list.pOptions);
ok(ret, "InternetSetOption should've succeeded\n");
/* get & verify the process IE proxy server */
list.dwOptionCount = 2;
list.dwOptionError = 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;
options[0].Value.pszValue = NULL;
options[1].Value.dwValue = 0;
ret = InternetQueryOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
ok(!lstrcmpW(list.pOptions[0].Value.pszValue, proxy_srvW),
ok(ret, "InternetQueryOption should've succeeded\n");
ok(!lstrcmpW(options[0].Value.pszValue, proxy_srvW),
"Retrieved proxy server should've been %s, was: %s\n",
wine_dbgstr_w(proxy_srvW), wine_dbgstr_w(list.pOptions[0].Value.pszValue));
ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
wine_dbgstr_w(proxy_srvW), wine_dbgstr_w(options[0].Value.pszValue));
ok(options[1].Value.dwValue == PROXY_TYPE_PROXY,
"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());
GlobalFree(list.pOptions[0].Value.pszValue);
HeapFree(GetProcessHeap(), 0, list.pOptions);
GlobalFree(options[0].Value.pszValue);
/* disable the proxy server */
list.dwOptionCount = 1;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT;
options[0].dwOption = INTERNET_PER_CONN_FLAGS;
options[0].Value.dwValue = PROXY_TYPE_DIRECT;
ret = InternetSetOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
HeapFree(GetProcessHeap(), 0, list.pOptions);
ok(ret, "InternetSetOption should've succeeded\n");
/* verify that the proxy is disabled */
list.dwOptionCount = 1;
list.dwOptionError = 0;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
options[0].Value.dwValue = 0;
ret = InternetQueryOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
ok(list.pOptions[0].Value.dwValue == PROXY_TYPE_DIRECT,
ok(ret, "InternetQueryOption should've succeeded\n");
ok(options[0].Value.dwValue == PROXY_TYPE_DIRECT,
"Retrieved flags should've been PROXY_TYPE_DIRECT, was: %ld\n",
list.pOptions[0].Value.dwValue);
HeapFree(GetProcessHeap(), 0, list.pOptions);
options[0].Value.dwValue);
/* set the proxy flags to 'invalid' value */
list.dwOptionCount = 1;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
options[0].dwOption = INTERNET_PER_CONN_FLAGS;
options[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
ret = InternetSetOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
HeapFree(GetProcessHeap(), 0, list.pOptions);
ok(ret, "InternetSetOption should've succeeded\n");
/* verify that the proxy is enabled */
list.dwOptionCount = 1;
list.dwOptionError = 0;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
options[0].Value.dwValue = 0;
ret = InternetQueryOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
todo_wine ok(list.pOptions[0].Value.dwValue == PROXY_TYPE_DIRECT,
ok(ret, "InternetQueryOption should've succeeded\n");
todo_wine ok(options[0].Value.dwValue == PROXY_TYPE_DIRECT,
"Retrieved flags should've been PROXY_TYPE_DIRECT, was: %ld\n",
list.pOptions[0].Value.dwValue);
HeapFree(GetProcessHeap(), 0, list.pOptions);
options[0].Value.dwValue);
/* restore original settings */
list.dwOptionCount = 2;
list.pOptions = orig_settings;
ret = InternetSetOptionW(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
GlobalFree(list.pOptions[0].Value.pszValue);
HeapFree(GetProcessHeap(), 0, list.pOptions);
ok(ret, "InternetSetOption should've succeeded\n");
GlobalFree(orig_settings[0].Value.pszValue);
InternetCloseHandle(ses);
}
......@@ -1392,7 +1357,7 @@ static void test_Option_PerConnectionOptionA(void)
BOOL ret;
DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTA);
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";
HINTERNET ses;
......@@ -1401,89 +1366,66 @@ static void test_Option_PerConnectionOptionA(void)
/* get the process IE proxy server info, to restore later */
list.dwOptionCount = 2;
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;
list.pOptions = orig_settings;
orig_settings[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
orig_settings[1].dwOption = INTERNET_PER_CONN_FLAGS;
ret = InternetQueryOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
orig_settings = list.pOptions;
ok(ret, "InternetQueryOption should've succeeded\n");
/* set the process IE proxy server */
list.dwOptionCount = 2;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[0].Value.pszValue = proxy_srv;
list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
list.pOptions = options;
options[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
options[0].Value.pszValue = proxy_srv;
options[1].dwOption = INTERNET_PER_CONN_FLAGS;
options[1].Value.dwValue = PROXY_TYPE_PROXY;
ret = InternetSetOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
HeapFree(GetProcessHeap(), 0, list.pOptions);
ok(ret, "InternetSetOption should've succeeded\n");
/* get & verify the process IE proxy server */
list.dwOptionCount = 2;
list.dwOptionError = 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;
options[0].Value.pszValue = NULL;
options[1].Value.dwValue = 0;
ret = InternetQueryOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
ok(!lstrcmpA(list.pOptions[0].Value.pszValue, "proxy.example"),
ok(ret, "InternetQueryOption should've succeeded\n");
ok(!lstrcmpA(options[0].Value.pszValue, "proxy.example"),
"Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
proxy_srv, list.pOptions[0].Value.pszValue);
ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
proxy_srv, options[0].Value.pszValue);
ok(options[1].Value.dwValue == PROXY_TYPE_PROXY,
"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);
HeapFree(GetProcessHeap(), 0, list.pOptions);
GlobalFree(options[0].Value.pszValue);
/* test with NULL as proxy server */
list.dwOptionCount = 1;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA));
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
list.pOptions[0].Value.pszValue = NULL;
options[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
options[0].Value.pszValue = NULL;
ret = InternetSetOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
HeapFree(GetProcessHeap(), 0, list.pOptions);
ok(ret, "InternetSetOption should've succeeded\n");
/* get & verify the proxy server */
list.dwOptionCount = 1;
list.dwOptionError = 0;
list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA));
list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
options[0].Value.dwValue = 0xdeadbeef;
ret = InternetQueryOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size);
ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
ok(!list.pOptions[0].Value.pszValue,
ok(ret, "InternetQueryOption should've succeeded\n");
ok(!options[0].Value.pszValue,
"Retrieved proxy server should've been NULL, was: \"%s\"\n",
list.pOptions[0].Value.pszValue);
GlobalFree(list.pOptions[0].Value.pszValue);
HeapFree(GetProcessHeap(), 0, list.pOptions);
options[0].Value.pszValue);
/* restore original settings */
list.dwOptionCount = 2;
list.pOptions = orig_settings;
ret = InternetSetOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION,
&list, size);
ok(ret == TRUE, "InternetSetOption should've succeeded\n");
GlobalFree(list.pOptions[0].Value.pszValue);
HeapFree(GetProcessHeap(), 0, list.pOptions);
ret = InternetSetOptionA(ses, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size);
ok(ret, "InternetSetOption should've succeeded\n");
GlobalFree(orig_settings[0].Value.pszValue);
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