hlink: Add tests and fix error handling in IHlink::{Get, Set}StringReference.
This commit is contained in:
parent
7fa3778d8c
commit
fc4a9e2e69
|
@ -245,6 +245,10 @@ static HRESULT WINAPI IHlink_fnSetStringReference(IHlink* iface,
|
|||
TRACE("(%p)->(%i %s %s)\n", This, grfHLSETF, debugstr_w(pwzTarget),
|
||||
debugstr_w(pwzLocation));
|
||||
|
||||
if(grfHLSETF > (HLINKSETF_TARGET | HLINKSETF_LOCATION) &&
|
||||
grfHLSETF < -(HLINKSETF_TARGET | HLINKSETF_LOCATION))
|
||||
return grfHLSETF;
|
||||
|
||||
if (grfHLSETF & HLINKSETF_TARGET)
|
||||
{
|
||||
heap_free(This->Target);
|
||||
|
@ -281,7 +285,20 @@ static HRESULT WINAPI IHlink_fnGetStringReference (IHlink* iface,
|
|||
{
|
||||
HlinkImpl *This = (HlinkImpl*)iface;
|
||||
|
||||
FIXME("(%p) -> (%i %p %p)\n", This, dwWhichRef, ppwzTarget, ppwzLocation);
|
||||
TRACE("(%p) -> (%i %p %p)\n", This, dwWhichRef, ppwzTarget, ppwzLocation);
|
||||
|
||||
/* note: undocumented behavior with dwWhichRef == -1 */
|
||||
if(dwWhichRef != -1 && dwWhichRef & ~(HLINKGETREF_DEFAULT | HLINKGETREF_ABSOLUTE | HLINKGETREF_RELATIVE))
|
||||
{
|
||||
if(ppwzTarget)
|
||||
*ppwzTarget = NULL;
|
||||
if(ppwzLocation)
|
||||
*ppwzLocation = NULL;
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if(dwWhichRef != HLINKGETREF_DEFAULT)
|
||||
FIXME("unhandled flags: 0x%x\n", dwWhichRef);
|
||||
|
||||
if (ppwzTarget)
|
||||
{
|
||||
|
@ -300,8 +317,6 @@ static HRESULT WINAPI IHlink_fnGetStringReference (IHlink* iface,
|
|||
IBindCtx_Release(pbc);
|
||||
IMoniker_Release(mon);
|
||||
}
|
||||
else
|
||||
FIXME("Unhandled case, no set Target and no moniker\n");
|
||||
}
|
||||
}
|
||||
if (ppwzLocation)
|
||||
|
|
|
@ -1121,6 +1121,100 @@ static void test_HlinkGetSetMonikerReference(void)
|
|||
IMoniker_Release(dummy);
|
||||
}
|
||||
|
||||
static void test_HlinkGetSetStringReference(void)
|
||||
{
|
||||
IHlink *link;
|
||||
static const WCHAR one[] = {'1',0};
|
||||
static const WCHAR two[] = {'2',0};
|
||||
static const WCHAR three[] = {'3',0};
|
||||
static const WCHAR empty[] = {0};
|
||||
WCHAR *fnd_tgt, *fnd_loc;
|
||||
HRESULT hres;
|
||||
|
||||
/* create a new hlink: target => NULL, location => one */
|
||||
hres = HlinkCreateFromMoniker(NULL, one, empty, NULL, 0, NULL, &IID_IHlink, (void**)&link);
|
||||
ok(hres == S_OK, "HlinkCreateFromMoniker failed: 0x%08x\n", hres);
|
||||
|
||||
/* test setting/getting location */
|
||||
hres = IHlink_GetStringReference(link, HLINKGETREF_DEFAULT, &fnd_tgt, &fnd_loc);
|
||||
ok(hres == S_OK, "IHlink_GetStringReference failed: 0x%08x\n", hres);
|
||||
ok(fnd_tgt == NULL, "Found target should have been NULL, was: %s\n", wine_dbgstr_w(fnd_tgt));
|
||||
ok(!lstrcmpW(fnd_loc, one), "Found location should have been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(fnd_loc));
|
||||
|
||||
hres = IHlink_SetStringReference(link, HLINKSETF_LOCATION, one, two);
|
||||
ok(hres == S_OK, "IHlink_SetStringReference failed: 0x%08x\n", hres);
|
||||
|
||||
hres = IHlink_GetStringReference(link, HLINKGETREF_DEFAULT, &fnd_tgt, &fnd_loc);
|
||||
ok(hres == S_OK, "IHlink_GetStringReference failed: 0x%08x\n", hres);
|
||||
ok(fnd_tgt == NULL, "Found target should have been NULL, was: %s\n", wine_dbgstr_w(fnd_tgt));
|
||||
ok(!lstrcmpW(fnd_loc, two), "Found location should have been %s, was: %s\n", wine_dbgstr_w(two), wine_dbgstr_w(fnd_loc));
|
||||
|
||||
hres = IHlink_SetStringReference(link, -HLINKSETF_LOCATION, two, one);
|
||||
ok(hres == S_OK, "IHlink_SetStringReference failed: 0x%08x\n", hres);
|
||||
|
||||
hres = IHlink_GetStringReference(link, HLINKGETREF_DEFAULT, &fnd_tgt, &fnd_loc);
|
||||
ok(hres == S_OK, "IHlink_GetStringReference failed: 0x%08x\n", hres);
|
||||
ok(fnd_tgt == NULL, "Found target should have been NULL, was: %s\n", wine_dbgstr_w(fnd_tgt));
|
||||
ok(!lstrcmpW(fnd_loc, one), "Found location should have been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(fnd_loc));
|
||||
|
||||
/* test setting/getting target */
|
||||
hres = IHlink_SetStringReference(link, HLINKSETF_TARGET, two, three);
|
||||
ok(hres == S_OK, "IHlink_SetStringReference failed: 0x%08x\n", hres);
|
||||
|
||||
hres = IHlink_GetStringReference(link, HLINKGETREF_DEFAULT, &fnd_tgt, &fnd_loc);
|
||||
ok(hres == S_OK, "IHlink_GetStringReference failed: 0x%08x\n", hres);
|
||||
ok(!lstrcmpW(fnd_tgt, two), "Found target should have been %s, was: %s\n", wine_dbgstr_w(two), wine_dbgstr_w(fnd_tgt));
|
||||
ok(!lstrcmpW(fnd_loc, one), "Found location should have been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(fnd_loc));
|
||||
|
||||
hres = IHlink_SetStringReference(link, -HLINKSETF_TARGET, three, two);
|
||||
ok(hres == S_OK, "IHlink_SetStringReference failed: 0x%08x\n", hres);
|
||||
|
||||
hres = IHlink_GetStringReference(link, HLINKGETREF_DEFAULT, &fnd_tgt, &fnd_loc);
|
||||
ok(hres == S_OK, "IHlink_GetStringReference failed: 0x%08x\n", hres);
|
||||
ok(!lstrcmpW(fnd_tgt, three), "Found target should have been %s, was: %s\n", wine_dbgstr_w(three), wine_dbgstr_w(fnd_tgt));
|
||||
ok(!lstrcmpW(fnd_loc, two), "Found location should have been %s, was: %s\n", wine_dbgstr_w(two), wine_dbgstr_w(fnd_loc));
|
||||
|
||||
/* test setting/getting both */
|
||||
hres = IHlink_SetStringReference(link, HLINKSETF_TARGET | HLINKSETF_LOCATION, one, two);
|
||||
ok(hres == S_OK, "IHlink_SetStringReference failed: 0x%08x\n", hres);
|
||||
|
||||
hres = IHlink_GetStringReference(link, HLINKGETREF_DEFAULT, &fnd_tgt, &fnd_loc);
|
||||
ok(hres == S_OK, "IHlink_GetStringReference failed: 0x%08x\n", hres);
|
||||
ok(!lstrcmpW(fnd_tgt, one), "Found target should have been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(fnd_tgt));
|
||||
ok(!lstrcmpW(fnd_loc, two), "Found location should have been %s, was: %s\n", wine_dbgstr_w(two), wine_dbgstr_w(fnd_loc));
|
||||
|
||||
hres = IHlink_SetStringReference(link, -(HLINKSETF_TARGET | HLINKSETF_LOCATION), three, one);
|
||||
ok(hres == S_OK, "IHlink_SetStringReference failed: 0x%08x\n", hres);
|
||||
|
||||
hres = IHlink_GetStringReference(link, HLINKGETREF_DEFAULT, &fnd_tgt, &fnd_loc);
|
||||
ok(hres == S_OK, "IHlink_GetStringReference failed: 0x%08x\n", hres);
|
||||
ok(!lstrcmpW(fnd_tgt, three), "Found target should have been %s, was: %s\n", wine_dbgstr_w(three), wine_dbgstr_w(fnd_tgt));
|
||||
ok(!lstrcmpW(fnd_loc, two), "Found location should have been %s, was: %s\n", wine_dbgstr_w(two), wine_dbgstr_w(fnd_loc));
|
||||
|
||||
/* test invalid flags/params */
|
||||
hres = IHlink_GetStringReference(link, 4, &fnd_tgt, &fnd_loc);
|
||||
ok(hres == E_INVALIDARG, "IHlink_GetStringReference should have failed "
|
||||
"with E_INVALIDARG (0x%08x), instead: 0x%08x\n", E_INVALIDARG, hres);
|
||||
ok(fnd_tgt == NULL, "Found target should have been NULL, was: %s\n", wine_dbgstr_w(fnd_tgt));
|
||||
ok(fnd_loc == NULL, "Found location should have been NULL, was: %s\n", wine_dbgstr_w(fnd_loc));
|
||||
|
||||
hres = IHlink_GetStringReference(link, -1, &fnd_tgt, &fnd_loc);
|
||||
todo_wine ok(hres == E_FAIL, "IHlink_GetStringReference should have failed "
|
||||
"with E_FAIL (0x%08x), instead: 0x%08x\n", E_FAIL, hres);
|
||||
|
||||
hres = IHlink_GetStringReference(link, -2, &fnd_tgt, &fnd_loc);
|
||||
ok(hres == E_INVALIDARG, "IHlink_GetStringReference should have failed "
|
||||
"with E_INVALIDARG (0x%08x), instead: 0x%08x\n", E_INVALIDARG, hres);
|
||||
|
||||
hres = IHlink_SetStringReference(link, 4, NULL, NULL);
|
||||
ok(hres == 4, "IHlink_SetStringReference should have failed with 0x4, instead: 0x%08x\n", hres);
|
||||
|
||||
hres = IHlink_SetStringReference(link, -4, NULL, NULL);
|
||||
ok(hres == -4, "IHlink_SetStringReference should have failed with 0xFFFFFFFC, instead: 0x%08x\n", hres);
|
||||
|
||||
IHlink_Release(link);
|
||||
}
|
||||
|
||||
START_TEST(hlink)
|
||||
{
|
||||
CoInitialize(NULL);
|
||||
|
@ -1133,6 +1227,7 @@ START_TEST(hlink)
|
|||
test_HlinkParseDisplayName();
|
||||
test_HlinkResolveMonikerForData();
|
||||
test_HlinkGetSetMonikerReference();
|
||||
test_HlinkGetSetStringReference();
|
||||
|
||||
CoUninitialize();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue