Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/shell32/tests/shlfolder.c | 159 ++++++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 81 deletions(-)
diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c index bd4bba2..1b140c0 100644 --- a/dlls/shell32/tests/shlfolder.c +++ b/dlls/shell32/tests/shlfolder.c @@ -44,6 +44,8 @@ DEFINE_GUID(IID_IParentAndItem, 0xB3A4B685, 0xB685, 0x4805, 0x99,0xD9, 0x5D,0xEA,0xD2,0x87,0x32,0x36); DEFINE_GUID(CLSID_ShellDocObjView, 0xe7e4bc40, 0xe76a, 0x11ce, 0xa9,0xbb, 0x00,0xaa,0x00,0x4a,0xe8,0x37);
+#define ARRAY_SIZE(x) ( sizeof(x) / sizeof((x)[0]) ) + static IMalloc *ppM;
static HRESULT (WINAPI *pSHCreateItemFromIDList)(PCIDLIST_ABSOLUTE pidl, REFIID riid, void **ppv); @@ -172,108 +174,103 @@ static LPWSTR myPathAddBackslashW( LPWSTR lpszPath ) return lpszPath; }
+static struct +{ + WCHAR path[MAX_PATH]; + HRESULT hr; + int todo; +} parse_tests[] = { + {{'c',':','\',0}, S_OK}, + {{'c',':','\','\',0}, E_INVALIDARG, 1}, + {{'c',':','\','f','a','k','e',0}, 0x80070002}, /* ERROR_FILE_NOT_FOUND */ + {{'c',':','f','a','k','e',0}, E_INVALIDARG, 1}, + {{'c',':','/',0}, E_INVALIDARG, 1}, + {{'c',':','\','w','i','n','d','o','w','s',0}, S_OK}, + {{'c',':','\','w','i','n','d','o','w','s','\',0}, S_OK}, + {{'c',':','\','w','i','n','d','o','w','s','\','.',0}, E_INVALIDARG, 1}, + {{'c',':','\','w','i','n','d','o','w','s','\','.','.',0}, E_INVALIDARG, 1}, + {{'.',0}, E_INVALIDARG, 1}, + {{'.','.',0}, E_INVALIDARG, 1}, + {{'t','e','s','t',0}, 0x80070002}, + {{'t','e','s','t','\',0}, 0x80070002}, + {{'s','u','b','\','d','i','r',0}, 0x80070002}, + {{'s','u','b','/','d','i','r',0}, E_INVALIDARG, 1}, + {{'h','t','t','p',':',0}, S_OK, 1}, + {{'h','t','t','p',':','t','e','s','t',0}, S_OK, 1}, + {{'h','t','t','p',':','\','t','e','s','t',0}, S_OK, 1}, + {{'x','x',':',0}, S_OK, 1}, +}; + static void test_ParseDisplayName(void) { + static WCHAR testdirW[] = {'p','a','r','s','e','t','e','s','t',0}; + static WCHAR backslashW[] = {'\',0}; + WCHAR buffer[MAX_PATH], buffer2[MAX_PATH]; + IShellFolder *desktop; + ITEMIDLIST *pidl; HRESULT hr; - IShellFolder *IDesktopFolder; - static const char *cNonExistDir1A = "c:\nonexist_subdir"; - static const char *cNonExistDir2A = "c:\\nonexist_subdir"; - static const char *cInetTestA = "http:\yyy"; - static const char *cInetTest2A = "xx:yyy"; - DWORD res; - WCHAR cTestDirW [MAX_PATH] = {0}; - ITEMIDLIST *newPIDL; BOOL bRes; + int i;
- hr = SHGetDesktopFolder(&IDesktopFolder); + hr = SHGetDesktopFolder(&desktop); ok(hr == S_OK, "Expected SHGetDesktopFolder to return S_OK, got 0x%08x\n", hr); - if(hr != S_OK) return;
- if (pSHCreateShellItem) - { - if (0) - { - /* null name and pidl, crashes on Windows 8 */ - hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, - NULL, NULL, NULL, 0); - ok(hr == E_INVALIDARG, "returned %08x, expected E_INVALIDARG\n", hr); - } + hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, NULL, NULL, &pidl, NULL); + ok(hr == E_INVALIDARG, "got %#x\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); - } - else - win_skip("SHCreateShellItem requires XP SP1 or later\n"); - - MultiByteToWideChar(CP_ACP, 0, cInetTestA, -1, cTestDirW, MAX_PATH); - hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, cTestDirW, NULL, &newPIDL, 0); - todo_wine ok(hr == S_OK, "ParseDisplayName returned %08x, expected SUCCESS\n", hr); - if (hr == S_OK) + for (i = 0; i < ARRAY_SIZE(parse_tests); i++) { - ok(ILFindLastID(newPIDL)->mkid.abID[0] == 0x61, "Last pidl should be of type " - "PT_IESPECIAL1, but is: %02x\n", ILFindLastID(newPIDL)->mkid.abID[0]); - IMalloc_Free(ppM, newPIDL); + hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, parse_tests[i].path, NULL, &pidl, NULL); +todo_wine_if(parse_tests[i].todo) + ok(hr == parse_tests[i].hr, "%s: expected %#x, got %#x\n", + wine_dbgstr_w(parse_tests[i].path), parse_tests[i].hr, hr); + if (SUCCEEDED(hr)) + CoTaskMemFree(pidl); }
- MultiByteToWideChar(CP_ACP, 0, cInetTest2A, -1, cTestDirW, MAX_PATH); - hr = IShellFolder_ParseDisplayName(IDesktopFolder, - NULL, NULL, cTestDirW, NULL, &newPIDL, 0); - todo_wine ok(hr == S_OK, "ParseDisplayName returned %08x, expected SUCCESS\n", hr); - if (hr == S_OK) - { - ok(ILFindLastID(newPIDL)->mkid.abID[0] == 0x61, "Last pidl should be of type " - "PT_IESPECIAL1, but is: %02x\n", ILFindLastID(newPIDL)->mkid.abID[0]); - IMalloc_Free(ppM, newPIDL); - } - - res = GetFileAttributesA(cNonExistDir1A); - if(res != INVALID_FILE_ATTRIBUTES) - { - skip("Test directory unexpectedly exists\n"); - goto finished; - } - - MultiByteToWideChar(CP_ACP, 0, cNonExistDir1A, -1, cTestDirW, MAX_PATH); - hr = IShellFolder_ParseDisplayName(IDesktopFolder, - NULL, NULL, cTestDirW, NULL, &newPIDL, 0); - ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), - "ParseDisplayName returned %08x, expected 0x80070002\n", hr); - - res = GetFileAttributesA(cNonExistDir2A); - if(res != INVALID_FILE_ATTRIBUTES) - { - skip("Test directory unexpectedly exists\n"); - goto finished; - } - - MultiByteToWideChar(CP_ACP, 0, cNonExistDir2A, -1, cTestDirW, MAX_PATH); - hr = IShellFolder_ParseDisplayName(IDesktopFolder, - NULL, NULL, cTestDirW, NULL, &newPIDL, 0); - todo_wine ok(hr == E_INVALIDARG, "ParseDisplayName returned %08x, expected E_INVALIDARG\n", hr); - /* I thought that perhaps the DesktopFolder's ParseDisplayName would recognize the * path corresponding to CSIDL_PERSONAL and return a CLSID_MyDocuments PIDL. Turns * out it doesn't. The magic seems to happen in the file dialogs, then. */
- bRes = SHGetSpecialFolderPathW(NULL, cTestDirW, CSIDL_PERSONAL, FALSE); + bRes = SHGetSpecialFolderPathW(NULL, buffer, CSIDL_PERSONAL, FALSE); ok(bRes, "SHGetSpecialFolderPath(CSIDL_PERSONAL) failed! %u\n", GetLastError()); - if (!bRes) goto finished;
- hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, cTestDirW, NULL, &newPIDL, 0); + hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, buffer, NULL, &pidl, 0); ok(hr == S_OK, "DesktopFolder->ParseDisplayName failed. hr = %08x.\n", hr); - if (hr != S_OK) goto finished;
- ok(ILFindLastID(newPIDL)->mkid.abID[0] == 0x31, + ok(ILFindLastID(pidl)->mkid.abID[0] == 0x31, "Last pidl should be of type PT_FOLDER, but is: %02x\n", - ILFindLastID(newPIDL)->mkid.abID[0]); - IMalloc_Free(ppM, newPIDL); + ILFindLastID(pidl)->mkid.abID[0]); + CoTaskMemFree(pidl);
-finished: - IShellFolder_Release(IDesktopFolder); + /* Relative paths are interpreted relative to the desktop. */ + GetTempPathW(sizeof(buffer), buffer); + GetLongPathNameW(buffer, buffer, sizeof(buffer)); + SetCurrentDirectoryW(buffer); + CreateDirectoryW(testdirW, NULL); + + hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, testdirW, NULL, &pidl, NULL); + ok(hr == 0x80070002, "got %#x\n", hr); + + RemoveDirectoryW(testdirW); + + hr = SHGetSpecialFolderPathW(NULL, buffer, CSIDL_DESKTOP, FALSE); + ok(hr == S_FALSE, "got %#x\n", hr); + SetCurrentDirectoryW(buffer); + CreateDirectoryW(testdirW, NULL); + + hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, testdirW, NULL, &pidl, NULL); + ok(hr == S_OK, "got %#x\n", hr); + + ok(SHGetPathFromIDListW(pidl, buffer2), "SHGetPathFromIDList failed\n"); + lstrcatW(buffer, backslashW); + lstrcatW(buffer, testdirW); + ok(!lstrcmpW(buffer, buffer2), "expected %s, got %s\n", wine_dbgstr_w(buffer), wine_dbgstr_w(buffer2)); + + RemoveDirectoryW(testdirW); + CoTaskMemFree(pidl); + + IShellFolder_Release(desktop); }
/* creates a file with the specified name for tests */
Fixes bug #44570.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- programs/explorer/explorer.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/programs/explorer/explorer.c b/programs/explorer/explorer.c index ac5bebb..c509336 100644 --- a/programs/explorer/explorer.c +++ b/programs/explorer/explorer.c @@ -24,6 +24,7 @@
#include "wine/unicode.h" #include "wine/debug.h" +#include "wine/heap.h" #include "explorer_private.h" #include "resource.h"
@@ -631,16 +632,26 @@ static IShellFolder* get_starting_shell_folder(parameters_struct* params) { IShellFolder* desktop,*folder; LPITEMIDLIST root_pidl; + WCHAR *fullpath = NULL; HRESULT hres; + DWORD size;
SHGetDesktopFolder(&desktop); if (!params->root[0]) { return desktop; } + + size = GetFullPathNameW(params->root, 0, fullpath, NULL); + if (!size) + return desktop; + fullpath = heap_alloc(size * sizeof(WCHAR)); + GetFullPathNameW(params->root, size, fullpath, NULL); + hres = IShellFolder_ParseDisplayName(desktop,NULL,NULL, - params->root,NULL, + fullpath,NULL, &root_pidl,NULL); + heap_free(fullpath);
if(FAILED(hres)) {