Thomas Mullaly : urlmon/tests: Added tests for IUriBuilder_CreateUriWithFlags.

Alexandre Julliard julliard at winehq.org
Thu Aug 19 11:44:04 CDT 2010


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

Author: Thomas Mullaly <thomas.mullaly at gmail.com>
Date:   Wed Aug 18 17:46:41 2010 -0400

urlmon/tests: Added tests for IUriBuilder_CreateUriWithFlags.

---

 dlls/urlmon/tests/uri.c |   66 +++++++++++++++++++++++++++++++++++++++++++++++
 dlls/urlmon/uri.c       |   17 ++++++++++++
 2 files changed, 83 insertions(+), 0 deletions(-)

diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c
index 0d4d237..743c42c 100644
--- a/dlls/urlmon/tests/uri.c
+++ b/dlls/urlmon/tests/uri.c
@@ -5167,6 +5167,39 @@ static void test_IUriBuilder_CreateUriSimple(IUriBuilder *builder, const uri_bui
     if(uri) IUri_Release(uri);
 }
 
+static void test_IUriBuilder_CreateUriWithFlags(IUriBuilder *builder, const uri_builder_test *test,
+                                                DWORD test_index) {
+    HRESULT hr;
+    IUri *uri = NULL;
+
+    hr = IUriBuilder_CreateUriWithFlags(builder, test->uri_with_flags, test->uri_with_builder_flags,
+                                        test->uri_with_encode_flags, 0, &uri);
+    if(test->uri_todo) {
+        todo_wine {
+            ok(hr == test->uri_with_hres,
+                "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
+                hr, test->uri_with_hres, test_index);
+        }
+    } else {
+        ok(hr == test->uri_with_hres,
+            "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
+            hr, test->uri_with_hres, test_index);
+    }
+
+    if(SUCCEEDED(hr)) {
+        BSTR received = NULL;
+
+        hr = IUri_GetAbsoluteUri(uri, &received);
+        ok(hr == S_OK, "Error: IUri_GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
+            hr, S_OK, test_index);
+        ok(!strcmp_aw(test->uri_with_expected, received),
+            "Error: Expected the URI to be %s but was %s instead on uri_builder_tests[%d].\n",
+            test->uri_with_expected, wine_dbgstr_w(received), test_index);
+        SysFreeString(received);
+    }
+    if(uri) IUri_Release(uri);
+}
+
 static void test_IUriBuilder_CreateInvalidArgs(void) {
     IUriBuilder *builder;
     HRESULT hr;
@@ -5205,6 +5238,23 @@ static void test_IUriBuilder_CreateInvalidArgs(void) {
             hr, E_NOTIMPL);
         ok(!uri, "Error: Expected uri to NULL, but was %p instead.\n", uri);
 
+        uri = (void*) 0xdeadbeef;
+        hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &uri);
+        ok(hr == INET_E_INVALID_URL,
+            "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
+            hr, INET_E_INVALID_URL);
+        ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
+
+        hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, NULL);
+        ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
+            hr, E_POINTER);
+
+        uri = (void*) 0xdeadbeef;
+        hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
+        ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
+            hr, E_NOTIMPL);
+        ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
+
         hr = pCreateUri(http_urlW, 0, 0, &test);
         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
         if(SUCCEEDED(hr)) {
@@ -5229,6 +5279,15 @@ static void test_IUriBuilder_CreateInvalidArgs(void) {
             todo_wine { ok(uri != NULL, "Error: uri was NULL.\n"); }
             if(uri) IUri_Release(uri);
 
+            uri = NULL;
+            hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &uri);
+            todo_wine {
+                ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
+                    hr, S_OK);
+            }
+            todo_wine { ok(uri != NULL, "Error: uri was NULL.\n"); }
+            if(uri) IUri_Release(uri);
+
             hr = IUriBuilder_SetFragment(builder, NULL);
             todo_wine { ok(hr == S_OK, "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x.\n", hr, S_OK); }
 
@@ -5243,6 +5302,12 @@ static void test_IUriBuilder_CreateInvalidArgs(void) {
             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
                 hr, S_OK);
             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
+
+            uri = (void*) 0xdeadbeef;
+            hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
+            ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
+                hr, E_NOTIMPL);
+            ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
         }
         if(test) IUri_Release(test);
     }
@@ -5304,6 +5369,7 @@ static void test_IUriBuilder(void) {
 
                 test_IUriBuilder_CreateUri(builder, &test, i);
                 test_IUriBuilder_CreateUriSimple(builder, &test, i);
+                test_IUriBuilder_CreateUriWithFlags(builder, &test, i);
             }
             if(builder) IUriBuilder_Release(builder);
         }
diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c
index a578b88..8aa130a 100644
--- a/dlls/urlmon/uri.c
+++ b/dlls/urlmon/uri.c
@@ -4156,6 +4156,23 @@ static HRESULT WINAPI UriBuilder_CreateUriWithFlags(IUriBuilder *iface,
                                          IUri       **ppIUri)
 {
     UriBuilder *This = URIBUILDER_THIS(iface);
+    TRACE("(%p)->(0x%08x 0x%08x %d %d %p)\n", This, dwCreateFlags, dwUriBuilderFlags,
+        dwAllowEncodingPropertyMask, (DWORD)dwReserved, ppIUri);
+
+    if(!ppIUri)
+        return E_POINTER;
+
+    /* Same as CreateUri. */
+    if(dwAllowEncodingPropertyMask && !This->uri) {
+        *ppIUri = NULL;
+        return E_NOTIMPL;
+    }
+
+    if(!This->uri) {
+        *ppIUri = NULL;
+        return INET_E_INVALID_URL;
+    }
+
     FIXME("(%p)->(0x%08x 0x%08x %d %d %p)\n", This, dwCreateFlags, dwUriBuilderFlags,
         dwAllowEncodingPropertyMask, (DWORD)dwReserved, ppIUri);
     return E_NOTIMPL;




More information about the wine-cvs mailing list