Signed-off-by: Andrew Eikum aeikum@codeweavers.com --- dlls/shell32/tests/shellpath.c | 64 ++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-)
diff --git a/dlls/shell32/tests/shellpath.c b/dlls/shell32/tests/shellpath.c index 4c9b9693983..504812bad5d 100644 --- a/dlls/shell32/tests/shellpath.c +++ b/dlls/shell32/tests/shellpath.c @@ -291,6 +291,18 @@ static const char *getFolderName(int folder) } }
+LPWSTR wcscasestr( LPCWSTR str, LPCWSTR sub ) +{ + while (*str) + { + const WCHAR *p1 = str, *p2 = sub; + while (*p1 && *p2 && towlower(*p1) == towlower(*p2)) { p1++; p2++; } + if (!*p2) return (WCHAR *)str; + str++; + } + return NULL; +} + /* Standard CSIDL values (and their flags) uses only two less-significant bytes */ #define NO_CSIDL 0x10000 #define WINE_ATTRIBUTES_OPTIONAL 0x20000 @@ -1964,10 +1976,11 @@ static void check_known_folder(IKnownFolderManager *mgr, KNOWNFOLDERID *folderId HRESULT hr; int csidl, expectedCsidl, ret; KNOWNFOLDER_DEFINITION kfd; - IKnownFolder *folder; + IKnownFolder *folder, *kf_parent; WCHAR sName[1024]; BOOL found = FALSE; unsigned int i; + WCHAR *ikf_path, *gkfp_path, *ikf_parent_path;
for (i = 0; i < ARRAY_SIZE(known_folders); ++i) { @@ -2019,10 +2032,57 @@ static void check_known_folder(IKnownFolderManager *mgr, KNOWNFOLDERID *folderId
ok_(__FILE__, known_folder->line)(!(kfd.kfdFlags & (~known_folder->definitionFlags)), "invalid known folder flags for %s: 0x%08x expected, but 0x%08x retrieved\n", known_folder->sFolderId, known_folder->definitionFlags, kfd.kfdFlags);
+ gkfp_path = NULL; + hr = pSHGetKnownFolderPath(folderId, KF_FLAG_DEFAULT, NULL, &gkfp_path); + if(SUCCEEDED(hr)) + { + ikf_path = NULL; + hr = IKnownFolder_GetPath(folder, KF_FLAG_DEFAULT, &ikf_path); + ok_(__FILE__, known_folder->line)(hr == S_OK, "IKnownFolder::GetPath failed: 0x%08x\n", hr); + ok_(__FILE__, known_folder->line)(ikf_path != NULL, "SHGetKnownFolderPath gave NULL path\n"); + + /* IKnownFolder::GetPath and SHGetKnownFolderPath should be the same */ + ok_(__FILE__, known_folder->line)(lstrcmpW(gkfp_path, ikf_path) == 0, "Got different paths: %s vs %s\n", + debugstr_w(gkfp_path), debugstr_w(ikf_path)); + + if(kfd.pszRelativePath) + { + /* RelativePath should be a substring of the path */ + ok_(__FILE__, known_folder->line)(wcscasestr(ikf_path, kfd.pszRelativePath) != NULL, + "KNOWNFOLDER_DEFINITION.pszRelativePath %s is not a substring of full path %s\n", + debugstr_w(kfd.pszRelativePath), debugstr_w(ikf_path)); + + hr = IKnownFolderManager_GetFolder(mgr, &kfd.fidParent, &kf_parent); + ok_(__FILE__, known_folder->line)(hr == S_OK, "IKnownFolderManager::GetFolder(parent) failed: 0x%08x\n", hr); + + if(SUCCEEDED(hr)) + { + ikf_parent_path = NULL; + hr = IKnownFolder_GetPath(kf_parent, KF_FLAG_DEFAULT, &ikf_parent_path); + ok_(__FILE__, known_folder->line)(hr == S_OK, "IKnownFolder::GetPath(parent) failed: 0x%08x\n", hr); + + /* Parent path + pszRelativePath should give the full path */ + ok_(__FILE__, known_folder->line)(memcmp(ikf_parent_path, ikf_path, lstrlenW(ikf_parent_path) * sizeof(WCHAR)) == 0, + "Full path %s does not start with parent path %s\n", + debugstr_w(ikf_path), debugstr_w(ikf_parent_path)); + ok_(__FILE__, known_folder->line)(*(ikf_path + lstrlenW(ikf_parent_path)) == '\', + "Missing slash\n"); + ok_(__FILE__, known_folder->line)(wcsicmp(kfd.pszRelativePath, ikf_path + lstrlenW(ikf_parent_path) + 1) == 0, + "Full path %s does not end with relative path %s\n", + debugstr_w(ikf_path), debugstr_w(kfd.pszRelativePath)); + + CoTaskMemFree(ikf_parent_path); + IKnownFolder_Release(kf_parent); + } + } + + CoTaskMemFree(ikf_path); + CoTaskMemFree(gkfp_path); + } FreeKnownFolderDefinitionFields(&kfd); }
- IKnownFolder_Release(folder); + IKnownFolder_Release(folder); }
break;
Hi,
On Thu, 27 May 2021, Andrew Eikum wrote: [...]
ok_(__FILE__, known_folder->line)(wcsicmp(kfd.pszRelativePath, ikf_path + lstrlenW(ikf_parent_path) + 1) == 0,
"Full path %s does not end with relative path %s\n",
debugstr_w(ikf_path), debugstr_w(kfd.pszRelativePath));
This check introduced a failure on Windows 8.1 for the cw-rx460 and cw-gtx560 machines:
https://test.winehq.org/data/patterns.html#shell32:shellpath
shellpath.c:380: Test failed: Full path L"C:\Users\winetest\AppData\Local\Microsoft\Windows\Burn\Burn1" does not end with relative path L"Microsoft\Windows\Burn\Burn"
Note that, as far as I know, neither has a CD/DVD writer.
On Fri, 4 Jun 2021, Francois Gouget wrote:
Hi,
On Thu, 27 May 2021, Andrew Eikum wrote: [...]
ok_(__FILE__, known_folder->line)(wcsicmp(kfd.pszRelativePath, ikf_path + lstrlenW(ikf_parent_path) + 1) == 0,
"Full path %s does not end with relative path %s\n",
debugstr_w(ikf_path), debugstr_w(kfd.pszRelativePath));
This check introduced a failure on Windows 8.1 for the cw-rx460 and cw-gtx560 machines:
https://test.winehq.org/data/patterns.html#shell32:shellpath
shellpath.c:380: Test failed: Full path L"C:\Users\winetest\AppData\Local\Microsoft\Windows\Burn\Burn1" does not end with relative path L"Microsoft\Windows\Burn\Burn"
Note that, as far as I know, neither has a CD/DVD writer.
I have dug some more and these did have two CD driver at some point... sort of:
https://bugs.winehq.org/show_bug.cgi?id=51284