shell32: Implement SHParseDisplayName with basic tests.

This commit is contained in:
Nikolay Sivov 2010-03-03 04:56:20 +03:00 committed by Alexandre Julliard
parent 721be7135f
commit 500c785053
3 changed files with 98 additions and 7 deletions

View File

@ -1326,9 +1326,24 @@ HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCI
HRESULT WINAPI SHParseDisplayName(LPCWSTR name, IBindCtx *bindctx, LPITEMIDLIST *pidlist,
SFGAOF attr_in, SFGAOF *attr_out)
{
FIXME("%s %p %p %d %p stub!\n", debugstr_w(name), bindctx, pidlist, attr_in, attr_out);
if(pidlist) *pidlist = NULL;
return E_NOTIMPL;
IShellFolder *desktop;
HRESULT hr;
TRACE("%s %p %p %d %p\n", debugstr_w(name), bindctx, pidlist, attr_in, attr_out);
*pidlist = NULL;
if (!name) return E_OUTOFMEMORY;
hr = SHGetDesktopFolder(&desktop);
if (hr != S_OK) return hr;
hr = IShellFolder_ParseDisplayName(desktop, NULL, bindctx, (LPWSTR)name, NULL, pidlist, &attr_in);
if (attr_out) *attr_out = attr_in;
IShellFolder_Release(desktop);
return hr;
}
/**************************************************************************

View File

@ -151,11 +151,11 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface,
This, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName),
pchEaten, ppidl, pdwAttributes);
if (!lpszDisplayName || !ppidl)
return E_INVALIDARG;
if (!ppidl) return E_INVALIDARG;
*ppidl = 0;
if (!lpszDisplayName) return E_INVALIDARG;
if (pchEaten)
*pchEaten = 0; /* strange but like the original */

View File

@ -54,7 +54,7 @@ static void (WINAPI *pILFree)(LPITEMIDLIST);
static BOOL (WINAPI *pILIsEqual)(LPCITEMIDLIST, LPCITEMIDLIST);
static HRESULT (WINAPI *pSHCreateShellItem)(LPCITEMIDLIST,IShellFolder*,LPCITEMIDLIST,IShellItem**);
static LPITEMIDLIST (WINAPI *pILCombine)(LPCITEMIDLIST,LPCITEMIDLIST);
static HRESULT (WINAPI *pSHParseDisplayName)(LPCWSTR,IBindCtx*,LPITEMIDLIST*,SFGAOF,SFGAOF*);
static void init_function_pointers(void)
{
@ -71,6 +71,7 @@ static void init_function_pointers(void)
MAKEFUNC(SHGetPathFromIDListW);
MAKEFUNC(SHGetSpecialFolderPathA);
MAKEFUNC(SHGetSpecialFolderPathW);
MAKEFUNC(SHParseDisplayName);
#undef MAKEFUNC
#define MAKEFUNC_ORD(f, ord) (p##f = (void*)GetProcAddress(hmod, (LPSTR)(ord)))
@ -103,6 +104,18 @@ static void test_ParseDisplayName(void)
hr = SHGetDesktopFolder(&IDesktopFolder);
if(hr != S_OK) return;
/* null name and pidl */
hr = IShellFolder_ParseDisplayName(IDesktopFolder,
NULL, NULL, NULL, NULL, NULL, 0);
ok(hr == E_INVALIDARG, "returned %08x, expected E_INVALIDARG\n", hr);
/* null name */
newPIDL = (ITEMIDLIST*)0xdeadbeef;
hr = IShellFolder_ParseDisplayName(IDesktopFolder,
NULL, NULL, NULL, NULL, &newPIDL, 0);
ok(newPIDL == 0, "expected null, got %p\n", newPIDL);
ok(hr == E_INVALIDARG, "returned %08x, expected E_INVALIDARG\n", hr);
MultiByteToWideChar(CP_ACP, 0, cInetTestA, -1, cTestDirW, MAX_PATH);
hr = IShellFolder_ParseDisplayName(IDesktopFolder,
NULL, NULL, cTestDirW, NULL, &newPIDL, 0);
@ -1962,6 +1975,68 @@ static void test_SHCreateShellItem(void)
IShellFolder_Release(desktopfolder);
}
static void test_SHParseDisplayName(void)
{
static const WCHAR prefixW[] = {'w','t',0};
LPITEMIDLIST pidl1, pidl2;
IShellFolder *desktop;
WCHAR dirW[MAX_PATH];
WCHAR nameW[10];
HRESULT hr;
BOOL ret;
if (!pSHParseDisplayName)
{
win_skip("SHParseDisplayName isn't available\n");
return;
}
if (0)
{
/* crashes on native */
hr = pSHParseDisplayName(NULL, NULL, NULL, 0, NULL);
nameW[0] = 0;
hr = pSHParseDisplayName(nameW, NULL, NULL, 0, NULL);
}
pidl1 = (LPITEMIDLIST)0xdeadbeef;
hr = pSHParseDisplayName(NULL, NULL, &pidl1, 0, NULL);
ok(hr == E_OUTOFMEMORY, "failed %08x\n", hr);
ok(pidl1 == 0, "expected null ptr, got %p\n", pidl1);
/* dummy name */
nameW[0] = 0;
hr = pSHParseDisplayName(nameW, NULL, &pidl1, 0, NULL);
ok(hr == S_OK, "failed %08x\n", hr);
hr = SHGetDesktopFolder(&desktop);
ok(hr == S_OK, "failed %08x\n", hr);
hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, nameW, NULL, &pidl2, NULL);
ok(hr == S_OK, "failed %08x\n", hr);
ret = pILIsEqual(pidl1, pidl2);
ok(ret == TRUE, "expected equal idls\n");
pILFree(pidl1);
pILFree(pidl2);
/* with path */
GetTempPathW(sizeof(dirW)/sizeof(WCHAR), dirW);
GetTempFileNameW(dirW, prefixW, 0, dirW);
CreateFileW(dirW, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
hr = pSHParseDisplayName(dirW, NULL, &pidl1, 0, NULL);
ok(hr == S_OK, "failed %08x\n", hr);
hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, dirW, NULL, &pidl2, NULL);
ok(hr == S_OK, "failed %08x\n", hr);
ret = pILIsEqual(pidl1, pidl2);
ok(ret == TRUE, "expected equal idls\n");
pILFree(pidl1);
pILFree(pidl2);
DeleteFileW(dirW);
IShellFolder_Release(desktop);
}
START_TEST(shlfolder)
{
init_function_pointers();
@ -1970,6 +2045,7 @@ START_TEST(shlfolder)
OleInitialize(NULL);
test_ParseDisplayName();
test_SHParseDisplayName();
test_BindToObject();
test_EnumObjects_and_CompareIDs();
test_GetDisplayName();