msxml3/tests: Added IServerXMLHTTPRequest tests.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d7430abd40
commit
f6b5b31083
|
@ -50,6 +50,9 @@ static void _expect_ref(IUnknown* obj, ULONG ref, int line)
|
|||
ok_(__FILE__, line)(rc == ref, "expected refcount %d, got %d\n", ref, rc);
|
||||
}
|
||||
|
||||
static const char xmltestA[] = "http://test.winehq.org/tests/xmltest.xml";
|
||||
static const CHAR xmltestbodyA[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<a>TEST</a>\n";
|
||||
|
||||
DEFINE_GUID(SID_SContainerDispatch, 0xb722be00, 0x4e68, 0x101b, 0xa2, 0xbc, 0x00, 0xaa, 0x00, 0x40, 0x47, 0x70);
|
||||
DEFINE_GUID(SID_UnknownSID, 0x75dd09cb, 0x6c40, 0x11d5, 0x85, 0x43, 0x00, 0xc0, 0x4f, 0xa0, 0xfb, 0xa3);
|
||||
|
||||
|
@ -91,6 +94,13 @@ DEFINE_EXPECT(collection_get_length);
|
|||
|
||||
static int g_unexpectedcall, g_expectedcall;
|
||||
|
||||
static int strcmp_wa(const WCHAR *strw, const char *stra)
|
||||
{
|
||||
WCHAR buf[512];
|
||||
MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR));
|
||||
return lstrcmpW(strw, buf);
|
||||
}
|
||||
|
||||
static BSTR alloc_str_from_narrow(const char *str)
|
||||
{
|
||||
int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
|
||||
|
@ -1431,14 +1441,26 @@ static void _test_open(unsigned line, IXMLHttpRequest *xhr, const char *method,
|
|||
ok_(__FILE__,line)(hr == exhres, "open(%s %s) failed: %08x, expected %08x\n", method, url, hr, exhres);
|
||||
}
|
||||
|
||||
#define test_server_open(a,b,c,d) _test_server_open(__LINE__,a,b,c,d)
|
||||
static void _test_server_open(unsigned line, IServerXMLHTTPRequest *xhr, const char *method, const char *url, HRESULT exhres)
|
||||
{
|
||||
VARIANT empty, vfalse;
|
||||
HRESULT hr;
|
||||
|
||||
V_VT(&empty) = VT_EMPTY;
|
||||
V_VT(&vfalse) = VT_BOOL;
|
||||
V_BOOL(&vfalse) = VARIANT_FALSE;
|
||||
|
||||
hr = IServerXMLHTTPRequest_open(xhr, _bstr_(method), _bstr_(url), vfalse, empty, empty);
|
||||
ok_(__FILE__,line)(hr == exhres, "open(%s %s) failed: %08x, expected %08x\n", method, url, hr, exhres);
|
||||
}
|
||||
|
||||
static void test_XMLHTTP(void)
|
||||
{
|
||||
static const char bodyA[] = "mode=Test";
|
||||
static const char urlA[] = "http://test.winehq.org/tests/post.php";
|
||||
static const char xmltestA[] = "http://test.winehq.org/tests/xmltest.xml";
|
||||
static const char referertesturl[] = "http://test.winehq.org/tests/referer.php";
|
||||
static const WCHAR wszExpectedResponse[] = {'F','A','I','L','E','D',0};
|
||||
static const CHAR xmltestbodyA[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<a>TEST</a>\n";
|
||||
static const WCHAR norefererW[] = {'n','o',' ','r','e','f','e','r','e','r',' ','s','e','t',0};
|
||||
|
||||
IXMLHttpRequest *xhr;
|
||||
|
@ -1768,6 +1790,38 @@ static void test_XMLHTTP(void)
|
|||
free_bstrs();
|
||||
}
|
||||
|
||||
static void test_server_xhr(void)
|
||||
{
|
||||
IServerXMLHTTPRequest *xhr;
|
||||
BSTR response;
|
||||
VARIANT body;
|
||||
HRESULT hr;
|
||||
|
||||
/* GET request */
|
||||
xhr = create_server_xhr();
|
||||
|
||||
test_server_open(xhr, "GET", xmltestA, S_OK);
|
||||
|
||||
V_VT(&body) = VT_EMPTY;
|
||||
|
||||
hr = IServerXMLHTTPRequest_send(xhr, body);
|
||||
if (hr == INET_E_RESOURCE_NOT_FOUND)
|
||||
{
|
||||
skip("No connection could be made with test.winehq.org\n");
|
||||
IServerXMLHTTPRequest_Release(xhr);
|
||||
return;
|
||||
}
|
||||
ok(hr == S_OK, "send failed: %08x\n", hr);
|
||||
|
||||
hr = IServerXMLHTTPRequest_get_responseText(xhr, &response);
|
||||
ok(hr == S_OK, "get_responseText failed: %08x\n", hr);
|
||||
ok(!strcmp_wa(response, xmltestbodyA), "got %s\n", wine_dbgstr_w(response));
|
||||
SysFreeString(response);
|
||||
|
||||
IServerXMLHTTPRequest_Release(xhr);
|
||||
free_bstrs();
|
||||
}
|
||||
|
||||
static void test_safe_httpreq(void)
|
||||
{
|
||||
IXMLHttpRequest *xhr;
|
||||
|
@ -1847,6 +1901,7 @@ START_TEST(httpreq)
|
|||
IXMLHttpRequest_Release(xhr);
|
||||
|
||||
test_XMLHTTP();
|
||||
test_server_xhr();
|
||||
test_safe_httpreq();
|
||||
test_supporterrorinfo();
|
||||
|
||||
|
|
Loading…
Reference in New Issue