[SHELL32_WINETEST] Sync with Wine Staging 2.16. CORE-13762
authorAmine Khaldi <amine.khaldi@reactos.org>
Thu, 19 Oct 2017 11:36:19 +0000 (12:36 +0100)
committerAmine Khaldi <amine.khaldi@reactos.org>
Thu, 19 Oct 2017 21:30:28 +0000 (22:30 +0100)
modules/rostests/winetests/shell32/CMakeLists.txt
modules/rostests/winetests/shell32/recyclebin.c
modules/rostests/winetests/shell32/shellpath.c
modules/rostests/winetests/shell32/shlexec.c
modules/rostests/winetests/shell32/shlfolder.c

index 47b0397..7d33d85 100644 (file)
@@ -1,4 +1,6 @@
 
+add_definitions(-DWINETEST_USE_DBGSTR_LONGLONG)
+
 remove_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502)
 
 list(APPEND SOURCE
index a5ac1dc..50e262e 100644 (file)
 static int (WINAPI *pSHQueryRecycleBinA)(LPCSTR,LPSHQUERYRBINFO);
 static int (WINAPI *pSHFileOperationA)(LPSHFILEOPSTRUCTA);
 
-static char int64_buffer[65];
-/* Note: This function uses a single buffer for the return value.*/
-static const char* str_from_int64(__int64 ll)
-{
-
-    if (sizeof(ll) > sizeof(unsigned long) && ll >> 32)
-        sprintf(int64_buffer,"%lx%08lx",(unsigned long)(ll >> 32),(unsigned long)ll);
-    else
-        sprintf(int64_buffer,"%lx",(unsigned long)ll);
-    return int64_buffer;
-}
-
 static void setup_pointers(void)
 {
     HMODULE hshell32 = GetModuleHandleA("shell32.dll");
@@ -88,8 +76,8 @@ static void test_query_recyclebin(void)
     ok(!pSHFileOperationA(&shfo), "Deletion was not successful\n");
     hr = pSHQueryRecycleBinA(buf,&info2);
     ok(hr == S_OK, "SHQueryRecycleBinA failed with error 0x%x\n", hr);
-    ok(info2.i64Size==info1.i64Size+written,"Expected recycle bin to have 0x%s bytes\n",str_from_int64(info1.i64Size+written));
-    ok(info2.i64NumItems==info1.i64NumItems+1,"Expected recycle bin to have 0x%s items\n",str_from_int64(info1.i64NumItems+1));
+    ok(info2.i64Size==info1.i64Size+written,"Expected recycle bin to have 0x%s bytes\n",wine_dbgstr_longlong(info1.i64Size+written));
+    ok(info2.i64NumItems==info1.i64NumItems+1,"Expected recycle bin to have 0x%s items\n",wine_dbgstr_longlong(info1.i64NumItems+1));
 }
 
 
index 3292c54..9fea876 100644 (file)
@@ -2781,9 +2781,33 @@ if (0) { /* crashes on native */
     hr = pSHGetKnownFolderIDList(&FOLDERID_Desktop, 0, NULL, NULL);
     ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
 
+    pidl = (void*)0xdeadbeef;
     hr = pSHGetKnownFolderIDList(&FOLDERID_Desktop, 0, NULL, &pidl);
-    ok(hr == S_OK, "got 0x%08x\n", hr);
-    CoTaskMemFree(pidl);
+    ok(hr == S_OK, "SHGetKnownFolderIDList failed: 0x%08x\n", hr);
+    ok(ILIsEmpty(pidl), "pidl should be empty.\n");
+    ok(pidl->mkid.cb == 0, "get wrong value: %d\n", pidl->mkid.cb);
+    ILFree(pidl);
+
+    pidl = (void*)0xdeadbeef;
+    hr = pSHGetKnownFolderIDList(&FOLDERID_Desktop, KF_FLAG_NO_ALIAS, NULL, &pidl);
+    ok(hr == S_OK, "SHGetKnownFolderIDList failed: 0x%08x\n", hr);
+    todo_wine ok(!ILIsEmpty(pidl), "pidl should not be empty.\n");
+    todo_wine ok(pidl->mkid.cb == 20, "get wrong value: %d\n", pidl->mkid.cb);
+    ILFree(pidl);
+
+    pidl = (void*)0xdeadbeef;
+    hr = pSHGetKnownFolderIDList(&FOLDERID_Documents, 0, NULL, &pidl);
+    ok(hr == S_OK, "SHGetKnownFolderIDList failed: 0x%08x\n", hr);
+    ok(!ILIsEmpty(pidl), "pidl should not be empty.\n");
+    ok(pidl->mkid.cb == 20, "get wrong value: %d\n", pidl->mkid.cb);
+    ILFree(pidl);
+
+    pidl = (void*)0xdeadbeef;
+    hr = pSHGetKnownFolderIDList(&FOLDERID_Documents, KF_FLAG_NO_ALIAS, NULL, &pidl);
+    ok(hr == S_OK, "SHGetKnownFolderIDList failed: 0x%08x\n", hr);
+    ok(!ILIsEmpty(pidl), "pidl should not be empty.\n");
+    ok(pidl->mkid.cb == 20, "get wrong value: %d\n", pidl->mkid.cb);
+    ILFree(pidl);
 }
 
 START_TEST(shellpath)
index 9db12ce..f0f51f5 100755 (executable)
@@ -1827,7 +1827,7 @@ static fileurl_tests_t fileurl_tests[]=
     {"file:///", "%%TMPDIR%%\\test file.shlexec", 0, 0},
 
     /* Test shortcuts vs. URLs */
-    {"file://///", "%s\\test_shortcut_shlexec.lnk", 0, 0x1d},
+    {"file://///", "%s\\test_shortcut_shlexec.lnk", 0, 0x1c},
 
     /* Confuse things by mixing protocols */
     {"file://", "shlproto://foo/bar", USE_COLON, 0},
@@ -1973,11 +1973,11 @@ static void test_urls(void)
     }
 
     /* A .lnk ending does not turn a URL into a shortcut */
-    todo_wait rc = shell_execute(NULL, "shlproto://foo/bar.lnk", NULL, NULL);
+    rc = shell_execute(NULL, "shlproto://foo/bar.lnk", NULL, NULL);
     ok(rc > 32, "%s failed: rc=%lu\n", shell_call, rc);
     okChildInt("argcA", 5);
-    todo_wine okChildString("argvA3", "URL");
-    todo_wine okChildString("argvA4", "shlproto://foo/bar.lnk");
+    okChildString("argvA3", "URL");
+    okChildString("argvA4", "shlproto://foo/bar.lnk");
 
     /* Neither does a .exe extension */
     rc = shell_execute(NULL, "shlproto://foo/bar.exe", NULL, NULL);
@@ -2180,13 +2180,13 @@ static void test_lnks(void)
         get_long_path_name(params, filename, sizeof(filename));
         okChildPath("argvA4", filename);
 
-        todo_wait rc=shell_execute_ex(SEE_MASK_NOZONECHECKS|SEE_MASK_DOENVSUBST, NULL, "%TMPDIR%\\test_shortcut_shlexec.lnk", NULL, NULL, NULL);
+        rc=shell_execute_ex(SEE_MASK_NOZONECHECKS|SEE_MASK_DOENVSUBST, NULL, "%TMPDIR%\\test_shortcut_shlexec.lnk", NULL, NULL, NULL);
         okShell(rc > 32, "failed: rc=%lu err=%u\n", rc, GetLastError());
         okChildInt("argcA", 5);
-        todo_wine okChildString("argvA3", "Open");
+        okChildString("argvA3", "Open");
         sprintf(params, "%s\\test file.shlexec", tmpdir);
         get_long_path_name(params, filename, sizeof(filename));
-        todo_wine okChildPath("argvA4", filename);
+        okChildPath("argvA4", filename);
     }
 
     /* Should just run our executable */
index 27a2a40..1e03978 100644 (file)
@@ -58,6 +58,8 @@ static void (WINAPI *pILFree)(LPITEMIDLIST);
 static BOOL (WINAPI *pILIsEqual)(LPCITEMIDLIST, LPCITEMIDLIST);
 static HRESULT (WINAPI *pSHCreateItemFromIDList)(PCIDLIST_ABSOLUTE pidl, REFIID riid, void **ppv);
 static HRESULT (WINAPI *pSHCreateItemFromParsingName)(PCWSTR,IBindCtx*,REFIID,void**);
+static HRESULT (WINAPI *pSHCreateItemFromRelativeName)(IShellItem*,PCWSTR,IBindCtx*,REFIID,void**);
+static HRESULT (WINAPI *pSHCreateItemInKnownFolder)(REFKNOWNFOLDERID,DWORD,PCWSTR,REFIID,void **);
 static HRESULT (WINAPI *pSHCreateShellItem)(LPCITEMIDLIST,IShellFolder*,LPCITEMIDLIST,IShellItem**);
 static HRESULT (WINAPI *pSHCreateShellItemArray)(LPCITEMIDLIST,IShellFolder*,UINT,LPCITEMIDLIST*,IShellItemArray**);
 static HRESULT (WINAPI *pSHCreateShellItemArrayFromIDLists)(UINT, PCIDLIST_ABSOLUTE*, IShellItemArray**);
@@ -66,6 +68,7 @@ static HRESULT (WINAPI *pSHCreateShellItemArrayFromShellItem)(IShellItem*, REFII
 static LPITEMIDLIST (WINAPI *pILCombine)(LPCITEMIDLIST,LPCITEMIDLIST);
 static HRESULT (WINAPI *pSHParseDisplayName)(LPCWSTR,IBindCtx*,LPITEMIDLIST*,SFGAOF,SFGAOF*);
 static LPITEMIDLIST (WINAPI *pSHSimpleIDListFromPathAW)(LPCVOID);
+static HRESULT (WINAPI *pSHGetKnownFolderPath)(REFKNOWNFOLDERID,DWORD,HANDLE,PWSTR*);
 static HRESULT (WINAPI *pSHGetNameFromIDList)(PCIDLIST_ABSOLUTE,SIGDN,PWSTR*);
 static HRESULT (WINAPI *pSHGetItemFromDataObject)(IDataObject*,DATAOBJ_GET_ITEM_FLAGS,REFIID,void**);
 static HRESULT (WINAPI *pSHGetIDListFromObject)(IUnknown*, PIDLIST_ABSOLUTE*);
@@ -115,6 +118,8 @@ static void init_function_pointers(void)
     MAKEFUNC(SHBindToParent);
     MAKEFUNC(SHCreateItemFromIDList);
     MAKEFUNC(SHCreateItemFromParsingName);
+    MAKEFUNC(SHCreateItemFromRelativeName);
+    MAKEFUNC(SHCreateItemInKnownFolder);
     MAKEFUNC(SHCreateShellItem);
     MAKEFUNC(SHCreateShellItemArray);
     MAKEFUNC(SHCreateShellItemArrayFromIDLists);
@@ -127,6 +132,7 @@ static void init_function_pointers(void)
     MAKEFUNC(SHGetSpecialFolderPathW);
     MAKEFUNC(SHGetSpecialFolderLocation);
     MAKEFUNC(SHParseDisplayName);
+    MAKEFUNC(SHGetKnownFolderPath);
     MAKEFUNC(SHGetNameFromIDList);
     MAKEFUNC(SHGetItemFromDataObject);
     MAKEFUNC(SHGetIDListFromObject);
@@ -2519,6 +2525,195 @@ static void test_SHCreateShellItem(void)
     else
         win_skip("No SHCreateItemFromIDList\n");
 
+    /* SHCreateItemFromRelativeName */
+    if(pSHCreateItemFromRelativeName && pSHGetKnownFolderPath)
+    {
+        IShellItem *shellitem_desktop = NULL;
+        WCHAR *desktop_path, *displayname;
+        WCHAR testfile_path[MAX_PATH] = {0};
+        HANDLE file;
+        LPITEMIDLIST pidl_desktop_testfile = NULL;
+        int order;
+
+        ret = pSHCreateShellItem(NULL, NULL, pidl_desktop, &shellitem_desktop);
+        ok(ret == S_OK, "SHCreateShellItem failed: 0x%08x.\n", ret);
+
+        shellitem = (void*)0xdeadbeef;
+        ret = pSHCreateItemFromRelativeName(shellitem_desktop, NULL, NULL, &IID_IShellItem,
+                                            (void**)&shellitem);
+        ok(ret == E_INVALIDARG, "Expected 0x%08x but SHCreateItemFromRelativeName return: 0x%08x.\n",
+           E_INVALIDARG, ret);
+        ok(shellitem == NULL, "shellitem was %p.\n", shellitem);
+
+        /* Test with a non-existent file */
+        shellitem = (void*)0xdeadbeef;
+        ret = pSHCreateItemFromRelativeName(shellitem_desktop, testfileW, NULL, &IID_IShellItem,
+                                            (void**)&shellitem);
+        ok(ret == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND),
+           "Expected 0x%08x but SHCreateItemFromRelativeName return: 0x%08x.\n",
+           HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), ret);
+        ok(shellitem == NULL, "shellitem was %p.\n", shellitem);
+
+        /* Create a file for testing in desktop folder */
+        pSHGetKnownFolderPath(&FOLDERID_Desktop, 0, NULL, &desktop_path);
+        lstrcatW(testfile_path, desktop_path);
+        myPathAddBackslashW(testfile_path);
+        lstrcatW(testfile_path, testfileW);
+        file = CreateFileW(testfile_path, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
+        ok(file != INVALID_HANDLE_VALUE, "CreateFileW failed! Last error: 0x%08x.\n", GetLastError());
+        CloseHandle(file);
+
+        shellitem = (void*)0xdeadbeef;
+        ret = pSHCreateItemFromRelativeName(shellitem_desktop, testfileW, NULL, &IID_IShellItem,
+                                            (void**)&shellitem);
+        ok(ret == S_OK, "SHCreateItemFromRelativeName failed: 0x%08x.\n", ret);
+        ok(shellitem != NULL, "shellitem was %p.\n", shellitem);
+        if(SUCCEEDED(ret))
+        {
+            ret = IShellItem_GetDisplayName(shellitem, 0, &displayname);
+            ok(ret == S_OK, "IShellItem_GetDisplayName failed: 0x%08x.\n", ret);
+            ok(!lstrcmpW(displayname, testfileW), "got wrong display name: %s.\n", wine_dbgstr_w(displayname));
+            CoTaskMemFree(displayname);
+
+            shellitem2 = (void*)0xdeadbeef;
+            ret = pSHCreateItemFromRelativeName(shellitem_desktop, testfileW, NULL, &IID_IShellItem,
+                                                (void**)&shellitem2);
+            ok(ret == S_OK, "SHCreateItemFromRelativeName failed: 0x%08x.\n", ret);
+            ret = IShellItem_Compare(shellitem, shellitem2, 0, &order);
+            ok(ret == S_OK, "IShellItem_Compare failed: 0x%08x.\n", ret);
+            ok(!order, "order got wrong value: %d.\n", order);
+            IShellItem_Release(shellitem2);
+
+            shellitem2 = (void*)0xdeadbeef;
+            ret = IShellFolder_ParseDisplayName(desktopfolder, NULL, NULL, testfileW, NULL,
+                                                &pidl_desktop_testfile, NULL);
+            ok(ret == S_OK, "ParseDisplayName failed 0x%08x.\n", ret);
+            ret = pSHCreateItemFromIDList(pidl_desktop_testfile, &IID_IShellItem, (void**)&shellitem2);
+            ret = IShellItem_Compare(shellitem, shellitem2, 0, &order);
+            ok(ret == S_OK, "IShellItem_Compare fail: 0x%08x.\n", ret);
+            ok(!order, "order got wrong value: %d.\n", order);
+            pILFree(pidl_desktop_testfile);
+            IShellItem_Release(shellitem2);
+
+            IShellItem_Release(shellitem);
+        }
+
+        DeleteFileW(testfile_path);
+        CoTaskMemFree(desktop_path);
+        IShellItem_Release(shellitem_desktop);
+    }
+    else
+        win_skip("No SHCreateItemFromRelativeName or SHGetKnownFolderPath\n");
+
+    /* SHCreateItemInKnownFolder */
+    if(pSHCreateItemInKnownFolder && pSHGetKnownFolderPath)
+    {
+        WCHAR *desktop_path;
+        WCHAR testfile_path[MAX_PATH] = {0};
+        HANDLE file;
+        WCHAR *displayname = NULL;
+        int order;
+        LPITEMIDLIST pidl_desktop_testfile = NULL;
+
+        shellitem = (void*)0xdeadbeef;
+        ret = pSHCreateItemInKnownFolder(&FOLDERID_Desktop, 0, NULL, &IID_IShellItem,
+                                         (void**)&shellitem);
+        ok(ret == S_OK, "SHCreateItemInKnownFolder failed: 0x%08x.\n", ret);
+        ok(shellitem != NULL, "shellitem was %p.\n", shellitem);
+        if(SUCCEEDED(ret))
+        {
+            shellitem2 = (void*)0xdeadbeef;
+            ret = pSHCreateShellItem(NULL, NULL, pidl_desktop, &shellitem2);
+            ok(SUCCEEDED(ret), "SHCreateShellItem returned %x\n", ret);
+            if(SUCCEEDED(ret))
+            {
+                ret = IShellItem_Compare(shellitem, shellitem2, 0, &order);
+                ok(ret == S_OK, "IShellItem_Compare failed: 0x%08x.\n", ret);
+                ok(!order, "order got wrong value: %d.\n", order);
+                IShellItem_Release(shellitem2);
+            }
+            IShellItem_Release(shellitem);
+        }
+
+        /* Test with a non-existent file */
+        shellitem = (void*)0xdeadbeef;
+        ret = pSHCreateItemInKnownFolder(&FOLDERID_Desktop, 0, testfileW, &IID_IShellItem,
+                                         (void**)&shellitem);
+        ok(ret == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND),
+           "Expected 0x%08x but SHCreateItemInKnownFolder return: 0x%08x.\n",
+           HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), ret);
+        ok(shellitem == NULL, "shellitem was %p.\n", shellitem);
+
+        pSHGetKnownFolderPath(&FOLDERID_Desktop, 0, NULL, &desktop_path);
+        lstrcatW(testfile_path, desktop_path);
+        myPathAddBackslashW(testfile_path);
+        lstrcatW(testfile_path, testfileW);
+        file = CreateFileW(testfile_path, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
+        ok(file != INVALID_HANDLE_VALUE, "CreateFileW failed! Last error: 0x%08x.\n", GetLastError());
+        CloseHandle(file);
+
+        shellitem = (void*)0xdeadbeef;
+        ret = pSHCreateItemInKnownFolder(&FOLDERID_Desktop, 0, testfileW, &IID_IShellItem,
+                                         (void**)&shellitem);
+        ok(ret == S_OK, "SHCreateItemInKnownFolder failed: 0x%08x.\n", ret);
+        ok(shellitem != NULL, "shellitem was %p.\n", shellitem);
+        if(SUCCEEDED(ret))
+        {
+            ret = IShellItem_GetDisplayName(shellitem, 0, &displayname);
+            ok(ret == S_OK, "IShellItem_GetDisplayName failed: 0x%08x.\n", ret);
+            ok(!lstrcmpW(displayname, testfileW), "got wrong display name: %s.\n",
+               wine_dbgstr_w(displayname));
+            CoTaskMemFree(displayname);
+
+            shellitem2 = (void*)0xdeadbeef;
+            ret = pSHCreateItemInKnownFolder(&FOLDERID_Desktop, 0, testfileW, &IID_IShellItem,
+                                             (void**)&shellitem2);
+            ok(ret == S_OK, "SHCreateItemInKnownFolder failed: 0x%08x.\n", ret);
+            ok(shellitem2 != NULL, "shellitem was %p.\n", shellitem);
+            ret = IShellItem_Compare(shellitem, shellitem2, 0, &order);
+            ok(ret == S_OK, "IShellItem_Compare failed: 0x%08x.\n", ret);
+            ok(!order, "order got wrong value: %d.\n", order);
+            IShellItem_Release(shellitem2);
+
+            shellitem2 = (void*)0xdeadbeef;
+            ret = IShellFolder_ParseDisplayName(desktopfolder, NULL, NULL, testfileW, NULL,
+                                                &pidl_desktop_testfile, NULL);
+            ok(SUCCEEDED(ret), "ParseDisplayName returned %x.\n", ret);
+            ret = pSHCreateItemFromIDList(pidl_desktop_testfile, &IID_IShellItem, (void**)&shellitem2);
+            ret = IShellItem_Compare(shellitem, shellitem2, 0, &order);
+            ok(ret == S_OK, "IShellItem_Compare failed: 0x%08x.\n", ret);
+            ok(!order, "order got wrong value: %d.\n", order);
+            pILFree(pidl_desktop_testfile);
+            IShellItem_Release(shellitem2);
+
+            IShellItem_Release(shellitem);
+        }
+
+        shellitem = (void*)0xdeadbeef;
+        ret = pSHCreateItemInKnownFolder(&FOLDERID_Documents, 0, NULL, &IID_IShellItem,
+                                         (void**)&shellitem);
+        ok(ret == S_OK, "SHCreateItemInKnownFolder failed: 0x%08x.\n", ret);
+        ok(shellitem != NULL, "shellitem was %p.\n", shellitem);
+        if(SUCCEEDED(ret))
+        {
+            shellitem2 = (void*)0xdeadbeef;
+            ret = pSHCreateItemInKnownFolder(&FOLDERID_Documents, 0, NULL, &IID_IShellItem,
+                                             (void**)&shellitem2);
+            ok(ret == S_OK, "SHCreateItemInKnownFolder failed: 0x%08x.\n", ret);
+            ok(shellitem2 != NULL, "shellitem was %p.\n", shellitem);
+            ret = IShellItem_Compare(shellitem, shellitem2, 0, &order);
+            ok(ret == S_OK, "IShellItem_Compare failed: 0x%08x.\n", ret);
+            ok(!order, "order got wrong value: %d.\n", order);
+            IShellItem_Release(shellitem2);
+
+            IShellItem_Release(shellitem);
+        }
+        DeleteFileW(testfile_path);
+        CoTaskMemFree(desktop_path);
+    }
+    else
+        win_skip("No SHCreateItemInKnownFolder or SHGetKnownFolderPath\n");
+
     DeleteFileA(".\\testfile");
     pILFree(pidl_abstestfile);
     pILFree(pidl_testfile);