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

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


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

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

urlmon/tests: Added tests for IUriBuilder_CreateUriSimple.

---

 dlls/urlmon/tests/uri.c |   64 +++++++++++++++++++++++++++++++++++++++++++++++
 dlls/urlmon/uri.c       |   16 +++++++++++
 2 files changed, 80 insertions(+), 0 deletions(-)

diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c
index 2d3c316..0d4d237 100644
--- a/dlls/urlmon/tests/uri.c
+++ b/dlls/urlmon/tests/uri.c
@@ -5135,6 +5135,38 @@ static void test_IUriBuilder_CreateUri(IUriBuilder *builder, const uri_builder_t
     if(uri) IUri_Release(uri);
 }
 
+static void test_IUriBuilder_CreateUriSimple(IUriBuilder *builder, const uri_builder_test *test,
+                                       DWORD test_index) {
+    HRESULT hr;
+    IUri *uri = NULL;
+
+    hr = IUriBuilder_CreateUriSimple(builder, test->uri_simple_encode_flags, 0, &uri);
+    if(test->uri_todo) {
+        todo_wine {
+            ok(hr == test->uri_simple_hres,
+                "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
+                hr, test->uri_simple_hres, test_index);
+        }
+    } else {
+        ok(hr == test->uri_simple_hres,
+            "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
+            hr, test->uri_simple_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_simple_expected, received),
+            "Error: Expected the URI to be %s but was %s instead on uri_builder_tests[%d].\n",
+            test->uri_simple_expected, wine_dbgstr_w(received), test_index);
+        SysFreeString(received);
+    }
+    if(uri) IUri_Release(uri);
+}
+
 static void test_IUriBuilder_CreateInvalidArgs(void) {
     IUriBuilder *builder;
     HRESULT hr;
@@ -5157,6 +5189,22 @@ static void test_IUriBuilder_CreateInvalidArgs(void) {
         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_NOTIMPL);
         ok(uri == NULL, "Error: expected uri to be NULL, but was %p instead.\n", uri);
 
+        uri = (void*) 0xdeadbeef;
+        hr = IUriBuilder_CreateUriSimple(builder, 0, 0, &uri);
+        ok(hr == INET_E_INVALID_URL, "Error: IUriBuilder_CreateUriSimple 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_CreateUriSimple(builder, 0, 0, NULL);
+        ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
+            hr, E_POINTER);
+
+        uri = (void*) 0xdeadbeef;
+        hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
+        ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
+            hr, E_NOTIMPL);
+        ok(!uri, "Error: Expected uri to 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)) {
@@ -5172,6 +5220,15 @@ static void test_IUriBuilder_CreateInvalidArgs(void) {
             todo_wine { ok(uri != NULL, "Error: The uri was NULL.\n"); }
             if(uri) IUri_Release(uri);
 
+            uri = NULL;
+            hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
+            todo_wine {
+                ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple 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); }
 
@@ -5180,6 +5237,12 @@ static void test_IUriBuilder_CreateInvalidArgs(void) {
             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri 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_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
+            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);
         }
         if(test) IUri_Release(test);
     }
@@ -5240,6 +5303,7 @@ static void test_IUriBuilder(void) {
                 }
 
                 test_IUriBuilder_CreateUri(builder, &test, i);
+                test_IUriBuilder_CreateUriSimple(builder, &test, i);
             }
             if(builder) IUriBuilder_Release(builder);
         }
diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c
index 11d9497..a578b88 100644
--- a/dlls/urlmon/uri.c
+++ b/dlls/urlmon/uri.c
@@ -4096,6 +4096,22 @@ static HRESULT WINAPI UriBuilder_CreateUriSimple(IUriBuilder *iface,
                                                  IUri       **ppIUri)
 {
     UriBuilder *This = URIBUILDER_THIS(iface);
+    TRACE("(%p)->(%d %d %p)\n", This, dwAllowEncodingPropertyMask, (DWORD)dwReserved, ppIUri);
+
+    if(!ppIUri)
+        return E_POINTER;
+
+    /* Acts the same way as CreateUri. */
+    if(dwAllowEncodingPropertyMask && !This->uri) {
+        *ppIUri = NULL;
+        return E_NOTIMPL;
+    }
+
+    if(!This->uri) {
+        *ppIUri = NULL;
+        return INET_E_INVALID_URL;
+    }
+
     FIXME("(%p)->(%d %d %p)\n", This, dwAllowEncodingPropertyMask, (DWORD)dwReserved, ppIUri);
     return E_NOTIMPL;
 }




More information about the wine-cvs mailing list