diff --git a/modules/rostests/apitests/shell32/CMakeLists.txt b/modules/rostests/apitests/shell32/CMakeLists.txt index acd85a23c3f..5bc791189ca 100644 --- a/modules/rostests/apitests/shell32/CMakeLists.txt +++ b/modules/rostests/apitests/shell32/CMakeLists.txt @@ -32,6 +32,7 @@ list(APPEND SOURCE SHCreateFileExtractIconW.cpp SHParseDisplayName.cpp SHRestricted.cpp + SHSimpleIDListFromPath.cpp She.cpp ShellExecCmdLine.cpp ShellExecuteEx.cpp diff --git a/modules/rostests/apitests/shell32/SHSimpleIDListFromPath.cpp b/modules/rostests/apitests/shell32/SHSimpleIDListFromPath.cpp new file mode 100644 index 00000000000..c43a06a0a6f --- /dev/null +++ b/modules/rostests/apitests/shell32/SHSimpleIDListFromPath.cpp @@ -0,0 +1,48 @@ +/* + * PROJECT: ReactOS API tests + * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) + * PURPOSE: Test for SHSimpleIDListFromPath + * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com) + */ + +#include "shelltest.h" +#include + +START_TEST(SHSimpleIDListFromPath) +{ + HRESULT hr; + WCHAR szPath[MAX_PATH]; + GetWindowsDirectoryW(szPath, _countof(szPath)); + + LPITEMIDLIST pidl1 = SHSimpleIDListFromPath(szPath); + LPITEMIDLIST pidl2 = ILCreateFromPathW(szPath); + LPITEMIDLIST pidl1Last = ILFindLastID(pidl1); + LPITEMIDLIST pidl2Last = ILFindLastID(pidl2); + ok_int(ILIsEqual(pidl1, pidl2), TRUE); + ok_int(ILIsEqual(pidl1Last, pidl2Last), TRUE); + + IShellFolder *psf1 = NULL; + IShellFolder *psf2 = NULL; + hr = SHBindToParent(pidl1, IID_PPV_ARG(IShellFolder, &psf1), NULL); + ok_long(hr, S_OK); + hr = SHBindToParent(pidl2, IID_PPV_ARG(IShellFolder, &psf2), NULL); + ok_long(hr, S_OK); + + DWORD attrs1 = SFGAO_FOLDER; + DWORD attrs2 = SFGAO_FOLDER; + + hr = (psf1 ? psf1->GetAttributesOf(1, &pidl1Last, &attrs1) : E_UNEXPECTED); + ok_long(hr, S_OK); + hr = (psf2 ? psf2->GetAttributesOf(1, &pidl2Last, &attrs2) : E_UNEXPECTED); + ok_long(hr, S_OK); + + ok_long((attrs1 & SFGAO_FOLDER), 0); + ok_long((attrs2 & SFGAO_FOLDER), SFGAO_FOLDER); + + ILFree(pidl1); + ILFree(pidl2); + if (psf1) + psf1->Release(); + if (psf2) + psf2->Release(); +} diff --git a/modules/rostests/apitests/shell32/testlist.c b/modules/rostests/apitests/shell32/testlist.c index 7e42b733569..bf977bac3ed 100644 --- a/modules/rostests/apitests/shell32/testlist.c +++ b/modules/rostests/apitests/shell32/testlist.c @@ -40,6 +40,7 @@ extern void func_ShellState(void); extern void func_SHGetAttributesFromDataObject(void); extern void func_SHLimitInputEdit(void); extern void func_SHParseDisplayName(void); +extern void func_SHSimpleIDListFromPath(void); extern void func_SHRestricted(void); const struct test winetest_testlist[] = @@ -81,6 +82,7 @@ const struct test winetest_testlist[] = { "SHGetAttributesFromDataObject", func_SHGetAttributesFromDataObject }, { "SHLimitInputEdit", func_SHLimitInputEdit }, { "SHParseDisplayName", func_SHParseDisplayName }, + { "SHSimpleIDListFromPath", func_SHSimpleIDListFromPath }, { "SHRestricted", func_SHRestricted }, { 0, 0 }