Author: tfaber Date: Wed Jun 20 13:13:51 2012 New Revision: 56759
URL: http://svn.reactos.org/svn/reactos?rev=56759&view=rev Log: [WININET_WINETEST] - Sync to Wine 1.5.4
Modified: trunk/rostests/winetests/wininet/CMakeLists.txt trunk/rostests/winetests/wininet/ftp.c trunk/rostests/winetests/wininet/http.c trunk/rostests/winetests/wininet/internet.c trunk/rostests/winetests/wininet/urlcache.c
Modified: trunk/rostests/winetests/wininet/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/CMakeLis... ============================================================================== --- trunk/rostests/winetests/wininet/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/winetests/wininet/CMakeLists.txt [iso-8859-1] Wed Jun 20 13:13:51 2012 @@ -2,8 +2,7 @@ remove_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502)
add_definitions( - -D__ROS_LONG64__ - -D_DLL -D__USE_CRTIMP) + -D__ROS_LONG64__)
list(APPEND SOURCE ftp.c
Modified: trunk/rostests/winetests/wininet/ftp.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/ftp.c?re... ============================================================================== --- trunk/rostests/winetests/wininet/ftp.c [iso-8859-1] (original) +++ trunk/rostests/winetests/wininet/ftp.c [iso-8859-1] Wed Jun 20 13:13:51 2012 @@ -726,8 +726,7 @@ { TRUE, ERROR_SUCCESS, "SIZE\t/welcome.msg" }, { TRUE, ERROR_SUCCESS, "SIZE /welcome.msg" }, { FALSE, ERROR_INTERNET_EXTENDED_ERROR, "PWD /welcome.msg" }, - { TRUE, ERROR_SUCCESS, "PWD" }, - { TRUE, ERROR_SUCCESS, "PWD\r\n" } + { TRUE, ERROR_SUCCESS, "PWD" } };
if (!pFtpCommandA)
Modified: trunk/rostests/winetests/wininet/http.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/http.c?r... ============================================================================== --- trunk/rostests/winetests/wininet/http.c [iso-8859-1] (original) +++ trunk/rostests/winetests/wininet/http.c [iso-8859-1] Wed Jun 20 13:13:51 2012 @@ -103,11 +103,11 @@ static const char *status_string[MAX_INTERNET_STATUS];
static HANDLE hCompleteEvent, conn_close_event; +static DWORD req_error;
#define TESTF_REDIRECT 0x01 #define TESTF_COMPRESSED 0x02 -#define TESTF_ALLOW_COOKIE 0x04 -#define TESTF_CHUNKED 0x08 +#define TESTF_CHUNKED 0x04
typedef struct { const char *url; @@ -143,7 +143,7 @@ "www.codeweavers.com", "", "Accept-Encoding: gzip, deflate", - TESTF_COMPRESSED|TESTF_ALLOW_COOKIE + TESTF_COMPRESSED }, { "http://test.winehq.org/tests/post.php", @@ -176,6 +176,48 @@ RegCloseKey(internet_settings);
return proxy_enable != 0; +} + +#define test_status_code(a,b) _test_status_code(__LINE__,a,b) +static void _test_status_code(unsigned line, HINTERNET req, DWORD excode) +{ + DWORD code, size, index; + char exbuf[10], bufa[10]; + BOOL res; + + code = 0xdeadbeef; + size = sizeof(code); + res = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, &code, &size, NULL); + ok_(__FILE__,line)(res, "HttpQueryInfo(HTTP_QUERY_STATUS_CODE|number) failed: %u\n", GetLastError()); + ok_(__FILE__,line)(code == excode, "code = %d, expected %d\n", code, excode); + + code = 0xdeadbeef; + index = 0; + size = sizeof(code); + res = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, &code, &size, &index); + ok_(__FILE__,line)(res, "HttpQueryInfo(HTTP_QUERY_STATUS_CODE|number index) failed: %u\n", GetLastError()); + ok_(__FILE__,line)(code == excode, "code = %d, expected %d\n", code, excode); + ok_(__FILE__,line)(!index, "index = %d, expected 0\n", code); + + sprintf(exbuf, "%u", excode); + + size = sizeof(bufa); + res = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE, bufa, &size, NULL); + ok_(__FILE__,line)(res, "HttpQueryInfo(HTTP_QUERY_STATUS_CODE) failed: %u\n", GetLastError()); + ok_(__FILE__,line)(!strcmp(bufa, exbuf), "unexpected status code %s, expected %s", bufa, exbuf); + + code = 0xdeadbeef; + index = 1; + size = sizeof(code); + res = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE||HTTP_QUERY_FLAG_NUMBER, &code, &size, &index); + ok_(__FILE__,line)(!res && GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, + "HttpQueryInfo failed: %x(%d)\n", res, GetLastError()); + + code = 0xdeadbeef; + size = sizeof(code); + res = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE||HTTP_QUERY_FLAG_REQUEST_HEADERS, &code, &size, NULL); + ok_(__FILE__,line)(!res && GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, + "HttpQueryInfo failed: %x(%d)\n", res, GetLastError()); }
static int close_handle_cnt; @@ -287,9 +329,11 @@ ok(dwStatusInformationLength == sizeof(INTERNET_ASYNC_RESULT), "info length should be sizeof(INTERNET_ASYNC_RESULT) instead of %d\n", dwStatusInformationLength); + ok(iar->dwResult == 1 || iar->dwResult == 0, "iar->dwResult = %ld\n", iar->dwResult); trace("%04x:Callback %p 0x%lx INTERNET_STATUS_REQUEST_COMPLETE {%ld,%d} %d\n", GetCurrentThreadId(), hInternet, dwContext, iar->dwResult,iar->dwError,dwStatusInformationLength); + req_error = iar->dwError; SetEvent(hCompleteEvent); break; } @@ -396,10 +440,8 @@ CHECK_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED); CHECK_NOT_NOTIFIED(INTERNET_STATUS_RESOLVING_NAME); CHECK_NOT_NOTIFIED(INTERNET_STATUS_NAME_RESOLVED); - if(test->flags & TESTF_ALLOW_COOKIE) { - SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT); - SET_OPTIONAL(INTERNET_STATUS_COOKIE_RECEIVED); - } + SET_OPTIONAL2(INTERNET_STATUS_COOKIE_SENT,2); + SET_OPTIONAL2(INTERNET_STATUS_COOKIE_RECEIVED,2); if (first_connection_to_test_url) { SET_EXPECT(INTERNET_STATUS_RESOLVING_NAME); @@ -431,6 +473,8 @@ goto abort; }
+ test_status_code(hor, 0); + trace("HttpSendRequestA -->\n"); if(test->post_data) { post_len = strlen(test->post_data); @@ -447,14 +491,14 @@ "Synchronous HttpSendRequest returning 0, error %u\n", GetLastError()); trace("HttpSendRequestA <--\n");
- if (flags & INTERNET_FLAG_ASYNC) + if (flags & INTERNET_FLAG_ASYNC) { WaitForSingleObject(hCompleteEvent, INFINITE); + ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error); + } HeapFree(GetProcessHeap(), 0, post_data);
- if(test->flags & TESTF_ALLOW_COOKIE) { - CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); - CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_RECEIVED); - } + CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); + CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_RECEIVED); if (first_connection_to_test_url) { if (! proxy_active()) @@ -549,6 +593,7 @@ ok(!length, "InternetQueryDataAvailable returned ERROR_IO_PENDING and %u length\n", length); WaitForSingleObject(hCompleteEvent, INFINITE); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); + ok(req_error, "req_error = 0\n"); continue; }else { ok(0, "InternetQueryDataAvailable failed: %u\n", GetLastError()); @@ -760,6 +805,7 @@ SET_EXPECT(INTERNET_STATUS_RESOLVING_NAME); SET_EXPECT(INTERNET_STATUS_NAME_RESOLVED); } + SET_OPTIONAL2(INTERNET_STATUS_COOKIE_SENT, 2); SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER); SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER); SET_EXPECT2(INTERNET_STATUS_SENDING_REQUEST, 2); @@ -787,8 +833,10 @@ "Synchronous HttpSendRequest returning 0, error %u\n", GetLastError()); trace("HttpSendRequestA <--\n");
- if (!rc && (GetLastError() == ERROR_IO_PENDING)) + if (!rc && (GetLastError() == ERROR_IO_PENDING)) { WaitForSingleObject(hCompleteEvent, INFINITE); + ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error); + }
if (first_connection_to_test_url) { @@ -811,6 +859,7 @@ CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); else todo_wine CHECK_NOT_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); + CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); /* Sent on WinXP only if first_connection_to_test_url is TRUE, on Win98 always sent */ CLEAR_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER); CLEAR_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER); @@ -841,7 +890,7 @@ SET_EXPECT(INTERNET_STATUS_RESPONSE_RECEIVED); rc = InternetReadFileEx(hor, &inetbuffers, 0, 0xdeadcafe); ok(rc, "InternetReadFileEx failed with error %u\n", GetLastError()); - trace("read %i bytes\n", inetbuffers.dwBufferLength); + trace("read %i bytes\n", inetbuffers.dwBufferLength); todo_wine { CHECK_NOT_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); @@ -879,6 +928,7 @@ WaitForSingleObject(hCompleteEvent, INFINITE); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); CHECK_NOT_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED); + ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error); } else { @@ -1842,7 +1892,7 @@ static void test_proxy_indirect(int port) { HINTERNET hi, hc, hr; - DWORD r, sz, val; + DWORD r, sz; char buffer[0x40];
hi = InternetOpen(NULL, 0, NULL, NULL, 0); @@ -1867,15 +1917,7 @@ } ok(!strcmp(buffer, "Basic realm="placebo""), "proxy auth info wrong\n");
- sz = sizeof buffer; - r = HttpQueryInfo(hr, HTTP_QUERY_STATUS_CODE, buffer, &sz, NULL); - ok(r, "HttpQueryInfo failed\n"); - ok(!strcmp(buffer, "407"), "proxy code wrong\n"); - - sz = sizeof val; - r = HttpQueryInfo(hr, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, &val, &sz, NULL); - ok(r, "HttpQueryInfo failed\n"); - ok(val == 407, "proxy code wrong\n"); + test_status_code(hr, 407);
sz = sizeof buffer; r = HttpQueryInfo(hr, HTTP_QUERY_STATUS_TEXT, buffer, &sz, NULL); @@ -1925,11 +1967,7 @@ r = HttpSendRequest(hr, NULL, 0, NULL, 0); ok(r, "HttpSendRequest failed\n");
- sz = sizeof buffer; - r = HttpQueryInfo(hr, HTTP_QUERY_STATUS_CODE, buffer, &sz, NULL); - ok(r, "HttpQueryInfo failed\n"); - ok(!strcmp(buffer, "407"), "proxy code wrong\n"); - + test_status_code(hr, 407);
/* set the user + password then try again */ todo_wine { @@ -1980,11 +2018,7 @@ ret = HttpSendRequest(request, NULL, 0, NULL, 0); ok(ret, "HttpSendRequest failed\n");
- status = 0; - size = sizeof(status); - ret = HttpQueryInfo( request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL ); - ok(ret, "HttpQueryInfo failed\n"); - ok(status == 200, "request failed with status %u\n", status); + test_status_code(request, 200);
InternetCloseHandle(request);
@@ -2025,7 +2059,6 @@ static void test_connection_header(int port) { HINTERNET ses, con, req; - DWORD size, status; BOOL ret;
ses = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); @@ -2040,11 +2073,7 @@ ret = HttpSendRequest(req, NULL, 0, NULL, 0); ok(ret, "HttpSendRequest failed\n");
- status = 0; - size = sizeof(status); - ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL); - ok(ret, "HttpQueryInfo failed\n"); - ok(status == 200, "request failed with status %u\n", status); + test_status_code(req, 200);
InternetCloseHandle(req);
@@ -2054,11 +2083,7 @@ ret = HttpSendRequest(req, NULL, 0, NULL, 0); ok(ret, "HttpSendRequest failed\n");
- status = 0; - size = sizeof(status); - ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL); - ok(ret, "HttpQueryInfo failed\n"); - ok(status == 200, "request failed with status %u\n", status); + test_status_code(req, 200);
InternetCloseHandle(req);
@@ -2068,11 +2093,7 @@ ret = HttpSendRequest(req, NULL, 0, NULL, 0); ok(ret, "HttpSendRequest failed\n");
- status = 0; - size = sizeof(status); - ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL); - ok(ret, "HttpQueryInfo failed\n"); - ok(status == 200, "request failed with status %u\n", status); + test_status_code(req, 200);
InternetCloseHandle(req);
@@ -2082,11 +2103,7 @@ ret = HttpSendRequest(req, NULL, 0, NULL, 0); ok(ret, "HttpSendRequest failed\n");
- status = 0; - size = sizeof(status); - ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL); - ok(ret, "HttpQueryInfo failed\n"); - ok(status == 200, "request failed with status %u\n", status); + test_status_code(req, 200);
InternetCloseHandle(req); InternetCloseHandle(con); @@ -2165,6 +2182,7 @@ ok(!res && (GetLastError() == ERROR_IO_PENDING), "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n"); WaitForSingleObject(hCompleteEvent, INFINITE); + ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER); @@ -2222,6 +2240,7 @@ ok(!res && (GetLastError() == ERROR_IO_PENDING), "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n"); WaitForSingleObject(hCompleteEvent, INFINITE); + ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER); @@ -2251,6 +2270,7 @@ SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); SetEvent(conn_close_event); WaitForSingleObject(hCompleteEvent, INFINITE); + ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error); CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); @@ -2292,7 +2312,7 @@ static void test_cookie_header(int port) { HINTERNET ses, con, req; - DWORD size, status, error; + DWORD size, error; BOOL ret; char buffer[64];
@@ -2327,11 +2347,7 @@ ret = HttpSendRequest(req, NULL, 0, NULL, 0); ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
- status = 0; - size = sizeof(status); - ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL); - ok(ret, "HttpQueryInfo failed\n"); - ok(status == 200, "request failed with status %u\n", status); + test_status_code(req, 200);
buffer[0] = 0; size = sizeof(buffer); @@ -2347,7 +2363,6 @@ static void test_basic_authentication(int port) { HINTERNET session, connect, request; - DWORD size, status; BOOL ret;
session = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); @@ -2362,11 +2377,7 @@ ret = HttpSendRequest(request, NULL, 0, NULL, 0); ok(ret, "HttpSendRequest failed %u\n", GetLastError());
- status = 0; - size = sizeof(status); - ret = HttpQueryInfo( request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL ); - ok(ret, "HttpQueryInfo failed\n"); - ok(status == 200, "request failed with status %u\n", status); + test_status_code(request, 200);
InternetCloseHandle(request); InternetCloseHandle(connect); @@ -2376,7 +2387,7 @@ static void test_invalid_response_headers(int port) { HINTERNET session, connect, request; - DWORD size, status; + DWORD size; BOOL ret; char buffer[256];
@@ -2392,11 +2403,7 @@ ret = HttpSendRequest(request, NULL, 0, NULL, 0); ok(ret, "HttpSendRequest failed %u\n", GetLastError());
- status = 0; - size = sizeof(status); - ret = HttpQueryInfo( request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL ); - ok(ret, "HttpQueryInfo failed\n"); - ok(status == 401, "unexpected status %u\n", status); + test_status_code(request, 401);
buffer[0] = 0; size = sizeof(buffer); @@ -2419,7 +2426,7 @@ static void test_response_without_headers(int port) { HINTERNET hi, hc, hr; - DWORD r, count, size, status; + DWORD r, count, size; char buffer[1024];
SetLastError(0xdeadbeef); @@ -2446,12 +2453,7 @@ todo_wine ok(count == sizeof page1 - 1, "count was wrong\n"); todo_wine ok(!memcmp(buffer, page1, sizeof page1), "http data wrong\n");
- status = 0; - size = sizeof(status); - SetLastError(0xdeadbeef); - r = HttpQueryInfo(hr, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL ); - todo_wine ok(r, "HttpQueryInfo failed %u\n", GetLastError()); - todo_wine ok(status == 200, "expected status 200 got %u\n", status); + test_status_code(hr, 200);
buffer[0] = 0; size = sizeof(buffer); @@ -2536,17 +2538,7 @@ ok(ret, "HttpQueryInfo failed %u\n", GetLastError()); ok(index == 0, "expected 0 got %u\n", index);
- index = 0; - size = sizeof(buffer); - ret = HttpQueryInfo(hr, HTTP_QUERY_STATUS_CODE, buffer, &size, &index); - ok(ret, "HttpQueryInfo failed %u\n", GetLastError()); - ok(index == 0, "expected 0 got %u\n", index); - - index = 0; - size = sizeof(buffer); - ret = HttpQueryInfo(hr, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, buffer, &size, &index); - ok(ret, "HttpQueryInfo failed %u\n", GetLastError()); - ok(index == 0, "expected 0 got %u\n", index); + test_status_code(hr, 200);
index = 0xdeadbeef; size = sizeof(buffer); @@ -2684,6 +2676,27 @@ ret = InternetQueryOption(req, INTERNET_OPTION_CONTEXT_VALUE, &ctx, &size); ok(ret, "InternetQueryOption failed %u\n", GetLastError()); ok(ctx == 3, "expected 3 got %lu\n", ctx); + + /* INTERNET_OPTION_PROXY */ + SetLastError(0xdeadbeef); + ret = InternetQueryOptionA(ses, INTERNET_OPTION_PROXY, NULL, NULL); + error = GetLastError(); + ok(!ret, "InternetQueryOption succeeded\n"); + ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error); + + SetLastError(0xdeadbeef); + ret = InternetQueryOptionA(ses, INTERNET_OPTION_PROXY, &ctx, NULL); + error = GetLastError(); + ok(!ret, "InternetQueryOption succeeded\n"); + ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error); + + size = 0; + SetLastError(0xdeadbeef); + ret = InternetQueryOptionA(ses, INTERNET_OPTION_PROXY, NULL, &size); + error = GetLastError(); + ok(!ret, "InternetQueryOption succeeded\n"); + ok(error == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %u\n", error); + ok(size >= sizeof(INTERNET_PROXY_INFOA), "expected size to be greater or equal to the struct size\n");
InternetCloseHandle(req); InternetCloseHandle(con); @@ -3052,7 +3065,7 @@ { HINTERNET ses, con, req; static const char *types[] = { (const char *)6240, "*/*", "%p", "", (const char *)0xffffffff, "*/*", NULL }; - DWORD size; + DWORD size, error; char buffer[32]; BOOL ret;
@@ -3064,11 +3077,14 @@
buffer[0] = 0; size = sizeof(buffer); + SetLastError(0xdeadbeef); ret = HttpQueryInfo(req, HTTP_QUERY_ACCEPT | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL); - ok(ret, "HttpQueryInfo failed: %u\n", GetLastError()); - ok(!strcmp(buffer, ", */*, %p, , , */*") || /* IE6 */ - !strcmp(buffer, "*/*, %p, */*"), - "got '%s' expected '*/*, %%p, */*' or ', */*, %%p, , , */*'\n", buffer); + error = GetLastError(); + ok(!ret || broken(ret), "HttpQueryInfo succeeded\n"); + if (!ret) ok(error == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n", error); + ok(broken(!strcmp(buffer, ", */*, %p, , , */*")) /* IE6 */ || + broken(!strcmp(buffer, "*/*, %p, */*")) /* IE7/8 */ || + !strcmp(buffer, ""), "got '%s' expected ''\n", buffer);
InternetCloseHandle(req); InternetCloseHandle(con); @@ -3185,6 +3201,8 @@ HANDLE wait; DWORD thread; unsigned int line; + DWORD expect_result; + BOOL is_aborted; };
static CRITICAL_SECTION notification_cs; @@ -3197,11 +3215,27 @@
EnterCriticalSection( ¬ification_cs );
+ if(info->is_aborted) { + LeaveCriticalSection(¬ification_cs); + return; + } + if (status == INTERNET_STATUS_HANDLE_CREATED) { DWORD size = sizeof(struct info *); HttpQueryInfoA( handle, INTERNET_OPTION_CONTEXT_VALUE, &info, &size, 0 ); - } + }else if(status == INTERNET_STATUS_REQUEST_COMPLETE) { + INTERNET_ASYNC_RESULT *ar = (INTERNET_ASYNC_RESULT*)buffer; + + ok(buflen == sizeof(*ar), "unexpected buflen = %d\n", buflen); + if(info->expect_result == ERROR_SUCCESS) { + ok(ar->dwResult == 1, "ar->dwResult = %ld, expected 1\n", ar->dwResult); + }else { + ok(!ar->dwResult, "ar->dwResult = %ld, expected 1\n", ar->dwResult); + ok(ar->dwError == info->expect_result, "ar->dwError = %d, expected %d\n", ar->dwError, info->expect_result); + } + } + i = info->index; if (i >= info->count) { @@ -3209,7 +3243,8 @@ return; }
- while (info->test[i].status != status && info->test[i].optional && + while (info->test[i].status != status && + (info->test[i].optional || info->test[i].todo) && i < info->count - 1 && info->test[i].function == info->test[i + 1].function) { @@ -3240,17 +3275,30 @@ LeaveCriticalSection( ¬ification_cs ); }
-static void setup_test( struct info *info, enum api function, unsigned int line ) +static void setup_test( struct info *info, enum api function, unsigned int line, DWORD expect_result ) { info->function = function; info->line = line; -} + info->expect_result = expect_result; +} + +struct notification_data +{ + const struct notification *test; + const unsigned int count; + const char *method; + const char *host; + const char *path; + const char *data; + BOOL expect_conn_failure; +};
static const struct notification async_send_request_ex_test[] = { { internet_connect, INTERNET_STATUS_HANDLE_CREATED, 0 }, { http_open_request, INTERNET_STATUS_HANDLE_CREATED, 0 }, { http_send_request_ex, INTERNET_STATUS_DETECTING_PROXY, 1, 0, 1 }, + { http_send_request_ex, INTERNET_STATUS_COOKIE_SENT, 1, 0, 1 }, { http_send_request_ex, INTERNET_STATUS_RESOLVING_NAME, 1, 0, 1 }, { http_send_request_ex, INTERNET_STATUS_NAME_RESOLVED, 1, 0, 1 }, { http_send_request_ex, INTERNET_STATUS_CONNECTING_TO_SERVER, 1 }, @@ -3269,7 +3317,71 @@ { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, 0, } };
-static void test_async_HttpSendRequestEx(void) +static const struct notification async_send_request_ex_test2[] = +{ + { internet_connect, INTERNET_STATUS_HANDLE_CREATED, 0 }, + { http_open_request, INTERNET_STATUS_HANDLE_CREATED, 0 }, + { http_send_request_ex, INTERNET_STATUS_DETECTING_PROXY, 1, 0, 1 }, + { http_send_request_ex, INTERNET_STATUS_COOKIE_SENT, 1, 0, 1 }, + { http_send_request_ex, INTERNET_STATUS_RESOLVING_NAME, 1, 0, 1 }, + { http_send_request_ex, INTERNET_STATUS_NAME_RESOLVED, 1, 0, 1 }, + { http_send_request_ex, INTERNET_STATUS_CONNECTING_TO_SERVER, 1, 1 }, + { http_send_request_ex, INTERNET_STATUS_CONNECTED_TO_SERVER, 1, 1 }, + { http_send_request_ex, INTERNET_STATUS_SENDING_REQUEST, 1 }, + { http_send_request_ex, INTERNET_STATUS_REQUEST_SENT, 1 }, + { http_send_request_ex, INTERNET_STATUS_REQUEST_COMPLETE, 1 }, + { http_end_request, INTERNET_STATUS_RECEIVING_RESPONSE, 1 }, + { http_end_request, INTERNET_STATUS_RESPONSE_RECEIVED, 1 }, + { http_end_request, INTERNET_STATUS_REQUEST_COMPLETE, 1 }, + { internet_close_handle, INTERNET_STATUS_CLOSING_CONNECTION, 0, 0, 1 }, + { internet_close_handle, INTERNET_STATUS_CONNECTION_CLOSED, 0, 0, 1 }, + { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, 0, }, + { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, 0, } +}; + +static const struct notification async_send_request_ex_resolve_failure_test[] = +{ + { internet_connect, INTERNET_STATUS_HANDLE_CREATED, 0 }, + { http_open_request, INTERNET_STATUS_HANDLE_CREATED, 0 }, + { http_send_request_ex, INTERNET_STATUS_DETECTING_PROXY, 1, 0, 1 }, + { http_send_request_ex, INTERNET_STATUS_RESOLVING_NAME, 1 }, + { http_send_request_ex, INTERNET_STATUS_DETECTING_PROXY, 1, 0, 1 }, + { http_send_request_ex, INTERNET_STATUS_REQUEST_COMPLETE, 1 }, + { http_end_request, INTERNET_STATUS_REQUEST_COMPLETE, 1 }, + { internet_close_handle, INTERNET_STATUS_CLOSING_CONNECTION, 0, 0, 1 }, + { internet_close_handle, INTERNET_STATUS_CONNECTION_CLOSED, 0, 0, 1 }, + { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, 0, }, + { internet_close_handle, INTERNET_STATUS_HANDLE_CLOSING, 0, } +}; + +static const struct notification_data notification_data[] = { + { + async_send_request_ex_test, + sizeof(async_send_request_ex_test)/sizeof(async_send_request_ex_test[0]), + "POST", + "test.winehq.org", + "tests/posttest.php", + "Public ID=codeweavers" + }, + { + async_send_request_ex_test2, + sizeof(async_send_request_ex_test)/sizeof(async_send_request_ex_test[0]), + "POST", + "test.winehq.org", + "tests/posttest.php" + }, + { + async_send_request_ex_resolve_failure_test, + sizeof(async_send_request_ex_resolve_failure_test)/sizeof(async_send_request_ex_resolve_failure_test[0]), + "GET", + "brokenhost", + "index.html", + NULL, + TRUE + } +}; + +static void test_async_HttpSendRequestEx(const struct notification_data *nd) { BOOL ret; HINTERNET ses, req, con; @@ -3277,72 +3389,90 @@ DWORD size, written, error; INTERNET_BUFFERSA b; static const char *accept[2] = {"*/*", NULL}; - static char data[] = "Public ID=codeweavers"; char buffer[32];
+ trace("Async HttpSendRequestEx test (%s %s)\n", nd->method, nd->host); + InitializeCriticalSection( ¬ification_cs );
- info.test = async_send_request_ex_test; - info.count = sizeof(async_send_request_ex_test)/sizeof(async_send_request_ex_test[0]); + info.test = nd->test; + info.count = nd->count; info.index = 0; info.wait = CreateEvent( NULL, FALSE, FALSE, NULL ); info.thread = GetCurrentThreadId(); + info.is_aborted = FALSE;
ses = InternetOpen( "winetest", 0, NULL, NULL, INTERNET_FLAG_ASYNC ); ok( ses != NULL, "InternetOpen failed\n" );
pInternetSetStatusCallbackA( ses, check_notification );
- setup_test( &info, internet_connect, __LINE__ ); - con = InternetConnect( ses, "crossover.codeweavers.com", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, (DWORD_PTR)&info ); + setup_test( &info, internet_connect, __LINE__, ERROR_SUCCESS ); + con = InternetConnect( ses, nd->host, 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, (DWORD_PTR)&info ); ok( con != NULL, "InternetConnect failed %u\n", GetLastError() );
WaitForSingleObject( info.wait, 10000 );
- setup_test( &info, http_open_request, __LINE__ ); - req = HttpOpenRequest( con, "POST", "posttest.php", NULL, NULL, accept, 0, (DWORD_PTR)&info ); + setup_test( &info, http_open_request, __LINE__, ERROR_SUCCESS ); + req = HttpOpenRequest( con, nd->method, nd->path, NULL, NULL, accept, 0, (DWORD_PTR)&info ); ok( req != NULL, "HttpOpenRequest failed %u\n", GetLastError() );
WaitForSingleObject( info.wait, 10000 );
- memset( &b, 0, sizeof(INTERNET_BUFFERSA) ); - b.dwStructSize = sizeof(INTERNET_BUFFERSA); - b.lpcszHeader = "Content-Type: application/x-www-form-urlencoded"; - b.dwHeadersLength = strlen( b.lpcszHeader ); - b.dwBufferTotal = strlen( data ); - - setup_test( &info, http_send_request_ex, __LINE__ ); - ret = HttpSendRequestExA( req, &b, NULL, 0x28, 0 ); + if(nd->data) { + memset( &b, 0, sizeof(INTERNET_BUFFERSA) ); + b.dwStructSize = sizeof(INTERNET_BUFFERSA); + b.lpcszHeader = "Content-Type: application/x-www-form-urlencoded"; + b.dwHeadersLength = strlen( b.lpcszHeader ); + b.dwBufferTotal = nd->data ? strlen( nd->data ) : 0; + } + + setup_test( &info, http_send_request_ex, __LINE__, + nd->expect_conn_failure ? ERROR_INTERNET_NAME_NOT_RESOLVED : ERROR_SUCCESS ); + ret = HttpSendRequestExA( req, nd->data ? &b : NULL, NULL, 0x28, 0 ); ok( !ret && GetLastError() == ERROR_IO_PENDING, "HttpSendRequestExA failed %d %u\n", ret, GetLastError() );
- WaitForSingleObject( info.wait, 10000 ); + error = WaitForSingleObject( info.wait, 10000 ); + if(error != WAIT_OBJECT_0) { + skip("WaitForSingleObject returned %d, assuming DNS problem\n", error); + info.is_aborted = TRUE; + goto abort; + }
size = sizeof(buffer); SetLastError( 0xdeadbeef ); ret = HttpQueryInfoA( req, HTTP_QUERY_CONTENT_ENCODING, buffer, &size, 0 ); error = GetLastError(); ok( !ret, "HttpQueryInfoA failed %u\n", GetLastError() ); - todo_wine - ok( error == ERROR_INTERNET_INCORRECT_HANDLE_STATE, - "expected ERROR_INTERNET_INCORRECT_HANDLE_STATE got %u\n", error ); - - written = 0; - size = strlen( data ); - setup_test( &info, internet_writefile, __LINE__ ); - ret = InternetWriteFile( req, data, size, &written ); - ok( ret, "InternetWriteFile failed %u\n", GetLastError() ); - ok( written == size, "expected %u got %u\n", written, size ); - - WaitForSingleObject( info.wait, 10000 ); + if(nd->expect_conn_failure) { + ok(error == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND got %u\n", error ); + }else { + todo_wine + ok(error == ERROR_INTERNET_INCORRECT_HANDLE_STATE, + "expected ERROR_INTERNET_INCORRECT_HANDLE_STATE got %u\n", error ); + } + + if (nd->data) + { + written = 0; + size = strlen( nd->data ); + setup_test( &info, internet_writefile, __LINE__, ERROR_SUCCESS ); + ret = InternetWriteFile( req, nd->data, size, &written ); + ok( ret, "InternetWriteFile failed %u\n", GetLastError() ); + ok( written == size, "expected %u got %u\n", written, size ); + + WaitForSingleObject( info.wait, 10000 ); + + SetLastError( 0xdeadbeef ); + ret = HttpEndRequestA( req, (void *)nd->data, 0x28, 0 ); + error = GetLastError(); + ok( !ret, "HttpEndRequestA succeeded\n" ); + ok( error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", error ); + }
SetLastError( 0xdeadbeef ); - ret = HttpEndRequestA( req, (void *)data, 0x28, 0 ); - error = GetLastError(); - ok( !ret, "HttpEndRequestA succeeded\n" ); - ok( error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", error ); - - SetLastError( 0xdeadbeef ); - setup_test( &info, http_end_request, __LINE__ ); + setup_test( &info, http_end_request, __LINE__, + nd->expect_conn_failure ? ERROR_INTERNET_OPERATION_CANCELLED : ERROR_SUCCESS); ret = HttpEndRequestA( req, NULL, 0x28, 0 ); error = GetLastError(); ok( !ret, "HttpEndRequestA succeeded\n" ); @@ -3350,7 +3480,8 @@
WaitForSingleObject( info.wait, 10000 );
- setup_test( &info, internet_close_handle, __LINE__ ); + setup_test( &info, internet_close_handle, __LINE__, ERROR_SUCCESS ); + abort: InternetCloseHandle( req ); InternetCloseHandle( con ); InternetCloseHandle( ses ); @@ -3488,7 +3619,9 @@ InternetReadFile_test(0, &test_data[2]); InternetReadFileExA_test(INTERNET_FLAG_ASYNC); test_open_url_async(); - test_async_HttpSendRequestEx(); + test_async_HttpSendRequestEx(¬ification_data[0]); + test_async_HttpSendRequestEx(¬ification_data[1]); + test_async_HttpSendRequestEx(¬ification_data[2]); InternetOpenRequest_test(); test_http_cache(); InternetOpenUrlA_test();
Modified: trunk/rostests/winetests/wininet/internet.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/internet... ============================================================================== --- trunk/rostests/winetests/wininet/internet.c [iso-8859-1] (original) +++ trunk/rostests/winetests/wininet/internet.c [iso-8859-1] Wed Jun 20 13:13:51 2012 @@ -41,16 +41,6 @@ static DWORD (WINAPI *pPrivacyGetZonePreferenceW)(DWORD, DWORD, LPDWORD, LPWSTR, LPDWORD); static DWORD (WINAPI *pPrivacySetZonePreferenceW)(DWORD, DWORD, DWORD, LPCWSTR);
-/* Win9x and WinMe don't have lstrcmpW */ -static int strcmp_ww(const WCHAR *str1, const WCHAR *str2) -{ - DWORD len1 = lstrlenW(str1); - DWORD len2 = lstrlenW(str2); - - if (len1 != len2) return 1; - return memcmp(str1, str2, len1 * sizeof(WCHAR)); -} - /* ############################### */
static void test_InternetCanonicalizeUrlA(void) @@ -169,6 +159,7 @@ static const char useragent[] = {"Wininet Test"}; char *buffer; int retval; + BOOL res;
hinet = InternetOpenA(useragent,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0); ok((hinet != 0x0),"InternetOpen Failed\n"); @@ -247,20 +238,65 @@ ok(retval == 0,"Got wrong return value %d\n",retval); ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
+ len = sizeof(val); + val = 0xdeadbeef; + res = InternetQueryOptionA(hinet, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len); + ok(!res, "InternetQueryOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n"); + ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION, "GetLastError() = %u\n", GetLastError()); + + val = 2; + res = InternetSetOptionA(hinet, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val)); + ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n"); + ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION, "GetLastError() = %u\n", GetLastError()); + InternetCloseHandle(hinet); - - len = sizeof(val); - retval = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len); - ok(retval == TRUE,"Got wrong return value %d\n", retval); - ok(len == sizeof(val), "got %d\n", len); - ok(val == 2, "got %d\n", val); - - len = sizeof(val); - retval = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER, &val, &len); - ok(retval == TRUE,"Got wrong return value %d\n", retval); - ok(len == sizeof(val), "got %d\n", len); - ok(val == 4, "got %d\n", val); - +} + +static void test_max_conns(void) +{ + DWORD len, val; + BOOL res; + + len = sizeof(val); + val = 0xdeadbeef; + res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len); + ok(res,"Got wrong return value %x\n", res); + ok(len == sizeof(val), "got %d\n", len); + ok(val == 2, "got %d\n", val); + + len = sizeof(val); + val = 0xdeadbeef; + res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER, &val, &len); + ok(res,"Got wrong return value %x\n", res); + ok(len == sizeof(val), "got %d\n", len); + ok(val == 4, "got %d\n", val); + + val = 3; + res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val)); + ok(res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) failed: %x\n", res); + + len = sizeof(val); + val = 0xdeadbeef; + res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len); + ok(res,"Got wrong return value %x\n", res); + ok(len == sizeof(val), "got %d\n", len); + ok(val == 3, "got %d\n", val); + + val = 0; + res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val)); + ok(!res || broken(res), /* <= w2k3 */ + "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER, 0) succeeded\n"); + if (!res) ok(GetLastError() == ERROR_BAD_ARGUMENTS, "GetLastError() = %u\n", GetLastError()); + + val = 2; + res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val)-1); + ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n"); + ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %u\n", GetLastError()); + + val = 2; + res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val)+1); + ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n"); + ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %u\n", GetLastError()); }
static void test_get_cookie(void) @@ -497,7 +533,7 @@ ok( sz == 1 + lstrlenW(buffer) || sz == lstrlenW(buffer), "sz wrong %d\n", sz);
/* before XP SP2, buffer is "server; server" */ - ok( !strcmp_ww(szExpect, buffer) || !strcmp_ww(szServer, buffer), "cookie data wrong\n"); + ok( !lstrcmpW(szExpect, buffer) || !lstrcmpW(szServer, buffer), "cookie data wrong\n");
sz = sizeof(buffer); r = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECTED_STATE, buffer, &sz); @@ -995,7 +1031,7 @@ ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size); ok(ret == TRUE, "InternetQueryOption should've succeeded\n"); - ok(!strcmp_ww(list.pOptions[0].Value.pszValue, proxy_srvW), + ok(!lstrcmpW(list.pOptions[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, @@ -1321,6 +1357,7 @@ test_Option_PerConnectionOption(); test_Option_PerConnectionOptionA(); test_InternetErrorDlg(); + test_max_conns();
if (!pInternetTimeFromSystemTimeA) win_skip("skipping the InternetTime tests\n");
Modified: trunk/rostests/winetests/wininet/urlcache.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/urlcache... ============================================================================== --- trunk/rostests/winetests/wininet/urlcache.c [iso-8859-1] (original) +++ trunk/rostests/winetests/wininet/urlcache.c [iso-8859-1] Wed Jun 20 13:13:51 2012 @@ -69,6 +69,7 @@ if (!strcmp(lpCacheEntryInfo->lpszSourceUrlName, TEST_URL)) { found = TRUE; + ret = TRUE; break; } SetLastError(0xdeadbeef); @@ -83,11 +84,11 @@ ret = FindNextUrlCacheEntry(hEnumHandle, lpCacheEntryInfo, &cbCacheEntryInfo); } } - ok(ret, "FindNextUrlCacheEntry failed with error %d\n", GetLastError()); if (!ret) break; } - ok(found, "committed url cache entry not found during enumeration\n"); + ok(ret, "FindNextUrlCacheEntry failed with error %d\n", GetLastError()); + ok(found, "Committed url cache entry not found during enumeration\n");
ret = FindCloseUrlCache(hEnumHandle); ok(ret, "FindCloseUrlCache failed with error %d\n", GetLastError()); @@ -133,7 +134,7 @@ ret = GetUrlCacheEntryInfoEx(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo, NULL, NULL, NULL, 0); ok(ret, "GetUrlCacheEntryInfoEx failed with error %d\n", GetLastError());
- check_cache_entry_infoA("GetUrlCacheEntryInfoEx", lpCacheEntryInfo); + if (ret) check_cache_entry_infoA("GetUrlCacheEntryInfoEx", lpCacheEntryInfo);
cbCacheEntryInfo = 100000; SetLastError(0xdeadbeef); @@ -146,10 +147,12 @@ /* Querying the redirect URL fails with ERROR_INVALID_PARAMETER */ SetLastError(0xdeadbeef); ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, NULL, NULL, &cbRedirectUrl, NULL, 0); + ok(!ret, "GetUrlCacheEntryInfoEx should have failed\n"); ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); SetLastError(0xdeadbeef); ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, &cbCacheEntryInfo, NULL, &cbRedirectUrl, NULL, 0); + ok(!ret, "GetUrlCacheEntryInfoEx should have failed\n"); ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); } @@ -234,6 +237,7 @@ "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); info = HeapAlloc(GetProcessHeap(), 0, size); ret = GetUrlCacheEntryInfo(TEST_URL, info, &size); + ok(ret, "GetUrlCacheEntryInfo failed: %d\n", GetLastError()); GetSystemTimeAsFileTime(&info->ExpireTime); exp_time.u.LowPart = info->ExpireTime.dwLowDateTime; exp_time.u.HighPart = info->ExpireTime.dwHighDateTime; @@ -344,6 +348,7 @@ HANDLE hFile; BYTE zero_byte = 0; LPINTERNET_CACHE_ENTRY_INFO lpCacheEntryInfo; + LPINTERNET_CACHE_ENTRY_INFO lpCacheEntryInfo2; DWORD cbCacheEntryInfo; static const FILETIME filetime_zero; FILETIME now; @@ -358,7 +363,7 @@
create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte));
- ret = CommitUrlCacheEntry(TEST_URL1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, NULL, 0, NULL, NULL); + ret = CommitUrlCacheEntry(TEST_URL1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, NULL, 0, "html", NULL); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); cbCacheEntryInfo = 0; ret = GetUrlCacheEntryInfo(TEST_URL1, NULL, &cbCacheEntryInfo); @@ -378,9 +383,11 @@ lpCacheEntryInfo->CacheEntryType); ok(!U(*lpCacheEntryInfo).dwExemptDelta, "expected dwExemptDelta 0, got %d\n", U(*lpCacheEntryInfo).dwExemptDelta); - HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo); - - /* A subsequent commit with a different time/type doesn't change the type */ + + /* Make sure there is a notable change in timestamps */ + Sleep(1000); + + /* A subsequent commit with a different time/type doesn't change most of the entry */ GetSystemTimeAsFileTime(&now); ret = CommitUrlCacheEntry(TEST_URL1, NULL, now, now, NORMAL_CACHE_ENTRY, (LPBYTE)ok_header, strlen(ok_header), NULL, NULL); @@ -390,26 +397,41 @@ ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); - lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); - ret = GetUrlCacheEntryInfo(TEST_URL1, lpCacheEntryInfo, &cbCacheEntryInfo); + lpCacheEntryInfo2 = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); + ret = GetUrlCacheEntryInfo(TEST_URL1, lpCacheEntryInfo2, &cbCacheEntryInfo); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); /* but it does change the time.. */ todo_wine - ok(memcmp(&lpCacheEntryInfo->ExpireTime, &filetime_zero, sizeof(FILETIME)), + ok(memcmp(&lpCacheEntryInfo2->ExpireTime, &filetime_zero, sizeof(FILETIME)), "expected positive ExpireTime\n"); todo_wine - ok(memcmp(&lpCacheEntryInfo->LastModifiedTime, &filetime_zero, sizeof(FILETIME)), + ok(memcmp(&lpCacheEntryInfo2->LastModifiedTime, &filetime_zero, sizeof(FILETIME)), "expected positive LastModifiedTime\n"); - ok(lpCacheEntryInfo->CacheEntryType == (NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY) || - broken(lpCacheEntryInfo->CacheEntryType == NORMAL_CACHE_ENTRY /* NT4/W2k */), + ok(lpCacheEntryInfo2->CacheEntryType == (NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY) || + broken(lpCacheEntryInfo2->CacheEntryType == NORMAL_CACHE_ENTRY /* NT4/W2k */), "expected type NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, got %08x\n", - lpCacheEntryInfo->CacheEntryType); + lpCacheEntryInfo2->CacheEntryType); /* and set the headers. */ todo_wine - ok(lpCacheEntryInfo->dwHeaderInfoSize == 19, - "expected headers size 19, got %d\n", - lpCacheEntryInfo->dwHeaderInfoSize); + ok(lpCacheEntryInfo2->dwHeaderInfoSize == 19, + "expected headers size 19, got %d\n", + lpCacheEntryInfo2->dwHeaderInfoSize); + /* Hit rate gets incremented by 1 */ + todo_wine + ok((lpCacheEntryInfo->dwHitRate + 1) == lpCacheEntryInfo2->dwHitRate, + "HitRate not incremented by one on commit\n"); + /* Last access time should be updated */ + todo_wine + ok(!(lpCacheEntryInfo->LastAccessTime.dwHighDateTime == lpCacheEntryInfo2->LastAccessTime.dwHighDateTime && + lpCacheEntryInfo->LastAccessTime.dwLowDateTime == lpCacheEntryInfo2->LastAccessTime.dwLowDateTime), + "Last accessed time was not updated by commit\n"); + /* File extension should be unset */ + todo_wine + ok(lpCacheEntryInfo2->lpszFileExtension == NULL, + "Fileextension isn't unset: %s\n", + lpCacheEntryInfo2->lpszFileExtension); HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo); + HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo2);
ret = CommitUrlCacheEntry(TEST_URL, filenameA, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); @@ -425,7 +447,7 @@ ret = RetrieveUrlCacheEntryFile(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo, 0); ok(ret, "RetrieveUrlCacheEntryFile failed with error %d\n", GetLastError());
- check_cache_entry_infoA("RetrieveUrlCacheEntryFile", lpCacheEntryInfo); + if (ret) check_cache_entry_infoA("RetrieveUrlCacheEntryFile", lpCacheEntryInfo);
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
@@ -491,7 +513,7 @@ cbCacheEntryInfo = 0; SetLastError(0xdeadbeef); ret = GetUrlCacheEntryInfo(TEST_URL, NULL, &cbCacheEntryInfo); - ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n"); + ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); @@ -550,18 +572,25 @@ if (pDeleteUrlCacheEntryA) { ret = pDeleteUrlCacheEntryA(TEST_URL); - todo_wine ok(!ret, "Expected failure\n"); - todo_wine ok(GetLastError() == ERROR_SHARING_VIOLATION, "Expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError()); check_file_exists(filenameA); } + + lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); + memset(lpCacheEntryInfo, 0, cbCacheEntryInfo); + ret = GetUrlCacheEntryInfo(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo); + ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); + ok(lpCacheEntryInfo->CacheEntryType & DELETED_CACHE_ENTRY, + "CacheEntryType hasn't DELETED_CACHE_ENTRY set, (flags %08x)\n", + lpCacheEntryInfo->CacheEntryType); + HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo); + if (pUnlockUrlCacheEntryFileA) { check_file_exists(filenameA); ret = pUnlockUrlCacheEntryFileA(TEST_URL, 0); - todo_wine ok(ret, "UnlockUrlCacheEntryFileA failed: %d\n", GetLastError()); /* By unlocking the already-deleted cache entry, the file associated * with it is deleted.. @@ -634,6 +663,7 @@ ok(!ret, "expected failure\n"); ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); + ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA, 0); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte)); @@ -644,7 +674,7 @@ cbCacheEntryInfo = 0; SetLastError(0xdeadbeef); ret = GetUrlCacheEntryInfo(TEST_URL, NULL, &cbCacheEntryInfo); - ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n"); + ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); @@ -654,7 +684,7 @@ "expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %d (0x%08x)\n", lpCacheEntryInfo->CacheEntryType, lpCacheEntryInfo->CacheEntryType); ok(U(*lpCacheEntryInfo).dwExemptDelta == 86400, - "expected dwExemptDelta 864000, got %d\n", + "expected dwExemptDelta 86400, got %d\n", U(*lpCacheEntryInfo).dwExemptDelta); HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo); if (pDeleteUrlCacheEntryA) @@ -676,7 +706,7 @@ cbCacheEntryInfo = 0; SetLastError(0xdeadbeef); ret = GetUrlCacheEntryInfo(TEST_URL, NULL, &cbCacheEntryInfo); - ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n"); + ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); @@ -686,7 +716,7 @@ "expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %d (0x%08x)\n", lpCacheEntryInfo->CacheEntryType, lpCacheEntryInfo->CacheEntryType); ok(U(*lpCacheEntryInfo).dwExemptDelta == 86400, - "expected dwExemptDelta 864000, got %d\n", + "expected dwExemptDelta 86400, got %d\n", U(*lpCacheEntryInfo).dwExemptDelta); U(*lpCacheEntryInfo).dwExemptDelta = 0; ret = SetUrlCacheEntryInfoA(TEST_URL, lpCacheEntryInfo, @@ -702,7 +732,30 @@ ok(lpCacheEntryInfo->CacheEntryType & (NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY), "expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %d (0x%08x)\n", lpCacheEntryInfo->CacheEntryType, lpCacheEntryInfo->CacheEntryType); + + /* Recommit of Url entry keeps dwExemptDelta */ + U(*lpCacheEntryInfo).dwExemptDelta = 8600; + ret = SetUrlCacheEntryInfoA(TEST_URL, lpCacheEntryInfo, + CACHE_ENTRY_EXEMPT_DELTA_FC); + ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError()); + + ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA1, 0); + ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); + create_and_write_file(filenameA1, &zero_byte, sizeof(zero_byte)); + + ret = CommitUrlCacheEntry(TEST_URL, filenameA1, filetime_zero, filetime_zero, + NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY, + (LPBYTE)ok_header, strlen(ok_header), "html", NULL); + ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); + + ret = GetUrlCacheEntryInfo(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo); + ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); + ok(U(*lpCacheEntryInfo).dwExemptDelta == 8600, + "expected dwExemptDelta 8600, got %d\n", + U(*lpCacheEntryInfo).dwExemptDelta); + HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo); + if (pDeleteUrlCacheEntryA) { ret = pDeleteUrlCacheEntryA(TEST_URL);