From 7a93748222ee2559edca6a3ae0807015ea62eadc Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Tue, 22 Dec 2009 11:40:11 +0000 Subject: [PATCH] sync hlink_winetest with wine 1.1.35 svn path=/trunk/; revision=44704 --- rostests/winetests/hlink/hlink.c | 125 +++++++++++++++++++++++++++---- 1 file changed, 111 insertions(+), 14 deletions(-) diff --git a/rostests/winetests/hlink/hlink.c b/rostests/winetests/hlink/hlink.c index 5e07359fdf5..1a7536fee93 100644 --- a/rostests/winetests/hlink/hlink.c +++ b/rostests/winetests/hlink/hlink.c @@ -57,15 +57,6 @@ DEFINE_EXPECT(IsSystemMoniker); DEFINE_EXPECT(BindToStorage); DEFINE_EXPECT(GetDisplayName); -static const char *debugstr_w(LPCWSTR str) -{ - static char buf[1024]; - if(!str) - return "(null)"; - WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL); - return buf; -} - static const char *debugstr_guid(REFIID riid) { static char buf[50]; @@ -80,7 +71,7 @@ static const char *debugstr_guid(REFIID riid) static void test_HlinkIsShortcut(void) { - int i; + UINT i; HRESULT hres; static const WCHAR file0[] = {'f','i','l','e',0}; @@ -597,13 +588,13 @@ static void test_HlinkCreateExtensionServices(void) hres = IHttpNegotiate_BeginningTransaction(http_negotiate, (void*)0xdeadbeef, (void*)0xdeadbeef, 0, &headers); ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres); - ok(!lstrcmpW(headers, headersexW), "unexpected headers \"%s\"\n", debugstr_w(headers)); + ok(!lstrcmpW(headers, headersexW), "unexpected headers %s\n", wine_dbgstr_w(headers)); CoTaskMemFree(headers); headers = (void*)0xdeadbeef; hres = IHttpNegotiate_OnResponse(http_negotiate, 200, (void*)0xdeadbeef, (void*)0xdeadbeef, &headers); ok(hres == S_OK, "OnResponse failed: %08x\n", hres); - ok(headers == NULL, "unexpected headers \"%s\"\n", debugstr_w(headers)); + ok(headers == NULL, "unexpected headers %s\n", wine_dbgstr_w(headers)); IHttpNegotiate_Release(http_negotiate); IAuthenticate_Release(authenticate); @@ -635,7 +626,7 @@ static void test_HlinkParseDisplayName(void) hres = IMoniker_GetDisplayName(mon, bctx, 0, &name); ok(hres == S_OK, "GetDiasplayName failed: %08x\n", hres); - ok(!lstrcmpW(name, winehq_urlW), "wrong display name %s\n", debugstr_w(name)); + ok(!lstrcmpW(name, winehq_urlW), "wrong display name %s\n", wine_dbgstr_w(name)); CoTaskMemFree(name); hres = IMoniker_IsSystemMoniker(mon, &issys); @@ -662,13 +653,14 @@ static void test_HlinkParseDisplayName(void) hres = IMoniker_GetDisplayName(mon, bctx, 0, &name); ok(hres == S_OK, "GetDiasplayName failed: %08x\n", hres); - ok(!lstrcmpW(name, invalid_urlW), "wrong display name %s\n", debugstr_w(name)); + ok(!lstrcmpW(name, invalid_urlW), "wrong display name %s\n", wine_dbgstr_w(name)); CoTaskMemFree(name); hres = IMoniker_IsSystemMoniker(mon, &issys); ok(hres == S_OK, "IsSystemMoniker failed: %08x\n", hres); ok(issys == MKSYS_FILEMONIKER, "issys=%x\n", issys); + IMoniker_Release(mon); IBindCtx_Release(bctx); } @@ -1025,6 +1017,110 @@ static void test_HlinkResolveMonikerForData(void) IBindCtx_Release(bctx); } +static void test_HlinkGetSetMonikerReference(void) +{ + IMoniker *found_trgt, *dummy, *dummy2; + IHlink *hlink; + HRESULT hres; + const WCHAR one[] = {'1',0}; + const WCHAR two[] = {'2',0}; + const WCHAR name[] = {'a',0}; + WCHAR *found_loc; + + /* create two dummy monikers to use as targets */ + hres = CreateItemMoniker(one, one, &dummy); + ok(hres == S_OK, "CreateItemMoniker failed: 0x%08x\n", hres); + + hres = CreateItemMoniker(two, two, &dummy2); + ok(hres == S_OK, "CreateItemMoniker failed: 0x%08x\n", hres); + + /* create a new hlink: target => dummy, location => one */ + hres = HlinkCreateFromMoniker(dummy, one, name, NULL, 0, NULL, &IID_IHlink, (void**)&hlink); + ok(hres == S_OK, "HlinkCreateFromMoniker failed: 0x%08x\n", hres); + + /* validate the target and location */ + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &found_trgt, &found_loc); + ok(hres == S_OK, "IHlink_GetMonikerReference failed: 0x%08x\n", hres); + ok(found_trgt == dummy, "Found target should've been %p, was: %p\n", dummy, found_trgt); + ok(lstrcmpW(found_loc, one) == 0, "Found location should've been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(found_loc)); + IMoniker_Release(found_trgt); + CoTaskMemFree(found_loc); + + /* set location => two */ + hres = IHlink_SetMonikerReference(hlink, HLINKSETF_LOCATION, dummy2, two); + ok(hres == S_OK, "IHlink_SetMonikerReference failed: 0x%08x\n", hres); + + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &found_trgt, &found_loc); + ok(found_trgt == dummy, "Found target should've been %p, was: %p\n", dummy, found_trgt); + ok(lstrcmpW(found_loc, two) == 0, "Found location should've been %s, was: %s\n", wine_dbgstr_w(two), wine_dbgstr_w(found_loc)); + IMoniker_Release(found_trgt); + CoTaskMemFree(found_loc); + + /* set target => dummy2 */ + hres = IHlink_SetMonikerReference(hlink, HLINKSETF_TARGET, dummy2, one); + ok(hres == S_OK, "IHlink_SetMonikerReference failed: 0x%08x\n", hres); + + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &found_trgt, &found_loc); + ok(found_trgt == dummy2, "Found target should've been %p, was: %p\n", dummy2, found_trgt); + ok(lstrcmpW(found_loc, two) == 0, "Found location should've been %s, was: %s\n", wine_dbgstr_w(two), wine_dbgstr_w(found_loc)); + IMoniker_Release(found_trgt); + CoTaskMemFree(found_loc); + + /* set target => dummy, location => one */ + hres = IHlink_SetMonikerReference(hlink, HLINKSETF_TARGET | HLINKSETF_LOCATION, dummy, one); + ok(hres == S_OK, "IHlink_SetMonikerReference failed: 0x%08x\n", hres); + + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &found_trgt, &found_loc); + ok(found_trgt == dummy, "Found target should've been %p, was: %p\n", dummy, found_trgt); + ok(lstrcmpW(found_loc, one) == 0, "Found location should've been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(found_loc)); + IMoniker_Release(found_trgt); + CoTaskMemFree(found_loc); + + /* no HLINKSETF flags */ + hres = IHlink_SetMonikerReference(hlink, 0, dummy2, two); + ok(hres == E_INVALIDARG, "IHlink_SetMonikerReference should've failed with E_INVALIDARG (0x%08x), failed with 0x%08x\n", E_INVALIDARG, hres); + + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &found_trgt, &found_loc); + ok(found_trgt == dummy, "Found target should've been %p, was: %p\n", dummy, found_trgt); + ok(lstrcmpW(found_loc, one) == 0, "Found location should've been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(found_loc)); + IMoniker_Release(found_trgt); + CoTaskMemFree(found_loc); + + /* invalid HLINKSETF flags */ + hres = IHlink_SetMonikerReference(hlink, 12, dummy2, two); + ok(hres == 12, "IHlink_SetMonikerReference should've failed with 0x%08x, failed with 0x%08x\n", 12, hres); + + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &found_trgt, &found_loc); + ok(found_trgt == dummy, "Found target should've been %p, was: %p\n", dummy, found_trgt); + ok(lstrcmpW(found_loc, one) == 0, "Found location should've been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(found_loc)); + IMoniker_Release(found_trgt); + CoTaskMemFree(found_loc); + + /* valid & invalid HLINKSETF flags */ + hres = IHlink_SetMonikerReference(hlink, 12 | HLINKSETF_TARGET, dummy2, two); + ok(hres == S_OK, "IHlink_SetMonikerReference failed: 0x%08x\n", hres); + + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &found_trgt, &found_loc); + ok(found_trgt == dummy2, "Found target should've been %p, was: %p\n", dummy2, found_trgt); + ok(lstrcmpW(found_loc, one) == 0, "Found location should've been %s, was: %s\n", wine_dbgstr_w(one), wine_dbgstr_w(found_loc)); + IMoniker_Release(found_trgt); + CoTaskMemFree(found_loc); + + /* NULL args */ + hres = IHlink_SetMonikerReference(hlink, HLINKSETF_TARGET | HLINKSETF_LOCATION, NULL, NULL); + ok(hres == S_OK, "IHlink_SetMonikerReference failed: 0x%08x\n", hres); + + hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &found_trgt, &found_loc); + ok(found_trgt == NULL, "Found target should've been %p, was: %p\n", NULL, found_trgt); + ok(found_loc == NULL, "Found location should've been %s, was: %s\n", wine_dbgstr_w(NULL), wine_dbgstr_w(found_loc)); + if(found_trgt) + IMoniker_Release(found_trgt); + + IHlink_Release(hlink); + IMoniker_Release(dummy2); + IMoniker_Release(dummy); +} + START_TEST(hlink) { CoInitialize(NULL); @@ -1036,6 +1132,7 @@ START_TEST(hlink) test_HlinkCreateExtensionServices(); test_HlinkParseDisplayName(); test_HlinkResolveMonikerForData(); + test_HlinkGetSetMonikerReference(); CoUninitialize(); }