Thomas Mullaly : urlmon: Implemented IUriBuilder_{Get/Set}Port.
Alexandre Julliard
julliard at winehq.org
Tue Sep 7 11:22:55 CDT 2010
Module: wine
Branch: master
Commit: a4eee688183db9036cf02a973d067a884022d24b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a4eee688183db9036cf02a973d067a884022d24b
Author: Thomas Mullaly <thomas.mullaly at gmail.com>
Date: Mon Sep 6 16:34:21 2010 -0400
urlmon: Implemented IUriBuilder_{Get/Set}Port.
---
dlls/urlmon/tests/uri.c | 136 ++++++++++++++++++++++++++++++++++++++++++++++-
dlls/urlmon/uri.c | 21 ++++++--
2 files changed, 152 insertions(+), 5 deletions(-)
diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c
index 684a608..6756d99 100644
--- a/dlls/urlmon/tests/uri.c
+++ b/dlls/urlmon/tests/uri.c
@@ -4315,7 +4315,7 @@ static const uri_builder_test uri_builder_tests[] = {
{
{TRUE,"test",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,TRUE}
},
- {TRUE,TRUE,120,S_OK,TRUE},
+ {TRUE,TRUE,120,S_OK,FALSE},
0,S_OK,TRUE,
0,S_OK,TRUE,
0,0,0,S_OK,TRUE,
@@ -4568,6 +4568,109 @@ static const uri_builder_test uri_builder_tests[] = {
{URL_SCHEME_UNKNOWN,S_OK},
{URLZONE_INVALID,E_NOTIMPL}
}
+ },
+ { "http://google.com/",0,S_OK,FALSE,
+ {
+ {FALSE},
+ },
+ /* 555 will be returned from GetPort even though FALSE was passed as the hasPort parameter. */
+ {TRUE,FALSE,555,S_OK,FALSE},
+ 0,S_OK,TRUE,
+ 0,S_OK,TRUE,
+ 0,0,0,S_OK,TRUE,
+ {
+ {"http://google.com/",S_OK},
+ {"google.com",S_OK},
+ {"http://google.com/",S_OK},
+ {"google.com",S_OK},
+ {"",S_FALSE},
+ {"",S_FALSE},
+ {"google.com",S_OK},
+ {"",S_FALSE},
+ {"/",S_OK},
+ {"/",S_OK},
+ {"",S_FALSE},
+ {"http://google.com/",S_OK},
+ {"http",S_OK},
+ {"",S_FALSE},
+ {"",S_FALSE}
+ },
+ {
+ {Uri_HOST_DNS,S_OK},
+ /* Still returns 80, even though earlier the port was disabled. */
+ {80,S_OK},
+ {URL_SCHEME_HTTP,S_OK},
+ {URLZONE_INVALID,E_NOTIMPL}
+ }
+ },
+ { "http://google.com/",0,S_OK,FALSE,
+ {
+ {FALSE},
+ },
+ /* Instead of getting "TRUE" back as the "hasPort" parameter in GetPort,
+ * you'll get 122345 instead.
+ */
+ {TRUE,122345,222,S_OK,FALSE},
+ 0,S_OK,TRUE,
+ 0,S_OK,TRUE,
+ 0,0,0,S_OK,TRUE,
+ {
+ {"http://google.com:222/",S_OK},
+ {"google.com:222",S_OK},
+ {"http://google.com:222/",S_OK},
+ {"google.com",S_OK},
+ {"",S_FALSE},
+ {"",S_FALSE},
+ {"google.com",S_OK},
+ {"",S_FALSE},
+ {"/",S_OK},
+ {"/",S_OK},
+ {"",S_FALSE},
+ {"http://google.com:222/",S_OK},
+ {"http",S_OK},
+ {"",S_FALSE},
+ {"",S_FALSE}
+ },
+ {
+ {Uri_HOST_DNS,S_OK},
+ {222,S_OK},
+ {URL_SCHEME_HTTP,S_OK},
+ {URLZONE_INVALID,E_NOTIMPL}
+ }
+ },
+ /* IUri's created with the IUriBuilder can have ports that exceed USHORT_MAX. */
+ { "http://google.com/",0,S_OK,FALSE,
+ {
+ {FALSE},
+ },
+
+ {TRUE,TRUE,999999,S_OK,FALSE},
+ 0,S_OK,TRUE,
+ 0,S_OK,TRUE,
+ 0,0,0,S_OK,TRUE,
+ {
+ {"http://google.com:999999/",S_OK},
+ {"google.com:999999",S_OK},
+ {"http://google.com:999999/",S_OK},
+ {"google.com",S_OK},
+ {"",S_FALSE},
+ {"",S_FALSE},
+ {"google.com",S_OK},
+ {"",S_FALSE},
+ {"/",S_OK},
+ {"/",S_OK},
+ {"",S_FALSE},
+ {"http://google.com:999999/",S_OK},
+ {"http",S_OK},
+ {"",S_FALSE},
+ {"",S_FALSE}
+ },
+ {
+ {Uri_HOST_DNS,S_OK},
+ {999999,S_OK},
+ {URL_SCHEME_HTTP,S_OK},
+ {URLZONE_INVALID,E_NOTIMPL}
+ }
}
};
@@ -7516,6 +7619,34 @@ static void test_IUriBuilder_RemoveProperties(void) {
}
}
+static void test_IUriBuilder_Misc(void) {
+ HRESULT hr;
+ IUri *uri;
+
+ hr = pCreateUri(http_urlW, 0, 0, &uri);
+ if(SUCCEEDED(hr)) {
+ IUriBuilder *builder;
+
+ hr = pCreateIUriBuilder(uri, 0, 0, &builder);
+ ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
+ if(SUCCEEDED(hr)) {
+ BOOL has = -1;
+ DWORD port = -1;
+
+ hr = IUriBuilder_GetPort(builder, &has, &port);
+ ok(hr == S_OK, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
+ if(SUCCEEDED(hr)) {
+ /* 'has' will be set to FALSE, even though uri had a port. */
+ ok(has == FALSE, "Error: Expected 'has' to be FALSE, was %d instead.\n", has);
+ /* Still sets 'port' to 80. */
+ ok(port == 80, "Error: Expected the port to be 80, but, was %d instead.\n", port);
+ }
+ }
+ if(builder) IUriBuilder_Release(builder);
+ }
+ if(uri) IUri_Release(uri);
+}
+
START_TEST(uri) {
HMODULE hurlmon;
@@ -7591,4 +7722,7 @@ START_TEST(uri) {
trace("test IUriBuilder_RemoveProperties...\n");
test_IUriBuilder_RemoveProperties();
+
+ trace("test IUriBuilder miscellaneous...\n");
+ test_IUriBuilder_Misc();
}
diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c
index c05c0fa..dbc1747 100644
--- a/dlls/urlmon/uri.c
+++ b/dlls/urlmon/uri.c
@@ -91,6 +91,9 @@ typedef struct {
WCHAR *path;
DWORD path_len;
+
+ BOOL has_port;
+ DWORD port;
} UriBuilder;
typedef struct {
@@ -4506,8 +4509,9 @@ static HRESULT WINAPI UriBuilder_GetPort(IUriBuilder *iface, BOOL *pfHasPort, DW
return E_POINTER;
}
- FIXME("(%p)->(%p %p)\n", This, pfHasPort, pdwPort);
- return E_NOTIMPL;
+ *pfHasPort = This->has_port;
+ *pdwPort = This->port;
+ return S_OK;
}
static HRESULT WINAPI UriBuilder_GetQuery(IUriBuilder *iface, DWORD *pcchQuery, LPCWSTR *ppwzQuery)
@@ -4605,8 +4609,12 @@ static HRESULT WINAPI UriBuilder_SetPath(IUriBuilder *iface, LPCWSTR pwzNewValue
static HRESULT WINAPI UriBuilder_SetPort(IUriBuilder *iface, BOOL fHasPort, DWORD dwNewValue)
{
UriBuilder *This = URIBUILDER_THIS(iface);
- FIXME("(%p)->(%d %d)\n", This, fHasPort, dwNewValue);
- return E_NOTIMPL;
+ TRACE("(%p)->(%d %d)\n", This, fHasPort, dwNewValue);
+
+ This->has_port = fHasPort;
+ This->port = dwNewValue;
+ This->modified_props |= Uri_HAS_PORT;
+ return S_OK;
}
static HRESULT WINAPI UriBuilder_SetQuery(IUriBuilder *iface, LPCWSTR pwzNewValue)
@@ -4705,6 +4713,11 @@ HRESULT WINAPI CreateIUriBuilder(IUri *pIUri, DWORD dwFlags, DWORD_PTR dwReserve
if((uri = get_uri_obj(pIUri))) {
IUri_AddRef(pIUri);
ret->uri = uri;
+
+ if(uri->has_port)
+ /* Windows doesn't set 'has_port' to TRUE in this case. */
+ ret->port = uri->port;
+
} else {
heap_free(ret);
*ppIUriBuilder = NULL;
More information about the wine-cvs
mailing list