hlink: Convert dll registration to the IRegistrar mechanism.
[wine] / dlls / urlmon / tests / uri.c
1 /*
2  * UrlMon IUri tests
3  *
4  * Copyright 2010 Thomas Mullaly
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include <wine/test.h>
22 #include <stdarg.h>
23 #include <stddef.h>
24
25 #define COBJMACROS
26 #define CONST_VTABLE
27
28 #include "windef.h"
29 #include "winbase.h"
30 #include "urlmon.h"
31 #include "shlwapi.h"
32 #include "wininet.h"
33 #include "strsafe.h"
34
35 #define URI_STR_PROPERTY_COUNT Uri_PROPERTY_STRING_LAST+1
36 #define URI_DWORD_PROPERTY_COUNT (Uri_PROPERTY_DWORD_LAST - Uri_PROPERTY_DWORD_START)+1
37 #define URI_BUILDER_STR_PROPERTY_COUNT 7
38
39 #define DEFINE_EXPECT(func) \
40     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
41
42 #define SET_EXPECT(func) \
43     expect_ ## func = TRUE
44
45 #define CHECK_EXPECT(func) \
46     do { \
47         ok(expect_ ##func, "unexpected call " #func "\n"); \
48         expect_ ## func = FALSE; \
49         called_ ## func = TRUE; \
50     }while(0)
51
52 #define CHECK_EXPECT2(func) \
53     do { \
54         ok(expect_ ##func, "unexpected call " #func "\n"); \
55         called_ ## func = TRUE; \
56     }while(0)
57
58 #define CHECK_CALLED(func) \
59     do { \
60         ok(called_ ## func, "expected " #func "\n"); \
61         expect_ ## func = called_ ## func = FALSE; \
62     }while(0)
63
64 DEFINE_EXPECT(CombineUrl);
65
66 static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**);
67 static HRESULT (WINAPI *pCreateUriWithFragment)(LPCWSTR, LPCWSTR, DWORD, DWORD_PTR, IUri**);
68 static HRESULT (WINAPI *pCreateIUriBuilder)(IUri*, DWORD, DWORD_PTR, IUriBuilder**);
69 static HRESULT (WINAPI *pCoInternetCombineIUri)(IUri*,IUri*,DWORD,IUri**,DWORD_PTR);
70 static HRESULT (WINAPI *pCoInternetGetSession)(DWORD,IInternetSession**,DWORD);
71 static HRESULT (WINAPI *pCoInternetCombineUrlEx)(IUri*,LPCWSTR,DWORD,IUri**,DWORD_PTR);
72 static HRESULT (WINAPI *pCoInternetParseIUri)(IUri*,PARSEACTION,DWORD,LPWSTR,DWORD,DWORD*,DWORD_PTR);
73
74 static const WCHAR http_urlW[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
75         '.','o','r','g','/',0};
76 static const WCHAR http_url_fragW[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
77         '.','o','r','g','/','#','F','r','a','g',0};
78
79 static const WCHAR combine_baseW[] = {'w','i','n','e','t','e','s','t',':','?','t',
80         'e','s','t','i','n','g',0};
81 static const WCHAR combine_relativeW[] = {'?','t','e','s','t',0};
82 static const WCHAR combine_resultW[] = {'z','i','p',':','t','e','s','t',0};
83
84 static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0};
85
86 typedef struct _uri_create_flag_test {
87     DWORD   flags;
88     HRESULT expected;
89 } uri_create_flag_test;
90
91 static const uri_create_flag_test invalid_flag_tests[] = {
92     /* Set of invalid flag combinations to test for. */
93     {Uri_CREATE_DECODE_EXTRA_INFO | Uri_CREATE_NO_DECODE_EXTRA_INFO, E_INVALIDARG},
94     {Uri_CREATE_CANONICALIZE | Uri_CREATE_NO_CANONICALIZE, E_INVALIDARG},
95     {Uri_CREATE_CRACK_UNKNOWN_SCHEMES | Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, E_INVALIDARG},
96     {Uri_CREATE_PRE_PROCESS_HTML_URI | Uri_CREATE_NO_PRE_PROCESS_HTML_URI, E_INVALIDARG},
97     {Uri_CREATE_IE_SETTINGS | Uri_CREATE_NO_IE_SETTINGS, E_INVALIDARG}
98 };
99
100 typedef struct _uri_str_property {
101     const char* value;
102     HRESULT     expected;
103     BOOL        todo;
104     const char* broken_value;
105 } uri_str_property;
106
107 typedef struct _uri_dword_property {
108     DWORD   value;
109     HRESULT expected;
110     BOOL    todo;
111 } uri_dword_property;
112
113 typedef struct _uri_properties {
114     const char*         uri;
115     DWORD               create_flags;
116     HRESULT             create_expected;
117     BOOL                create_todo;
118
119     uri_str_property    str_props[URI_STR_PROPERTY_COUNT];
120     uri_dword_property  dword_props[URI_DWORD_PROPERTY_COUNT];
121 } uri_properties;
122
123 static const uri_properties uri_tests[] = {
124     {   "http://www.winehq.org/tests/../tests/../..", 0, S_OK, FALSE,
125         {
126             {"http://www.winehq.org/",S_OK,FALSE},                      /* ABSOLUTE_URI */
127             {"www.winehq.org",S_OK,FALSE},                              /* AUTHORITY */
128             {"http://www.winehq.org/",S_OK,FALSE},                      /* DISPLAY_URI */
129             {"winehq.org",S_OK,FALSE},                                  /* DOMAIN */
130             {"",S_FALSE,FALSE},                                         /* EXTENSION */
131             {"",S_FALSE,FALSE},                                         /* FRAGMENT */
132             {"www.winehq.org",S_OK,FALSE},                              /* HOST */
133             {"",S_FALSE,FALSE},                                         /* PASSWORD */
134             {"/",S_OK,FALSE},                                           /* PATH */
135             {"/",S_OK,FALSE},                                           /* PATH_AND_QUERY */
136             {"",S_FALSE,FALSE},                                         /* QUERY */
137             {"http://www.winehq.org/tests/../tests/../..",S_OK,FALSE},  /* RAW_URI */
138             {"http",S_OK,FALSE},                                        /* SCHEME_NAME */
139             {"",S_FALSE,FALSE},                                         /* USER_INFO */
140             {"",S_FALSE,FALSE}                                          /* USER_NAME */
141         },
142         {
143             {Uri_HOST_DNS,S_OK,FALSE},                                  /* HOST_TYPE */
144             {80,S_OK,FALSE},                                            /* PORT */
145             {URL_SCHEME_HTTP,S_OK,FALSE},                               /* SCHEME */
146             {URLZONE_INVALID,E_NOTIMPL,FALSE}                           /* ZONE */
147         }
148     },
149     {   "http://winehq.org/tests/.././tests", 0, S_OK, FALSE,
150         {
151             {"http://winehq.org/tests",S_OK,FALSE},
152             {"winehq.org",S_OK,FALSE},
153             {"http://winehq.org/tests",S_OK,FALSE},
154             {"winehq.org",S_OK,FALSE},
155             {"",S_FALSE,FALSE},
156             {"",S_FALSE,FALSE},
157             {"winehq.org",S_OK,FALSE},
158             {"",S_FALSE,FALSE},
159             {"/tests",S_OK,FALSE},
160             {"/tests",S_OK,FALSE},
161             {"",S_FALSE,FALSE},
162             {"http://winehq.org/tests/.././tests",S_OK,FALSE},
163             {"http",S_OK,FALSE},
164             {"",S_FALSE,FALSE},
165             {"",S_FALSE,FALSE}
166         },
167         {
168             {Uri_HOST_DNS,S_OK,FALSE},
169             {80,S_OK,FALSE},
170             {URL_SCHEME_HTTP,S_OK,FALSE},
171             {URLZONE_INVALID,E_NOTIMPL,FALSE}
172         }
173     },
174     {   "HtTp://www.winehq.org/tests/..?query=x&return=y", 0, S_OK, FALSE,
175         {
176             {"http://www.winehq.org/?query=x&return=y",S_OK,FALSE},
177             {"www.winehq.org",S_OK,FALSE},
178             {"http://www.winehq.org/?query=x&return=y",S_OK,FALSE},
179             {"winehq.org",S_OK,FALSE},
180             {"",S_FALSE,FALSE},
181             {"",S_FALSE,FALSE},
182             {"www.winehq.org",S_OK,FALSE},
183             {"",S_FALSE,FALSE},
184             {"/",S_OK,FALSE},
185             {"/?query=x&return=y",S_OK,FALSE},
186             {"?query=x&return=y",S_OK,FALSE},
187             {"HtTp://www.winehq.org/tests/..?query=x&return=y",S_OK,FALSE},
188             {"http",S_OK,FALSE},
189             {"",S_FALSE,FALSE},
190             {"",S_FALSE,FALSE}
191         },
192         {
193             {Uri_HOST_DNS,S_OK,FALSE},
194             {80,S_OK,FALSE},
195             {URL_SCHEME_HTTP,S_OK,FALSE},
196             {URLZONE_INVALID,E_NOTIMPL,FALSE},
197         }
198     },
199     {   "hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters", 0, S_OK, FALSE,
200         {
201             {"http://usEr%3Ainfo@example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
202             {"usEr%3Ainfo@example.com",S_OK,FALSE},
203             {"http://example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
204             {"example.com",S_OK,FALSE},
205             {"",S_FALSE,FALSE},
206             {"",S_FALSE,FALSE},
207             {"example.com",S_OK,FALSE},
208             {"",S_FALSE,FALSE},
209             {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
210             {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
211             {"",S_FALSE,FALSE},
212             {"hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters",S_OK,FALSE},
213             {"http",S_OK,FALSE},
214             {"usEr%3Ainfo",S_OK,FALSE},
215             {"usEr%3Ainfo",S_OK,FALSE}
216         },
217         {
218             {Uri_HOST_DNS,S_OK,FALSE},
219             {80,S_OK,FALSE},
220             {URL_SCHEME_HTTP,S_OK,FALSE},
221             {URLZONE_INVALID,E_NOTIMPL,FALSE},
222         }
223     },
224     {   "ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt", 0, S_OK, FALSE,
225         {
226             {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK,FALSE},
227             {"winepass:wine@ftp.winehq.org:9999",S_OK,FALSE},
228             {"ftp://ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK,FALSE},
229             {"winehq.org",S_OK,FALSE},
230             {".txt",S_OK,FALSE},
231             {"",S_FALSE,FALSE},
232             {"ftp.winehq.org",S_OK,FALSE},
233             {"wine",S_OK,FALSE},
234             {"/dir/foo%20bar.txt",S_OK,FALSE},
235             {"/dir/foo%20bar.txt",S_OK,FALSE},
236             {"",S_FALSE,FALSE},
237             {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt",S_OK,FALSE},
238             {"ftp",S_OK,FALSE},
239             {"winepass:wine",S_OK,FALSE},
240             {"winepass",S_OK,FALSE}
241         },
242         {
243             {Uri_HOST_DNS,S_OK,FALSE},
244             {9999,S_OK,FALSE},
245             {URL_SCHEME_FTP,S_OK,FALSE},
246             {URLZONE_INVALID,E_NOTIMPL,FALSE}
247         }
248     },
249     {   "file://c:\\tests\\../tests/foo%20bar.mp3", 0, S_OK, FALSE,
250         {
251             {"file:///c:/tests/foo%2520bar.mp3",S_OK,FALSE},
252             {"",S_FALSE,FALSE},
253             {"file:///c:/tests/foo%2520bar.mp3",S_OK,FALSE},
254             {"",S_FALSE,FALSE},
255             {".mp3",S_OK,FALSE},
256             {"",S_FALSE,FALSE},
257             {"",S_FALSE,FALSE},
258             {"",S_FALSE,FALSE},
259             {"/c:/tests/foo%2520bar.mp3",S_OK,FALSE},
260             {"/c:/tests/foo%2520bar.mp3",S_OK,FALSE},
261             {"",S_FALSE,FALSE},
262             {"file://c:\\tests\\../tests/foo%20bar.mp3",S_OK,FALSE},
263             {"file",S_OK,FALSE},
264             {"",S_FALSE,FALSE},
265             {"",S_FALSE,FALSE}
266         },
267         {
268             {Uri_HOST_UNKNOWN,S_OK,FALSE},
269             {0,S_FALSE,FALSE},
270             {URL_SCHEME_FILE,S_OK,FALSE},
271             {URLZONE_INVALID,E_NOTIMPL,FALSE}
272         }
273     },
274     {   "FILE://localhost/test dir\\../tests/test%20file.README.txt", 0, S_OK, FALSE,
275         {
276             {"file:///tests/test%20file.README.txt",S_OK,FALSE},
277             {"",S_FALSE,FALSE},
278             {"file:///tests/test%20file.README.txt",S_OK,FALSE},
279             {"",S_FALSE,FALSE},
280             {".txt",S_OK,FALSE},
281             {"",S_FALSE,FALSE},
282             {"",S_FALSE,FALSE},
283             {"",S_FALSE,FALSE},
284             {"/tests/test%20file.README.txt",S_OK,FALSE},
285             {"/tests/test%20file.README.txt",S_OK,FALSE},
286             {"",S_FALSE,FALSE},
287             {"FILE://localhost/test dir\\../tests/test%20file.README.txt",S_OK,FALSE},
288             {"file",S_OK,FALSE},
289             {"",S_FALSE,FALSE},
290             {"",S_FALSE,FALSE}
291         },
292         {
293             {Uri_HOST_UNKNOWN,S_OK,FALSE},
294             {0,S_FALSE,FALSE},
295             {URL_SCHEME_FILE,S_OK,FALSE},
296             {URLZONE_INVALID,E_NOTIMPL,FALSE}
297         }
298     },
299     {   "urn:nothing:should:happen here", 0, S_OK, FALSE,
300         {
301             {"urn:nothing:should:happen here",S_OK,FALSE},
302             {"",S_FALSE,FALSE},
303             {"urn:nothing:should:happen here",S_OK,FALSE},
304             {"",S_FALSE,FALSE},
305             {"",S_FALSE,FALSE},
306             {"",S_FALSE,FALSE},
307             {"",S_FALSE,FALSE},
308             {"",S_FALSE,FALSE},
309             {"nothing:should:happen here",S_OK,FALSE},
310             {"nothing:should:happen here",S_OK,FALSE},
311             {"",S_FALSE,FALSE},
312             {"urn:nothing:should:happen here",S_OK,FALSE},
313             {"urn",S_OK,FALSE},
314             {"",S_FALSE,FALSE},
315             {"",S_FALSE,FALSE}
316         },
317         {
318             {Uri_HOST_UNKNOWN,S_OK,FALSE},
319             {0,S_FALSE,FALSE},
320             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
321             {URLZONE_INVALID,E_NOTIMPL,FALSE}
322         }
323     },
324     {   "http://127.0.0.1/tests/../test dir/./test.txt", 0, S_OK, FALSE,
325         {
326             {"http://127.0.0.1/test%20dir/test.txt",S_OK,FALSE},
327             {"127.0.0.1",S_OK,FALSE},
328             {"http://127.0.0.1/test%20dir/test.txt",S_OK,FALSE},
329             {"",S_FALSE,FALSE},
330             {".txt",S_OK,FALSE},
331             {"",S_FALSE,FALSE},
332             {"127.0.0.1",S_OK,FALSE},
333             {"",S_FALSE,FALSE},
334             {"/test%20dir/test.txt",S_OK,FALSE},
335             {"/test%20dir/test.txt",S_OK,FALSE},
336             {"",S_FALSE,FALSE},
337             {"http://127.0.0.1/tests/../test dir/./test.txt",S_OK,FALSE},
338             {"http",S_OK,FALSE},
339             {"",S_FALSE,FALSE},
340             {"",S_FALSE,FALSE}
341         },
342         {
343             {Uri_HOST_IPV4,S_OK,FALSE},
344             {80,S_OK,FALSE},
345             {URL_SCHEME_HTTP,S_OK,FALSE},
346             {URLZONE_INVALID,E_NOTIMPL,FALSE}
347         }
348     },
349     {   "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", 0, S_OK, FALSE,
350         {
351             {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,FALSE},
352             {"[fedc:ba98:7654:3210:fedc:ba98:7654:3210]",S_OK,FALSE},
353             {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,FALSE},
354             {"",S_FALSE,FALSE},
355             {"",S_FALSE,FALSE},
356             {"",S_FALSE,FALSE},
357             {"fedc:ba98:7654:3210:fedc:ba98:7654:3210",S_OK,FALSE},
358             {"",S_FALSE,FALSE},
359             {"/",S_OK,FALSE},
360             {"/",S_OK,FALSE},
361             {"",S_FALSE,FALSE},
362             {"http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]",S_OK,FALSE},
363             {"http",S_OK,FALSE},
364             {"",S_FALSE,FALSE},
365             {"",S_FALSE,FALSE}
366         },
367         {
368             {Uri_HOST_IPV6,S_OK,FALSE},
369             {80,S_OK,FALSE},
370             {URL_SCHEME_HTTP,S_OK,FALSE},
371             {URLZONE_INVALID,E_NOTIMPL,FALSE}
372         }
373     },
374     {   "ftp://[::13.1.68.3]", 0, S_OK, FALSE,
375         {
376             {"ftp://[::13.1.68.3]/",S_OK,FALSE},
377             {"[::13.1.68.3]",S_OK,FALSE},
378             {"ftp://[::13.1.68.3]/",S_OK,FALSE},
379             {"",S_FALSE,FALSE},
380             {"",S_FALSE,FALSE},
381             {"",S_FALSE,FALSE},
382             {"::13.1.68.3",S_OK,FALSE},
383             {"",S_FALSE,FALSE},
384             {"/",S_OK,FALSE},
385             {"/",S_OK,FALSE},
386             {"",S_FALSE,FALSE},
387             {"ftp://[::13.1.68.3]",S_OK,FALSE},
388             {"ftp",S_OK,FALSE},
389             {"",S_FALSE,FALSE},
390             {"",S_FALSE,FALSE}
391         },
392         {
393             {Uri_HOST_IPV6,S_OK,FALSE},
394             {21,S_OK,FALSE},
395             {URL_SCHEME_FTP,S_OK,FALSE},
396             {URLZONE_INVALID,E_NOTIMPL,FALSE}
397         }
398     },
399     {   "http://[FEDC:BA98:0:0:0:0:0:3210]", 0, S_OK, FALSE,
400         {
401             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
402             {"[fedc:ba98::3210]",S_OK,FALSE},
403             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
404             {"",S_FALSE,FALSE},
405             {"",S_FALSE,FALSE},
406             {"",S_FALSE,FALSE},
407             {"fedc:ba98::3210",S_OK,FALSE},
408             {"",S_FALSE,FALSE},
409             {"/",S_OK,FALSE},
410             {"/",S_OK,FALSE},
411             {"",S_FALSE,FALSE},
412             {"http://[FEDC:BA98:0:0:0:0:0:3210]",S_OK,FALSE},
413             {"http",S_OK,FALSE},
414             {"",S_FALSE,FALSE},
415             {"",S_FALSE,FALSE},
416         },
417         {
418             {Uri_HOST_IPV6,S_OK,FALSE},
419             {80,S_OK,FALSE},
420             {URL_SCHEME_HTTP,S_OK,FALSE},
421             {URLZONE_INVALID,E_NOTIMPL,FALSE}
422         }
423     },
424     {   "1234://www.winehq.org", 0, S_OK, FALSE,
425         {
426             {"1234://www.winehq.org/",S_OK,FALSE},
427             {"www.winehq.org",S_OK,FALSE},
428             {"1234://www.winehq.org/",S_OK,FALSE},
429             {"winehq.org",S_OK,FALSE},
430             {"",S_FALSE,FALSE},
431             {"",S_FALSE,FALSE},
432             {"www.winehq.org",S_OK,FALSE},
433             {"",S_FALSE,FALSE},
434             {"/",S_OK,FALSE},
435             {"/",S_OK,FALSE},
436             {"",S_FALSE,FALSE},
437             {"1234://www.winehq.org",S_OK,FALSE},
438             {"1234",S_OK,FALSE},
439             {"",S_FALSE,FALSE},
440             {"",S_FALSE,FALSE}
441         },
442         {
443             {Uri_HOST_DNS,S_OK,FALSE},
444             {0,S_FALSE,FALSE},
445             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
446             {URLZONE_INVALID,E_NOTIMPL,FALSE}
447         }
448     },
449     /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
450     {   "C:/test/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
451         {
452             {"file:///C:/test/test.mp3",S_OK,FALSE},
453             {"",S_FALSE,FALSE},
454             {"file:///C:/test/test.mp3",S_OK,FALSE},
455             {"",S_FALSE,FALSE},
456             {".mp3",S_OK,FALSE},
457             {"",S_FALSE,FALSE},
458             {"",S_FALSE,FALSE},
459             {"",S_FALSE,FALSE},
460             {"/C:/test/test.mp3",S_OK,FALSE},
461             {"/C:/test/test.mp3",S_OK,FALSE},
462             {"",S_FALSE,FALSE},
463             {"C:/test/test.mp3",S_OK,FALSE},
464             {"file",S_OK,FALSE},
465             {"",S_FALSE,FALSE},
466             {"",S_FALSE,FALSE}
467         },
468         {
469             {Uri_HOST_UNKNOWN,S_OK,FALSE},
470             {0,S_FALSE,FALSE},
471             {URL_SCHEME_FILE,S_OK,FALSE},
472             {URLZONE_INVALID,E_NOTIMPL,FALSE}
473         }
474     },
475     /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
476     {   "\\\\Server/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
477         {
478             {"file://server/test.mp3",S_OK,FALSE},
479             {"server",S_OK,FALSE},
480             {"file://server/test.mp3",S_OK,FALSE},
481             {"",S_FALSE,FALSE},
482             {".mp3",S_OK,FALSE},
483             {"",S_FALSE,FALSE},
484             {"server",S_OK,FALSE},
485             {"",S_FALSE,FALSE},
486             {"/test.mp3",S_OK,FALSE},
487             {"/test.mp3",S_OK,FALSE},
488             {"",S_FALSE,FALSE},
489             {"\\\\Server/test.mp3",S_OK,FALSE},
490             {"file",S_OK,FALSE},
491             {"",S_FALSE,FALSE},
492             {"",S_FALSE,FALSE}
493         },
494         {
495             {Uri_HOST_DNS,S_OK,FALSE},
496             {0,S_FALSE,FALSE},
497             {URL_SCHEME_FILE,S_OK,FALSE},
498             {URLZONE_INVALID,E_NOTIMPL,FALSE}
499         }
500     },
501     {   "www.winehq.org/test", Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
502         {
503             {"*:www.winehq.org/test",S_OK,FALSE},
504             {"www.winehq.org",S_OK,FALSE},
505             {"*:www.winehq.org/test",S_OK,FALSE},
506             {"winehq.org",S_OK,FALSE},
507             {"",S_FALSE,FALSE},
508             {"",S_FALSE,FALSE},
509             {"www.winehq.org",S_OK,FALSE},
510             {"",S_FALSE,FALSE},
511             {"/test",S_OK,FALSE},
512             {"/test",S_OK,FALSE},
513             {"",S_FALSE,FALSE},
514             {"www.winehq.org/test",S_OK,FALSE},
515             {"*",S_OK,FALSE},
516             {"",S_FALSE,FALSE},
517             {"",S_FALSE,FALSE}
518         },
519         {
520             {Uri_HOST_DNS,S_OK,FALSE},
521             {0,S_FALSE,FALSE},
522             {URL_SCHEME_WILDCARD,S_OK,FALSE},
523             {URLZONE_INVALID,E_NOTIMPL,FALSE}
524         }
525     },
526     /* Valid since the '*' is the only character in the scheme name. */
527     {   "*:www.winehq.org/test", 0, S_OK, FALSE,
528         {
529             {"*:www.winehq.org/test",S_OK,FALSE},
530             {"www.winehq.org",S_OK,FALSE},
531             {"*:www.winehq.org/test",S_OK,FALSE},
532             {"winehq.org",S_OK,FALSE},
533             {"",S_FALSE,FALSE},
534             {"",S_FALSE,FALSE},
535             {"www.winehq.org",S_OK,FALSE},
536             {"",S_FALSE,FALSE},
537             {"/test",S_OK,FALSE},
538             {"/test",S_OK,FALSE},
539             {"",S_FALSE,FALSE},
540             {"*:www.winehq.org/test",S_OK,FALSE},
541             {"*",S_OK,FALSE},
542             {"",S_FALSE,FALSE},
543             {"",S_FALSE,FALSE}
544         },
545         {
546             {Uri_HOST_DNS,S_OK,FALSE},
547             {0,S_FALSE,FALSE},
548             {URL_SCHEME_WILDCARD,S_OK,FALSE},
549             {URLZONE_INVALID,E_NOTIMPL,FALSE}
550         }
551     },
552     {   "/../some dir/test.ext", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
553         {
554             {"/../some dir/test.ext",S_OK,FALSE},
555             {"",S_FALSE,FALSE},
556             {"/../some dir/test.ext",S_OK,FALSE},
557             {"",S_FALSE,FALSE},
558             {".ext",S_OK,FALSE},
559             {"",S_FALSE,FALSE},
560             {"",S_FALSE,FALSE},
561             {"",S_FALSE,FALSE},
562             {"/../some dir/test.ext",S_OK,FALSE},
563             {"/../some dir/test.ext",S_OK,FALSE},
564             {"",S_FALSE,FALSE},
565             {"/../some dir/test.ext",S_OK,FALSE},
566             {"",S_FALSE,FALSE},
567             {"",S_FALSE,FALSE},
568             {"",S_FALSE,FALSE}
569         },
570         {
571             {Uri_HOST_UNKNOWN,S_OK,FALSE},
572             {0,S_FALSE,FALSE},
573             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
574             {URLZONE_INVALID,E_NOTIMPL,FALSE}
575         }
576     },
577     {   "//implicit/wildcard/uri scheme", Uri_CREATE_ALLOW_RELATIVE|Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
578         {
579             {"*://implicit/wildcard/uri%20scheme",S_OK,FALSE},
580             {"",S_OK,FALSE},
581             {"*://implicit/wildcard/uri%20scheme",S_OK,FALSE},
582             {"",S_FALSE,FALSE},
583             {"",S_FALSE,FALSE},
584             {"",S_FALSE,FALSE},
585             {"",S_OK,FALSE},
586             {"",S_FALSE,FALSE},
587             {"//implicit/wildcard/uri%20scheme",S_OK,FALSE},
588             {"//implicit/wildcard/uri%20scheme",S_OK,FALSE},
589             {"",S_FALSE,FALSE},
590             {"//implicit/wildcard/uri scheme",S_OK,FALSE},
591             {"*",S_OK,FALSE},
592             {"",S_FALSE,FALSE},
593             {"",S_FALSE,FALSE},
594         },
595         {
596             {Uri_HOST_UNKNOWN,S_OK,FALSE},
597             {0,S_FALSE,FALSE},
598             {URL_SCHEME_WILDCARD,S_OK,FALSE},
599             {URLZONE_INVALID,E_NOTIMPL,FALSE}
600         }
601     },
602     /* URI is considered opaque since CREATE_NO_CRACK_UNKNOWN_SCHEMES is set and its an unknown scheme. */
603     {   "zip://google.com", Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, S_OK, FALSE,
604         {
605             {"zip:/.//google.com",S_OK,FALSE},
606             {"",S_FALSE,FALSE},
607             {"zip:/.//google.com",S_OK,FALSE},
608             {"",S_FALSE,FALSE},
609             {".com",S_OK,FALSE},
610             {"",S_FALSE,FALSE},
611             {"",S_FALSE,FALSE},
612             {"",S_FALSE,FALSE},
613             {"/.//google.com",S_OK,FALSE},
614             {"/.//google.com",S_OK,FALSE},
615             {"",S_FALSE,FALSE},
616             {"zip://google.com",S_OK,FALSE},
617             {"zip",S_OK,FALSE},
618             {"",S_FALSE,FALSE},
619             {"",S_FALSE,FALSE}
620         },
621         {
622             {Uri_HOST_UNKNOWN,S_OK,FALSE},
623             {0,S_FALSE,FALSE},
624             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
625             {URLZONE_INVALID,E_NOTIMPL,FALSE}
626         }
627     },
628     /* Windows uses the first occurrence of ':' to delimit the userinfo. */
629     {   "ftp://user:pass:word@winehq.org/", 0, S_OK, FALSE,
630         {
631             {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
632             {"user:pass:word@winehq.org",S_OK,FALSE},
633             {"ftp://winehq.org/",S_OK,FALSE},
634             {"winehq.org",S_OK,FALSE},
635             {"",S_FALSE,FALSE},
636             {"",S_FALSE,FALSE},
637             {"winehq.org",S_OK,FALSE},
638             {"pass:word",S_OK,FALSE},
639             {"/",S_OK,FALSE},
640             {"/",S_OK,FALSE},
641             {"",S_FALSE,FALSE},
642             {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
643             {"ftp",S_OK,FALSE},
644             {"user:pass:word",S_OK,FALSE},
645             {"user",S_OK,FALSE}
646         },
647         {
648             {Uri_HOST_DNS,S_OK,FALSE},
649             {21,S_OK,FALSE},
650             {URL_SCHEME_FTP,S_OK,FALSE},
651             {URLZONE_INVALID,E_NOTIMPL,FALSE}
652         }
653     },
654     /* Make sure % encoded unreserved characters are decoded. */
655     {   "ftp://w%49%4Ee:PA%53%53@ftp.google.com/", 0, S_OK, FALSE,
656         {
657             {"ftp://wINe:PASS@ftp.google.com/",S_OK,FALSE},
658             {"wINe:PASS@ftp.google.com",S_OK,FALSE},
659             {"ftp://ftp.google.com/",S_OK,FALSE},
660             {"google.com",S_OK,FALSE},
661             {"",S_FALSE,FALSE},
662             {"",S_FALSE,FALSE},
663             {"ftp.google.com",S_OK,FALSE},
664             {"PASS",S_OK,FALSE},
665             {"/",S_OK,FALSE},
666             {"/",S_OK,FALSE},
667             {"",S_FALSE,FALSE},
668             {"ftp://w%49%4Ee:PA%53%53@ftp.google.com/",S_OK,FALSE},
669             {"ftp",S_OK,FALSE},
670             {"wINe:PASS",S_OK,FALSE},
671             {"wINe",S_OK,FALSE}
672         },
673         {
674             {Uri_HOST_DNS,S_OK,FALSE},
675             {21,S_OK,FALSE},
676             {URL_SCHEME_FTP,S_OK,FALSE},
677             {URLZONE_INVALID,E_NOTIMPL,FALSE}
678         }
679     },
680     /* Make sure % encoded characters which are NOT unreserved are NOT decoded. */
681     {   "ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/", 0, S_OK, FALSE,
682         {
683             {"ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/",S_OK,FALSE},
684             {"w%5D%5Be:PA%7B%7D@ftp.google.com",S_OK,FALSE},
685             {"ftp://ftp.google.com/",S_OK,FALSE},
686             {"google.com",S_OK,FALSE},
687             {"",S_FALSE,FALSE},
688             {"",S_FALSE,FALSE},
689             {"ftp.google.com",S_OK,FALSE},
690             {"PA%7B%7D",S_OK,FALSE},
691             {"/",S_OK,FALSE},
692             {"/",S_OK,FALSE},
693             {"",S_FALSE,FALSE},
694             {"ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/",S_OK,FALSE},
695             {"ftp",S_OK,FALSE},
696             {"w%5D%5Be:PA%7B%7D",S_OK,FALSE},
697             {"w%5D%5Be",S_OK,FALSE}
698         },
699         {
700             {Uri_HOST_DNS,S_OK,FALSE},
701             {21,S_OK,FALSE},
702             {URL_SCHEME_FTP,S_OK,FALSE},
703             {URLZONE_INVALID,E_NOTIMPL,FALSE}
704         }
705     },
706     /* You're allowed to have an empty password portion in the userinfo section. */
707     {   "ftp://empty:@ftp.google.com/", 0, S_OK, FALSE,
708         {
709             {"ftp://empty:@ftp.google.com/",S_OK,FALSE},
710             {"empty:@ftp.google.com",S_OK,FALSE},
711             {"ftp://ftp.google.com/",S_OK,FALSE},
712             {"google.com",S_OK,FALSE},
713             {"",S_FALSE,FALSE},
714             {"",S_FALSE,FALSE},
715             {"ftp.google.com",S_OK,FALSE},
716             {"",S_OK,FALSE},
717             {"/",S_OK,FALSE},
718             {"/",S_OK,FALSE},
719             {"",S_FALSE,FALSE},
720             {"ftp://empty:@ftp.google.com/",S_OK,FALSE},
721             {"ftp",S_OK,FALSE},
722             {"empty:",S_OK,FALSE},
723             {"empty",S_OK,FALSE}
724         },
725         {
726             {Uri_HOST_DNS,S_OK,FALSE},
727             {21,S_OK,FALSE},
728             {URL_SCHEME_FTP,S_OK,FALSE},
729             {URLZONE_INVALID,E_NOTIMPL,FALSE}
730         }
731     },
732     /* Make sure forbidden characters in "userinfo" get encoded. */
733     {   "ftp://\" \"weird@ftp.google.com/", 0, S_OK, FALSE,
734         {
735             {"ftp://%22%20%22weird@ftp.google.com/",S_OK,FALSE},
736             {"%22%20%22weird@ftp.google.com",S_OK,FALSE},
737             {"ftp://ftp.google.com/",S_OK,FALSE},
738             {"google.com",S_OK,FALSE},
739             {"",S_FALSE,FALSE},
740             {"",S_FALSE,FALSE},
741             {"ftp.google.com",S_OK,FALSE},
742             {"",S_FALSE,FALSE},
743             {"/",S_OK,FALSE},
744             {"/",S_OK,FALSE},
745             {"",S_FALSE,FALSE},
746             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
747             {"ftp",S_OK,FALSE},
748             {"%22%20%22weird",S_OK,FALSE},
749             {"%22%20%22weird",S_OK,FALSE}
750         },
751         {
752             {Uri_HOST_DNS,S_OK,FALSE},
753             {21,S_OK,FALSE},
754             {URL_SCHEME_FTP,S_OK,FALSE},
755             {URLZONE_INVALID,E_NOTIMPL,FALSE}
756         }
757     },
758     /* Make sure the forbidden characters don't get percent encoded. */
759     {   "ftp://\" \"weird@ftp.google.com/", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
760         {
761             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
762             {"\" \"weird@ftp.google.com",S_OK,FALSE},
763             {"ftp://ftp.google.com/",S_OK,FALSE},
764             {"google.com",S_OK,FALSE},
765             {"",S_FALSE,FALSE},
766             {"",S_FALSE,FALSE},
767             {"ftp.google.com",S_OK,FALSE},
768             {"",S_FALSE,FALSE},
769             {"/",S_OK,FALSE},
770             {"/",S_OK,FALSE},
771             {"",S_FALSE,FALSE},
772             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
773             {"ftp",S_OK,FALSE},
774             {"\" \"weird",S_OK,FALSE},
775             {"\" \"weird",S_OK,FALSE}
776         },
777         {
778             {Uri_HOST_DNS,S_OK,FALSE},
779             {21,S_OK,FALSE},
780             {URL_SCHEME_FTP,S_OK,FALSE},
781             {URLZONE_INVALID,E_NOTIMPL,FALSE}
782         }
783     },
784     /* Allowed to have invalid % encoded because its an unknown scheme type. */
785     {   "zip://%xy:word@winehq.org/", 0, S_OK, FALSE,
786         {
787             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
788             {"%xy:word@winehq.org",S_OK,FALSE},
789             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
790             {"winehq.org",S_OK,FALSE},
791             {"",S_FALSE,FALSE},
792             {"",S_FALSE,FALSE},
793             {"winehq.org",S_OK,FALSE},
794             {"word",S_OK,FALSE},
795             {"/",S_OK,FALSE},
796             {"/",S_OK,FALSE},
797             {"",S_FALSE,FALSE},
798             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
799             {"zip",S_OK,FALSE},
800             {"%xy:word",S_OK,FALSE},
801             {"%xy",S_OK,FALSE}
802         },
803         {
804             {Uri_HOST_DNS,S_OK,FALSE},
805             {0,S_FALSE,FALSE},
806             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
807             {URLZONE_INVALID,E_NOTIMPL,FALSE}
808         }
809     },
810     /* Unreserved, percent encoded characters aren't decoded in the userinfo becuase the scheme
811      * isn't known.
812      */
813     {   "zip://%2E:%52%53ord@winehq.org/", 0, S_OK, FALSE,
814         {
815             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
816             {"%2E:%52%53ord@winehq.org",S_OK,FALSE},
817             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
818             {"winehq.org",S_OK,FALSE},
819             {"",S_FALSE,FALSE},
820             {"",S_FALSE,FALSE},
821             {"winehq.org",S_OK,FALSE},
822             {"%52%53ord",S_OK,FALSE},
823             {"/",S_OK,FALSE},
824             {"/",S_OK,FALSE},
825             {"",S_FALSE,FALSE},
826             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
827             {"zip",S_OK,FALSE},
828             {"%2E:%52%53ord",S_OK,FALSE},
829             {"%2E",S_OK,FALSE}
830         },
831         {
832             {Uri_HOST_DNS,S_OK,FALSE},
833             {0,S_FALSE,FALSE},
834             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
835             {URLZONE_INVALID,E_NOTIMPL,FALSE}
836         }
837     },
838     {   "ftp://[](),'test':word@winehq.org/", 0, S_OK, FALSE,
839         {
840             {"ftp://[](),'test':word@winehq.org/",S_OK,FALSE},
841             {"[](),'test':word@winehq.org",S_OK,FALSE},
842             {"ftp://winehq.org/",S_OK,FALSE},
843             {"winehq.org",S_OK,FALSE},
844             {"",S_FALSE,FALSE},
845             {"",S_FALSE,FALSE},
846             {"winehq.org",S_OK,FALSE},
847             {"word",S_OK,FALSE},
848             {"/",S_OK,FALSE},
849             {"/",S_OK,FALSE},
850             {"",S_FALSE,FALSE},
851             {"ftp://[](),'test':word@winehq.org/",S_OK,FALSE},
852             {"ftp",S_OK,FALSE},
853             {"[](),'test':word",S_OK,FALSE},
854             {"[](),'test'",S_OK,FALSE}
855         },
856         {
857             {Uri_HOST_DNS,S_OK,FALSE},
858             {21,S_OK,FALSE},
859             {URL_SCHEME_FTP,S_OK,FALSE},
860             {URLZONE_INVALID,E_NOTIMPL,FALSE}
861         }
862     },
863     {   "ftp://test?:word@winehq.org/", 0, S_OK, FALSE,
864         {
865             {"ftp://test/?:word@winehq.org/",S_OK,FALSE},
866             {"test",S_OK,FALSE},
867             {"ftp://test/?:word@winehq.org/",S_OK,FALSE},
868             {"",S_FALSE,FALSE},
869             {"",S_FALSE,FALSE},
870             {"",S_FALSE,FALSE},
871             {"test",S_OK,FALSE},
872             {"",S_FALSE,FALSE},
873             {"/",S_OK,FALSE},
874             {"/?:word@winehq.org/",S_OK,FALSE},
875             {"?:word@winehq.org/",S_OK,FALSE},
876             {"ftp://test?:word@winehq.org/",S_OK,FALSE},
877             {"ftp",S_OK,FALSE},
878             {"",S_FALSE,FALSE},
879             {"",S_FALSE,FALSE}
880         },
881         {
882             {Uri_HOST_DNS,S_OK,FALSE},
883             {21,S_OK,FALSE},
884             {URL_SCHEME_FTP,S_OK,FALSE},
885             {URLZONE_INVALID,E_NOTIMPL,FALSE}
886         }
887     },
888     {   "ftp://test#:word@winehq.org/", 0, S_OK, FALSE,
889         {
890             {"ftp://test/#:word@winehq.org/",S_OK,FALSE},
891             {"test",S_OK,FALSE},
892             {"ftp://test/#:word@winehq.org/",S_OK,FALSE},
893             {"",S_FALSE,FALSE},
894             {"",S_FALSE,FALSE},
895             {"#:word@winehq.org/",S_OK,FALSE},
896             {"test",S_OK,FALSE},
897             {"",S_FALSE,FALSE},
898             {"/",S_OK,FALSE},
899             {"/",S_OK,FALSE},
900             {"",S_FALSE,FALSE},
901             {"ftp://test#:word@winehq.org/",S_OK,FALSE},
902             {"ftp",S_OK,FALSE},
903             {"",S_FALSE,FALSE},
904             {"",S_FALSE,FALSE}
905         },
906         {
907             {Uri_HOST_DNS,S_OK,FALSE},
908             {21,S_OK,FALSE},
909             {URL_SCHEME_FTP,S_OK,FALSE},
910             {URLZONE_INVALID,E_NOTIMPL,FALSE}
911         }
912     },
913     /* Allowed to have a backslash in the userinfo since it's an unknown scheme. */
914     {   "zip://test\\:word@winehq.org/", 0, S_OK, FALSE,
915         {
916             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
917             {"test\\:word@winehq.org",S_OK,FALSE},
918             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
919             {"winehq.org",S_OK,FALSE},
920             {"",S_FALSE,FALSE},
921             {"",S_FALSE,FALSE},
922             {"winehq.org",S_OK,FALSE},
923             {"word",S_OK,FALSE},
924             {"/",S_OK,FALSE},
925             {"/",S_OK,FALSE},
926             {"",S_FALSE,FALSE},
927             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
928             {"zip",S_OK,FALSE},
929             {"test\\:word",S_OK,FALSE},
930             {"test\\",S_OK,FALSE}
931         },
932         {
933             {Uri_HOST_DNS,S_OK,FALSE},
934             {0,S_FALSE,FALSE},
935             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
936             {URLZONE_INVALID,E_NOTIMPL,FALSE}
937         }
938     },
939     /* It normalizes IPv4 addresses correctly. */
940     {   "http://127.000.000.100/", 0, S_OK, FALSE,
941         {
942             {"http://127.0.0.100/",S_OK,FALSE},
943             {"127.0.0.100",S_OK,FALSE},
944             {"http://127.0.0.100/",S_OK,FALSE},
945             {"",S_FALSE,FALSE},
946             {"",S_FALSE,FALSE},
947             {"",S_FALSE,FALSE},
948             {"127.0.0.100",S_OK,FALSE},
949             {"",S_FALSE,FALSE},
950             {"/",S_OK,FALSE},
951             {"/",S_OK,FALSE},
952             {"",S_FALSE,FALSE},
953             {"http://127.000.000.100/",S_OK,FALSE},
954             {"http",S_OK,FALSE},
955             {"",S_FALSE,FALSE},
956             {"",S_FALSE,FALSE}
957         },
958         {
959             {Uri_HOST_IPV4,S_OK,FALSE},
960             {80,S_OK,FALSE},
961             {URL_SCHEME_HTTP,S_OK,FALSE},
962             {URLZONE_INVALID,E_NOTIMPL,FALSE}
963         }
964     },
965     /* Make sure it normalizes partial IPv4 addresses correctly. */
966     {   "http://127.0/", 0, S_OK, FALSE,
967         {
968             {"http://127.0.0.0/",S_OK,FALSE},
969             {"127.0.0.0",S_OK,FALSE},
970             {"http://127.0.0.0/",S_OK,FALSE},
971             {"",S_FALSE,FALSE},
972             {"",S_FALSE,FALSE},
973             {"",S_FALSE,FALSE},
974             {"127.0.0.0",S_OK,FALSE},
975             {"",S_FALSE,FALSE},
976             {"/",S_OK,FALSE},
977             {"/",S_OK,FALSE},
978             {"",S_FALSE,FALSE},
979             {"http://127.0/",S_OK,FALSE},
980             {"http",S_OK,FALSE},
981             {"",S_FALSE,FALSE},
982             {"",S_FALSE,FALSE}
983         },
984         {
985             {Uri_HOST_IPV4,S_OK,FALSE},
986             {80,S_OK,FALSE},
987             {URL_SCHEME_HTTP,S_OK,FALSE},
988             {URLZONE_INVALID,E_NOTIMPL,FALSE}
989         }
990     },
991     /* Make sure it converts implicit IPv4's correctly. */
992     {   "http://123456/", 0, S_OK, FALSE,
993         {
994             {"http://0.1.226.64/",S_OK,FALSE},
995             {"0.1.226.64",S_OK,FALSE},
996             {"http://0.1.226.64/",S_OK,FALSE},
997             {"",S_FALSE,FALSE},
998             {"",S_FALSE,FALSE},
999             {"",S_FALSE,FALSE},
1000             {"0.1.226.64",S_OK,FALSE},
1001             {"",S_FALSE,FALSE},
1002             {"/",S_OK,FALSE},
1003             {"/",S_OK,FALSE},
1004             {"",S_FALSE,FALSE},
1005             {"http://123456/",S_OK,FALSE},
1006             {"http",S_OK,FALSE},
1007             {"",S_FALSE,FALSE},
1008             {"",S_FALSE,FALSE}
1009         },
1010         {
1011             {Uri_HOST_IPV4,S_OK,FALSE},
1012             {80,S_OK,FALSE},
1013             {URL_SCHEME_HTTP,S_OK,FALSE},
1014             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1015         }
1016     },
1017     /* UINT_MAX */
1018     {   "http://4294967295/", 0, S_OK, FALSE,
1019         {
1020             {"http://255.255.255.255/",S_OK,FALSE},
1021             {"255.255.255.255",S_OK,FALSE},
1022             {"http://255.255.255.255/",S_OK,FALSE},
1023             {"",S_FALSE,FALSE},
1024             {"",S_FALSE,FALSE},
1025             {"",S_FALSE,FALSE},
1026             {"255.255.255.255",S_OK,FALSE},
1027             {"",S_FALSE,FALSE},
1028             {"/",S_OK,FALSE},
1029             {"/",S_OK,FALSE},
1030             {"",S_FALSE,FALSE},
1031             {"http://4294967295/",S_OK,FALSE},
1032             {"http",S_OK,FALSE},
1033             {"",S_FALSE,FALSE},
1034             {"",S_FALSE,FALSE}
1035         },
1036         {
1037             {Uri_HOST_IPV4,S_OK,FALSE},
1038             {80,S_OK,FALSE},
1039             {URL_SCHEME_HTTP,S_OK,FALSE},
1040             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1041         }
1042     },
1043     /* UINT_MAX+1 */
1044     {   "http://4294967296/", 0, S_OK, FALSE,
1045         {
1046             {"http://4294967296/",S_OK,FALSE},
1047             {"4294967296",S_OK,FALSE},
1048             {"http://4294967296/",S_OK,FALSE},
1049             {"",S_FALSE,FALSE},
1050             {"",S_FALSE,FALSE},
1051             {"",S_FALSE,FALSE},
1052             {"4294967296",S_OK,FALSE},
1053             {"",S_FALSE,FALSE},
1054             {"/",S_OK,FALSE},
1055             {"/",S_OK,FALSE},
1056             {"",S_FALSE,FALSE},
1057             {"http://4294967296/",S_OK,FALSE},
1058             {"http",S_OK,FALSE},
1059             {"",S_FALSE,FALSE},
1060             {"",S_FALSE,FALSE}
1061         },
1062         {
1063             {Uri_HOST_DNS,S_OK,FALSE},
1064             {80,S_OK,FALSE},
1065             {URL_SCHEME_HTTP,S_OK,FALSE},
1066             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1067         }
1068     },
1069     /* Window's doesn't normalize IP address for unknown schemes. */
1070     {   "1234://4294967295/", 0, S_OK, FALSE,
1071         {
1072             {"1234://4294967295/",S_OK,FALSE},
1073             {"4294967295",S_OK,FALSE},
1074             {"1234://4294967295/",S_OK,FALSE},
1075             {"",S_FALSE,FALSE},
1076             {"",S_FALSE,FALSE},
1077             {"",S_FALSE,FALSE},
1078             {"4294967295",S_OK,FALSE},
1079             {"",S_FALSE,FALSE},
1080             {"/",S_OK,FALSE},
1081             {"/",S_OK,FALSE},
1082             {"",S_FALSE,FALSE},
1083             {"1234://4294967295/",S_OK,FALSE},
1084             {"1234",S_OK,FALSE},
1085             {"",S_FALSE,FALSE},
1086             {"",S_FALSE,FALSE}
1087         },
1088         {
1089             {Uri_HOST_IPV4,S_OK,FALSE},
1090             {0,S_FALSE,FALSE},
1091             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1092             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1093         }
1094     },
1095     /* Window's doesn't normalize IP address for unknown schemes. */
1096     {   "1234://127.001/", 0, S_OK, FALSE,
1097         {
1098             {"1234://127.001/",S_OK,FALSE},
1099             {"127.001",S_OK,FALSE},
1100             {"1234://127.001/",S_OK,FALSE},
1101             {"",S_FALSE,FALSE},
1102             {"",S_FALSE,FALSE},
1103             {"",S_FALSE,FALSE},
1104             {"127.001",S_OK,FALSE},
1105             {"",S_FALSE,FALSE},
1106             {"/",S_OK,FALSE},
1107             {"/",S_OK,FALSE},
1108             {"",S_FALSE,FALSE},
1109             {"1234://127.001/",S_OK,FALSE},
1110             {"1234",S_OK,FALSE},
1111             {"",S_FALSE,FALSE},
1112             {"",S_FALSE,FALSE}
1113         },
1114         {
1115             {Uri_HOST_IPV4,S_OK,FALSE},
1116             {0,S_FALSE,FALSE},
1117             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1118             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1119         }
1120     },
1121     {   "http://[FEDC:BA98::3210]", 0, S_OK, FALSE,
1122         {
1123             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
1124             {"[fedc:ba98::3210]",S_OK,FALSE},
1125             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
1126             {"",S_FALSE,FALSE},
1127             {"",S_FALSE,FALSE},
1128             {"",S_FALSE,FALSE},
1129             {"fedc:ba98::3210",S_OK,FALSE},
1130             {"",S_FALSE,FALSE},
1131             {"/",S_OK,FALSE},
1132             {"/",S_OK,FALSE},
1133             {"",S_FALSE,FALSE},
1134             {"http://[FEDC:BA98::3210]",S_OK,FALSE},
1135             {"http",S_OK,FALSE},
1136             {"",S_FALSE,FALSE},
1137             {"",S_FALSE,FALSE},
1138         },
1139         {
1140             {Uri_HOST_IPV6,S_OK,FALSE},
1141             {80,S_OK,FALSE},
1142             {URL_SCHEME_HTTP,S_OK,FALSE},
1143             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1144         }
1145     },
1146     {   "http://[::]", 0, S_OK, FALSE,
1147         {
1148             {"http://[::]/",S_OK,FALSE},
1149             {"[::]",S_OK,FALSE},
1150             {"http://[::]/",S_OK,FALSE},
1151             {"",S_FALSE,FALSE},
1152             {"",S_FALSE,FALSE},
1153             {"",S_FALSE,FALSE},
1154             {"::",S_OK,FALSE},
1155             {"",S_FALSE,FALSE},
1156             {"/",S_OK,FALSE},
1157             {"/",S_OK,FALSE},
1158             {"",S_FALSE,FALSE},
1159             {"http://[::]",S_OK,FALSE},
1160             {"http",S_OK,FALSE},
1161             {"",S_FALSE,FALSE},
1162             {"",S_FALSE,FALSE},
1163         },
1164         {
1165             {Uri_HOST_IPV6,S_OK,FALSE},
1166             {80,S_OK,FALSE},
1167             {URL_SCHEME_HTTP,S_OK,FALSE},
1168             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1169         }
1170     },
1171     {   "http://[FEDC:BA98::]", 0, S_OK, FALSE,
1172         {
1173             {"http://[fedc:ba98::]/",S_OK,FALSE},
1174             {"[fedc:ba98::]",S_OK,FALSE},
1175             {"http://[fedc:ba98::]/",S_OK,FALSE},
1176             {"",S_FALSE,FALSE},
1177             {"",S_FALSE,FALSE},
1178             {"",S_FALSE,FALSE},
1179             {"fedc:ba98::",S_OK,FALSE},
1180             {"",S_FALSE,FALSE},
1181             {"/",S_OK,FALSE},
1182             {"/",S_OK,FALSE},
1183             {"",S_FALSE,FALSE},
1184             {"http://[FEDC:BA98::]",S_OK,FALSE},
1185             {"http",S_OK,FALSE},
1186             {"",S_FALSE,FALSE},
1187             {"",S_FALSE,FALSE},
1188         },
1189         {
1190             {Uri_HOST_IPV6,S_OK,FALSE},
1191             {80,S_OK,FALSE},
1192             {URL_SCHEME_HTTP,S_OK,FALSE},
1193             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1194         }
1195     },
1196     /* Valid even with 2 byte elision because it doesn't appear the beginning or end. */
1197     {   "http://[1::3:4:5:6:7:8]", 0, S_OK, FALSE,
1198         {
1199             {"http://[1:0:3:4:5:6:7:8]/",S_OK,FALSE},
1200             {"[1:0:3:4:5:6:7:8]",S_OK,FALSE},
1201             {"http://[1:0:3:4:5:6:7:8]/",S_OK,FALSE},
1202             {"",S_FALSE,FALSE},
1203             {"",S_FALSE,FALSE},
1204             {"",S_FALSE,FALSE},
1205             {"1:0:3:4:5:6:7:8",S_OK,FALSE},
1206             {"",S_FALSE,FALSE},
1207             {"/",S_OK,FALSE},
1208             {"/",S_OK,FALSE},
1209             {"",S_FALSE,FALSE},
1210             {"http://[1::3:4:5:6:7:8]",S_OK,FALSE},
1211             {"http",S_OK,FALSE},
1212             {"",S_FALSE,FALSE},
1213             {"",S_FALSE,FALSE},
1214         },
1215         {
1216             {Uri_HOST_IPV6,S_OK,FALSE},
1217             {80,S_OK,FALSE},
1218             {URL_SCHEME_HTTP,S_OK,FALSE},
1219             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1220         }
1221     },
1222     {   "http://[v2.34]/", 0, S_OK, FALSE,
1223         {
1224             {"http://[v2.34]/",S_OK,FALSE},
1225             {"[v2.34]",S_OK,FALSE},
1226             {"http://[v2.34]/",S_OK,FALSE},
1227             {"",S_FALSE,FALSE},
1228             {"",S_FALSE,FALSE},
1229             {"",S_FALSE,FALSE},
1230             {"[v2.34]",S_OK,FALSE},
1231             {"",S_FALSE,FALSE},
1232             {"/",S_OK,FALSE},
1233             {"/",S_OK,FALSE},
1234             {"",S_FALSE,FALSE},
1235             {"http://[v2.34]/",S_OK,FALSE},
1236             {"http",S_OK,FALSE},
1237             {"",S_FALSE,FALSE},
1238             {"",S_FALSE,FALSE}
1239         },
1240         {
1241             {Uri_HOST_UNKNOWN,S_OK,FALSE},
1242             {80,S_OK,FALSE},
1243             {URL_SCHEME_HTTP,S_OK,FALSE},
1244             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1245         }
1246     },
1247     /* Windows ignores ':' if they appear after a '[' on a non-IPLiteral host. */
1248     {   "http://[xyz:12345.com/test", 0, S_OK, FALSE,
1249         {
1250             {"http://[xyz:12345.com/test",S_OK,FALSE},
1251             {"[xyz:12345.com",S_OK,FALSE},
1252             {"http://[xyz:12345.com/test",S_OK,FALSE},
1253             {"[xyz:12345.com",S_OK,FALSE},
1254             {"",S_FALSE,FALSE},
1255             {"",S_FALSE,FALSE},
1256             {"[xyz:12345.com",S_OK,FALSE},
1257             {"",S_FALSE,FALSE},
1258             {"/test",S_OK,FALSE},
1259             {"/test",S_OK,FALSE},
1260             {"",S_FALSE,FALSE},
1261             {"http://[xyz:12345.com/test",S_OK,FALSE},
1262             {"http",S_OK,FALSE},
1263             {"",S_FALSE,FALSE},
1264             {"",S_FALSE,FALSE}
1265         },
1266         {
1267             {Uri_HOST_DNS,S_OK,FALSE},
1268             {80,S_OK,FALSE},
1269             {URL_SCHEME_HTTP,S_OK,FALSE},
1270             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1271         }
1272     },
1273     /* Valid URI since the '[' and ']' don't appear at the beginning and end
1274      * of the host name (respectively).
1275      */
1276     {   "ftp://www.[works].com/", 0, S_OK, FALSE,
1277         {
1278             {"ftp://www.[works].com/",S_OK,FALSE},
1279             {"www.[works].com",S_OK,FALSE},
1280             {"ftp://www.[works].com/",S_OK,FALSE},
1281             {"[works].com",S_OK,FALSE},
1282             {"",S_FALSE,FALSE},
1283             {"",S_FALSE,FALSE},
1284             {"www.[works].com",S_OK,FALSE},
1285             {"",S_FALSE,FALSE},
1286             {"/",S_OK,FALSE},
1287             {"/",S_OK,FALSE},
1288             {"",S_FALSE,FALSE},
1289             {"ftp://www.[works].com/",S_OK,FALSE},
1290             {"ftp",S_OK,FALSE},
1291             {"",S_FALSE,FALSE},
1292             {"",S_FALSE,FALSE}
1293         },
1294         {
1295             {Uri_HOST_DNS,S_OK,FALSE},
1296             {21,S_OK,FALSE},
1297             {URL_SCHEME_FTP,S_OK,FALSE},
1298             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1299         }
1300     },
1301     /* Considers ':' a delimiter since it appears after the ']'. */
1302     {   "http://www.google.com]:12345/", 0, S_OK, FALSE,
1303         {
1304             {"http://www.google.com]:12345/",S_OK,FALSE},
1305             {"www.google.com]:12345",S_OK,FALSE},
1306             {"http://www.google.com]:12345/",S_OK,FALSE},
1307             {"google.com]",S_OK,FALSE},
1308             {"",S_FALSE,FALSE},
1309             {"",S_FALSE,FALSE},
1310             {"www.google.com]",S_OK,FALSE},
1311             {"",S_FALSE,FALSE},
1312             {"/",S_OK,FALSE},
1313             {"/",S_OK,FALSE},
1314             {"",S_FALSE,FALSE},
1315             {"http://www.google.com]:12345/",S_OK,FALSE},
1316             {"http",S_OK,FALSE},
1317             {"",S_FALSE,FALSE},
1318             {"",S_FALSE,FALSE}
1319         },
1320         {
1321             {Uri_HOST_DNS,S_OK,FALSE},
1322             {12345,S_OK,FALSE},
1323             {URL_SCHEME_HTTP,S_OK,FALSE},
1324             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1325         }
1326     },
1327     /* Unknown scheme types can have invalid % encoded data in the hostname. */
1328     {   "zip://w%XXw%GEw.google.com/", 0, S_OK, FALSE,
1329         {
1330             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1331             {"w%XXw%GEw.google.com",S_OK,FALSE},
1332             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1333             {"google.com",S_OK,FALSE},
1334             {"",S_FALSE,FALSE},
1335             {"",S_FALSE,FALSE},
1336             {"w%XXw%GEw.google.com",S_OK,FALSE},
1337             {"",S_FALSE,FALSE},
1338             {"/",S_OK,FALSE},
1339             {"/",S_OK,FALSE},
1340             {"",S_FALSE,FALSE},
1341             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1342             {"zip",S_OK,FALSE},
1343             {"",S_FALSE,FALSE},
1344             {"",S_FALSE,FALSE}
1345         },
1346         {
1347             {Uri_HOST_DNS,S_OK,FALSE},
1348             {0,S_FALSE,FALSE},
1349             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1350             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1351         }
1352     },
1353     /* Unknown scheme types hostname doesn't get lower cased. */
1354     {   "zip://GOOGLE.com/", 0, S_OK, FALSE,
1355         {
1356             {"zip://GOOGLE.com/",S_OK,FALSE},
1357             {"GOOGLE.com",S_OK,FALSE},
1358             {"zip://GOOGLE.com/",S_OK,FALSE},
1359             {"GOOGLE.com",S_OK,FALSE},
1360             {"",S_FALSE,FALSE},
1361             {"",S_FALSE,FALSE},
1362             {"GOOGLE.com",S_OK,FALSE},
1363             {"",S_FALSE,FALSE},
1364             {"/",S_OK,FALSE},
1365             {"/",S_OK,FALSE},
1366             {"",S_FALSE,FALSE},
1367             {"zip://GOOGLE.com/",S_OK,FALSE},
1368             {"zip",S_OK,FALSE},
1369             {"",S_FALSE,FALSE},
1370             {"",S_FALSE,FALSE}
1371         },
1372         {
1373             {Uri_HOST_DNS,S_OK,FALSE},
1374             {0,S_FALSE,FALSE},
1375             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1376             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1377         }
1378     },
1379     /* Hostname get's lower cased for known scheme types. */
1380     {   "http://WWW.GOOGLE.com/", 0, S_OK, FALSE,
1381         {
1382             {"http://www.google.com/",S_OK,FALSE},
1383             {"www.google.com",S_OK,FALSE},
1384             {"http://www.google.com/",S_OK,FALSE},
1385             {"google.com",S_OK,FALSE},
1386             {"",S_FALSE,FALSE},
1387             {"",S_FALSE,FALSE},
1388             {"www.google.com",S_OK,FALSE},
1389             {"",S_FALSE,FALSE},
1390             {"/",S_OK,FALSE},
1391             {"/",S_OK,FALSE},
1392             {"",S_FALSE,FALSE},
1393             {"http://WWW.GOOGLE.com/",S_OK,FALSE},
1394             {"http",S_OK,FALSE},
1395             {"",S_FALSE,FALSE},
1396             {"",S_FALSE,FALSE}
1397         },
1398         {
1399             {Uri_HOST_DNS,S_OK,FALSE},
1400             {80,S_OK,FALSE},
1401             {URL_SCHEME_HTTP,S_OK,FALSE},
1402             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1403         }
1404     },
1405     /* Characters that get % encoded in the hostname also have their percent
1406      * encoded forms lower cased.
1407      */
1408     {   "http://www.%7Cgoogle|.com/", 0, S_OK, FALSE,
1409         {
1410             {"http://www.%7cgoogle%7c.com/",S_OK,FALSE},
1411             {"www.%7cgoogle%7c.com",S_OK,FALSE},
1412             {"http://www.%7cgoogle%7c.com/",S_OK,FALSE},
1413             {"%7cgoogle%7c.com",S_OK,FALSE},
1414             {"",S_FALSE,FALSE},
1415             {"",S_FALSE,FALSE},
1416             {"www.%7cgoogle%7c.com",S_OK,FALSE},
1417             {"",S_FALSE,FALSE},
1418             {"/",S_OK,FALSE},
1419             {"/",S_OK,FALSE},
1420             {"",S_FALSE,FALSE},
1421             {"http://www.%7Cgoogle|.com/",S_OK,FALSE},
1422             {"http",S_OK,FALSE},
1423             {"",S_FALSE,FALSE},
1424             {"",S_FALSE,FALSE}
1425         },
1426         {
1427             {Uri_HOST_DNS,S_OK,FALSE},
1428             {80,S_OK,FALSE},
1429             {URL_SCHEME_HTTP,S_OK,FALSE},
1430             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1431         }
1432     },
1433     /* IPv4 addresses attached to IPv6 can be included in elisions. */
1434     {   "http://[1:2:3:4:5:6:0.0.0.0]", 0, S_OK, FALSE,
1435         {
1436             {"http://[1:2:3:4:5:6::]/",S_OK,FALSE},
1437             {"[1:2:3:4:5:6::]",S_OK,FALSE},
1438             {"http://[1:2:3:4:5:6::]/",S_OK,FALSE},
1439             {"",S_FALSE,FALSE},
1440             {"",S_FALSE,FALSE},
1441             {"",S_FALSE,FALSE},
1442             {"1:2:3:4:5:6::",S_OK,FALSE},
1443             {"",S_FALSE,FALSE},
1444             {"/",S_OK,FALSE},
1445             {"/",S_OK,FALSE},
1446             {"",S_FALSE,FALSE},
1447             {"http://[1:2:3:4:5:6:0.0.0.0]",S_OK,FALSE},
1448             {"http",S_OK,FALSE},
1449             {"",S_FALSE,FALSE},
1450             {"",S_FALSE,FALSE},
1451         },
1452         {
1453             {Uri_HOST_IPV6,S_OK,FALSE},
1454             {80,S_OK,FALSE},
1455             {URL_SCHEME_HTTP,S_OK,FALSE},
1456             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1457         }
1458     },
1459     /* IPv4 addresses get normalized. */
1460     {   "http://[::001.002.003.000]", 0, S_OK, FALSE,
1461         {
1462             {"http://[::1.2.3.0]/",S_OK,FALSE},
1463             {"[::1.2.3.0]",S_OK,FALSE},
1464             {"http://[::1.2.3.0]/",S_OK,FALSE},
1465             {"",S_FALSE,FALSE},
1466             {"",S_FALSE,FALSE},
1467             {"",S_FALSE,FALSE},
1468             {"::1.2.3.0",S_OK,FALSE},
1469             {"",S_FALSE,FALSE},
1470             {"/",S_OK,FALSE},
1471             {"/",S_OK,FALSE},
1472             {"",S_FALSE,FALSE},
1473             {"http://[::001.002.003.000]",S_OK,FALSE},
1474             {"http",S_OK,FALSE},
1475             {"",S_FALSE,FALSE},
1476             {"",S_FALSE,FALSE},
1477         },
1478         {
1479             {Uri_HOST_IPV6,S_OK,FALSE},
1480             {80,S_OK,FALSE},
1481             {URL_SCHEME_HTTP,S_OK,FALSE},
1482             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1483         }
1484     },
1485     /* Windows doesn't do anything to IPv6's in unknown schemes. */
1486     {   "zip://[0001:0:000:0004:0005:0006:001.002.003.000]", 0, S_OK, FALSE,
1487         {
1488             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]/",S_OK,FALSE},
1489             {"[0001:0:000:0004:0005:0006:001.002.003.000]",S_OK,FALSE},
1490             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]/",S_OK,FALSE},
1491             {"",S_FALSE,FALSE},
1492             {"",S_FALSE,FALSE},
1493             {"",S_FALSE,FALSE},
1494             {"0001:0:000:0004:0005:0006:001.002.003.000",S_OK,FALSE},
1495             {"",S_FALSE,FALSE},
1496             {"/",S_OK,FALSE},
1497             {"/",S_OK,FALSE},
1498             {"",S_FALSE,FALSE},
1499             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]",S_OK,FALSE},
1500             {"zip",S_OK,FALSE},
1501             {"",S_FALSE,FALSE},
1502             {"",S_FALSE,FALSE},
1503         },
1504         {
1505             {Uri_HOST_IPV6,S_OK,FALSE},
1506             {0,S_FALSE,FALSE},
1507             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1508             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1509         }
1510     },
1511     /* IPv4 address is converted into 2 h16 components. */
1512     {   "http://[ffff::192.222.111.32]", 0, S_OK, FALSE,
1513         {
1514             {"http://[ffff::c0de:6f20]/",S_OK,FALSE},
1515             {"[ffff::c0de:6f20]",S_OK,FALSE},
1516             {"http://[ffff::c0de:6f20]/",S_OK,FALSE},
1517             {"",S_FALSE,FALSE},
1518             {"",S_FALSE,FALSE},
1519             {"",S_FALSE,FALSE},
1520             {"ffff::c0de:6f20",S_OK,FALSE},
1521             {"",S_FALSE,FALSE},
1522             {"/",S_OK,FALSE},
1523             {"/",S_OK,FALSE},
1524             {"",S_FALSE,FALSE},
1525             {"http://[ffff::192.222.111.32]",S_OK,FALSE},
1526             {"http",S_OK,FALSE},
1527             {"",S_FALSE,FALSE},
1528             {"",S_FALSE,FALSE},
1529         },
1530         {
1531             {Uri_HOST_IPV6,S_OK,FALSE},
1532             {80,S_OK,FALSE},
1533             {URL_SCHEME_HTTP,S_OK,FALSE},
1534             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1535         }
1536     },
1537     /* Max value for a port. */
1538     {   "http://google.com:65535", 0, S_OK, FALSE,
1539         {
1540             {"http://google.com:65535/",S_OK,FALSE},
1541             {"google.com:65535",S_OK,FALSE},
1542             {"http://google.com:65535/",S_OK,FALSE},
1543             {"google.com",S_OK,FALSE},
1544             {"",S_FALSE,FALSE},
1545             {"",S_FALSE,FALSE},
1546             {"google.com",S_OK,FALSE},
1547             {"",S_FALSE,FALSE},
1548             {"/",S_OK,FALSE},
1549             {"/",S_OK,FALSE},
1550             {"",S_FALSE,FALSE},
1551             {"http://google.com:65535",S_OK,FALSE},
1552             {"http",S_OK,FALSE},
1553             {"",S_FALSE,FALSE},
1554             {"",S_FALSE,FALSE}
1555         },
1556         {
1557             {Uri_HOST_DNS,S_OK,FALSE},
1558             {65535,S_OK,FALSE},
1559             {URL_SCHEME_HTTP,S_OK,FALSE},
1560             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1561         }
1562     },
1563     {   "zip://google.com:65536", 0, S_OK, FALSE,
1564         {
1565             {"zip://google.com:65536/",S_OK,FALSE},
1566             {"google.com:65536",S_OK,FALSE},
1567             {"zip://google.com:65536/",S_OK,FALSE},
1568             {"google.com:65536",S_OK,FALSE},
1569             {"",S_FALSE,FALSE},
1570             {"",S_FALSE,FALSE},
1571             {"google.com:65536",S_OK,FALSE},
1572             {"",S_FALSE,FALSE},
1573             {"/",S_OK,FALSE},
1574             {"/",S_OK,FALSE},
1575             {"",S_FALSE,FALSE},
1576             {"zip://google.com:65536",S_OK,FALSE},
1577             {"zip",S_OK,FALSE},
1578             {"",S_FALSE,FALSE},
1579             {"",S_FALSE,FALSE}
1580         },
1581         {
1582             {Uri_HOST_DNS,S_OK,FALSE},
1583             {0,S_FALSE,FALSE},
1584             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1585             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1586         }
1587     },
1588     {   "zip://google.com:65536:25", 0, S_OK, FALSE,
1589         {
1590             {"zip://google.com:65536:25/",S_OK,FALSE},
1591             {"google.com:65536:25",S_OK,FALSE},
1592             {"zip://google.com:65536:25/",S_OK,FALSE},
1593             {"google.com:65536:25",S_OK,FALSE},
1594             {"",S_FALSE,FALSE},
1595             {"",S_FALSE,FALSE},
1596             {"google.com:65536:25",S_OK,FALSE},
1597             {"",S_FALSE,FALSE},
1598             {"/",S_OK,FALSE},
1599             {"/",S_OK,FALSE},
1600             {"",S_FALSE,FALSE},
1601             {"zip://google.com:65536:25",S_OK,FALSE},
1602             {"zip",S_OK,FALSE},
1603             {"",S_FALSE,FALSE},
1604             {"",S_FALSE,FALSE}
1605         },
1606         {
1607             {Uri_HOST_DNS,S_OK,FALSE},
1608             {0,S_FALSE,FALSE},
1609             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1610             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1611         }
1612     },
1613     {   "zip://[::ffff]:abcd", 0, S_OK, FALSE,
1614         {
1615             {"zip://[::ffff]:abcd/",S_OK,FALSE},
1616             {"[::ffff]:abcd",S_OK,FALSE},
1617             {"zip://[::ffff]:abcd/",S_OK,FALSE},
1618             {"",S_FALSE,FALSE},
1619             {"",S_FALSE,FALSE},
1620             {"",S_FALSE,FALSE},
1621             {"[::ffff]:abcd",S_OK,FALSE},
1622             {"",S_FALSE,FALSE},
1623             {"/",S_OK,FALSE},
1624             {"/",S_OK,FALSE},
1625             {"",S_FALSE,FALSE},
1626             {"zip://[::ffff]:abcd",S_OK,FALSE},
1627             {"zip",S_OK,FALSE},
1628             {"",S_FALSE,FALSE},
1629             {"",S_FALSE,FALSE}
1630         },
1631         {
1632             {Uri_HOST_DNS,S_OK,FALSE},
1633             {0,S_FALSE,FALSE},
1634             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1635             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1636         }
1637     },
1638     {   "zip://127.0.0.1:abcd", 0, S_OK, FALSE,
1639         {
1640             {"zip://127.0.0.1:abcd/",S_OK,FALSE},
1641             {"127.0.0.1:abcd",S_OK,FALSE},
1642             {"zip://127.0.0.1:abcd/",S_OK,FALSE},
1643             {"0.1:abcd",S_OK,FALSE},
1644             {"",S_FALSE,FALSE},
1645             {"",S_FALSE,FALSE},
1646             {"127.0.0.1:abcd",S_OK,FALSE},
1647             {"",S_FALSE,FALSE},
1648             {"/",S_OK,FALSE},
1649             {"/",S_OK,FALSE},
1650             {"",S_FALSE,FALSE},
1651             {"zip://127.0.0.1:abcd",S_OK,FALSE},
1652             {"zip",S_OK,FALSE},
1653             {"",S_FALSE,FALSE},
1654             {"",S_FALSE,FALSE}
1655         },
1656         {
1657             {Uri_HOST_DNS,S_OK,FALSE},
1658             {0,S_FALSE,FALSE},
1659             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1660             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1661         }
1662     },
1663     /* Port is just copied over. */
1664     {   "http://google.com:00035", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1665         {
1666             {"http://google.com:00035",S_OK,FALSE},
1667             {"google.com:00035",S_OK,FALSE},
1668             {"http://google.com:00035",S_OK,FALSE,"http://google.com:35"},
1669             {"google.com",S_OK,FALSE},
1670             {"",S_FALSE,FALSE},
1671             {"",S_FALSE,FALSE},
1672             {"google.com",S_OK,FALSE},
1673             {"",S_FALSE,FALSE},
1674             {"",S_FALSE,FALSE},
1675             {"",S_FALSE,FALSE},
1676             {"",S_FALSE,FALSE},
1677             {"http://google.com:00035",S_OK,FALSE},
1678             {"http",S_OK,FALSE},
1679             {"",S_FALSE,FALSE},
1680             {"",S_FALSE,FALSE}
1681         },
1682         {
1683             {Uri_HOST_DNS,S_OK,FALSE},
1684             {35,S_OK,FALSE},
1685             {URL_SCHEME_HTTP,S_OK,FALSE},
1686             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1687         }
1688     },
1689     /* Default port is copied over. */
1690     {   "http://google.com:80", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1691         {
1692             {"http://google.com:80",S_OK,FALSE},
1693             {"google.com:80",S_OK,FALSE},
1694             {"http://google.com:80",S_OK,FALSE},
1695             {"google.com",S_OK,FALSE},
1696             {"",S_FALSE,FALSE},
1697             {"",S_FALSE,FALSE},
1698             {"google.com",S_OK,FALSE},
1699             {"",S_FALSE,FALSE},
1700             {"",S_FALSE,FALSE},
1701             {"",S_FALSE,FALSE},
1702             {"",S_FALSE,FALSE},
1703             {"http://google.com:80",S_OK,FALSE},
1704             {"http",S_OK,FALSE},
1705             {"",S_FALSE,FALSE},
1706             {"",S_FALSE,FALSE}
1707         },
1708         {
1709             {Uri_HOST_DNS,S_OK,FALSE},
1710             {80,S_OK,FALSE},
1711             {URL_SCHEME_HTTP,S_OK,FALSE},
1712             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1713         }
1714     },
1715     {   "http://google.com.uk", 0, S_OK, FALSE,
1716         {
1717             {"http://google.com.uk/",S_OK,FALSE},
1718             {"google.com.uk",S_OK,FALSE},
1719             {"http://google.com.uk/",S_OK,FALSE},
1720             {"google.com.uk",S_OK,FALSE},
1721             {"",S_FALSE,FALSE},
1722             {"",S_FALSE,FALSE},
1723             {"google.com.uk",S_OK,FALSE},
1724             {"",S_FALSE,FALSE},
1725             {"/",S_OK,FALSE},
1726             {"/",S_OK,FALSE},
1727             {"",S_FALSE,FALSE},
1728             {"http://google.com.uk",S_OK,FALSE},
1729             {"http",S_OK,FALSE},
1730             {"",S_FALSE,FALSE},
1731             {"",S_FALSE,FALSE}
1732         },
1733         {
1734             {Uri_HOST_DNS,S_OK,FALSE},
1735             {80,S_OK,FALSE},
1736             {URL_SCHEME_HTTP,S_OK,FALSE},
1737             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1738         }
1739     },
1740     {   "http://google.com.com", 0, S_OK, FALSE,
1741         {
1742             {"http://google.com.com/",S_OK,FALSE},
1743             {"google.com.com",S_OK,FALSE},
1744             {"http://google.com.com/",S_OK,FALSE},
1745             {"com.com",S_OK,FALSE},
1746             {"",S_FALSE,FALSE},
1747             {"",S_FALSE,FALSE},
1748             {"google.com.com",S_OK,FALSE},
1749             {"",S_FALSE,FALSE},
1750             {"/",S_OK,FALSE},
1751             {"/",S_OK,FALSE},
1752             {"",S_FALSE,FALSE},
1753             {"http://google.com.com",S_OK,FALSE},
1754             {"http",S_OK,FALSE},
1755             {"",S_FALSE,FALSE},
1756             {"",S_FALSE,FALSE}
1757         },
1758         {
1759             {Uri_HOST_DNS,S_OK,FALSE},
1760             {80,S_OK,FALSE},
1761             {URL_SCHEME_HTTP,S_OK,FALSE},
1762             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1763         }
1764     },
1765     {   "http://google.uk.1", 0, S_OK, FALSE,
1766         {
1767             {"http://google.uk.1/",S_OK,FALSE},
1768             {"google.uk.1",S_OK,FALSE},
1769             {"http://google.uk.1/",S_OK,FALSE},
1770             {"google.uk.1",S_OK,FALSE},
1771             {"",S_FALSE,FALSE},
1772             {"",S_FALSE,FALSE},
1773             {"google.uk.1",S_OK,FALSE},
1774             {"",S_FALSE,FALSE},
1775             {"/",S_OK,FALSE},
1776             {"/",S_OK,FALSE},
1777             {"",S_FALSE,FALSE},
1778             {"http://google.uk.1",S_OK,FALSE},
1779             {"http",S_OK,FALSE},
1780             {"",S_FALSE,FALSE},
1781             {"",S_FALSE,FALSE}
1782         },
1783         {
1784             {Uri_HOST_DNS,S_OK,FALSE},
1785             {80,S_OK,FALSE},
1786             {URL_SCHEME_HTTP,S_OK,FALSE},
1787             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1788         }
1789     },
1790     /* Since foo isn't a recognized 3 character TLD its considered the domain name. */
1791     {   "http://google.foo.uk", 0, S_OK, FALSE,
1792         {
1793             {"http://google.foo.uk/",S_OK,FALSE},
1794             {"google.foo.uk",S_OK,FALSE},
1795             {"http://google.foo.uk/",S_OK,FALSE},
1796             {"foo.uk",S_OK,FALSE},
1797             {"",S_FALSE,FALSE},
1798             {"",S_FALSE,FALSE},
1799             {"google.foo.uk",S_OK,FALSE},
1800             {"",S_FALSE,FALSE},
1801             {"/",S_OK,FALSE},
1802             {"/",S_OK,FALSE},
1803             {"",S_FALSE,FALSE},
1804             {"http://google.foo.uk",S_OK,FALSE},
1805             {"http",S_OK,FALSE},
1806             {"",S_FALSE,FALSE},
1807             {"",S_FALSE,FALSE}
1808         },
1809         {
1810             {Uri_HOST_DNS,S_OK,FALSE},
1811             {80,S_OK,FALSE},
1812             {URL_SCHEME_HTTP,S_OK,FALSE},
1813             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1814         }
1815     },
1816     {   "http://.com", 0, S_OK, FALSE,
1817         {
1818             {"http://.com/",S_OK,FALSE},
1819             {".com",S_OK,FALSE},
1820             {"http://.com/",S_OK,FALSE},
1821             {".com",S_OK,FALSE},
1822             {"",S_FALSE,FALSE},
1823             {"",S_FALSE,FALSE},
1824             {".com",S_OK,FALSE},
1825             {"",S_FALSE,FALSE},
1826             {"/",S_OK,FALSE},
1827             {"/",S_OK,FALSE},
1828             {"",S_FALSE,FALSE},
1829             {"http://.com",S_OK,FALSE},
1830             {"http",S_OK,FALSE},
1831             {"",S_FALSE,FALSE},
1832             {"",S_FALSE,FALSE}
1833         },
1834         {
1835             {Uri_HOST_DNS,S_OK,FALSE},
1836             {80,S_OK,FALSE},
1837             {URL_SCHEME_HTTP,S_OK,FALSE},
1838             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1839         }
1840     },
1841     {   "http://.uk", 0, S_OK, FALSE,
1842         {
1843             {"http://.uk/",S_OK,FALSE},
1844             {".uk",S_OK,FALSE},
1845             {"http://.uk/",S_OK,FALSE},
1846             {"",S_FALSE,FALSE},
1847             {"",S_FALSE,FALSE},
1848             {"",S_FALSE,FALSE},
1849             {".uk",S_OK,FALSE},
1850             {"",S_FALSE,FALSE},
1851             {"/",S_OK,FALSE},
1852             {"/",S_OK,FALSE},
1853             {"",S_FALSE,FALSE},
1854             {"http://.uk",S_OK,FALSE},
1855             {"http",S_OK,FALSE},
1856             {"",S_FALSE,FALSE},
1857             {"",S_FALSE,FALSE}
1858         },
1859         {
1860             {Uri_HOST_DNS,S_OK,FALSE},
1861             {80,S_OK,FALSE},
1862             {URL_SCHEME_HTTP,S_OK,FALSE},
1863             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1864         }
1865     },
1866     {   "http://www.co.google.com.[]", 0, S_OK, FALSE,
1867         {
1868             {"http://www.co.google.com.[]/",S_OK,FALSE},
1869             {"www.co.google.com.[]",S_OK,FALSE},
1870             {"http://www.co.google.com.[]/",S_OK,FALSE},
1871             {"google.com.[]",S_OK,FALSE},
1872             {"",S_FALSE,FALSE},
1873             {"",S_FALSE,FALSE},
1874             {"www.co.google.com.[]",S_OK,FALSE},
1875             {"",S_FALSE,FALSE},
1876             {"/",S_OK,FALSE},
1877             {"/",S_OK,FALSE},
1878             {"",S_FALSE,FALSE},
1879             {"http://www.co.google.com.[]",S_OK,FALSE},
1880             {"http",S_OK,FALSE},
1881             {"",S_FALSE,FALSE},
1882             {"",S_FALSE,FALSE}
1883         },
1884         {
1885             {Uri_HOST_DNS,S_OK,FALSE},
1886             {80,S_OK,FALSE},
1887             {URL_SCHEME_HTTP,S_OK,FALSE},
1888             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1889         }
1890     },
1891     {   "http://co.uk", 0, S_OK, FALSE,
1892         {
1893             {"http://co.uk/",S_OK,FALSE},
1894             {"co.uk",S_OK,FALSE},
1895             {"http://co.uk/",S_OK,FALSE},
1896             {"",S_FALSE,FALSE},
1897             {"",S_FALSE,FALSE},
1898             {"",S_FALSE,FALSE},
1899             {"co.uk",S_OK,FALSE},
1900             {"",S_FALSE,FALSE},
1901             {"/",S_OK,FALSE},
1902             {"/",S_OK,FALSE},
1903             {"",S_FALSE,FALSE},
1904             {"http://co.uk",S_OK,FALSE},
1905             {"http",S_OK,FALSE},
1906             {"",S_FALSE,FALSE},
1907             {"",S_FALSE,FALSE}
1908         },
1909         {
1910             {Uri_HOST_DNS,S_OK,FALSE},
1911             {80,S_OK,FALSE},
1912             {URL_SCHEME_HTTP,S_OK,FALSE},
1913             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1914         }
1915     },
1916     {   "http://www.co.google.us.test", 0, S_OK, FALSE,
1917         {
1918             {"http://www.co.google.us.test/",S_OK,FALSE},
1919             {"www.co.google.us.test",S_OK,FALSE},
1920             {"http://www.co.google.us.test/",S_OK,FALSE},
1921             {"us.test",S_OK,FALSE},
1922             {"",S_FALSE,FALSE},
1923             {"",S_FALSE,FALSE},
1924             {"www.co.google.us.test",S_OK,FALSE},
1925             {"",S_FALSE,FALSE},
1926             {"/",S_OK,FALSE},
1927             {"/",S_OK,FALSE},
1928             {"",S_FALSE,FALSE},
1929             {"http://www.co.google.us.test",S_OK,FALSE},
1930             {"http",S_OK,FALSE},
1931             {"",S_FALSE,FALSE},
1932             {"",S_FALSE,FALSE}
1933         },
1934         {
1935             {Uri_HOST_DNS,S_OK,FALSE},
1936             {80,S_OK,FALSE},
1937             {URL_SCHEME_HTTP,S_OK,FALSE},
1938             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1939         }
1940     },
1941     {   "http://gov.uk", 0, S_OK, FALSE,
1942         {
1943             {"http://gov.uk/",S_OK,FALSE},
1944             {"gov.uk",S_OK,FALSE},
1945             {"http://gov.uk/",S_OK,FALSE},
1946             {"",S_FALSE,FALSE},
1947             {"",S_FALSE,FALSE},
1948             {"",S_FALSE,FALSE},
1949             {"gov.uk",S_OK,FALSE},
1950             {"",S_FALSE,FALSE},
1951             {"/",S_OK,FALSE},
1952             {"/",S_OK,FALSE},
1953             {"",S_FALSE,FALSE},
1954             {"http://gov.uk",S_OK,FALSE},
1955             {"http",S_OK,FALSE},
1956             {"",S_FALSE,FALSE},
1957             {"",S_FALSE,FALSE}
1958         },
1959         {
1960             {Uri_HOST_DNS,S_OK,FALSE},
1961             {80,S_OK,FALSE},
1962             {URL_SCHEME_HTTP,S_OK,FALSE},
1963             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1964         }
1965     },
1966     {   "zip://www.google.com\\test", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1967         {
1968             {"zip://www.google.com\\test",S_OK,FALSE},
1969             {"www.google.com\\test",S_OK,FALSE},
1970             {"zip://www.google.com\\test",S_OK,FALSE},
1971             {"google.com\\test",S_OK,FALSE},
1972             {"",S_FALSE,FALSE},
1973             {"",S_FALSE,FALSE},
1974             {"www.google.com\\test",S_OK,FALSE},
1975             {"",S_FALSE,FALSE},
1976             {"",S_FALSE,FALSE},
1977             {"",S_FALSE,FALSE},
1978             {"",S_FALSE,FALSE},
1979             {"zip://www.google.com\\test",S_OK,FALSE},
1980             {"zip",S_OK,FALSE},
1981             {"",S_FALSE,FALSE},
1982             {"",S_FALSE,FALSE}
1983         },
1984         {
1985             {Uri_HOST_DNS,S_OK,FALSE},
1986             {0,S_FALSE,FALSE},
1987             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1988             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1989         }
1990     },
1991     {   "urn:excepts:bad:%XY:encoded", 0, S_OK, FALSE,
1992         {
1993             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
1994             {"",S_FALSE,FALSE},
1995             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
1996             {"",S_FALSE,FALSE},
1997             {"",S_FALSE,FALSE},
1998             {"",S_FALSE,FALSE},
1999             {"",S_FALSE,FALSE},
2000             {"",S_FALSE,FALSE},
2001             {"excepts:bad:%XY:encoded",S_OK,FALSE},
2002             {"excepts:bad:%XY:encoded",S_OK,FALSE},
2003             {"",S_FALSE,FALSE},
2004             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2005             {"urn",S_OK,FALSE},
2006             {"",S_FALSE,FALSE},
2007             {"",S_FALSE,FALSE}
2008         },
2009         {
2010             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2011             {0,S_FALSE,FALSE},
2012             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2013             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2014         }
2015     },
2016     /* Since the original URI doesn't contain an extra '/' before the path no % encoded values
2017      * are decoded and all '%' are encoded.
2018      */
2019     {   "file://C:/te%3Es%2Et/tes%t.mp3", 0, S_OK, FALSE,
2020         {
2021             {"file:///C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2022             {"",S_FALSE,FALSE},
2023             {"file:///C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2024             {"",S_FALSE,FALSE},
2025             {".mp3",S_OK,FALSE},
2026             {"",S_FALSE,FALSE},
2027             {"",S_FALSE,FALSE},
2028             {"",S_FALSE,FALSE},
2029             {"/C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2030             {"/C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2031             {"",S_FALSE,FALSE},
2032             {"file://C:/te%3Es%2Et/tes%t.mp3",S_OK,FALSE},
2033             {"file",S_OK,FALSE},
2034             {"",S_FALSE,FALSE},
2035             {"",S_FALSE,FALSE}
2036         },
2037         {
2038             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2039             {0,S_FALSE,FALSE},
2040             {URL_SCHEME_FILE,S_OK,FALSE},
2041             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2042         }
2043     },
2044     /* Since there's a '/' in front of the drive letter, any percent encoded, non-forbidden character
2045      * is decoded and only %'s in front of invalid hex digits are encoded.
2046      */
2047     {   "file:///C:/te%3Es%2Et/t%23es%t.mp3", 0, S_OK, FALSE,
2048         {
2049             {"file:///C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2050             {"",S_FALSE,FALSE},
2051             {"file:///C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2052             {"",S_FALSE,FALSE},
2053             {".mp3",S_OK,FALSE},
2054             {"",S_FALSE,FALSE},
2055             {"",S_FALSE,FALSE},
2056             {"",S_FALSE,FALSE},
2057             {"/C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2058             {"/C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2059             {"",S_FALSE,FALSE},
2060             {"file:///C:/te%3Es%2Et/t%23es%t.mp3",S_OK,FALSE},
2061             {"file",S_OK,FALSE},
2062             {"",S_FALSE,FALSE},
2063             {"",S_FALSE,FALSE}
2064         },
2065         {
2066             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2067             {0,S_FALSE,FALSE},
2068             {URL_SCHEME_FILE,S_OK,FALSE},
2069             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2070         }
2071     },
2072     /* Only unreserved percent encoded characters are decoded for known schemes that aren't file. */
2073     {   "http://[::001.002.003.000]/%3F%23%2E%54/test", 0, S_OK, FALSE,
2074         {
2075             {"http://[::1.2.3.0]/%3F%23.T/test",S_OK,FALSE},
2076             {"[::1.2.3.0]",S_OK,FALSE},
2077             {"http://[::1.2.3.0]/%3F%23.T/test",S_OK,FALSE},
2078             {"",S_FALSE,FALSE},
2079             {"",S_FALSE,FALSE},
2080             {"",S_FALSE,FALSE},
2081             {"::1.2.3.0",S_OK,FALSE},
2082             {"",S_FALSE,FALSE},
2083             {"/%3F%23.T/test",S_OK,FALSE},
2084             {"/%3F%23.T/test",S_OK,FALSE},
2085             {"",S_FALSE,FALSE},
2086             {"http://[::001.002.003.000]/%3F%23%2E%54/test",S_OK,FALSE},
2087             {"http",S_OK,FALSE},
2088             {"",S_FALSE,FALSE},
2089             {"",S_FALSE,FALSE},
2090         },
2091         {
2092             {Uri_HOST_IPV6,S_OK,FALSE},
2093             {80,S_OK,FALSE},
2094             {URL_SCHEME_HTTP,S_OK,FALSE},
2095             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2096         }
2097     },
2098     /* Forbidden characters are always encoded for file URIs. */
2099     {   "file:///C:/\"test\"/test.mp3", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2100         {
2101             {"file:///C:/%22test%22/test.mp3",S_OK,FALSE},
2102             {"",S_FALSE,FALSE},
2103             {"file:///C:/%22test%22/test.mp3",S_OK,FALSE},
2104             {"",S_FALSE,FALSE},
2105             {".mp3",S_OK,FALSE},
2106             {"",S_FALSE,FALSE},
2107             {"",S_FALSE,FALSE},
2108             {"",S_FALSE,FALSE},
2109             {"/C:/%22test%22/test.mp3",S_OK,FALSE},
2110             {"/C:/%22test%22/test.mp3",S_OK,FALSE},
2111             {"",S_FALSE,FALSE},
2112             {"file:///C:/\"test\"/test.mp3",S_OK,FALSE},
2113             {"file",S_OK,FALSE},
2114             {"",S_FALSE,FALSE},
2115             {"",S_FALSE,FALSE}
2116         },
2117         {
2118             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2119             {0,S_FALSE,FALSE},
2120             {URL_SCHEME_FILE,S_OK,FALSE},
2121             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2122         }
2123     },
2124     /* Forbidden characters are never encoded for unknown scheme types. */
2125     {   "1234://4294967295/<|>\" test<|>", 0, S_OK, FALSE,
2126         {
2127             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2128             {"4294967295",S_OK,FALSE},
2129             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2130             {"",S_FALSE,FALSE},
2131             {"",S_FALSE,FALSE},
2132             {"",S_FALSE,FALSE},
2133             {"4294967295",S_OK,FALSE},
2134             {"",S_FALSE,FALSE},
2135             {"/<|>\" test<|>",S_OK,FALSE},
2136             {"/<|>\" test<|>",S_OK,FALSE},
2137             {"",S_FALSE,FALSE},
2138             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2139             {"1234",S_OK,FALSE},
2140             {"",S_FALSE,FALSE},
2141             {"",S_FALSE,FALSE}
2142         },
2143         {
2144             {Uri_HOST_IPV4,S_OK,FALSE},
2145             {0,S_FALSE,FALSE},
2146             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2147             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2148         }
2149     },
2150     /* Make sure forbidden characters are percent encoded. */
2151     {   "http://gov.uk/<|> test<|>", 0, S_OK, FALSE,
2152         {
2153             {"http://gov.uk/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2154             {"gov.uk",S_OK,FALSE},
2155             {"http://gov.uk/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2156             {"",S_FALSE,FALSE},
2157             {"",S_FALSE,FALSE},
2158             {"",S_FALSE,FALSE},
2159             {"gov.uk",S_OK,FALSE},
2160             {"",S_FALSE,FALSE},
2161             {"/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2162             {"/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2163             {"",S_FALSE,FALSE},
2164             {"http://gov.uk/<|> test<|>",S_OK,FALSE},
2165             {"http",S_OK,FALSE},
2166             {"",S_FALSE,FALSE},
2167             {"",S_FALSE,FALSE}
2168         },
2169         {
2170             {Uri_HOST_DNS,S_OK,FALSE},
2171             {80,S_OK,FALSE},
2172             {URL_SCHEME_HTTP,S_OK,FALSE},
2173             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2174         }
2175     },
2176     {   "http://gov.uk/test/../test2/././../test3/.././././", 0, S_OK, FALSE,
2177         {
2178             {"http://gov.uk/",S_OK,FALSE},
2179             {"gov.uk",S_OK,FALSE},
2180             {"http://gov.uk/",S_OK,FALSE},
2181             {"",S_FALSE,FALSE},
2182             {"",S_FALSE,FALSE},
2183             {"",S_FALSE,FALSE},
2184             {"gov.uk",S_OK,FALSE},
2185             {"",S_FALSE,FALSE},
2186             {"/",S_OK,FALSE},
2187             {"/",S_OK,FALSE},
2188             {"",S_FALSE,FALSE},
2189             {"http://gov.uk/test/../test2/././../test3/.././././",S_OK,FALSE},
2190             {"http",S_OK,FALSE},
2191             {"",S_FALSE,FALSE},
2192             {"",S_FALSE,FALSE}
2193         },
2194         {
2195             {Uri_HOST_DNS,S_OK,FALSE},
2196             {80,S_OK,FALSE},
2197             {URL_SCHEME_HTTP,S_OK,FALSE},
2198             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2199         }
2200     },
2201     {   "http://gov.uk/test/test2/../../..", 0, S_OK, FALSE,
2202         {
2203             {"http://gov.uk/",S_OK,FALSE},
2204             {"gov.uk",S_OK,FALSE},
2205             {"http://gov.uk/",S_OK,FALSE},
2206             {"",S_FALSE,FALSE},
2207             {"",S_FALSE,FALSE},
2208             {"",S_FALSE,FALSE},
2209             {"gov.uk",S_OK,FALSE},
2210             {"",S_FALSE,FALSE},
2211             {"/",S_OK,FALSE},
2212             {"/",S_OK,FALSE},
2213             {"",S_FALSE,FALSE},
2214             {"http://gov.uk/test/test2/../../..",S_OK,FALSE},
2215             {"http",S_OK,FALSE},
2216             {"",S_FALSE,FALSE},
2217             {"",S_FALSE,FALSE}
2218         },
2219         {
2220             {Uri_HOST_DNS,S_OK,FALSE},
2221             {80,S_OK,FALSE},
2222             {URL_SCHEME_HTTP,S_OK,FALSE},
2223             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2224         }
2225     },
2226     {   "http://gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2227         {
2228             {"http://gov.uk/",S_OK,FALSE},
2229             {"gov.uk",S_OK,FALSE},
2230             {"http://gov.uk/",S_OK,FALSE},
2231             {"",S_FALSE,FALSE},
2232             {"",S_FALSE,FALSE},
2233             {"",S_FALSE,FALSE},
2234             {"gov.uk",S_OK,FALSE},
2235             {"",S_FALSE,FALSE},
2236             {"/",S_OK,FALSE},
2237             {"/",S_OK,FALSE},
2238             {"",S_FALSE,FALSE},
2239             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2240             {"http",S_OK,FALSE},
2241             {"",S_FALSE,FALSE},
2242             {"",S_FALSE,FALSE}
2243         },
2244         {
2245             {Uri_HOST_DNS,S_OK,FALSE},
2246             {80,S_OK,FALSE},
2247             {URL_SCHEME_HTTP,S_OK,FALSE},
2248             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2249         }
2250     },
2251     {   "file://c:\\tests\\../tests\\./.\\..\\foo%20bar.mp3", 0, S_OK, FALSE,
2252         {
2253             {"file:///c:/foo%2520bar.mp3",S_OK,FALSE},
2254             {"",S_FALSE,FALSE},
2255             {"file:///c:/foo%2520bar.mp3",S_OK,FALSE},
2256             {"",S_FALSE,FALSE},
2257             {".mp3",S_OK,FALSE},
2258             {"",S_FALSE,FALSE},
2259             {"",S_FALSE,FALSE},
2260             {"",S_FALSE,FALSE},
2261             {"/c:/foo%2520bar.mp3",S_OK,FALSE},
2262             {"/c:/foo%2520bar.mp3",S_OK,FALSE},
2263             {"",S_FALSE,FALSE},
2264             {"file://c:\\tests\\../tests\\./.\\..\\foo%20bar.mp3",S_OK,FALSE},
2265             {"file",S_OK,FALSE},
2266             {"",S_FALSE,FALSE},
2267             {"",S_FALSE,FALSE}
2268         },
2269         {
2270             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2271             {0,S_FALSE,FALSE},
2272             {URL_SCHEME_FILE,S_OK,FALSE},
2273             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2274         }
2275     },
2276     /* Dot removal happens for unknown scheme types. */
2277     {   "zip://gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2278         {
2279             {"zip://gov.uk/",S_OK,FALSE},
2280             {"gov.uk",S_OK,FALSE},
2281             {"zip://gov.uk/",S_OK,FALSE},
2282             {"",S_FALSE,FALSE},
2283             {"",S_FALSE,FALSE},
2284             {"",S_FALSE,FALSE},
2285             {"gov.uk",S_OK,FALSE},
2286             {"",S_FALSE,FALSE},
2287             {"/",S_OK,FALSE},
2288             {"/",S_OK,FALSE},
2289             {"",S_FALSE,FALSE},
2290             {"zip://gov.uk/test/test2/../../.",S_OK,FALSE},
2291             {"zip",S_OK,FALSE},
2292             {"",S_FALSE,FALSE},
2293             {"",S_FALSE,FALSE}
2294         },
2295         {
2296             {Uri_HOST_DNS,S_OK,FALSE},
2297             {0,S_FALSE,FALSE},
2298             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2299             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2300         }
2301     },
2302     /* Dot removal doesn't happen if NO_CANONICALIZE is set. */
2303     {   "http://gov.uk/test/test2/../../.", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2304         {
2305             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2306             {"gov.uk",S_OK,FALSE},
2307             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2308             {"",S_FALSE,FALSE},
2309             {".",S_OK,FALSE},
2310             {"",S_FALSE,FALSE},
2311             {"gov.uk",S_OK,FALSE},
2312             {"",S_FALSE,FALSE},
2313             {"/test/test2/../../.",S_OK,FALSE},
2314             {"/test/test2/../../.",S_OK,FALSE},
2315             {"",S_FALSE,FALSE},
2316             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2317             {"http",S_OK,FALSE},
2318             {"",S_FALSE,FALSE},
2319             {"",S_FALSE,FALSE}
2320         },
2321         {
2322             {Uri_HOST_DNS,S_OK,FALSE},
2323             {80,S_OK,FALSE},
2324             {URL_SCHEME_HTTP,S_OK,FALSE},
2325             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2326         }
2327     },
2328     /* Dot removal doesn't happen for wildcard scheme types. */
2329     {   "*:gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2330         {
2331             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2332             {"gov.uk",S_OK,FALSE},
2333             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2334             {"",S_FALSE,FALSE},
2335             {".",S_OK,FALSE},
2336             {"",S_FALSE,FALSE},
2337             {"gov.uk",S_OK,FALSE},
2338             {"",S_FALSE,FALSE},
2339             {"/test/test2/../../.",S_OK,FALSE},
2340             {"/test/test2/../../.",S_OK,FALSE},
2341             {"",S_FALSE,FALSE},
2342             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2343             {"*",S_OK,FALSE},
2344             {"",S_FALSE,FALSE},
2345             {"",S_FALSE,FALSE}
2346         },
2347         {
2348             {Uri_HOST_DNS,S_OK,FALSE},
2349             {0,S_FALSE,FALSE},
2350             {URL_SCHEME_WILDCARD,S_OK,FALSE},
2351             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2352         }
2353     },
2354     /* Forbidden characters are encoded for opaque known scheme types. */
2355     {   "mailto:\"acco<|>unt@example.com\"", 0, S_OK, FALSE,
2356         {
2357             {"mailto:%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2358             {"",S_FALSE,FALSE},
2359             {"mailto:%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2360             {"",S_FALSE,FALSE},
2361             {".com%22",S_OK,FALSE},
2362             {"",S_FALSE,FALSE},
2363             {"",S_FALSE,FALSE},
2364             {"",S_FALSE,FALSE},
2365             {"%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2366             {"%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2367             {"",S_FALSE,FALSE},
2368             {"mailto:\"acco<|>unt@example.com\"",S_OK,FALSE},
2369             {"mailto",S_OK,FALSE},
2370             {"",S_FALSE,FALSE},
2371             {"",S_FALSE,FALSE}
2372         },
2373         {
2374             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2375             {0,S_FALSE,FALSE},
2376             {URL_SCHEME_MAILTO,S_OK,FALSE},
2377             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2378         }
2379     },
2380     {   "news:test.tes<|>t.com", 0, S_OK, FALSE,
2381         {
2382             {"news:test.tes%3C%7C%3Et.com",S_OK,FALSE},
2383             {"",S_FALSE,FALSE},
2384             {"news:test.tes%3C%7C%3Et.com",S_OK,FALSE},
2385             {"",S_FALSE,FALSE},
2386             {".com",S_OK,FALSE},
2387             {"",S_FALSE,FALSE},
2388             {"",S_FALSE,FALSE},
2389             {"",S_FALSE,FALSE},
2390             {"test.tes%3C%7C%3Et.com",S_OK,FALSE},
2391             {"test.tes%3C%7C%3Et.com",S_OK,FALSE},
2392             {"",S_FALSE,FALSE},
2393             {"news:test.tes<|>t.com",S_OK,FALSE},
2394             {"news",S_OK,FALSE},
2395             {"",S_FALSE,FALSE},
2396             {"",S_FALSE,FALSE}
2397         },
2398         {
2399             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2400             {0,S_FALSE,FALSE},
2401             {URL_SCHEME_NEWS,S_OK,FALSE},
2402             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2403         }
2404     },
2405     /* Don't encode forbidden characters. */
2406     {   "news:test.tes<|>t.com", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2407         {
2408             {"news:test.tes<|>t.com",S_OK,FALSE},
2409             {"",S_FALSE,FALSE},
2410             {"news:test.tes<|>t.com",S_OK,FALSE},
2411             {"",S_FALSE,FALSE},
2412             {".com",S_OK,FALSE},
2413             {"",S_FALSE,FALSE},
2414             {"",S_FALSE,FALSE},
2415             {"",S_FALSE,FALSE},
2416             {"test.tes<|>t.com",S_OK,FALSE},
2417             {"test.tes<|>t.com",S_OK,FALSE},
2418             {"",S_FALSE,FALSE},
2419             {"news:test.tes<|>t.com",S_OK,FALSE},
2420             {"news",S_OK,FALSE},
2421             {"",S_FALSE,FALSE},
2422             {"",S_FALSE,FALSE}
2423         },
2424         {
2425             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2426             {0,S_FALSE,FALSE},
2427             {URL_SCHEME_NEWS,S_OK,FALSE},
2428             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2429         }
2430     },
2431     /* Forbidden characters aren't encoded for unknown, opaque URIs. */
2432     {   "urn:test.tes<|>t.com", 0, S_OK, FALSE,
2433         {
2434             {"urn:test.tes<|>t.com",S_OK,FALSE},
2435             {"",S_FALSE,FALSE},
2436             {"urn:test.tes<|>t.com",S_OK,FALSE},
2437             {"",S_FALSE,FALSE},
2438             {".com",S_OK,FALSE},
2439             {"",S_FALSE,FALSE},
2440             {"",S_FALSE,FALSE},
2441             {"",S_FALSE,FALSE},
2442             {"test.tes<|>t.com",S_OK,FALSE},
2443             {"test.tes<|>t.com",S_OK,FALSE},
2444             {"",S_FALSE,FALSE},
2445             {"urn:test.tes<|>t.com",S_OK,FALSE},
2446             {"urn",S_OK,FALSE},
2447             {"",S_FALSE,FALSE},
2448             {"",S_FALSE,FALSE}
2449         },
2450         {
2451             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2452             {0,S_FALSE,FALSE},
2453             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2454             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2455         }
2456     },
2457     /* Percent encoded unreserved characters are decoded for known opaque URIs. */
2458     {   "news:test.%74%65%73%74.com", 0, S_OK, FALSE,
2459         {
2460             {"news:test.test.com",S_OK,FALSE},
2461             {"",S_FALSE,FALSE},
2462             {"news:test.test.com",S_OK,FALSE},
2463             {"",S_FALSE,FALSE},
2464             {".com",S_OK,FALSE},
2465             {"",S_FALSE,FALSE},
2466             {"",S_FALSE,FALSE},
2467             {"",S_FALSE,FALSE},
2468             {"test.test.com",S_OK,FALSE},
2469             {"test.test.com",S_OK,FALSE},
2470             {"",S_FALSE,FALSE},
2471             {"news:test.%74%65%73%74.com",S_OK,FALSE},
2472             {"news",S_OK,FALSE},
2473             {"",S_FALSE,FALSE},
2474             {"",S_FALSE,FALSE}
2475         },
2476         {
2477             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2478             {0,S_FALSE,FALSE},
2479             {URL_SCHEME_NEWS,S_OK,FALSE},
2480             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2481         }
2482     },
2483     /* Percent encoded characters are still decoded for known scheme types. */
2484     {   "news:test.%74%65%73%74.com", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2485         {
2486             {"news:test.test.com",S_OK,FALSE},
2487             {"",S_FALSE,FALSE},
2488             {"news:test.test.com",S_OK,FALSE},
2489             {"",S_FALSE,FALSE},
2490             {".com",S_OK,FALSE},
2491             {"",S_FALSE,FALSE},
2492             {"",S_FALSE,FALSE},
2493             {"",S_FALSE,FALSE},
2494             {"test.test.com",S_OK,FALSE},
2495             {"test.test.com",S_OK,FALSE},
2496             {"",S_FALSE,FALSE},
2497             {"news:test.%74%65%73%74.com",S_OK,FALSE},
2498             {"news",S_OK,FALSE},
2499             {"",S_FALSE,FALSE},
2500             {"",S_FALSE,FALSE}
2501         },
2502         {
2503             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2504             {0,S_FALSE,FALSE},
2505             {URL_SCHEME_NEWS,S_OK,FALSE},
2506             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2507         }
2508     },
2509     /* Percent encoded characters aren't decoded for unknown scheme types. */
2510     {   "urn:test.%74%65%73%74.com", 0, S_OK, FALSE,
2511         {
2512             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2513             {"",S_FALSE,FALSE},
2514             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2515             {"",S_FALSE,FALSE},
2516             {".com",S_OK,FALSE},
2517             {"",S_FALSE,FALSE},
2518             {"",S_FALSE,FALSE},
2519             {"",S_FALSE,FALSE},
2520             {"test.%74%65%73%74.com",S_OK,FALSE},
2521             {"test.%74%65%73%74.com",S_OK,FALSE},
2522             {"",S_FALSE,FALSE},
2523             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2524             {"urn",S_OK,FALSE},
2525             {"",S_FALSE,FALSE},
2526             {"",S_FALSE,FALSE}
2527         },
2528         {
2529             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2530             {0,S_FALSE,FALSE},
2531             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2532             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2533         }
2534     },
2535     /* Unknown scheme types can have invalid % encoded data in query string. */
2536     {   "zip://www.winehq.org/tests/..?query=%xx&return=y", 0, S_OK, FALSE,
2537         {
2538             {"zip://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2539             {"www.winehq.org",S_OK,FALSE},
2540             {"zip://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2541             {"winehq.org",S_OK,FALSE},
2542             {"",S_FALSE,FALSE},
2543             {"",S_FALSE,FALSE},
2544             {"www.winehq.org",S_OK,FALSE},
2545             {"",S_FALSE,FALSE},
2546             {"/",S_OK,FALSE},
2547             {"/?query=%xx&return=y",S_OK,FALSE},
2548             {"?query=%xx&return=y",S_OK,FALSE},
2549             {"zip://www.winehq.org/tests/..?query=%xx&return=y",S_OK,FALSE},
2550             {"zip",S_OK,FALSE},
2551             {"",S_FALSE,FALSE},
2552             {"",S_FALSE,FALSE}
2553         },
2554         {
2555             {Uri_HOST_DNS,S_OK,FALSE},
2556             {0,S_FALSE,FALSE},
2557             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2558             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2559         }
2560     },
2561     /* Known scheme types can have invalid % encoded data with the right flags. */
2562     {   "http://www.winehq.org/tests/..?query=%xx&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2563         {
2564             {"http://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2565             {"www.winehq.org",S_OK,FALSE},
2566             {"http://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2567             {"winehq.org",S_OK,FALSE},
2568             {"",S_FALSE,FALSE},
2569             {"",S_FALSE,FALSE},
2570             {"www.winehq.org",S_OK,FALSE},
2571             {"",S_FALSE,FALSE},
2572             {"/",S_OK,FALSE},
2573             {"/?query=%xx&return=y",S_OK,FALSE},
2574             {"?query=%xx&return=y",S_OK,FALSE},
2575             {"http://www.winehq.org/tests/..?query=%xx&return=y",S_OK,FALSE},
2576             {"http",S_OK,FALSE},
2577             {"",S_FALSE,FALSE},
2578             {"",S_FALSE,FALSE}
2579         },
2580         {
2581             {Uri_HOST_DNS,S_OK,FALSE},
2582             {80,S_OK,FALSE},
2583             {URL_SCHEME_HTTP,S_OK,FALSE},
2584             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2585         }
2586     },
2587     /* Forbidden characters in query aren't percent encoded for known scheme types with this flag. */
2588     {   "http://www.winehq.org/tests/..?query=<|>&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2589         {
2590             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2591             {"www.winehq.org",S_OK,FALSE},
2592             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2593             {"winehq.org",S_OK,FALSE},
2594             {"",S_FALSE,FALSE},
2595             {"",S_FALSE,FALSE},
2596             {"www.winehq.org",S_OK,FALSE},
2597             {"",S_FALSE,FALSE},
2598             {"/",S_OK,FALSE},
2599             {"/?query=<|>&return=y",S_OK,FALSE},
2600             {"?query=<|>&return=y",S_OK,FALSE},
2601             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2602             {"http",S_OK,FALSE},
2603             {"",S_FALSE,FALSE},
2604             {"",S_FALSE,FALSE}
2605         },
2606         {
2607             {Uri_HOST_DNS,S_OK,FALSE},
2608             {80,S_OK,FALSE},
2609             {URL_SCHEME_HTTP,S_OK,FALSE},
2610             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2611         }
2612     },
2613     /* Forbidden characters in query aren't percent encoded for known scheme types with this flag. */
2614     {   "http://www.winehq.org/tests/..?query=<|>&return=y", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2615         {
2616             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2617             {"www.winehq.org",S_OK,FALSE},
2618             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2619             {"winehq.org",S_OK,FALSE},
2620             {"",S_FALSE,FALSE},
2621             {"",S_FALSE,FALSE},
2622             {"www.winehq.org",S_OK,FALSE},
2623             {"",S_FALSE,FALSE},
2624             {"/",S_OK,FALSE},
2625             {"/?query=<|>&return=y",S_OK,FALSE},
2626             {"?query=<|>&return=y",S_OK,FALSE},
2627             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2628             {"http",S_OK,FALSE},
2629             {"",S_FALSE,FALSE},
2630             {"",S_FALSE,FALSE}
2631         },
2632         {
2633             {Uri_HOST_DNS,S_OK,FALSE},
2634             {80,S_OK,FALSE},
2635             {URL_SCHEME_HTTP,S_OK,FALSE},
2636             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2637         }
2638     },
2639     /* Forbidden characters are encoded for known scheme types. */
2640     {   "http://www.winehq.org/tests/..?query=<|>&return=y", 0, S_OK, FALSE,
2641         {
2642             {"http://www.winehq.org/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2643             {"www.winehq.org",S_OK,FALSE},
2644             {"http://www.winehq.org/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2645             {"winehq.org",S_OK,FALSE},
2646             {"",S_FALSE,FALSE},
2647             {"",S_FALSE,FALSE},
2648             {"www.winehq.org",S_OK,FALSE},
2649             {"",S_FALSE,FALSE},
2650             {"/",S_OK,FALSE},
2651             {"/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2652             {"?query=%3C%7C%3E&return=y",S_OK,FALSE},
2653             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2654             {"http",S_OK,FALSE},
2655             {"",S_FALSE,FALSE},
2656             {"",S_FALSE,FALSE}
2657         },
2658         {
2659             {Uri_HOST_DNS,S_OK,FALSE},
2660             {80,S_OK,FALSE},
2661             {URL_SCHEME_HTTP,S_OK,FALSE},
2662             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2663         }
2664     },
2665     /* Forbidden characters are not encoded for unknown scheme types. */
2666     {   "zip://www.winehq.org/tests/..?query=<|>&return=y", 0, S_OK, FALSE,
2667         {
2668             {"zip://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2669             {"www.winehq.org",S_OK,FALSE},
2670             {"zip://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2671             {"winehq.org",S_OK,FALSE},
2672             {"",S_FALSE,FALSE},
2673             {"",S_FALSE,FALSE},
2674             {"www.winehq.org",S_OK,FALSE},
2675             {"",S_FALSE,FALSE},
2676             {"/",S_OK,FALSE},
2677             {"/?query=<|>&return=y",S_OK,FALSE},
2678             {"?query=<|>&return=y",S_OK,FALSE},
2679             {"zip://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2680             {"zip",S_OK,FALSE},
2681             {"",S_FALSE,FALSE},
2682             {"",S_FALSE,FALSE}
2683         },
2684         {
2685             {Uri_HOST_DNS,S_OK,FALSE},
2686             {0,S_FALSE,FALSE},
2687             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2688             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2689         }
2690     },
2691     /* Percent encoded, unreserved characters are decoded for known scheme types. */
2692     {   "http://www.winehq.org/tests/..?query=%30%31&return=y", 0, S_OK, FALSE,
2693         {
2694             {"http://www.winehq.org/?query=01&return=y",S_OK,FALSE},
2695             {"www.winehq.org",S_OK,FALSE},
2696             {"http://www.winehq.org/?query=01&return=y",S_OK,FALSE},
2697             {"winehq.org",S_OK,FALSE},
2698             {"",S_FALSE,FALSE},
2699             {"",S_FALSE,FALSE},
2700             {"www.winehq.org",S_OK,FALSE},
2701             {"",S_FALSE,FALSE},
2702             {"/",S_OK,FALSE},
2703             {"/?query=01&return=y",S_OK,FALSE},
2704             {"?query=01&return=y",S_OK,FALSE},
2705             {"http://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2706             {"http",S_OK,FALSE},
2707             {"",S_FALSE,FALSE},
2708             {"",S_FALSE,FALSE}
2709         },
2710         {
2711             {Uri_HOST_DNS,S_OK,FALSE},
2712             {80,S_OK,FALSE},
2713             {URL_SCHEME_HTTP,S_OK,FALSE},
2714             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2715         }
2716     },
2717     /* Percent encoded, unreserved characters aren't decoded for unknown scheme types. */
2718     {   "zip://www.winehq.org/tests/..?query=%30%31&return=y", 0, S_OK, FALSE,
2719         {
2720             {"zip://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2721             {"www.winehq.org",S_OK,FALSE},
2722             {"zip://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2723             {"winehq.org",S_OK,FALSE},
2724             {"",S_FALSE,FALSE},
2725             {"",S_FALSE,FALSE},
2726             {"www.winehq.org",S_OK,FALSE},
2727             {"",S_FALSE,FALSE},
2728             {"/",S_OK,FALSE},
2729             {"/?query=%30%31&return=y",S_OK,FALSE},
2730             {"?query=%30%31&return=y",S_OK,FALSE},
2731             {"zip://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2732             {"zip",S_OK,FALSE},
2733             {"",S_FALSE,FALSE},
2734             {"",S_FALSE,FALSE}
2735         },
2736         {
2737             {Uri_HOST_DNS,S_OK,FALSE},
2738             {0,S_FALSE,FALSE},
2739             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2740             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2741         }
2742     },
2743     /* Percent encoded characters aren't decoded when NO_DECODE_EXTRA_INFO is set. */
2744     {   "http://www.winehq.org/tests/..?query=%30%31&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2745         {
2746             {"http://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2747             {"www.winehq.org",S_OK,FALSE},
2748             {"http://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2749             {"winehq.org",S_OK,FALSE},
2750             {"",S_FALSE,FALSE},
2751             {"",S_FALSE,FALSE},
2752             {"www.winehq.org",S_OK,FALSE},
2753             {"",S_FALSE,FALSE},
2754             {"/",S_OK,FALSE},
2755             {"/?query=%30%31&return=y",S_OK,FALSE},
2756             {"?query=%30%31&return=y",S_OK,FALSE},
2757             {"http://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2758             {"http",S_OK,FALSE},
2759             {"",S_FALSE,FALSE},
2760             {"",S_FALSE,FALSE}
2761         },
2762         {
2763             {Uri_HOST_DNS,S_OK,FALSE},
2764             {80,S_OK,FALSE},
2765             {URL_SCHEME_HTTP,S_OK,FALSE},
2766             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2767         }
2768     },
2769     {   "http://www.winehq.org?query=12&return=y", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2770         {
2771             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2772             {"www.winehq.org",S_OK,FALSE},
2773             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2774             {"winehq.org",S_OK,FALSE},
2775             {"",S_FALSE,FALSE},
2776             {"",S_FALSE,FALSE},
2777             {"www.winehq.org",S_OK,FALSE},
2778             {"",S_FALSE,FALSE},
2779             {"",S_FALSE,FALSE},
2780             {"?query=12&return=y",S_OK,FALSE},
2781             {"?query=12&return=y",S_OK,FALSE},
2782             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2783             {"http",S_OK,FALSE},
2784             {"",S_FALSE,FALSE},
2785             {"",S_FALSE,FALSE}
2786         },
2787         {
2788             {Uri_HOST_DNS,S_OK,FALSE},
2789             {80,S_OK,FALSE},
2790             {URL_SCHEME_HTTP,S_OK,FALSE},
2791             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2792         }
2793     },
2794     /* Unknown scheme types can have invalid % encoded data in fragments. */
2795     {   "zip://www.winehq.org/tests/#Te%xx", 0, S_OK, FALSE,
2796         {
2797             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2798             {"www.winehq.org",S_OK,FALSE},
2799             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2800             {"winehq.org",S_OK,FALSE},
2801             {"",S_FALSE,FALSE},
2802             {"#Te%xx",S_OK,FALSE},
2803             {"www.winehq.org",S_OK,FALSE},
2804             {"",S_FALSE,FALSE},
2805             {"/tests/",S_OK,FALSE},
2806             {"/tests/",S_OK,FALSE},
2807             {"",S_FALSE,FALSE},
2808             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2809             {"zip",S_OK,FALSE},
2810             {"",S_FALSE,FALSE},
2811             {"",S_FALSE,FALSE}
2812         },
2813         {
2814             {Uri_HOST_DNS,S_OK,FALSE},
2815             {0,S_FALSE,FALSE},
2816             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2817             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2818         }
2819     },
2820     /* Forbidden characters in fragment aren't encoded for unknown schemes. */
2821     {   "zip://www.winehq.org/tests/#Te<|>", 0, S_OK, FALSE,
2822         {
2823             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2824             {"www.winehq.org",S_OK,FALSE},
2825             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2826             {"winehq.org",S_OK,FALSE},
2827             {"",S_FALSE,FALSE},
2828             {"#Te<|>",S_OK,FALSE},
2829             {"www.winehq.org",S_OK,FALSE},
2830             {"",S_FALSE,FALSE},
2831             {"/tests/",S_OK,FALSE},
2832             {"/tests/",S_OK,FALSE},
2833             {"",S_FALSE,FALSE},
2834             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2835             {"zip",S_OK,FALSE},
2836             {"",S_FALSE,FALSE},
2837             {"",S_FALSE,FALSE}
2838         },
2839         {
2840             {Uri_HOST_DNS,S_OK,FALSE},
2841             {0,S_FALSE,FALSE},
2842             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2843             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2844         }
2845     },
2846     /* Forbidden characters in the fragment are percent encoded for known schemes. */
2847     {   "http://www.winehq.org/tests/#Te<|>", 0, S_OK, FALSE,
2848         {
2849             {"http://www.winehq.org/tests/#Te%3C%7C%3E",S_OK,FALSE},
2850             {"www.winehq.org",S_OK,FALSE},
2851             {"http://www.winehq.org/tests/#Te%3C%7C%3E",S_OK,FALSE},
2852             {"winehq.org",S_OK,FALSE},
2853             {"",S_FALSE,FALSE},
2854             {"#Te%3C%7C%3E",S_OK,FALSE},
2855             {"www.winehq.org",S_OK,FALSE},
2856             {"",S_FALSE,FALSE},
2857             {"/tests/",S_OK,FALSE},
2858             {"/tests/",S_OK,FALSE},
2859             {"",S_FALSE,FALSE},
2860             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2861             {"http",S_OK,FALSE},
2862             {"",S_FALSE,FALSE},
2863             {"",S_FALSE,FALSE}
2864         },
2865         {
2866             {Uri_HOST_DNS,S_OK,FALSE},
2867             {80,S_OK,FALSE},
2868             {URL_SCHEME_HTTP,S_OK,FALSE},
2869             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2870         }
2871     },
2872     /* Forbidden characters aren't encoded in the fragment with this flag. */
2873     {   "http://www.winehq.org/tests/#Te<|>", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2874         {
2875             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2876             {"www.winehq.org",S_OK,FALSE},
2877             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2878             {"winehq.org",S_OK,FALSE},
2879             {"",S_FALSE,FALSE},
2880             {"#Te<|>",S_OK,FALSE},
2881             {"www.winehq.org",S_OK,FALSE},
2882             {"",S_FALSE,FALSE},
2883             {"/tests/",S_OK,FALSE},
2884             {"/tests/",S_OK,FALSE},
2885             {"",S_FALSE,FALSE},
2886             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2887             {"http",S_OK,FALSE},
2888             {"",S_FALSE,FALSE},
2889             {"",S_FALSE,FALSE}
2890         },
2891         {
2892             {Uri_HOST_DNS,S_OK,FALSE},
2893             {80,S_OK,FALSE},
2894             {URL_SCHEME_HTTP,S_OK,FALSE},
2895             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2896         }
2897     },
2898     /* Forbidden characters aren't encoded in the fragment with this flag. */
2899     {   "http://www.winehq.org/tests/#Te<|>", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2900         {
2901             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2902             {"www.winehq.org",S_OK,FALSE},
2903             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2904             {"winehq.org",S_OK,FALSE},
2905             {"",S_FALSE,FALSE},
2906             {"#Te<|>",S_OK,FALSE},
2907             {"www.winehq.org",S_OK,FALSE},
2908             {"",S_FALSE,FALSE},
2909             {"/tests/",S_OK,FALSE},
2910             {"/tests/",S_OK,FALSE},
2911             {"",S_FALSE,FALSE},
2912             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2913             {"http",S_OK,FALSE},
2914             {"",S_FALSE,FALSE},
2915             {"",S_FALSE,FALSE}
2916         },
2917         {
2918             {Uri_HOST_DNS,S_OK,FALSE},
2919             {80,S_OK,FALSE},
2920             {URL_SCHEME_HTTP,S_OK,FALSE},
2921             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2922         }
2923     },
2924     /* Percent encoded, unreserved characters aren't decoded for known scheme types. */
2925     {   "zip://www.winehq.org/tests/#Te%30%31%32", 0, S_OK, FALSE,
2926         {
2927             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2928             {"www.winehq.org",S_OK,FALSE},
2929             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2930             {"winehq.org",S_OK,FALSE},
2931             {"",S_FALSE,FALSE},
2932             {"#Te%30%31%32",S_OK,FALSE},
2933             {"www.winehq.org",S_OK,FALSE},
2934             {"",S_FALSE,FALSE},
2935             {"/tests/",S_OK,FALSE},
2936             {"/tests/",S_OK,FALSE},
2937             {"",S_FALSE,FALSE},
2938             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2939             {"zip",S_OK,FALSE},
2940             {"",S_FALSE,FALSE},
2941             {"",S_FALSE,FALSE}
2942         },
2943         {
2944             {Uri_HOST_DNS,S_OK,FALSE},
2945             {0,S_FALSE,FALSE},
2946             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2947             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2948         }
2949     },
2950     /* Percent encoded, unreserved characters are decoded for known schemes. */
2951     {   "http://www.winehq.org/tests/#Te%30%31%32", 0, S_OK, FALSE,
2952         {
2953             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
2954             {"www.winehq.org",S_OK,FALSE},
2955             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
2956             {"winehq.org",S_OK,FALSE},
2957             {"",S_FALSE,FALSE},
2958             {"#Te012",S_OK,FALSE},
2959             {"www.winehq.org",S_OK,FALSE},
2960             {"",S_FALSE,FALSE},
2961             {"/tests/",S_OK,FALSE},
2962             {"/tests/",S_OK,FALSE},
2963             {"",S_FALSE,FALSE},
2964             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2965             {"http",S_OK,FALSE},
2966             {"",S_FALSE,FALSE},
2967             {"",S_FALSE,FALSE}
2968         },
2969         {
2970             {Uri_HOST_DNS,S_OK,FALSE},
2971             {80,S_OK,FALSE},
2972             {URL_SCHEME_HTTP,S_OK,FALSE},
2973             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2974         }
2975     },
2976     /* Percent encoded, unreserved characters are decoded even if NO_CANONICALIZE is set. */
2977     {   "http://www.winehq.org/tests/#Te%30%31%32", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2978         {
2979             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
2980             {"www.winehq.org",S_OK,FALSE},
2981             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
2982             {"winehq.org",S_OK,FALSE},
2983             {"",S_FALSE,FALSE},
2984             {"#Te012",S_OK,FALSE},
2985             {"www.winehq.org",S_OK,FALSE},
2986             {"",S_FALSE,FALSE},
2987             {"/tests/",S_OK,FALSE},
2988             {"/tests/",S_OK,FALSE},
2989             {"",S_FALSE,FALSE},
2990             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2991             {"http",S_OK,FALSE},
2992             {"",S_FALSE,FALSE},
2993             {"",S_FALSE,FALSE}
2994         },
2995         {
2996             {Uri_HOST_DNS,S_OK,FALSE},
2997             {80,S_OK,FALSE},
2998             {URL_SCHEME_HTTP,S_OK,FALSE},
2999             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3000         }
3001     },
3002     /* Percent encoded, unreserved characters aren't decoded when NO_DECODE_EXTRA is set. */
3003     {   "http://www.winehq.org/tests/#Te%30%31%32", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
3004         {
3005             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3006             {"www.winehq.org",S_OK,FALSE},
3007             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3008             {"winehq.org",S_OK,FALSE},
3009             {"",S_FALSE,FALSE},
3010             {"#Te%30%31%32",S_OK,FALSE},
3011             {"www.winehq.org",S_OK,FALSE},
3012             {"",S_FALSE,FALSE},
3013             {"/tests/",S_OK,FALSE},
3014             {"/tests/",S_OK,FALSE},
3015             {"",S_FALSE,FALSE},
3016             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3017             {"http",S_OK,FALSE},
3018             {"",S_FALSE,FALSE},
3019             {"",S_FALSE,FALSE}
3020         },
3021         {
3022             {Uri_HOST_DNS,S_OK,FALSE},
3023             {80,S_OK,FALSE},
3024             {URL_SCHEME_HTTP,S_OK,FALSE},
3025             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3026         }
3027     },
3028     /* Leading/Trailing whitespace is removed. */
3029     {   "    http://google.com/     ", 0, S_OK, FALSE,
3030         {
3031             {"http://google.com/",S_OK,FALSE},
3032             {"google.com",S_OK,FALSE},
3033             {"http://google.com/",S_OK,FALSE},
3034             {"google.com",S_OK,FALSE},
3035             {"",S_FALSE,FALSE},
3036             {"",S_FALSE,FALSE},
3037             {"google.com",S_OK,FALSE},
3038             {"",S_FALSE,FALSE},
3039             {"/",S_OK,FALSE},
3040             {"/",S_OK,FALSE},
3041             {"",S_FALSE,FALSE},
3042             {"http://google.com/",S_OK,FALSE},
3043             {"http",S_OK,FALSE},
3044             {"",S_FALSE,FALSE},
3045             {"",S_FALSE,FALSE}
3046         },
3047         {
3048             {Uri_HOST_DNS,S_OK,FALSE},
3049             {80,S_OK,FALSE},
3050             {URL_SCHEME_HTTP,S_OK,FALSE},
3051             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3052         }
3053     },
3054     {   "\t\t\r\nhttp\n://g\noogle.co\rm/\n\n\n", 0, S_OK, FALSE,
3055         {
3056             {"http://google.com/",S_OK,FALSE},
3057             {"google.com",S_OK,FALSE},
3058             {"http://google.com/",S_OK,FALSE},
3059             {"google.com",S_OK,FALSE},
3060             {"",S_FALSE,FALSE},
3061             {"",S_FALSE,FALSE},
3062             {"google.com",S_OK,FALSE},
3063             {"",S_FALSE,FALSE},
3064             {"/",S_OK,FALSE},
3065             {"/",S_OK,FALSE},
3066             {"",S_FALSE,FALSE},
3067             {"http://google.com/",S_OK,FALSE},
3068             {"http",S_OK,FALSE},
3069             {"",S_FALSE,FALSE},
3070             {"",S_FALSE,FALSE}
3071         },
3072         {
3073             {Uri_HOST_DNS,S_OK,FALSE},
3074             {80,S_OK,FALSE},
3075             {URL_SCHEME_HTTP,S_OK,FALSE},
3076             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3077         }
3078     },
3079     {   "http://g\noogle.co\rm/\n\n\n", Uri_CREATE_NO_PRE_PROCESS_HTML_URI, S_OK, FALSE,
3080         {
3081             {"http://g%0aoogle.co%0dm/%0A%0A%0A",S_OK,FALSE},
3082             {"g%0aoogle.co%0dm",S_OK,FALSE},
3083             {"http://g%0aoogle.co%0dm/%0A%0A%0A",S_OK,FALSE},
3084             {"g%0aoogle.co%0dm",S_OK,FALSE},
3085             {"",S_FALSE,FALSE},
3086             {"",S_FALSE,FALSE},
3087             {"g%0aoogle.co%0dm",S_OK,FALSE},
3088             {"",S_FALSE,FALSE},
3089             {"/%0A%0A%0A",S_OK,FALSE},
3090             {"/%0A%0A%0A",S_OK,FALSE},
3091             {"",S_FALSE,FALSE},
3092             {"http://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3093             {"http",S_OK,FALSE},
3094             {"",S_FALSE,FALSE},
3095             {"",S_FALSE,FALSE}
3096         },
3097         {
3098             {Uri_HOST_DNS,S_OK,FALSE},
3099             {80,S_OK,FALSE},
3100             {URL_SCHEME_HTTP,S_OK,FALSE},
3101             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3102         }
3103     },
3104     {   "zip://g\noogle.co\rm/\n\n\n", Uri_CREATE_NO_PRE_PROCESS_HTML_URI, S_OK, FALSE,
3105         {
3106             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3107             {"g\noogle.co\rm",S_OK,FALSE},
3108             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3109             {"g\noogle.co\rm",S_OK,FALSE},
3110             {"",S_FALSE,FALSE},
3111             {"",S_FALSE,FALSE},
3112             {"g\noogle.co\rm",S_OK,FALSE},
3113             {"",S_FALSE,FALSE},
3114             {"/\n\n\n",S_OK,FALSE},
3115             {"/\n\n\n",S_OK,FALSE},
3116             {"",S_FALSE,FALSE},
3117             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3118             {"zip",S_OK,FALSE},
3119             {"",S_FALSE,FALSE},
3120             {"",S_FALSE,FALSE}
3121         },
3122         {
3123             {Uri_HOST_DNS,S_OK,FALSE},
3124             {0,S_FALSE,FALSE},
3125             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3126             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3127         }
3128     },
3129     /* Since file URLs are usually hierarchical, it returns an empty string
3130      * for the absolute URI property since it was declared as an opaque URI.
3131      */
3132     {   "file:index.html", 0, S_OK, FALSE,
3133         {
3134             {"",S_FALSE,FALSE},
3135             {"",S_FALSE,FALSE},
3136             {"file:index.html",S_OK,FALSE},
3137             {"",S_FALSE,FALSE},
3138             {".html",S_OK,FALSE},
3139             {"",S_FALSE,FALSE},
3140             {"",S_FALSE,FALSE},
3141             {"",S_FALSE,FALSE},
3142             {"index.html",S_OK,FALSE},
3143             {"index.html",S_OK,FALSE},
3144             {"",S_FALSE,FALSE},
3145             {"file:index.html",S_OK,FALSE},
3146             {"file",S_OK,FALSE},
3147             {"",S_FALSE,FALSE},
3148             {"",S_FALSE,FALSE}
3149         },
3150         {
3151             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3152             {0,S_FALSE,FALSE},
3153             {URL_SCHEME_FILE,S_OK,FALSE},
3154             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3155         }
3156     },
3157     /* Doesn't have an absolute since it's opaque, but gets it port set. */
3158     {   "http:test.com/index.html", 0, S_OK, FALSE,
3159         {
3160             {"",S_FALSE,FALSE},
3161             {"",S_FALSE,FALSE},
3162             {"http:test.com/index.html",S_OK,FALSE},
3163             {"",S_FALSE,FALSE},
3164             {".html",S_OK,FALSE},
3165             {"",S_FALSE,FALSE},
3166             {"",S_FALSE,FALSE},
3167             {"",S_FALSE,FALSE},
3168             {"test.com/index.html",S_OK,FALSE},
3169             {"test.com/index.html",S_OK,FALSE},
3170             {"",S_FALSE,FALSE},
3171             {"http:test.com/index.html",S_OK,FALSE},
3172             {"http",S_OK,FALSE},
3173             {"",S_FALSE,FALSE},
3174             {"",S_FALSE,FALSE}
3175         },
3176         {
3177             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3178             {80,S_OK,FALSE},
3179             {URL_SCHEME_HTTP,S_OK,FALSE},
3180             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3181         }
3182     },
3183     {   "ftp:test.com/index.html", 0, S_OK, FALSE,
3184         {
3185             {"",S_FALSE,FALSE},
3186             {"",S_FALSE,FALSE},
3187             {"ftp:test.com/index.html",S_OK,FALSE},
3188             {"",S_FALSE,FALSE},
3189             {".html",S_OK,FALSE},
3190             {"",S_FALSE,FALSE},
3191             {"",S_FALSE,FALSE},
3192             {"",S_FALSE,FALSE},
3193             {"test.com/index.html",S_OK,FALSE},
3194             {"test.com/index.html",S_OK,FALSE},
3195             {"",S_FALSE,FALSE},
3196             {"ftp:test.com/index.html",S_OK,FALSE},
3197             {"ftp",S_OK,FALSE},
3198             {"",S_FALSE,FALSE},
3199             {"",S_FALSE,FALSE}
3200         },
3201         {
3202             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3203             {21,S_OK,FALSE},
3204             {URL_SCHEME_FTP,S_OK,FALSE},
3205             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3206         }
3207     },
3208     {   "file://C|/test.mp3", 0, S_OK, FALSE,
3209         {
3210             {"file:///C:/test.mp3",S_OK,FALSE},
3211             {"",S_FALSE,FALSE},
3212             {"file:///C:/test.mp3",S_OK,FALSE},
3213             {"",S_FALSE,FALSE},
3214             {".mp3",S_OK,FALSE},
3215             {"",S_FALSE,FALSE},
3216             {"",S_FALSE,FALSE},
3217             {"",S_FALSE,FALSE},
3218             {"/C:/test.mp3",S_OK,FALSE},
3219             {"/C:/test.mp3",S_OK,FALSE},
3220             {"",S_FALSE,FALSE},
3221             {"file://C|/test.mp3",S_OK,FALSE},
3222             {"file",S_OK,FALSE},
3223             {"",S_FALSE,FALSE},
3224             {"",S_FALSE,FALSE}
3225         },
3226         {
3227             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3228             {0,S_FALSE,FALSE},
3229             {URL_SCHEME_FILE,S_OK,FALSE},
3230             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3231         }
3232     },
3233     {   "file:///C|/test.mp3", 0, S_OK, FALSE,
3234         {
3235             {"file:///C:/test.mp3",S_OK,FALSE},
3236             {"",S_FALSE,FALSE},
3237             {"file:///C:/test.mp3",S_OK,FALSE},
3238             {"",S_FALSE,FALSE},
3239             {".mp3",S_OK,FALSE},
3240             {"",S_FALSE,FALSE},
3241             {"",S_FALSE,FALSE},
3242             {"",S_FALSE,FALSE},
3243             {"/C:/test.mp3",S_OK,FALSE},
3244             {"/C:/test.mp3",S_OK,FALSE},
3245             {"",S_FALSE,FALSE},
3246             {"file:///C|/test.mp3",S_OK,FALSE},
3247             {"file",S_OK,FALSE},
3248             {"",S_FALSE,FALSE},
3249             {"",S_FALSE,FALSE}
3250         },
3251         {
3252             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3253             {0,S_FALSE,FALSE},
3254             {URL_SCHEME_FILE,S_OK,FALSE},
3255             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3256         }
3257     },
3258     /* Extra '/' isn't added before "c:" since USE_DOS_PATH is set and '/' are converted
3259      * to '\\'.
3260      */
3261     {   "file://c:/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3262         {
3263             {"file://c:\\dir\\index.html",S_OK,FALSE},
3264             {"",S_FALSE,FALSE},
3265             {"file://c:\\dir\\index.html",S_OK,FALSE},
3266             {"",S_FALSE,FALSE},
3267             {".html",S_OK,FALSE},
3268             {"",S_FALSE,FALSE},
3269             {"",S_FALSE,FALSE},
3270             {"",S_FALSE,FALSE},
3271             {"c:\\dir\\index.html",S_OK,FALSE},
3272             {"c:\\dir\\index.html",S_OK,FALSE},
3273             {"",S_FALSE,FALSE},
3274             {"file://c:/dir/index.html",S_OK,FALSE},
3275             {"file",S_OK,FALSE},
3276             {"",S_FALSE,FALSE},
3277             {"",S_FALSE,FALSE}
3278         },
3279         {
3280             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3281             {0,S_FALSE,FALSE},
3282             {URL_SCHEME_FILE,S_OK,FALSE},
3283             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3284         }
3285     },
3286     /* Extra '/' after "file://" is removed. */
3287     {   "file:///c:/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3288         {
3289             {"file://c:\\dir\\index.html",S_OK,FALSE},
3290             {"",S_FALSE,FALSE},
3291             {"file://c:\\dir\\index.html",S_OK,FALSE},
3292             {"",S_FALSE,FALSE},
3293             {".html",S_OK,FALSE},
3294             {"",S_FALSE,FALSE},
3295             {"",S_FALSE,FALSE},
3296             {"",S_FALSE,FALSE},
3297             {"c:\\dir\\index.html",S_OK,FALSE},
3298             {"c:\\dir\\index.html",S_OK,FALSE},
3299             {"",S_FALSE,FALSE},
3300             {"file:///c:/dir/index.html",S_OK,FALSE},
3301             {"file",S_OK,FALSE},
3302             {"",S_FALSE,FALSE},
3303             {"",S_FALSE,FALSE}
3304         },
3305         {
3306             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3307             {0,S_FALSE,FALSE},
3308             {URL_SCHEME_FILE,S_OK,FALSE},
3309             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3310         }
3311     },
3312     /* Allow more characters when Uri_CREATE_FILE_USE_DOS_PATH is specified */
3313     {   "file:///c:/dir\\%%61%20%5Fname/file%2A.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3314         {
3315             {"file://c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3316             {"",S_FALSE,FALSE},
3317             {"file://c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3318             {"",S_FALSE,FALSE},
3319             {".html",S_OK,FALSE},
3320             {"",S_FALSE,FALSE},
3321             {"",S_FALSE,FALSE},
3322             {"",S_FALSE,FALSE},
3323             {"c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3324             {"c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3325             {"",S_FALSE,FALSE},
3326             {"file:///c:/dir\\%%61%20%5Fname/file%2A.html",S_OK,FALSE},
3327             {"file",S_OK,FALSE},
3328             {"",S_FALSE,FALSE},
3329             {"",S_FALSE,FALSE}
3330         },
3331         {
3332             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3333             {0,S_FALSE,FALSE},
3334             {URL_SCHEME_FILE,S_OK,FALSE},
3335             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3336         }
3337     },
3338     {   "file://c|/dir\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3339         {
3340             {"file://c:\\dir\\index.html",S_OK,FALSE},
3341             {"",S_FALSE,FALSE},
3342             {"file://c:\\dir\\index.html",S_OK,FALSE},
3343             {"",S_FALSE,FALSE},
3344             {".html",S_OK,FALSE},
3345             {"",S_FALSE,FALSE},
3346             {"",S_FALSE,FALSE},
3347             {"",S_FALSE,FALSE},
3348             {"c:\\dir\\index.html",S_OK,FALSE},
3349             {"c:\\dir\\index.html",S_OK,FALSE},
3350             {"",S_FALSE,FALSE},
3351             {"file://c|/dir\\index.html",S_OK,FALSE},
3352             {"file",S_OK,FALSE},
3353             {"",S_FALSE,FALSE},
3354             {"",S_FALSE,FALSE}
3355         },
3356         {
3357             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3358             {0,S_FALSE,FALSE},
3359             {URL_SCHEME_FILE,S_OK,FALSE},
3360             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3361         }
3362     },
3363     /* The backslashes after the scheme name are converted to forward slashes. */
3364     {   "file:\\\\c:\\dir\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3365         {
3366             {"file://c:\\dir\\index.html",S_OK,FALSE},
3367             {"",S_FALSE,FALSE},
3368             {"file://c:\\dir\\index.html",S_OK,FALSE},
3369             {"",S_FALSE,FALSE},
3370             {".html",S_OK,FALSE},
3371             {"",S_FALSE,FALSE},
3372             {"",S_FALSE,FALSE},
3373             {"",S_FALSE,FALSE},
3374             {"c:\\dir\\index.html",S_OK,FALSE},
3375             {"c:\\dir\\index.html",S_OK,FALSE},
3376             {"",S_FALSE,FALSE},
3377             {"file:\\\\c:\\dir\\index.html",S_OK,FALSE},
3378             {"file",S_OK,FALSE},
3379             {"",S_FALSE,FALSE},
3380             {"",S_FALSE,FALSE}
3381         },
3382         {
3383             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3384             {0,S_FALSE,FALSE},
3385             {URL_SCHEME_FILE,S_OK,FALSE},
3386             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3387         }
3388     },
3389     {   "file:\\\\c:/dir/index.html", 0, S_OK, FALSE,
3390         {
3391             {"file:///c:/dir/index.html",S_OK,FALSE},
3392             {"",S_FALSE,FALSE},
3393             {"file:///c:/dir/index.html",S_OK,FALSE},
3394             {"",S_FALSE,FALSE},
3395             {".html",S_OK,FALSE},
3396             {"",S_FALSE,FALSE},
3397             {"",S_FALSE,FALSE},
3398             {"",S_FALSE,FALSE},
3399             {"/c:/dir/index.html",S_OK,FALSE},
3400             {"/c:/dir/index.html",S_OK,FALSE},
3401             {"",S_FALSE,FALSE},
3402             {"file:\\\\c:/dir/index.html",S_OK,FALSE},
3403             {"file",S_OK,FALSE},
3404             {"",S_FALSE,FALSE},
3405             {"",S_FALSE,FALSE}
3406         },
3407         {
3408             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3409             {0,S_FALSE,FALSE},
3410             {URL_SCHEME_FILE,S_OK,FALSE},
3411             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3412         }
3413     },
3414     {   "http:\\\\google.com", 0, S_OK, FALSE,
3415         {
3416             {"http://google.com/",S_OK,FALSE},
3417             {"google.com",S_OK,FALSE},
3418             {"http://google.com/",S_OK,FALSE},
3419             {"google.com",S_OK,FALSE},
3420             {"",S_FALSE,FALSE},
3421             {"",S_FALSE,FALSE},
3422             {"google.com",S_OK,FALSE},
3423             {"",S_FALSE,FALSE},
3424             {"/",S_OK,FALSE},
3425             {"/",S_OK,FALSE},
3426             {"",S_FALSE,FALSE},
3427             {"http:\\\\google.com",S_OK,FALSE},
3428             {"http",S_OK,FALSE},
3429             {"",S_FALSE,FALSE},
3430             {"",S_FALSE,FALSE}
3431         },
3432         {
3433             {Uri_HOST_DNS,S_OK,FALSE},
3434             {80,S_OK,FALSE},
3435             {URL_SCHEME_HTTP,S_OK,FALSE},
3436             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3437         }
3438     },
3439     /* the "\\\\" aren't converted to "//" for unknown scheme types and it's considered opaque. */
3440     {   "zip:\\\\google.com", 0, S_OK, FALSE,
3441         {
3442             {"zip:\\\\google.com",S_OK,FALSE},
3443             {"",S_FALSE,FALSE},
3444             {"zip:\\\\google.com",S_OK,FALSE},
3445             {"",S_FALSE,FALSE},
3446             {".com",S_OK,FALSE},
3447             {"",S_FALSE,FALSE},
3448             {"",S_FALSE,FALSE},
3449             {"",S_FALSE,FALSE},
3450             {"\\\\google.com",S_OK,FALSE},
3451             {"\\\\google.com",S_OK,FALSE},
3452             {"",S_FALSE,FALSE},
3453             {"zip:\\\\google.com",S_OK,FALSE},
3454             {"zip",S_OK,FALSE},
3455             {"",S_FALSE,FALSE},
3456             {"",S_FALSE,FALSE}
3457         },
3458         {
3459             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3460             {0,S_FALSE,FALSE},
3461             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3462             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3463         }
3464     },
3465     /* Dot segments aren't removed. */
3466     {   "file://c:\\dir\\../..\\./index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3467         {
3468             {"file://c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3469             {"",S_FALSE,FALSE},
3470             {"file://c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3471             {"",S_FALSE,FALSE},
3472             {".html",S_OK,FALSE},
3473             {"",S_FALSE,FALSE},
3474             {"",S_FALSE,FALSE},
3475             {"",S_FALSE,FALSE},
3476             {"c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3477             {"c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3478             {"",S_FALSE,FALSE},
3479             {"file://c:\\dir\\../..\\./index.html",S_OK,FALSE},
3480             {"file",S_OK,FALSE},
3481             {"",S_FALSE,FALSE},
3482             {"",S_FALSE,FALSE}
3483         },
3484         {
3485             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3486             {0,S_FALSE,FALSE},
3487             {URL_SCHEME_FILE,S_OK,FALSE},
3488             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3489         }
3490     },
3491     /* Forbidden characters aren't percent encoded. */
3492     {   "file://c:\\dir\\i^|ndex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3493         {
3494             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3495             {"",S_FALSE,FALSE},
3496             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3497             {"",S_FALSE,FALSE},
3498             {".html",S_OK,FALSE},
3499             {"",S_FALSE,FALSE},
3500             {"",S_FALSE,FALSE},
3501             {"",S_FALSE,FALSE},
3502             {"c:\\dir\\i^|ndex.html",S_OK,FALSE},
3503             {"c:\\dir\\i^|ndex.html",S_OK,FALSE},
3504             {"",S_FALSE,FALSE},
3505             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3506             {"file",S_OK,FALSE},
3507             {"",S_FALSE,FALSE},
3508             {"",S_FALSE,FALSE}
3509         },
3510         {
3511             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3512             {0,S_FALSE,FALSE},
3513             {URL_SCHEME_FILE,S_OK,FALSE},
3514             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3515         }
3516     },
3517     /* The '\' are still converted to '/' even though it's an opaque file URI. */
3518     {   "file:c:\\dir\\../..\\index.html", 0, S_OK, FALSE,
3519         {
3520             {"",S_FALSE,FALSE},
3521             {"",S_FALSE,FALSE},
3522             {"file:c:/dir/../../index.html",S_OK,FALSE},
3523             {"",S_FALSE,FALSE},
3524             {".html",S_OK,FALSE},
3525             {"",S_FALSE,FALSE},
3526             {"",S_FALSE,FALSE},
3527             {"",S_FALSE,FALSE},
3528             {"c:/dir/../../index.html",S_OK,FALSE},
3529             {"c:/dir/../../index.html",S_OK,FALSE},
3530             {"",S_FALSE,FALSE},
3531             {"file:c:\\dir\\../..\\index.html",S_OK,FALSE},
3532             {"file",S_OK,FALSE},
3533             {"",S_FALSE,FALSE},
3534             {"",S_FALSE,FALSE}
3535         },
3536         {
3537             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3538             {0,S_FALSE,FALSE},
3539             {URL_SCHEME_FILE,S_OK,FALSE},
3540             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3541         }
3542     },
3543     /* '/' are still converted to '\' even though it's an opaque URI. */
3544     {   "file:c:/dir\\../..\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3545         {
3546             {"",S_FALSE,FALSE},
3547             {"",S_FALSE,FALSE},
3548             {"file:c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3549             {"",S_FALSE,FALSE},
3550             {".html",S_OK,FALSE},
3551             {"",S_FALSE,FALSE},
3552             {"",S_FALSE,FALSE},
3553             {"",S_FALSE,FALSE},
3554             {"c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3555             {"c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3556             {"",S_FALSE,FALSE},
3557             {"file:c:/dir\\../..\\index.html",S_OK,FALSE},
3558             {"file",S_OK,FALSE},
3559             {"",S_FALSE,FALSE},
3560             {"",S_FALSE,FALSE}
3561         },
3562         {
3563             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3564             {0,S_FALSE,FALSE},
3565             {URL_SCHEME_FILE,S_OK,FALSE},
3566             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3567         }
3568     },
3569     /* Forbidden characters aren't percent encoded. */
3570     {   "file:c:\\in^|dex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3571         {
3572             {"",S_FALSE,FALSE},
3573             {"",S_FALSE,FALSE},
3574             {"file:c:\\in^|dex.html",S_OK,FALSE},
3575             {"",S_FALSE,FALSE},
3576             {".html",S_OK,FALSE},
3577             {"",S_FALSE,FALSE},
3578             {"",S_FALSE,FALSE},
3579             {"",S_FALSE,FALSE},
3580             {"c:\\in^|dex.html",S_OK,FALSE},
3581             {"c:\\in^|dex.html",S_OK,FALSE},
3582             {"",S_FALSE,FALSE},
3583             {"file:c:\\in^|dex.html",S_OK,FALSE},
3584             {"file",S_OK,FALSE},
3585             {"",S_FALSE,FALSE},
3586             {"",S_FALSE,FALSE}
3587         },
3588         {
3589             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3590             {0,S_FALSE,FALSE},
3591             {URL_SCHEME_FILE,S_OK,FALSE},
3592             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3593         }
3594     },
3595     /* Doesn't have a UserName since the ':' appears at the beginning of the
3596      * userinfo section.
3597      */
3598     {   "http://:password@gov.uk", 0, S_OK, FALSE,
3599         {
3600             {"http://:password@gov.uk/",S_OK,FALSE},
3601             {":password@gov.uk",S_OK,FALSE},
3602             {"http://gov.uk/",S_OK,FALSE},
3603             {"",S_FALSE,FALSE},
3604             {"",S_FALSE,FALSE},
3605             {"",S_FALSE,FALSE},
3606             {"gov.uk",S_OK,FALSE},
3607             {"password",S_OK,FALSE},
3608             {"/",S_OK,FALSE},
3609             {"/",S_OK,FALSE},
3610             {"",S_FALSE,FALSE},
3611             {"http://:password@gov.uk",S_OK,FALSE},
3612             {"http",S_OK,FALSE},
3613             {":password",S_OK,FALSE},
3614             {"",S_FALSE,FALSE}
3615         },
3616         {
3617             {Uri_HOST_DNS,S_OK,FALSE},
3618             {80,S_OK,FALSE},
3619             {URL_SCHEME_HTTP,S_OK,FALSE},
3620             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3621         }
3622     },
3623     /* Has a UserName since the userinfo section doesn't contain a password. */
3624     {   "http://@gov.uk", 0, S_OK, FALSE,
3625         {
3626             {"http://gov.uk/",S_OK,FALSE,"http://@gov.uk/"},
3627             {"@gov.uk",S_OK,FALSE},
3628             {"http://gov.uk/",S_OK,FALSE},
3629             {"",S_FALSE,FALSE},
3630             {"",S_FALSE,FALSE},
3631             {"",S_FALSE,FALSE},
3632             {"gov.uk",S_OK,FALSE},
3633             {"",S_FALSE,FALSE},
3634             {"/",S_OK,FALSE},
3635             {"/",S_OK,FALSE},
3636             {"",S_FALSE,FALSE},
3637             {"http://@gov.uk",S_OK,FALSE},
3638             {"http",S_OK,FALSE},
3639             {"",S_OK,FALSE},
3640             {"",S_OK,FALSE}
3641         },
3642         {
3643             {Uri_HOST_DNS,S_OK,FALSE},
3644             {80,S_OK,FALSE},
3645             {URL_SCHEME_HTTP,S_OK,FALSE},
3646             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3647         }
3648     },
3649     /* ":@" not included in the absolute URI. */
3650     {   "http://:@gov.uk", 0, S_OK, FALSE,
3651         {
3652             {"http://gov.uk/",S_OK,FALSE,"http://:@gov.uk/"},
3653             {":@gov.uk",S_OK,FALSE},
3654             {"http://gov.uk/",S_OK,FALSE},
3655             {"",S_FALSE,FALSE},
3656             {"",S_FALSE,FALSE},
3657             {"",S_FALSE,FALSE},
3658             {"gov.uk",S_OK,FALSE},
3659             {"",S_OK,FALSE},
3660             {"/",S_OK,FALSE},
3661             {"/",S_OK,FALSE},
3662             {"",S_FALSE,FALSE},
3663             {"http://:@gov.uk",S_OK,FALSE},
3664             {"http",S_OK,FALSE},
3665             {":",S_OK,FALSE},
3666             {"",S_FALSE,FALSE}
3667         },
3668         {
3669             {Uri_HOST_DNS,S_OK,FALSE},
3670             {80,S_OK,FALSE},
3671             {URL_SCHEME_HTTP,S_OK,FALSE},
3672             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3673         }
3674     },
3675     /* '@' is included because it's an unknown scheme type. */
3676     {   "zip://@gov.uk", 0, S_OK, FALSE,
3677         {
3678             {"zip://@gov.uk/",S_OK,FALSE},
3679             {"@gov.uk",S_OK,FALSE},
3680             {"zip://@gov.uk/",S_OK,FALSE},
3681             {"",S_FALSE,FALSE},
3682             {"",S_FALSE,FALSE},
3683             {"",S_FALSE,FALSE},
3684             {"gov.uk",S_OK,FALSE},
3685             {"",S_FALSE,FALSE},
3686             {"/",S_OK,FALSE},
3687             {"/",S_OK,FALSE},
3688             {"",S_FALSE,FALSE},
3689             {"zip://@gov.uk",S_OK,FALSE},
3690             {"zip",S_OK,FALSE},
3691             {"",S_OK,FALSE},
3692             {"",S_OK,FALSE}
3693         },
3694         {
3695             {Uri_HOST_DNS,S_OK,FALSE},
3696             {0,S_FALSE,FALSE},
3697             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3698             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3699         }
3700     },
3701     /* ":@" are included because it's an unknown scheme type. */
3702     {   "zip://:@gov.uk", 0, S_OK, FALSE,
3703         {
3704             {"zip://:@gov.uk/",S_OK,FALSE},
3705             {":@gov.uk",S_OK,FALSE},
3706             {"zip://:@gov.uk/",S_OK,FALSE},
3707             {"",S_FALSE,FALSE},
3708             {"",S_FALSE,FALSE},
3709             {"",S_FALSE,FALSE},
3710             {"gov.uk",S_OK,FALSE},
3711             {"",S_OK,FALSE},
3712             {"/",S_OK,FALSE},
3713             {"/",S_OK,FALSE},
3714             {"",S_FALSE,FALSE},
3715             {"zip://:@gov.uk",S_OK,FALSE},
3716             {"zip",S_OK,FALSE},
3717             {":",S_OK,FALSE},
3718             {"",S_FALSE,FALSE}
3719         },
3720         {
3721             {Uri_HOST_DNS,S_OK,FALSE},
3722             {0,S_FALSE,FALSE},
3723             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3724             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3725         }
3726     },
3727     {   "about:blank", 0, S_OK, FALSE,
3728         {
3729             {"about:blank",S_OK,FALSE},
3730             {"",S_FALSE,FALSE},
3731             {"about:blank",S_OK,FALSE},
3732             {"",S_FALSE,FALSE},
3733             {"",S_FALSE,FALSE},
3734             {"",S_FALSE,FALSE},
3735             {"",S_FALSE,FALSE},
3736             {"",S_FALSE,FALSE},
3737             {"blank",S_OK,FALSE},
3738             {"blank",S_OK,FALSE},
3739             {"",S_FALSE,FALSE},
3740             {"about:blank",S_OK,FALSE},
3741             {"about",S_OK,FALSE},
3742             {"",S_FALSE,FALSE},
3743             {"",S_FALSE,FALSE}
3744         },
3745         {
3746             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3747             {0,S_FALSE,FALSE},
3748             {URL_SCHEME_ABOUT,S_OK,FALSE},
3749             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3750         }
3751     },
3752     {   "mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",0,S_OK,FALSE,
3753         {
3754             {"mk:@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3755             {"",S_FALSE,FALSE},
3756             {"mk:@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3757             {"",S_FALSE,FALSE},
3758             {".htm",S_OK,FALSE},
3759             {"",S_FALSE,FALSE},
3760             {"",S_FALSE,FALSE},
3761             {"",S_FALSE,FALSE},
3762             {"@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3763             {"@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3764             {"",S_FALSE,FALSE},
3765             {"mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3766             {"mk",S_OK,FALSE},
3767             {"",S_FALSE,FALSE},
3768             {"",S_FALSE,FALSE}
3769         },
3770         {
3771             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3772             {0,S_FALSE,FALSE},
3773             {URL_SCHEME_MK,S_OK,FALSE},
3774             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3775         }
3776     },
3777     {   "mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",0,S_OK,FALSE,
3778         {
3779             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3780             {"",S_FALSE,FALSE},
3781             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3782             {"",S_FALSE,FALSE},
3783             {".htm",S_OK,FALSE},
3784             {"",S_FALSE,FALSE},
3785             {"",S_FALSE,FALSE},
3786             {"",S_FALSE,FALSE},
3787             {"@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3788             {"@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3789             {"",S_FALSE,FALSE},
3790             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3791             {"mk",S_OK,FALSE},
3792             {"",S_FALSE,FALSE},
3793             {"",S_FALSE,FALSE}
3794         },
3795         {
3796             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3797             {0,S_FALSE,FALSE},
3798             {URL_SCHEME_MK,S_OK,FALSE},
3799             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3800         }
3801     },
3802     /* Two '\' are added to the URI when USE_DOS_PATH is set, and it's a UNC path. */
3803     {   "file://server/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3804         {
3805             {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
3806             {"server",S_OK,FALSE},
3807             {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
3808             {"",S_FALSE,FALSE},
3809             {".html",S_OK,FALSE},
3810             {"",S_FALSE,FALSE},
3811             {"server",S_OK,FALSE},
3812             {"",S_FALSE,FALSE},
3813             {"\\dir\\index.html",S_OK,FALSE},
3814             {"\\dir\\index.html",S_OK,FALSE},
3815             {"",S_FALSE,FALSE},
3816             {"file://server/dir/index.html",S_OK,FALSE},
3817             {"file",S_OK,FALSE},
3818             {"",S_FALSE,FALSE},
3819             {"",S_FALSE,FALSE}
3820         },
3821         {
3822             {Uri_HOST_DNS,S_OK,FALSE},
3823             {0,S_FALSE,FALSE},
3824             {URL_SCHEME_FILE,S_OK,FALSE},
3825             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3826         }
3827     },
3828     /* When CreateUri generates an IUri, it still displays the default port in the
3829      * authority.
3830      */
3831     {   "http://google.com:80/", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
3832         {
3833             {"http://google.com:80/",S_OK,FALSE},
3834             {"google.com:80",S_OK,FALSE},
3835             {"http://google.com:80/",S_OK,FALSE},
3836             {"google.com",S_OK,FALSE},
3837             {"",S_FALSE,FALSE},
3838             {"",S_FALSE,FALSE},
3839             {"google.com",S_OK,FALSE},
3840             {"",S_FALSE,FALSE},
3841             {"/",S_OK,FALSE},
3842             {"/",S_OK,FALSE},
3843             {"",S_FALSE,FALSE},
3844             {"http://google.com:80/",S_OK,FALSE},
3845             {"http",S_OK,FALSE},
3846             {"",S_FALSE,FALSE},
3847             {"",S_FALSE,FALSE}
3848         },
3849         {
3850             {Uri_HOST_DNS,S_OK,FALSE},
3851             {80,S_OK,FALSE},
3852             {URL_SCHEME_HTTP,S_OK,FALSE},
3853             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3854         }
3855     },
3856     /* For res URIs the host is everything up until the first '/'. */
3857     {   "res://C:\\dir\\file.exe/DATA/test.html", 0, S_OK, FALSE,
3858         {
3859             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3860             {"C:\\dir\\file.exe",S_OK,FALSE},
3861             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3862             {"",S_FALSE,FALSE},
3863             {".html",S_OK,FALSE},
3864             {"",S_FALSE,FALSE},
3865             {"C:\\dir\\file.exe",S_OK,FALSE},
3866             {"",S_FALSE,FALSE},
3867             {"/DATA/test.html",S_OK,FALSE},
3868             {"/DATA/test.html",S_OK,FALSE},
3869             {"",S_FALSE,FALSE},
3870             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3871             {"res",S_OK,FALSE},
3872             {"",S_FALSE,FALSE},
3873             {"",S_FALSE,FALSE}
3874         },
3875         {
3876             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3877             {0,S_FALSE,FALSE},
3878             {URL_SCHEME_RES,S_OK,FALSE},
3879             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3880         }
3881     },
3882     /* Res URI can contain a '|' in the host name. */
3883     {   "res://c:\\di|r\\file.exe/test", 0, S_OK, FALSE,
3884         {
3885             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3886             {"c:\\di|r\\file.exe",S_OK,FALSE},
3887             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3888             {"",S_FALSE,FALSE},
3889             {"",S_FALSE,FALSE},
3890             {"",S_FALSE,FALSE},
3891             {"c:\\di|r\\file.exe",S_OK,FALSE},
3892             {"",S_FALSE,FALSE},
3893             {"/test",S_OK,FALSE},
3894             {"/test",S_OK,FALSE},
3895             {"",S_FALSE,FALSE},
3896             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3897             {"res",S_OK,FALSE},
3898             {"",S_FALSE,FALSE},
3899             {"",S_FALSE,FALSE}
3900         },
3901         {
3902             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3903             {0,S_FALSE,FALSE},
3904             {URL_SCHEME_RES,S_OK,FALSE},
3905             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3906         }
3907     },
3908     /* Res URIs can have invalid percent encoded values. */
3909     {   "res://c:\\dir%xx\\file.exe/test", 0, S_OK, FALSE,
3910         {
3911             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3912             {"c:\\dir%xx\\file.exe",S_OK,FALSE},
3913             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3914             {"",S_FALSE,FALSE},
3915             {"",S_FALSE,FALSE},
3916             {"",S_FALSE,FALSE},
3917             {"c:\\dir%xx\\file.exe",S_OK,FALSE},
3918             {"",S_FALSE,FALSE},
3919             {"/test",S_OK,FALSE},
3920             {"/test",S_OK,FALSE},
3921             {"",S_FALSE,FALSE},
3922             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3923             {"res",S_OK,FALSE},
3924             {"",S_FALSE,FALSE},
3925             {"",S_FALSE,FALSE}
3926         },
3927         {
3928             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3929             {0,S_FALSE,FALSE},
3930             {URL_SCHEME_RES,S_OK,FALSE},
3931             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3932         }
3933     },
3934     /* Res doesn't get forbidden characters percent encoded in it's path. */
3935     {   "res://c:\\test/tes<|>t", 0, S_OK, FALSE,
3936         {
3937             {"res://c:\\test/tes<|>t",S_OK,FALSE},
3938             {"c:\\test",S_OK,FALSE},
3939             {"res://c:\\test/tes<|>t",S_OK,FALSE},
3940             {"",S_FALSE,FALSE},
3941             {"",S_FALSE,FALSE},
3942             {"",S_FALSE,FALSE},
3943             {"c:\\test",S_OK,FALSE},
3944             {"",S_FALSE,FALSE},
3945             {"/tes<|>t",S_OK,FALSE},
3946             {"/tes<|>t",S_OK,FALSE},
3947             {"",S_FALSE,FALSE},
3948             {"res://c:\\test/tes<|>t",S_OK,FALSE},
3949             {"res",S_OK,FALSE},
3950             {"",S_FALSE,FALSE},
3951             {"",S_FALSE,FALSE}
3952         },
3953         {
3954             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3955             {0,S_FALSE,FALSE},
3956             {URL_SCHEME_RES,S_OK,FALSE},
3957             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3958         }
3959     }
3960 };
3961
3962 typedef struct _invalid_uri {
3963     const char* uri;
3964     DWORD       flags;
3965     BOOL        todo;
3966 } invalid_uri;
3967
3968 static const invalid_uri invalid_uri_tests[] = {
3969     /* Has to have a scheme name. */
3970     {"://www.winehq.org",0,FALSE},
3971     /* Window's doesn't like URI's which are implicitly file paths without the
3972      * ALLOW_IMPLICIT_FILE_SCHEME flag set.
3973      */
3974     {"C:/test/test.mp3",0,FALSE},
3975     {"\\\\Server/test/test.mp3",0,FALSE},
3976     {"C:/test/test.mp3",Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME,FALSE},
3977     {"\\\\Server/test/test.mp3",Uri_CREATE_ALLOW_RELATIVE,FALSE},
3978     /* Invalid schemes. */
3979     {"*abcd://not.valid.com",0,FALSE},
3980     {"*a*b*c*d://not.valid.com",0,FALSE},
3981     /* Not allowed to have invalid % encoded data. */
3982     {"ftp://google.co%XX/",0,FALSE},
3983     /* To many h16 components. */
3984     {"http://[1:2:3:4:5:6:7:8:9]",0,FALSE},
3985     /* Not enough room for IPv4 address. */
3986     {"http://[1:2:3:4:5:6:7:192.0.1.0]",0,FALSE},
3987     /* Not enough h16 components. */
3988     {"http://[1:2:3:4]",0,FALSE},
3989     /* Not enough components including IPv4. */
3990     {"http://[1:192.0.1.0]",0,FALSE},
3991     /* Not allowed to have partial IPv4 in IPv6. */
3992     {"http://[::192.0]",0,FALSE},
3993     /* Can't have elision of 1 h16 at beginning of address. */
3994     {"http://[::2:3:4:5:6:7:8]",0,FALSE},
3995     /* Can't have elision of 1 h16 at end of address. */
3996     {"http://[1:2:3:4:5:6:7::]",0,FALSE},
3997     /* Expects a valid IP Literal. */
3998     {"ftp://[not.valid.uri]/",0,FALSE},
3999     /* Expects valid port for a known scheme type. */
4000     {"ftp://www.winehq.org:123fgh",0,FALSE},
4001     /* Port exceeds USHORT_MAX for known scheme type. */
4002     {"ftp://www.winehq.org:65536",0,FALSE},
4003     /* Invalid port with IPv4 address. */
4004     {"http://www.winehq.org:1abcd",0,FALSE},
4005     /* Invalid port with IPv6 address. */
4006     {"http://[::ffff]:32xy",0,FALSE},
4007     /* Not allowed to have backslashes with NO_CANONICALIZE. */
4008     {"gopher://www.google.com\\test",Uri_CREATE_NO_CANONICALIZE,FALSE},
4009     /* Not allowed to have invalid % encoded data in opaque URI path. */
4010     {"news:test%XX",0,FALSE},
4011     {"mailto:wine@winehq%G8.com",0,FALSE},
4012     /* Known scheme types can't have invalid % encoded data in query string. */
4013     {"http://google.com/?query=te%xx",0,FALSE},
4014     /* Invalid % encoded data in fragment of know scheme type. */
4015     {"ftp://google.com/#Test%xx",0,FALSE},
4016     {"  http://google.com/",Uri_CREATE_NO_PRE_PROCESS_HTML_URI,FALSE},
4017     {"\n\nhttp://google.com/",Uri_CREATE_NO_PRE_PROCESS_HTML_URI,FALSE},
4018     {"file://c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4019     {"file://c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4020     {"file://c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4021     {"file:c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4022     {"file:c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4023     {"file:c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4024     /* res URIs aren't allowed to have forbidden dos path characters in the
4025      * hostname.
4026      */
4027     {"res://c:\\te<st\\test/test",0,FALSE},
4028     {"res://c:\\te>st\\test/test",0,FALSE},
4029     {"res://c:\\te\"st\\test/test",0,FALSE},
4030     {"res://c:\\test/te%xxst",0,FALSE}
4031 };
4032
4033 typedef struct _uri_equality {
4034     const char* a;
4035     DWORD       create_flags_a;
4036     BOOL        create_todo_a;
4037     const char* b;
4038     DWORD       create_flags_b;
4039     BOOL        create_todo_b;
4040     BOOL        equal;
4041     BOOL        todo;
4042 } uri_equality;
4043
4044 static const uri_equality equality_tests[] = {
4045     {
4046         "HTTP://www.winehq.org/test dir/./",0,FALSE,
4047         "http://www.winehq.org/test dir/../test dir/",0,FALSE,
4048         TRUE, FALSE
4049     },
4050     {
4051         /* http://www.winehq.org/test%20dir */
4052         "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,
4053         "http://www.winehq.org/test dir",0,FALSE,
4054         TRUE, FALSE
4055     },
4056     {
4057         "c:\\test.mp3",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME,FALSE,
4058         "file:///c:/test.mp3",0,FALSE,
4059         TRUE, FALSE
4060     },
4061     {
4062         "ftp://ftp.winehq.org/",0,FALSE,
4063         "ftp://ftp.winehq.org",0,FALSE,
4064         TRUE, FALSE
4065     },
4066     {
4067         "ftp://ftp.winehq.org/test/test2/../../testB/",0,FALSE,
4068         "ftp://ftp.winehq.org/t%45stB/",0,FALSE,
4069         FALSE, FALSE
4070     },
4071     {
4072         "http://google.com/TEST",0,FALSE,
4073         "http://google.com/test",0,FALSE,
4074         FALSE, FALSE
4075     },
4076     {
4077         "http://GOOGLE.com/",0,FALSE,
4078         "http://google.com/",0,FALSE,
4079         TRUE, FALSE
4080     },
4081     /* Performs case insensitive compare of host names (for known scheme types). */
4082     {
4083         "ftp://GOOGLE.com/",Uri_CREATE_NO_CANONICALIZE,FALSE,
4084         "ftp://google.com/",0,FALSE,
4085         TRUE, FALSE
4086     },
4087     {
4088         "zip://GOOGLE.com/",0,FALSE,
4089         "zip://google.com/",0,FALSE,
4090         FALSE, FALSE
4091     },
4092     {
4093         "file:///c:/TEST/TeST/",0,FALSE,
4094         "file:///c:/test/test/",0,FALSE,
4095         TRUE, FALSE
4096     },
4097     {
4098         "file:///server/TEST",0,FALSE,
4099         "file:///SERVER/TEST",0,FALSE,
4100         TRUE, FALSE
4101     },
4102     {
4103         "http://google.com",Uri_CREATE_NO_CANONICALIZE,FALSE,
4104         "http://google.com/",0,FALSE,
4105         TRUE, FALSE
4106     },
4107     {
4108         "ftp://google.com:21/",0,FALSE,
4109         "ftp://google.com/",0,FALSE,
4110         TRUE, FALSE
4111     },
4112     {
4113         "http://google.com:80/",Uri_CREATE_NO_CANONICALIZE,FALSE,
4114         "http://google.com/",0,FALSE,
4115         TRUE, FALSE
4116     },
4117     {
4118         "http://google.com:70/",0,FALSE,
4119         "http://google.com:71/",0,FALSE,
4120         FALSE, FALSE
4121     }
4122 };
4123
4124 typedef struct _uri_with_fragment {
4125     const char* uri;
4126     const char* fragment;
4127     DWORD       create_flags;
4128     HRESULT     create_expected;
4129     BOOL        create_todo;
4130
4131     const char* expected_uri;
4132     BOOL        expected_todo;
4133 } uri_with_fragment;
4134
4135 static const uri_with_fragment uri_fragment_tests[] = {
4136     {
4137         "http://google.com/","#fragment",0,S_OK,FALSE,
4138         "http://google.com/#fragment",FALSE
4139     },
4140     {
4141         "http://google.com/","fragment",0,S_OK,FALSE,
4142         "http://google.com/#fragment",FALSE
4143     },
4144     {
4145         "zip://test.com/","?test",0,S_OK,FALSE,
4146         "zip://test.com/#?test",FALSE
4147     },
4148     /* The fragment can be empty. */
4149     {
4150         "ftp://ftp.google.com/","",0,S_OK,FALSE,
4151         "ftp://ftp.google.com/#",FALSE
4152     }
4153 };
4154
4155 typedef struct _uri_builder_property {
4156     BOOL            change;
4157     const char      *value;
4158     const char      *expected_value;
4159     Uri_PROPERTY    property;
4160     HRESULT         expected;
4161     BOOL            todo;
4162 } uri_builder_property;
4163
4164 typedef struct _uri_builder_port {
4165     BOOL    change;
4166     BOOL    set;
4167     DWORD   value;
4168     HRESULT expected;
4169     BOOL    todo;
4170 } uri_builder_port;
4171
4172 typedef struct _uri_builder_str_property {
4173     const char* expected;
4174     HRESULT     result;
4175     BOOL        todo;
4176 } uri_builder_str_property;
4177
4178 typedef struct _uri_builder_dword_property {
4179     DWORD   expected;
4180     HRESULT result;
4181     BOOL    todo;
4182 } uri_builder_dword_property;
4183
4184 typedef struct _uri_builder_test {
4185     const char                  *uri;
4186     DWORD                       create_flags;
4187     HRESULT                     create_builder_expected;
4188     BOOL                        create_builder_todo;
4189
4190     uri_builder_property        properties[URI_BUILDER_STR_PROPERTY_COUNT];
4191
4192     uri_builder_port            port_prop;
4193
4194     DWORD                       uri_flags;
4195     HRESULT                     uri_hres;
4196     BOOL                        uri_todo;
4197
4198     DWORD                       uri_simple_encode_flags;
4199     HRESULT                     uri_simple_hres;
4200     BOOL                        uri_simple_todo;
4201
4202     DWORD                       uri_with_flags;
4203     DWORD                       uri_with_builder_flags;
4204     DWORD                       uri_with_encode_flags;
4205     HRESULT                     uri_with_hres;
4206     BOOL                        uri_with_todo;
4207
4208     uri_builder_str_property    expected_str_props[URI_STR_PROPERTY_COUNT];
4209     uri_builder_dword_property  expected_dword_props[URI_DWORD_PROPERTY_COUNT];
4210 } uri_builder_test;
4211
4212 static const uri_builder_test uri_builder_tests[] = {
4213     {   "http://google.com/",0,S_OK,FALSE,
4214         {
4215             {TRUE,"#fragment",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4216             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE},
4217             {TRUE,"?query=x",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE},
4218             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4219         },
4220         {FALSE},
4221         0,S_OK,FALSE,
4222         0,S_OK,FALSE,
4223         0,0,0,S_OK,FALSE,
4224         {
4225             {"http://username:password@google.com/?query=x#fragment",S_OK},
4226             {"username:password@google.com",S_OK},
4227             {"http://google.com/?query=x#fragment",S_OK},
4228             {"google.com",S_OK},
4229             {"",S_FALSE},
4230             {"#fragment",S_OK},
4231             {"google.com",S_OK},
4232             {"password",S_OK},
4233             {"/",S_OK},
4234             {"/?query=x",S_OK},
4235             {"?query=x",S_OK},
4236             {"http://username:password@google.com/?query=x#fragment",S_OK},
4237             {"http",S_OK},
4238             {"username:password",S_OK},
4239             {"username",S_OK}
4240         },
4241         {
4242             {Uri_HOST_DNS,S_OK},
4243             {80,S_OK},
4244             {URL_SCHEME_HTTP,S_OK},
4245             {URLZONE_INVALID,E_NOTIMPL}
4246         }
4247     },
4248     {   "http://google.com/",0,S_OK,FALSE,
4249         {
4250             {TRUE,"test",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
4251         },
4252         {TRUE,TRUE,120,S_OK,FALSE},
4253         0,S_OK,FALSE,
4254         0,S_OK,FALSE,
4255         0,0,0,S_OK,FALSE,
4256         {
4257             {"test://google.com:120/",S_OK},
4258             {"google.com:120",S_OK},
4259             {"test://google.com:120/",S_OK},
4260             {"google.com",S_OK},
4261             {"",S_FALSE},
4262             {"",S_FALSE},
4263             {"google.com",S_OK},
4264             {"",S_FALSE},
4265             {"/",S_OK},
4266             {"/",S_OK},
4267             {"",S_FALSE},
4268             {"test://google.com:120/",S_OK},
4269             {"test",S_OK},
4270             {"",S_FALSE},
4271             {"",S_FALSE}
4272         },
4273         {
4274             {Uri_HOST_DNS,S_OK},
4275             {120,S_OK},
4276             {URL_SCHEME_UNKNOWN,S_OK},
4277             {URLZONE_INVALID,E_NOTIMPL}
4278         }
4279     },
4280     {   "/Test/test dir",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4281         {
4282             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
4283             {TRUE,"::192.2.3.4",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
4284             {TRUE,NULL,NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
4285         },
4286         {FALSE},
4287         0,S_OK,FALSE,
4288         0,S_OK,FALSE,
4289         0,0,0,S_OK,FALSE,
4290         {
4291             {"http://[::192.2.3.4]/",S_OK},
4292             {"[::192.2.3.4]",S_OK},
4293             {"http://[::192.2.3.4]/",S_OK},
4294             {"",S_FALSE},
4295             {"",S_FALSE},
4296             {"",S_FALSE},
4297             {"::192.2.3.4",S_OK},
4298             {"",S_FALSE},
4299             {"/",S_OK},
4300             {"/",S_OK},
4301             {"",S_FALSE},
4302             {"http://[::192.2.3.4]/",S_OK},
4303             {"http",S_OK},
4304             {"",S_FALSE},
4305             {"",S_FALSE}
4306         },
4307         {
4308             {Uri_HOST_IPV6,S_OK},
4309             {80,S_OK},
4310             {URL_SCHEME_HTTP,S_OK},
4311             {URLZONE_INVALID,E_NOTIMPL}
4312         }
4313     },
4314     {   "http://google.com/",0,S_OK,FALSE,
4315         {
4316             {TRUE,"Frag","#Frag",Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4317         },
4318         {FALSE},
4319         0,S_OK,FALSE,
4320         0,S_OK,FALSE,
4321         0,0,0,S_OK,FALSE,
4322         {
4323             {"http://google.com/#Frag",S_OK},
4324             {"google.com",S_OK},
4325             {"http://google.com/#Frag",S_OK},
4326             {"google.com",S_OK},
4327             {"",S_FALSE},
4328             {"#Frag",S_OK},
4329             {"google.com",S_OK},
4330             {"",S_FALSE},
4331             {"/",S_OK},
4332             {"/",S_OK},
4333             {"",S_FALSE},
4334             {"http://google.com/#Frag",S_OK},
4335             {"http",S_OK},
4336             {"",S_FALSE},
4337             {"",S_FALSE}
4338         },
4339         {
4340             {Uri_HOST_DNS,S_OK},
4341             {80,S_OK},
4342             {URL_SCHEME_HTTP,S_OK},
4343             {URLZONE_INVALID,E_NOTIMPL}
4344         }
4345     },
4346     {   "http://google.com/",0,S_OK,FALSE,
4347         {
4348             {TRUE,"","#",Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4349         },
4350         {FALSE},
4351         0,S_OK,FALSE,
4352         0,S_OK,FALSE,
4353         0,0,0,S_OK,FALSE,
4354         {
4355             {"http://google.com/#",S_OK},
4356             {"google.com",S_OK},
4357             {"http://google.com/#",S_OK},
4358             {"google.com",S_OK},
4359             {"",S_FALSE},
4360             {"#",S_OK},
4361             {"google.com",S_OK},
4362             {"",S_FALSE},
4363             {"/",S_OK},
4364             {"/",S_OK},
4365             {"",S_FALSE},
4366             {"http://google.com/#",S_OK},
4367             {"http",S_OK},
4368             {"",S_FALSE},
4369             {"",S_FALSE}
4370         },
4371         {
4372             {Uri_HOST_DNS,S_OK},
4373             {80,S_OK},
4374             {URL_SCHEME_HTTP,S_OK},
4375             {URLZONE_INVALID,E_NOTIMPL}
4376         }
4377     },
4378     {   "http://google.com/",0,S_OK,FALSE,
4379         {
4380             {TRUE,":password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4381         },
4382         {FALSE},
4383         0,S_OK,FALSE,
4384         0,S_OK,FALSE,
4385         0,0,0,S_OK,FALSE,
4386         {
4387             {"http://::password@google.com/",S_OK},
4388             {"::password@google.com",S_OK},
4389             {"http://google.com/",S_OK},
4390             {"google.com",S_OK},
4391             {"",S_FALSE},
4392             {"",S_FALSE},
4393             {"google.com",S_OK},
4394             {":password",S_OK},
4395             {"/",S_OK},
4396             {"/",S_OK},
4397             {"",S_FALSE},
4398             {"http://::password@google.com/",S_OK},
4399             {"http",S_OK},
4400             {"::password",S_OK},
4401             {"",S_FALSE}
4402         },
4403         {
4404             {Uri_HOST_DNS,S_OK},
4405             {80,S_OK},
4406             {URL_SCHEME_HTTP,S_OK},
4407             {URLZONE_INVALID,E_NOTIMPL}
4408         }
4409     },
4410     {   "test/test",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4411         {
4412             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4413         },
4414         {FALSE},
4415         Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4416         0,S_OK,FALSE,
4417         Uri_CREATE_ALLOW_RELATIVE,0,0,S_OK,FALSE,
4418         {
4419             {":password@test/test",S_OK},
4420             {":password@",S_OK},
4421             {":password@test/test",S_OK},
4422             {"",S_FALSE},
4423             {"",S_FALSE},
4424             {"",S_FALSE},
4425             {"",S_FALSE},
4426             {"password",S_OK},
4427             {"test/test",S_OK},
4428             {"test/test",S_OK},
4429             {"",S_FALSE},
4430             {":password@test/test",S_OK},
4431             {"",S_FALSE},
4432             {":password",S_OK},
4433             {"",S_FALSE}
4434         },
4435         {
4436             {Uri_HOST_UNKNOWN,S_OK},
4437             {0,S_FALSE},
4438             {URL_SCHEME_UNKNOWN,S_OK},
4439             {URLZONE_INVALID,E_NOTIMPL}
4440         }
4441     },
4442     {   "http://google.com/",0,S_OK,FALSE,
4443         {
4444             {TRUE,"test/test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4445         },
4446         {FALSE},
4447         0,S_OK,FALSE,
4448         0,S_OK,FALSE,
4449         0,0,0,S_OK,FALSE,
4450         {
4451             {"http://google.com/test/test",S_OK},
4452             {"google.com",S_OK},
4453             {"http://google.com/test/test",S_OK},
4454             {"google.com",S_OK},
4455             {"",S_FALSE},
4456             {"",S_FALSE},
4457             {"google.com",S_OK},
4458             {"",S_FALSE},
4459             {"/test/test",S_OK},
4460             {"/test/test",S_OK},
4461             {"",S_FALSE},
4462             {"http://google.com/test/test",S_OK},
4463             {"http",S_OK},
4464             {"",S_FALSE},
4465             {"",S_FALSE}
4466         },
4467         {
4468             {Uri_HOST_DNS,S_OK},
4469             {80,S_OK},
4470             {URL_SCHEME_HTTP,S_OK},
4471             {URLZONE_INVALID,E_NOTIMPL}
4472         }
4473     },
4474     {   "zip:testing/test",0,S_OK,FALSE,
4475         {
4476             {TRUE,"test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4477         },
4478         {FALSE},
4479         0,S_OK,FALSE,
4480         0,S_OK,FALSE,
4481         0,0,0,S_OK,FALSE,
4482         {
4483             {"zip:test",S_OK},
4484             {"",S_FALSE},
4485             {"zip:test",S_OK},
4486             {"",S_FALSE},
4487             {"",S_FALSE},
4488             {"",S_FALSE},
4489             {"",S_FALSE},
4490             {"",S_FALSE},
4491             {"test",S_OK},
4492             {"test",S_OK},
4493             {"",S_FALSE},
4494             {"zip:test",S_OK},
4495             {"zip",S_OK},
4496             {"",S_FALSE},
4497             {"",S_FALSE}
4498         },
4499         {
4500             {Uri_HOST_UNKNOWN,S_OK},
4501             {0,S_FALSE},
4502             {URL_SCHEME_UNKNOWN,S_OK},
4503             {URLZONE_INVALID,E_NOTIMPL}
4504         }
4505     },
4506     {   "http://google.com/",0,S_OK,FALSE,
4507         {
4508             {FALSE},
4509         },
4510         /* 555 will be returned from GetPort even though FALSE was passed as the hasPort parameter. */
4511         {TRUE,FALSE,555,S_OK,FALSE},
4512         0,S_OK,FALSE,
4513         0,S_OK,FALSE,
4514         0,0,0,S_OK,FALSE,
4515         {
4516             {"http://google.com/",S_OK},
4517             {"google.com",S_OK},
4518             {"http://google.com/",S_OK},
4519             {"google.com",S_OK},
4520             {"",S_FALSE},
4521             {"",S_FALSE},
4522             {"google.com",S_OK},
4523             {"",S_FALSE},
4524             {"/",S_OK},
4525             {"/",S_OK},
4526             {"",S_FALSE},
4527             {"http://google.com/",S_OK},
4528             {"http",S_OK},
4529             {"",S_FALSE},
4530             {"",S_FALSE}
4531         },
4532         {
4533             {Uri_HOST_DNS,S_OK},
4534             /* Still returns 80, even though earlier the port was disabled. */
4535             {80,S_OK},
4536             {URL_SCHEME_HTTP,S_OK},
4537             {URLZONE_INVALID,E_NOTIMPL}
4538         }
4539     },
4540     {   "http://google.com/",0,S_OK,FALSE,
4541         {
4542             {FALSE},
4543         },
4544         /* Instead of getting "TRUE" back as the "hasPort" parameter in GetPort,
4545          * you'll get 122345 instead.
4546          */
4547         {TRUE,122345,222,S_OK,FALSE},
4548         0,S_OK,FALSE,
4549         0,S_OK,FALSE,
4550         0,0,0,S_OK,FALSE,
4551         {
4552             {"http://google.com:222/",S_OK},
4553             {"google.com:222",S_OK},
4554             {"http://google.com:222/",S_OK},
4555             {"google.com",S_OK},
4556             {"",S_FALSE},
4557             {"",S_FALSE},
4558             {"google.com",S_OK},
4559             {"",S_FALSE},
4560             {"/",S_OK},
4561             {"/",S_OK},
4562             {"",S_FALSE},
4563             {"http://google.com:222/",S_OK},
4564             {"http",S_OK},
4565             {"",S_FALSE},
4566             {"",S_FALSE}
4567         },
4568         {
4569             {Uri_HOST_DNS,S_OK},
4570             {222,S_OK},
4571             {URL_SCHEME_HTTP,S_OK},
4572             {URLZONE_INVALID,E_NOTIMPL}
4573         }
4574     },
4575     /* IUri's created with the IUriBuilder can have ports that exceed USHORT_MAX. */
4576     {   "http://google.com/",0,S_OK,FALSE,
4577         {
4578             {FALSE},
4579         },
4580         {TRUE,TRUE,999999,S_OK,FALSE},
4581         0,S_OK,FALSE,
4582         0,S_OK,FALSE,
4583         0,0,0,S_OK,FALSE,
4584         {
4585             {"http://google.com:999999/",S_OK},
4586             {"google.com:999999",S_OK},
4587             {"http://google.com:999999/",S_OK},
4588             {"google.com",S_OK},
4589             {"",S_FALSE},
4590             {"",S_FALSE},
4591             {"google.com",S_OK},
4592             {"",S_FALSE},
4593             {"/",S_OK},
4594             {"/",S_OK},
4595             {"",S_FALSE},
4596             {"http://google.com:999999/",S_OK},
4597             {"http",S_OK},
4598             {"",S_FALSE},
4599             {"",S_FALSE}
4600         },
4601         {
4602             {Uri_HOST_DNS,S_OK},
4603             {999999,S_OK},
4604             {URL_SCHEME_HTTP,S_OK},
4605             {URLZONE_INVALID,E_NOTIMPL}
4606         }
4607     },
4608     {   "http://google.com/",0,S_OK,FALSE,
4609         {
4610             {TRUE,"test","?test",Uri_PROPERTY_QUERY,S_OK,FALSE},
4611         },
4612
4613         {FALSE},
4614         0,S_OK,FALSE,
4615         0,S_OK,FALSE,
4616         0,0,0,S_OK,FALSE,
4617         {
4618             {"http://google.com/?test",S_OK},
4619             {"google.com",S_OK},
4620             {"http://google.com/?test",S_OK},
4621             {"google.com",S_OK},
4622             {"",S_FALSE},
4623             {"",S_FALSE},
4624             {"google.com",S_OK},
4625             {"",S_FALSE},
4626             {"/",S_OK},
4627             {"/?test",S_OK},
4628             {"?test",S_OK},
4629             {"http://google.com/?test",S_OK},
4630             {"http",S_OK},
4631             {"",S_FALSE},
4632             {"",S_FALSE}
4633         },
4634         {
4635             {Uri_HOST_DNS,S_OK},
4636             {80,S_OK},
4637             {URL_SCHEME_HTTP,S_OK},
4638             {URLZONE_INVALID,E_NOTIMPL}
4639         }
4640     },
4641     {   "http://:password@google.com/",0,S_OK,FALSE,
4642         {
4643             {FALSE},
4644         },
4645         {FALSE},
4646         0,S_OK,FALSE,
4647         0,S_OK,FALSE,
4648         0,0,0,S_OK,FALSE,
4649         {
4650             {"http://:password@google.com/",S_OK},
4651             {":password@google.com",S_OK},
4652             {"http://google.com/",S_OK},
4653             {"google.com",S_OK},
4654             {"",S_FALSE},
4655             {"",S_FALSE},
4656             {"google.com",S_OK},
4657             {"password",S_OK},
4658             {"/",S_OK},
4659             {"/",S_OK},
4660             {"",S_FALSE},
4661             {"http://:password@google.com/",S_OK},
4662             {"http",S_OK},
4663             {":password",S_OK},
4664             {"",S_FALSE}
4665         },
4666         {
4667             {Uri_HOST_DNS,S_OK},
4668             {80,S_OK},
4669             {URL_SCHEME_HTTP,S_OK},
4670             {URLZONE_INVALID,E_NOTIMPL}
4671         }
4672     },
4673     /* IUriBuilder doesn't need a base IUri to build a IUri. */
4674     {   NULL,0,S_OK,FALSE,
4675         {
4676             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
4677             {TRUE,"google.com",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
4678         },
4679         {FALSE},
4680         0,S_OK,FALSE,
4681         0,S_OK,FALSE,
4682         0,0,0,S_OK,FALSE,
4683         {
4684             {"http://google.com/",S_OK},
4685             {"google.com",S_OK},
4686             {"http://google.com/",S_OK},
4687             {"google.com",S_OK},
4688             {"",S_FALSE},
4689             {"",S_FALSE},
4690             {"google.com",S_OK},
4691             {"",S_FALSE},
4692             {"/",S_OK},
4693             {"/",S_OK},
4694             {"",S_FALSE},
4695             {"http://google.com/",S_OK},
4696             {"http",S_OK},
4697             {"",S_FALSE},
4698             {"",S_FALSE}
4699         },
4700         {
4701             {Uri_HOST_DNS,S_OK},
4702             {80,S_OK},
4703             {URL_SCHEME_HTTP,S_OK},
4704             {URLZONE_INVALID,E_NOTIMPL}
4705         }
4706     },
4707     /* Can't set the scheme name to NULL. */
4708     {   "zip://google.com/",0,S_OK,FALSE,
4709         {
4710             {TRUE,NULL,"zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
4711         },
4712         {FALSE},
4713         0,S_OK,FALSE,
4714         0,S_OK,FALSE,
4715         0,0,0,S_OK,FALSE,
4716         {
4717             {"zip://google.com/",S_OK},
4718             {"google.com",S_OK},
4719             {"zip://google.com/",S_OK},
4720             {"google.com",S_OK},
4721             {"",S_FALSE},
4722             {"",S_FALSE},
4723             {"google.com",S_OK},
4724             {"",S_FALSE},
4725             {"/",S_OK},
4726             {"/",S_OK},
4727             {"",S_FALSE},
4728             {"zip://google.com/",S_OK},
4729             {"zip",S_OK},
4730             {"",S_FALSE},
4731             {"",S_FALSE}
4732         },
4733         {
4734             {Uri_HOST_DNS,S_OK},
4735             {0,S_FALSE},
4736             {URL_SCHEME_UNKNOWN,S_OK},
4737             {URLZONE_INVALID,E_NOTIMPL}
4738         }
4739     },
4740     /* Can't set the scheme name to an empty string. */
4741     {   "zip://google.com/",0,S_OK,FALSE,
4742         {
4743             {TRUE,"","zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
4744         },
4745         {FALSE},
4746         0,S_OK,FALSE,
4747         0,S_OK,FALSE,
4748         0,0,0,S_OK,FALSE,
4749         {
4750             {"zip://google.com/",S_OK},
4751             {"google.com",S_OK},
4752             {"zip://google.com/",S_OK},
4753             {"google.com",S_OK},
4754             {"",S_FALSE},
4755             {"",S_FALSE},
4756             {"google.com",S_OK},
4757             {"",S_FALSE},
4758             {"/",S_OK},
4759             {"/",S_OK},
4760             {"",S_FALSE},
4761             {"zip://google.com/",S_OK},
4762             {"zip",S_OK},
4763             {"",S_FALSE},
4764             {"",S_FALSE}
4765         },
4766         {
4767             {Uri_HOST_DNS,S_OK},
4768             {0,S_FALSE},
4769             {URL_SCHEME_UNKNOWN,S_OK},
4770             {URLZONE_INVALID,E_NOTIMPL}
4771         }
4772     },
4773     /* -1 to CreateUri makes it use the same flags as the base IUri was created with.
4774      * CreateUriSimple always uses the flags the base IUri was created with (if any).
4775      */
4776     {   "http://google.com/../../",Uri_CREATE_NO_CANONICALIZE,S_OK,FALSE,
4777         {{FALSE}},
4778         {FALSE},
4779         -1,S_OK,FALSE,
4780         0,S_OK,FALSE,
4781         0,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
4782         {
4783             {"http://google.com/../../",S_OK},
4784             {"google.com",S_OK},
4785             {"http://google.com/../../",S_OK},
4786             {"google.com",S_OK},
4787             {"",S_FALSE},
4788             {"",S_FALSE},
4789             {"google.com",S_OK},
4790             {"",S_FALSE},
4791             {"/../../",S_OK},
4792             {"/../../",S_OK},
4793             {"",S_FALSE},
4794             {"http://google.com/../../",S_OK},
4795             {"http",S_OK},
4796             {"",S_FALSE},
4797             {"",S_FALSE}
4798         },
4799         {
4800             {Uri_HOST_DNS,S_OK},
4801             {80,S_OK},
4802             {URL_SCHEME_HTTP,S_OK},
4803             {URLZONE_INVALID,E_NOTIMPL}
4804         }
4805     },
4806     {   "http://google.com/",0,S_OK,FALSE,
4807         {
4808             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4809         },
4810         {FALSE},
4811         -1,S_OK,FALSE,
4812         0,S_OK,FALSE,
4813         Uri_CREATE_NO_DECODE_EXTRA_INFO,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
4814         {
4815             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
4816             {"google.com",S_OK},
4817             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
4818             {"google.com",S_OK},
4819             {"",S_FALSE},
4820             {"#Fr%3C%7C%3Eg",S_OK},
4821             {"google.com",S_OK},
4822             {"",S_FALSE},
4823             {"/",S_OK},
4824             {"/",S_OK},
4825             {"",S_FALSE},
4826             {"http://google.com/#Fr<|>g",S_OK},
4827             {"http",S_OK},
4828             {"",S_FALSE},
4829             {"",S_FALSE}
4830         },
4831         {
4832             {Uri_HOST_DNS,S_OK},
4833             {80,S_OK},
4834             {URL_SCHEME_HTTP,S_OK},
4835             {URLZONE_INVALID,E_NOTIMPL}
4836         }
4837     },
4838     {   "http://google.com/",0,S_OK,FALSE,
4839         {
4840             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4841         },
4842         {FALSE},
4843         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,E_INVALIDARG,FALSE,
4844         0,S_OK,FALSE,
4845         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
4846         {
4847             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
4848             {"google.com",S_OK},
4849             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
4850             {"google.com",S_OK},
4851             {"",S_FALSE},
4852             {"#Fr%3C%7C%3Eg",S_OK},
4853             {"google.com",S_OK},
4854             {"",S_FALSE},
4855             {"/",S_OK},
4856             {"/",S_OK},
4857             {"",S_FALSE},
4858             {"http://google.com/#Fr<|>g",S_OK},
4859             {"http",S_OK},
4860             {"",S_FALSE},
4861             {"",S_FALSE}
4862         },
4863         {
4864             {Uri_HOST_DNS,S_OK},
4865             {80,S_OK},
4866             {URL_SCHEME_HTTP,S_OK},
4867             {URLZONE_INVALID,E_NOTIMPL}
4868         }
4869     },
4870     {   NULL,0,S_OK,FALSE,
4871         {
4872             {TRUE,"/test/test/",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4873             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4874         },
4875         {FALSE},
4876         0,INET_E_INVALID_URL,FALSE,
4877         0,INET_E_INVALID_URL,FALSE,
4878         0,0,0,INET_E_INVALID_URL,FALSE
4879     },
4880     {   "http://google.com/",0,S_OK,FALSE,
4881         {
4882             {TRUE,"ht%xxtp",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
4883         },
4884         {FALSE},
4885         0,INET_E_INVALID_URL,FALSE,
4886         0,INET_E_INVALID_URL,FALSE,
4887         0,0,0,INET_E_INVALID_URL,FALSE
4888     },
4889     /* File scheme's can't have a username set. */
4890     {   "file://google.com/",0,S_OK,FALSE,
4891         {
4892             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4893         },
4894         {FALSE},
4895         0,INET_E_INVALID_URL,FALSE,
4896         0,INET_E_INVALID_URL,FALSE,
4897         0,0,0,INET_E_INVALID_URL,FALSE
4898     },
4899     /* File schemes can't have a password set. */
4900     {   "file://google.com/",0,S_OK,FALSE,
4901         {
4902             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4903         },
4904         {FALSE},
4905         0,INET_E_INVALID_URL,FALSE,
4906         0,INET_E_INVALID_URL,FALSE,
4907         0,0,0,INET_E_INVALID_URL,FALSE
4908     },
4909     /* UserName can't contain any character that is a delimeter for another
4910      * component that appears after it in a normal URI.
4911      */
4912     {   "http://google.com/",0,S_OK,FALSE,
4913         {
4914             {TRUE,"user:pass",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4915         },
4916         {FALSE},
4917         0,INET_E_INVALID_URL,FALSE,
4918         0,INET_E_INVALID_URL,FALSE,
4919         0,0,0,INET_E_INVALID_URL,FALSE
4920     },
4921     {   "http://google.com/",0,S_OK,FALSE,
4922         {
4923             {TRUE,"user@google.com",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4924         },
4925         {FALSE},
4926         0,INET_E_INVALID_URL,FALSE,
4927         0,INET_E_INVALID_URL,FALSE,
4928         0,0,0,INET_E_INVALID_URL,FALSE
4929     },
4930     {   "http://google.com/",0,S_OK,FALSE,
4931         {
4932             {TRUE,"user/path",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4933         },
4934         {FALSE},
4935         0,INET_E_INVALID_URL,FALSE,
4936         0,INET_E_INVALID_URL,FALSE,
4937         0,0,0,INET_E_INVALID_URL,FALSE
4938     },
4939     {   "http://google.com/",0,S_OK,FALSE,
4940         {
4941             {TRUE,"user?Query",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4942         },
4943         {FALSE},
4944         0,INET_E_INVALID_URL,FALSE,
4945         0,INET_E_INVALID_URL,FALSE,
4946         0,0,0,INET_E_INVALID_URL,FALSE
4947     },
4948     {   "http://google.com/",0,S_OK,FALSE,
4949         {
4950             {TRUE,"user#Frag",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4951         },
4952         {FALSE},
4953         0,INET_E_INVALID_URL,FALSE,
4954         0,INET_E_INVALID_URL,FALSE,
4955         0,0,0,INET_E_INVALID_URL,FALSE
4956     },
4957     {   "http://google.com/",0,S_OK,FALSE,
4958         {
4959             {TRUE,"pass@google.com",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4960         },
4961         {FALSE},
4962         0,INET_E_INVALID_URL,FALSE,
4963         0,INET_E_INVALID_URL,FALSE,
4964         0,0,0,INET_E_INVALID_URL,FALSE
4965     },
4966     {   "http://google.com/",0,S_OK,FALSE,
4967         {
4968             {TRUE,"pass/path",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4969         },
4970         {FALSE},
4971         0,INET_E_INVALID_URL,FALSE,
4972         0,INET_E_INVALID_URL,FALSE,
4973         0,0,0,INET_E_INVALID_URL,FALSE
4974     },
4975     {   "http://google.com/",0,S_OK,FALSE,
4976         {
4977             {TRUE,"pass?query",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4978         },
4979         {FALSE},
4980         0,INET_E_INVALID_URL,FALSE,
4981         0,INET_E_INVALID_URL,FALSE,
4982        0,0,0,INET_E_INVALID_URL,FALSE
4983     },
4984     {   "http://google.com/",0,S_OK,FALSE,
4985         {
4986             {TRUE,"pass#frag",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4987         },
4988         {FALSE},
4989         0,INET_E_INVALID_URL,FALSE,
4990         0,INET_E_INVALID_URL,FALSE,
4991         0,0,0,INET_E_INVALID_URL,FALSE
4992     },
4993     {   "http://google.com/",0,S_OK,FALSE,
4994         {
4995             {TRUE,"winehq.org/test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
4996         },
4997         {FALSE},
4998         0,INET_E_INVALID_URL,FALSE,
4999         0,INET_E_INVALID_URL,FALSE,
5000         0,0,0,INET_E_INVALID_URL,FALSE
5001     },
5002     {   "http://google.com/",0,S_OK,FALSE,
5003         {
5004             {TRUE,"winehq.org?test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5005         },
5006         {FALSE},
5007         0,INET_E_INVALID_URL,FALSE,
5008         0,INET_E_INVALID_URL,FALSE,
5009         0,0,0,INET_E_INVALID_URL,FALSE
5010     },
5011     {   "http://google.com/",0,S_OK,FALSE,
5012         {
5013             {TRUE,"winehq.org#test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5014         },
5015         {FALSE},
5016         0,INET_E_INVALID_URL,FALSE,
5017         0,INET_E_INVALID_URL,FALSE,
5018         0,0,0,INET_E_INVALID_URL,FALSE
5019     },
5020     /* Hostname is allowed to contain a ':' (even for known scheme types). */
5021     {   "http://google.com/",0,S_OK,FALSE,
5022         {
5023             {TRUE,"winehq.org:test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
5024         },
5025         {FALSE},
5026         0,S_OK,FALSE,
5027         0,S_OK,FALSE,
5028         0,0,0,S_OK,FALSE,
5029         {
5030             {"http://winehq.org:test/",S_OK},
5031             {"winehq.org:test",S_OK},
5032             {"http://winehq.org:test/",S_OK},
5033             {"winehq.org:test",S_OK},
5034             {"",S_FALSE},
5035             {"",S_FALSE},
5036             {"winehq.org:test",S_OK},
5037             {"",S_FALSE},
5038             {"/",S_OK},
5039             {"/",S_OK},
5040             {"",S_FALSE},
5041             {"http://winehq.org:test/",S_OK},
5042             {"http",S_OK},
5043             {"",S_FALSE},
5044             {"",S_FALSE}
5045         },
5046         {
5047             {Uri_HOST_DNS,S_OK},
5048             {80,S_OK},
5049             {URL_SCHEME_HTTP,S_OK},
5050             {URLZONE_INVALID,E_NOTIMPL}
5051         }
5052     },
5053     /* Can't set the host name to NULL. */
5054     {   "http://google.com/",0,S_OK,FALSE,
5055         {
5056             {TRUE,NULL,"google.com",Uri_PROPERTY_HOST,E_INVALIDARG,FALSE}
5057         },
5058         {FALSE},
5059         0,S_OK,FALSE,
5060         0,S_OK,FALSE,
5061         0,0,0,S_OK,FALSE,
5062         {
5063             {"http://google.com/",S_OK},
5064             {"google.com",S_OK},
5065             {"http://google.com/",S_OK},
5066             {"google.com",S_OK},
5067             {"",S_FALSE},
5068             {"",S_FALSE},
5069             {"google.com",S_OK},
5070             {"",S_FALSE},
5071             {"/",S_OK},
5072             {"/",S_OK},
5073             {"",S_FALSE},
5074             {"http://google.com/",S_OK},
5075             {"http",S_OK},
5076             {"",S_FALSE},
5077             {"",S_FALSE}
5078         },
5079         {
5080             {Uri_HOST_DNS,S_OK},
5081             {80,S_OK},
5082             {URL_SCHEME_HTTP,S_OK},
5083             {URLZONE_INVALID,E_NOTIMPL}
5084         }
5085     },
5086     /* Can set the host name to an empty string. */
5087     {   "http://google.com/",0,S_OK,FALSE,
5088         {
5089             {TRUE,"",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5090         },
5091         {FALSE},
5092         0,S_OK,FALSE,
5093         0,S_OK,FALSE,
5094         0,0,0,S_OK,FALSE,
5095         {
5096             {"http:///",S_OK},
5097             {"",S_OK},
5098             {"http:///",S_OK},
5099             {"",S_FALSE},
5100             {"",S_FALSE},
5101             {"",S_FALSE},
5102             {"",S_OK},
5103             {"",S_FALSE},
5104             {"/",S_OK},
5105             {"/",S_OK},
5106             {"",S_FALSE},
5107             {"http:///",S_OK},
5108             {"http",S_OK},
5109             {"",S_FALSE},
5110             {"",S_FALSE}
5111         },
5112         {
5113             {Uri_HOST_UNKNOWN,S_OK},
5114             {80,S_OK},
5115             {URL_SCHEME_HTTP,S_OK},
5116             {URLZONE_INVALID,E_NOTIMPL}
5117         }
5118     },
5119     {   "http://google.com/",0,S_OK,FALSE,
5120         {
5121             {TRUE,"/path?query",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5122         },
5123         {FALSE},
5124         0,INET_E_INVALID_URL,FALSE,
5125         0,INET_E_INVALID_URL,FALSE,
5126         0,0,0,INET_E_INVALID_URL,FALSE
5127     },
5128     {   "http://google.com/",0,S_OK,FALSE,
5129         {
5130             {TRUE,"/path#test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5131         },
5132         {FALSE},
5133         0,INET_E_INVALID_URL,FALSE,
5134         0,INET_E_INVALID_URL,FALSE,
5135         0,0,0,INET_E_INVALID_URL,FALSE
5136     },
5137     {   "http://google.com/",0,S_OK,FALSE,
5138         {
5139             {TRUE,"?path#test",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE}
5140         },
5141         {FALSE},
5142         0,INET_E_INVALID_URL,FALSE,
5143         0,INET_E_INVALID_URL,FALSE,
5144         0,0,0,INET_E_INVALID_URL,FALSE
5145     }
5146 };
5147
5148 typedef struct _uri_builder_remove_test {
5149     const char  *uri;
5150     DWORD       create_flags;
5151     HRESULT     create_builder_expected;
5152     BOOL        create_builder_todo;
5153
5154     DWORD       remove_properties;
5155     HRESULT     remove_expected;
5156     BOOL        remove_todo;
5157
5158     const char  *expected_uri;
5159     DWORD       expected_flags;
5160     HRESULT     expected_hres;
5161     BOOL        expected_todo;
5162 } uri_builder_remove_test;
5163
5164 static const uri_builder_remove_test uri_builder_remove_tests[] = {
5165     {   "http://google.com/test?test=y#Frag",0,S_OK,FALSE,
5166         Uri_HAS_FRAGMENT|Uri_HAS_PATH|Uri_HAS_QUERY,S_OK,FALSE,
5167         "http://google.com/",0,S_OK,FALSE
5168     },
5169     {   "http://user:pass@winehq.org/",0,S_OK,FALSE,
5170         Uri_HAS_USER_NAME|Uri_HAS_PASSWORD,S_OK,FALSE,
5171         "http://winehq.org/",0,S_OK,FALSE
5172     },
5173     {   "zip://google.com?Test=x",0,S_OK,FALSE,
5174         Uri_HAS_HOST,S_OK,FALSE,
5175         "zip:/?Test=x",0,S_OK,FALSE
5176     },
5177     /* Doesn't remove the whole userinfo component. */
5178     {   "http://username:pass@google.com/",0,S_OK,FALSE,
5179         Uri_HAS_USER_INFO,S_OK,FALSE,
5180         "http://username:pass@google.com/",0,S_OK,FALSE
5181     },
5182     /* Doesn't remove the domain. */
5183     {   "http://google.com/",0,S_OK,FALSE,
5184         Uri_HAS_DOMAIN,S_OK,FALSE,
5185         "http://google.com/",0,S_OK,FALSE
5186     },
5187     {   "http://google.com:120/",0,S_OK,FALSE,
5188         Uri_HAS_AUTHORITY,S_OK,FALSE,
5189         "http://google.com:120/",0,S_OK,FALSE
5190     },
5191     {   "http://google.com/test.com/",0,S_OK,FALSE,
5192         Uri_HAS_EXTENSION,S_OK,FALSE,
5193         "http://google.com/test.com/",0,S_OK,FALSE
5194     },
5195     {   "http://google.com/?test=x",0,S_OK,FALSE,
5196         Uri_HAS_PATH_AND_QUERY,S_OK,FALSE,
5197         "http://google.com/?test=x",0,S_OK,FALSE
5198     },
5199     /* Can't remove the scheme name. */
5200     {   "http://google.com/?test=x",0,S_OK,FALSE,
5201         Uri_HAS_SCHEME_NAME|Uri_HAS_QUERY,E_INVALIDARG,FALSE,
5202         "http://google.com/?test=x",0,S_OK,FALSE
5203     }
5204 };
5205
5206 typedef struct _uri_combine_str_property {
5207     const char  *value;
5208     HRESULT     expected;
5209     BOOL        todo;
5210     const char  *broken_value;
5211     const char  *value_ex;
5212 } uri_combine_str_property;
5213
5214 typedef struct _uri_combine_test {
5215     const char  *base_uri;
5216     DWORD       base_create_flags;
5217     const char  *relative_uri;
5218     DWORD       relative_create_flags;
5219     DWORD       combine_flags;
5220     HRESULT     expected;
5221     BOOL        todo;
5222
5223     uri_combine_str_property    str_props[URI_STR_PROPERTY_COUNT];
5224     uri_dword_property          dword_props[URI_DWORD_PROPERTY_COUNT];
5225 } uri_combine_test;
5226
5227 static const uri_combine_test uri_combine_tests[] = {
5228     {   "http://google.com/fun/stuff",0,
5229         "../not/fun/stuff",Uri_CREATE_ALLOW_RELATIVE,
5230         0,S_OK,FALSE,
5231         {
5232             {"http://google.com/not/fun/stuff",S_OK},
5233             {"google.com",S_OK},
5234             {"http://google.com/not/fun/stuff",S_OK},
5235             {"google.com",S_OK},
5236             {"",S_FALSE},
5237             {"",S_FALSE},
5238             {"google.com",S_OK},
5239             {"",S_FALSE},
5240             {"/not/fun/stuff",S_OK},
5241             {"/not/fun/stuff",S_OK},
5242             {"",S_FALSE},
5243             {"http://google.com/not/fun/stuff",S_OK},
5244             {"http",S_OK},
5245             {"",S_FALSE},
5246             {"",S_FALSE}
5247         },
5248         {
5249             {Uri_HOST_DNS,S_OK},
5250             {80,S_OK},
5251             {URL_SCHEME_HTTP,S_OK},
5252             {URLZONE_INVALID,E_NOTIMPL}
5253         }
5254     },
5255     {   "http://google.com/test",0,
5256         "zip://test.com/cool",0,
5257         0,S_OK,FALSE,
5258         {
5259             {"zip://test.com/cool",S_OK},
5260             {"test.com",S_OK},
5261             {"zip://test.com/cool",S_OK},
5262             {"test.com",S_OK},
5263             {"",S_FALSE},
5264             {"",S_FALSE},
5265             {"test.com",S_OK},
5266             {"",S_FALSE},
5267             {"/cool",S_OK},
5268             {"/cool",S_OK},
5269             {"",S_FALSE},
5270             {"zip://test.com/cool",S_OK},
5271             {"zip",S_OK},
5272             {"",S_FALSE},
5273             {"",S_FALSE}
5274         },
5275         {
5276             {Uri_HOST_DNS,S_OK},
5277             {0,S_FALSE},
5278             {URL_SCHEME_UNKNOWN,S_OK},
5279             {URLZONE_INVALID,E_NOTIMPL}
5280         }
5281     },
5282     {   "http://google.com/use/base/path",0,
5283         "?relative",Uri_CREATE_ALLOW_RELATIVE,
5284         0,S_OK,FALSE,
5285         {
5286             {"http://google.com/use/base/path?relative",S_OK},
5287             {"google.com",S_OK},
5288             {"http://google.com/use/base/path?relative",S_OK},
5289             {"google.com",S_OK},
5290             {"",S_FALSE},
5291             {"",S_FALSE},
5292             {"google.com",S_OK},
5293             {"",S_FALSE},
5294             {"/use/base/path",S_OK},
5295             {"/use/base/path?relative",S_OK},
5296             {"?relative",S_OK},
5297             {"http://google.com/use/base/path?relative",S_OK},
5298             {"http",S_OK},
5299             {"",S_FALSE},
5300             {"",S_FALSE}
5301         },
5302         {
5303             {Uri_HOST_DNS,S_OK},
5304             {80,S_OK},
5305             {URL_SCHEME_HTTP,S_OK},
5306             {URLZONE_INVALID,E_NOTIMPL}
5307         }
5308     },
5309     {   "http://google.com/path",0,
5310         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5311         0,S_OK,FALSE,
5312         {
5313             {"http://google.com/testing",S_OK},
5314             {"google.com",S_OK},
5315             {"http://google.com/testing",S_OK},
5316             {"google.com",S_OK},
5317             {"",S_FALSE},
5318             {"",S_FALSE},
5319             {"google.com",S_OK},
5320             {"",S_FALSE},
5321             {"/testing",S_OK},
5322             {"/testing",S_OK},
5323             {"",S_FALSE},
5324             {"http://google.com/testing",S_OK},
5325             {"http",S_OK},
5326             {"",S_FALSE},
5327             {"",S_FALSE}
5328         },
5329         {
5330             {Uri_HOST_DNS,S_OK},
5331             {80,S_OK},
5332             {URL_SCHEME_HTTP,S_OK},
5333             {URLZONE_INVALID,E_NOTIMPL}
5334         }
5335     },
5336     {   "http://google.com/path",0,
5337         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5338         URL_DONT_SIMPLIFY,S_OK,FALSE,
5339         {
5340             {"http://google.com:80/test/../test/.././testing",S_OK},
5341             {"google.com",S_OK},
5342             {"http://google.com:80/test/../test/.././testing",S_OK},
5343             {"google.com",S_OK},
5344             {"",S_FALSE},
5345             {"",S_FALSE},
5346             {"google.com",S_OK},
5347             {"",S_FALSE},
5348             {"/test/../test/.././testing",S_OK},
5349             {"/test/../test/.././testing",S_OK},
5350             {"",S_FALSE},
5351             {"http://google.com:80/test/../test/.././testing",S_OK},
5352             {"http",S_OK},
5353             {"",S_FALSE},
5354             {"",S_FALSE}
5355         },
5356         {
5357             {Uri_HOST_DNS,S_OK},
5358             {80,S_OK},
5359             {URL_SCHEME_HTTP,S_OK},
5360             {URLZONE_INVALID,E_NOTIMPL}
5361         }
5362     },
5363     {   "http://winehq.org/test/abc",0,
5364         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5365         0,S_OK,FALSE,
5366         {
5367             {"http://winehq.org/test/testing/test",S_OK},
5368             {"winehq.org",S_OK},
5369             {"http://winehq.org/test/testing/test",S_OK},
5370             {"winehq.org",S_OK},
5371             {"",S_FALSE},
5372             {"",S_FALSE},
5373             {"winehq.org",S_OK},
5374             {"",S_FALSE},
5375             {"/test/testing/test",S_OK},
5376             {"/test/testing/test",S_OK},
5377             {"",S_FALSE},
5378             {"http://winehq.org/test/testing/test",S_OK},
5379             {"http",S_OK},
5380             {"",S_FALSE},
5381             {"",S_FALSE}
5382         },
5383         {
5384             {Uri_HOST_DNS,S_OK},
5385             {80,S_OK},
5386             {URL_SCHEME_HTTP,S_OK},
5387             {URLZONE_INVALID,E_NOTIMPL}
5388         }
5389     },
5390     {   "http://winehq.org/test/abc",0,
5391         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5392         URL_DONT_SIMPLIFY,S_OK,FALSE,
5393         {
5394             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5395             /* Default port is hidden in the authority. */
5396             {"winehq.org",S_OK},
5397             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5398             {"winehq.org",S_OK},
5399             {"",S_FALSE},
5400             {"",S_FALSE},
5401             {"winehq.org",S_OK},
5402             {"",S_FALSE},
5403             {"/test/testing/abc/../test",S_OK},
5404             {"/test/testing/abc/../test",S_OK},
5405             {"",S_FALSE},
5406             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5407             {"http",S_OK},
5408             {"",S_FALSE},
5409             {"",S_FALSE}
5410         },
5411         {
5412             {Uri_HOST_DNS,S_OK},
5413             {80,S_OK},
5414             {URL_SCHEME_HTTP,S_OK},
5415             {URLZONE_INVALID,E_NOTIMPL}
5416         }
5417     },
5418     {   "http://winehq.org/test?query",0,
5419         "testing",Uri_CREATE_ALLOW_RELATIVE,
5420         0,S_OK,FALSE,
5421         {
5422             {"http://winehq.org/testing",S_OK},
5423             {"winehq.org",S_OK},
5424             {"http://winehq.org/testing",S_OK},
5425             {"winehq.org",S_OK},
5426             {"",S_FALSE},
5427             {"",S_FALSE},
5428             {"winehq.org",S_OK},
5429             {"",S_FALSE},
5430             {"/testing",S_OK},
5431             {"/testing",S_OK},
5432             {"",S_FALSE},
5433             {"http://winehq.org/testing",S_OK},
5434             {"http",S_OK},
5435             {"",S_FALSE},
5436             {"",S_FALSE}
5437         },
5438         {
5439             {Uri_HOST_DNS,S_OK},
5440             {80,S_OK},
5441             {URL_SCHEME_HTTP,S_OK},
5442             {URLZONE_INVALID,E_NOTIMPL}
5443         }
5444     },
5445     {   "http://winehq.org/test#frag",0,
5446         "testing",Uri_CREATE_ALLOW_RELATIVE,
5447         0,S_OK,FALSE,
5448         {
5449             {"http://winehq.org/testing",S_OK},
5450             {"winehq.org",S_OK},
5451             {"http://winehq.org/testing",S_OK},
5452             {"winehq.org",S_OK},
5453             {"",S_FALSE},
5454             {"",S_FALSE},
5455             {"winehq.org",S_OK},
5456             {"",S_FALSE},
5457             {"/testing",S_OK},
5458             {"/testing",S_OK},
5459             {"",S_FALSE},
5460             {"http://winehq.org/testing",S_OK},
5461             {"http",S_OK},
5462             {"",S_FALSE},
5463             {"",S_FALSE}
5464         },
5465         {
5466             {Uri_HOST_DNS,S_OK},
5467             {80,S_OK},
5468             {URL_SCHEME_HTTP,S_OK},
5469             {URLZONE_INVALID,E_NOTIMPL}
5470         }
5471     },
5472     {   "testing?query#frag",Uri_CREATE_ALLOW_RELATIVE,
5473         "test",Uri_CREATE_ALLOW_RELATIVE,
5474         0,S_OK,FALSE,
5475         {
5476             {"test",S_OK},
5477             {"",S_FALSE},
5478             {"test",S_OK},
5479             {"",S_FALSE},
5480             {"",S_FALSE},
5481             {"",S_FALSE},
5482             {"",S_FALSE},
5483             {"",S_FALSE},
5484             {"test",S_OK},
5485             {"test",S_OK},
5486             {"",S_FALSE},
5487             {"test",S_OK},
5488             {"",S_FALSE},
5489             {"",S_FALSE},
5490             {"",S_FALSE}
5491         },
5492         {
5493             {Uri_HOST_UNKNOWN,S_OK},
5494             {0,S_FALSE},
5495             {URL_SCHEME_UNKNOWN,S_OK},
5496             {URLZONE_INVALID,E_NOTIMPL}
5497         }
5498     },
5499     {   "file:///c:/test/test",0,
5500         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5501         URL_FILE_USE_PATHURL,S_OK,FALSE,
5502         {
5503             {"file://c:\\testing.mp3",S_OK},
5504             {"",S_FALSE},
5505             {"file://c:\\testing.mp3",S_OK},
5506             {"",S_FALSE},
5507             {".mp3",S_OK},
5508             {"",S_FALSE},
5509             {"",S_FALSE},
5510             {"",S_FALSE},
5511             {"c:\\testing.mp3",S_OK},
5512             {"c:\\testing.mp3",S_OK},
5513             {"",S_FALSE},
5514             {"file://c:\\testing.mp3",S_OK},
5515             {"file",S_OK},
5516             {"",S_FALSE},
5517             {"",S_FALSE}
5518         },
5519         {
5520             {Uri_HOST_UNKNOWN,S_OK},
5521             {0,S_FALSE},
5522             {URL_SCHEME_FILE,S_OK},
5523             {URLZONE_INVALID,E_NOTIMPL}
5524         }
5525     },
5526     {   "file:///c:/test/test",0,
5527         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5528         0,S_OK,FALSE,
5529         {
5530             {"file:///c:/testing.mp3",S_OK},
5531             {"",S_FALSE},
5532             {"file:///c:/testing.mp3",S_OK},
5533             {"",S_FALSE},
5534             {".mp3",S_OK},
5535             {"",S_FALSE},
5536             {"",S_FALSE},
5537             {"",S_FALSE},
5538             {"/c:/testing.mp3",S_OK},
5539             {"/c:/testing.mp3",S_OK},
5540             {"",S_FALSE},
5541             {"file:///c:/testing.mp3",S_OK},
5542             {"file",S_OK},
5543             {"",S_FALSE},
5544             {"",S_FALSE}
5545         },
5546         {
5547             {Uri_HOST_UNKNOWN,S_OK},
5548             {0,S_FALSE},
5549             {URL_SCHEME_FILE,S_OK},
5550             {URLZONE_INVALID,E_NOTIMPL}
5551         }
5552     },
5553     {   "file://test.com/test/test",0,
5554         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5555         URL_FILE_USE_PATHURL,S_OK,FALSE,
5556         {
5557             {"file://\\\\test.com\\testing.mp3",S_OK},
5558             {"test.com",S_OK},
5559             {"file://\\\\test.com\\testing.mp3",S_OK},
5560             {"test.com",S_OK},
5561             {".mp3",S_OK},
5562             {"",S_FALSE},
5563             {"test.com",S_OK},
5564             {"",S_FALSE},
5565             {"\\testing.mp3",S_OK},
5566             {"\\testing.mp3",S_OK},
5567             {"",S_FALSE},
5568             {"file://\\\\test.com\\testing.mp3",S_OK},
5569             {"file",S_OK},
5570             {"",S_FALSE},
5571             {"",S_FALSE}
5572         },
5573         {
5574             {Uri_HOST_DNS,S_OK},
5575             {0,S_FALSE},
5576             {URL_SCHEME_FILE,S_OK},
5577             {URLZONE_INVALID,E_NOTIMPL}
5578         }
5579     },
5580     /* URL_DONT_SIMPLIFY has no effect. */
5581     {   "http://google.com/test",0,
5582         "zip://test.com/cool/../cool/test",0,
5583         URL_DONT_SIMPLIFY,S_OK,FALSE,
5584         {
5585             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
5586             {"test.com",S_OK},
5587             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
5588             {"test.com",S_OK},
5589             {"",S_FALSE},
5590             {"",S_FALSE},
5591             {"test.com",S_OK},
5592             {"",S_FALSE},
5593             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
5594             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
5595             {"",S_FALSE},
5596             /* The resulting IUri has the same Raw URI as the relative URI (only IE 8).
5597              * On IE 7 it reduces the path in the Raw URI.
5598              */
5599             {"zip://test.com/cool/../cool/test",S_OK,FALSE,"zip://test.com/cool/test"},
5600             {"zip",S_OK},
5601             {"",S_FALSE},
5602             {"",S_FALSE}
5603         },
5604         {
5605             {Uri_HOST_DNS,S_OK},
5606             {0,S_FALSE},
5607             {URL_SCHEME_UNKNOWN,S_OK},
5608             {URLZONE_INVALID,E_NOTIMPL}
5609         }
5610     },
5611     /* FILE_USE_PATHURL has no effect in IE 8, in IE 7 the
5612      * resulting URI is converted into a dos path.
5613      */
5614     {   "http://google.com/test",0,
5615         "file:///c:/test/",0,
5616         URL_FILE_USE_PATHURL,S_OK,FALSE,
5617         {
5618             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
5619             {"",S_FALSE},
5620             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
5621             {"",S_FALSE},
5622             {"",S_FALSE},
5623             {"",S_FALSE},
5624             {"",S_FALSE},
5625             {"",S_FALSE},
5626             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
5627             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
5628             {"",S_FALSE},
5629             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
5630             {"file",S_OK},
5631             {"",S_FALSE},
5632             {"",S_FALSE}
5633         },
5634         {
5635             {Uri_HOST_UNKNOWN,S_OK},
5636             {0,S_FALSE},
5637             {URL_SCHEME_FILE,S_OK},
5638             {URLZONE_INVALID,E_NOTIMPL}
5639         }
5640     },
5641     {   "http://google.com/test",0,
5642         "http://test.com/test#%30test",0,
5643         URL_DONT_UNESCAPE_EXTRA_INFO,S_OK,FALSE,
5644         {
5645             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
5646             {"test.com",S_OK},
5647             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
5648             {"test.com",S_OK},
5649             {"",S_FALSE},
5650             {"#0test",S_OK,FALSE,NULL,"#%30test"},
5651             {"test.com",S_OK},
5652             {"",S_FALSE},
5653             {"/test",S_OK},
5654             {"/test",S_OK},
5655             {"",S_FALSE},
5656             /* IE 7 decodes the %30 to a 0 in the Raw URI. */
5657             {"http://test.com/test#%30test",S_OK,FALSE,"http://test.com/test#0test"},
5658             {"http",S_OK},
5659             {"",S_FALSE},
5660             {"",S_FALSE}
5661         },
5662         {
5663             {Uri_HOST_DNS,S_OK},
5664             {80,S_OK},
5665             {URL_SCHEME_HTTP,S_OK},
5666             {URLZONE_INVALID,E_NOTIMPL}
5667         }
5668     },
5669     /* Windows validates the path component from the relative Uri. */
5670     {   "http://google.com/test",0,
5671         "/Te%XXst",Uri_CREATE_ALLOW_RELATIVE,
5672         0,E_INVALIDARG,FALSE
5673     },
5674     /* Windows doesn't validate the query from the relative Uri. */
5675     {   "http://google.com/test",0,
5676         "?Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
5677         0,S_OK,FALSE,
5678         {
5679             {"http://google.com/test?Tes%XXt",S_OK},
5680             {"google.com",S_OK},
5681             {"http://google.com/test?Tes%XXt",S_OK},
5682             {"google.com",S_OK},
5683             {"",S_FALSE},
5684             {"",S_FALSE},
5685             {"google.com",S_OK},
5686             {"",S_FALSE},
5687             {"/test",S_OK},
5688             {"/test?Tes%XXt",S_OK},
5689             {"?Tes%XXt",S_OK},
5690             {"http://google.com/test?Tes%XXt",S_OK},
5691             {"http",S_OK},
5692             {"",S_FALSE},
5693             {"",S_FALSE}
5694         },
5695         {
5696             {Uri_HOST_DNS,S_OK},
5697             {80,S_OK},
5698             {URL_SCHEME_HTTP,S_OK},
5699             {URLZONE_INVALID,E_NOTIMPL}
5700         }
5701     },
5702     /* Windows doesn't validate the fragment from the relative Uri. */
5703     {   "http://google.com/test",0,
5704         "#Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
5705         0,S_OK,FALSE,
5706         {
5707             {"http://google.com/test#Tes%XXt",S_OK},
5708             {"google.com",S_OK},
5709             {"http://google.com/test#Tes%XXt",S_OK},
5710             {"google.com",S_OK},
5711             {"",S_FALSE},
5712             {"#Tes%XXt",S_OK},
5713             {"google.com",S_OK},
5714             {"",S_FALSE},
5715             {"/test",S_OK},
5716             {"/test",S_OK},
5717             {"",S_FALSE},
5718             {"http://google.com/test#Tes%XXt",S_OK},
5719             {"http",S_OK},
5720             {"",S_FALSE},
5721             {"",S_FALSE}
5722         },
5723         {
5724             {Uri_HOST_DNS,S_OK},
5725             {80,S_OK},
5726             {URL_SCHEME_HTTP,S_OK},
5727             {URLZONE_INVALID,E_NOTIMPL}
5728         }
5729     },
5730     /* Creates an IUri which contains an invalid dos path char. */
5731     {   "file:///c:/test",0,
5732         "/test<ing",Uri_CREATE_ALLOW_RELATIVE,
5733         URL_FILE_USE_PATHURL,S_OK,FALSE,
5734         {
5735             {"file://c:\\test<ing",S_OK},
5736             {"",S_FALSE},
5737             {"file://c:\\test<ing",S_OK},
5738             {"",S_FALSE},
5739             {"",S_FALSE},
5740             {"",S_FALSE},
5741             {"",S_FALSE},
5742             {"",S_FALSE},
5743             {"c:\\test<ing",S_OK},
5744             {"c:\\test<ing",S_OK},
5745             {"",S_FALSE},
5746             {"file://c:\\test<ing",S_OK},
5747             {"file",S_OK},
5748             {"",S_FALSE},
5749             {"",S_FALSE}
5750         },
5751         {
5752             {Uri_HOST_UNKNOWN,S_OK},
5753             {0,S_FALSE},
5754             {URL_SCHEME_FILE,S_OK},
5755             {URLZONE_INVALID,E_NOTIMPL}
5756         }
5757     },
5758     /* Appends the path after the drive letter (if any). */
5759     {   "file:///c:/test",0,
5760         "/c:/testing",Uri_CREATE_ALLOW_RELATIVE,
5761         0,S_OK,FALSE,
5762         {
5763             {"file:///c:/c:/testing",S_OK},
5764             {"",S_FALSE},
5765             {"file:///c:/c:/testing",S_OK},
5766             {"",S_FALSE},
5767             {"",S_FALSE},
5768             {"",S_FALSE},
5769             {"",S_FALSE},
5770             {"",S_FALSE},
5771             {"/c:/c:/testing",S_OK},
5772             {"/c:/c:/testing",S_OK},
5773             {"",S_FALSE},
5774             {"file:///c:/c:/testing",S_OK},
5775             {"file",S_OK},
5776             {"",S_FALSE},
5777             {"",S_FALSE}
5778         },
5779         {
5780             {Uri_HOST_UNKNOWN,S_OK},
5781             {0,S_FALSE},
5782             {URL_SCHEME_FILE,S_OK},
5783             {URLZONE_INVALID,E_NOTIMPL}
5784         }
5785     },
5786     /* A '/' is added if the base URI doesn't have a path and the
5787      * relative URI doesn't contain a path (since the base URI is
5788      * hierarchical.
5789      */
5790     {   "http://google.com",Uri_CREATE_NO_CANONICALIZE,
5791         "?test",Uri_CREATE_ALLOW_RELATIVE,
5792         0,S_OK,FALSE,
5793         {
5794             {"http://google.com/?test",S_OK},
5795             {"google.com",S_OK},
5796             {"http://google.com/?test",S_OK},
5797             {"google.com",S_OK},
5798             {"",S_FALSE},
5799             {"",S_FALSE},
5800             {"google.com",S_OK},
5801             {"",S_FALSE},
5802             {"/",S_OK},
5803             {"/?test",S_OK},
5804             {"?test",S_OK},
5805             {"http://google.com/?test",S_OK},
5806             {"http",S_OK},
5807             {"",S_FALSE},
5808             {"",S_FALSE}
5809         },
5810         {
5811             {Uri_HOST_DNS,S_OK},
5812             {80,S_OK},
5813             {URL_SCHEME_HTTP,S_OK},
5814             {URLZONE_INVALID,E_NOTIMPL}
5815         }
5816     },
5817     {   "zip://google.com",Uri_CREATE_NO_CANONICALIZE,
5818         "?test",Uri_CREATE_ALLOW_RELATIVE,
5819         0,S_OK,FALSE,
5820         {
5821             {"zip://google.com/?test",S_OK},
5822             {"google.com",S_OK},
5823             {"zip://google.com/?test",S_OK},
5824             {"google.com",S_OK},
5825             {"",S_FALSE},
5826             {"",S_FALSE},
5827             {"google.com",S_OK},
5828             {"",S_FALSE},
5829             {"/",S_OK},
5830             {"/?test",S_OK},
5831             {"?test",S_OK},
5832             {"zip://google.com/?test",S_OK},
5833             {"zip",S_OK},
5834             {"",S_FALSE},
5835             {"",S_FALSE}
5836         },
5837         {
5838             {Uri_HOST_DNS,S_OK},
5839             {0,S_FALSE},
5840             {URL_SCHEME_UNKNOWN,S_OK},
5841             {URLZONE_INVALID,E_NOTIMPL}
5842         }
5843     },
5844     /* No path is appended since the base URI is opaque. */
5845     {   "zip:?testing",0,
5846         "?test",Uri_CREATE_ALLOW_RELATIVE,
5847         0,S_OK,FALSE,
5848         {
5849             {"zip:?test",S_OK},
5850             {"",S_FALSE},
5851             {"zip:?test",S_OK},
5852             {"",S_FALSE},
5853             {"",S_FALSE},
5854             {"",S_FALSE},
5855             {"",S_FALSE},
5856             {"",S_FALSE},
5857             {"",S_OK},
5858             {"?test",S_OK},
5859             {"?test",S_OK},
5860             {"zip:?test",S_OK},
5861             {"zip",S_OK},
5862             {"",S_FALSE},
5863             {"",S_FALSE}
5864         },
5865         {
5866             {Uri_HOST_UNKNOWN,S_OK},
5867             {0,S_FALSE},
5868             {URL_SCHEME_UNKNOWN,S_OK},
5869             {URLZONE_INVALID,E_NOTIMPL}
5870         }
5871     },
5872     {   "file:///c:/",0,
5873         "../testing/test",Uri_CREATE_ALLOW_RELATIVE,
5874         0,S_OK,FALSE,
5875         {
5876             {"file:///c:/testing/test",S_OK},
5877             {"",S_FALSE},
5878             {"file:///c:/testing/test",S_OK},
5879             {"",S_FALSE},
5880             {"",S_FALSE},
5881             {"",S_FALSE},
5882             {"",S_FALSE},
5883             {"",S_FALSE},
5884             {"/c:/testing/test",S_OK},
5885             {"/c:/testing/test",S_OK},
5886             {"",S_FALSE},
5887             {"file:///c:/testing/test",S_OK},
5888             {"file",S_OK},
5889             {"",S_FALSE},
5890             {"",S_FALSE}
5891         },
5892         {
5893             {Uri_HOST_UNKNOWN,S_OK},
5894             {0,S_FALSE},
5895             {URL_SCHEME_FILE,S_OK},
5896             {URLZONE_INVALID,E_NOTIMPL}
5897         }
5898     }
5899 };
5900
5901 typedef struct _uri_parse_test {
5902     const char  *uri;
5903     DWORD       uri_flags;
5904     PARSEACTION action;
5905     DWORD       flags;
5906     const char  *property;
5907     HRESULT     expected;
5908     BOOL        todo;
5909 } uri_parse_test;
5910
5911 static const uri_parse_test uri_parse_tests[] = {
5912     /* PARSE_CANONICALIZE tests. */
5913     {"zip://google.com/test<|>",0,PARSE_CANONICALIZE,0,"zip://google.com/test<|>",S_OK,FALSE},
5914     {"http://google.com/test<|>",0,PARSE_CANONICALIZE,0,"http://google.com/test%3C%7C%3E",S_OK,FALSE},
5915     {"http://google.com/%30%23%3F",0,PARSE_CANONICALIZE,URL_UNESCAPE,"http://google.com/0#?",S_OK,FALSE},
5916     {"test <|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_ESCAPE_UNSAFE,"test %3C%7C%3E",S_OK,FALSE},
5917     {"test <|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_ESCAPE_SPACES_ONLY,"test%20<|>",S_OK,FALSE},
5918     {"test%20<|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_UNESCAPE|URL_ESCAPE_UNSAFE,"test%20%3C%7C%3E",S_OK,FALSE},
5919     {"http://google.com/%20",0,PARSE_CANONICALIZE,URL_ESCAPE_PERCENT,"http://google.com/%2520",S_OK,FALSE},
5920     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_DONT_SIMPLIFY,"http://google.com/test/../",S_OK,FALSE},
5921     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_NO_META,"http://google.com/test/../",S_OK,FALSE},
5922     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,0,"http://google.com/",S_OK,FALSE},
5923     {"zip://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,0,"zip://google.com/",S_OK,FALSE},
5924     {"file:///c:/test/../test",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_DONT_SIMPLIFY,"file:///c:/test/../test",S_OK,FALSE},
5925
5926     /* PARSE_FRIENDLY tests. */
5927     {"http://test@google.com/test#test",0,PARSE_FRIENDLY,0,"http://google.com/test#test",S_OK,FALSE},
5928     {"zip://test@google.com/test",0,PARSE_FRIENDLY,0,"zip://test@google.com/test",S_OK,FALSE},
5929
5930     /* PARSE_ROOTDOCUMENT tests. */
5931     {"http://google.com:200/test/test",0,PARSE_ROOTDOCUMENT,0,"http://google.com:200/",S_OK,FALSE},
5932     {"http://google.com",Uri_CREATE_NO_CANONICALIZE,PARSE_ROOTDOCUMENT,0,"http://google.com/",S_OK,FALSE},
5933     {"zip://google.com/",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
5934     {"file:///c:/testing/",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
5935     {"file://server/test",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
5936     {"zip:test/test",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
5937
5938     /* PARSE_DOCUMENT tests. */
5939     {"http://test@google.com/test?query#frag",0,PARSE_DOCUMENT,0,"http://test@google.com/test?query",S_OK,FALSE},
5940     {"http:testing#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
5941     {"file:///c:/test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
5942     {"zip://google.com/#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
5943     {"zip:test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
5944     {"testing#frag",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOCUMENT,0,"",S_OK,FALSE}
5945 };
5946
5947 static inline LPWSTR a2w(LPCSTR str) {
5948     LPWSTR ret = NULL;
5949
5950     if(str) {
5951         DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
5952         ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
5953         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
5954     }
5955
5956     return ret;
5957 }
5958
5959 static inline BOOL heap_free(void* mem) {
5960     return HeapFree(GetProcessHeap(), 0, mem);
5961 }
5962
5963 static inline DWORD strcmp_aw(LPCSTR strA, LPCWSTR strB) {
5964     LPWSTR strAW = a2w(strA);
5965     DWORD ret = lstrcmpW(strAW, strB);
5966     heap_free(strAW);
5967     return ret;
5968 }
5969
5970 static inline ULONG get_refcnt(IUri *uri) {
5971     IUri_AddRef(uri);
5972     return IUri_Release(uri);
5973 }
5974
5975 static void change_property(IUriBuilder *builder, const uri_builder_property *prop,
5976                             DWORD test_index) {
5977     HRESULT hr;
5978     LPWSTR valueW;
5979
5980     valueW = a2w(prop->value);
5981     switch(prop->property) {
5982     case Uri_PROPERTY_FRAGMENT:
5983         hr = IUriBuilder_SetFragment(builder, valueW);
5984         if(prop->todo) {
5985             todo_wine {
5986                 ok(hr == prop->expected,
5987                     "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
5988                     hr, prop->expected, test_index);
5989             }
5990         } else {
5991             ok(hr == prop->expected,
5992                 "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
5993                 hr, prop->expected, test_index);
5994         }
5995         break;
5996     case Uri_PROPERTY_HOST:
5997         hr = IUriBuilder_SetHost(builder, valueW);
5998         if(prop->todo) {
5999             todo_wine {
6000                 ok(hr == prop->expected,
6001                     "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6002                     hr, prop->expected, test_index);
6003             }
6004         } else {
6005             ok(hr == prop->expected,
6006                 "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6007                 hr, prop->expected, test_index);
6008         }
6009         break;
6010     case Uri_PROPERTY_PASSWORD:
6011         hr = IUriBuilder_SetPassword(builder, valueW);
6012         if(prop->todo) {
6013             todo_wine {
6014                 ok(hr == prop->expected,
6015                     "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6016                     hr, prop->expected, test_index);
6017             }
6018         } else {
6019             ok(hr == prop->expected,
6020                 "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6021                 hr, prop->expected, test_index);
6022         }
6023         break;
6024     case Uri_PROPERTY_PATH:
6025         hr = IUriBuilder_SetPath(builder, valueW);
6026         if(prop->todo) {
6027             todo_wine {
6028                 ok(hr == prop->expected,
6029                     "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6030                     hr, prop->expected, test_index);
6031             }
6032         } else {
6033             ok(hr == prop->expected,
6034                 "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6035                 hr, prop->expected, test_index);
6036         }
6037         break;
6038     case Uri_PROPERTY_QUERY:
6039         hr = IUriBuilder_SetQuery(builder, valueW);
6040         if(prop->todo) {
6041             todo_wine {
6042                 ok(hr == prop->expected,
6043                     "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6044                     hr, prop->expected, test_index);
6045             }
6046         } else {
6047             ok(hr == prop->expected,
6048                 "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6049                 hr, prop->expected, test_index);
6050         }
6051         break;
6052     case Uri_PROPERTY_SCHEME_NAME:
6053         hr = IUriBuilder_SetSchemeName(builder, valueW);
6054         if(prop->todo) {
6055             todo_wine {
6056                 ok(hr == prop->expected,
6057                     "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6058                     hr, prop->expected, test_index);
6059             }
6060         } else {
6061             ok(hr == prop->expected,
6062                 "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6063                 hr, prop->expected, test_index);
6064         }
6065         break;
6066     case Uri_PROPERTY_USER_NAME:
6067         hr = IUriBuilder_SetUserName(builder, valueW);
6068         if(prop->todo) {
6069             todo_wine {
6070                 ok(hr == prop->expected,
6071                     "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6072                     hr, prop->expected, test_index);
6073             }
6074         } else {
6075             ok(hr == prop->expected,
6076                 "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6077                 hr, prop->expected, test_index);
6078         }
6079         break;
6080     default:
6081         trace("Unsupported operation for %d on uri_builder_tests[%d].\n", prop->property, test_index);
6082     }
6083
6084     heap_free(valueW);
6085 }
6086
6087 /*
6088  * Simple tests to make sure the CreateUri function handles invalid flag combinations
6089  * correctly.
6090  */
6091 static void test_CreateUri_InvalidFlags(void) {
6092     DWORD i;
6093
6094     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
6095         HRESULT hr;
6096         IUri *uri = (void*) 0xdeadbeef;
6097
6098         hr = pCreateUri(http_urlW, invalid_flag_tests[i].flags, 0, &uri);
6099         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUri returned 0x%08x, expected 0x%08x, flags=0x%08x\n",
6100                 hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
6101         ok(uri == NULL, "Error: expected the IUri to be NULL, but it was %p instead\n", uri);
6102     }
6103 }
6104
6105 static void test_CreateUri_InvalidArgs(void) {
6106     HRESULT hr;
6107     IUri *uri = (void*) 0xdeadbeef;
6108
6109     const WCHAR invalidW[] = {'i','n','v','a','l','i','d',0};
6110     static const WCHAR emptyW[] = {0};
6111
6112     hr = pCreateUri(http_urlW, 0, 0, NULL);
6113     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6114
6115     hr = pCreateUri(NULL, 0, 0, &uri);
6116     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6117     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6118
6119     uri = (void*) 0xdeadbeef;
6120     hr = pCreateUri(invalidW, 0, 0, &uri);
6121     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6122     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6123
6124     uri = (void*) 0xdeadbeef;
6125     hr = pCreateUri(emptyW, 0, 0, &uri);
6126     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6127     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6128 }
6129
6130 static void test_CreateUri_InvalidUri(void) {
6131     DWORD i;
6132
6133     for(i = 0; i < sizeof(invalid_uri_tests)/sizeof(invalid_uri_tests[0]); ++i) {
6134         invalid_uri test = invalid_uri_tests[i];
6135         IUri *uri = NULL;
6136         LPWSTR uriW;
6137         HRESULT hr;
6138
6139         uriW = a2w(test.uri);
6140         hr = pCreateUri(uriW, test.flags, 0, &uri);
6141         if(test.todo) {
6142             todo_wine {
6143                 ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6144                     hr, E_INVALIDARG, i);
6145             }
6146         } else {
6147             ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6148                 hr, E_INVALIDARG, i);
6149         }
6150         if(uri) IUri_Release(uri);
6151
6152         heap_free(uriW);
6153     }
6154 }
6155
6156 static void test_IUri_GetPropertyBSTR(void) {
6157     IUri *uri = NULL;
6158     HRESULT hr;
6159     DWORD i;
6160
6161     /* Make sure GetPropertyBSTR handles invalid args correctly. */
6162     hr = pCreateUri(http_urlW, 0, 0, &uri);
6163     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6164     if(SUCCEEDED(hr)) {
6165         BSTR received = NULL;
6166
6167         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_RAW_URI, NULL, 0);
6168         ok(hr == E_POINTER, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6169
6170         /* Make sure it handles a invalid Uri_PROPERTY's correctly. */
6171         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_PORT, &received, 0);
6172         ok(hr == S_OK, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6173         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6174         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6175         SysFreeString(received);
6176
6177         /* Make sure it handles the ZONE property correctly. */
6178         received = NULL;
6179         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_ZONE, &received, 0);
6180         ok(hr == S_FALSE, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_FALSE);
6181         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6182         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6183         SysFreeString(received);
6184     }
6185     if(uri) IUri_Release(uri);
6186
6187     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6188         uri_properties test = uri_tests[i];
6189         LPWSTR uriW;
6190         uri = NULL;
6191
6192         uriW = a2w(test.uri);
6193         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6194         if(test.create_todo) {
6195             todo_wine {
6196                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6197                         hr, test.create_expected, i);
6198             }
6199         } else {
6200             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6201                     hr, test.create_expected, i);
6202         }
6203
6204         if(SUCCEEDED(hr)) {
6205             DWORD j;
6206
6207             /* Checks all the string properties of the uri. */
6208             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
6209                 BSTR received = NULL;
6210                 uri_str_property prop = test.str_props[j];
6211
6212                 hr = IUri_GetPropertyBSTR(uri, j, &received, 0);
6213                 if(prop.todo) {
6214                     todo_wine {
6215                         ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6216                                 hr, prop.expected, i, j);
6217                     }
6218                     todo_wine {
6219                         ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6220                                 "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6221                                 prop.value, wine_dbgstr_w(received), i, j);
6222                     }
6223                 } else {
6224                     ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6225                             hr, prop.expected, i, j);
6226                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6227                             "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6228                             prop.value, wine_dbgstr_w(received), i, j);
6229                 }
6230
6231                 SysFreeString(received);
6232             }
6233         }
6234
6235         if(uri) IUri_Release(uri);
6236
6237         heap_free(uriW);
6238     }
6239 }
6240
6241 static void test_IUri_GetPropertyDWORD(void) {
6242     IUri *uri = NULL;
6243     HRESULT hr;
6244     DWORD i;
6245
6246     hr = pCreateUri(http_urlW, 0, 0, &uri);
6247     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6248     if(SUCCEEDED(hr)) {
6249         DWORD received = 0xdeadbeef;
6250
6251         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_DWORD_START, NULL, 0);
6252         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6253
6254         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_ABSOLUTE_URI, &received, 0);
6255         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6256         ok(received == 0, "Error: Expected received=%d but instead received=%d.\n", 0, received);
6257     }
6258     if(uri) IUri_Release(uri);
6259
6260     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6261         uri_properties test = uri_tests[i];
6262         LPWSTR uriW;
6263         uri = NULL;
6264
6265         uriW = a2w(test.uri);
6266         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6267         if(test.create_todo) {
6268             todo_wine {
6269                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6270                         hr, test.create_expected, i);
6271             }
6272         } else {
6273             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6274                     hr, test.create_expected, i);
6275         }
6276
6277         if(SUCCEEDED(hr)) {
6278             DWORD j;
6279
6280             /* Checks all the DWORD properties of the uri. */
6281             for(j = 0; j < sizeof(test.dword_props)/sizeof(test.dword_props[0]); ++j) {
6282                 DWORD received;
6283                 uri_dword_property prop = test.dword_props[j];
6284
6285                 hr = IUri_GetPropertyDWORD(uri, j+Uri_PROPERTY_DWORD_START, &received, 0);
6286                 if(prop.todo) {
6287                     todo_wine {
6288                         ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
6289                                 hr, prop.expected, i, j);
6290                     }
6291                     todo_wine {
6292                         ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
6293                                 prop.value, received, i, j);
6294                     }
6295                 } else {
6296                     ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
6297                             hr, prop.expected, i, j);
6298                     ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
6299                             prop.value, received, i, j);
6300                 }
6301             }
6302         }
6303
6304         if(uri) IUri_Release(uri);
6305
6306         heap_free(uriW);
6307     }
6308 }
6309
6310 /* Tests all the 'Get*' property functions which deal with strings. */
6311 static void test_IUri_GetStrProperties(void) {
6312     IUri *uri = NULL;
6313     HRESULT hr;
6314     DWORD i;
6315
6316     /* Make sure all the 'Get*' string property functions handle invalid args correctly. */
6317     hr = pCreateUri(http_urlW, 0, 0, &uri);
6318     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6319     if(SUCCEEDED(hr)) {
6320         hr = IUri_GetAbsoluteUri(uri, NULL);
6321         ok(hr == E_POINTER, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6322
6323         hr = IUri_GetAuthority(uri, NULL);
6324         ok(hr == E_POINTER, "Error: GetAuthority returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6325
6326         hr = IUri_GetDisplayUri(uri, NULL);
6327         ok(hr == E_POINTER, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6328
6329         hr = IUri_GetDomain(uri, NULL);
6330         ok(hr == E_POINTER, "Error: GetDomain returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6331
6332         hr = IUri_GetExtension(uri, NULL);
6333         ok(hr == E_POINTER, "Error: GetExtension returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6334
6335         hr = IUri_GetFragment(uri, NULL);
6336         ok(hr == E_POINTER, "Error: GetFragment returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6337
6338         hr = IUri_GetHost(uri, NULL);
6339         ok(hr == E_POINTER, "Error: GetHost returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6340
6341         hr = IUri_GetPassword(uri, NULL);
6342         ok(hr == E_POINTER, "Error: GetPassword returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6343
6344         hr = IUri_GetPath(uri, NULL);
6345         ok(hr == E_POINTER, "Error: GetPath returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6346
6347         hr = IUri_GetPathAndQuery(uri, NULL);
6348         ok(hr == E_POINTER, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6349
6350         hr = IUri_GetQuery(uri, NULL);
6351         ok(hr == E_POINTER, "Error: GetQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6352
6353         hr = IUri_GetRawUri(uri, NULL);
6354         ok(hr == E_POINTER, "Error: GetRawUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6355
6356         hr = IUri_GetSchemeName(uri, NULL);
6357         ok(hr == E_POINTER, "Error: GetSchemeName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6358
6359         hr = IUri_GetUserInfo(uri, NULL);
6360         ok(hr == E_POINTER, "Error: GetUserInfo returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6361
6362         hr = IUri_GetUserName(uri, NULL);
6363         ok(hr == E_POINTER, "Error: GetUserName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6364     }
6365     if(uri) IUri_Release(uri);
6366
6367     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6368         uri_properties test = uri_tests[i];
6369         LPWSTR uriW;
6370         uri = NULL;
6371
6372         uriW = a2w(test.uri);
6373         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6374         if(test.create_todo) {
6375             todo_wine {
6376                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6377                         hr, test.create_expected, i);
6378             }
6379         } else {
6380             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6381                     hr, test.create_expected, i);
6382         }
6383
6384         if(SUCCEEDED(hr)) {
6385             uri_str_property prop;
6386             BSTR received = NULL;
6387
6388             /* GetAbsoluteUri() tests. */
6389             prop = test.str_props[Uri_PROPERTY_ABSOLUTE_URI];
6390             hr = IUri_GetAbsoluteUri(uri, &received);
6391             if(prop.todo) {
6392                 todo_wine {
6393                     ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6394                             hr, prop.expected, i);
6395                 }
6396                 todo_wine {
6397                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6398                             "Error: Expected %s but got %s on uri_tests[%d].\n",
6399                             prop.value, wine_dbgstr_w(received), i);
6400                 }
6401             } else {
6402                 ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6403                         hr, prop.expected, i);
6404                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6405                         "Error: Expected %s but got %s on uri_tests[%d].\n",
6406                         prop.value, wine_dbgstr_w(received), i);
6407             }
6408             SysFreeString(received);
6409             received = NULL;
6410
6411             /* GetAuthority() tests. */
6412             prop = test.str_props[Uri_PROPERTY_AUTHORITY];
6413             hr = IUri_GetAuthority(uri, &received);
6414             if(prop.todo) {
6415                 todo_wine {
6416                     ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6417                             hr, prop.expected, i);
6418                 }
6419                 todo_wine {
6420                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6421                             prop.value, wine_dbgstr_w(received), i);
6422                 }
6423             } else {
6424                 ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6425                         hr, prop.expected, i);
6426                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6427                         prop.value, wine_dbgstr_w(received), i);
6428             }
6429             SysFreeString(received);
6430             received = NULL;
6431
6432             /* GetDisplayUri() tests. */
6433             prop = test.str_props[Uri_PROPERTY_DISPLAY_URI];
6434             hr = IUri_GetDisplayUri(uri, &received);
6435             if(prop.todo) {
6436                 todo_wine {
6437                     ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6438                             hr, prop.expected, i);
6439                 }
6440                 todo_wine {
6441                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6442                             "Error: Expected %s but got %s on uri_test[%d].\n",
6443                             prop.value, wine_dbgstr_w(received), i);
6444                 }
6445             } else {
6446                 ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6447                         hr, prop.expected, i);
6448                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6449                         "Error: Expected %s but got %s on uri_tests[%d].\n",
6450                         prop.value, wine_dbgstr_w(received), i);
6451             }
6452             SysFreeString(received);
6453             received = NULL;
6454
6455             /* GetDomain() tests. */
6456             prop = test.str_props[Uri_PROPERTY_DOMAIN];
6457             hr = IUri_GetDomain(uri, &received);
6458             if(prop.todo) {
6459                 todo_wine {
6460                     ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6461                             hr, prop.expected, i);
6462                 }
6463                 todo_wine {
6464                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6465                             prop.value, wine_dbgstr_w(received), i);
6466                 }
6467             } else {
6468                 ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6469                         hr, prop.expected, i);
6470                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6471                         prop.value, wine_dbgstr_w(received), i);
6472             }
6473             SysFreeString(received);
6474             received = NULL;
6475
6476             /* GetExtension() tests. */
6477             prop = test.str_props[Uri_PROPERTY_EXTENSION];
6478             hr = IUri_GetExtension(uri, &received);
6479             if(prop.todo) {
6480                 todo_wine {
6481                     ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6482                             hr, prop.expected, i);
6483                 }
6484                 todo_wine {
6485                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6486                             prop.value, wine_dbgstr_w(received), i);
6487                 }
6488             } else {
6489                 ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6490                         hr, prop.expected, i);
6491                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6492                         prop.value, wine_dbgstr_w(received), i);
6493             }
6494             SysFreeString(received);
6495             received = NULL;
6496
6497             /* GetFragment() tests. */
6498             prop = test.str_props[Uri_PROPERTY_FRAGMENT];
6499             hr = IUri_GetFragment(uri, &received);
6500             if(prop.todo) {
6501                 todo_wine {
6502                     ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6503                             hr, prop.expected, i);
6504                 }
6505                 todo_wine {
6506                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6507                             prop.value, wine_dbgstr_w(received), i);
6508                 }
6509             } else {
6510                 ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6511                         hr, prop.expected, i);
6512                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6513                         prop.value, wine_dbgstr_w(received), i);
6514             }
6515             SysFreeString(received);
6516             received = NULL;
6517
6518             /* GetHost() tests. */
6519             prop = test.str_props[Uri_PROPERTY_HOST];
6520             hr = IUri_GetHost(uri, &received);
6521             if(prop.todo) {
6522                 todo_wine {
6523                     ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6524                             hr, prop.expected, i);
6525                 }
6526                 todo_wine {
6527                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6528                             prop.value, wine_dbgstr_w(received), i);
6529                 }
6530             } else {
6531                 ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6532                         hr, prop.expected, i);
6533                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6534                         prop.value, wine_dbgstr_w(received), i);
6535             }
6536             SysFreeString(received);
6537             received = NULL;
6538
6539             /* GetPassword() tests. */
6540             prop = test.str_props[Uri_PROPERTY_PASSWORD];
6541             hr = IUri_GetPassword(uri, &received);
6542             if(prop.todo) {
6543                 todo_wine {
6544                     ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6545                             hr, prop.expected, i);
6546                 }
6547                 todo_wine {
6548                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6549                             prop.value, wine_dbgstr_w(received), i);
6550                 }
6551             } else {
6552                 ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6553                         hr, prop.expected, i);
6554                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6555                         prop.value, wine_dbgstr_w(received), i);
6556             }
6557             SysFreeString(received);
6558             received = NULL;
6559
6560             /* GetPath() tests. */
6561             prop = test.str_props[Uri_PROPERTY_PATH];
6562             hr = IUri_GetPath(uri, &received);
6563             if(prop.todo) {
6564                 todo_wine {
6565                     ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6566                             hr, prop.expected, i);
6567                 }
6568                 todo_wine {
6569                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6570                             prop.value, wine_dbgstr_w(received), i);
6571                 }
6572             } else {
6573                 ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6574                         hr, prop.expected, i);
6575                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6576                         prop.value, wine_dbgstr_w(received), i);
6577             }
6578             SysFreeString(received);
6579             received = NULL;
6580
6581             /* GetPathAndQuery() tests. */
6582             prop = test.str_props[Uri_PROPERTY_PATH_AND_QUERY];
6583             hr = IUri_GetPathAndQuery(uri, &received);
6584             if(prop.todo) {
6585                 todo_wine {
6586                     ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6587                             hr, prop.expected, i);
6588                 }
6589                 todo_wine {
6590                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6591                             prop.value, wine_dbgstr_w(received), i);
6592                 }
6593             } else {
6594                 ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6595                         hr, prop.expected, i);
6596                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6597                         prop.value, wine_dbgstr_w(received), i);
6598             }
6599             SysFreeString(received);
6600             received = NULL;
6601
6602             /* GetQuery() tests. */
6603             prop = test.str_props[Uri_PROPERTY_QUERY];
6604             hr = IUri_GetQuery(uri, &received);
6605             if(prop.todo) {
6606                 todo_wine {
6607                     ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6608                             hr, prop.expected, i);
6609                 }
6610                 todo_wine {
6611                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6612                             prop.value, wine_dbgstr_w(received), i);
6613                 }
6614             } else {
6615                 ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6616                         hr, prop.expected, i);
6617                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6618                         prop.value, wine_dbgstr_w(received), i);
6619             }
6620             SysFreeString(received);
6621             received = NULL;
6622
6623             /* GetRawUri() tests. */
6624             prop = test.str_props[Uri_PROPERTY_RAW_URI];
6625             hr = IUri_GetRawUri(uri, &received);
6626             if(prop.todo) {
6627                 todo_wine {
6628                     ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6629                             hr, prop.expected, i);
6630                 }
6631                 todo_wine {
6632                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6633                             prop.value, wine_dbgstr_w(received), i);
6634                 }
6635             } else {
6636                 ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6637                         hr, prop.expected, i);
6638                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6639                         prop.value, wine_dbgstr_w(received), i);
6640             }
6641             SysFreeString(received);
6642             received = NULL;
6643
6644             /* GetSchemeName() tests. */
6645             prop = test.str_props[Uri_PROPERTY_SCHEME_NAME];
6646             hr = IUri_GetSchemeName(uri, &received);
6647             if(prop.todo) {
6648                 todo_wine {
6649                     ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6650                             hr, prop.expected, i);
6651                 }
6652                 todo_wine {
6653                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6654                             prop.value, wine_dbgstr_w(received), i);
6655                 }
6656             } else {
6657                 ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6658                         hr, prop.expected, i);
6659                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6660                         prop.value, wine_dbgstr_w(received), i);
6661             }
6662             SysFreeString(received);
6663             received = NULL;
6664
6665             /* GetUserInfo() tests. */
6666             prop = test.str_props[Uri_PROPERTY_USER_INFO];
6667             hr = IUri_GetUserInfo(uri, &received);
6668             if(prop.todo) {
6669                 todo_wine {
6670                     ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6671                             hr, prop.expected, i);
6672                 }
6673                 todo_wine {
6674                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6675                             prop.value, wine_dbgstr_w(received), i);
6676                 }
6677             } else {
6678                 ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6679                         hr, prop.expected, i);
6680                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6681                         prop.value, wine_dbgstr_w(received), i);
6682             }
6683             SysFreeString(received);
6684             received = NULL;
6685
6686             /* GetUserName() tests. */
6687             prop = test.str_props[Uri_PROPERTY_USER_NAME];
6688             hr = IUri_GetUserName(uri, &received);
6689             if(prop.todo) {
6690                 todo_wine {
6691                     ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6692                             hr, prop.expected, i);
6693                 }
6694                 todo_wine {
6695                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6696                             prop.value, wine_dbgstr_w(received), i);
6697                 }
6698             } else {
6699                 ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6700                         hr, prop.expected, i);
6701                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6702                         prop.value, wine_dbgstr_w(received), i);
6703             }
6704             SysFreeString(received);
6705         }
6706
6707         if(uri) IUri_Release(uri);
6708
6709         heap_free(uriW);
6710     }
6711 }
6712
6713 static void test_IUri_GetDwordProperties(void) {
6714     IUri *uri = NULL;
6715     HRESULT hr;
6716     DWORD i;
6717
6718     /* Make sure all the 'Get*' dword property functions handle invalid args correctly. */
6719     hr = pCreateUri(http_urlW, 0, 0, &uri);
6720     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6721     if(SUCCEEDED(hr)) {
6722         hr = IUri_GetHostType(uri, NULL);
6723         ok(hr == E_INVALIDARG, "Error: GetHostType returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6724
6725         hr = IUri_GetPort(uri, NULL);
6726         ok(hr == E_INVALIDARG, "Error: GetPort returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6727
6728         hr = IUri_GetScheme(uri, NULL);
6729         ok(hr == E_INVALIDARG, "Error: GetScheme returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6730
6731         hr = IUri_GetZone(uri, NULL);
6732         ok(hr == E_INVALIDARG, "Error: GetZone returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6733     }
6734     if(uri) IUri_Release(uri);
6735
6736     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6737         uri_properties test = uri_tests[i];
6738         LPWSTR uriW;
6739         uri = NULL;
6740
6741         uriW = a2w(test.uri);
6742         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6743         if(test.create_todo) {
6744             todo_wine {
6745                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6746                         hr, test.create_expected, i);
6747             }
6748         } else {
6749             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6750                     hr, test.create_expected, i);
6751         }
6752
6753         if(SUCCEEDED(hr)) {
6754             uri_dword_property prop;
6755             DWORD received;
6756
6757             /* Assign an insane value so tests don't accidentally pass when
6758              * they shouldn't!
6759              */
6760             received = -9999999;
6761
6762             /* GetHostType() tests. */
6763             prop = test.dword_props[Uri_PROPERTY_HOST_TYPE-Uri_PROPERTY_DWORD_START];
6764             hr = IUri_GetHostType(uri, &received);
6765             if(prop.todo) {
6766                 todo_wine {
6767                     ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6768                             hr, prop.expected, i);
6769                 }
6770                 todo_wine {
6771                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6772                 }
6773             } else {
6774                 ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6775                         hr, prop.expected, i);
6776                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6777             }
6778             received = -9999999;
6779
6780             /* GetPort() tests. */
6781             prop = test.dword_props[Uri_PROPERTY_PORT-Uri_PROPERTY_DWORD_START];
6782             hr = IUri_GetPort(uri, &received);
6783             if(prop.todo) {
6784                 todo_wine {
6785                     ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6786                             hr, prop.expected, i);
6787                 }
6788                 todo_wine {
6789                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6790                 }
6791             } else {
6792                 ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6793                         hr, prop.expected, i);
6794                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6795             }
6796             received = -9999999;
6797
6798             /* GetScheme() tests. */
6799             prop = test.dword_props[Uri_PROPERTY_SCHEME-Uri_PROPERTY_DWORD_START];
6800             hr = IUri_GetScheme(uri, &received);
6801             if(prop.todo) {
6802                 todo_wine {
6803                     ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6804                             hr, prop.expected, i);
6805                 }
6806                 todo_wine {
6807                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6808                 }
6809             } else {
6810                 ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6811                         hr, prop.expected, i);
6812                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6813             }
6814             received = -9999999;
6815
6816             /* GetZone() tests. */
6817             prop = test.dword_props[Uri_PROPERTY_ZONE-Uri_PROPERTY_DWORD_START];
6818             hr = IUri_GetZone(uri, &received);
6819             if(prop.todo) {
6820                 todo_wine {
6821                     ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6822                             hr, prop.expected, i);
6823                 }
6824                 todo_wine {
6825                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6826                 }
6827             } else {
6828                 ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6829                         hr, prop.expected, i);
6830                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6831             }
6832         }
6833
6834         if(uri) IUri_Release(uri);
6835
6836         heap_free(uriW);
6837     }
6838 }
6839
6840 static void test_IUri_GetPropertyLength(void) {
6841     IUri *uri = NULL;
6842     HRESULT hr;
6843     DWORD i;
6844
6845     /* Make sure it handles invalid args correctly. */
6846     hr = pCreateUri(http_urlW, 0, 0, &uri);
6847     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6848     if(SUCCEEDED(hr)) {
6849         DWORD received = 0xdeadbeef;
6850
6851         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_STRING_START, NULL, 0);
6852         ok(hr == E_INVALIDARG, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6853
6854         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_DWORD_START, &received, 0);
6855         ok(hr == E_INVALIDARG, "Error: GetPropertyLength return 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6856         ok(received == 0xdeadbeef, "Error: Expected 0xdeadbeef but got 0x%08x.\n", received);
6857     }
6858     if(uri) IUri_Release(uri);
6859
6860     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6861         uri_properties test = uri_tests[i];
6862         LPWSTR uriW;
6863         uri = NULL;
6864
6865         uriW = a2w(test.uri);
6866         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6867         if(test.create_todo) {
6868             todo_wine {
6869                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6870                         hr, test.create_expected, i);
6871             }
6872         } else {
6873             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_test[%d].\n",
6874                     hr, test.create_expected, i);
6875         }
6876
6877         if(SUCCEEDED(hr)) {
6878             DWORD j;
6879
6880             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
6881                 DWORD expectedLen, brokenLen, receivedLen;
6882                 uri_str_property prop = test.str_props[j];
6883
6884                 expectedLen = lstrlen(prop.value);
6885                 brokenLen = lstrlen(prop.broken_value);
6886
6887                 /* This won't be necessary once GetPropertyLength is implemented. */
6888                 receivedLen = -1;
6889
6890                 hr = IUri_GetPropertyLength(uri, j, &receivedLen, 0);
6891                 if(prop.todo) {
6892                     todo_wine {
6893                         ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
6894                                 hr, prop.expected, i, j);
6895                     }
6896                     todo_wine {
6897                         ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
6898                                 "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
6899                                 expectedLen, receivedLen, i, j);
6900                     }
6901                 } else {
6902                     ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
6903                             hr, prop.expected, i, j);
6904                     ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
6905                             "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
6906                             expectedLen, receivedLen, i, j);
6907                 }
6908             }
6909         }
6910
6911         if(uri) IUri_Release(uri);
6912
6913         heap_free(uriW);
6914     }
6915 }
6916
6917 static DWORD compute_expected_props(uri_properties *test)
6918 {
6919     DWORD ret = 0, i;
6920
6921     for(i=Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_STRING_LAST; i++) {
6922         if(test->str_props[i-Uri_PROPERTY_STRING_START].expected == S_OK)
6923             ret |= 1<<i;
6924     }
6925
6926     for(i=Uri_PROPERTY_DWORD_START; i <= Uri_PROPERTY_DWORD_LAST; i++) {
6927         if(test->dword_props[i-Uri_PROPERTY_DWORD_START].expected == S_OK)
6928             ret |= 1<<i;
6929     }
6930
6931     return ret;
6932 }
6933
6934 static void test_IUri_GetProperties(void) {
6935     IUri *uri = NULL;
6936     HRESULT hr;
6937     DWORD i;
6938
6939     hr = pCreateUri(http_urlW, 0, 0, &uri);
6940     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6941     if(SUCCEEDED(hr)) {
6942         hr = IUri_GetProperties(uri, NULL);
6943         ok(hr == E_INVALIDARG, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6944     }
6945     if(uri) IUri_Release(uri);
6946
6947     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6948         uri_properties test = uri_tests[i];
6949         LPWSTR uriW;
6950         uri = NULL;
6951
6952         uriW = a2w(test.uri);
6953         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6954         if(test.create_todo) {
6955             todo_wine {
6956                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
6957             }
6958         } else {
6959             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
6960         }
6961
6962         if(SUCCEEDED(hr)) {
6963             DWORD received = 0, expected_props;
6964             DWORD j;
6965
6966             hr = IUri_GetProperties(uri, &received);
6967             ok(hr == S_OK, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6968
6969             expected_props = compute_expected_props(&test);
6970
6971             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
6972                 /* (1 << j) converts a Uri_PROPERTY to its corresponding Uri_HAS_* flag mask. */
6973                 if(expected_props & (1 << j))
6974                     ok(received & (1 << j), "Error: Expected flag for property %d on uri_tests[%d].\n", j, i);
6975                 else
6976                     ok(!(received & (1 << j)), "Error: Received flag for property %d when not expected on uri_tests[%d].\n", j, i);
6977             }
6978         }
6979
6980         if(uri) IUri_Release(uri);
6981
6982         heap_free(uriW);
6983     }
6984 }
6985
6986 static void test_IUri_HasProperty(void) {
6987     IUri *uri = NULL;
6988     HRESULT hr;
6989     DWORD i;
6990
6991     hr = pCreateUri(http_urlW, 0, 0, &uri);
6992     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6993     if(SUCCEEDED(hr)) {
6994         hr = IUri_HasProperty(uri, Uri_PROPERTY_RAW_URI, NULL);
6995         ok(hr == E_INVALIDARG, "Error: HasProperty returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6996     }
6997     if(uri) IUri_Release(uri);
6998
6999     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7000         uri_properties test = uri_tests[i];
7001         LPWSTR uriW;
7002         uri = NULL;
7003
7004         uriW = a2w(test.uri);
7005
7006         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7007         if(test.create_todo) {
7008             todo_wine {
7009                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7010             }
7011         } else {
7012             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7013         }
7014
7015         if(SUCCEEDED(hr)) {
7016             DWORD expected_props, j;
7017
7018             expected_props = compute_expected_props(&test);
7019
7020             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
7021                 /* Assign -1, then explicitly test for TRUE or FALSE later. */
7022                 BOOL received = -1;
7023
7024                 hr = IUri_HasProperty(uri, j, &received);
7025                 ok(hr == S_OK, "Error: HasProperty returned 0x%08x, expected 0x%08x for property %d on uri_tests[%d].\n",
7026                         hr, S_OK, j, i);
7027
7028                 if(expected_props & (1 << j)) {
7029                     ok(received == TRUE, "Error: Expected to have property %d on uri_tests[%d].\n", j, i);
7030                 } else {
7031                     ok(received == FALSE, "Error: Wasn't expecting to have property %d on uri_tests[%d].\n", j, i);
7032                 }
7033             }
7034         }
7035
7036         if(uri) IUri_Release(uri);
7037
7038         heap_free(uriW);
7039     }
7040 }
7041
7042 static void test_IUri_IsEqual(void) {
7043     IUri *uriA, *uriB;
7044     HRESULT hrA, hrB;
7045     DWORD i;
7046
7047     uriA = uriB = NULL;
7048
7049     /* Make sure IsEqual handles invalid args correctly. */
7050     hrA = pCreateUri(http_urlW, 0, 0, &uriA);
7051     hrB = pCreateUri(http_urlW, 0, 0, &uriB);
7052     ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hrA, S_OK);
7053     ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hrB, S_OK);
7054     if(SUCCEEDED(hrA) && SUCCEEDED(hrB)) {
7055         BOOL equal = -1;
7056         hrA = IUri_IsEqual(uriA, NULL, &equal);
7057         ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hrA, S_OK);
7058         ok(equal == FALSE, "Error: Expected equal to be FALSE, but was %d instead.\n", equal);
7059
7060         hrA = IUri_IsEqual(uriA, uriB, NULL);
7061         ok(hrA == E_POINTER, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hrA, E_POINTER);
7062     }
7063     if(uriA) IUri_Release(uriA);
7064     if(uriB) IUri_Release(uriB);
7065
7066     for(i = 0; i < sizeof(equality_tests)/sizeof(equality_tests[0]); ++i) {
7067         uri_equality test = equality_tests[i];
7068         LPWSTR uriA_W, uriB_W;
7069
7070         uriA = uriB = NULL;
7071
7072         uriA_W = a2w(test.a);
7073         uriB_W = a2w(test.b);
7074
7075         hrA = pCreateUri(uriA_W, test.create_flags_a, 0, &uriA);
7076         if(test.create_todo_a) {
7077             todo_wine {
7078                 ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n",
7079                         hrA, S_OK, i);
7080             }
7081         } else {
7082             ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n",
7083                     hrA, S_OK, i);
7084         }
7085
7086         hrB = pCreateUri(uriB_W, test.create_flags_b, 0, &uriB);
7087         if(test.create_todo_b) {
7088             todo_wine {
7089                 ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n",
7090                         hrB, S_OK, i);
7091             }
7092         } else {
7093             ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n",
7094                     hrB, S_OK, i);
7095         }
7096
7097         if(SUCCEEDED(hrA) && SUCCEEDED(hrB)) {
7098             BOOL equal = -1;
7099
7100             hrA = IUri_IsEqual(uriA, uriB, &equal);
7101             if(test.todo) {
7102                 todo_wine {
7103                     ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n",
7104                             hrA, S_OK, i);
7105                 }
7106                 todo_wine {
7107                     ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7108                 }
7109             } else {
7110                 ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n", hrA, S_OK, i);
7111                 ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7112             }
7113         }
7114         if(uriA) IUri_Release(uriA);
7115         if(uriB) IUri_Release(uriB);
7116
7117         heap_free(uriA_W);
7118         heap_free(uriB_W);
7119     }
7120 }
7121
7122 static void test_CreateUriWithFragment_InvalidArgs(void) {
7123     HRESULT hr;
7124     IUri *uri = (void*) 0xdeadbeef;
7125     const WCHAR fragmentW[] = {'#','f','r','a','g','m','e','n','t',0};
7126
7127     hr = pCreateUriWithFragment(NULL, fragmentW, 0, 0, &uri);
7128     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7129     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7130
7131     hr = pCreateUriWithFragment(http_urlW, fragmentW, 0, 0, NULL);
7132     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7133
7134     /* Original URI can't already contain a fragment component. */
7135     uri = (void*) 0xdeadbeef;
7136     hr = pCreateUriWithFragment(http_url_fragW, fragmentW, 0, 0, &uri);
7137     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7138     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7139 }
7140
7141 /* CreateUriWithFragment has the same invalid flag combinations as CreateUri. */
7142 static void test_CreateUriWithFragment_InvalidFlags(void) {
7143     DWORD i;
7144
7145     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
7146         HRESULT hr;
7147         IUri *uri = (void*) 0xdeadbeef;
7148
7149         hr = pCreateUriWithFragment(http_urlW, NULL, invalid_flag_tests[i].flags, 0, &uri);
7150         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x. flags=0x%08x.\n",
7151             hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
7152         ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7153     }
7154 }
7155
7156 static void test_CreateUriWithFragment(void) {
7157     DWORD i;
7158
7159     for(i = 0; i < sizeof(uri_fragment_tests)/sizeof(uri_fragment_tests[0]); ++i) {
7160         HRESULT hr;
7161         IUri *uri = NULL;
7162         LPWSTR uriW, fragW;
7163         uri_with_fragment test = uri_fragment_tests[i];
7164
7165         uriW = a2w(test.uri);
7166         fragW = a2w(test.fragment);
7167
7168         hr = pCreateUriWithFragment(uriW, fragW, test.create_flags, 0, &uri);
7169         if(test.expected_todo) {
7170             todo_wine {
7171                 ok(hr == test.create_expected,
7172                     "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7173                     hr, test.create_expected, i);
7174             }
7175         } else
7176             ok(hr == test.create_expected,
7177                 "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7178                 hr, test.create_expected, i);
7179
7180         if(SUCCEEDED(hr)) {
7181             BSTR received = NULL;
7182
7183             hr = IUri_GetAbsoluteUri(uri, &received);
7184             if(test.expected_todo) {
7185                 todo_wine {
7186                     ok(hr == S_OK,
7187                         "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7188                         hr, S_OK, i);
7189                 }
7190                 todo_wine {
7191                     ok(!strcmp_aw(test.expected_uri, received),
7192                         "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7193                         test.expected_uri, wine_dbgstr_w(received), i);
7194                 }
7195             } else {
7196                 ok(hr == S_OK, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7197                     hr, S_OK, i);
7198                 ok(!strcmp_aw(test.expected_uri, received), "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7199                     test.expected_uri, wine_dbgstr_w(received), i);
7200             }
7201
7202             SysFreeString(received);
7203         }
7204
7205         if(uri) IUri_Release(uri);
7206         heap_free(uriW);
7207     }
7208 }
7209
7210 static void test_CreateIUriBuilder(void) {
7211     HRESULT hr;
7212     IUriBuilder *builder = NULL;
7213     IUri *uri;
7214
7215     hr = pCreateIUriBuilder(NULL, 0, 0, NULL);
7216     ok(hr == E_POINTER, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x\n",
7217         hr, E_POINTER);
7218
7219     /* CreateIUriBuilder increases the ref count of the IUri it receives. */
7220     hr = pCreateUri(http_urlW, 0, 0, &uri);
7221     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7222     if(SUCCEEDED(hr)) {
7223         ULONG cur_count, orig_count;
7224
7225         orig_count = get_refcnt(uri);
7226         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
7227         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7228         ok(builder != NULL, "Error: Expecting builder not to be NULL\n");
7229
7230         cur_count = get_refcnt(uri);
7231         ok(cur_count == orig_count+1, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count+1, cur_count);
7232
7233         if(builder) IUriBuilder_Release(builder);
7234         cur_count = get_refcnt(uri);
7235         ok(cur_count == orig_count, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count, cur_count);
7236     }
7237     if(uri) IUri_Release(uri);
7238 }
7239
7240 static void test_IUriBuilder_CreateUri(IUriBuilder *builder, const uri_builder_test *test,
7241                                        DWORD test_index) {
7242     HRESULT hr;
7243     IUri *uri = NULL;
7244
7245     hr = IUriBuilder_CreateUri(builder, test->uri_flags, 0, 0, &uri);
7246     if(test->uri_todo) {
7247         todo_wine {
7248             ok(hr == test->uri_hres,
7249                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7250                 hr, test->uri_hres, test_index);
7251         }
7252     } else {
7253         ok(hr == test->uri_hres,
7254             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7255             hr, test->uri_hres, test_index);
7256     }
7257
7258     if(SUCCEEDED(hr)) {
7259         DWORD i;
7260
7261         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7262             uri_builder_str_property prop = test->expected_str_props[i];
7263             BSTR received = NULL;
7264
7265             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7266             if(prop.todo) {
7267                 todo_wine {
7268                     ok(hr == prop.result,
7269                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7270                         hr, prop.result, test_index, i);
7271                 }
7272             } else {
7273                 ok(hr == prop.result,
7274                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7275                     hr, prop.result, test_index, i);
7276             }
7277             if(SUCCEEDED(hr)) {
7278                 if(prop.todo) {
7279                     todo_wine {
7280                         ok(!strcmp_aw(prop.expected, received),
7281                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7282                             prop.expected, wine_dbgstr_w(received), test_index, i);
7283                     }
7284                 } else {
7285                     ok(!strcmp_aw(prop.expected, received),
7286                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7287                         prop.expected, wine_dbgstr_w(received), test_index, i);
7288                 }
7289             }
7290             SysFreeString(received);
7291         }
7292
7293         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7294             uri_builder_dword_property prop = test->expected_dword_props[i];
7295             DWORD received = -2;
7296
7297             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7298             if(prop.todo) {
7299                 todo_wine {
7300                     ok(hr == prop.result,
7301                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7302                         hr, prop.result, test_index, i);
7303                 }
7304             } else {
7305                 ok(hr == prop.result,
7306                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7307                     hr, prop.result, test_index, i);
7308             }
7309             if(SUCCEEDED(hr)) {
7310                 if(prop.todo) {
7311                     todo_wine {
7312                         ok(received == prop.expected,
7313                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7314                             prop.expected, received, test_index, i);
7315                     }
7316                 } else {
7317                     ok(received == prop.expected,
7318                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7319                         prop.expected, received, test_index, i);
7320                 }
7321             }
7322         }
7323     }
7324     if(uri) IUri_Release(uri);
7325 }
7326
7327 static void test_IUriBuilder_CreateUriSimple(IUriBuilder *builder, const uri_builder_test *test,
7328                                        DWORD test_index) {
7329     HRESULT hr;
7330     IUri *uri = NULL;
7331
7332     hr = IUriBuilder_CreateUriSimple(builder, test->uri_simple_encode_flags, 0, &uri);
7333     if(test->uri_simple_todo) {
7334         todo_wine {
7335             ok(hr == test->uri_simple_hres,
7336                 "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7337                 hr, test->uri_simple_hres, test_index);
7338         }
7339     } else {
7340         ok(hr == test->uri_simple_hres,
7341             "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7342             hr, test->uri_simple_hres, test_index);
7343     }
7344
7345     if(SUCCEEDED(hr)) {
7346         DWORD i;
7347
7348         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7349             uri_builder_str_property prop = test->expected_str_props[i];
7350             BSTR received = NULL;
7351
7352             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7353             if(prop.todo) {
7354                 todo_wine {
7355                     ok(hr == prop.result,
7356                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7357                         hr, prop.result, test_index, i);
7358                 }
7359             } else {
7360                 ok(hr == prop.result,
7361                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7362                     hr, prop.result, test_index, i);
7363             }
7364             if(SUCCEEDED(hr)) {
7365                 if(prop.todo) {
7366                     todo_wine {
7367                         ok(!strcmp_aw(prop.expected, received),
7368                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7369                             prop.expected, wine_dbgstr_w(received), test_index, i);
7370                     }
7371                 } else {
7372                     ok(!strcmp_aw(prop.expected, received),
7373                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7374                         prop.expected, wine_dbgstr_w(received), test_index, i);
7375                 }
7376             }
7377             SysFreeString(received);
7378         }
7379
7380         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7381             uri_builder_dword_property prop = test->expected_dword_props[i];
7382             DWORD received = -2;
7383
7384             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7385             if(prop.todo) {
7386                 todo_wine {
7387                     ok(hr == prop.result,
7388                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7389                         hr, prop.result, test_index, i);
7390                 }
7391             } else {
7392                 ok(hr == prop.result,
7393                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7394                     hr, prop.result, test_index, i);
7395             }
7396             if(SUCCEEDED(hr)) {
7397                 if(prop.todo) {
7398                     todo_wine {
7399                         ok(received == prop.expected,
7400                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7401                             prop.expected, received, test_index, i);
7402                     }
7403                 } else {
7404                     ok(received == prop.expected,
7405                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7406                         prop.expected, received, test_index, i);
7407                 }
7408             }
7409         }
7410     }
7411     if(uri) IUri_Release(uri);
7412 }
7413
7414 static void test_IUriBuilder_CreateUriWithFlags(IUriBuilder *builder, const uri_builder_test *test,
7415                                                 DWORD test_index) {
7416     HRESULT hr;
7417     IUri *uri = NULL;
7418
7419     hr = IUriBuilder_CreateUriWithFlags(builder, test->uri_with_flags, test->uri_with_builder_flags,
7420                                         test->uri_with_encode_flags, 0, &uri);
7421     if(test->uri_with_todo) {
7422         todo_wine {
7423             ok(hr == test->uri_with_hres,
7424                 "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7425                 hr, test->uri_with_hres, test_index);
7426         }
7427     } else {
7428         ok(hr == test->uri_with_hres,
7429             "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7430             hr, test->uri_with_hres, test_index);
7431     }
7432
7433     if(SUCCEEDED(hr)) {
7434         DWORD i;
7435
7436         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7437             uri_builder_str_property prop = test->expected_str_props[i];
7438             BSTR received = NULL;
7439
7440             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7441             if(prop.todo) {
7442                 todo_wine {
7443                     ok(hr == prop.result,
7444                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7445                         hr, prop.result, test_index, i);
7446                 }
7447             } else {
7448                 ok(hr == prop.result,
7449                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7450                     hr, prop.result, test_index, i);
7451             }
7452             if(SUCCEEDED(hr)) {
7453                 if(prop.todo) {
7454                     todo_wine {
7455                         ok(!strcmp_aw(prop.expected, received),
7456                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7457                             prop.expected, wine_dbgstr_w(received), test_index, i);
7458                     }
7459                 } else {
7460                     ok(!strcmp_aw(prop.expected, received),
7461                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7462                         prop.expected, wine_dbgstr_w(received), test_index, i);
7463                 }
7464             }
7465             SysFreeString(received);
7466         }
7467
7468         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7469             uri_builder_dword_property prop = test->expected_dword_props[i];
7470             DWORD received = -2;
7471
7472             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7473             if(prop.todo) {
7474                 todo_wine {
7475                     ok(hr == prop.result,
7476                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7477                         hr, prop.result, test_index, i);
7478                 }
7479             } else {
7480                 ok(hr == prop.result,
7481                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7482                     hr, prop.result, test_index, i);
7483             }
7484             if(SUCCEEDED(hr)) {
7485                 if(prop.todo) {
7486                     todo_wine {
7487                         ok(received == prop.expected,
7488                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7489                             prop.expected, received, test_index, i);
7490                     }
7491                 } else {
7492                     ok(received == prop.expected,
7493                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7494                         prop.expected, received, test_index, i);
7495                 }
7496             }
7497         }
7498     }
7499     if(uri) IUri_Release(uri);
7500 }
7501
7502 static void test_IUriBuilder_CreateInvalidArgs(void) {
7503     IUriBuilder *builder;
7504     HRESULT hr;
7505
7506     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
7507     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7508     if(SUCCEEDED(hr)) {
7509         IUri *test = NULL, *uri = (void*) 0xdeadbeef;
7510
7511         /* Test what happens if the IUriBuilder doesn't have a IUri set. */
7512         hr = IUriBuilder_CreateUri(builder, 0, 0, 0, NULL);
7513         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7514
7515         uri = (void*) 0xdeadbeef;
7516         hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
7517         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_NOTIMPL);
7518         ok(uri == NULL, "Error: expected uri to be NULL, but was %p instead.\n", uri);
7519
7520         hr = IUriBuilder_CreateUriSimple(builder, 0, 0, NULL);
7521         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
7522             hr, E_POINTER);
7523
7524         uri = (void*) 0xdeadbeef;
7525         hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
7526         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
7527             hr, E_NOTIMPL);
7528         ok(!uri, "Error: Expected uri to NULL, but was %p instead.\n", uri);
7529
7530         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, NULL);
7531         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
7532             hr, E_POINTER);
7533
7534         uri = (void*) 0xdeadbeef;
7535         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
7536         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
7537             hr, E_NOTIMPL);
7538         ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7539
7540         hr = pCreateUri(http_urlW, 0, 0, &test);
7541         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7542         if(SUCCEEDED(hr)) {
7543             hr = IUriBuilder_SetIUri(builder, test);
7544             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7545
7546             /* No longer returns E_NOTIMPL, since a IUri has been set and hasn't been modified. */
7547             uri = NULL;
7548             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
7549             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7550             ok(uri != NULL, "Error: The uri was NULL.\n");
7551             if(uri) IUri_Release(uri);
7552
7553             uri = NULL;
7554             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
7555             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
7556                 hr, S_OK);
7557             ok(uri != NULL, "Error: uri was NULL.\n");
7558             if(uri) IUri_Release(uri);
7559
7560             uri = NULL;
7561             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &uri);
7562             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
7563                 hr, S_OK);
7564             ok(uri != NULL, "Error: uri was NULL.\n");
7565             if(uri) IUri_Release(uri);
7566
7567             hr = IUriBuilder_SetFragment(builder, NULL);
7568             ok(hr == S_OK, "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7569
7570             /* The IUriBuilder is changed, so it returns E_NOTIMPL again. */
7571             uri = (void*) 0xdeadbeef;
7572             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
7573             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7574             ok(!uri, "Error: Expected uri to be NULL but was %p instead.\n", uri);
7575
7576             uri = (void*) 0xdeadbeef;
7577             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
7578             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
7579                 hr, S_OK);
7580             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7581
7582             uri = (void*) 0xdeadbeef;
7583             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
7584             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
7585                 hr, E_NOTIMPL);
7586             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7587         }
7588         if(test) IUri_Release(test);
7589     }
7590     if(builder) IUriBuilder_Release(builder);
7591 }
7592
7593 /* Tests invalid args to the "Get*" functions. */
7594 static void test_IUriBuilder_GetInvalidArgs(void) {
7595     IUriBuilder *builder = NULL;
7596     HRESULT hr;
7597
7598     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
7599     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7600     if(SUCCEEDED(hr)) {
7601         LPCWSTR received = (void*) 0xdeadbeef;
7602         DWORD len = -1, port = -1;
7603         BOOL set = -1;
7604
7605         hr = IUriBuilder_GetFragment(builder, NULL, NULL);
7606         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
7607             hr, E_POINTER);
7608         hr = IUriBuilder_GetFragment(builder, NULL, &received);
7609         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
7610             hr, E_POINTER);
7611         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7612         hr = IUriBuilder_GetFragment(builder, &len, NULL);
7613         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
7614             hr, E_POINTER);
7615         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7616
7617         hr = IUriBuilder_GetHost(builder, NULL, NULL);
7618         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
7619             hr, E_POINTER);
7620         received = (void*) 0xdeadbeef;
7621         hr = IUriBuilder_GetHost(builder, NULL, &received);
7622         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
7623             hr, E_POINTER);
7624         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7625         len = -1;
7626         hr = IUriBuilder_GetHost(builder, &len, NULL);
7627         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
7628             hr, E_POINTER);
7629         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7630
7631         hr = IUriBuilder_GetPassword(builder, NULL, NULL);
7632         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
7633             hr, E_POINTER);
7634         received = (void*) 0xdeadbeef;
7635         hr = IUriBuilder_GetPassword(builder, NULL, &received);
7636         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
7637             hr, E_POINTER);
7638         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7639         len = -1;
7640         hr = IUriBuilder_GetPassword(builder, &len, NULL);
7641         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
7642             hr, E_POINTER);
7643         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7644
7645         hr = IUriBuilder_GetPath(builder, NULL, NULL);
7646         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
7647             hr, E_POINTER);
7648         received = (void*) 0xdeadbeef;
7649         hr = IUriBuilder_GetPath(builder, NULL, &received);
7650         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
7651             hr, E_POINTER);
7652         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7653         len = -1;
7654         hr = IUriBuilder_GetPath(builder, &len, NULL);
7655         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
7656             hr, E_POINTER);
7657         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7658
7659         hr = IUriBuilder_GetPort(builder, NULL, NULL);
7660         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
7661             hr, E_POINTER);
7662         hr = IUriBuilder_GetPort(builder, NULL, &port);
7663         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
7664             hr, E_POINTER);
7665         ok(!port, "Error: Expected port to be 0, but was %d instead.\n", port);
7666         hr = IUriBuilder_GetPort(builder, &set, NULL);
7667         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
7668             hr, E_POINTER);
7669         ok(!set, "Error: Expected set to be FALSE, but was %d instead.\n", set);
7670
7671         hr = IUriBuilder_GetQuery(builder, NULL, NULL);
7672         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
7673             hr, E_POINTER);
7674         received = (void*) 0xdeadbeef;
7675         hr = IUriBuilder_GetQuery(builder, NULL, &received);
7676         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
7677             hr, E_POINTER);
7678         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7679         len = -1;
7680         hr = IUriBuilder_GetQuery(builder, &len, NULL);
7681         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
7682             hr, E_POINTER);
7683         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7684
7685         hr = IUriBuilder_GetSchemeName(builder, NULL, NULL);
7686         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
7687             hr, E_POINTER);
7688         received = (void*) 0xdeadbeef;
7689         hr = IUriBuilder_GetSchemeName(builder, NULL, &received);
7690         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
7691             hr, E_POINTER);
7692         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7693         len = -1;
7694         hr = IUriBuilder_GetSchemeName(builder, &len, NULL);
7695         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
7696             hr, E_POINTER);
7697         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7698
7699         hr = IUriBuilder_GetUserName(builder, NULL, NULL);
7700         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
7701             hr, E_POINTER);
7702         received = (void*) 0xdeadbeef;
7703         hr = IUriBuilder_GetUserName(builder, NULL, &received);
7704         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
7705             hr, E_POINTER);
7706         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7707         len = -1;
7708         hr = IUriBuilder_GetUserName(builder, &len, NULL);
7709         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
7710             hr, E_POINTER);
7711         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7712     }
7713     if(builder) IUriBuilder_Release(builder);
7714 }
7715
7716 static void test_IUriBuilder_GetFragment(IUriBuilder *builder, const uri_builder_test *test,
7717                                          DWORD test_index) {
7718     HRESULT hr;
7719     DWORD i;
7720     LPCWSTR received = NULL;
7721     DWORD len = -1;
7722     const uri_builder_property *prop = NULL;
7723
7724     /* Check if the property was set earlier. */
7725     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
7726         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_FRAGMENT)
7727             prop = &(test->properties[i]);
7728     }
7729
7730     if(prop) {
7731         /* Use expected_value unless it's NULL, then use value. */
7732         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
7733         hr = IUriBuilder_GetFragment(builder, &len, &received);
7734         if(prop->todo) {
7735             todo_wine {
7736                 ok(hr == (expected ? S_OK : S_FALSE),
7737                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7738                     hr, (expected ? S_OK : S_FALSE), test_index);
7739             }
7740             if(SUCCEEDED(hr)) {
7741                 todo_wine {
7742                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7743                         expected, wine_dbgstr_w(received), test_index);
7744                 }
7745                 todo_wine {
7746                     ok(lstrlen(expected) == len,
7747                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7748                         lstrlen(expected), len, test_index);
7749                 }
7750             }
7751         } else {
7752             ok(hr == (expected ? S_OK : S_FALSE),
7753                 "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7754                 hr, (expected ? S_OK : S_FALSE), test_index);
7755             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7756                 expected, wine_dbgstr_w(received), test_index);
7757             ok(lstrlen(expected) == len,
7758                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7759                 lstrlen(expected), len, test_index);
7760         }
7761     } else {
7762         /* The property wasn't set earlier, so it should return whatever
7763          * the base IUri contains (if anything).
7764          */
7765         IUri *uri = NULL;
7766         hr = IUriBuilder_GetIUri(builder, &uri);
7767         ok(hr == S_OK,
7768             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7769             hr, S_OK, test_index);
7770         if(SUCCEEDED(hr)) {
7771             if(!uri) {
7772                 received = (void*) 0xdeadbeef;
7773                 len = -1;
7774
7775                 hr = IUriBuilder_GetFragment(builder, &len, &received);
7776                 ok(hr == S_FALSE,
7777                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7778                     hr, S_FALSE, test_index);
7779                 if(SUCCEEDED(hr)) {
7780                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
7781                         len, test_index);
7782                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
7783                         received, test_index);
7784                 }
7785             } else {
7786                 BOOL has_prop = FALSE;
7787                 BSTR expected = NULL;
7788
7789                 hr = IUri_GetFragment(uri, &expected);
7790                 ok(SUCCEEDED(hr),
7791                     "Error: Expected IUri_GetFragment to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
7792                     hr, test_index);
7793                 has_prop = hr == S_OK;
7794
7795                 hr = IUriBuilder_GetFragment(builder, &len, &received);
7796                 if(has_prop) {
7797                     ok(hr == S_OK,
7798                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7799                         hr, S_OK, test_index);
7800                     if(SUCCEEDED(hr)) {
7801                         ok(!lstrcmpW(expected, received),
7802                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
7803                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
7804                         ok(lstrlenW(expected) == len,
7805                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7806                             lstrlenW(expected), len, test_index);
7807                     }
7808                 } else {
7809                     ok(hr == S_FALSE,
7810                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7811                         hr, S_FALSE, test_index);
7812                     if(SUCCEEDED(hr)) {
7813                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
7814                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
7815                             len, test_index);
7816                     }
7817                 }
7818                 SysFreeString(expected);
7819             }
7820         }
7821         if(uri) IUri_Release(uri);
7822     }
7823 }
7824
7825 static void test_IUriBuilder_GetHost(IUriBuilder *builder, const uri_builder_test *test,
7826                                      DWORD test_index) {
7827     HRESULT hr;
7828     DWORD i;
7829     LPCWSTR received = NULL;
7830     DWORD len = -1;
7831     const uri_builder_property *prop = NULL;
7832
7833     /* Check if the property was set earlier. */
7834     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
7835         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_HOST)
7836             prop = &(test->properties[i]);
7837     }
7838
7839     if(prop) {
7840         /* Use expected_value unless it's NULL, then use value. */
7841         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
7842         hr = IUriBuilder_GetHost(builder, &len, &received);
7843         if(prop->todo) {
7844             todo_wine {
7845                 ok(hr == (expected ? S_OK : S_FALSE),
7846                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7847                     hr, (expected ? S_OK : S_FALSE), test_index);
7848             }
7849             if(SUCCEEDED(hr)) {
7850                 todo_wine {
7851                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7852                         expected, wine_dbgstr_w(received), test_index);
7853                 }
7854                 todo_wine {
7855                     ok(lstrlen(expected) == len,
7856                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7857                         lstrlen(expected), len, test_index);
7858                 }
7859             }
7860         } else {
7861             ok(hr == (expected ? S_OK : S_FALSE),
7862                 "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7863                 hr, (expected ? S_OK : S_FALSE), test_index);
7864             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7865                 expected, wine_dbgstr_w(received), test_index);
7866             ok(lstrlen(expected) == len,
7867                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7868                 lstrlen(expected), len, test_index);
7869         }
7870     } else {
7871         /* The property wasn't set earlier, so it should return whatever
7872          * the base IUri contains (if anything).
7873          */
7874         IUri *uri = NULL;
7875         hr = IUriBuilder_GetIUri(builder, &uri);
7876         ok(hr == S_OK,
7877             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7878             hr, S_OK, test_index);
7879         if(SUCCEEDED(hr)) {
7880             if(!uri) {
7881                 received = (void*) 0xdeadbeef;
7882                 len = -1;
7883
7884                 hr = IUriBuilder_GetHost(builder, &len, &received);
7885                 ok(hr == S_FALSE,
7886                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7887                     hr, S_FALSE, test_index);
7888                 if(SUCCEEDED(hr)) {
7889                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
7890                         len, test_index);
7891                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
7892                         received, test_index);
7893                 }
7894             } else {
7895                 BOOL has_prop = FALSE;
7896                 BSTR expected = NULL;
7897
7898                 hr = IUri_GetHost(uri, &expected);
7899                 ok(SUCCEEDED(hr),
7900                     "Error: Expected IUri_GetHost to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
7901                     hr, test_index);
7902                 has_prop = hr == S_OK;
7903
7904                 hr = IUriBuilder_GetHost(builder, &len, &received);
7905                 if(has_prop) {
7906                     ok(hr == S_OK,
7907                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7908                         hr, S_OK, test_index);
7909                     if(SUCCEEDED(hr)) {
7910                         ok(!lstrcmpW(expected, received),
7911                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
7912                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
7913                         ok(lstrlenW(expected) == len,
7914                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7915                             lstrlenW(expected), len, test_index);
7916                     }
7917                 } else {
7918                     ok(hr == S_FALSE,
7919                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7920                         hr, S_FALSE, test_index);
7921                     if(SUCCEEDED(hr)) {
7922                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
7923                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
7924                             len, test_index);
7925                     }
7926                 }
7927                 SysFreeString(expected);
7928             }
7929         }
7930         if(uri) IUri_Release(uri);
7931     }
7932 }
7933
7934 static void test_IUriBuilder_GetPassword(IUriBuilder *builder, const uri_builder_test *test,
7935                                          DWORD test_index) {
7936     HRESULT hr;
7937     DWORD i;
7938     LPCWSTR received = NULL;
7939     DWORD len = -1;
7940     const uri_builder_property *prop = NULL;
7941
7942     /* Check if the property was set earlier. */
7943     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
7944         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PASSWORD)
7945             prop = &(test->properties[i]);
7946     }
7947
7948     if(prop) {
7949         /* Use expected_value unless it's NULL, then use value. */
7950         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
7951         hr = IUriBuilder_GetPassword(builder, &len, &received);
7952         if(prop->todo) {
7953             todo_wine {
7954                 ok(hr == (expected ? S_OK : S_FALSE),
7955                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7956                     hr, (expected ? S_OK : S_FALSE), test_index);
7957             }
7958             if(SUCCEEDED(hr)) {
7959                 todo_wine {
7960                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7961                         expected, wine_dbgstr_w(received), test_index);
7962                 }
7963                 todo_wine {
7964                     ok(lstrlen(expected) == len,
7965                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7966                         lstrlen(expected), len, test_index);
7967                 }
7968             }
7969         } else {
7970             ok(hr == (expected ? S_OK : S_FALSE),
7971                 "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7972                 hr, (expected ? S_OK : S_FALSE), test_index);
7973             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7974                 expected, wine_dbgstr_w(received), test_index);
7975             ok(lstrlen(expected) == len,
7976                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7977                 lstrlen(expected), len, test_index);
7978         }
7979     } else {
7980         /* The property wasn't set earlier, so it should return whatever
7981          * the base IUri contains (if anything).
7982          */
7983         IUri *uri = NULL;
7984         hr = IUriBuilder_GetIUri(builder, &uri);
7985         ok(hr == S_OK,
7986             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7987             hr, S_OK, test_index);
7988         if(SUCCEEDED(hr)) {
7989             if(!uri) {
7990                 received = (void*) 0xdeadbeef;
7991                 len = -1;
7992
7993                 hr = IUriBuilder_GetPassword(builder, &len, &received);
7994                 ok(hr == S_FALSE,
7995                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7996                     hr, S_FALSE, test_index);
7997                 if(SUCCEEDED(hr)) {
7998                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
7999                         len, test_index);
8000                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8001                         received, test_index);
8002                 }
8003             } else {
8004                 BOOL has_prop = FALSE;
8005                 BSTR expected = NULL;
8006
8007                 hr = IUri_GetPassword(uri, &expected);
8008                 ok(SUCCEEDED(hr),
8009                     "Error: Expected IUri_GetPassword to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8010                     hr, test_index);
8011                 has_prop = hr == S_OK;
8012
8013                 hr = IUriBuilder_GetPassword(builder, &len, &received);
8014                 if(has_prop) {
8015                     ok(hr == S_OK,
8016                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8017                         hr, S_OK, test_index);
8018                     if(SUCCEEDED(hr)) {
8019                         ok(!lstrcmpW(expected, received),
8020                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8021                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8022                         ok(lstrlenW(expected) == len,
8023                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8024                             lstrlenW(expected), len, test_index);
8025                     }
8026                 } else {
8027                     ok(hr == S_FALSE,
8028                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8029                         hr, S_FALSE, test_index);
8030                     if(SUCCEEDED(hr)) {
8031                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8032                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8033                             len, test_index);
8034                     }
8035                 }
8036                 SysFreeString(expected);
8037             }
8038         }
8039         if(uri) IUri_Release(uri);
8040     }
8041 }
8042
8043 static void test_IUriBuilder_GetPath(IUriBuilder *builder, const uri_builder_test *test,
8044                                      DWORD test_index) {
8045     HRESULT hr;
8046     DWORD i;
8047     LPCWSTR received = NULL;
8048     DWORD len = -1;
8049     const uri_builder_property *prop = NULL;
8050
8051     /* Check if the property was set earlier. */
8052     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8053         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PATH)
8054             prop = &(test->properties[i]);
8055     }
8056
8057     if(prop) {
8058         /* Use expected_value unless it's NULL, then use value. */
8059         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8060         hr = IUriBuilder_GetPath(builder, &len, &received);
8061         if(prop->todo) {
8062             todo_wine {
8063                 ok(hr == (expected ? S_OK : S_FALSE),
8064                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8065                     hr, (expected ? S_OK : S_FALSE), test_index);
8066             }
8067             if(SUCCEEDED(hr)) {
8068                 todo_wine {
8069                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8070                         expected, wine_dbgstr_w(received), test_index);
8071                 }
8072                 todo_wine {
8073                     ok(lstrlen(expected) == len,
8074                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8075                         lstrlen(expected), len, test_index);
8076                 }
8077             }
8078         } else {
8079             ok(hr == (expected ? S_OK : S_FALSE),
8080                 "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8081                 hr, (expected ? S_OK : S_FALSE), test_index);
8082             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8083                 expected, wine_dbgstr_w(received), test_index);
8084             ok(lstrlen(expected) == len,
8085                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8086                 lstrlen(expected), len, test_index);
8087         }
8088     } else {
8089         /* The property wasn't set earlier, so it should return whatever
8090          * the base IUri contains (if anything).
8091          */
8092         IUri *uri = NULL;
8093         hr = IUriBuilder_GetIUri(builder, &uri);
8094         ok(hr == S_OK,
8095             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8096             hr, S_OK, test_index);
8097         if(SUCCEEDED(hr)) {
8098             if(!uri) {
8099                 received = (void*) 0xdeadbeef;
8100                 len = -1;
8101
8102                 hr = IUriBuilder_GetPath(builder, &len, &received);
8103                 ok(hr == S_FALSE,
8104                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8105                     hr, S_FALSE, test_index);
8106                 if(SUCCEEDED(hr)) {
8107                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8108                         len, test_index);
8109                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8110                         received, test_index);
8111                 }
8112             } else {
8113                 BOOL has_prop = FALSE;
8114                 BSTR expected = NULL;
8115
8116                 hr = IUri_GetPath(uri, &expected);
8117                 ok(SUCCEEDED(hr),
8118                     "Error: Expected IUri_GetPath to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8119                     hr, test_index);
8120                 has_prop = hr == S_OK;
8121
8122                 hr = IUriBuilder_GetPath(builder, &len, &received);
8123                 if(has_prop) {
8124                     ok(hr == S_OK,
8125                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8126                         hr, S_OK, test_index);
8127                     if(SUCCEEDED(hr)) {
8128                         ok(!lstrcmpW(expected, received),
8129                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8130                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8131                         ok(lstrlenW(expected) == len,
8132                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8133                             lstrlenW(expected), len, test_index);
8134                     }
8135                 } else {
8136                     ok(hr == S_FALSE,
8137                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8138                         hr, S_FALSE, test_index);
8139                     if(SUCCEEDED(hr)) {
8140                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8141                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8142                             len, test_index);
8143                     }
8144                 }
8145                 SysFreeString(expected);
8146             }
8147         }
8148         if(uri) IUri_Release(uri);
8149     }
8150 }
8151
8152 static void test_IUriBuilder_GetPort(IUriBuilder *builder, const uri_builder_test *test,
8153                                      DWORD test_index) {
8154     HRESULT hr;
8155     BOOL has_port = FALSE;
8156     DWORD received = -1;
8157
8158     if(test->port_prop.change) {
8159         DWORD expected = test->port_prop.value;
8160
8161         hr = IUriBuilder_GetPort(builder, &has_port, &received);
8162         if(test->port_prop.todo) {
8163             todo_wine {
8164                 ok(hr == S_OK,
8165                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8166                     hr, S_OK, test_index);
8167             }
8168             if(SUCCEEDED(hr)) {
8169                 todo_wine {
8170                     ok(has_port == test->port_prop.set,
8171                         "Error: Expected has_port to be %d but was %d instead on uri_builder_tests[%d].\n",
8172                         test->port_prop.set, has_port, test_index);
8173                 }
8174                 todo_wine {
8175                     ok(received == expected,
8176                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8177                         expected, received, test_index);
8178                 }
8179             }
8180         } else {
8181             ok(hr == S_OK,
8182                 "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8183                 hr, S_OK, test_index);
8184             ok(has_port == test->port_prop.set,
8185                 "Error: Expected has_port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8186                 test->port_prop.set, has_port, test_index);
8187             ok(received == test->port_prop.value,
8188                 "Error: Expected port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8189                 test->port_prop.value, received, test_index);
8190         }
8191     } else {
8192         IUri *uri = NULL;
8193
8194         hr = IUriBuilder_GetIUri(builder, &uri);
8195         ok(hr == S_OK,
8196             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8197             hr, S_OK, test_index);
8198         if(SUCCEEDED(hr)) {
8199             if(!uri) {
8200                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8201                 ok(hr == S_OK,
8202                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8203                     hr, S_OK, test_index);
8204                 if(SUCCEEDED(hr)) {
8205                     ok(has_port == FALSE,
8206                         "Error: Expected has_port to be FALSE, but was %d instead on uri_builder_tests[%d].\n",
8207                         has_port, test_index);
8208                     ok(!received, "Error: Expected received to be 0, but was %d instead on uri_builder_tests[%d].\n",
8209                         received, test_index);
8210                 }
8211             } else {
8212                 DWORD expected;
8213
8214                 hr = IUri_GetPort(uri, &expected);
8215                 ok(SUCCEEDED(hr),
8216                     "Error: Expected IUri_Port to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8217                     hr, test_index);
8218
8219                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8220                 ok(hr == S_OK,
8221                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8222                     hr, S_OK, test_index);
8223                 if(SUCCEEDED(hr)) {
8224                     ok(!has_port,
8225                         "Error: Expected has_port to be FALSE but was TRUE instead on uri_builder_tests[%d].\n",
8226                         test_index);
8227                     ok(received == expected,
8228                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8229                         expected, received, test_index);
8230                 }
8231             }
8232         }
8233         if(uri) IUri_Release(uri);
8234     }
8235 }
8236
8237 static void test_IUriBuilder_GetQuery(IUriBuilder *builder, const uri_builder_test *test,
8238                                       DWORD test_index) {
8239     HRESULT hr;
8240     DWORD i;
8241     LPCWSTR received = NULL;
8242     DWORD len = -1;
8243     const uri_builder_property *prop = NULL;
8244
8245     /* Check if the property was set earlier. */
8246     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8247         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_QUERY)
8248             prop = &(test->properties[i]);
8249     }
8250
8251     if(prop) {
8252         /* Use expected_value unless it's NULL, then use value. */
8253         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8254         hr = IUriBuilder_GetQuery(builder, &len, &received);
8255         if(prop->todo) {
8256             todo_wine {
8257                 ok(hr == (expected ? S_OK : S_FALSE),
8258                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8259                     hr, (expected ? S_OK : S_FALSE), test_index);
8260             }
8261             if(SUCCEEDED(hr)) {
8262                 todo_wine {
8263                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8264                         expected, wine_dbgstr_w(received), test_index);
8265                 }
8266                 todo_wine {
8267                     ok(lstrlen(expected) == len,
8268                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8269                         lstrlen(expected), len, test_index);
8270                 }
8271             }
8272         } else {
8273             ok(hr == (expected ? S_OK : S_FALSE),
8274                 "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8275                 hr, (expected ? S_OK : S_FALSE), test_index);
8276             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8277                 expected, wine_dbgstr_w(received), test_index);
8278             ok(lstrlen(expected) == len,
8279                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8280                 lstrlen(expected), len, test_index);
8281         }
8282     } else {
8283         /* The property wasn't set earlier, so it should return whatever
8284          * the base IUri contains (if anything).
8285          */
8286         IUri *uri = NULL;
8287         hr = IUriBuilder_GetIUri(builder, &uri);
8288         ok(hr == S_OK,
8289             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8290             hr, S_OK, test_index);
8291         if(SUCCEEDED(hr)) {
8292             if(!uri) {
8293                 received = (void*) 0xdeadbeef;
8294                 len = -1;
8295
8296                 hr = IUriBuilder_GetQuery(builder, &len, &received);
8297                 ok(hr == S_FALSE,
8298                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8299                     hr, S_FALSE, test_index);
8300                 if(SUCCEEDED(hr)) {
8301                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8302                         len, test_index);
8303                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8304                         received, test_index);
8305                 }
8306             } else {
8307                 BOOL has_prop = FALSE;
8308                 BSTR expected = NULL;
8309
8310                 hr = IUri_GetQuery(uri, &expected);
8311                 ok(SUCCEEDED(hr),
8312                     "Error: Expected IUri_GetQuery to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8313                     hr, test_index);
8314                 has_prop = hr == S_OK;
8315
8316                 hr = IUriBuilder_GetQuery(builder, &len, &received);
8317                 if(has_prop) {
8318                     ok(hr == S_OK,
8319                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8320                         hr, S_OK, test_index);
8321                     if(SUCCEEDED(hr)) {
8322                         ok(!lstrcmpW(expected, received),
8323                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8324                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8325                         ok(lstrlenW(expected) == len,
8326                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8327                             lstrlenW(expected), len, test_index);
8328                     }
8329                 } else {
8330                     ok(hr == S_FALSE,
8331                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8332                         hr, S_FALSE, test_index);
8333                     if(SUCCEEDED(hr)) {
8334                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8335                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8336                             len, test_index);
8337                     }
8338                 }
8339                 SysFreeString(expected);
8340             }
8341         }
8342         if(uri) IUri_Release(uri);
8343     }
8344 }
8345
8346 static void test_IUriBuilder_GetSchemeName(IUriBuilder *builder, const uri_builder_test *test,
8347                                            DWORD test_index) {
8348     HRESULT hr;
8349     DWORD i;
8350     LPCWSTR received = NULL;
8351     DWORD len = -1;
8352     const uri_builder_property *prop = NULL;
8353
8354     /* Check if the property was set earlier. */
8355     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8356         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_SCHEME_NAME)
8357             prop = &(test->properties[i]);
8358     }
8359
8360     if(prop) {
8361         /* Use expected_value unless it's NULL, then use value. */
8362         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8363         hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8364         if(prop->todo) {
8365             todo_wine {
8366                 ok(hr == (expected ? S_OK : S_FALSE),
8367                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8368                     hr, (expected ? S_OK : S_FALSE), test_index);
8369             }
8370             if(SUCCEEDED(hr)) {
8371                 todo_wine {
8372                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8373                         expected, wine_dbgstr_w(received), test_index);
8374                 }
8375                 todo_wine {
8376                     ok(lstrlen(expected) == len,
8377                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8378                         lstrlen(expected), len, test_index);
8379                 }
8380             }
8381         } else {
8382             ok(hr == (expected ? S_OK : S_FALSE),
8383                 "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8384                 hr, (expected ? S_OK : S_FALSE), test_index);
8385             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8386                 expected, wine_dbgstr_w(received), test_index);
8387             ok(lstrlen(expected) == len,
8388                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8389                 lstrlen(expected), len, test_index);
8390         }
8391     } else {
8392         /* The property wasn't set earlier, so it should return whatever
8393          * the base IUri contains (if anything).
8394          */
8395         IUri *uri = NULL;
8396         hr = IUriBuilder_GetIUri(builder, &uri);
8397         ok(hr == S_OK,
8398             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8399             hr, S_OK, test_index);
8400         if(SUCCEEDED(hr)) {
8401             if(!uri) {
8402                 received = (void*) 0xdeadbeef;
8403                 len = -1;
8404
8405                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8406                 ok(hr == S_FALSE,
8407                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8408                     hr, S_FALSE, test_index);
8409                 if(SUCCEEDED(hr)) {
8410                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8411                         len, test_index);
8412                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8413                         received, test_index);
8414                 }
8415             } else {
8416                 BOOL has_prop = FALSE;
8417                 BSTR expected = NULL;
8418
8419                 hr = IUri_GetSchemeName(uri, &expected);
8420                 ok(SUCCEEDED(hr),
8421                     "Error: Expected IUri_GetSchemeName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8422                     hr, test_index);
8423                 has_prop = hr == S_OK;
8424
8425                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8426                 if(has_prop) {
8427                     ok(hr == S_OK,
8428                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8429                         hr, S_OK, test_index);
8430                     if(SUCCEEDED(hr)) {
8431                         ok(!lstrcmpW(expected, received),
8432                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8433                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8434                         ok(lstrlenW(expected) == len,
8435                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8436                             lstrlenW(expected), len, test_index);
8437                     }
8438                 } else {
8439                     ok(hr == S_FALSE,
8440                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8441                         hr, S_FALSE, test_index);
8442                     if(SUCCEEDED(hr)) {
8443                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8444                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8445                             len, test_index);
8446                     }
8447                 }
8448                 SysFreeString(expected);
8449             }
8450         }
8451         if(uri) IUri_Release(uri);
8452     }
8453 }
8454
8455 static void test_IUriBuilder_GetUserName(IUriBuilder *builder, const uri_builder_test *test,
8456                                          DWORD test_index) {
8457     HRESULT hr;
8458     DWORD i;
8459     LPCWSTR received = NULL;
8460     DWORD len = -1;
8461     const uri_builder_property *prop = NULL;
8462
8463     /* Check if the property was set earlier. */
8464     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8465         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_USER_NAME)
8466             prop = &(test->properties[i]);
8467     }
8468
8469     if(prop && prop->value && *prop->value) {
8470         /* Use expected_value unless it's NULL, then use value. */
8471         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8472         hr = IUriBuilder_GetUserName(builder, &len, &received);
8473         if(prop->todo) {
8474             todo_wine {
8475                 ok(hr == (expected ? S_OK : S_FALSE),
8476                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8477                     hr, (expected ? S_OK : S_FALSE), test_index);
8478             }
8479             if(SUCCEEDED(hr)) {
8480                 todo_wine {
8481                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8482                         expected, wine_dbgstr_w(received), test_index);
8483                 }
8484                 todo_wine {
8485                     ok(lstrlen(expected) == len,
8486                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8487                         lstrlen(expected), len, test_index);
8488                 }
8489             }
8490         } else {
8491             ok(hr == (expected ? S_OK : S_FALSE),
8492                 "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8493                 hr, (expected ? S_OK : S_FALSE), test_index);
8494             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8495                 expected, wine_dbgstr_w(received), test_index);
8496             ok(lstrlen(expected) == len,
8497                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8498                 lstrlen(expected), len, test_index);
8499         }
8500     } else {
8501         /* The property wasn't set earlier, so it should return whatever
8502          * the base IUri contains (if anything).
8503          */
8504         IUri *uri = NULL;
8505         hr = IUriBuilder_GetIUri(builder, &uri);
8506         ok(hr == S_OK,
8507             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8508             hr, S_OK, test_index);
8509         if(SUCCEEDED(hr)) {
8510             if(!uri) {
8511                 received = (void*) 0xdeadbeef;
8512                 len = -1;
8513
8514                 hr = IUriBuilder_GetUserName(builder, &len, &received);
8515                 ok(hr == S_FALSE,
8516                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8517                     hr, S_FALSE, test_index);
8518                 if(SUCCEEDED(hr)) {
8519                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8520                         len, test_index);
8521                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8522                         received, test_index);
8523                 }
8524             } else {
8525                 BSTR expected = NULL;
8526                 BOOL has_prop = FALSE;
8527
8528                 hr = IUri_GetUserName(uri, &expected);
8529                 ok(SUCCEEDED(hr),
8530                     "Error: Expected IUri_GetUserName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8531                     hr, test_index);
8532                 has_prop = hr == S_OK;
8533
8534                 hr = IUriBuilder_GetUserName(builder, &len, &received);
8535                 if(has_prop) {
8536                     ok(hr == S_OK,
8537                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8538                         hr, S_OK, test_index);
8539                     if(SUCCEEDED(hr)) {
8540                         ok(!lstrcmpW(expected, received),
8541                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8542                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8543                         ok(lstrlenW(expected) == len,
8544                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8545                             lstrlenW(expected), len, test_index);
8546                     }
8547                 } else {
8548                     ok(hr == S_FALSE,
8549                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8550                         hr, S_FALSE, test_index);
8551                     if(SUCCEEDED(hr)) {
8552                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8553                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8554                             len, test_index);
8555                     }
8556                 }
8557                 SysFreeString(expected);
8558             }
8559         }
8560         if(uri) IUri_Release(uri);
8561     }
8562 }
8563
8564 /* Tests IUriBuilder functions. */
8565 static void test_IUriBuilder(void) {
8566     HRESULT hr;
8567     IUriBuilder *builder;
8568     DWORD i;
8569
8570     for(i = 0; i < sizeof(uri_builder_tests)/sizeof(uri_builder_tests[0]); ++i) {
8571         IUri *uri = NULL;
8572         uri_builder_test test = uri_builder_tests[i];
8573         LPWSTR uriW = NULL;
8574
8575         if(test.uri) {
8576             uriW = a2w(test.uri);
8577             hr = pCreateUri(uriW, test.create_flags, 0, &uri);
8578             ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8579                 hr, S_OK, i);
8580             if(FAILED(hr)) continue;
8581         }
8582         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
8583         if(test.create_builder_todo) {
8584             todo_wine {
8585                 ok(hr == test.create_builder_expected,
8586                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8587                     hr, test.create_builder_expected, i);
8588             }
8589         } else {
8590             ok(hr == test.create_builder_expected,
8591                 "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8592                 hr, test.create_builder_expected, i);
8593         }
8594         if(SUCCEEDED(hr)) {
8595             DWORD j;
8596             BOOL modified = FALSE, received = FALSE;
8597
8598             /* Perform all the string property changes. */
8599             for(j = 0; j < URI_BUILDER_STR_PROPERTY_COUNT; ++j) {
8600                 uri_builder_property prop = test.properties[j];
8601                 if(prop.change) {
8602                     change_property(builder, &prop, i);
8603                     if(prop.property != Uri_PROPERTY_SCHEME_NAME &&
8604                        prop.property != Uri_PROPERTY_HOST)
8605                         modified = TRUE;
8606                     else if(prop.value && *prop.value)
8607                         modified = TRUE;
8608                     else if(prop.value && !*prop.value && prop.property == Uri_PROPERTY_HOST)
8609                         /* Host name property can't be NULL, but it can be empty. */
8610                         modified = TRUE;
8611                 }
8612             }
8613
8614             if(test.port_prop.change) {
8615                 hr = IUriBuilder_SetPort(builder, test.port_prop.set, test.port_prop.value);
8616                 modified = TRUE;
8617                 if(test.port_prop.todo) {
8618                     todo_wine {
8619                         ok(hr == test.port_prop.expected,
8620                             "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8621                             hr, test.port_prop.expected, i);
8622                     }
8623                 } else {
8624                     ok(hr == test.port_prop.expected,
8625                         "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8626                         hr, test.port_prop.expected, i);
8627                 }
8628             }
8629
8630             hr = IUriBuilder_HasBeenModified(builder, &received);
8631             ok(hr == S_OK,
8632                 "Error IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8633                 hr, S_OK, i);
8634             if(SUCCEEDED(hr))
8635                 ok(received == modified,
8636                     "Error: Expected received to be %d but was %d instead on uri_builder_tests[%d].\n",
8637                     modified, received, i);
8638
8639             /* Test the "Get*" functions. */
8640             test_IUriBuilder_GetFragment(builder, &test, i);
8641             test_IUriBuilder_GetHost(builder, &test, i);
8642             test_IUriBuilder_GetPassword(builder, &test, i);
8643             test_IUriBuilder_GetPath(builder, &test, i);
8644             test_IUriBuilder_GetPort(builder, &test, i);
8645             test_IUriBuilder_GetQuery(builder, &test, i);
8646             test_IUriBuilder_GetSchemeName(builder, &test, i);
8647             test_IUriBuilder_GetUserName(builder, &test, i);
8648
8649             test_IUriBuilder_CreateUri(builder, &test, i);
8650             test_IUriBuilder_CreateUriSimple(builder, &test, i);
8651             test_IUriBuilder_CreateUriWithFlags(builder, &test, i);
8652         }
8653         if(builder) IUriBuilder_Release(builder);
8654         if(uri) IUri_Release(uri);
8655         heap_free(uriW);
8656     }
8657 }
8658
8659 static void test_IUriBuilder_HasBeenModified(void) {
8660     HRESULT hr;
8661     IUriBuilder *builder = NULL;
8662
8663     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8664     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8665     if(SUCCEEDED(hr)) {
8666         static const WCHAR hostW[] = {'g','o','o','g','l','e','.','c','o','m',0};
8667         IUri *uri = NULL;
8668         BOOL received;
8669
8670         hr = IUriBuilder_HasBeenModified(builder, NULL);
8671         ok(hr == E_POINTER, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8672             hr, E_POINTER);
8673
8674         hr = IUriBuilder_SetHost(builder, hostW);
8675         ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n",
8676             hr, S_OK);
8677
8678         hr = IUriBuilder_HasBeenModified(builder, &received);
8679         ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8680             hr, S_OK);
8681         if(SUCCEEDED(hr))
8682             ok(received == TRUE, "Error: Expected received to be TRUE.\n");
8683
8684         hr = pCreateUri(http_urlW, 0, 0, &uri);
8685         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8686         if(SUCCEEDED(hr)) {
8687             LPCWSTR prop;
8688             DWORD len = -1;
8689
8690             hr = IUriBuilder_SetIUri(builder, uri);
8691             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n",
8692                 hr, S_OK);
8693
8694             hr = IUriBuilder_HasBeenModified(builder, &received);
8695             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8696                 hr, S_OK);
8697             if(SUCCEEDED(hr))
8698                 ok(received == FALSE, "Error: Expected received to be FALSE.\n");
8699
8700             /* Test what happens with you call SetIUri with the same IUri again. */
8701             hr = IUriBuilder_SetHost(builder, hostW);
8702             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8703
8704             hr = IUriBuilder_HasBeenModified(builder, &received);
8705             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8706                 hr, S_OK);
8707             if(SUCCEEDED(hr))
8708                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
8709
8710             hr = IUriBuilder_SetIUri(builder, uri);
8711             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8712
8713             /* IUriBuilder already had 'uri' as it's IUri property and so Windows doesn't
8714              * reset any of the changes that were made to the IUriBuilder.
8715              */
8716             hr = IUriBuilder_HasBeenModified(builder, &received);
8717             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8718             if(SUCCEEDED(hr))
8719                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
8720
8721             hr = IUriBuilder_GetHost(builder, &len, &prop);
8722             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8723             if(SUCCEEDED(hr)) {
8724                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
8725                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
8726                 ok(len == lstrlenW(hostW), "Error: Expected len to be %d, but was %d instead.\n",
8727                     lstrlenW(hostW), len);
8728             }
8729
8730             hr = IUriBuilder_SetIUri(builder, NULL);
8731             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8732
8733             hr = IUriBuilder_SetHost(builder, hostW);
8734             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8735             hr = IUriBuilder_HasBeenModified(builder, &received);
8736             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8737                 hr, S_OK);
8738             if(SUCCEEDED(hr))
8739                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
8740
8741             hr = IUriBuilder_SetIUri(builder, NULL);
8742             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%09x.\n", hr, S_OK);
8743
8744             hr = IUriBuilder_HasBeenModified(builder, &received);
8745             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8746                 hr, S_OK);
8747             if(SUCCEEDED(hr))
8748                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
8749
8750             hr = IUriBuilder_GetHost(builder, &len, &prop);
8751             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8752             if(SUCCEEDED(hr)) {
8753                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
8754                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
8755                 ok(len == lstrlenW(hostW), "Error: Expected len to %d, but was %d instead.\n",
8756                     lstrlenW(hostW), len);
8757             }
8758         }
8759         if(uri) IUri_Release(uri);
8760     }
8761     if(builder) IUriBuilder_Release(builder);
8762 }
8763
8764 /* Test IUriBuilder {Get,Set}IUri functions. */
8765 static void test_IUriBuilder_IUriProperty(void) {
8766     IUriBuilder *builder = NULL;
8767     HRESULT hr;
8768
8769     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8770     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8771     if(SUCCEEDED(hr)) {
8772         IUri *uri = NULL;
8773
8774         hr = IUriBuilder_GetIUri(builder, NULL);
8775         ok(hr == E_POINTER, "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x.\n",
8776             hr, E_POINTER);
8777
8778         hr = pCreateUri(http_urlW, 0, 0, &uri);
8779         if(SUCCEEDED(hr)) {
8780             IUri *test = NULL;
8781             ULONG cur_count, orig_count;
8782
8783             /* IUriBuilder doesn't clone the IUri, it use the same IUri. */
8784             orig_count = get_refcnt(uri);
8785             hr = IUriBuilder_SetIUri(builder, uri);
8786             cur_count = get_refcnt(uri);
8787             if(SUCCEEDED(hr))
8788                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8789                     orig_count+1, cur_count);
8790
8791             hr = IUriBuilder_SetIUri(builder, NULL);
8792             cur_count = get_refcnt(uri);
8793             if(SUCCEEDED(hr))
8794                 ok(cur_count == orig_count, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8795                     orig_count, cur_count);
8796
8797             /* CreateUri* functions will return back the same IUri if nothing has changed. */
8798             hr = IUriBuilder_SetIUri(builder, uri);
8799             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8800             orig_count = get_refcnt(uri);
8801
8802             hr = IUriBuilder_CreateUri(builder, 0, 0, 0, &test);
8803             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8804             if(SUCCEEDED(hr)) {
8805                 cur_count = get_refcnt(uri);
8806                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8807                     orig_count+1, cur_count);
8808                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n",
8809                     uri, test);
8810             }
8811             if(test) IUri_Release(test);
8812
8813             test = NULL;
8814             hr = IUriBuilder_CreateUri(builder, -1, 0, 0, &test);
8815             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8816             if(SUCCEEDED(hr)) {
8817                 cur_count = get_refcnt(uri);
8818                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8819                     orig_count+1, cur_count);
8820                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
8821             }
8822             if(test) IUri_Release(test);
8823
8824             /* Doesn't return the same IUri, if the flag combination is different then the one that created
8825              * the base IUri.
8826              */
8827             test = NULL;
8828             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, &test);
8829             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8830             if(SUCCEEDED(hr))
8831                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
8832
8833             if(test) IUri_Release(test);
8834
8835             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
8836              * explicitly set (because it's a default flags).
8837              */
8838             test = NULL;
8839             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_CANONICALIZE, 0, 0, &test);
8840             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8841             if(SUCCEEDED(hr)) {
8842                 cur_count = get_refcnt(uri);
8843                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8844                     orig_count+1, cur_count);
8845                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
8846             }
8847             if(test) IUri_Release(test);
8848
8849             test = NULL;
8850             hr = IUriBuilder_CreateUriSimple(builder, 0, 0, &test);
8851             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8852             if(SUCCEEDED(hr)) {
8853                 cur_count = get_refcnt(uri);
8854                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8855                     orig_count+1, cur_count);
8856                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
8857             }
8858             if(test) IUri_Release(test);
8859
8860             test = NULL;
8861             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &test);
8862             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8863                 hr, S_OK);
8864             if(SUCCEEDED(hr)) {
8865                 cur_count = get_refcnt(uri);
8866                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8867                     orig_count+1, cur_count);
8868                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
8869             }
8870             if(test) IUri_Release(test);
8871
8872             /* Doesn't return the same IUri, if the flag combination is different then the one that created
8873              * the base IUri.
8874              */
8875             test = NULL;
8876             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, 0, &test);
8877             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8878             if(SUCCEEDED(hr))
8879                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
8880
8881             if(test) IUri_Release(test);
8882
8883             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
8884              * explicitly set (because it's a default flags).
8885              */
8886             test = NULL;
8887             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_CANONICALIZE, 0, 0, 0, &test);
8888             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8889             if(SUCCEEDED(hr)) {
8890                 cur_count = get_refcnt(uri);
8891                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8892                     orig_count+1, cur_count);
8893                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
8894             }
8895             if(test) IUri_Release(test);
8896         }
8897         if(uri) IUri_Release(uri);
8898     }
8899     if(builder) IUriBuilder_Release(builder);
8900 }
8901
8902 static void test_IUriBuilder_RemoveProperties(void) {
8903     IUriBuilder *builder = NULL;
8904     HRESULT hr;
8905     DWORD i;
8906
8907     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8908     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8909     if(SUCCEEDED(hr)) {
8910         /* Properties that can't be removed. */
8911         const DWORD invalid = Uri_HAS_ABSOLUTE_URI|Uri_HAS_DISPLAY_URI|Uri_HAS_RAW_URI|Uri_HAS_HOST_TYPE|
8912                               Uri_HAS_SCHEME|Uri_HAS_ZONE;
8913
8914         for(i = Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_DWORD_LAST; ++i) {
8915             hr = IUriBuilder_RemoveProperties(builder, i << 1);
8916             if((i << 1) & invalid) {
8917                 ok(hr == E_INVALIDARG,
8918                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
8919                     hr, E_INVALIDARG, i);
8920             } else {
8921                 ok(hr == S_OK,
8922                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
8923                     hr, S_OK, i);
8924             }
8925         }
8926
8927         /* Also doesn't accept anything that's outside the range of the
8928          * Uri_HAS flags.
8929          */
8930         hr = IUriBuilder_RemoveProperties(builder, (Uri_PROPERTY_DWORD_LAST+1) << 1);
8931         ok(hr == E_INVALIDARG, "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x.\n",
8932             hr, E_INVALIDARG);
8933     }
8934     if(builder) IUriBuilder_Release(builder);
8935
8936     for(i = 0; i < sizeof(uri_builder_remove_tests)/sizeof(uri_builder_remove_tests[0]); ++i) {
8937         uri_builder_remove_test test = uri_builder_remove_tests[i];
8938         IUri *uri = NULL;
8939         LPWSTR uriW;
8940
8941         uriW = a2w(test.uri);
8942         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
8943         if(SUCCEEDED(hr)) {
8944             builder = NULL;
8945
8946             hr = pCreateIUriBuilder(uri, 0, 0, &builder);
8947             if(test.create_builder_todo) {
8948                 todo_wine {
8949                     ok(hr == test.create_builder_expected,
8950                         "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
8951                         hr, test.create_builder_expected, i);
8952                 }
8953             } else {
8954                 ok(hr == test.create_builder_expected,
8955                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
8956                     hr, test.create_builder_expected, i);
8957             }
8958             if(SUCCEEDED(hr)) {
8959                 hr = IUriBuilder_RemoveProperties(builder, test.remove_properties);
8960                 if(test.remove_todo) {
8961                     todo_wine {
8962                         ok(hr == test.remove_expected,
8963                             "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x on test %d.\n",
8964                             hr, test.remove_expected, i);
8965                     }
8966                 } else {
8967                     ok(hr == test.remove_expected,
8968                         "Error: IUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
8969                         hr, test.remove_expected, i);
8970                 }
8971                 if(SUCCEEDED(hr)) {
8972                     IUri *result = NULL;
8973
8974                     hr = IUriBuilder_CreateUri(builder, test.expected_flags, 0, 0, &result);
8975                     if(test.expected_todo) {
8976                         todo_wine {
8977                             ok(hr == test.expected_hres,
8978                                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
8979                                 hr, test.expected_hres, i);
8980                         }
8981                     } else {
8982                         ok(hr == test.expected_hres,
8983                             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
8984                             hr, test.expected_hres, i);
8985                     }
8986                     if(SUCCEEDED(hr)) {
8987                         BSTR received = NULL;
8988
8989                         hr = IUri_GetAbsoluteUri(result, &received);
8990                         ok(!strcmp_aw(test.expected_uri, received),
8991                             "Error: Expected %s but got %s instead on test %d.\n",
8992                             test.expected_uri, wine_dbgstr_w(received), i);
8993                         SysFreeString(received);
8994                     }
8995                     if(result) IUri_Release(result);
8996                 }
8997             }
8998             if(builder) IUriBuilder_Release(builder);
8999         }
9000         if(uri) IUri_Release(uri);
9001         heap_free(uriW);
9002     }
9003 }
9004
9005 static void test_IUriBuilder_Misc(void) {
9006     HRESULT hr;
9007     IUri *uri;
9008
9009     hr = pCreateUri(http_urlW, 0, 0, &uri);
9010     if(SUCCEEDED(hr)) {
9011         IUriBuilder *builder;
9012
9013         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9014         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9015         if(SUCCEEDED(hr)) {
9016             BOOL has = -1;
9017             DWORD port = -1;
9018
9019             hr = IUriBuilder_GetPort(builder, &has, &port);
9020             ok(hr == S_OK, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9021             if(SUCCEEDED(hr)) {
9022                 /* 'has' will be set to FALSE, even though uri had a port. */
9023                 ok(has == FALSE, "Error: Expected 'has' to be FALSE, was %d instead.\n", has);
9024                 /* Still sets 'port' to 80. */
9025                 ok(port == 80, "Error: Expected the port to be 80, but, was %d instead.\n", port);
9026             }
9027         }
9028         if(builder) IUriBuilder_Release(builder);
9029     }
9030     if(uri) IUri_Release(uri);
9031 }
9032
9033 static void test_CoInternetCombineIUri(void) {
9034     HRESULT hr;
9035     IUri *base, *relative, *result;
9036     DWORD i;
9037
9038     base = NULL;
9039     hr = pCreateUri(http_urlW, 0, 0, &base);
9040     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9041     if(SUCCEEDED(hr)) {
9042         result = (void*) 0xdeadbeef;
9043         hr = pCoInternetCombineIUri(base, NULL, 0, &result, 0);
9044         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9045         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9046     }
9047
9048     relative = NULL;
9049     hr = pCreateUri(http_urlW, 0, 0, &relative);
9050     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9051     if(SUCCEEDED(hr)) {
9052         result = (void*) 0xdeadbeef;
9053         hr = pCoInternetCombineIUri(NULL, relative, 0, &result, 0);
9054         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9055         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9056     }
9057
9058     hr = pCoInternetCombineIUri(base, relative, 0, NULL, 0);
9059     ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9060
9061     if(base) IUri_Release(base);
9062     if(relative) IUri_Release(relative);
9063
9064     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
9065         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
9066
9067         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
9068         ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9069         if(SUCCEEDED(hr)) {
9070             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
9071
9072             hr = pCreateUri(relativeW, uri_combine_tests[i].relative_create_flags, 0, &relative);
9073             ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9074             if(SUCCEEDED(hr)) {
9075                 result = NULL;
9076
9077                 hr = pCoInternetCombineIUri(base, relative, uri_combine_tests[i].combine_flags, &result, 0);
9078                 if(uri_combine_tests[i].todo) {
9079                     todo_wine {
9080                         ok(hr == uri_combine_tests[i].expected,
9081                             "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9082                             hr, uri_combine_tests[i].expected, i);
9083                     }
9084                 } else {
9085                     ok(hr == uri_combine_tests[i].expected,
9086                         "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9087                         hr, uri_combine_tests[i]. expected, i);
9088                 }
9089                 if(SUCCEEDED(hr)) {
9090                     DWORD j;
9091
9092                     for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
9093                         uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
9094                         BSTR received;
9095
9096                         hr = IUri_GetPropertyBSTR(result, j, &received, 0);
9097                         if(prop.todo) {
9098                             todo_wine {
9099                                 ok(hr == prop.expected,
9100                                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9101                                     hr, prop.expected, i, j);
9102                             }
9103                             todo_wine {
9104                                 ok(!strcmp_aw(prop.value, received) ||
9105                                    broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9106                                     "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9107                                     prop.value, wine_dbgstr_w(received), i, j);
9108                             }
9109                         } else {
9110                             ok(hr == prop.expected,
9111                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9112                                 hr, prop.expected, i, j);
9113                             ok(!strcmp_aw(prop.value, received) ||
9114                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9115                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9116                                 prop.value, wine_dbgstr_w(received), i, j);
9117                         }
9118                         SysFreeString(received);
9119                     }
9120
9121                     for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
9122                         uri_dword_property prop = uri_combine_tests[i].dword_props[j];
9123                         DWORD received;
9124
9125                         hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
9126                         if(prop.todo) {
9127                             todo_wine {
9128                                 ok(hr == prop.expected,
9129                                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9130                                     hr, prop.expected, i, j);
9131                             }
9132                             todo_wine {
9133                                 ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9134                                     prop.value, received, i, j);
9135                             }
9136                         } else {
9137                             ok(hr == prop.expected,
9138                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9139                                 hr, prop.expected, i, j);
9140                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9141                                 prop.value, received, i, j);
9142                         }
9143                     }
9144                 }
9145                 if(result) IUri_Release(result);
9146             }
9147             if(relative) IUri_Release(relative);
9148             heap_free(relativeW);
9149         }
9150         if(base) IUri_Release(base);
9151         heap_free(baseW);
9152     }
9153 }
9154
9155 static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface,
9156                                                           REFIID riid, void **ppv)
9157 {
9158     ok(0, "unexpected call\n");
9159     return E_NOINTERFACE;
9160 }
9161
9162 static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
9163 {
9164     return 2;
9165 }
9166
9167 static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
9168 {
9169     return 1;
9170 }
9171
9172 static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
9173         PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
9174         DWORD *pcchResult, DWORD dwReserved)
9175 {
9176     ok(0, "unexpected call %d\n", ParseAction);
9177     return E_NOTIMPL;
9178 }
9179
9180 static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
9181         LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags,
9182         LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
9183 {
9184     CHECK_EXPECT(CombineUrl);
9185     ok(!lstrcmpW(pwzBaseUrl, combine_baseW), "Error: Expected %s, but got %s instead.\n",
9186         wine_dbgstr_w(combine_baseW), wine_dbgstr_w(pwzBaseUrl));
9187     ok(!lstrcmpW(pwzRelativeUrl, combine_relativeW), "Error: Expected %s, but got %s instead.\n",
9188         wine_dbgstr_w(combine_relativeW), wine_dbgstr_w(pwzRelativeUrl));
9189     ok(dwCombineFlags == (URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO),
9190         "Error: Expected 0, but got 0x%08x.\n", dwCombineFlags);
9191     ok(cchResult == INTERNET_MAX_URL_LENGTH+1, "Error: Got %d.\n", cchResult);
9192
9193     memcpy(pwzResult, combine_resultW, sizeof(combine_resultW));
9194     *pcchResult = lstrlenW(combine_resultW);
9195
9196     return S_OK;
9197 }
9198
9199 static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface,
9200         LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
9201 {
9202     ok(0, "unexpected call\n");
9203     return E_NOTIMPL;
9204 }
9205
9206 static HRESULT WINAPI InternetProtocolInfo_QueryInfo(IInternetProtocolInfo *iface,
9207         LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer,
9208         DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
9209 {
9210     ok(0, "unexpected call\n");
9211     return E_NOTIMPL;
9212 }
9213
9214 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl = {
9215     InternetProtocolInfo_QueryInterface,
9216     InternetProtocolInfo_AddRef,
9217     InternetProtocolInfo_Release,
9218     InternetProtocolInfo_ParseUrl,
9219     InternetProtocolInfo_CombineUrl,
9220     InternetProtocolInfo_CompareUrl,
9221     InternetProtocolInfo_QueryInfo
9222 };
9223
9224 static IInternetProtocolInfo protocol_info = { &InternetProtocolInfoVtbl };
9225
9226 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
9227 {
9228     if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
9229         *ppv = &protocol_info;
9230         return S_OK;
9231     }
9232
9233     ok(0, "unexpected call\n");
9234     return E_NOINTERFACE;
9235 }
9236
9237 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
9238 {
9239     return 2;
9240 }
9241
9242 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
9243 {
9244     return 1;
9245 }
9246
9247 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
9248                                         REFIID riid, void **ppv)
9249 {
9250     ok(0, "unexpected call\n");
9251     return E_NOTIMPL;
9252 }
9253
9254 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
9255 {
9256     ok(0, "unexpected call\n");
9257     return S_OK;
9258 }
9259
9260 static const IClassFactoryVtbl ClassFactoryVtbl = {
9261     ClassFactory_QueryInterface,
9262     ClassFactory_AddRef,
9263     ClassFactory_Release,
9264     ClassFactory_CreateInstance,
9265     ClassFactory_LockServer
9266 };
9267
9268 static IClassFactory protocol_cf = { &ClassFactoryVtbl };
9269
9270 static void register_protocols(void)
9271 {
9272     IInternetSession *session;
9273     HRESULT hres;
9274
9275     hres = pCoInternetGetSession(0, &session, 0);
9276     ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
9277     if(FAILED(hres))
9278         return;
9279
9280     hres = IInternetSession_RegisterNameSpace(session, &protocol_cf, &IID_NULL,
9281             winetestW, 0, NULL, 0);
9282     ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
9283
9284     IInternetSession_Release(session);
9285 }
9286
9287 static void unregister_protocols(void) {
9288     IInternetSession *session;
9289     HRESULT hr;
9290
9291     hr = pCoInternetGetSession(0, &session, 0);
9292     ok(hr == S_OK, "CoInternetGetSession failed: 0x%08x\n", hr);
9293     if(FAILED(hr))
9294         return;
9295
9296     hr = IInternetSession_UnregisterNameSpace(session, &protocol_cf, winetestW);
9297     ok(hr == S_OK, "UnregisterNameSpace failed: 0x%08x\n", hr);
9298
9299     IInternetSession_Release(session);
9300 }
9301
9302 static void test_CoInternetCombineIUri_Pluggable(void) {
9303     HRESULT hr;
9304     IUri *base = NULL;
9305
9306     hr = pCreateUri(combine_baseW, 0, 0, &base);
9307     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9308     if(SUCCEEDED(hr)) {
9309         IUri *relative = NULL;
9310
9311         hr = pCreateUri(combine_relativeW, Uri_CREATE_ALLOW_RELATIVE, 0, &relative);
9312         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9313         if(SUCCEEDED(hr)) {
9314             IUri *result = NULL;
9315
9316             SET_EXPECT(CombineUrl);
9317
9318             hr = pCoInternetCombineIUri(base, relative, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
9319                                         &result, 0);
9320             ok(hr == S_OK, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9321
9322             CHECK_CALLED(CombineUrl);
9323
9324             if(SUCCEEDED(hr)) {
9325                 BSTR received = NULL;
9326                 hr = IUri_GetAbsoluteUri(result, &received);
9327                 ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
9328                 if(SUCCEEDED(hr)) {
9329                     ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
9330                         wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
9331                 }
9332                 SysFreeString(received);
9333             }
9334             if(result) IUri_Release(result);
9335         }
9336         if(relative) IUri_Release(relative);
9337     }
9338     if(base) IUri_Release(base);
9339 }
9340
9341 static void test_CoInternetCombineUrlEx(void) {
9342     HRESULT hr;
9343     IUri *base, *result;
9344     DWORD i;
9345
9346     base = NULL;
9347     hr = pCreateUri(http_urlW, 0, 0, &base);
9348     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9349     if(SUCCEEDED(hr)) {
9350         result = (void*) 0xdeadbeef;
9351         hr = pCoInternetCombineUrlEx(base, NULL, 0, &result, 0);
9352         ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9353             hr, E_UNEXPECTED);
9354         ok(!result, "Error: Expected 'result' to be NULL was %p instead.\n", result);
9355     }
9356
9357     result = (void*) 0xdeadbeef;
9358     hr = pCoInternetCombineUrlEx(NULL, http_urlW, 0, &result, 0);
9359     ok(hr == E_INVALIDARG, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9360         hr, E_INVALIDARG);
9361     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
9362
9363     result = (void*) 0xdeadbeef;
9364     hr = pCoInternetCombineUrlEx(NULL, NULL, 0, &result, 0);
9365     ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9366         hr, E_UNEXPECTED);
9367     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
9368
9369     hr = pCoInternetCombineUrlEx(base, http_urlW, 0, NULL, 0);
9370     ok(hr == E_POINTER, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9371         hr, E_POINTER);
9372     if(base) IUri_Release(base);
9373
9374     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
9375         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
9376
9377         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
9378         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_combine_tests[%d].\n", hr, i);
9379         if(SUCCEEDED(hr)) {
9380             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
9381
9382             hr = pCoInternetCombineUrlEx(base, relativeW, uri_combine_tests[i].combine_flags,
9383                                          &result, 0);
9384             if(uri_combine_tests[i].todo) {
9385                 todo_wine {
9386                     ok(hr == uri_combine_tests[i].expected,
9387                         "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9388                         hr, uri_combine_tests[i].expected, i);
9389                 }
9390             } else {
9391                 ok(hr == uri_combine_tests[i].expected,
9392                     "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9393                     hr, uri_combine_tests[i]. expected, i);
9394             }
9395             if(SUCCEEDED(hr)) {
9396                 DWORD j;
9397
9398                 for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
9399                     uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
9400                     BSTR received;
9401                     LPCSTR value = (prop.value_ex) ? prop.value_ex : prop.value;
9402
9403                     hr = IUri_GetPropertyBSTR(result, j, &received, 0);
9404                     if(prop.todo) {
9405                         todo_wine {
9406                             ok(hr == prop.expected,
9407                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9408                                 hr, prop.expected, i, j);
9409                         }
9410                         todo_wine {
9411                             ok(!strcmp_aw(value, received) ||
9412                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9413                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9414                                 value, wine_dbgstr_w(received), i, j);
9415                         }
9416                     } else {
9417                         ok(hr == prop.expected,
9418                             "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9419                             hr, prop.expected, i, j);
9420                         ok(!strcmp_aw(value, received) ||
9421                            broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9422                             "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9423                             value, wine_dbgstr_w(received), i, j);
9424                     }
9425                     SysFreeString(received);
9426                 }
9427
9428                 for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
9429                     uri_dword_property prop = uri_combine_tests[i].dword_props[j];
9430                     DWORD received;
9431
9432                     hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
9433                     if(prop.todo) {
9434                         todo_wine {
9435                             ok(hr == prop.expected,
9436                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9437                                 hr, prop.expected, i, j);
9438                         }
9439                         todo_wine {
9440                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9441                                 prop.value, received, i, j);
9442                         }
9443                     } else {
9444                         ok(hr == prop.expected,
9445                             "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9446                             hr, prop.expected, i, j);
9447                         ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9448                             prop.value, received, i, j);
9449                     }
9450                 }
9451             }
9452             if(result) IUri_Release(result);
9453             heap_free(relativeW);
9454         }
9455         if(base) IUri_Release(base);
9456         heap_free(baseW);
9457     }
9458 }
9459
9460 static void test_CoInternetCombineUrlEx_Pluggable(void) {
9461     HRESULT hr;
9462     IUri *base = NULL;
9463
9464     hr = pCreateUri(combine_baseW, 0, 0, &base);
9465     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9466     if(SUCCEEDED(hr)) {
9467         IUri *result = NULL;
9468
9469         SET_EXPECT(CombineUrl);
9470
9471         hr = pCoInternetCombineUrlEx(base, combine_relativeW, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
9472                                      &result, 0);
9473         ok(hr == S_OK, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9474
9475         CHECK_CALLED(CombineUrl);
9476
9477         if(SUCCEEDED(hr)) {
9478             BSTR received = NULL;
9479             hr = IUri_GetAbsoluteUri(result, &received);
9480             ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
9481             if(SUCCEEDED(hr)) {
9482                 ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
9483                     wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
9484             }
9485             SysFreeString(received);
9486         }
9487         if(result) IUri_Release(result);
9488     }
9489     if(base) IUri_Release(base);
9490 }
9491
9492 static void test_CoInternetParseIUri_InvalidArgs(void) {
9493     HRESULT hr;
9494     IUri *uri = NULL;
9495     WCHAR tmp[3];
9496     DWORD result = -1;
9497
9498     hr = pCoInternetParseIUri(NULL, PARSE_CANONICALIZE, 0, tmp, 3, &result, 0);
9499     ok(hr == E_INVALIDARG, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9500         hr, E_INVALIDARG);
9501     ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9502
9503     hr = pCreateUri(http_urlW, 0, 0, &uri);
9504     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9505     if(SUCCEEDED(hr)) {
9506         DWORD expected_len;
9507
9508         result = -1;
9509         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, NULL, 0, &result, 0);
9510         ok(hr == E_INVALIDARG, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9511             hr, E_INVALIDARG);
9512         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9513
9514         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, tmp, 3, NULL, 0);
9515         ok(hr == E_POINTER, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9516             hr, E_POINTER);
9517
9518         result = -1;
9519         hr = pCoInternetParseIUri(uri, PARSE_SECURITY_URL, 0, tmp, 3, &result, 0);
9520         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x expected 0x%08x.\n",
9521             hr, E_FAIL);
9522         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9523
9524         result = -1;
9525         hr = pCoInternetParseIUri(uri, PARSE_MIME, 0, tmp, 3, &result, 0);
9526         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9527             hr, E_FAIL);
9528         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9529
9530         result = -1;
9531         hr = pCoInternetParseIUri(uri, PARSE_SERVER, 0, tmp, 3, &result, 0);
9532         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9533             hr, E_FAIL);
9534         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9535
9536         result = -1;
9537         hr = pCoInternetParseIUri(uri, PARSE_SECURITY_DOMAIN, 0, tmp, 3, &result, 0);
9538         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9539             hr, E_FAIL);
9540         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9541
9542         expected_len = lstrlenW(http_urlW);
9543         result = -1;
9544         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, tmp, 3, &result, 0);
9545         ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER,
9546             "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9547             hr, STRSAFE_E_INSUFFICIENT_BUFFER);
9548         ok(result == expected_len, "Error: Expected 'result' to be %d, but was %d instead.\n",
9549             expected_len, result);
9550     }
9551     if(uri) IUri_Release(uri);
9552 }
9553
9554 static void test_CoInternetParseIUri(void) {
9555     DWORD i;
9556
9557     for(i = 0; i < sizeof(uri_parse_tests)/sizeof(uri_parse_tests[0]); ++i) {
9558         HRESULT hr;
9559         IUri *uri;
9560         LPWSTR uriW;
9561         uri_parse_test test = uri_parse_tests[i];
9562
9563         uriW = a2w(test.uri);
9564         hr = pCreateUri(uriW, test.uri_flags, 0, &uri);
9565         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_parse_tests[%d].\n", hr, i);
9566         if(SUCCEEDED(hr)) {
9567             WCHAR result[INTERNET_MAX_URL_LENGTH+1];
9568             DWORD result_len = -1;
9569
9570             hr = pCoInternetParseIUri(uri, test.action, test.flags, result, INTERNET_MAX_URL_LENGTH+1, &result_len, 0);
9571             if(test.todo) {
9572                 todo_wine {
9573                     ok(hr == test.expected,
9574                         "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x on uri_parse_tests[%d].\n",
9575                         hr, test.expected, i);
9576                 }
9577             } else {
9578                 ok(hr == test.expected,
9579                     "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x on uri_parse_tests[%d].\n",
9580                     hr, test.expected, i);
9581             }
9582             if(SUCCEEDED(hr)) {
9583                 DWORD len = lstrlenA(test.property);
9584                 ok(!strcmp_aw(test.property, result),
9585                     "Error: Expected %s but got %s instead on uri_parse_tests[%d].\n",
9586                     test.property, wine_dbgstr_w(result), i);
9587                 ok(len == result_len,
9588                     "Error: Expected %d, but got %d instead on uri_parse_tests[%d].\n",
9589                     len, result_len, i);
9590             } else {
9591                 ok(!result_len,
9592                     "Error: Expected 'result_len' to be 0, but was %d on uri_parse_tests[%d].\n",
9593                     result_len, i);
9594             }
9595         }
9596         if(uri) IUri_Release(uri);
9597         heap_free(uriW);
9598     }
9599 }
9600
9601 START_TEST(uri) {
9602     HMODULE hurlmon;
9603
9604     hurlmon = GetModuleHandle("urlmon.dll");
9605     pCoInternetGetSession = (void*) GetProcAddress(hurlmon, "CoInternetGetSession");
9606     pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri");
9607     pCreateUriWithFragment = (void*) GetProcAddress(hurlmon, "CreateUriWithFragment");
9608     pCreateIUriBuilder = (void*) GetProcAddress(hurlmon, "CreateIUriBuilder");
9609     pCoInternetCombineIUri = (void*) GetProcAddress(hurlmon, "CoInternetCombineIUri");
9610     pCoInternetCombineUrlEx = (void*) GetProcAddress(hurlmon, "CoInternetCombineUrlEx");
9611     pCoInternetParseIUri = (void*) GetProcAddress(hurlmon, "CoInternetParseIUri");
9612
9613     if(!pCreateUri) {
9614         win_skip("CreateUri is not present, skipping tests.\n");
9615         return;
9616     }
9617
9618     trace("test CreateUri invalid flags...\n");
9619     test_CreateUri_InvalidFlags();
9620
9621     trace("test CreateUri invalid args...\n");
9622     test_CreateUri_InvalidArgs();
9623
9624     trace("test CreateUri invalid URIs...\n");
9625     test_CreateUri_InvalidUri();
9626
9627     trace("test IUri_GetPropertyBSTR...\n");
9628     test_IUri_GetPropertyBSTR();
9629
9630     trace("test IUri_GetPropertyDWORD...\n");
9631     test_IUri_GetPropertyDWORD();
9632
9633     trace("test IUri_GetStrProperties...\n");
9634     test_IUri_GetStrProperties();
9635
9636     trace("test IUri_GetDwordProperties...\n");
9637     test_IUri_GetDwordProperties();
9638
9639     trace("test IUri_GetPropertyLength...\n");
9640     test_IUri_GetPropertyLength();
9641
9642     trace("test IUri_GetProperties...\n");
9643     test_IUri_GetProperties();
9644
9645     trace("test IUri_HasProperty...\n");
9646     test_IUri_HasProperty();
9647
9648     trace("test IUri_IsEqual...\n");
9649     test_IUri_IsEqual();
9650
9651     trace("test CreateUriWithFragment invalid args...\n");
9652     test_CreateUriWithFragment_InvalidArgs();
9653
9654     trace("test CreateUriWithFragment invalid flags...\n");
9655     test_CreateUriWithFragment_InvalidFlags();
9656
9657     trace("test CreateUriWithFragment...\n");
9658     test_CreateUriWithFragment();
9659
9660     trace("test CreateIUriBuilder...\n");
9661     test_CreateIUriBuilder();
9662
9663     trace("test IUriBuilder_CreateInvalidArgs...\n");
9664     test_IUriBuilder_CreateInvalidArgs();
9665
9666     trace("test IUriBuilder...\n");
9667     test_IUriBuilder();
9668
9669     trace("test IUriBuilder_GetInvalidArgs...\n");
9670     test_IUriBuilder_GetInvalidArgs();
9671
9672     trace("test IUriBuilder_HasBeenModified...\n");
9673     test_IUriBuilder_HasBeenModified();
9674
9675     trace("test IUriBuilder_IUriProperty...\n");
9676     test_IUriBuilder_IUriProperty();
9677
9678     trace("test IUriBuilder_RemoveProperties...\n");
9679     test_IUriBuilder_RemoveProperties();
9680
9681     trace("test IUriBuilder miscellaneous...\n");
9682     test_IUriBuilder_Misc();
9683
9684     trace("test CoInternetCombineIUri...\n");
9685     test_CoInternetCombineIUri();
9686
9687     trace("test CoInternetCombineUrlEx...\n");
9688     test_CoInternetCombineUrlEx();
9689
9690     trace("test CoInternetParseIUri Invalid Args...\n");
9691     test_CoInternetParseIUri_InvalidArgs();
9692
9693     trace("test CoInternetParseIUri...\n");
9694     test_CoInternetParseIUri();
9695
9696     register_protocols();
9697
9698     trace("test CoInternetCombineIUri pluggable...\n");
9699     test_CoInternetCombineIUri_Pluggable();
9700
9701     trace("test CoInternetCombineUrlEx Pluggable...\n");
9702     test_CoInternetCombineUrlEx_Pluggable();
9703
9704     unregister_protocols();
9705 }