Matijn Woudt : winhttp/tests: Add tests for WinHttpSetTimeouts.

Alexandre Julliard julliard at winehq.org
Thu Jan 28 11:15:34 CST 2010


Module: wine
Branch: master
Commit: 5a712037aff785e943bc29f15fb065bb3cb48c3a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5a712037aff785e943bc29f15fb065bb3cb48c3a

Author: Matijn Woudt <tijnema at gmail.com>
Date:   Wed Jan 27 23:01:29 2010 +0100

winhttp/tests: Add tests for WinHttpSetTimeouts.

---

 dlls/winhttp/tests/winhttp.c |  108 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 108 insertions(+), 0 deletions(-)

diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c
index f0b46b6..bddf871 100644
--- a/dlls/winhttp/tests/winhttp.c
+++ b/dlls/winhttp/tests/winhttp.c
@@ -1031,6 +1031,113 @@ static void test_set_default_proxy_config(void)
            GetLastError());
 }
 
+static void test_Timeouts (void)
+{
+    BOOL ret;
+    HINTERNET ses, req, con;
+    static const WCHAR codeweavers[] = {'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
+
+
+    ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
+    ok(ses != NULL, "failed to open session %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(ses, -2, 0, 0, 0);
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+       "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(ses, 0, -2, 0, 0);
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+       "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(ses, 0, 0, -2, 0);
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+       "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(ses, 0, 0, 0, -2);
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+       "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(ses, -1, -1, -1, -1);
+    todo_wine ok(ret, "%u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(ses, 0, 0, 0, 0);
+    todo_wine ok(ret, "%u\n", GetLastError());
+
+    con = WinHttpConnect(ses, codeweavers, 0, 0);
+    ok(con != NULL, "failed to open a connection %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(con, -2, 0, 0, 0);
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+       "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(con, 0, -2, 0, 0);
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+       "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(con, 0, 0, -2, 0);
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+       "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(con, 0, 0, 0, -2);
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+       "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(con, -1, -1, -1, -1);
+    ok(!ret && GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE,
+       "expected ERROR_WINHTTP_INVALID_TYPE, got %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(con, 0, 0, 0, 0);
+    ok(!ret && GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE,
+       "expected ERROR_WINHTTP_INVALID_TYPE, got %u\n", GetLastError());
+
+    req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
+    ok(req != NULL, "failed to open a request %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(req, -2, 0, 0, 0);
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+       "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(req, 0, -2, 0, 0);
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+       "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(req, 0, 0, -2, 0);
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+       "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(req, 0, 0, 0, -2);
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+       "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(req, -1, -1, -1, -1);
+    ok(ret, "%u\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = WinHttpSetTimeouts(req, 0, 0, 0, 0);
+    ok(ret, "%u\n", GetLastError());
+
+    WinHttpCloseHandle(req);
+    WinHttpCloseHandle(con);
+    WinHttpCloseHandle(ses);
+}
+
 START_TEST (winhttp)
 {
     test_OpenRequest();
@@ -1043,4 +1150,5 @@ START_TEST (winhttp)
     test_QueryOption();
     test_set_default_proxy_config();
     test_empty_headers_param();
+    test_Timeouts();
 }




More information about the wine-cvs mailing list