Commit 7611d107 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wininet: Added more tests.

parent ccd11eb7
...@@ -107,6 +107,7 @@ static HANDLE hCompleteEvent; ...@@ -107,6 +107,7 @@ static HANDLE hCompleteEvent;
#define TESTF_REDIRECT 0x01 #define TESTF_REDIRECT 0x01
#define TESTF_COMPRESSED 0x02 #define TESTF_COMPRESSED 0x02
#define TESTF_ALLOW_COOKIE 0x04 #define TESTF_ALLOW_COOKIE 0x04
#define TESTF_CHUNKED 0x08
typedef struct { typedef struct {
const char *url; const char *url;
...@@ -121,6 +122,14 @@ typedef struct { ...@@ -121,6 +122,14 @@ typedef struct {
static const test_data_t test_data[] = { static const test_data_t test_data[] = {
{ {
"http://test.winehq.org/tests/data.php",
"http://test.winehq.org/tests/data.php",
"test.winehq.org",
"/tests/data.php",
"",
TESTF_CHUNKED
},
{
"http://test.winehq.org/tests/redirect", "http://test.winehq.org/tests/redirect",
"http://test.winehq.org/tests/hello.html", "http://test.winehq.org/tests/hello.html",
"test.winehq.org", "test.winehq.org",
...@@ -303,7 +312,7 @@ static VOID WINAPI callback( ...@@ -303,7 +312,7 @@ static VOID WINAPI callback(
static void InternetReadFile_test(int flags, const test_data_t *test) static void InternetReadFile_test(int flags, const test_data_t *test)
{ {
char *post_data = NULL; char *post_data = NULL;
BOOL res; BOOL res, on_async = TRUE;
CHAR buffer[4000]; CHAR buffer[4000];
DWORD length, post_len = 0; DWORD length, post_len = 0;
DWORD out; DWORD out;
...@@ -521,9 +530,6 @@ static void InternetReadFile_test(int flags, const test_data_t *test) ...@@ -521,9 +530,6 @@ static void InternetReadFile_test(int flags, const test_data_t *test)
if (flags & INTERNET_FLAG_ASYNC) if (flags & INTERNET_FLAG_ASYNC)
SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE);
res = InternetQueryDataAvailable(hor,&length,0x0,0x0); res = InternetQueryDataAvailable(hor,&length,0x0,0x0);
ok(!(!res && length != 0),"InternetQueryDataAvailable failed with non-zero length\n");
ok(res || ((flags & INTERNET_FLAG_ASYNC) && GetLastError() == ERROR_IO_PENDING),
"InternetQueryDataAvailable failed, error %d\n", GetLastError());
if (flags & INTERNET_FLAG_ASYNC) if (flags & INTERNET_FLAG_ASYNC)
{ {
if (res) if (res)
...@@ -532,11 +538,22 @@ static void InternetReadFile_test(int flags, const test_data_t *test) ...@@ -532,11 +538,22 @@ static void InternetReadFile_test(int flags, const test_data_t *test)
} }
else if (GetLastError() == ERROR_IO_PENDING) else if (GetLastError() == ERROR_IO_PENDING)
{ {
trace("PENDING\n");
/* on some tests, InternetQueryDataAvailable returns non-zero length and ERROR_IO_PENDING */
if(!(test->flags & TESTF_CHUNKED))
ok(!length, "InternetQueryDataAvailable returned ERROR_IO_PENDING and %u length\n", length);
WaitForSingleObject(hCompleteEvent, INFINITE); WaitForSingleObject(hCompleteEvent, INFINITE);
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
continue; continue;
}else {
ok(0, "InternetQueryDataAvailable failed: %u\n", GetLastError());
} }
}else {
ok(res, "InternetQueryDataAvailable failed: %u\n", GetLastError());
} }
trace("LENGTH %d\n", length);
if(test->flags & TESTF_CHUNKED)
ok(length <= 8192, "length = %d, expected <= 8192\n", length);
if (length) if (length)
{ {
char *buffer; char *buffer;
...@@ -551,10 +568,12 @@ static void InternetReadFile_test(int flags, const test_data_t *test) ...@@ -551,10 +568,12 @@ static void InternetReadFile_test(int flags, const test_data_t *test)
if(test->content) if(test->content)
ok(!strcmp(buffer, test->content), "buffer = '%s', expected '%s'\n", buffer, test->content); ok(!strcmp(buffer, test->content), "buffer = '%s', expected '%s'\n", buffer, test->content);
HeapFree(GetProcessHeap(),0,buffer); HeapFree(GetProcessHeap(),0,buffer);
} }else {
if (length == 0) ok(!on_async, "Returned zero size in response to request complete\n");
break; break;
} }
on_async = FALSE;
}
if(test->flags & TESTF_REDIRECT) { if(test->flags & TESTF_REDIRECT) {
CHECK_NOTIFIED2(INTERNET_STATUS_CLOSING_CONNECTION, 2); CHECK_NOTIFIED2(INTERNET_STATUS_CLOSING_CONNECTION, 2);
CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTION_CLOSED, 2); CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTION_CLOSED, 2);
...@@ -1851,7 +1870,7 @@ static void test_basic_request(int port, const char *verb, const char *url) ...@@ -1851,7 +1870,7 @@ static void test_basic_request(int port, const char *verb, const char *url)
r = InternetReadFile(hr, buffer, sizeof buffer, &count); r = InternetReadFile(hr, buffer, sizeof buffer, &count);
ok(r, "InternetReadFile failed %u\n", GetLastError()); ok(r, "InternetReadFile failed %u\n", GetLastError());
ok(count == sizeof page1 - 1, "count was wrong\n"); ok(count == sizeof page1 - 1, "count was wrong\n");
ok(!memcmp(buffer, page1, sizeof page1), "http data wrong\n"); ok(!memcmp(buffer, page1, sizeof page1), "http data wrong, got: %s\n", buffer);
InternetCloseHandle(hr); InternetCloseHandle(hr);
InternetCloseHandle(hc); InternetCloseHandle(hc);
...@@ -3387,12 +3406,13 @@ START_TEST(http) ...@@ -3387,12 +3406,13 @@ START_TEST(http)
pInternetSetStatusCallbackA = (void*)GetProcAddress(hdll, "InternetSetStatusCallbackA"); pInternetSetStatusCallbackA = (void*)GetProcAddress(hdll, "InternetSetStatusCallbackA");
init_status_tests(); init_status_tests();
test_InternetCloseHandle(); if(0)test_InternetCloseHandle();
InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[0]); InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[0]);
InternetReadFile_test(0, &test_data[0]);
first_connection_to_test_url = TRUE;
InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[1]); InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[1]);
InternetReadFile_test(0, &test_data[1]); InternetReadFile_test(0, &test_data[1]);
first_connection_to_test_url = TRUE;
InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[2]);
InternetReadFile_test(0, &test_data[2]);
InternetReadFileExA_test(INTERNET_FLAG_ASYNC); InternetReadFileExA_test(INTERNET_FLAG_ASYNC);
test_open_url_async(); test_open_url_async();
test_async_HttpSendRequestEx(); test_async_HttpSendRequestEx();
...@@ -3406,5 +3426,5 @@ START_TEST(http) ...@@ -3406,5 +3426,5 @@ START_TEST(http)
test_bogus_accept_types_array(); test_bogus_accept_types_array();
InternetReadFile_chunked_test(); InternetReadFile_chunked_test();
HttpSendRequestEx_test(); HttpSendRequestEx_test();
InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[2]); InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[3]);
} }
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