2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Test for SHExplorerParseCmdLine
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org
14 #define UNKNOWN_SIZE 0x100
16 typedef struct _EXPLORER_INFO
19 PIDLIST_ABSOLUTE pidl
;
20 DWORD dwFlags
; /* TODO: make some constants */
21 ULONG Unknown
[UNKNOWN_SIZE
]; /* TODO: find out more */
22 } EXPLORER_INFO
, *PEXPLORER_INFO
;
26 SHExplorerParseCmdLine(
27 _Out_ PEXPLORER_INFO Info
);
29 #define PIDL_IS_UNTOUCHED -1
30 #define PIDL_IS_NULL -2
31 #define PIDL_IS_PATH -3
33 #define InvalidPointer ((PVOID)0x5555555555555555ULL)
39 _In_ INT ExpectedCsidl
,
40 _In_ DWORD ExpectedFlags
,
41 _In_ PCWSTR ExpectedFileName
,
48 FillMemory(&Info
, sizeof(Info
), 0x55);
49 Info
.dwFlags
= 0x00000000;
50 Ret
= SHExplorerParseCmdLine(&Info
);
52 if (ExpectedRet
== -1)
53 ok(Ret
== Info
.pidl
, "Ret = %p, expected %p\n", Ret
, Info
.pidl
);
55 ok(Ret
== (PVOID
)ExpectedRet
, "Ret = %p, expected %p\n", Ret
, (PVOID
)ExpectedRet
);
57 if (ExpectedFileName
== NULL
)
58 ok(Info
.FileName
== InvalidPointer
, "FileName = %p\n", Info
.FileName
);
61 ok(Info
.FileName
!= NULL
&& Info
.FileName
!= InvalidPointer
, "FileName = %p\n", Info
.FileName
);
62 if (Info
.FileName
!= NULL
&& Info
.FileName
!= InvalidPointer
)
64 ok(!wcscmp(Info
.FileName
, ExpectedFileName
), "FileName = %ls, expected %ls\n", Info
.FileName
, ExpectedFileName
);
65 LocalFree(Info
.FileName
);
69 if (ExpectedCsidl
== PIDL_IS_UNTOUCHED
)
70 ok(Info
.pidl
== InvalidPointer
, "pidl = %p\n", Info
.pidl
);
71 else if (ExpectedCsidl
== PIDL_IS_NULL
)
72 ok(Info
.pidl
== NULL
, "pidl = %p\n", Info
.pidl
);
75 PIDLIST_ABSOLUTE ExpectedPidl
;
78 ok(Info
.pidl
!= NULL
, "pidl = %p\n", Info
.pidl
);
79 if (Info
.pidl
!= NULL
&& Info
.pidl
!= InvalidPointer
)
81 if (ExpectedCsidl
== PIDL_IS_PATH
)
83 ExpectedPidl
= SHSimpleIDListFromPath(PidlPath
);
84 hr
= ExpectedPidl
== NULL
? E_FAIL
: S_OK
;
85 ok(ExpectedPidl
!= NULL
, "SHSimpleIDListFromPath failed\n");
89 hr
= SHGetFolderLocation(NULL
, ExpectedCsidl
, NULL
, 0, &ExpectedPidl
);
90 ok(hr
== S_OK
, "SHGetFolderLocation returned %08lx\n", hr
);
94 ok(ILIsEqual(Info
.pidl
, ExpectedPidl
), "Unexpected pidl value\n");
101 ok(Info
.dwFlags
== ExpectedFlags
, "dwFlags = %08lx, expected %08lx\n", Info
.dwFlags
, ExpectedFlags
);
102 for (i
= 0; i
< sizeof(Info
.Unknown
) / sizeof(Info
.Unknown
[0]); i
++)
103 ok(Info
.Unknown
[i
] == 0x55555555, "Unknown[%lu] = %08lx\n", i
, Info
.Unknown
[i
]);
106 START_TEST(SHExplorerParseCmdLine
)
114 PCWSTR ExpectedFileName
;
118 { L
"", -1, CSIDL_MYDOCUMENTS
, 0x00000009 },
119 { L
"/e", TRUE
, PIDL_IS_UNTOUCHED
, 0x00000008 },
120 { L
"/n", TRUE
, PIDL_IS_UNTOUCHED
, 0x00004001 },
121 { L
"/x", TRUE
, PIDL_IS_NULL
, 0x02000000, L
"/x" },
122 { L
"-e", TRUE
, PIDL_IS_NULL
, 0x02000000, L
"-e" },
123 { L
"C:\\", TRUE
, PIDL_IS_PATH
, 0x00000200, NULL
, L
"C:\\" },
124 { L
"/e,C:\\", TRUE
, PIDL_IS_PATH
, 0x00000208, NULL
, L
"C:\\" },
125 { L
"/select,C:\\", TRUE
, PIDL_IS_PATH
, 0x00000240, NULL
, L
"C:\\" },
126 { L
"/e,::{20d04fe0-3aea-1069-a2d8-08002b30309d}", TRUE
, PIDL_IS_PATH
, 0x00000208, NULL
, L
"::{20d04fe0-3aea-1069-a2d8-08002b30309d}" },
127 { L
"::{645ff040-5081-101b-9f08-00aa002f954e}", TRUE
, PIDL_IS_PATH
, 0x00000200, NULL
, L
"::{645ff040-5081-101b-9f08-00aa002f954e}" },
128 { L
"/select,::{450d8fba-ad25-11d0-98a8-0800361b1103}", TRUE
, PIDL_IS_PATH
, 0x00000240, NULL
, L
"::{450d8fba-ad25-11d0-98a8-0800361b1103}" },
129 { L
"=", TRUE
, PIDL_IS_PATH
, 0x00000200, NULL
, L
"::{20d04fe0-3aea-1069-a2d8-08002b30309d}" },
130 /* TODO: needs a lot more testcases */
132 const int TestCount
= sizeof(Tests
) / sizeof(Tests
[0]);
134 WCHAR OriginalCommandLine
[1024];
137 CommandLine
= GetCommandLineW();
138 StringCbCopyW(OriginalCommandLine
, sizeof(OriginalCommandLine
), CommandLine
);
140 for (i
= 0; i
< TestCount
; i
++)
142 wcscpy(CommandLine
, L
"browseui_apitest.exe ");
143 wcscat(CommandLine
, Tests
[i
].CommandLine
);
144 trace("Command line: %ls\n", CommandLine
);
145 TestCommandLine(Tests
[i
].ExpectedRet
,
146 Tests
[i
].ExpectedCsidl
,
147 Tests
[i
].ExpectedFlags
,
148 Tests
[i
].ExpectedFileName
,
152 wcscpy(CommandLine
, OriginalCommandLine
);