https://git.reactos.org/?p=reactos.git;a=commitdiff;h=654c59a5f82298815b7261e6c4fdea8b79b3f988
commit 654c59a5f82298815b7261e6c4fdea8b79b3f988 Author: Whindmar Saksit <whinds...@proton.me> AuthorDate: Sun Oct 13 17:46:06 2024 +0200 Commit: GitHub <nore...@github.com> CommitDate: Sun Oct 13 17:46:06 2024 +0200 [SHELL32_APITEST] Basic ILIsEqual tests (#7438) --- modules/rostests/apitests/shell32/ItemIDList.cpp | 60 +++++++++++++++++++++++- modules/rostests/apitests/shell32/testlist.c | 2 + 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/modules/rostests/apitests/shell32/ItemIDList.cpp b/modules/rostests/apitests/shell32/ItemIDList.cpp index 08214efb876..9665dede641 100644 --- a/modules/rostests/apitests/shell32/ItemIDList.cpp +++ b/modules/rostests/apitests/shell32/ItemIDList.cpp @@ -9,7 +9,10 @@ #include "shelltest.h" #include <shellutils.h> -enum { DIRBIT = 1, FILEBIT = 2 }; +enum { + DIRBIT = 1, FILEBIT = 2, + PT_COMPUTER_REGITEM = 0x2E, +}; static BYTE GetPIDLType(LPCITEMIDLIST pidl) { @@ -202,3 +205,58 @@ START_TEST(PIDL) skip("?\n"); ILFree(pidl); } + +START_TEST(ILIsEqual) +{ + LPITEMIDLIST p1, p2, pidl; + + p1 = p2 = NULL; + ok_int(ILIsEqual(p1, p2), TRUE); + + ITEMIDLIST emptyitem = {}, emptyitem2 = {}; + ok_int(ILIsEqual(&emptyitem, &emptyitem2), TRUE); + + ok_int(ILIsEqual(NULL, &emptyitem), FALSE); // These two are not equal for some reason + + p1 = SHCloneSpecialIDList(NULL, CSIDL_DRIVES, FALSE); + p2 = SHCloneSpecialIDList(NULL, CSIDL_DRIVES, FALSE); + if (p1 && p2) + { + ok_int(ILIsEqual(p1, p2), TRUE); + p1->mkid.abID[0] = PT_COMPUTER_REGITEM; // RegItem in wrong parent + ok_int(ILIsEqual(p1, p2), FALSE); + } + else + { + skip("Unable to initialize test\n"); + } + ILFree(p1); + ILFree(p2); + + // ILIsParent must compare like ILIsEqual + p1 = SHSimpleIDListFromPath(L"c:\\"); + p2 = SHSimpleIDListFromPath(L"c:\\dir\\file"); + if (p1 && p2) + { + ok_int(ILIsParent(NULL, p1, FALSE), FALSE); // NULL is always false + ok_int(ILIsParent(p1, NULL, FALSE), FALSE); // NULL is always false + ok_int(ILIsParent(NULL, NULL, FALSE), FALSE); // NULL is always false + ok_int(ILIsParent(p1, p1, FALSE), TRUE); // I'm my own parent + ok_int(ILIsParent(p1, p1, TRUE), FALSE); // Self is not immediate + ok_int(ILIsParent(p1, p2, FALSE), TRUE); // Grandchild + ok_int(ILIsParent(p1, p2, TRUE), FALSE); // Grandchild is not immediate + ok_ptr(ILFindChild(p1, p2), ILGetNext(ILGetNext(p2))); // Child is "dir\\file", skip MyComputer and C: + ok_int(ILIsEmpty(pidl = ILFindChild(p1, p1)) && pidl, TRUE); // Self + ILRemoveLastID(p2); + ok_int(ILIsParent(p1, p2, TRUE), TRUE); // Immediate child + + p1->mkid.abID[0] = PT_COMPUTER_REGITEM; // RegItem in wrong parent + ok_int(ILIsParent(p1, p2, FALSE), FALSE); + } + else + { + skip("Unable to initialize test\n"); + } + ILFree(p1); + ILFree(p2); +} diff --git a/modules/rostests/apitests/shell32/testlist.c b/modules/rostests/apitests/shell32/testlist.c index 9f4fbf34e9e..4b16a6dd4d5 100644 --- a/modules/rostests/apitests/shell32/testlist.c +++ b/modules/rostests/apitests/shell32/testlist.c @@ -19,6 +19,7 @@ extern void func_FindExecutable(void); extern void func_GetDisplayNameOf(void); extern void func_GUIDFromString(void); extern void func_ILCreateFromPath(void); +extern void func_ILIsEqual(void); extern void func_Int64ToString(void); extern void func_IShellFolderViewCB(void); extern void func_menu(void); @@ -63,6 +64,7 @@ const struct test winetest_testlist[] = { "GetDisplayNameOf", func_GetDisplayNameOf }, { "GUIDFromString", func_GUIDFromString }, { "ILCreateFromPath", func_ILCreateFromPath }, + { "ILIsEqual", func_ILIsEqual }, { "Int64ToString", func_Int64ToString }, { "IShellFolderViewCB", func_IShellFolderViewCB }, { "menu", func_menu },