Jacek Caban : msxml3/tests: Added IServerXMLHTTPRequest tests.

Alexandre Julliard julliard at winehq.org
Wed Mar 28 16:42:43 CDT 2018


Module: wine
Branch: master
Commit: f6b5b31083ce52936837047bcd85bccbe216cac3
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f6b5b31083ce52936837047bcd85bccbe216cac3

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Mar 27 18:20:11 2018 +0200

msxml3/tests: Added IServerXMLHTTPRequest tests.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msxml3/tests/httpreq.c | 59 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)

diff --git a/dlls/msxml3/tests/httpreq.c b/dlls/msxml3/tests/httpreq.c
index 4f51ef9..5149222 100644
--- a/dlls/msxml3/tests/httpreq.c
+++ b/dlls/msxml3/tests/httpreq.c
@@ -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();
 




More information about the wine-cvs mailing list