Commit a09e659a authored by Matijn Woudt's avatar Matijn Woudt Committed by Alexandre Julliard

winhttp/tests: Add timeout tests for WinHttp{Set, Query}Option.

parent 607cb33f
...@@ -1034,6 +1034,7 @@ static void test_set_default_proxy_config(void) ...@@ -1034,6 +1034,7 @@ static void test_set_default_proxy_config(void)
static void test_Timeouts (void) static void test_Timeouts (void)
{ {
BOOL ret; BOOL ret;
DWORD value, size;
HINTERNET ses, req, con; HINTERNET ses, req, con;
static const WCHAR codeweavers[] = {'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0}; static const WCHAR codeweavers[] = {'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
...@@ -1069,9 +1070,128 @@ static void test_Timeouts (void) ...@@ -1069,9 +1070,128 @@ static void test_Timeouts (void)
ret = WinHttpSetTimeouts(ses, 0, 0, 0, 0); ret = WinHttpSetTimeouts(ses, 0, 0, 0, 0);
todo_wine ok(ret, "%u\n", GetLastError()); todo_wine ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = WinHttpSetTimeouts(ses, 0x0123, 0x4567, 0x89ab, 0xcdef);
todo_wine ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0x4567, "Expected 0x4567, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0x89ab, "Expected 0x89ab, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xcdef, "Expected 0xcdef, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0;
ret = WinHttpSetOption(ses, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, sizeof(value));
todo_wine ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0, "Expected 0, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0;
ret = WinHttpSetOption(ses, WINHTTP_OPTION_SEND_TIMEOUT, &value, sizeof(value));
todo_wine ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0, "Expected 0, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0;
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, sizeof(value));
todo_wine ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0, "Expected 0, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xbeefdead;
ret = WinHttpSetOption(ses, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, sizeof(value));
todo_wine ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xbeefdead;
ret = WinHttpSetOption(ses, WINHTTP_OPTION_SEND_TIMEOUT, &value, sizeof(value));
todo_wine ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xbeefdead;
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, sizeof(value));
todo_wine ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
con = WinHttpConnect(ses, codeweavers, 0, 0); con = WinHttpConnect(ses, codeweavers, 0, 0);
ok(con != NULL, "failed to open a connection %u\n", GetLastError()); ok(con != NULL, "failed to open a connection %u\n", GetLastError());
/* Timeout values should match the last one set for session */
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(con, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(con, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(con, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = WinHttpSetTimeouts(con, -2, 0, 0, 0); ret = WinHttpSetTimeouts(con, -2, 0, 0, 0);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
...@@ -1102,9 +1222,86 @@ static void test_Timeouts (void) ...@@ -1102,9 +1222,86 @@ static void test_Timeouts (void)
ok(!ret && GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE, ok(!ret && GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE,
"expected ERROR_WINHTTP_INVALID_TYPE, got %u\n", GetLastError()); "expected ERROR_WINHTTP_INVALID_TYPE, got %u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0;
ret = WinHttpSetOption(con, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, sizeof(value));
ok(!ret && GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE,
"expected ERROR_WINHTTP_INVALID_TYPE, got %u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0;
ret = WinHttpSetOption(con, WINHTTP_OPTION_SEND_TIMEOUT, &value, sizeof(value));
ok(!ret && GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE,
"expected ERROR_WINHTTP_INVALID_TYPE, got %u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0;
ret = WinHttpSetOption(con, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, sizeof(value));
ok(!ret && GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE,
"expected ERROR_WINHTTP_INVALID_TYPE, got %u\n", GetLastError());
/* Changing timeout values for session should affect the values for connection */
SetLastError(0xdeadbeef);
value = 0xdead;
ret = WinHttpSetOption(ses, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, sizeof(value));
todo_wine ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(con, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xdead;
ret = WinHttpSetOption(ses, WINHTTP_OPTION_SEND_TIMEOUT, &value, sizeof(value));
todo_wine ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(con, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xdead;
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, sizeof(value));
todo_wine ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(con, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0); req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
ok(req != NULL, "failed to open a request %u\n", GetLastError()); ok(req != NULL, "failed to open a request %u\n", GetLastError());
/* Timeout values should match the last one set for session */
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = WinHttpSetTimeouts(req, -2, 0, 0, 0); ret = WinHttpSetTimeouts(req, -2, 0, 0, 0);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
...@@ -1133,6 +1330,178 @@ static void test_Timeouts (void) ...@@ -1133,6 +1330,178 @@ static void test_Timeouts (void)
ret = WinHttpSetTimeouts(req, 0, 0, 0, 0); ret = WinHttpSetTimeouts(req, 0, 0, 0, 0);
ok(ret, "%u\n", GetLastError()); ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = WinHttpSetTimeouts(req, 0xcdef, 0x89ab, 0x4567, 0x0123);
ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0x89ab, "Expected 0x89ab, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0x4567, "Expected 0x4567, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0x0123, "Expected 0x0123, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0;
ret = WinHttpSetOption(req, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, sizeof(value));
ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0, "Expected 0, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0;
ret = WinHttpSetOption(req, WINHTTP_OPTION_SEND_TIMEOUT, &value, sizeof(value));
ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0, "Expected 0, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0;
ret = WinHttpSetOption(req, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, sizeof(value));
ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0, "Expected 0, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xbeefdead;
ret = WinHttpSetOption(req, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, sizeof(value));
ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xbeefdead;
ret = WinHttpSetOption(req, WINHTTP_OPTION_SEND_TIMEOUT, &value, sizeof(value));
ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xbeefdead;
ret = WinHttpSetOption(req, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, sizeof(value));
ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
/* Changing timeout values for session should not affect the values for a request,
* neither should the other way around.
*/
SetLastError(0xdeadbeef);
value = 0xbeefdead;
ret = WinHttpSetOption(req, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, sizeof(value));
ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xbeefdead;
ret = WinHttpSetOption(req, WINHTTP_OPTION_SEND_TIMEOUT, &value, sizeof(value));
ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xbeefdead;
ret = WinHttpSetOption(req, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, sizeof(value));
ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xbeef;
ret = WinHttpSetOption(ses, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, sizeof(value));
todo_wine ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xbeef;
ret = WinHttpSetOption(ses, WINHTTP_OPTION_SEND_TIMEOUT, &value, sizeof(value));
todo_wine ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
SetLastError(0xdeadbeef);
value = 0xbeef;
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, sizeof(value));
todo_wine ok(ret, "%u\n", GetLastError());
SetLastError(0xdeadbeef);
value = 0xdeadbeef;
size = sizeof(DWORD);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
todo_wine ok(ret, "%u\n", GetLastError());
todo_wine ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
WinHttpCloseHandle(req); WinHttpCloseHandle(req);
WinHttpCloseHandle(con); WinHttpCloseHandle(con);
WinHttpCloseHandle(ses); WinHttpCloseHandle(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