urlmon/tests: Added test for invalid args to IUri_GetPropertyBSTR and IUri_GetPropertyDWORD.

oldstable
Thomas Mullaly 2010-05-30 11:06:10 -04:00 committed by Alexandre Julliard
parent f16fa49f4d
commit a6f1ebfe41
3 changed files with 56 additions and 3 deletions

View File

@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = urlmon.dll
IMPORTLIB = urlmon
IMPORTS = uuid ole32 rpcrt4 shlwapi wininet user32 advapi32 kernel32 ntdll
IMPORTS = uuid ole32 oleaut32 rpcrt4 shlwapi wininet user32 advapi32 kernel32 ntdll
EXTRADEFS = -D_URLMON_ -DENTRY_PREFIX=URLMON_ -DPROXY_DELEGATION -DREGISTER_PROXY_DLL \
-DPROXY_CLSID_IS="{0x79EAC9F1,0xBAF9,0x11CE,{0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B}}"

View File

@ -442,13 +442,40 @@ static void test_CreateUri_InvalidArgs(void) {
}
static void test_IUri_GetPropertyBSTR(void) {
IUri *uri = NULL;
HRESULT hr;
DWORD i;
/* Make sure GetPropertyBSTR handles 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)) {
BSTR received = NULL;
hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_RAW_URI, NULL, 0);
ok(hr == E_POINTER, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
/* Make sure it handles a invalid Uri_PROPERTY's correctly. */
hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_PORT, &received, 0);
ok(hr == S_OK, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
ok(received != NULL, "Error: Expected the string not to be NULL.\n");
ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
SysFreeString(received);
/* Make sure it handles the ZONE property correctly. */
received = NULL;
hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_ZONE, &received, 0);
ok(hr == S_FALSE, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_FALSE);
ok(received != NULL, "Error: Expected the string not to be NULL.\n");
ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
SysFreeString(received);
}
if(uri) IUri_Release(uri);
for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
uri_properties test = uri_tests[i];
HRESULT hr;
IUri *uri = NULL;
LPWSTR uriW;
uri = NULL;
uriW = a2w(test.uri);
hr = pCreateUri(uriW, test.create_flags, 0, &uri);
@ -505,8 +532,14 @@ static void test_IUri_GetPropertyDWORD(void) {
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)) {
DWORD received = 0xdeadbeef;
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);
hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_ABSOLUTE_URI, &received, 0);
ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
ok(received == 0, "Error: Expected received=%d but instead received=%d.\n", 0, received);
}
if(uri) IUri_Release(uri);

View File

@ -84,6 +84,21 @@ static HRESULT WINAPI Uri_GetPropertyBSTR(IUri *iface, Uri_PROPERTY uriProp, BST
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%d %p %x)\n", This, uriProp, pbstrProperty, dwFlags);
if(!pbstrProperty)
return E_POINTER;
if(uriProp > Uri_PROPERTY_STRING_LAST) {
/* Windows allocates an empty BSTR for invalid Uri_PROPERTY's. */
*pbstrProperty = SysAllocStringLen(NULL, 0);
/* It only returns S_FALSE for the ZONE property... */
if(uriProp == Uri_PROPERTY_ZONE)
return S_FALSE;
else
return S_OK;
}
return E_NOTIMPL;
}
@ -120,6 +135,11 @@ static HRESULT WINAPI Uri_GetPropertyDWORD(IUri *iface, Uri_PROPERTY uriProp, DW
return E_NOTIMPL;
}
if(uriProp < Uri_PROPERTY_DWORD_START) {
*pcchProperty = 0;
return E_INVALIDARG;
}
return E_NOTIMPL;
}