Rob Shearman : msxml3: Add a simple test for XMLHTTP.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Dec 28 07:40:31 CST 2006


Module: wine
Branch: master
Commit: 588e423bde1ad5d723aa318125f0b47b24c5cef8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=588e423bde1ad5d723aa318125f0b47b24c5cef8

Author: Rob Shearman <rob at codeweavers.com>
Date:   Thu Dec 28 02:40:46 2006 +0000

msxml3: Add a simple test for XMLHTTP.

---

 dlls/msxml3/tests/domdoc.c |   48 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c
index a2824fd..4fc139d 100644
--- a/dlls/msxml3/tests/domdoc.c
+++ b/dlls/msxml3/tests/domdoc.c
@@ -23,6 +23,7 @@
 
 #include "windows.h"
 #include "ole2.h"
+#include "xmldom.h"
 #include "msxml2.h"
 #include <stdio.h>
 
@@ -1090,6 +1091,52 @@ static void test_removeChild(void)
     IXMLDOMDocument_Release( doc );
 }
 
+static void test_XMLHTTP(void)
+{
+    static const WCHAR wszBody[] = {'m','o','d','e','=','T','e','s','t',0};
+    static WCHAR wszPOST[] = {'P','O','S','T',0};
+    static WCHAR wszUrl[] = {'h','t','t','p',':','/','/',
+        'c','r','o','s','s','o','v','e','r','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
+        'p','o','s','t','t','e','s','t','.','p','h','p',0};
+    static const WCHAR wszExpectedResponse[] = {'F','A','I','L','E','D',0};
+    IXMLHttpRequest *pXMLHttpRequest;
+    BSTR bstrResponse;
+    VARIANT dummy;
+    VARIANT varfalse;
+    VARIANT varbody;
+    HRESULT hr = CoCreateInstance(&CLSID_XMLHTTPRequest, NULL,
+                                  CLSCTX_INPROC_SERVER, &IID_IXMLHttpRequest,
+                                  (void **)&pXMLHttpRequest);
+    todo_wine {
+    ok(hr == S_OK, "CoCreateInstance(CLSID_XMLHTTPRequest) should have succeeded instead of failing with 0x%08x\n", hr);
+    }
+    if (hr != S_OK)
+        return;
+
+    VariantInit(&dummy);
+    V_VT(&dummy) = VT_ERROR;
+    V_ERROR(&dummy) = DISP_E_MEMBERNOTFOUND;
+    VariantInit(&varfalse);
+    V_VT(&varfalse) = VT_BOOL;
+    V_BOOL(&varfalse) = VARIANT_FALSE;
+    V_VT(&varbody) = VT_BSTR;
+    V_BSTR(&varbody) = SysAllocString(wszBody);
+
+    hr = IXMLHttpRequest_open(pXMLHttpRequest, wszPOST, wszUrl, varfalse, dummy, dummy);
+    ok(hr == S_OK, "IXMLHttpRequest_open should have succeeded instead of failing with 0x%08x\n", hr);
+
+    hr = IXMLHttpRequest_send(pXMLHttpRequest, varbody);
+    ok(hr == S_OK, "IXMLHttpRequest_send should have succeeded instead of failing with 0x%08x\n", hr);
+    VariantClear(&varbody);
+
+    hr = IXMLHttpRequest_get_responseText(pXMLHttpRequest, &bstrResponse);
+    ok(hr == S_OK, "IXMLHttpRequest_get_responseText should have succeeded instead of failing with 0x%08x\n", hr);
+    /* the server currently returns "FAILED" because the Content-Type header is
+     * not what the server expects */
+    ok(!memcmp(bstrResponse, wszExpectedResponse, sizeof(wszExpectedResponse)), "bstrResponse differs from what was expected\n");
+    SysFreeString(bstrResponse);
+}
+
 START_TEST(domdoc)
 {
     HRESULT r;
@@ -1105,6 +1152,7 @@ START_TEST(domdoc)
     test_get_text();
     test_get_childNodes();
     test_removeChild();
+    test_XMLHTTP();
 
     CoUninitialize();
 }




More information about the wine-cvs mailing list