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;
#define TESTF_REDIRECT 0x01
#define TESTF_COMPRESSED 0x02
#define TESTF_ALLOW_COOKIE 0x04
#define TESTF_CHUNKED 0x08
typedef struct {
const char *url;
......@@ -121,6 +122,14 @@ typedef struct {
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/hello.html",
"test.winehq.org",
......@@ -303,7 +312,7 @@ static VOID WINAPI callback(
static void InternetReadFile_test(int flags, const test_data_t *test)
{
char *post_data = NULL;
BOOL res;
BOOL res, on_async = TRUE;
CHAR buffer[4000];
DWORD length, post_len = 0;
DWORD out;
......@@ -521,9 +530,6 @@ static void InternetReadFile_test(int flags, const test_data_t *test)
if (flags & INTERNET_FLAG_ASYNC)
SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE);
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 (res)
......@@ -532,11 +538,22 @@ static void InternetReadFile_test(int flags, const test_data_t *test)
}
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);
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
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)
{
char *buffer;
......@@ -551,9 +568,11 @@ static void InternetReadFile_test(int flags, const test_data_t *test)
if(test->content)
ok(!strcmp(buffer, test->content), "buffer = '%s', expected '%s'\n", buffer, test->content);
HeapFree(GetProcessHeap(),0,buffer);
}
if (length == 0)
}else {
ok(!on_async, "Returned zero size in response to request complete\n");
break;
}
on_async = FALSE;
}
if(test->flags & TESTF_REDIRECT) {
CHECK_NOTIFIED2(INTERNET_STATUS_CLOSING_CONNECTION, 2);
......@@ -1851,7 +1870,7 @@ static void test_basic_request(int port, const char *verb, const char *url)
r = InternetReadFile(hr, buffer, sizeof buffer, &count);
ok(r, "InternetReadFile failed %u\n", GetLastError());
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(hc);
......@@ -3387,12 +3406,13 @@ START_TEST(http)
pInternetSetStatusCallbackA = (void*)GetProcAddress(hdll, "InternetSetStatusCallbackA");
init_status_tests();
test_InternetCloseHandle();
if(0)test_InternetCloseHandle();
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(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);
test_open_url_async();
test_async_HttpSendRequestEx();
......@@ -3406,5 +3426,5 @@ START_TEST(http)
test_bogus_accept_types_array();
InternetReadFile_chunked_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