Author: cwittich
Date: Wed Mar 3 20:44:02 2010
New Revision: 45799
URL:
http://svn.reactos.org/svn/reactos?rev=45799&view=rev
Log:
[HLINK_WINETEST]
sync hlink_winetest to wine 1.1.39
Added:
trunk/rostests/winetests/hlink/browse_ctx.c (with props)
Modified:
trunk/rostests/winetests/hlink/hlink.c
trunk/rostests/winetests/hlink/hlink.rbuild
trunk/rostests/winetests/hlink/testlist.c
Added: trunk/rostests/winetests/hlink/browse_ctx.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/hlink/browse_ct…
==============================================================================
--- trunk/rostests/winetests/hlink/browse_ctx.c (added)
+++ trunk/rostests/winetests/hlink/browse_ctx.c [iso-8859-1] Wed Mar 3 20:44:02 2010
@@ -1,0 +1,90 @@
+/*
+ * Copyright 2009 Andrew Eikum for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+
+#include <stdio.h>
+
+#include <hlink.h>
+
+#include "wine/test.h"
+
+/* Win9x and WinMe don't have lstrcmpW */
+static int strcmp_ww(const WCHAR *str1, const WCHAR *str2)
+{
+ DWORD len1 = lstrlenW(str1);
+ DWORD len2 = lstrlenW(str2);
+
+ if (len1 != len2) return 1;
+ return memcmp(str1, str2, len1 * sizeof(WCHAR));
+}
+
+static void test_SetInitialHlink(void)
+{
+ IHlinkBrowseContext *bc;
+ IHlink *found_hlink;
+ IMoniker *dummy, *found_moniker;
+ IBindCtx *bindctx;
+ WCHAR one[] = {'1',0};
+ WCHAR five[] = {'5',0};
+ WCHAR *found_name, *exp_name;
+ HRESULT hres;
+
+ hres = CreateBindCtx(0, &bindctx);
+ ok(hres == S_OK, "CreateBindCtx failed: 0x%08x\n", hres);
+
+ hres = CreateItemMoniker(one, five, &dummy);
+ ok(hres == S_OK, "CreateItemMoniker failed: 0x%08x\n", hres);
+
+ hres = IMoniker_GetDisplayName(dummy, bindctx, NULL, &exp_name);
+ ok(hres == S_OK, "GetDisplayName failed: 0x%08x\n", hres);
+
+ hres = HlinkCreateBrowseContext(NULL, &IID_IHlinkBrowseContext,
(void**)&bc);
+ ok(hres == S_OK, "HlinkCreateBrowseContext failed: 0x%08x\n", hres);
+
+ hres = IHlinkBrowseContext_SetInitialHlink(bc, dummy, one, NULL);
+ ok(hres == S_OK, "SetInitialHlink failed: 0x%08x\n", hres);
+
+ hres = IHlinkBrowseContext_GetHlink(bc, HLID_CURRENT, &found_hlink);
+ ok(hres == S_OK, "GetHlink failed: 0x%08x\n", hres);
+
+ hres = IHlink_GetMonikerReference(found_hlink, HLINKGETREF_DEFAULT,
&found_moniker, NULL);
+ ok(hres == S_OK, "GetMonikerReference failed: 0x%08x\n", hres);
+
+ hres = IMoniker_GetDisplayName(found_moniker, bindctx, NULL, &found_name);
+ ok(hres == S_OK, "GetDisplayName failed: 0x%08x\n", hres);
+ ok(!strcmp_ww(found_name, exp_name), "Found display name should have been %s,
was: %s\n", wine_dbgstr_w(exp_name), wine_dbgstr_w(found_name));
+
+ CoTaskMemFree(exp_name);
+ CoTaskMemFree(found_name);
+
+ IBindCtx_Release(bindctx);
+ IMoniker_Release(found_moniker);
+ IHlink_Release(found_hlink);
+ IHlinkBrowseContext_Release(bc);
+ IMoniker_Release(dummy);
+}
+
+START_TEST(browse_ctx)
+{
+ CoInitialize(NULL);
+
+ test_SetInitialHlink();
+
+ CoUninitialize();
+}
Propchange: trunk/rostests/winetests/hlink/browse_ctx.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rostests/winetests/hlink/hlink.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/hlink/hlink.c?r…
==============================================================================
--- trunk/rostests/winetests/hlink/hlink.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/hlink/hlink.c [iso-8859-1] Wed Mar 3 20:44:02 2010
@@ -137,9 +137,7 @@
r = IHlink_GetStringReference(lnk, HLINKGETREF_DEFAULT, &str, NULL);
ok(r == S_OK, "failed\n");
- todo_wine {
ok(!lstrcmpW(str, url2), "url wrong\n");
- }
CoTaskMemFree(str);
r = IHlink_GetStringReference(lnk, HLINKGETREF_DEFAULT, NULL, NULL);
@@ -1121,6 +1119,231 @@
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));
+ CoTaskMemFree(fnd_tgt);
+ CoTaskMemFree(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));
+ CoTaskMemFree(fnd_tgt);
+ CoTaskMemFree(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));
+ CoTaskMemFree(fnd_tgt);
+ CoTaskMemFree(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));
+ CoTaskMemFree(fnd_tgt);
+ CoTaskMemFree(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));
+ CoTaskMemFree(fnd_tgt);
+ CoTaskMemFree(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));
+ CoTaskMemFree(fnd_tgt);
+ CoTaskMemFree(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));
+ CoTaskMemFree(fnd_tgt);
+ CoTaskMemFree(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));
+ CoTaskMemFree(fnd_tgt);
+ CoTaskMemFree(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);
+ CoTaskMemFree(fnd_tgt);
+ CoTaskMemFree(fnd_loc);
+
+ 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);
+ CoTaskMemFree(fnd_tgt);
+ CoTaskMemFree(fnd_loc);
+
+ 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);
+}
+
+#define setStringRef(h,f,t,l) r_setStringRef(__LINE__,h,f,t,l)
+static void r_setStringRef(unsigned line, IHlink *hlink, DWORD flags, const WCHAR *tgt,
const WCHAR *loc)
+{
+ HRESULT hres;
+ hres = IHlink_SetStringReference(hlink, flags, tgt, loc);
+ ok_(__FILE__,line) (hres == S_OK, "IHlink_SetStringReference failed:
0x%08x\n", hres);
+}
+
+#define getStringRef(h,t,l) r_getStringRef(__LINE__,h,t,l)
+static void r_getStringRef(unsigned line, IHlink *hlink, const WCHAR *exp_tgt, const
WCHAR *exp_loc)
+{
+ HRESULT hres;
+ WCHAR *fnd_tgt, *fnd_loc;
+
+ hres = IHlink_GetStringReference(hlink, HLINKGETREF_DEFAULT, &fnd_tgt,
&fnd_loc);
+ ok_(__FILE__,line) (hres == S_OK, "IHlink_GetStringReference failed:
0x%08x\n", hres);
+
+ if(exp_tgt)
+ ok_(__FILE__,line) (!lstrcmpW(fnd_tgt, exp_tgt), "Found string target should
have been %s, was: %s\n", wine_dbgstr_w(exp_tgt), wine_dbgstr_w(fnd_tgt));
+ else
+ ok_(__FILE__,line) (exp_tgt == NULL, "Found string target should have been
NULL, was: %s\n", wine_dbgstr_w(fnd_tgt));
+
+ if(exp_loc)
+ ok_(__FILE__,line) (!lstrcmpW(fnd_loc, exp_loc), "Found string location
should have been %s, was: %s\n", wine_dbgstr_w(exp_loc), wine_dbgstr_w(fnd_loc));
+ else
+ ok_(__FILE__,line) (exp_loc == NULL, "Found string location should have been
NULL, was: %s\n", wine_dbgstr_w(fnd_loc));
+
+ CoTaskMemFree(fnd_tgt);
+ CoTaskMemFree(fnd_loc);
+}
+
+#define setMonikerRef(h,f,t,l) r_setMonikerRef(__LINE__,h,f,t,l)
+static void r_setMonikerRef(unsigned line, IHlink *hlink, DWORD flags, IMoniker *tgt,
const WCHAR *loc)
+{
+ HRESULT hres;
+ hres = IHlink_SetMonikerReference(hlink, flags, tgt, loc);
+ ok_(__FILE__,line) (hres == S_OK, "IHlink_SetMonikerReference failed:
0x%08x\n", hres);
+}
+
+/* passing 0xFFFFFFFF as exp_tgt will return the retrieved target & not test it */
+#define getMonikerRef(h,t,l) r_getMonikerRef(__LINE__,h,t,l)
+static IMoniker *r_getMonikerRef(unsigned line, IHlink *hlink, IMoniker *exp_tgt, const
WCHAR *exp_loc)
+{
+ HRESULT hres;
+ IMoniker *fnd_tgt;
+ WCHAR *fnd_loc;
+
+ hres = IHlink_GetMonikerReference(hlink, HLINKGETREF_DEFAULT, &fnd_tgt,
&fnd_loc);
+ ok_(__FILE__,line) (hres == S_OK, "IHlink_GetMonikerReference failed:
0x%08x\n", hres);
+
+ if(exp_loc)
+ ok_(__FILE__,line) (!lstrcmpW(fnd_loc, exp_loc), "Found string location
should have been %s, was: %s\n", wine_dbgstr_w(exp_loc), wine_dbgstr_w(fnd_loc));
+ else
+ ok_(__FILE__,line) (exp_loc == NULL, "Found string location should have been
NULL, was: %s\n", wine_dbgstr_w(fnd_loc));
+
+ CoTaskMemFree(fnd_loc);
+
+ if(exp_tgt == (IMoniker*)0xFFFFFFFF)
+ return fnd_tgt;
+
+ ok_(__FILE__,line) (fnd_tgt == exp_tgt, "Found moniker target should have been
%p, was: %p\n", exp_tgt, fnd_tgt);
+
+ if(fnd_tgt)
+ IMoniker_Release(fnd_tgt);
+
+ return NULL;
+}
+
+static void test_HlinkMoniker(void)
+{
+ IHlink *hlink;
+ IMoniker *aMon, *file_mon;
+ static const WCHAR emptyW[] = {0};
+ static const WCHAR wordsW[] =
{'w','o','r','d','s',0};
+ static const WCHAR aW[] = {'a',0};
+ static const WCHAR bW[] = {'b',0};
+ HRESULT hres;
+
+ hres = HlinkCreateFromString(NULL, NULL, NULL, NULL, 0, NULL, &IID_IHlink,
(void**)&hlink);
+ ok(hres == S_OK, "HlinkCreateFromString failed: 0x%08x\n", hres);
+ getStringRef(hlink, NULL, NULL);
+ getMonikerRef(hlink, NULL, NULL);
+
+ /* setting a string target creates a moniker reference */
+ setStringRef(hlink, HLINKSETF_TARGET | HLINKSETF_LOCATION, aW, wordsW);
+ getStringRef(hlink, aW, wordsW);
+ aMon = getMonikerRef(hlink, (IMoniker*)0xFFFFFFFF, wordsW);
+ ok(aMon != NULL, "Moniker from %s target should not be NULL\n",
wine_dbgstr_w(aW));
+ if(aMon)
+ IMoniker_Release(aMon);
+
+ /* setting target & location to the empty string deletes the moniker
+ * reference */
+ setStringRef(hlink, HLINKSETF_TARGET | HLINKSETF_LOCATION, emptyW, emptyW);
+ getStringRef(hlink, NULL, NULL);
+ getMonikerRef(hlink, NULL, NULL);
+
+ /* setting a moniker target also sets the target string to that moniker's
+ * display name */
+ hres = CreateFileMoniker(bW, &file_mon);
+ ok(hres == S_OK, "CreateFileMoniker failed: 0x%08x\n", hres);
+
+ setMonikerRef(hlink, HLINKSETF_TARGET | HLINKSETF_LOCATION, file_mon, wordsW);
+ getStringRef(hlink, bW, wordsW);
+ getMonikerRef(hlink, file_mon, wordsW);
+
+ IMoniker_Release(file_mon);
+
+ IHlink_Release(hlink);
+}
+
START_TEST(hlink)
{
CoInitialize(NULL);
@@ -1133,6 +1356,8 @@
test_HlinkParseDisplayName();
test_HlinkResolveMonikerForData();
test_HlinkGetSetMonikerReference();
+ test_HlinkGetSetStringReference();
+ test_HlinkMoniker();
CoUninitialize();
}
Modified: trunk/rostests/winetests/hlink/hlink.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/hlink/hlink.rbu…
==============================================================================
--- trunk/rostests/winetests/hlink/hlink.rbuild [iso-8859-1] (original)
+++ trunk/rostests/winetests/hlink/hlink.rbuild [iso-8859-1] Wed Mar 3 20:44:02 2010
@@ -3,7 +3,8 @@
<group>
<module name="hlink_winetest" type="win32cui"
installbase="bin" installname="hlink_winetest.exe"
allowwarnings="true">
<include base="hlink_winetest">.</include>
- <define name="__ROS_LONG64__" />
+ <define name="__ROS_LONG64__" />
+ <file>browse_ctx.c</file>
<file>hlink.c</file>
<file>testlist.c</file>
<library>wine</library>
Modified: trunk/rostests/winetests/hlink/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/hlink/testlist.…
==============================================================================
--- trunk/rostests/winetests/hlink/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/hlink/testlist.c [iso-8859-1] Wed Mar 3 20:44:02 2010
@@ -7,9 +7,11 @@
#include "wine/test.h"
extern void func_hlink(void);
+extern void func_browse_ctx(void);
const struct test winetest_testlist[] =
{
+ { "browse_ctx", func_browse_ctx },
{ "hlink", func_hlink },
{ 0, 0 }
};