Thomas Mullaly : urlmon/tests: Added tests for IUri_GetPropertyDWORD.
Alexandre Julliard
julliard at winehq.org
Thu May 27 10:46:42 CDT 2010
Module: wine
Branch: master
Commit: 7bc121c8802299d88ef01b0de8063247f936f4dd
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7bc121c8802299d88ef01b0de8063247f936f4dd
Author: Thomas Mullaly <thomas.mullaly at gmail.com>
Date: Wed May 26 17:42:12 2010 -0400
urlmon/tests: Added tests for IUri_GetPropertyDWORD.
---
dlls/urlmon/tests/uri.c | 123 +++++++++++++++++++++++++++++++++++++++++++++++
dlls/urlmon/uri.c | 15 ++++++
include/urlmon.idl | 10 ++++
3 files changed, 148 insertions(+), 0 deletions(-)
diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c
index 453fde7..cff1a08 100644
--- a/dlls/urlmon/tests/uri.c
+++ b/dlls/urlmon/tests/uri.c
@@ -37,8 +37,10 @@
#include "windef.h"
#include "winbase.h"
#include "urlmon.h"
+#include "shlwapi.h"
#define URI_STR_PROPERTY_COUNT Uri_PROPERTY_STRING_LAST+1
+#define URI_DWORD_PROPERTY_COUNT (Uri_PROPERTY_DWORD_LAST - Uri_PROPERTY_DWORD_START)+1
static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**);
@@ -65,6 +67,12 @@ typedef struct _uri_str_property {
BOOL todo;
} uri_str_property;
+typedef struct _uri_dword_property {
+ DWORD value;
+ HRESULT expected;
+ BOOL todo;
+} uri_dword_property;
+
typedef struct _uri_properties {
const char* uri;
DWORD create_flags;
@@ -72,6 +80,7 @@ typedef struct _uri_properties {
BOOL create_todo;
uri_str_property str_props[URI_STR_PROPERTY_COUNT];
+ uri_dword_property dword_props[URI_DWORD_PROPERTY_COUNT];
} uri_properties;
static const uri_properties uri_tests[] = {
@@ -92,6 +101,12 @@ static const uri_properties uri_tests[] = {
{"http",S_OK,TRUE}, /* SCHEME_NAME */
{"",S_FALSE,TRUE}, /* USER_INFO */
{"",S_FALSE,TRUE} /* USER_NAME */
+ },
+ {
+ {Uri_HOST_DNS,S_OK,TRUE}, /* HOST_TYPE */
+ {80,S_OK,TRUE}, /* PORT */
+ {URL_SCHEME_HTTP,S_OK,TRUE}, /* SCHEME */
+ {URLZONE_INVALID,E_NOTIMPL,FALSE} /* ZONE */
}
},
{ "http://winehq.org/tests/.././tests", 0, S_OK, FALSE,
@@ -111,6 +126,12 @@ static const uri_properties uri_tests[] = {
{"http",S_OK,TRUE},
{"",S_FALSE,TRUE},
{"",S_FALSE,TRUE}
+ },
+ {
+ {Uri_HOST_DNS,S_OK,TRUE},
+ {80,S_OK,TRUE},
+ {URL_SCHEME_HTTP,S_OK,TRUE},
+ {URLZONE_INVALID,E_NOTIMPL,FALSE}
}
},
{ "HtTp://www.winehq.org/tests/..?query=x&return=y", 0, S_OK, FALSE,
@@ -130,6 +151,12 @@ static const uri_properties uri_tests[] = {
{"http",S_OK,TRUE},
{"",S_FALSE,TRUE},
{"",S_FALSE,TRUE}
+ },
+ {
+ {Uri_HOST_DNS,S_OK,TRUE},
+ {80,S_OK,TRUE},
+ {URL_SCHEME_HTTP,S_OK,TRUE},
+ {URLZONE_INVALID,E_NOTIMPL,FALSE},
}
},
{ "hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters", 0, S_OK, FALSE,
@@ -149,6 +176,12 @@ static const uri_properties uri_tests[] = {
{"http",S_OK,TRUE},
{"usEr%3Ainfo",S_OK,TRUE},
{"usEr%3Ainfo",S_OK,TRUE}
+ },
+ {
+ {Uri_HOST_DNS,S_OK,TRUE},
+ {80,S_OK,TRUE},
+ {URL_SCHEME_HTTP,S_OK,TRUE},
+ {URLZONE_INVALID,E_NOTIMPL,FALSE},
}
},
{ "ftp://winepass:[email protected]:9999/dir/foo bar.txt", 0, S_OK, FALSE,
@@ -168,6 +201,12 @@ static const uri_properties uri_tests[] = {
{"ftp",S_OK,TRUE},
{"winepass:wine",S_OK,TRUE},
{"winepass",S_OK,TRUE}
+ },
+ {
+ {Uri_HOST_DNS,S_OK,TRUE},
+ {9999,S_OK,TRUE},
+ {URL_SCHEME_FTP,S_OK,TRUE},
+ {URLZONE_INVALID,E_NOTIMPL,FALSE}
}
},
{ "file://c:\\tests\\../tests/foo%20bar.mp3", 0, S_OK, FALSE,
@@ -187,6 +226,12 @@ static const uri_properties uri_tests[] = {
{"file",S_OK,TRUE},
{"",S_FALSE,TRUE},
{"",S_FALSE,TRUE}
+ },
+ {
+ {Uri_HOST_UNKNOWN,S_OK,TRUE},
+ {0,S_FALSE,TRUE},
+ {URL_SCHEME_FILE,S_OK,TRUE},
+ {URLZONE_INVALID,E_NOTIMPL,FALSE}
}
},
{ "FILE://localhost/test dir\\../tests/test%20file.README.txt", 0, S_OK, FALSE,
@@ -206,6 +251,12 @@ static const uri_properties uri_tests[] = {
{"file",S_OK,TRUE},
{"",S_FALSE,TRUE},
{"",S_FALSE,TRUE}
+ },
+ {
+ {Uri_HOST_UNKNOWN,S_OK,TRUE},
+ {0,S_FALSE,TRUE},
+ {URL_SCHEME_FILE,S_OK,TRUE},
+ {URLZONE_INVALID,E_NOTIMPL,FALSE}
}
},
{ "urn:nothing:should:happen here", 0, S_OK, FALSE,
@@ -225,6 +276,12 @@ static const uri_properties uri_tests[] = {
{"urn",S_OK,TRUE},
{"",S_FALSE,TRUE},
{"",S_FALSE,TRUE}
+ },
+ {
+ {Uri_HOST_UNKNOWN,S_OK,TRUE},
+ {0,S_FALSE,TRUE},
+ {URL_SCHEME_UNKNOWN,S_OK,TRUE},
+ {URLZONE_INVALID,E_NOTIMPL,FALSE}
}
}
};
@@ -340,6 +397,69 @@ static void test_IUri_GetPropertyBSTR(void) {
}
}
+static void test_IUri_GetPropertyDWORD(void) {
+ IUri *uri = NULL;
+ HRESULT hr;
+ DWORD i;
+
+ 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_GetPropertyDWORD(uri, Uri_PROPERTY_DWORD_START, NULL, 0);
+ ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD 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. Failed on uri_tests[%d].\n",
+ hr, test.create_expected, i);
+ }
+ } else {
+ ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
+ hr, test.create_expected, i);
+ }
+
+ if(SUCCEEDED(hr)) {
+ DWORD j;
+
+ /* Checks all the DWORD properties of the uri. */
+ for(j = 0; j < sizeof(test.dword_props)/sizeof(test.dword_props[0]); ++j) {
+ DWORD received;
+ uri_dword_property prop = test.dword_props[j];
+
+ hr = IUri_GetPropertyDWORD(uri, j+Uri_PROPERTY_DWORD_START, &received, 0);
+ if(prop.todo) {
+ todo_wine {
+ ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
+ hr, prop.expected, i, j);
+ }
+ todo_wine {
+ ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
+ prop.value, received, i, j);
+ }
+ } else {
+ ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
+ hr, prop.expected, i, j);
+ ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
+ prop.value, received, i, j);
+ }
+ }
+ }
+
+ if(uri) IUri_Release(uri);
+
+ heap_free(uriW);
+ }
+}
+
START_TEST(uri) {
HMODULE hurlmon;
@@ -359,4 +479,7 @@ START_TEST(uri) {
trace("test IUri_GetPropertyBSTR...\n");
test_IUri_GetPropertyBSTR();
+
+ trace("test IUri_GetPropretyDWORD...\n");
+ test_IUri_GetPropertyDWORD();
}
diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c
index 5b72fa5..9018002 100644
--- a/dlls/urlmon/uri.c
+++ b/dlls/urlmon/uri.c
@@ -1,5 +1,6 @@
/*
* Copyright 2010 Jacek Caban for CodeWeavers
+ * Copyright 2010 Thomas Mullaly
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -97,6 +98,20 @@ static HRESULT WINAPI Uri_GetPropertyDWORD(IUri *iface, Uri_PROPERTY uriProp, DW
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags);
+
+ if(!pcchProperty)
+ return E_INVALIDARG;
+
+ /* 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
+ * function.
+ */
+ if(uriProp == Uri_PROPERTY_ZONE) {
+ *pcchProperty = URLZONE_INVALID;
+ return E_NOTIMPL;
+ }
+
return E_NOTIMPL;
}
diff --git a/include/urlmon.idl b/include/urlmon.idl
index 2ab3b2b..c1d3bec 100644
--- a/include/urlmon.idl
+++ b/include/urlmon.idl
@@ -1231,6 +1231,7 @@ interface IInternetZoneManager : IUnknown
typedef enum tagURLZONE
{
+ URLZONE_INVALID = -1,
URLZONE_PREDEFINED_MIN = 0,
URLZONE_LOCAL_MACHINE = 0,
URLZONE_INTRANET = 1,
@@ -1563,6 +1564,15 @@ interface IUri : IUnknown
Uri_PROPERTY_DWORD_LAST = Uri_PROPERTY_ZONE
} Uri_PROPERTY;
+ typedef enum
+ {
+ Uri_HOST_UNKNOWN = 0,
+ Uri_HOST_DNS = 1,
+ Uri_HOST_IPV4 = 2,
+ Uri_HOST_IPV6 = 3,
+ Uri_HOST_IDN = 4
+ } Uri_HOST_TYPE;
+
HRESULT GetPropertyBSTR(
[in] Uri_PROPERTY uriProp,
[out] BSTR *pbstrProperty,
More information about the wine-cvs
mailing list