[BROWSEUI_APITEST]
[reactos.git] / rostests / apitests / browseui / SHExplorerParseCmdLine.c
1 /*
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
6 */
7
8 #include <apitest.h>
9
10 //#define UNICODE
11 #include <strsafe.h>
12 #include <shlobj.h>
13
14 #define PADDING_SIZE 0x100
15
16 typedef struct _EXPLORER_INFO
17 {
18 PWSTR FileName;
19 PIDLIST_ABSOLUTE pidl;
20 DWORD dwFlags;
21 ULONG Unknown1[5];
22 PIDLIST_ABSOLUTE pidlRoot;
23 ULONG Unknown3[4];
24 GUID guidInproc;
25 ULONG Padding[PADDING_SIZE];
26 } EXPLORER_INFO, *PEXPLORER_INFO;
27
28 UINT
29 WINAPI
30 SHExplorerParseCmdLine(
31 _Out_ PEXPLORER_INFO Info);
32
33 #define PIDL_IS_UNTOUCHED -1
34 #define PIDL_IS_NULL -2
35 #define PIDL_IS_PATH -3
36 #define PIDL_IS_EMPTY -4
37 #define PIDL_PATH_EQUALS_PATH -5
38
39 #define InvalidPointer ((PVOID)0x5555555555555555ULL)
40
41 static
42 VOID
43 TestCommandLine(
44 _In_ INT ExpectedRet,
45 _In_ INT ExpectedCsidl,
46 _In_ DWORD ExpectedFlags,
47 _In_ PCWSTR ExpectedFileName,
48 _In_ PCWSTR PidlPath,
49 _Out_opt_ PUINT PWriteEnd)
50 {
51 EXPLORER_INFO Info;
52 UINT Ret;
53 ULONG i;
54 PDWORD InfoWords = (PDWORD) &Info;
55
56 FillMemory(&Info, sizeof(Info), 0x55);
57 Info.dwFlags = 0x00000000;
58 Ret = SHExplorerParseCmdLine(&Info);
59
60 // Special case for empty cmdline: Ret is the PIDL for the selected folder.
61 if (ExpectedRet == -1)
62 ok((LPITEMIDLIST) Ret == Info.pidl, "Ret = %x, expected %p\n", Ret, Info.pidl);
63 else
64 ok(Ret == ExpectedRet, "Ret = %x, expected %p\n", Ret, (PVOID) ExpectedRet);
65
66 if (ExpectedFileName == NULL)
67 ok(Info.FileName == InvalidPointer, "FileName = %p\n", Info.FileName);
68 else
69 {
70 ok(Info.FileName != NULL && Info.FileName != InvalidPointer, "FileName = %p\n", Info.FileName);
71 if (Info.FileName != NULL && Info.FileName != InvalidPointer)
72 {
73 ok(!wcscmp(Info.FileName, ExpectedFileName), "FileName = %ls, expected %ls\n", Info.FileName, ExpectedFileName);
74 LocalFree(Info.FileName);
75 }
76 }
77
78 if (ExpectedCsidl == PIDL_IS_UNTOUCHED)
79 ok(Info.pidl == InvalidPointer, "pidl = %p\n", Info.pidl);
80 else if (ExpectedCsidl == PIDL_IS_NULL)
81 ok(Info.pidl == NULL, "pidl = %p\n", Info.pidl);
82 else
83 {
84 PIDLIST_ABSOLUTE ExpectedPidl;
85 HRESULT hr;
86
87 ok(Info.pidl != NULL, "pidl = %p\n", Info.pidl);
88 if (Info.pidl != NULL && Info.pidl != InvalidPointer)
89 {
90 WCHAR pidlPathName[MAX_PATH] = L"";
91
92 if (Info.pidl != NULL && Info.pidl != (LPITEMIDLIST) 0x55555555)
93 {
94 SHGetPathFromIDListW(Info.pidl, pidlPathName);
95 }
96
97 if (ExpectedCsidl == PIDL_PATH_EQUALS_PATH)
98 {
99 ok(wcsicmp(pidlPathName, PidlPath) == 0, "Path from pidl does not match; pidlPathName=%S\n", pidlPathName);
100 }
101 else if (ExpectedCsidl == PIDL_IS_EMPTY)
102 {
103 ok(wcslen(pidlPathName) == 0, "Unexpected non-empty path from pidl; pidlPathName=%S\n", pidlPathName);
104 }
105 else
106 {
107 if (ExpectedCsidl == PIDL_IS_PATH)
108 {
109 ExpectedPidl = SHSimpleIDListFromPath(PidlPath);
110 hr = ExpectedPidl == NULL ? E_FAIL : S_OK;
111 ok(ExpectedPidl != NULL, "SHSimpleIDListFromPath(%S) failed. pidlPathName=%S\n", PidlPath, pidlPathName);
112 if (SUCCEEDED(hr))
113 {
114 ok(ILIsEqual(Info.pidl, ExpectedPidl), "Unexpected pidl value %p; pidlPathName=%S PidlPath=%S\n", Info.pidl, pidlPathName, PidlPath);
115 ILFree(ExpectedPidl);
116 }
117 }
118 else
119 {
120 hr = SHGetFolderLocation(NULL, ExpectedCsidl, NULL, 0, &ExpectedPidl);
121 ok(hr == S_OK, "SHGetFolderLocation returned %08lx\n", hr);
122 if (SUCCEEDED(hr))
123 {
124 BOOL eq = ILIsEqual(Info.pidl, ExpectedPidl);
125 ILFree(ExpectedPidl);
126
127 ok(eq, "Unexpected pidl value %p; pidlPathName=%S CSIDL=%d\n", Info.pidl, pidlPathName, ExpectedCsidl);
128 }
129 }
130 }
131 ILFree(Info.pidl);
132 }
133 }
134
135 ok(Info.dwFlags == ExpectedFlags, "dwFlags = %08lx, expected %08lx\n", Info.dwFlags, ExpectedFlags);
136 for (i = 0; i < sizeof(Info) / sizeof(DWORD); i++)
137 {
138 switch (i*4)
139 {
140 case 0x00: // FileName
141 case 0x04: // pidl
142 case 0x08: // dwFlags
143 case 0x20: // pidlRoot
144 case 0x34: // guidInproc (1/4)
145 case 0x38: // guidInproc (2/4)
146 case 0x3C: // guidInproc (3/4)
147 case 0x40: // guidInproc (4/4)
148 break;
149 default:
150 ok(InfoWords[i] == 0x55555555, "Word 0x%02lx has been set to 0x%08lx\n", i * 4, InfoWords[i]);
151 }
152 }
153
154 if (PWriteEnd)
155 {
156 PBYTE data = (PBYTE)&Info;
157
158 *PWriteEnd = 0;
159
160 for (i = sizeof(Info); i > 0; i--)
161 {
162 if (data[i - 1] != 0x55)
163 {
164 *PWriteEnd = i;
165 break;
166 }
167 }
168 }
169 }
170
171 START_TEST(SHExplorerParseCmdLine)
172 {
173 static struct
174 {
175 INT TestLine;
176 PCWSTR CommandLine;
177 INT ExpectedRet;
178 INT ExpectedCsidl;
179 DWORD ExpectedFlags;
180 PCWSTR ExpectedFileName;
181 PCWSTR PidlPath;
182 } Tests [] =
183 {
184 { __LINE__, L"", -1, CSIDL_MYDOCUMENTS, 0x00000009 },
185 { __LINE__, L"/e", TRUE, PIDL_IS_UNTOUCHED, 0x00000008 },
186 { __LINE__, L"/n", TRUE, PIDL_IS_UNTOUCHED, 0x00004001 },
187 { __LINE__, L"/x", TRUE, PIDL_IS_NULL, 0x02000000, L"/x" },
188 { __LINE__, L"-e", TRUE, PIDL_IS_NULL, 0x02000000, L"-e" },
189 { __LINE__, L"C:\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" },
190 { __LINE__, L"/e,C:\\", TRUE, PIDL_IS_PATH, 0x00000208, NULL, L"C:\\" },
191 { __LINE__, L"/select,C:\\", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\" },
192 { __LINE__, L"/e,::{20d04fe0-3aea-1069-a2d8-08002b30309d}", TRUE, PIDL_IS_PATH, 0x00000208, NULL, L"::{20d04fe0-3aea-1069-a2d8-08002b30309d}" },
193 { __LINE__, L"::{645ff040-5081-101b-9f08-00aa002f954e}", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"::{645ff040-5081-101b-9f08-00aa002f954e}" },
194 { __LINE__, L"/select,::{450d8fba-ad25-11d0-98a8-0800361b1103}", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"::{450d8fba-ad25-11d0-98a8-0800361b1103}" },
195 { __LINE__, L"=", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"::{20d04fe0-3aea-1069-a2d8-08002b30309d}" },
196 { __LINE__, L".", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Documents and Settings\\gigaherz\\Desktop" },
197 { __LINE__, L"..", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Documents and Settings\\gigaherz" },
198 { __LINE__, L"wrongpath", TRUE, PIDL_IS_NULL, 0x02000000, L"wrongpath"},
199 { __LINE__, L"%wrongdir%", TRUE, PIDL_IS_NULL, 0x02000000, L"%wrongdir%"},
200 { __LINE__, L"%programfiles#", TRUE, PIDL_IS_NULL, 0x02000000, L"%programfiles#"},
201 { __LINE__, L",", TRUE, PIDL_IS_EMPTY, 0x00000200},
202 { __LINE__, L"c:\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" },
203 { __LINE__, L"c:", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" },
204 { __LINE__, L"c", TRUE, PIDL_IS_NULL, 0x02000000, L"c"},
205 { __LINE__, L"c:\\Program Files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
206 { __LINE__, L"c:\\Program Files\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
207 { __LINE__, L"c:\\Program Files/", TRUE, PIDL_IS_NULL, 0x02000000, L"c:\\Program Files/"},
208 { __LINE__, L"c:/Program Files/", TRUE, PIDL_IS_NULL, 0x02000000, L"c:/Program Files/"},
209 { __LINE__, L"c:\\ntldr", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\ntldr" },
210 { __LINE__, L"\"c:\\\"\"program files\"", TRUE, PIDL_IS_NULL, 0x02000000, L"c:\\\"program files"},
211 { __LINE__, L"\"c:\\\"program files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
212 { __LINE__, L"\"c:\\ \"program files", TRUE, PIDL_IS_NULL, 0x02000000, L"c:\\ program files"},
213 { __LINE__, L"\"c:\\\" program files", TRUE, PIDL_IS_NULL, 0x02000000, L"c:\\ program files"},
214 { __LINE__, L"\"c:\\\", \"c:\\program files\"", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
215 { __LINE__, L"c:\\,c:\\program files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
216 { __LINE__, L"/root", 0, CSIDL_MYDOCUMENTS, 0x00000000},
217 { __LINE__, L"\"/root\"", 0, CSIDL_MYDOCUMENTS, 0x00000000},
218 { __LINE__, L"/root,", TRUE, CSIDL_MYDOCUMENTS, 0x00000000},
219 { __LINE__, L"/root,c", TRUE, CSIDL_MYDOCUMENTS, 0x00000000},
220 { __LINE__, L"/root,\"\"", TRUE, CSIDL_MYDOCUMENTS, 0x00000000},
221 { __LINE__, L"/root,wrong", TRUE, CSIDL_MYDOCUMENTS, 0x00000000},
222 { __LINE__, L"/root,0", TRUE, CSIDL_MYDOCUMENTS, 0x00000000},
223 { __LINE__, L"/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000000, NULL, L"c:\\" },
224 { __LINE__, L"/root,\"c:\\\"", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000000, NULL, L"c:\\" },
225 { __LINE__, L"/root \"c:\\\"", TRUE, PIDL_IS_NULL, 0x02000000, L"/root c:\\"},
226 { __LINE__, L"/root,\"c:\\\"\"program files\"", TRUE, PIDL_IS_PATH, 0x00000000},
227 { __LINE__, L"/root,\"c:\\\"program files", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000000, NULL, L"c:\\Program Files" },
228 { __LINE__, L"/root,c:\\,c:\\Program Files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
229 { __LINE__, L"/root,c:\\,Program Files", TRUE, PIDL_IS_NULL, 0x02000000, L"Program Files"},
230 { __LINE__, L"/root,\"c:\\\"", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000000, NULL, L"c:\\" },
231 { __LINE__, L"c:\\Program Files,/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000200, NULL, L"c:\\" },
232 { __LINE__, L"a:\\,/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000200, NULL, L"c:\\" },
233 { __LINE__, L"a:\\,/root,c", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"A:\\" },
234 { __LINE__, L"c:\\,/root,c", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" },
235 { __LINE__, L"/select", TRUE, CSIDL_MYDOCUMENTS, 0x00000040},
236 { __LINE__, L"/select,", TRUE, CSIDL_DRIVES, 0x00000240 },
237 { __LINE__, L"/select,c", TRUE, PIDL_IS_NULL, 0x02000040, L"c"},
238 { __LINE__, L"/select,0", TRUE, PIDL_IS_NULL, 0x02000040, L"0"},
239 { __LINE__, L"/select,c:\\", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\" },
240 { __LINE__, L"c:\\,/select", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\" },
241 { __LINE__, L"/select,c:\\ntldr", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\ntldr" },
242 { __LINE__, L"/select,c:\\Program Files,c:\\Documents and settings", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\Documents and Settings" },
243 { __LINE__, L"c:\\,/select,ntldr", TRUE, PIDL_IS_NULL, 0x02000240, L"ntldr"},
244 { __LINE__, L"c:\\,/select,c:\\ntldr", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\ntldr" },
245 { __LINE__, L"a:\\,/select,c:\\ntldr", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\ntldr" },
246 { __LINE__, L"z:\\,/select,c:\\ntldr", TRUE, PIDL_IS_PATH, 0x02000240, L"z:\\", L"C:\\ntldr" },
247 { __LINE__, L"select,c:\\ ", TRUE, PIDL_IS_PATH, 0x02000200, L"select", L"C:\\" },
248 { __LINE__, L"/select c:\\ ", TRUE, PIDL_IS_NULL, 0x02000000, L"/select c:\\"},
249 { __LINE__, L"a:\\,/select,c:\\", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\" },
250 { __LINE__, L"a:\\,/select,c", TRUE, PIDL_IS_NULL, 0x02000240, L"c"},
251 { __LINE__, L"c:\\,/select,c", TRUE, PIDL_IS_NULL, 0x02000240, L"c"},
252 { __LINE__, L"/e", TRUE, CSIDL_MYDOCUMENTS, 0x00000008},
253 { __LINE__, L"/e,", TRUE, CSIDL_DRIVES, 0x00000208 },
254 { __LINE__, L"/e,\"", TRUE, CSIDL_DRIVES, 0x00000208 },
255 { __LINE__, L"/e,\"\"", TRUE, CSIDL_DRIVES, 0x00000208 },
256 { __LINE__, L"/e,c:\\", TRUE, PIDL_IS_PATH, 0x00000208, NULL, L"C:\\" },
257 { __LINE__, L"c:\\,/e", TRUE, PIDL_IS_PATH, 0x00000208, NULL, L"C:\\" },
258 { __LINE__, L"/e,c", TRUE, PIDL_IS_NULL, 0x02000008, L"c"},
259 { __LINE__, L"/root,c:\\,/select,ntldr", TRUE, PIDL_IS_NULL, 0x02000040, L"ntldr"},
260 { __LINE__, L"/select,ntldr,/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x02000040, L"ntldr", L"c:\\" },
261 { __LINE__, L"/root,c:\\,/select,c:\\ntldr", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\ntldr" },
262 { __LINE__, L"/select,c:\\ntldr,/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000240, NULL, L"c:\\" },
263 { __LINE__, L"/e,/select,ntldr,/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x02000048, L"ntldr", L"c:\\" },
264 { __LINE__, L"/e,/root,c:\\,/select,ntldr", TRUE, PIDL_IS_NULL, 0x02000048, L"ntldr"},
265 { __LINE__, L"/e,/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000008, NULL, L"c:\\" },
266 { __LINE__, L"/e,c:\\,/select,ntldr", TRUE, PIDL_IS_NULL, 0x02000248, L"ntldr"},
267 { __LINE__, L"c:\\,/e,/select,ntldr", TRUE, PIDL_IS_NULL, 0x02000248, L"ntldr"},
268 { __LINE__, L"c:\\,/select,ntldr,/e", TRUE, PIDL_IS_NULL, 0x02000248, L"ntldr"},
269 { __LINE__, L"http:\\\\www.reactos.org", TRUE, PIDL_IS_NULL, 0x02000000, L"http:\\\\www.reactos.org"},
270 { __LINE__, L"/e,http:\\\\www.reactos.org", TRUE, PIDL_IS_NULL, 0x02000008, L"http:\\\\www.reactos.org"},
271 { __LINE__, L"/root,c:\\,http:\\\\www.reactos.org", TRUE, PIDL_IS_NULL, 0x02000000, L"http:\\\\www.reactos.org"},
272 { __LINE__, L"/separate ", TRUE, CSIDL_MYDOCUMENTS, 0x00020000},
273 { __LINE__, L"/separate,c:\\ program files", TRUE, PIDL_IS_NULL, 0x02020000, L"c:\\ program files"},
274 { __LINE__, L"/separate, c:\\program files", TRUE, PIDL_IS_PATH, 0x00020200, NULL, L"C:\\Program Files" },
275 { __LINE__, L"/separate, c:\\program files ,/e", TRUE, PIDL_IS_PATH, 0x00020208, NULL, L"C:\\Program Files" },
276 { __LINE__, L"/separate, c:\\program files ,\\e", TRUE, PIDL_IS_NULL, 0x02020200, L"\\e"},
277 { __LINE__, L"c:\\Documents and settings,/separate,/n,/e,/root,c:\\,/select,c:\\Program files,", TRUE, CSIDL_DRIVES, 0x00024249 },
278 { __LINE__, L"c:\\Documents and settings,/separate,/n,/e,/root,{450D8FBA-AD25-11D0-98A8-0800361B1103, 0},test,/select,c:\\Program files,", TRUE, CSIDL_DRIVES, 0x02024249, L"test" },
279 { __LINE__, L"c:\\Documents and settings,/inproc,/noui,/s,/separate,/n,/e,/root,{450D8FBA-AD25-11D0-98A8-0800361B1103, 0},test,/select,c:\\Program files,", FALSE, PIDL_PATH_EQUALS_PATH, 0x00000200, NULL, L"C:\\Documents and Settings" },
280 { __LINE__, L"=", TRUE, CSIDL_DRIVES, 0x00000200 },
281 { __LINE__, L"=c:\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" },
282 { __LINE__, L"=c:\\ntldr", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\ntldr" },
283 { __LINE__, L"/root,=", TRUE, CSIDL_DRIVES, 0x00000200 },
284 { __LINE__, L"/root=c:\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" },
285 { __LINE__, L"/root=c:\\Program files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
286 { __LINE__, L"/root=\"c:\\Program files\"", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
287 { __LINE__, L"/root=\"\"c:\\Program files\"\"", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
288 { __LINE__, L"c:\\=/root=\"c:\\Program files\"", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000000, NULL, L"C:\\Program Files" },
289 { __LINE__, L"/select=c:\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" },
290 { __LINE__, L"/select=c:\\Program files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
291 { __LINE__, L"=,/select,c:\\", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\" },
292 { __LINE__, L"/select,c:\\,=", TRUE, CSIDL_DRIVES, 0x00000240 },
293 { __LINE__, L"c:\\=/select=c:\\windows\\system32", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\WINDOWS\\system32" },
294 { __LINE__, L"/select=c:\\windows\\system32", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\WINDOWS\\system32" },
295 { __LINE__, L"=/select=c:\\windows\\system32", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\WINDOWS\\system32" },
296 { __LINE__, L"/e,=", TRUE, CSIDL_DRIVES, 0x00000208 },
297 { __LINE__, L"/e=", TRUE, CSIDL_DRIVES, 0x00000200 },
298 { __LINE__, L"/e=\"", TRUE, CSIDL_DRIVES, 0x00000200 },
299 { __LINE__, L"/e=\"\"", TRUE, CSIDL_DRIVES, 0x00000200 },
300 { __LINE__, L"=\"=\"", TRUE, PIDL_IS_NULL, 0x02000000, L"="},
301 { __LINE__, L"==\"=\"", TRUE, PIDL_IS_NULL, 0x02000200, L"="},
302 { __LINE__, L"===\"=\"", TRUE, PIDL_IS_NULL, 0x02000200, L"="},
303 { __LINE__, L"=\"=\"", TRUE, PIDL_IS_NULL, 0x02000000, L"="},
304 { __LINE__, L"==\"==\"", TRUE, PIDL_IS_NULL, 0x02000200, L"=="},
305 { __LINE__, L"===\"===\"", TRUE, PIDL_IS_NULL, 0x02000200, L"==="},
306 { __LINE__, L"=\"=a\"", TRUE, PIDL_IS_NULL, 0x02000000, L"=a"},
307 { __LINE__, L"==\"=a=\"", TRUE, PIDL_IS_NULL, 0x02000200, L"=a="},
308 { __LINE__, L"===\"=a=a=\"", TRUE, PIDL_IS_NULL, 0x02000200, L"=a=a="},
309 { __LINE__, L"=\"=a\"==", TRUE, CSIDL_DRIVES, 0x02000200, L"=a" },
310 { __LINE__, L"==\"=a=\"=", TRUE, CSIDL_DRIVES, 0x02000200, L"=a=" },
311 { __LINE__, L"===\"=a=a=\"===", TRUE, CSIDL_DRIVES, 0x02000200, L"=a=a=" },
312 { __LINE__, L"=,=,=,\"=a=a=\",=,=,=", TRUE, CSIDL_DRIVES, 0x02000200, L"=a=a=" },
313 { __LINE__, L"\"", TRUE, CSIDL_DRIVES, 0x00000200 },
314 { __LINE__, L"\"\"", TRUE, CSIDL_DRIVES, 0x00000200 },
315 { __LINE__, L"\"\"\"", TRUE, PIDL_IS_NULL, 0x02000000, L"\""},
316 { __LINE__, L"\"\"\"\"", TRUE, PIDL_IS_NULL, 0x02000000, L"\""},
317 { __LINE__, L"\"\"\"\"\"", TRUE, PIDL_IS_NULL, 0x02000000, L"\"\""},
318 { __LINE__, L"/s", TRUE, CSIDL_MYDOCUMENTS, 0x00000002},
319 { __LINE__, L"/noui", TRUE, CSIDL_MYDOCUMENTS, 0x00001000},
320 { __LINE__, L"/idlist", TRUE, PIDL_IS_UNTOUCHED, 0x00000000},
321 { __LINE__, L"-embedding", TRUE, CSIDL_MYDOCUMENTS, 0x00000080 },
322 { __LINE__, L"/inproc", FALSE, PIDL_IS_UNTOUCHED, 0x00000000 },
323 { __LINE__, L"/inproc,1", FALSE, PIDL_IS_UNTOUCHED, 0x00000000 },
324 { __LINE__, L"/inproc,a", FALSE, PIDL_IS_UNTOUCHED, 0x00000000 },
325 { __LINE__, L"/inproc,c:\\", FALSE, PIDL_IS_UNTOUCHED, 0x00000000 },
326 { __LINE__, L"/inproc,\"c:\\\"", FALSE, PIDL_IS_UNTOUCHED, 0x00000000 },
327 { __LINE__, L"/inproc,{20d04fe0-3aea-1069-a2d8-08002b30309d}", TRUE, PIDL_IS_UNTOUCHED, 0x00000400 },
328 };
329 const int TestCount = sizeof(Tests) / sizeof(Tests[0]);
330 PWSTR CommandLine;
331 WCHAR OriginalCommandLine[1024];
332 int i;
333 UINT maxWrite = 0;
334
335 CommandLine = GetCommandLineW();
336 StringCbCopyW(OriginalCommandLine, sizeof(OriginalCommandLine), CommandLine);
337
338 for (i = 0; i < TestCount; i++)
339 {
340 UINT cWrite;
341
342 wcscpy(CommandLine, L"browseui_apitest.exe ");
343 wcscat(CommandLine, Tests[i].CommandLine);
344 trace("Command line (%d): %ls\n", Tests[i].TestLine, CommandLine);
345 TestCommandLine(Tests[i].ExpectedRet,
346 Tests[i].ExpectedCsidl,
347 Tests[i].ExpectedFlags,
348 Tests[i].ExpectedFileName,
349 Tests[i].PidlPath,
350 &cWrite);
351
352 if (cWrite > maxWrite)
353 maxWrite = cWrite;
354 }
355
356 trace("Writes reached the byte right before 0x%08x\n", maxWrite);
357
358 wcscpy(CommandLine, OriginalCommandLine);
359 }