Skip to content

Commit 654c59a

Browse files
authored
[SHELL32_APITEST] Basic ILIsEqual tests (reactos#7438)
1 parent 439e67d commit 654c59a

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

modules/rostests/apitests/shell32/ItemIDList.cpp

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
#include "shelltest.h"
1010
#include <shellutils.h>
1111

12-
enum { DIRBIT = 1, FILEBIT = 2 };
12+
enum {
13+
DIRBIT = 1, FILEBIT = 2,
14+
PT_COMPUTER_REGITEM = 0x2E,
15+
};
1316

1417
static BYTE GetPIDLType(LPCITEMIDLIST pidl)
1518
{
@@ -202,3 +205,58 @@ START_TEST(PIDL)
202205
skip("?\n");
203206
ILFree(pidl);
204207
}
208+
209+
START_TEST(ILIsEqual)
210+
{
211+
LPITEMIDLIST p1, p2, pidl;
212+
213+
p1 = p2 = NULL;
214+
ok_int(ILIsEqual(p1, p2), TRUE);
215+
216+
ITEMIDLIST emptyitem = {}, emptyitem2 = {};
217+
ok_int(ILIsEqual(&emptyitem, &emptyitem2), TRUE);
218+
219+
ok_int(ILIsEqual(NULL, &emptyitem), FALSE); // These two are not equal for some reason
220+
221+
p1 = SHCloneSpecialIDList(NULL, CSIDL_DRIVES, FALSE);
222+
p2 = SHCloneSpecialIDList(NULL, CSIDL_DRIVES, FALSE);
223+
if (p1 && p2)
224+
{
225+
ok_int(ILIsEqual(p1, p2), TRUE);
226+
p1->mkid.abID[0] = PT_COMPUTER_REGITEM; // RegItem in wrong parent
227+
ok_int(ILIsEqual(p1, p2), FALSE);
228+
}
229+
else
230+
{
231+
skip("Unable to initialize test\n");
232+
}
233+
ILFree(p1);
234+
ILFree(p2);
235+
236+
// ILIsParent must compare like ILIsEqual
237+
p1 = SHSimpleIDListFromPath(L"c:\\");
238+
p2 = SHSimpleIDListFromPath(L"c:\\dir\\file");
239+
if (p1 && p2)
240+
{
241+
ok_int(ILIsParent(NULL, p1, FALSE), FALSE); // NULL is always false
242+
ok_int(ILIsParent(p1, NULL, FALSE), FALSE); // NULL is always false
243+
ok_int(ILIsParent(NULL, NULL, FALSE), FALSE); // NULL is always false
244+
ok_int(ILIsParent(p1, p1, FALSE), TRUE); // I'm my own parent
245+
ok_int(ILIsParent(p1, p1, TRUE), FALSE); // Self is not immediate
246+
ok_int(ILIsParent(p1, p2, FALSE), TRUE); // Grandchild
247+
ok_int(ILIsParent(p1, p2, TRUE), FALSE); // Grandchild is not immediate
248+
ok_ptr(ILFindChild(p1, p2), ILGetNext(ILGetNext(p2))); // Child is "dir\\file", skip MyComputer and C:
249+
ok_int(ILIsEmpty(pidl = ILFindChild(p1, p1)) && pidl, TRUE); // Self
250+
ILRemoveLastID(p2);
251+
ok_int(ILIsParent(p1, p2, TRUE), TRUE); // Immediate child
252+
253+
p1->mkid.abID[0] = PT_COMPUTER_REGITEM; // RegItem in wrong parent
254+
ok_int(ILIsParent(p1, p2, FALSE), FALSE);
255+
}
256+
else
257+
{
258+
skip("Unable to initialize test\n");
259+
}
260+
ILFree(p1);
261+
ILFree(p2);
262+
}

modules/rostests/apitests/shell32/testlist.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ extern void func_FindExecutable(void);
1919
extern void func_GetDisplayNameOf(void);
2020
extern void func_GUIDFromString(void);
2121
extern void func_ILCreateFromPath(void);
22+
extern void func_ILIsEqual(void);
2223
extern void func_Int64ToString(void);
2324
extern void func_IShellFolderViewCB(void);
2425
extern void func_menu(void);
@@ -63,6 +64,7 @@ const struct test winetest_testlist[] =
6364
{ "GetDisplayNameOf", func_GetDisplayNameOf },
6465
{ "GUIDFromString", func_GUIDFromString },
6566
{ "ILCreateFromPath", func_ILCreateFromPath },
67+
{ "ILIsEqual", func_ILIsEqual },
6668
{ "Int64ToString", func_Int64ToString },
6769
{ "IShellFolderViewCB", func_IShellFolderViewCB },
6870
{ "menu", func_menu },

0 commit comments

Comments
 (0)