Thomas Mullaly : urlmon/tests: Added tests for the IUri_Get* dword property functions.

Alexandre Julliard julliard at winehq.org
Fri May 28 09:43:12 CDT 2010


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

Author: Thomas Mullaly <thomas.mullaly at gmail.com>
Date:   Thu May 27 19:39:28 2010 -0400

urlmon/tests: Added tests for the IUri_Get* dword property functions.

---

 dlls/urlmon/tests/uri.c |  130 +++++++++++++++++++++++++++++++++++++++++++++++
 dlls/urlmon/uri.c       |   22 ++++++++-
 2 files changed, 151 insertions(+), 1 deletions(-)

diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c
index 7e2496e..58f39b9 100644
--- a/dlls/urlmon/tests/uri.c
+++ b/dlls/urlmon/tests/uri.c
@@ -835,6 +835,133 @@ static void test_IUri_GetStrProperties(void) {
     }
 }
 
+static void test_IUri_GetDwordProperties(void) {
+    IUri *uri = NULL;
+    HRESULT hr;
+    DWORD i;
+
+    /* Make sure all the 'Get*' dword property functions handle invalid args correctly. */
+    hr = pCreateUri(http_urlW, 0, 0, &uri);
+    ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
+    if(SUCCEEDED(hr)) {
+        hr = IUri_GetHostType(uri, NULL);
+        ok(hr == E_INVALIDARG, "Error: GetHostType returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
+
+        hr = IUri_GetPort(uri, NULL);
+        ok(hr == E_INVALIDARG, "Error: GetPort returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
+
+        hr = IUri_GetScheme(uri, NULL);
+        ok(hr == E_INVALIDARG, "Error: GetScheme returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
+
+        hr = IUri_GetZone(uri, NULL);
+        ok(hr == E_INVALIDARG, "Error: GetZone returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
+    }
+    if(uri) IUri_Release(uri);
+
+    for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
+        uri_properties test = uri_tests[i];
+        LPWSTR uriW;
+        uri = NULL;
+
+        uriW = a2w(test.uri);
+        hr = pCreateUri(uriW, test.create_flags, 0, &uri);
+        if(test.create_todo) {
+            todo_wine {
+                ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
+                        hr, test.create_expected, i);
+            }
+        } else {
+            ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
+                    hr, test.create_expected, i);
+        }
+
+        if(SUCCEEDED(hr)) {
+            uri_dword_property prop;
+            DWORD received;
+
+            /* Assign an insane value so tests don't accidentally pass when
+             * they shouldn't!
+             */
+            received = -9999999;
+
+            /* GetHostType() tests. */
+            prop = test.dword_props[Uri_PROPERTY_HOST_TYPE-Uri_PROPERTY_DWORD_START];
+            hr = IUri_GetHostType(uri, &received);
+            if(prop.todo) {
+                todo_wine {
+                    ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
+                            hr, prop.expected, i);
+                }
+                todo_wine {
+                    ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
+                }
+            } else {
+                ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
+                        hr, prop.expected, i);
+                ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
+            }
+            received = -9999999;
+
+            /* GetPort() tests. */
+            prop = test.dword_props[Uri_PROPERTY_PORT-Uri_PROPERTY_DWORD_START];
+            hr = IUri_GetPort(uri, &received);
+            if(prop.todo) {
+                todo_wine {
+                    ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
+                            hr, prop.expected, i);
+                }
+                todo_wine {
+                    ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
+                }
+            } else {
+                ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
+                        hr, prop.expected, i);
+                ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
+            }
+            received = -9999999;
+
+            /* GetScheme() tests. */
+            prop = test.dword_props[Uri_PROPERTY_SCHEME-Uri_PROPERTY_DWORD_START];
+            hr = IUri_GetScheme(uri, &received);
+            if(prop.todo) {
+                todo_wine {
+                    ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
+                            hr, prop.expected, i);
+                }
+                todo_wine {
+                    ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
+                }
+            } else {
+                ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
+                        hr, prop.expected, i);
+                ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
+            }
+            received = -9999999;
+
+            /* GetZone() tests. */
+            prop = test.dword_props[Uri_PROPERTY_ZONE-Uri_PROPERTY_DWORD_START];
+            hr = IUri_GetZone(uri, &received);
+            if(prop.todo) {
+                todo_wine {
+                    ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
+                            hr, prop.expected, i);
+                }
+                todo_wine {
+                    ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
+                }
+            } else {
+                ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
+                        hr, prop.expected, i);
+                ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
+            }
+        }
+
+        if(uri) IUri_Release(uri);
+
+        heap_free(uriW);
+    }
+}
+
 START_TEST(uri) {
     HMODULE hurlmon;
 
@@ -860,4 +987,7 @@ START_TEST(uri) {
 
     trace("test IUri_GetStrProperties...\n");
     test_IUri_GetStrProperties();
+
+    trace("test IUri_GetDwordProperties...\n");
+    test_IUri_GetDwordProperties();
 }
diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c
index 8d8130e..27b0863 100644
--- a/dlls/urlmon/uri.c
+++ b/dlls/urlmon/uri.c
@@ -104,7 +104,7 @@ static HRESULT WINAPI Uri_GetPropertyDWORD(IUri *iface, Uri_PROPERTY uriProp, DW
 
     /* Microsoft's implementation for the ZONE property of a URI seems to be lacking...
      * From what I can tell, instead of checking which URLZONE the URI belongs to it
-     * simply assigns URLZONE_INVALID and returns E_NOTIMPL. This also applies the GetZone
+     * simply assigns URLZONE_INVALID and returns E_NOTIMPL. This also applies to the GetZone
      * function.
      */
     if(uriProp == Uri_PROPERTY_ZONE) {
@@ -287,6 +287,10 @@ static HRESULT WINAPI Uri_GetHostType(IUri *iface, DWORD *pdwHostType)
 {
     Uri *This = URI_THIS(iface);
     FIXME("(%p)->(%p)\n", This, pdwHostType);
+
+    if(!pdwHostType)
+        return E_INVALIDARG;
+
     return E_NOTIMPL;
 }
 
@@ -294,6 +298,10 @@ static HRESULT WINAPI Uri_GetPort(IUri *iface, DWORD *pdwPort)
 {
     Uri *This = URI_THIS(iface);
     FIXME("(%p)->(%p)\n", This, pdwPort);
+
+    if(!pdwPort)
+        return E_INVALIDARG;
+
     return E_NOTIMPL;
 }
 
@@ -301,6 +309,10 @@ static HRESULT WINAPI Uri_GetScheme(IUri *iface, DWORD *pdwScheme)
 {
     Uri *This = URI_THIS(iface);
     FIXME("(%p)->(%p)\n", This, pdwScheme);
+
+    if(!pdwScheme)
+        return E_INVALIDARG;
+
     return E_NOTIMPL;
 }
 
@@ -308,6 +320,14 @@ static HRESULT WINAPI Uri_GetZone(IUri *iface, DWORD *pdwZone)
 {
     Uri *This = URI_THIS(iface);
     FIXME("(%p)->(%p)\n", This, pdwZone);
+
+    if(!pdwZone)
+        return E_INVALIDARG;
+
+    /* Microsoft doesn't seem to have this implemented yet... See
+     * the comment in Uri_GetPropertyDWORD for more about this.
+     */
+    *pdwZone = URLZONE_INVALID;
     return E_NOTIMPL;
 }
 




More information about the wine-cvs mailing list