urlmon: Implemented parser for the userinfo of a URI.
[wine/testsucceed.git] / dlls / urlmon / tests / uri.c
blobc309d194ade4f9b9795dcb523502a2c3ac0c499c
1 /*
2 * UrlMon IUri tests
4 * Copyright 2010 Thomas Mullaly
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * IUri testing framework goals:
23 * - Test invalid args
24 * - invalid flags
25 * - invalid args (IUri, uri string)
26 * - Test parsing for components when no canonicalization occurs
27 * - Test parsing for components when canonicalization occurs.
28 * - More tests...
31 #include <wine/test.h>
32 #include <stdarg.h>
33 #include <stddef.h>
35 #define COBJMACROS
37 #include "windef.h"
38 #include "winbase.h"
39 #include "urlmon.h"
40 #include "shlwapi.h"
42 #define URI_STR_PROPERTY_COUNT Uri_PROPERTY_STRING_LAST+1
43 #define URI_DWORD_PROPERTY_COUNT (Uri_PROPERTY_DWORD_LAST - Uri_PROPERTY_DWORD_START)+1
45 static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**);
47 static const WCHAR http_urlW[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
48 '.','o','r','g','/',0};
50 typedef struct _uri_create_flag_test {
51 DWORD flags;
52 HRESULT expected;
53 } uri_create_flag_test;
55 static const uri_create_flag_test invalid_flag_tests[] = {
56 /* Set of invalid flag combinations to test for. */
57 {Uri_CREATE_DECODE_EXTRA_INFO | Uri_CREATE_NO_DECODE_EXTRA_INFO, E_INVALIDARG},
58 {Uri_CREATE_CANONICALIZE | Uri_CREATE_NO_CANONICALIZE, E_INVALIDARG},
59 {Uri_CREATE_CRACK_UNKNOWN_SCHEMES | Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, E_INVALIDARG},
60 {Uri_CREATE_PRE_PROCESS_HTML_URI | Uri_CREATE_NO_PRE_PROCESS_HTML_URI, E_INVALIDARG},
61 {Uri_CREATE_IE_SETTINGS | Uri_CREATE_NO_IE_SETTINGS, E_INVALIDARG}
64 typedef struct _uri_str_property {
65 const char* value;
66 HRESULT expected;
67 BOOL todo;
68 } uri_str_property;
70 typedef struct _uri_dword_property {
71 DWORD value;
72 HRESULT expected;
73 BOOL todo;
74 } uri_dword_property;
76 typedef struct _uri_properties {
77 const char* uri;
78 DWORD create_flags;
79 HRESULT create_expected;
80 BOOL create_todo;
81 DWORD props;
82 BOOL props_todo;
84 uri_str_property str_props[URI_STR_PROPERTY_COUNT];
85 uri_dword_property dword_props[URI_DWORD_PROPERTY_COUNT];
86 } uri_properties;
88 static const uri_properties uri_tests[] = {
89 { "http://www.winehq.org/tests/../tests/../..", 0, S_OK, FALSE,
90 /* A flag bitmap containing all the Uri_HAS_* flags that correspond to this uri. */
91 Uri_HAS_ABSOLUTE_URI|Uri_HAS_AUTHORITY|Uri_HAS_DISPLAY_URI|Uri_HAS_DOMAIN|Uri_HAS_HOST|
92 Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|Uri_HAS_HOST_TYPE|
93 Uri_HAS_PORT|Uri_HAS_SCHEME,
94 TRUE,
96 {"http://www.winehq.org/",S_OK,TRUE}, /* ABSOLUTE_URI */
97 {"www.winehq.org",S_OK,TRUE}, /* AUTHORITY */
98 {"http://www.winehq.org/",S_OK,TRUE}, /* DISPLAY_URI */
99 {"winehq.org",S_OK,TRUE}, /* DOMAIN */
100 {"",S_FALSE,TRUE}, /* EXTENSION */
101 {"",S_FALSE,TRUE}, /* FRAGMENT */
102 {"www.winehq.org",S_OK,TRUE}, /* HOST */
103 {"",S_FALSE,TRUE}, /* PASSWORD */
104 {"/",S_OK,TRUE}, /* PATH */
105 {"/",S_OK,TRUE}, /* PATH_AND_QUERY */
106 {"",S_FALSE,TRUE}, /* QUERY */
107 {"http://www.winehq.org/tests/../tests/../..",S_OK,FALSE}, /* RAW_URI */
108 {"http",S_OK,FALSE}, /* SCHEME_NAME */
109 {"",S_FALSE,TRUE}, /* USER_INFO */
110 {"",S_FALSE,TRUE} /* USER_NAME */
113 {Uri_HOST_DNS,S_OK,TRUE}, /* HOST_TYPE */
114 {80,S_OK,TRUE}, /* PORT */
115 {URL_SCHEME_HTTP,S_OK,FALSE}, /* SCHEME */
116 {URLZONE_INVALID,E_NOTIMPL,FALSE} /* ZONE */
119 { "http://winehq.org/tests/.././tests", 0, S_OK, FALSE,
120 Uri_HAS_ABSOLUTE_URI|Uri_HAS_AUTHORITY|Uri_HAS_DISPLAY_URI|Uri_HAS_DOMAIN|Uri_HAS_HOST|
121 Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|Uri_HAS_HOST_TYPE|
122 Uri_HAS_PORT|Uri_HAS_SCHEME,
123 TRUE,
125 {"http://winehq.org/tests",S_OK,TRUE},
126 {"winehq.org",S_OK,TRUE},
127 {"http://winehq.org/tests",S_OK,TRUE},
128 {"winehq.org",S_OK,TRUE},
129 {"",S_FALSE,TRUE},
130 {"",S_FALSE,TRUE},
131 {"winehq.org",S_OK,TRUE},
132 {"",S_FALSE,TRUE},
133 {"/tests",S_OK,TRUE},
134 {"/tests",S_OK,TRUE},
135 {"",S_FALSE,TRUE},
136 {"http://winehq.org/tests/.././tests",S_OK,FALSE},
137 {"http",S_OK,FALSE},
138 {"",S_FALSE,TRUE},
139 {"",S_FALSE,TRUE}
142 {Uri_HOST_DNS,S_OK,TRUE},
143 {80,S_OK,TRUE},
144 {URL_SCHEME_HTTP,S_OK,FALSE},
145 {URLZONE_INVALID,E_NOTIMPL,FALSE}
148 { "HtTp://www.winehq.org/tests/..?query=x&return=y", 0, S_OK, FALSE,
149 Uri_HAS_ABSOLUTE_URI|Uri_HAS_AUTHORITY|Uri_HAS_DISPLAY_URI|Uri_HAS_DOMAIN|Uri_HAS_HOST|
150 Uri_HAS_DOMAIN|Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_QUERY|Uri_HAS_RAW_URI|
151 Uri_HAS_SCHEME_NAME|Uri_HAS_HOST_TYPE|Uri_HAS_PORT|Uri_HAS_SCHEME,
152 TRUE,
154 {"http://www.winehq.org/?query=x&return=y",S_OK,TRUE},
155 {"www.winehq.org",S_OK,TRUE},
156 {"http://www.winehq.org/?query=x&return=y",S_OK,TRUE},
157 {"winehq.org",S_OK,TRUE},
158 {"",S_FALSE,TRUE},
159 {"",S_FALSE,TRUE},
160 {"www.winehq.org",S_OK,TRUE},
161 {"",S_FALSE,TRUE},
162 {"/",S_OK,TRUE},
163 {"/?query=x&return=y",S_OK,TRUE},
164 {"?query=x&return=y",S_OK,TRUE},
165 {"HtTp://www.winehq.org/tests/..?query=x&return=y",S_OK,FALSE},
166 {"http",S_OK,FALSE},
167 {"",S_FALSE,TRUE},
168 {"",S_FALSE,TRUE}
171 {Uri_HOST_DNS,S_OK,TRUE},
172 {80,S_OK,TRUE},
173 {URL_SCHEME_HTTP,S_OK,FALSE},
174 {URLZONE_INVALID,E_NOTIMPL,FALSE},
177 { "hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters", 0, S_OK, FALSE,
178 Uri_HAS_ABSOLUTE_URI|Uri_HAS_AUTHORITY|Uri_HAS_DISPLAY_URI|Uri_HAS_DOMAIN|Uri_HAS_HOST|Uri_HAS_PATH|
179 Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|Uri_HAS_USER_INFO|Uri_HAS_USER_NAME|
180 Uri_HAS_HOST_TYPE|Uri_HAS_PORT|Uri_HAS_SCHEME,
181 TRUE,
183 {"http://usEr%3Ainfo@example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,TRUE},
184 {"usEr%3Ainfo@example.com",S_OK,TRUE},
185 {"http://example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,TRUE},
186 {"example.com",S_OK,TRUE},
187 {"",S_FALSE,TRUE},
188 {"",S_FALSE,TRUE},
189 {"example.com",S_OK,TRUE},
190 {"",S_FALSE,TRUE},
191 {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,TRUE},
192 {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,TRUE},
193 {"",S_FALSE,TRUE},
194 {"hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters",S_OK,FALSE},
195 {"http",S_OK,FALSE},
196 {"usEr%3Ainfo",S_OK,TRUE},
197 {"usEr%3Ainfo",S_OK,TRUE}
200 {Uri_HOST_DNS,S_OK,TRUE},
201 {80,S_OK,TRUE},
202 {URL_SCHEME_HTTP,S_OK,FALSE},
203 {URLZONE_INVALID,E_NOTIMPL,FALSE},
206 { "ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt", 0, S_OK, FALSE,
207 Uri_HAS_ABSOLUTE_URI|Uri_HAS_AUTHORITY|Uri_HAS_DISPLAY_URI|Uri_HAS_DOMAIN|Uri_HAS_EXTENSION|
208 Uri_HAS_HOST|Uri_HAS_PASSWORD|Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|
209 Uri_HAS_SCHEME_NAME|Uri_HAS_USER_INFO|Uri_HAS_USER_NAME|Uri_HAS_HOST_TYPE|Uri_HAS_PORT|
210 Uri_HAS_SCHEME,
211 TRUE,
213 {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK,TRUE},
214 {"winepass:wine@ftp.winehq.org:9999",S_OK,TRUE},
215 {"ftp://ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK,TRUE},
216 {"winehq.org",S_OK,TRUE},
217 {".txt",S_OK,TRUE},
218 {"",S_FALSE,TRUE},
219 {"ftp.winehq.org",S_OK,TRUE},
220 {"wine",S_OK,TRUE},
221 {"/dir/foo%20bar.txt",S_OK,TRUE},
222 {"/dir/foo%20bar.txt",S_OK,TRUE},
223 {"",S_FALSE,TRUE},
224 {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt",S_OK,FALSE},
225 {"ftp",S_OK,FALSE},
226 {"winepass:wine",S_OK,TRUE},
227 {"winepass",S_OK,TRUE}
230 {Uri_HOST_DNS,S_OK,TRUE},
231 {9999,S_OK,TRUE},
232 {URL_SCHEME_FTP,S_OK,FALSE},
233 {URLZONE_INVALID,E_NOTIMPL,FALSE}
236 { "file://c:\\tests\\../tests/foo%20bar.mp3", 0, S_OK, FALSE,
237 Uri_HAS_ABSOLUTE_URI|Uri_HAS_DISPLAY_URI|Uri_HAS_EXTENSION|Uri_HAS_PATH|
238 Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|Uri_HAS_HOST_TYPE|Uri_HAS_SCHEME,
239 TRUE,
241 {"file:///c:/tests/foo%2520bar.mp3",S_OK,TRUE},
242 {"",S_FALSE,TRUE},
243 {"file:///c:/tests/foo%2520bar.mp3",S_OK,TRUE},
244 {"",S_FALSE,TRUE},
245 {".mp3",S_OK,TRUE},
246 {"",S_FALSE,TRUE},
247 {"",S_FALSE,TRUE},
248 {"",S_FALSE,TRUE},
249 {"/c:/tests/foo%2520bar.mp3",S_OK,TRUE},
250 {"/c:/tests/foo%2520bar.mp3",S_OK,TRUE},
251 {"",S_FALSE,TRUE},
252 {"file://c:\\tests\\../tests/foo%20bar.mp3",S_OK,FALSE},
253 {"file",S_OK,FALSE},
254 {"",S_FALSE,TRUE},
255 {"",S_FALSE,TRUE}
258 {Uri_HOST_UNKNOWN,S_OK,TRUE},
259 {0,S_FALSE,TRUE},
260 {URL_SCHEME_FILE,S_OK,FALSE},
261 {URLZONE_INVALID,E_NOTIMPL,FALSE}
264 { "FILE://localhost/test dir\\../tests/test%20file.README.txt", 0, S_OK, FALSE,
265 Uri_HAS_ABSOLUTE_URI|Uri_HAS_DISPLAY_URI|Uri_HAS_EXTENSION|Uri_HAS_PATH|
266 Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|Uri_HAS_HOST_TYPE|Uri_HAS_SCHEME,
267 TRUE,
269 {"file:///tests/test%20file.README.txt",S_OK,TRUE},
270 {"",S_FALSE,TRUE},
271 {"file:///tests/test%20file.README.txt",S_OK,TRUE},
272 {"",S_FALSE,TRUE},
273 {".txt",S_OK,TRUE},
274 {"",S_FALSE,TRUE},
275 {"",S_FALSE,TRUE},
276 {"",S_FALSE,TRUE},
277 {"/tests/test%20file.README.txt",S_OK,TRUE},
278 {"/tests/test%20file.README.txt",S_OK,TRUE},
279 {"",S_FALSE,TRUE},
280 {"FILE://localhost/test dir\\../tests/test%20file.README.txt",S_OK,FALSE},
281 {"file",S_OK,FALSE},
282 {"",S_FALSE,TRUE},
283 {"",S_FALSE,TRUE}
286 {Uri_HOST_UNKNOWN,S_OK,TRUE},
287 {0,S_FALSE,TRUE},
288 {URL_SCHEME_FILE,S_OK,FALSE},
289 {URLZONE_INVALID,E_NOTIMPL,FALSE}
292 { "urn:nothing:should:happen here", 0, S_OK, FALSE,
293 Uri_HAS_ABSOLUTE_URI|Uri_HAS_DISPLAY_URI|Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|
294 Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|Uri_HAS_HOST_TYPE|Uri_HAS_SCHEME,
295 TRUE,
297 {"urn:nothing:should:happen here",S_OK,TRUE},
298 {"",S_FALSE,TRUE},
299 {"urn:nothing:should:happen here",S_OK,TRUE},
300 {"",S_FALSE,TRUE},
301 {"",S_FALSE,TRUE},
302 {"",S_FALSE,TRUE},
303 {"",S_FALSE,TRUE},
304 {"",S_FALSE,TRUE},
305 {"nothing:should:happen here",S_OK,TRUE},
306 {"nothing:should:happen here",S_OK,TRUE},
307 {"",S_FALSE,TRUE},
308 {"urn:nothing:should:happen here",S_OK,FALSE},
309 {"urn",S_OK,FALSE},
310 {"",S_FALSE,TRUE},
311 {"",S_FALSE,TRUE}
314 {Uri_HOST_UNKNOWN,S_OK,TRUE},
315 {0,S_FALSE,TRUE},
316 {URL_SCHEME_UNKNOWN,S_OK,FALSE},
317 {URLZONE_INVALID,E_NOTIMPL,FALSE}
320 { "http://127.0.0.1/tests/../test dir/./test.txt", 0, S_OK, FALSE,
321 Uri_HAS_ABSOLUTE_URI|Uri_HAS_AUTHORITY|Uri_HAS_DISPLAY_URI|Uri_HAS_EXTENSION|
322 Uri_HAS_HOST|Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|
323 Uri_HAS_HOST_TYPE|Uri_HAS_PORT|Uri_HAS_SCHEME,
324 TRUE,
326 {"http://127.0.0.1/test%20dir/test.txt",S_OK,TRUE},
327 {"127.0.0.1",S_OK,TRUE},
328 {"http://127.0.0.1/test%20dir/test.txt",S_OK,TRUE},
329 {"",S_FALSE,TRUE},
330 {".txt",S_OK,TRUE},
331 {"",S_FALSE,TRUE},
332 {"127.0.0.1",S_OK,TRUE},
333 {"",S_FALSE,TRUE},
334 {"/test%20dir/test.txt",S_OK,TRUE},
335 {"/test%20dir/test.txt",S_OK,TRUE},
336 {"",S_FALSE,TRUE},
337 {"http://127.0.0.1/tests/../test dir/./test.txt",S_OK,FALSE},
338 {"http",S_OK,FALSE},
339 {"",S_FALSE,TRUE},
340 {"",S_FALSE,TRUE}
343 {Uri_HOST_IPV4,S_OK,TRUE},
344 {80,S_OK,TRUE},
345 {URL_SCHEME_HTTP,S_OK,FALSE},
346 {URLZONE_INVALID,E_NOTIMPL,FALSE}
349 { "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", 0, S_OK, FALSE,
350 Uri_HAS_ABSOLUTE_URI|Uri_HAS_AUTHORITY|Uri_HAS_DISPLAY_URI|Uri_HAS_HOST|
351 Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|
352 Uri_HAS_HOST_TYPE|Uri_HAS_PORT|Uri_HAS_SCHEME,
353 TRUE,
355 {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,TRUE},
356 {"[fedc:ba98:7654:3210:fedc:ba98:7654:3210]",S_OK,TRUE},
357 {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,TRUE},
358 {"",S_FALSE,TRUE},
359 {"",S_FALSE,TRUE},
360 {"",S_FALSE,TRUE},
361 {"fedc:ba98:7654:3210:fedc:ba98:7654:3210",S_OK,TRUE},
362 {"",S_FALSE,TRUE},
363 {"/",S_OK,TRUE},
364 {"/",S_OK,TRUE},
365 {"",S_FALSE,TRUE},
366 {"http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]",S_OK,FALSE},
367 {"http",S_OK,FALSE},
368 {"",S_FALSE,TRUE},
369 {"",S_FALSE,TRUE}
372 {Uri_HOST_IPV6,S_OK,TRUE},
373 {80,S_OK,TRUE},
374 {URL_SCHEME_HTTP,S_OK,FALSE},
375 {URLZONE_INVALID,E_NOTIMPL,FALSE}
378 { "ftp://[::13.1.68.3]", 0, S_OK, FALSE,
379 Uri_HAS_ABSOLUTE_URI|Uri_HAS_AUTHORITY|Uri_HAS_DISPLAY_URI|Uri_HAS_HOST|
380 Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|
381 Uri_HAS_HOST_TYPE|Uri_HAS_PORT|Uri_HAS_SCHEME,
382 TRUE,
384 {"ftp://[::13.1.68.3]/",S_OK,TRUE},
385 {"[::13.1.68.3]",S_OK,TRUE},
386 {"ftp://[::13.1.68.3]/",S_OK,TRUE},
387 {"",S_FALSE,TRUE},
388 {"",S_FALSE,TRUE},
389 {"",S_FALSE,TRUE},
390 {"::13.1.68.3",S_OK,TRUE},
391 {"",S_FALSE,TRUE},
392 {"/",S_OK,TRUE},
393 {"/",S_OK,TRUE},
394 {"",S_FALSE,TRUE},
395 {"ftp://[::13.1.68.3]",S_OK,FALSE},
396 {"ftp",S_OK,FALSE},
397 {"",S_FALSE,TRUE},
398 {"",S_FALSE,TRUE}
401 {Uri_HOST_IPV6,S_OK,TRUE},
402 {21,S_OK,TRUE},
403 {URL_SCHEME_FTP,S_OK,FALSE},
404 {URLZONE_INVALID,E_NOTIMPL,FALSE}
407 { "http://[FEDC:BA98:0:0:0:0:0:3210]", 0, S_OK, FALSE,
408 Uri_HAS_ABSOLUTE_URI|Uri_HAS_AUTHORITY|Uri_HAS_DISPLAY_URI|Uri_HAS_HOST|
409 Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|
410 Uri_HAS_HOST_TYPE|Uri_HAS_PORT|Uri_HAS_SCHEME,
411 TRUE,
413 {"http://[fedc:ba98::3210]/",S_OK,TRUE},
414 {"[fedc:ba98::3210]",S_OK,TRUE},
415 {"http://[fedc:ba98::3210]/",S_OK,TRUE},
416 {"",S_FALSE,TRUE},
417 {"",S_FALSE,TRUE},
418 {"",S_FALSE,TRUE},
419 {"fedc:ba98::3210",S_OK,TRUE},
420 {"",S_FALSE,TRUE},
421 {"/",S_OK,TRUE},
422 {"/",S_OK,TRUE},
423 {"",S_FALSE,TRUE},
424 {"http://[FEDC:BA98:0:0:0:0:0:3210]",S_OK,FALSE},
425 {"http",S_OK,FALSE},
426 {"",S_FALSE,TRUE},
427 {"",S_FALSE,TRUE},
430 {Uri_HOST_IPV6,S_OK,TRUE},
431 {80,S_OK,TRUE},
432 {URL_SCHEME_HTTP,S_OK,FALSE},
433 {URLZONE_INVALID,E_NOTIMPL,FALSE}
436 { "1234://www.winehq.org", 0, S_OK, FALSE,
437 Uri_HAS_ABSOLUTE_URI|Uri_HAS_AUTHORITY|Uri_HAS_DISPLAY_URI|Uri_HAS_DOMAIN|
438 Uri_HAS_HOST|Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|
439 Uri_HAS_HOST_TYPE|Uri_HAS_SCHEME,
440 TRUE,
442 {"1234://www.winehq.org/",S_OK,TRUE},
443 {"www.winehq.org",S_OK,TRUE},
444 {"1234://www.winehq.org/",S_OK,TRUE},
445 {"winehq.org",S_OK,TRUE},
446 {"",S_FALSE,TRUE},
447 {"",S_FALSE,TRUE},
448 {"www.winehq.org",S_OK,TRUE},
449 {"",S_FALSE,TRUE},
450 {"/",S_OK,TRUE},
451 {"/",S_OK,TRUE},
452 {"",S_FALSE,TRUE},
453 {"1234://www.winehq.org",S_OK,FALSE},
454 {"1234",S_OK,FALSE},
455 {"",S_FALSE,TRUE},
456 {"",S_FALSE,TRUE}
459 {Uri_HOST_DNS,S_OK,TRUE},
460 {0,S_FALSE,TRUE},
461 {URL_SCHEME_UNKNOWN,S_OK,FALSE},
462 {URLZONE_INVALID,E_NOTIMPL,FALSE}
465 { "://www.winehq.org", 0, E_INVALIDARG, FALSE,
466 0, TRUE,
468 {"",S_FALSE,TRUE},
469 {"",S_FALSE,TRUE},
470 {"",S_FALSE,TRUE},
471 {"",S_FALSE,TRUE},
472 {"",S_FALSE,TRUE},
473 {"",S_FALSE,TRUE},
474 {"",S_FALSE,TRUE},
475 {"",S_FALSE,TRUE},
476 {"",S_FALSE,TRUE},
477 {"",S_FALSE,TRUE},
478 {"",S_FALSE,TRUE},
479 {"",S_FALSE,TRUE},
480 {"",S_FALSE,TRUE},
481 {"",S_FALSE,TRUE},
482 {"",S_FALSE,TRUE}
485 {Uri_HOST_UNKNOWN,S_FALSE,TRUE},
486 {0,S_FALSE,TRUE},
487 {URL_SCHEME_UNKNOWN,S_FALSE,FALSE},
488 {URLZONE_INVALID,E_NOTIMPL,FALSE}
491 /* Window's doesn't like URI's which are implicitly file paths without the ALLOW_IMPLICIT_FILE_SCHEME flag set. */
492 { "C:/test/test.mp3", 0, E_INVALIDARG, FALSE,
493 0, TRUE,
495 {"",S_FALSE,FALSE},
496 {"",S_FALSE,FALSE},
497 {"",S_FALSE,FALSE},
498 {"",S_FALSE,FALSE},
499 {"",S_FALSE,FALSE},
500 {"",S_FALSE,FALSE},
501 {"",S_FALSE,FALSE},
502 {"",S_FALSE,FALSE},
503 {"",S_FALSE,FALSE},
504 {"",S_FALSE,FALSE},
505 {"",S_FALSE,FALSE},
506 {"",S_FALSE,FALSE},
507 {"",S_FALSE,FALSE},
508 {"",S_FALSE,FALSE},
509 {"",S_FALSE,FALSE}
512 {Uri_HOST_UNKNOWN,S_FALSE,FALSE},
513 {0,S_FALSE,FALSE},
514 {URL_SCHEME_INVALID,S_FALSE,FALSE},
515 {URLZONE_INVALID,E_NOTIMPL,FALSE}
518 /* Window's doesn't like URI's which are implicitly file paths without the ALLOW_IMPLICIT_FILE_SCHEME flag set. */
519 { "\\\\Server/test/test.mp3", 0, E_INVALIDARG, FALSE,
520 0, TRUE,
522 {"",S_FALSE,FALSE},
523 {"",S_FALSE,FALSE},
524 {"",S_FALSE,FALSE},
525 {"",S_FALSE,FALSE},
526 {"",S_FALSE,FALSE},
527 {"",S_FALSE,FALSE},
528 {"",S_FALSE,FALSE},
529 {"",S_FALSE,FALSE},
530 {"",S_FALSE,FALSE},
531 {"",S_FALSE,FALSE},
532 {"",S_FALSE,FALSE},
533 {"",S_FALSE,FALSE},
534 {"",S_FALSE,FALSE},
535 {"",S_FALSE,FALSE},
536 {"",S_FALSE,FALSE}
539 {Uri_HOST_UNKNOWN,S_FALSE,FALSE},
540 {0,S_FALSE,FALSE},
541 {URL_SCHEME_INVALID,S_FALSE,FALSE},
542 {URLZONE_INVALID,E_NOTIMPL,FALSE}
545 /* Window's doesn't like URI's which are implicitly file paths without the ALLOW_IMPLICIT_FILE_SCHEME flag set. */
546 { "\\\\Server/test/test.mp3", Uri_CREATE_ALLOW_RELATIVE, E_INVALIDARG, FALSE,
547 0, TRUE,
549 {"",S_FALSE,FALSE},
550 {"",S_FALSE,FALSE},
551 {"",S_FALSE,FALSE},
552 {"",S_FALSE,FALSE},
553 {"",S_FALSE,FALSE},
554 {"",S_FALSE,FALSE},
555 {"",S_FALSE,FALSE},
556 {"",S_FALSE,FALSE},
557 {"",S_FALSE,FALSE},
558 {"",S_FALSE,FALSE},
559 {"",S_FALSE,FALSE},
560 {"",S_FALSE,FALSE},
561 {"",S_FALSE,FALSE},
562 {"",S_FALSE,FALSE},
563 {"",S_FALSE,FALSE}
566 {Uri_HOST_UNKNOWN,S_FALSE,FALSE},
567 {0,S_FALSE,FALSE},
568 {URL_SCHEME_INVALID,S_FALSE,FALSE},
569 {URLZONE_INVALID,E_NOTIMPL,FALSE}
572 /* Window's doesn't like URI's which are implicitly file paths without the ALLOW_IMPLICIT_FILE_SCHEME flag set. */
573 { "C:/test/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, E_INVALIDARG, FALSE,
574 0, TRUE,
576 {"",S_FALSE,FALSE},
577 {"",S_FALSE,FALSE},
578 {"",S_FALSE,FALSE},
579 {"",S_FALSE,FALSE},
580 {"",S_FALSE,FALSE},
581 {"",S_FALSE,FALSE},
582 {"",S_FALSE,FALSE},
583 {"",S_FALSE,FALSE},
584 {"",S_FALSE,FALSE},
585 {"",S_FALSE,FALSE},
586 {"",S_FALSE,FALSE},
587 {"",S_FALSE,FALSE},
588 {"",S_FALSE,FALSE},
589 {"",S_FALSE,FALSE},
590 {"",S_FALSE,FALSE}
593 {Uri_HOST_UNKNOWN,S_FALSE,FALSE},
594 {0,S_FALSE,FALSE},
595 {URL_SCHEME_INVALID,S_FALSE,FALSE},
596 {URLZONE_INVALID,E_NOTIMPL,FALSE}
599 /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
600 { "C:/test/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
601 Uri_HAS_ABSOLUTE_URI|Uri_HAS_DISPLAY_URI|Uri_HAS_EXTENSION|Uri_HAS_PATH|
602 Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|Uri_HAS_HOST_TYPE|Uri_HAS_SCHEME,
603 TRUE,
605 {"file:///C:/test/test.mp3",S_OK,TRUE},
606 {"",S_FALSE,TRUE},
607 {"file:///C:/test/test.mp3",S_OK,TRUE},
608 {"",S_FALSE,TRUE},
609 {".mp3",S_OK,TRUE},
610 {"",S_FALSE,TRUE},
611 {"",S_FALSE,TRUE},
612 {"",S_FALSE,TRUE},
613 {"/C:/test/test.mp3",S_OK,TRUE},
614 {"/C:/test/test.mp3",S_OK,TRUE},
615 {"",S_FALSE,TRUE},
616 {"C:/test/test.mp3",S_OK,FALSE},
617 {"file",S_OK,FALSE},
618 {"",S_FALSE,TRUE},
619 {"",S_FALSE,TRUE}
622 {Uri_HOST_UNKNOWN,S_OK,TRUE},
623 {0,S_FALSE,TRUE},
624 {URL_SCHEME_FILE,S_OK,FALSE},
625 {URLZONE_INVALID,E_NOTIMPL,FALSE}
628 /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
629 { "\\\\Server/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
630 Uri_HAS_ABSOLUTE_URI|Uri_HAS_AUTHORITY|Uri_HAS_DISPLAY_URI|Uri_HAS_EXTENSION|
631 Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_HOST|Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|
632 Uri_HAS_HOST_TYPE|Uri_HAS_SCHEME,
633 TRUE,
635 {"file://server/test.mp3",S_OK,TRUE},
636 {"server",S_OK,TRUE},
637 {"file://server/test.mp3",S_OK,TRUE},
638 {"",S_FALSE,TRUE},
639 {".mp3",S_OK,TRUE},
640 {"",S_FALSE,TRUE},
641 {"server",S_OK,TRUE},
642 {"",S_FALSE,TRUE},
643 {"/test.mp3",S_OK,TRUE},
644 {"/test.mp3",S_OK,TRUE},
645 {"",S_FALSE,TRUE},
646 {"\\\\Server/test.mp3",S_OK,FALSE},
647 {"file",S_OK,FALSE},
648 {"",S_FALSE,TRUE},
649 {"",S_FALSE,TRUE}
652 {Uri_HOST_DNS,S_OK,TRUE},
653 {0,S_FALSE,TRUE},
654 {URL_SCHEME_FILE,S_OK,FALSE},
655 {URLZONE_INVALID,E_NOTIMPL,FALSE}
658 { "www.winehq.org/test", Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
659 Uri_HAS_ABSOLUTE_URI|Uri_HAS_AUTHORITY|Uri_HAS_DISPLAY_URI|Uri_HAS_DOMAIN|Uri_HAS_HOST|
660 Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|Uri_HAS_HOST_TYPE|
661 Uri_HAS_SCHEME,
662 TRUE,
664 {"*:www.winehq.org/test",S_OK,TRUE},
665 {"www.winehq.org",S_OK,TRUE},
666 {"*:www.winehq.org/test",S_OK,TRUE},
667 {"winehq.org",S_OK,TRUE},
668 {"",S_FALSE,TRUE},
669 {"",S_FALSE,TRUE},
670 {"www.winehq.org",S_OK,TRUE},
671 {"",S_FALSE,TRUE},
672 {"/test",S_OK,TRUE},
673 {"/test",S_OK,TRUE},
674 {"",S_FALSE,TRUE},
675 {"www.winehq.org/test",S_OK,FALSE},
676 {"*",S_OK,FALSE},
677 {"",S_FALSE,TRUE},
678 {"",S_FALSE,TRUE}
681 {Uri_HOST_DNS,S_OK,TRUE},
682 {0,S_FALSE,TRUE},
683 {URL_SCHEME_WILDCARD,S_OK,FALSE},
684 {URLZONE_INVALID,E_NOTIMPL,FALSE}
687 /* Valid since the '*' is the only character in the scheme name. */
688 { "*:www.winehq.org/test", 0, S_OK, FALSE,
689 Uri_HAS_ABSOLUTE_URI|Uri_HAS_AUTHORITY|Uri_HAS_DISPLAY_URI|Uri_HAS_DOMAIN|Uri_HAS_HOST|
690 Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|Uri_HAS_HOST_TYPE|
691 Uri_HAS_SCHEME,
692 TRUE,
694 {"*:www.winehq.org/test",S_OK,TRUE},
695 {"www.winehq.org",S_OK,TRUE},
696 {"*:www.winehq.org/test",S_OK,TRUE},
697 {"winehq.org",S_OK,TRUE},
698 {"",S_FALSE,TRUE},
699 {"",S_FALSE,TRUE},
700 {"www.winehq.org",S_OK,TRUE},
701 {"",S_FALSE,TRUE},
702 {"/test",S_OK,TRUE},
703 {"/test",S_OK,TRUE},
704 {"",S_FALSE,TRUE},
705 {"*:www.winehq.org/test",S_OK,FALSE},
706 {"*",S_OK,FALSE},
707 {"",S_FALSE,TRUE},
708 {"",S_FALSE,TRUE}
711 {Uri_HOST_DNS,S_OK,TRUE},
712 {0,S_FALSE,TRUE},
713 {URL_SCHEME_WILDCARD,S_OK,FALSE},
714 {URLZONE_INVALID,E_NOTIMPL,FALSE}
717 /* Not valid since a '*' is only allowed to appear if its the only character in scheme. */
718 { "*abcd://not.valid.com", 0, E_INVALIDARG, FALSE,
719 0, TRUE,
721 {"",S_FALSE,FALSE},
722 {"",S_FALSE,FALSE},
723 {"",S_FALSE,FALSE},
724 {"",S_FALSE,FALSE},
725 {"",S_FALSE,FALSE},
726 {"",S_FALSE,FALSE},
727 {"",S_FALSE,FALSE},
728 {"",S_FALSE,FALSE},
729 {"",S_FALSE,FALSE},
730 {"",S_FALSE,FALSE},
731 {"",S_FALSE,FALSE},
732 {"",S_FALSE,FALSE},
733 {"",S_FALSE,FALSE},
734 {"",S_FALSE,FALSE},
735 {"",S_FALSE,FALSE}
738 {Uri_HOST_UNKNOWN,S_FALSE,FALSE},
739 {0,S_FALSE,FALSE},
740 {URL_SCHEME_INVALID,S_FALSE,FALSE},
741 {URLZONE_INVALID,E_NOTIMPL,FALSE}
744 /* Not valid since a '*' is only allowed to appear if its the only character in scheme. */
745 { "*a*b*c*d://not.valid.com", 0, E_INVALIDARG, FALSE,
746 0, TRUE,
748 {"",S_FALSE,FALSE},
749 {"",S_FALSE,FALSE},
750 {"",S_FALSE,FALSE},
751 {"",S_FALSE,FALSE},
752 {"",S_FALSE,FALSE},
753 {"",S_FALSE,FALSE},
754 {"",S_FALSE,FALSE},
755 {"",S_FALSE,FALSE},
756 {"",S_FALSE,FALSE},
757 {"",S_FALSE,FALSE},
758 {"",S_FALSE,FALSE},
759 {"",S_FALSE,FALSE},
760 {"",S_FALSE,FALSE},
761 {"",S_FALSE,FALSE},
762 {"",S_FALSE,FALSE}
765 {Uri_HOST_UNKNOWN,S_FALSE,FALSE},
766 {0,S_FALSE,FALSE},
767 {URL_SCHEME_INVALID,S_FALSE,FALSE},
768 {URLZONE_INVALID,E_NOTIMPL,FALSE}
771 { "/../some dir/test.ext", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
772 Uri_HAS_ABSOLUTE_URI|Uri_HAS_DISPLAY_URI|Uri_HAS_EXTENSION|Uri_HAS_PATH|
773 Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_HOST_TYPE|Uri_HAS_SCHEME,
774 TRUE,
776 {"/../some dir/test.ext",S_OK,TRUE},
777 {"",S_FALSE,TRUE},
778 {"/../some dir/test.ext",S_OK,TRUE},
779 {"",S_FALSE,TRUE},
780 {".ext",S_OK,TRUE},
781 {"",S_FALSE,TRUE},
782 {"",S_FALSE,TRUE},
783 {"",S_FALSE,TRUE},
784 {"/../some dir/test.ext",S_OK,TRUE},
785 {"/../some dir/test.ext",S_OK,TRUE},
786 {"",S_FALSE,TRUE},
787 {"/../some dir/test.ext",S_OK,FALSE},
788 {"",S_FALSE,FALSE},
789 {"",S_FALSE,TRUE},
790 {"",S_FALSE,TRUE}
793 {Uri_HOST_UNKNOWN,S_OK,TRUE},
794 {0,S_FALSE,TRUE},
795 {URL_SCHEME_UNKNOWN,S_OK,FALSE},
796 {URLZONE_INVALID,E_NOTIMPL,FALSE}
799 { "//implicit/wildcard/uri scheme", Uri_CREATE_ALLOW_RELATIVE|Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
800 Uri_HAS_ABSOLUTE_URI|Uri_HAS_AUTHORITY|Uri_HAS_DISPLAY_URI|Uri_HAS_HOST|Uri_HAS_PATH|
801 Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|Uri_HAS_HOST_TYPE|Uri_HAS_SCHEME,
802 TRUE,
804 {"*://implicit/wildcard/uri%20scheme",S_OK,TRUE},
805 {"",S_OK,TRUE},
806 {"*://implicit/wildcard/uri%20scheme",S_OK,TRUE},
807 {"",S_FALSE,TRUE},
808 {"",S_FALSE,TRUE},
809 {"",S_FALSE,TRUE},
810 {"",S_OK,TRUE},
811 {"",S_FALSE,TRUE},
812 {"//implicit/wildcard/uri%20scheme",S_OK,TRUE},
813 {"//implicit/wildcard/uri%20scheme",S_OK,TRUE},
814 {"",S_FALSE,TRUE},
815 {"//implicit/wildcard/uri scheme",S_OK,FALSE},
816 {"*",S_OK,FALSE},
817 {"",S_FALSE,TRUE},
818 {"",S_FALSE,TRUE},
821 {Uri_HOST_UNKNOWN,S_OK,TRUE},
822 {0,S_FALSE,TRUE},
823 {URL_SCHEME_WILDCARD,S_OK,FALSE},
824 {URLZONE_INVALID,E_NOTIMPL,FALSE}
827 /* URI is considered opaque since CREATE_NO_CRACK_UNKNOWN_SCHEMES is set and its an unknown scheme. */
828 { "zip://google.com", Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, S_OK, FALSE,
829 Uri_HAS_ABSOLUTE_URI|Uri_HAS_DISPLAY_URI|Uri_HAS_EXTENSION|Uri_HAS_PATH|
830 Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|Uri_HAS_HOST_TYPE|Uri_HAS_SCHEME_NAME|
831 Uri_HAS_SCHEME,
832 TRUE,
834 {"zip:/.//google.com",S_OK,TRUE},
835 {"",S_FALSE,TRUE},
836 {"zip:/.//google.com",S_OK,TRUE},
837 {"",S_FALSE,TRUE},
838 {".com",S_OK,TRUE},
839 {"",S_FALSE,TRUE},
840 {"",S_FALSE,TRUE},
841 {"",S_FALSE,TRUE},
842 {"/.//google.com",S_OK,TRUE},
843 {"/.//google.com",S_OK,TRUE},
844 {"",S_FALSE,TRUE},
845 {"zip://google.com",S_OK,FALSE},
846 {"zip",S_OK,FALSE},
847 {"",S_FALSE,TRUE},
848 {"",S_FALSE,TRUE}
851 {Uri_HOST_UNKNOWN,S_OK,TRUE},
852 {0,S_FALSE,TRUE},
853 {URL_SCHEME_UNKNOWN,S_OK,FALSE},
854 {URLZONE_INVALID,E_NOTIMPL,FALSE}
857 /* Windows uses the first occurence of ':' to delimit the userinfo. */
858 { "ftp://user:pass:word@winehq.org/", 0, S_OK, FALSE,
859 Uri_HAS_ABSOLUTE_URI|Uri_HAS_AUTHORITY|Uri_HAS_DISPLAY_URI|Uri_HAS_DOMAIN|
860 Uri_HAS_HOST|Uri_HAS_PASSWORD|Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|Uri_HAS_RAW_URI|
861 Uri_HAS_SCHEME_NAME|Uri_HAS_USER_INFO|Uri_HAS_USER_NAME|Uri_HAS_HOST_TYPE|Uri_HAS_PORT|
862 Uri_HAS_SCHEME,
863 TRUE,
865 {"ftp://user:pass:word@winehq.org/",S_OK,TRUE},
866 {"user:pass:word@winehq.org",S_OK,TRUE},
867 {"ftp://winehq.org/",S_OK,TRUE},
868 {"winehq.org",S_OK,TRUE},
869 {"",S_FALSE,TRUE},
870 {"",S_FALSE,TRUE},
871 {"winehq.org",S_OK,TRUE},
872 {"pass:word",S_OK,TRUE},
873 {"/",S_OK,TRUE},
874 {"/",S_OK,TRUE},
875 {"",S_FALSE,TRUE},
876 {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
877 {"ftp",S_OK,FALSE},
878 {"user:pass:word",S_OK,TRUE},
879 {"user",S_OK,TRUE}
882 {Uri_HOST_DNS,S_OK,TRUE},
883 {21,S_OK,TRUE},
884 {URL_SCHEME_FTP,S_OK,FALSE},
885 {URLZONE_INVALID,E_NOTIMPL,FALSE}
890 typedef struct _uri_equality {
891 const char* a;
892 DWORD create_flags_a;
893 BOOL create_todo_a;
894 const char* b;
895 DWORD create_flags_b;
896 BOOL create_todo_b;
897 BOOL equal;
898 BOOL todo;
899 } uri_equality;
901 static const uri_equality equality_tests[] = {
903 "HTTP://www.winehq.org/test dir/./",0,FALSE,
904 "http://www.winehq.org/test dir/../test dir/",0,FALSE,
905 TRUE, TRUE
908 /* http://www.winehq.org/test%20dir */
909 "http://%77%77%77%2E%77%69%6E%65%68%71%2E%6F%72%67/%74%65%73%74%20%64%69%72",0,FALSE,
910 "http://www.winehq.org/test dir",0,FALSE,
911 TRUE, TRUE,
914 "c:\\test.mp3",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME,FALSE,
915 "file:///c:/test.mp3",0,FALSE,
916 TRUE,TRUE
919 "ftp://ftp.winehq.org/",0,FALSE,
920 "ftp://ftp.winehq.org",0,FALSE,
921 TRUE, TRUE
924 "ftp://ftp.winehq.org/test/test2/../../testB/",0,FALSE,
925 "ftp://ftp.winehq.org/t%45stB/",0,FALSE,
926 FALSE, TRUE
930 static inline LPWSTR a2w(LPCSTR str) {
931 LPWSTR ret = NULL;
933 if(str) {
934 DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
935 ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
936 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
939 return ret;
942 static inline BOOL heap_free(void* mem) {
943 return HeapFree(GetProcessHeap(), 0, mem);
946 static inline DWORD strcmp_aw(LPCSTR strA, LPCWSTR strB) {
947 LPWSTR strAW = a2w(strA);
948 DWORD ret = lstrcmpW(strAW, strB);
949 heap_free(strAW);
950 return ret;
954 * Simple tests to make sure the CreateUri function handles invalid flag combinations
955 * correctly.
957 static void test_CreateUri_InvalidFlags(void) {
958 DWORD i;
960 for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
961 HRESULT hr;
962 IUri *uri = (void*) 0xdeadbeef;
964 hr = pCreateUri(http_urlW, invalid_flag_tests[i].flags, 0, &uri);
965 todo_wine {
966 ok(hr == invalid_flag_tests[i].expected, "Error: CreateUri returned 0x%08x, expected 0x%08x, flags=0x%08x\n",
967 hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
969 todo_wine { ok(uri == NULL, "Error: expected the IUri to be NULL, but it was %p instead\n", uri); }
973 static void test_CreateUri_InvalidArgs(void) {
974 HRESULT hr;
975 IUri *uri = (void*) 0xdeadbeef;
977 const WCHAR invalidW[] = {'i','n','v','a','l','i','d',0};
979 hr = pCreateUri(http_urlW, 0, 0, NULL);
980 ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
982 hr = pCreateUri(NULL, 0, 0, &uri);
983 ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
984 ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
986 uri = (void*) 0xdeadbeef;
987 hr = pCreateUri(invalidW, 0, 0, &uri);
988 ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
989 ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
992 static void test_IUri_GetPropertyBSTR(void) {
993 IUri *uri = NULL;
994 HRESULT hr;
995 DWORD i;
997 /* Make sure GetPropertyBSTR handles invalid args correctly. */
998 hr = pCreateUri(http_urlW, 0, 0, &uri);
999 ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
1000 if(SUCCEEDED(hr)) {
1001 BSTR received = NULL;
1003 hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_RAW_URI, NULL, 0);
1004 ok(hr == E_POINTER, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
1006 /* Make sure it handles a invalid Uri_PROPERTY's correctly. */
1007 hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_PORT, &received, 0);
1008 ok(hr == S_OK, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
1009 ok(received != NULL, "Error: Expected the string not to be NULL.\n");
1010 ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
1011 SysFreeString(received);
1013 /* Make sure it handles the ZONE property correctly. */
1014 received = NULL;
1015 hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_ZONE, &received, 0);
1016 ok(hr == S_FALSE, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_FALSE);
1017 ok(received != NULL, "Error: Expected the string not to be NULL.\n");
1018 ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
1019 SysFreeString(received);
1021 if(uri) IUri_Release(uri);
1023 for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
1024 uri_properties test = uri_tests[i];
1025 LPWSTR uriW;
1026 uri = NULL;
1028 uriW = a2w(test.uri);
1029 hr = pCreateUri(uriW, test.create_flags, 0, &uri);
1030 if(test.create_todo) {
1031 todo_wine {
1032 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
1033 hr, test.create_expected, i);
1035 } else {
1036 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
1037 hr, test.create_expected, i);
1040 if(SUCCEEDED(hr)) {
1041 DWORD j;
1043 /* Checks all the string properties of the uri. */
1044 for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
1045 BSTR received = NULL;
1046 uri_str_property prop = test.str_props[j];
1048 hr = IUri_GetPropertyBSTR(uri, j, &received, 0);
1049 if(prop.todo) {
1050 todo_wine {
1051 ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
1052 hr, prop.expected, i, j);
1054 todo_wine {
1055 ok(!strcmp_aw(prop.value, received), "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
1056 prop.value, wine_dbgstr_w(received), i, j);
1058 } else {
1059 ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
1060 hr, prop.expected, i, j);
1061 ok(!strcmp_aw(prop.value, received), "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
1062 prop.value, wine_dbgstr_w(received), i, j);
1065 SysFreeString(received);
1069 if(uri) IUri_Release(uri);
1071 heap_free(uriW);
1075 static void test_IUri_GetPropertyDWORD(void) {
1076 IUri *uri = NULL;
1077 HRESULT hr;
1078 DWORD i;
1080 hr = pCreateUri(http_urlW, 0, 0, &uri);
1081 ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
1082 if(SUCCEEDED(hr)) {
1083 DWORD received = 0xdeadbeef;
1085 hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_DWORD_START, NULL, 0);
1086 ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
1088 hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_ABSOLUTE_URI, &received, 0);
1089 ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
1090 ok(received == 0, "Error: Expected received=%d but instead received=%d.\n", 0, received);
1092 if(uri) IUri_Release(uri);
1094 for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
1095 uri_properties test = uri_tests[i];
1096 LPWSTR uriW;
1097 uri = NULL;
1099 uriW = a2w(test.uri);
1100 hr = pCreateUri(uriW, test.create_flags, 0, &uri);
1101 if(test.create_todo) {
1102 todo_wine {
1103 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
1104 hr, test.create_expected, i);
1106 } else {
1107 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
1108 hr, test.create_expected, i);
1111 if(SUCCEEDED(hr)) {
1112 DWORD j;
1114 /* Checks all the DWORD properties of the uri. */
1115 for(j = 0; j < sizeof(test.dword_props)/sizeof(test.dword_props[0]); ++j) {
1116 DWORD received;
1117 uri_dword_property prop = test.dword_props[j];
1119 hr = IUri_GetPropertyDWORD(uri, j+Uri_PROPERTY_DWORD_START, &received, 0);
1120 if(prop.todo) {
1121 todo_wine {
1122 ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
1123 hr, prop.expected, i, j);
1125 todo_wine {
1126 ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
1127 prop.value, received, i, j);
1129 } else {
1130 ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
1131 hr, prop.expected, i, j);
1132 ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
1133 prop.value, received, i, j);
1138 if(uri) IUri_Release(uri);
1140 heap_free(uriW);
1144 /* Tests all the 'Get*' property functions which deal with strings. */
1145 static void test_IUri_GetStrProperties(void) {
1146 IUri *uri = NULL;
1147 HRESULT hr;
1148 DWORD i;
1150 /* Make sure all the 'Get*' string property functions handle invalid args correctly. */
1151 hr = pCreateUri(http_urlW, 0, 0, &uri);
1152 ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
1153 if(SUCCEEDED(hr)) {
1154 hr = IUri_GetAbsoluteUri(uri, NULL);
1155 ok(hr == E_POINTER, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
1157 hr = IUri_GetAuthority(uri, NULL);
1158 ok(hr == E_POINTER, "Error: GetAuthority returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
1160 hr = IUri_GetDisplayUri(uri, NULL);
1161 ok(hr == E_POINTER, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
1163 hr = IUri_GetDomain(uri, NULL);
1164 ok(hr == E_POINTER, "Error: GetDomain returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
1166 hr = IUri_GetExtension(uri, NULL);
1167 ok(hr == E_POINTER, "Error: GetExtension returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
1169 hr = IUri_GetFragment(uri, NULL);
1170 ok(hr == E_POINTER, "Error: GetFragment returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
1172 hr = IUri_GetHost(uri, NULL);
1173 ok(hr == E_POINTER, "Error: GetHost returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
1175 hr = IUri_GetPassword(uri, NULL);
1176 ok(hr == E_POINTER, "Error: GetPassword returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
1178 hr = IUri_GetPath(uri, NULL);
1179 ok(hr == E_POINTER, "Error: GetPath returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
1181 hr = IUri_GetPathAndQuery(uri, NULL);
1182 ok(hr == E_POINTER, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
1184 hr = IUri_GetQuery(uri, NULL);
1185 ok(hr == E_POINTER, "Error: GetQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
1187 hr = IUri_GetRawUri(uri, NULL);
1188 ok(hr == E_POINTER, "Error: GetRawUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
1190 hr = IUri_GetSchemeName(uri, NULL);
1191 ok(hr == E_POINTER, "Error: GetSchemeName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
1193 hr = IUri_GetUserInfo(uri, NULL);
1194 ok(hr == E_POINTER, "Error: GetUserInfo returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
1196 hr = IUri_GetUserName(uri, NULL);
1197 ok(hr == E_POINTER, "Error: GetUserName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
1199 if(uri) IUri_Release(uri);
1201 for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
1202 uri_properties test = uri_tests[i];
1203 LPWSTR uriW;
1204 uri = NULL;
1206 uriW = a2w(test.uri);
1207 hr = pCreateUri(uriW, test.create_flags, 0, &uri);
1208 if(test.create_todo) {
1209 todo_wine {
1210 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1211 hr, test.create_expected, i);
1213 } else {
1214 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1215 hr, test.create_expected, i);
1218 if(SUCCEEDED(hr)) {
1219 uri_str_property prop;
1220 BSTR received = NULL;
1222 /* GetAbsoluteUri() tests. */
1223 prop = test.str_props[Uri_PROPERTY_ABSOLUTE_URI];
1224 hr = IUri_GetAbsoluteUri(uri, &received);
1225 if(prop.todo) {
1226 todo_wine {
1227 ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1228 hr, prop.expected, i);
1230 todo_wine {
1231 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1232 prop.value, wine_dbgstr_w(received), i);
1234 } else {
1235 ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1236 hr, prop.expected, i);
1237 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1238 prop.value, wine_dbgstr_w(received), i);
1240 SysFreeString(received);
1241 received = NULL;
1243 /* GetAuthority() tests. */
1244 prop = test.str_props[Uri_PROPERTY_AUTHORITY];
1245 hr = IUri_GetAuthority(uri, &received);
1246 if(prop.todo) {
1247 todo_wine {
1248 ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1249 hr, prop.expected, i);
1251 todo_wine {
1252 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1253 prop.value, wine_dbgstr_w(received), i);
1255 } else {
1256 ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1257 hr, prop.expected, i);
1258 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1259 prop.value, wine_dbgstr_w(received), i);
1261 SysFreeString(received);
1262 received = NULL;
1264 /* GetDisplayUri() tests. */
1265 prop = test.str_props[Uri_PROPERTY_DISPLAY_URI];
1266 hr = IUri_GetDisplayUri(uri, &received);
1267 if(prop.todo) {
1268 todo_wine {
1269 ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1270 hr, prop.expected, i);
1272 todo_wine {
1273 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_test[%d].\n",
1274 prop.value, wine_dbgstr_w(received), i);
1276 } else {
1277 ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1278 hr, prop.expected, i);
1279 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1280 prop.value, wine_dbgstr_w(received), i);
1282 SysFreeString(received);
1283 received = NULL;
1285 /* GetDomain() tests. */
1286 prop = test.str_props[Uri_PROPERTY_DOMAIN];
1287 hr = IUri_GetDomain(uri, &received);
1288 if(prop.todo) {
1289 todo_wine {
1290 ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1291 hr, prop.expected, i);
1293 todo_wine {
1294 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1295 prop.value, wine_dbgstr_w(received), i);
1297 } else {
1298 ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1299 hr, prop.expected, i);
1300 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1301 prop.value, wine_dbgstr_w(received), i);
1303 SysFreeString(received);
1304 received = NULL;
1306 /* GetExtension() tests. */
1307 prop = test.str_props[Uri_PROPERTY_EXTENSION];
1308 hr = IUri_GetExtension(uri, &received);
1309 if(prop.todo) {
1310 todo_wine {
1311 ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1312 hr, prop.expected, i);
1314 todo_wine {
1315 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1316 prop.value, wine_dbgstr_w(received), i);
1318 } else {
1319 ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1320 hr, prop.expected, i);
1321 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1322 prop.value, wine_dbgstr_w(received), i);
1324 SysFreeString(received);
1325 received = NULL;
1327 /* GetFragment() tests. */
1328 prop = test.str_props[Uri_PROPERTY_FRAGMENT];
1329 hr = IUri_GetFragment(uri, &received);
1330 if(prop.todo) {
1331 todo_wine {
1332 ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1333 hr, prop.expected, i);
1335 todo_wine {
1336 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1337 prop.value, wine_dbgstr_w(received), i);
1339 } else {
1340 ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1341 hr, prop.expected, i);
1342 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1343 prop.value, wine_dbgstr_w(received), i);
1345 SysFreeString(received);
1346 received = NULL;
1348 /* GetHost() tests. */
1349 prop = test.str_props[Uri_PROPERTY_HOST];
1350 hr = IUri_GetHost(uri, &received);
1351 if(prop.todo) {
1352 todo_wine {
1353 ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1354 hr, prop.expected, i);
1356 todo_wine {
1357 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1358 prop.value, wine_dbgstr_w(received), i);
1360 } else {
1361 ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1362 hr, prop.expected, i);
1363 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1364 prop.value, wine_dbgstr_w(received), i);
1366 SysFreeString(received);
1367 received = NULL;
1369 /* GetPassword() tests. */
1370 prop = test.str_props[Uri_PROPERTY_PASSWORD];
1371 hr = IUri_GetPassword(uri, &received);
1372 if(prop.todo) {
1373 todo_wine {
1374 ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1375 hr, prop.expected, i);
1377 todo_wine {
1378 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1379 prop.value, wine_dbgstr_w(received), i);
1381 } else {
1382 ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1383 hr, prop.expected, i);
1384 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1385 prop.value, wine_dbgstr_w(received), i);
1387 SysFreeString(received);
1388 received = NULL;
1390 /* GetPath() tests. */
1391 prop = test.str_props[Uri_PROPERTY_PATH];
1392 hr = IUri_GetPath(uri, &received);
1393 if(prop.todo) {
1394 todo_wine {
1395 ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1396 hr, prop.expected, i);
1398 todo_wine {
1399 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1400 prop.value, wine_dbgstr_w(received), i);
1402 } else {
1403 ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1404 hr, prop.expected, i);
1405 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1406 prop.value, wine_dbgstr_w(received), i);
1408 SysFreeString(received);
1409 received = NULL;
1411 /* GetPathAndQuery() tests. */
1412 prop = test.str_props[Uri_PROPERTY_PATH_AND_QUERY];
1413 hr = IUri_GetPathAndQuery(uri, &received);
1414 if(prop.todo) {
1415 todo_wine {
1416 ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1417 hr, prop.expected, i);
1419 todo_wine {
1420 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1421 prop.value, wine_dbgstr_w(received), i);
1423 } else {
1424 ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1425 hr, prop.expected, i);
1426 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1427 prop.value, wine_dbgstr_w(received), i);
1429 SysFreeString(received);
1430 received = NULL;
1432 /* GetQuery() tests. */
1433 prop = test.str_props[Uri_PROPERTY_QUERY];
1434 hr = IUri_GetQuery(uri, &received);
1435 if(prop.todo) {
1436 todo_wine {
1437 ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1438 hr, prop.expected, i);
1440 todo_wine {
1441 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1442 prop.value, wine_dbgstr_w(received), i);
1444 } else {
1445 ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1446 hr, prop.expected, i);
1447 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1448 prop.value, wine_dbgstr_w(received), i);
1450 SysFreeString(received);
1451 received = NULL;
1453 /* GetRawUri() tests. */
1454 prop = test.str_props[Uri_PROPERTY_RAW_URI];
1455 hr = IUri_GetRawUri(uri, &received);
1456 if(prop.todo) {
1457 todo_wine {
1458 ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1459 hr, prop.expected, i);
1461 todo_wine {
1462 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1463 prop.value, wine_dbgstr_w(received), i);
1465 } else {
1466 ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1467 hr, prop.expected, i);
1468 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1469 prop.value, wine_dbgstr_w(received), i);
1471 SysFreeString(received);
1472 received = NULL;
1474 /* GetSchemeName() tests. */
1475 prop = test.str_props[Uri_PROPERTY_SCHEME_NAME];
1476 hr = IUri_GetSchemeName(uri, &received);
1477 if(prop.todo) {
1478 todo_wine {
1479 ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1480 hr, prop.expected, i);
1482 todo_wine {
1483 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1484 prop.value, wine_dbgstr_w(received), i);
1486 } else {
1487 ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1488 hr, prop.expected, i);
1489 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1490 prop.value, wine_dbgstr_w(received), i);
1492 SysFreeString(received);
1493 received = NULL;
1495 /* GetUserInfo() tests. */
1496 prop = test.str_props[Uri_PROPERTY_USER_INFO];
1497 hr = IUri_GetUserInfo(uri, &received);
1498 if(prop.todo) {
1499 todo_wine {
1500 ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1501 hr, prop.expected, i);
1503 todo_wine {
1504 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1505 prop.value, wine_dbgstr_w(received), i);
1507 } else {
1508 ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1509 hr, prop.expected, i);
1510 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1511 prop.value, wine_dbgstr_w(received), i);
1513 SysFreeString(received);
1514 received = NULL;
1516 /* GetUserName() tests. */
1517 prop = test.str_props[Uri_PROPERTY_USER_NAME];
1518 hr = IUri_GetUserName(uri, &received);
1519 if(prop.todo) {
1520 todo_wine {
1521 ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1522 hr, prop.expected, i);
1524 todo_wine {
1525 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1526 prop.value, wine_dbgstr_w(received), i);
1528 } else {
1529 ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1530 hr, prop.expected, i);
1531 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
1532 prop.value, wine_dbgstr_w(received), i);
1534 SysFreeString(received);
1537 if(uri) IUri_Release(uri);
1539 heap_free(uriW);
1543 static void test_IUri_GetDwordProperties(void) {
1544 IUri *uri = NULL;
1545 HRESULT hr;
1546 DWORD i;
1548 /* Make sure all the 'Get*' dword property functions handle invalid args correctly. */
1549 hr = pCreateUri(http_urlW, 0, 0, &uri);
1550 ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
1551 if(SUCCEEDED(hr)) {
1552 hr = IUri_GetHostType(uri, NULL);
1553 ok(hr == E_INVALIDARG, "Error: GetHostType returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
1555 hr = IUri_GetPort(uri, NULL);
1556 ok(hr == E_INVALIDARG, "Error: GetPort returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
1558 hr = IUri_GetScheme(uri, NULL);
1559 ok(hr == E_INVALIDARG, "Error: GetScheme returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
1561 hr = IUri_GetZone(uri, NULL);
1562 ok(hr == E_INVALIDARG, "Error: GetZone returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
1564 if(uri) IUri_Release(uri);
1566 for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
1567 uri_properties test = uri_tests[i];
1568 LPWSTR uriW;
1569 uri = NULL;
1571 uriW = a2w(test.uri);
1572 hr = pCreateUri(uriW, test.create_flags, 0, &uri);
1573 if(test.create_todo) {
1574 todo_wine {
1575 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1576 hr, test.create_expected, i);
1578 } else {
1579 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1580 hr, test.create_expected, i);
1583 if(SUCCEEDED(hr)) {
1584 uri_dword_property prop;
1585 DWORD received;
1587 /* Assign an insane value so tests don't accidentally pass when
1588 * they shouldn't!
1590 received = -9999999;
1592 /* GetHostType() tests. */
1593 prop = test.dword_props[Uri_PROPERTY_HOST_TYPE-Uri_PROPERTY_DWORD_START];
1594 hr = IUri_GetHostType(uri, &received);
1595 if(prop.todo) {
1596 todo_wine {
1597 ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1598 hr, prop.expected, i);
1600 todo_wine {
1601 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
1603 } else {
1604 ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1605 hr, prop.expected, i);
1606 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
1608 received = -9999999;
1610 /* GetPort() tests. */
1611 prop = test.dword_props[Uri_PROPERTY_PORT-Uri_PROPERTY_DWORD_START];
1612 hr = IUri_GetPort(uri, &received);
1613 if(prop.todo) {
1614 todo_wine {
1615 ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1616 hr, prop.expected, i);
1618 todo_wine {
1619 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
1621 } else {
1622 ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1623 hr, prop.expected, i);
1624 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
1626 received = -9999999;
1628 /* GetScheme() tests. */
1629 prop = test.dword_props[Uri_PROPERTY_SCHEME-Uri_PROPERTY_DWORD_START];
1630 hr = IUri_GetScheme(uri, &received);
1631 if(prop.todo) {
1632 todo_wine {
1633 ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1634 hr, prop.expected, i);
1636 todo_wine {
1637 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
1639 } else {
1640 ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1641 hr, prop.expected, i);
1642 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
1644 received = -9999999;
1646 /* GetZone() tests. */
1647 prop = test.dword_props[Uri_PROPERTY_ZONE-Uri_PROPERTY_DWORD_START];
1648 hr = IUri_GetZone(uri, &received);
1649 if(prop.todo) {
1650 todo_wine {
1651 ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1652 hr, prop.expected, i);
1654 todo_wine {
1655 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
1657 } else {
1658 ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1659 hr, prop.expected, i);
1660 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
1664 if(uri) IUri_Release(uri);
1666 heap_free(uriW);
1670 static void test_IUri_GetPropertyLength(void) {
1671 IUri *uri = NULL;
1672 HRESULT hr;
1673 DWORD i;
1675 /* Make sure it handles invalid args correctly. */
1676 hr = pCreateUri(http_urlW, 0, 0, &uri);
1677 ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
1678 if(SUCCEEDED(hr)) {
1679 DWORD received = 0xdeadbeef;
1681 hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_STRING_START, NULL, 0);
1682 ok(hr == E_INVALIDARG, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
1684 hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_DWORD_START, &received, 0);
1685 ok(hr == E_INVALIDARG, "Error: GetPropertyLength return 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
1686 ok(received == 0xdeadbeef, "Error: Expected 0xdeadbeef but got 0x%08x.\n", received);
1688 if(uri) IUri_Release(uri);
1690 for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
1691 uri_properties test = uri_tests[i];
1692 LPWSTR uriW;
1693 uri = NULL;
1695 uriW = a2w(test.uri);
1696 hr = pCreateUri(uriW, test.create_flags, 0, &uri);
1697 if(test.create_todo) {
1698 todo_wine {
1699 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1700 hr, test.create_expected, i);
1702 } else {
1703 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_test[%d].\n",
1704 hr, test.create_expected, i);
1707 if(SUCCEEDED(hr)) {
1708 DWORD j;
1710 for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
1711 DWORD expectedLen, receivedLen;
1712 uri_str_property prop = test.str_props[j];
1714 expectedLen = lstrlen(prop.value);
1716 /* This won't be necessary once GetPropertyLength is implemented. */
1717 receivedLen = -1;
1719 hr = IUri_GetPropertyLength(uri, j, &receivedLen, 0);
1720 if(prop.todo) {
1721 todo_wine {
1722 ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
1723 hr, prop.expected, i, j);
1725 todo_wine {
1726 ok(receivedLen == expectedLen, "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
1727 expectedLen, receivedLen, i, j);
1729 } else {
1730 ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
1731 hr, prop.expected, i, j);
1732 ok(receivedLen == expectedLen, "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
1733 expectedLen, receivedLen, i, j);
1738 if(uri) IUri_Release(uri);
1740 heap_free(uriW);
1744 static void test_IUri_GetProperties(void) {
1745 IUri *uri = NULL;
1746 HRESULT hr;
1747 DWORD i;
1749 hr = pCreateUri(http_urlW, 0, 0, &uri);
1750 ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
1751 if(SUCCEEDED(hr)) {
1752 hr = IUri_GetProperties(uri, NULL);
1753 ok(hr == E_INVALIDARG, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
1755 if(uri) IUri_Release(uri);
1757 for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
1758 uri_properties test = uri_tests[i];
1759 LPWSTR uriW;
1760 uri = NULL;
1762 uriW = a2w(test.uri);
1763 hr = pCreateUri(uriW, test.create_flags, 0, &uri);
1764 if(test.create_todo) {
1765 todo_wine {
1766 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
1768 } else {
1769 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
1772 if(SUCCEEDED(hr)) {
1773 DWORD received = 0;
1774 DWORD j;
1776 hr = IUri_GetProperties(uri, &received);
1777 if(test.props_todo) {
1778 todo_wine {
1779 ok(hr == S_OK, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
1781 } else {
1782 ok(hr == S_OK, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
1785 for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
1786 /* (1 << j) converts a Uri_PROPERTY to its corresponding Uri_HAS_* flag mask. */
1787 if(test.props & (1 << j)) {
1788 if(test.props_todo) {
1789 todo_wine {
1790 ok(received & (1 << j), "Error: Expected flag for property %d on uri_tests[%d].\n", j, i);
1792 } else {
1793 ok(received & (1 << j), "Error: Expected flag for property %d on uri_tests[%d].\n", j, i);
1795 } else {
1796 /* NOTE: Since received is initialized to 0, this test will always pass while
1797 * GetProperties is unimplemented.
1799 ok(!(received & (1 << j)), "Error: Received flag for property %d when not expected on uri_tests[%d].\n", j, i);
1804 if(uri) IUri_Release(uri);
1806 heap_free(uriW);
1810 static void test_IUri_HasProperty(void) {
1811 IUri *uri = NULL;
1812 HRESULT hr;
1813 DWORD i;
1815 hr = pCreateUri(http_urlW, 0, 0, &uri);
1816 ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
1817 if(SUCCEEDED(hr)) {
1818 hr = IUri_HasProperty(uri, Uri_PROPERTY_RAW_URI, NULL);
1819 ok(hr == E_INVALIDARG, "Error: HasProperty returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
1821 if(uri) IUri_Release(uri);
1823 for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
1824 uri_properties test = uri_tests[i];
1825 LPWSTR uriW;
1826 uri = NULL;
1828 uriW = a2w(test.uri);
1830 hr = pCreateUri(uriW, test.create_flags, 0, &uri);
1831 if(test.create_todo) {
1832 todo_wine {
1833 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
1835 } else {
1836 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
1839 if(SUCCEEDED(hr)) {
1840 DWORD j;
1842 for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
1843 /* Assign -1, then explicitly test for TRUE or FALSE later. */
1844 BOOL received = -1;
1846 hr = IUri_HasProperty(uri, j, &received);
1847 if(test.props_todo) {
1848 todo_wine {
1849 ok(hr == S_OK, "Error: HasProperty returned 0x%08x, expected 0x%08x for property %d on uri_tests[%d].\n",
1850 hr, S_OK, j, i);
1853 /* Check if the property should be true. */
1854 if(test.props & (1 << j)) {
1855 todo_wine {
1856 ok(received == TRUE, "Error: Expected to have property %d on uri_tests[%d].\n", j, i);
1858 } else {
1859 todo_wine {
1860 ok(received == FALSE, "Error: Wasn't expecting to have property %d on uri_tests[%d].\n", j, i);
1863 } else {
1864 ok(hr == S_OK, "Error: HasProperty returned 0x%08x, expected 0x%08x for property %d on uri_tests[%d].\n",
1865 hr, S_OK, j, i);
1867 if(test.props & (1 << j)) {
1868 ok(received == TRUE, "Error: Expected to have property %d on uri_tests[%d].\n", j, i);
1869 } else {
1870 ok(received == FALSE, "Error: Wasn't expecting to have property %d on uri_tests[%d].\n", j, i);
1876 if(uri) IUri_Release(uri);
1878 heap_free(uriW);
1882 static void test_IUri_IsEqual(void) {
1883 IUri *uriA, *uriB;
1884 HRESULT hrA, hrB;
1885 DWORD i;
1887 uriA = uriB = NULL;
1889 /* Make sure IsEqual handles invalid args correctly. */
1890 hrA = pCreateUri(http_urlW, 0, 0, &uriA);
1891 hrB = pCreateUri(http_urlW, 0, 0, &uriB);
1892 ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hrA, S_OK);
1893 ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hrB, S_OK);
1894 if(SUCCEEDED(hrA) && SUCCEEDED(hrB)) {
1895 BOOL equal = -1;
1896 hrA = IUri_IsEqual(uriA, NULL, &equal);
1897 ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hrA, S_OK);
1898 ok(equal == FALSE, "Error: Expected equal to be FALSE, but was %d instead.\n", equal);
1900 hrA = IUri_IsEqual(uriA, uriB, NULL);
1901 ok(hrA == E_POINTER, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hrA, E_POINTER);
1903 if(uriA) IUri_Release(uriA);
1904 if(uriB) IUri_Release(uriB);
1906 for(i = 0; i < sizeof(equality_tests)/sizeof(equality_tests[0]); ++i) {
1907 uri_equality test = equality_tests[i];
1908 LPWSTR uriA_W, uriB_W;
1910 uriA = uriB = NULL;
1912 uriA_W = a2w(test.a);
1913 uriB_W = a2w(test.b);
1915 hrA = pCreateUri(uriA_W, test.create_flags_a, 0, &uriA);
1916 if(test.create_todo_a) {
1917 todo_wine {
1918 ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n",
1919 hrA, S_OK, i);
1921 } else {
1922 ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n",
1923 hrA, S_OK, i);
1926 hrB = pCreateUri(uriB_W, test.create_flags_b, 0, &uriB);
1927 if(test.create_todo_b) {
1928 todo_wine {
1929 ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n",
1930 hrB, S_OK, i);
1932 } else {
1933 ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n",
1934 hrB, S_OK, i);
1937 if(SUCCEEDED(hrA) && SUCCEEDED(hrB)) {
1938 BOOL equal = -1;
1940 hrA = IUri_IsEqual(uriA, uriB, &equal);
1941 if(test.todo) {
1942 todo_wine {
1943 ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n",
1944 hrA, S_OK, i);
1946 todo_wine {
1947 ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
1949 } else {
1950 ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n", hrA, S_OK, i);
1951 ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
1954 if(uriA) IUri_Release(uriA);
1955 if(uriB) IUri_Release(uriB);
1957 heap_free(uriA_W);
1958 heap_free(uriB_W);
1962 START_TEST(uri) {
1963 HMODULE hurlmon;
1965 hurlmon = GetModuleHandle("urlmon.dll");
1966 pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri");
1968 if(!pCreateUri) {
1969 win_skip("CreateUri is not present, skipping tests.\n");
1970 return;
1973 trace("test CreateUri invalid flags...\n");
1974 test_CreateUri_InvalidFlags();
1976 trace("test CreateUri invalid args...\n");
1977 test_CreateUri_InvalidArgs();
1979 trace("test IUri_GetPropertyBSTR...\n");
1980 test_IUri_GetPropertyBSTR();
1982 trace("test IUri_GetPropertyDWORD...\n");
1983 test_IUri_GetPropertyDWORD();
1985 trace("test IUri_GetStrProperties...\n");
1986 test_IUri_GetStrProperties();
1988 trace("test IUri_GetDwordProperties...\n");
1989 test_IUri_GetDwordProperties();
1991 trace("test IUri_GetPropertyLength...\n");
1992 test_IUri_GetPropertyLength();
1994 trace("test IUri_GetProperties...\n");
1995 test_IUri_GetProperties();
1997 trace("test IUri_HasProperty...\n");
1998 test_IUri_HasProperty();
2000 trace("test IUri_IsEqual...\n");
2001 test_IUri_IsEqual();