advapi32: Added support for SERVICE_CONFIG_PRESHUTDOWN_INFO.
[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 DEFINE_EXPECT(ParseUrl);
66
67 static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**);
68 static HRESULT (WINAPI *pCreateUriWithFragment)(LPCWSTR, LPCWSTR, DWORD, DWORD_PTR, IUri**);
69 static HRESULT (WINAPI *pCreateIUriBuilder)(IUri*, DWORD, DWORD_PTR, IUriBuilder**);
70 static HRESULT (WINAPI *pCoInternetCombineIUri)(IUri*,IUri*,DWORD,IUri**,DWORD_PTR);
71 static HRESULT (WINAPI *pCoInternetGetSession)(DWORD,IInternetSession**,DWORD);
72 static HRESULT (WINAPI *pCoInternetCombineUrlEx)(IUri*,LPCWSTR,DWORD,IUri**,DWORD_PTR);
73 static HRESULT (WINAPI *pCoInternetParseIUri)(IUri*,PARSEACTION,DWORD,LPWSTR,DWORD,DWORD*,DWORD_PTR);
74 static HRESULT (WINAPI *pCreateURLMonikerEx)(IMoniker*,LPCWSTR,IMoniker**,DWORD);
75 static HRESULT (WINAPI *pCreateURLMonikerEx2)(IMoniker*,IUri*,IMoniker**,DWORD);
76
77 static const WCHAR http_urlW[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
78         '.','o','r','g','/',0};
79 static const WCHAR http_url_fragW[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
80         '.','o','r','g','/','#','F','r','a','g',0};
81
82 static const WCHAR combine_baseW[] = {'w','i','n','e','t','e','s','t',':','?','t',
83         'e','s','t','i','n','g',0};
84 static const WCHAR combine_relativeW[] = {'?','t','e','s','t',0};
85 static const WCHAR combine_resultW[] = {'z','i','p',':','t','e','s','t',0};
86
87 static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0};
88
89 static const WCHAR parse_urlW[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t',0};
90 static const WCHAR parse_resultW[] = {'z','i','p',':','t','e','s','t',0};
91
92 static PARSEACTION parse_action;
93 static DWORD parse_flags;
94
95 typedef struct _uri_create_flag_test {
96     DWORD   flags;
97     HRESULT expected;
98 } uri_create_flag_test;
99
100 static const uri_create_flag_test invalid_flag_tests[] = {
101     /* Set of invalid flag combinations to test for. */
102     {Uri_CREATE_DECODE_EXTRA_INFO | Uri_CREATE_NO_DECODE_EXTRA_INFO, E_INVALIDARG},
103     {Uri_CREATE_CANONICALIZE | Uri_CREATE_NO_CANONICALIZE, E_INVALIDARG},
104     {Uri_CREATE_CRACK_UNKNOWN_SCHEMES | Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, E_INVALIDARG},
105     {Uri_CREATE_PRE_PROCESS_HTML_URI | Uri_CREATE_NO_PRE_PROCESS_HTML_URI, E_INVALIDARG},
106     {Uri_CREATE_IE_SETTINGS | Uri_CREATE_NO_IE_SETTINGS, E_INVALIDARG}
107 };
108
109 typedef struct _uri_str_property {
110     const char* value;
111     HRESULT     expected;
112     BOOL        todo;
113     const char* broken_value;
114 } uri_str_property;
115
116 typedef struct _uri_dword_property {
117     DWORD   value;
118     HRESULT expected;
119     BOOL    todo;
120 } uri_dword_property;
121
122 typedef struct _uri_properties {
123     const char*         uri;
124     DWORD               create_flags;
125     HRESULT             create_expected;
126     BOOL                create_todo;
127
128     uri_str_property    str_props[URI_STR_PROPERTY_COUNT];
129     uri_dword_property  dword_props[URI_DWORD_PROPERTY_COUNT];
130 } uri_properties;
131
132 static const uri_properties uri_tests[] = {
133     {   "http://www.winehq.org/tests/../tests/../..", 0, S_OK, FALSE,
134         {
135             {"http://www.winehq.org/",S_OK,FALSE},                      /* ABSOLUTE_URI */
136             {"www.winehq.org",S_OK,FALSE},                              /* AUTHORITY */
137             {"http://www.winehq.org/",S_OK,FALSE},                      /* DISPLAY_URI */
138             {"winehq.org",S_OK,FALSE},                                  /* DOMAIN */
139             {"",S_FALSE,FALSE},                                         /* EXTENSION */
140             {"",S_FALSE,FALSE},                                         /* FRAGMENT */
141             {"www.winehq.org",S_OK,FALSE},                              /* HOST */
142             {"",S_FALSE,FALSE},                                         /* PASSWORD */
143             {"/",S_OK,FALSE},                                           /* PATH */
144             {"/",S_OK,FALSE},                                           /* PATH_AND_QUERY */
145             {"",S_FALSE,FALSE},                                         /* QUERY */
146             {"http://www.winehq.org/tests/../tests/../..",S_OK,FALSE},  /* RAW_URI */
147             {"http",S_OK,FALSE},                                        /* SCHEME_NAME */
148             {"",S_FALSE,FALSE},                                         /* USER_INFO */
149             {"",S_FALSE,FALSE}                                          /* USER_NAME */
150         },
151         {
152             {Uri_HOST_DNS,S_OK,FALSE},                                  /* HOST_TYPE */
153             {80,S_OK,FALSE},                                            /* PORT */
154             {URL_SCHEME_HTTP,S_OK,FALSE},                               /* SCHEME */
155             {URLZONE_INVALID,E_NOTIMPL,FALSE}                           /* ZONE */
156         }
157     },
158     {   "http://winehq.org/tests/.././tests", 0, S_OK, FALSE,
159         {
160             {"http://winehq.org/tests",S_OK,FALSE},
161             {"winehq.org",S_OK,FALSE},
162             {"http://winehq.org/tests",S_OK,FALSE},
163             {"winehq.org",S_OK,FALSE},
164             {"",S_FALSE,FALSE},
165             {"",S_FALSE,FALSE},
166             {"winehq.org",S_OK,FALSE},
167             {"",S_FALSE,FALSE},
168             {"/tests",S_OK,FALSE},
169             {"/tests",S_OK,FALSE},
170             {"",S_FALSE,FALSE},
171             {"http://winehq.org/tests/.././tests",S_OK,FALSE},
172             {"http",S_OK,FALSE},
173             {"",S_FALSE,FALSE},
174             {"",S_FALSE,FALSE}
175         },
176         {
177             {Uri_HOST_DNS,S_OK,FALSE},
178             {80,S_OK,FALSE},
179             {URL_SCHEME_HTTP,S_OK,FALSE},
180             {URLZONE_INVALID,E_NOTIMPL,FALSE}
181         }
182     },
183     {   "HtTp://www.winehq.org/tests/..?query=x&return=y", 0, S_OK, FALSE,
184         {
185             {"http://www.winehq.org/?query=x&return=y",S_OK,FALSE},
186             {"www.winehq.org",S_OK,FALSE},
187             {"http://www.winehq.org/?query=x&return=y",S_OK,FALSE},
188             {"winehq.org",S_OK,FALSE},
189             {"",S_FALSE,FALSE},
190             {"",S_FALSE,FALSE},
191             {"www.winehq.org",S_OK,FALSE},
192             {"",S_FALSE,FALSE},
193             {"/",S_OK,FALSE},
194             {"/?query=x&return=y",S_OK,FALSE},
195             {"?query=x&return=y",S_OK,FALSE},
196             {"HtTp://www.winehq.org/tests/..?query=x&return=y",S_OK,FALSE},
197             {"http",S_OK,FALSE},
198             {"",S_FALSE,FALSE},
199             {"",S_FALSE,FALSE}
200         },
201         {
202             {Uri_HOST_DNS,S_OK,FALSE},
203             {80,S_OK,FALSE},
204             {URL_SCHEME_HTTP,S_OK,FALSE},
205             {URLZONE_INVALID,E_NOTIMPL,FALSE},
206         }
207     },
208     {   "hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters", 0, S_OK, FALSE,
209         {
210             {"http://usEr%3Ainfo@example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
211             {"usEr%3Ainfo@example.com",S_OK,FALSE},
212             {"http://example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
213             {"example.com",S_OK,FALSE},
214             {"",S_FALSE,FALSE},
215             {"",S_FALSE,FALSE},
216             {"example.com",S_OK,FALSE},
217             {"",S_FALSE,FALSE},
218             {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
219             {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
220             {"",S_FALSE,FALSE},
221             {"hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters",S_OK,FALSE},
222             {"http",S_OK,FALSE},
223             {"usEr%3Ainfo",S_OK,FALSE},
224             {"usEr%3Ainfo",S_OK,FALSE}
225         },
226         {
227             {Uri_HOST_DNS,S_OK,FALSE},
228             {80,S_OK,FALSE},
229             {URL_SCHEME_HTTP,S_OK,FALSE},
230             {URLZONE_INVALID,E_NOTIMPL,FALSE},
231         }
232     },
233     {   "ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt", 0, S_OK, FALSE,
234         {
235             {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK,FALSE},
236             {"winepass:wine@ftp.winehq.org:9999",S_OK,FALSE},
237             {"ftp://ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK,FALSE},
238             {"winehq.org",S_OK,FALSE},
239             {".txt",S_OK,FALSE},
240             {"",S_FALSE,FALSE},
241             {"ftp.winehq.org",S_OK,FALSE},
242             {"wine",S_OK,FALSE},
243             {"/dir/foo%20bar.txt",S_OK,FALSE},
244             {"/dir/foo%20bar.txt",S_OK,FALSE},
245             {"",S_FALSE,FALSE},
246             {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt",S_OK,FALSE},
247             {"ftp",S_OK,FALSE},
248             {"winepass:wine",S_OK,FALSE},
249             {"winepass",S_OK,FALSE}
250         },
251         {
252             {Uri_HOST_DNS,S_OK,FALSE},
253             {9999,S_OK,FALSE},
254             {URL_SCHEME_FTP,S_OK,FALSE},
255             {URLZONE_INVALID,E_NOTIMPL,FALSE}
256         }
257     },
258     {   "file://c:\\tests\\../tests/foo%20bar.mp3", 0, S_OK, FALSE,
259         {
260             {"file:///c:/tests/foo%2520bar.mp3",S_OK,FALSE},
261             {"",S_FALSE,FALSE},
262             {"file:///c:/tests/foo%2520bar.mp3",S_OK,FALSE},
263             {"",S_FALSE,FALSE},
264             {".mp3",S_OK,FALSE},
265             {"",S_FALSE,FALSE},
266             {"",S_FALSE,FALSE},
267             {"",S_FALSE,FALSE},
268             {"/c:/tests/foo%2520bar.mp3",S_OK,FALSE},
269             {"/c:/tests/foo%2520bar.mp3",S_OK,FALSE},
270             {"",S_FALSE,FALSE},
271             {"file://c:\\tests\\../tests/foo%20bar.mp3",S_OK,FALSE},
272             {"file",S_OK,FALSE},
273             {"",S_FALSE,FALSE},
274             {"",S_FALSE,FALSE}
275         },
276         {
277             {Uri_HOST_UNKNOWN,S_OK,FALSE},
278             {0,S_FALSE,FALSE},
279             {URL_SCHEME_FILE,S_OK,FALSE},
280             {URLZONE_INVALID,E_NOTIMPL,FALSE}
281         }
282     },
283     {   "file://c:\\tests\\../tests/foo%20bar.mp3", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
284         {
285             {"file:///c:/tests/../tests/foo%2520bar.mp3",S_OK,FALSE},
286             {"",S_FALSE,FALSE},
287             {"file:///c:/tests/../tests/foo%2520bar.mp3",S_OK,FALSE},
288             {"",S_FALSE,FALSE},
289             {".mp3",S_OK,FALSE},
290             {"",S_FALSE,FALSE},
291             {"",S_FALSE,FALSE},
292             {"",S_FALSE,FALSE},
293             {"/c:/tests/../tests/foo%2520bar.mp3",S_OK,FALSE},
294             {"/c:/tests/../tests/foo%2520bar.mp3",S_OK,FALSE},
295             {"",S_FALSE,FALSE},
296             {"file://c:\\tests\\../tests/foo%20bar.mp3",S_OK,FALSE},
297             {"file",S_OK,FALSE},
298             {"",S_FALSE,FALSE},
299             {"",S_FALSE,FALSE}
300         },
301         {
302             {Uri_HOST_UNKNOWN,S_OK,FALSE},
303             {0,S_FALSE,FALSE},
304             {URL_SCHEME_FILE,S_OK,FALSE},
305             {URLZONE_INVALID,E_NOTIMPL,FALSE}
306         }
307     },
308     {   "FILE://localhost/test dir\\../tests/test%20file.README.txt", 0, S_OK, FALSE,
309         {
310             {"file:///tests/test%20file.README.txt",S_OK,FALSE},
311             {"",S_FALSE,FALSE},
312             {"file:///tests/test%20file.README.txt",S_OK,FALSE},
313             {"",S_FALSE,FALSE},
314             {".txt",S_OK,FALSE},
315             {"",S_FALSE,FALSE},
316             {"",S_FALSE,FALSE},
317             {"",S_FALSE,FALSE},
318             {"/tests/test%20file.README.txt",S_OK,FALSE},
319             {"/tests/test%20file.README.txt",S_OK,FALSE},
320             {"",S_FALSE,FALSE},
321             {"FILE://localhost/test dir\\../tests/test%20file.README.txt",S_OK,FALSE},
322             {"file",S_OK,FALSE},
323             {"",S_FALSE,FALSE},
324             {"",S_FALSE,FALSE}
325         },
326         {
327             {Uri_HOST_UNKNOWN,S_OK,FALSE},
328             {0,S_FALSE,FALSE},
329             {URL_SCHEME_FILE,S_OK,FALSE},
330             {URLZONE_INVALID,E_NOTIMPL,FALSE}
331         }
332     },
333     {   "urn:nothing:should:happen here", 0, S_OK, FALSE,
334         {
335             {"urn:nothing:should:happen here",S_OK,FALSE},
336             {"",S_FALSE,FALSE},
337             {"urn:nothing:should:happen here",S_OK,FALSE},
338             {"",S_FALSE,FALSE},
339             {"",S_FALSE,FALSE},
340             {"",S_FALSE,FALSE},
341             {"",S_FALSE,FALSE},
342             {"",S_FALSE,FALSE},
343             {"nothing:should:happen here",S_OK,FALSE},
344             {"nothing:should:happen here",S_OK,FALSE},
345             {"",S_FALSE,FALSE},
346             {"urn:nothing:should:happen here",S_OK,FALSE},
347             {"urn",S_OK,FALSE},
348             {"",S_FALSE,FALSE},
349             {"",S_FALSE,FALSE}
350         },
351         {
352             {Uri_HOST_UNKNOWN,S_OK,FALSE},
353             {0,S_FALSE,FALSE},
354             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
355             {URLZONE_INVALID,E_NOTIMPL,FALSE}
356         }
357     },
358     {   "http://127.0.0.1/tests/../test dir/./test.txt", 0, S_OK, FALSE,
359         {
360             {"http://127.0.0.1/test%20dir/test.txt",S_OK,FALSE},
361             {"127.0.0.1",S_OK,FALSE},
362             {"http://127.0.0.1/test%20dir/test.txt",S_OK,FALSE},
363             {"",S_FALSE,FALSE},
364             {".txt",S_OK,FALSE},
365             {"",S_FALSE,FALSE},
366             {"127.0.0.1",S_OK,FALSE},
367             {"",S_FALSE,FALSE},
368             {"/test%20dir/test.txt",S_OK,FALSE},
369             {"/test%20dir/test.txt",S_OK,FALSE},
370             {"",S_FALSE,FALSE},
371             {"http://127.0.0.1/tests/../test dir/./test.txt",S_OK,FALSE},
372             {"http",S_OK,FALSE},
373             {"",S_FALSE,FALSE},
374             {"",S_FALSE,FALSE}
375         },
376         {
377             {Uri_HOST_IPV4,S_OK,FALSE},
378             {80,S_OK,FALSE},
379             {URL_SCHEME_HTTP,S_OK,FALSE},
380             {URLZONE_INVALID,E_NOTIMPL,FALSE}
381         }
382     },
383     {   "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", 0, S_OK, FALSE,
384         {
385             {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,FALSE},
386             {"[fedc:ba98:7654:3210:fedc:ba98:7654:3210]",S_OK,FALSE},
387             {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,FALSE},
388             {"",S_FALSE,FALSE},
389             {"",S_FALSE,FALSE},
390             {"",S_FALSE,FALSE},
391             {"fedc:ba98:7654:3210:fedc:ba98:7654:3210",S_OK,FALSE},
392             {"",S_FALSE,FALSE},
393             {"/",S_OK,FALSE},
394             {"/",S_OK,FALSE},
395             {"",S_FALSE,FALSE},
396             {"http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]",S_OK,FALSE},
397             {"http",S_OK,FALSE},
398             {"",S_FALSE,FALSE},
399             {"",S_FALSE,FALSE}
400         },
401         {
402             {Uri_HOST_IPV6,S_OK,FALSE},
403             {80,S_OK,FALSE},
404             {URL_SCHEME_HTTP,S_OK,FALSE},
405             {URLZONE_INVALID,E_NOTIMPL,FALSE}
406         }
407     },
408     {   "ftp://[::13.1.68.3]", 0, S_OK, FALSE,
409         {
410             {"ftp://[::13.1.68.3]/",S_OK,FALSE},
411             {"[::13.1.68.3]",S_OK,FALSE},
412             {"ftp://[::13.1.68.3]/",S_OK,FALSE},
413             {"",S_FALSE,FALSE},
414             {"",S_FALSE,FALSE},
415             {"",S_FALSE,FALSE},
416             {"::13.1.68.3",S_OK,FALSE},
417             {"",S_FALSE,FALSE},
418             {"/",S_OK,FALSE},
419             {"/",S_OK,FALSE},
420             {"",S_FALSE,FALSE},
421             {"ftp://[::13.1.68.3]",S_OK,FALSE},
422             {"ftp",S_OK,FALSE},
423             {"",S_FALSE,FALSE},
424             {"",S_FALSE,FALSE}
425         },
426         {
427             {Uri_HOST_IPV6,S_OK,FALSE},
428             {21,S_OK,FALSE},
429             {URL_SCHEME_FTP,S_OK,FALSE},
430             {URLZONE_INVALID,E_NOTIMPL,FALSE}
431         }
432     },
433     {   "http://[FEDC:BA98:0:0:0:0:0:3210]", 0, S_OK, FALSE,
434         {
435             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
436             {"[fedc:ba98::3210]",S_OK,FALSE},
437             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
438             {"",S_FALSE,FALSE},
439             {"",S_FALSE,FALSE},
440             {"",S_FALSE,FALSE},
441             {"fedc:ba98::3210",S_OK,FALSE},
442             {"",S_FALSE,FALSE},
443             {"/",S_OK,FALSE},
444             {"/",S_OK,FALSE},
445             {"",S_FALSE,FALSE},
446             {"http://[FEDC:BA98:0:0:0:0:0:3210]",S_OK,FALSE},
447             {"http",S_OK,FALSE},
448             {"",S_FALSE,FALSE},
449             {"",S_FALSE,FALSE},
450         },
451         {
452             {Uri_HOST_IPV6,S_OK,FALSE},
453             {80,S_OK,FALSE},
454             {URL_SCHEME_HTTP,S_OK,FALSE},
455             {URLZONE_INVALID,E_NOTIMPL,FALSE}
456         }
457     },
458     {   "1234://www.winehq.org", 0, S_OK, FALSE,
459         {
460             {"1234://www.winehq.org/",S_OK,FALSE},
461             {"www.winehq.org",S_OK,FALSE},
462             {"1234://www.winehq.org/",S_OK,FALSE},
463             {"winehq.org",S_OK,FALSE},
464             {"",S_FALSE,FALSE},
465             {"",S_FALSE,FALSE},
466             {"www.winehq.org",S_OK,FALSE},
467             {"",S_FALSE,FALSE},
468             {"/",S_OK,FALSE},
469             {"/",S_OK,FALSE},
470             {"",S_FALSE,FALSE},
471             {"1234://www.winehq.org",S_OK,FALSE},
472             {"1234",S_OK,FALSE},
473             {"",S_FALSE,FALSE},
474             {"",S_FALSE,FALSE}
475         },
476         {
477             {Uri_HOST_DNS,S_OK,FALSE},
478             {0,S_FALSE,FALSE},
479             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
480             {URLZONE_INVALID,E_NOTIMPL,FALSE}
481         }
482     },
483     /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
484     {   "C:/test/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
485         {
486             {"file:///C:/test/test.mp3",S_OK,FALSE},
487             {"",S_FALSE,FALSE},
488             {"file:///C:/test/test.mp3",S_OK,FALSE},
489             {"",S_FALSE,FALSE},
490             {".mp3",S_OK,FALSE},
491             {"",S_FALSE,FALSE},
492             {"",S_FALSE,FALSE},
493             {"",S_FALSE,FALSE},
494             {"/C:/test/test.mp3",S_OK,FALSE},
495             {"/C:/test/test.mp3",S_OK,FALSE},
496             {"",S_FALSE,FALSE},
497             {"C:/test/test.mp3",S_OK,FALSE},
498             {"file",S_OK,FALSE},
499             {"",S_FALSE,FALSE},
500             {"",S_FALSE,FALSE}
501         },
502         {
503             {Uri_HOST_UNKNOWN,S_OK,FALSE},
504             {0,S_FALSE,FALSE},
505             {URL_SCHEME_FILE,S_OK,FALSE},
506             {URLZONE_INVALID,E_NOTIMPL,FALSE}
507         }
508     },
509     /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
510     {   "\\\\Server/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
511         {
512             {"file://server/test.mp3",S_OK,FALSE},
513             {"server",S_OK,FALSE},
514             {"file://server/test.mp3",S_OK,FALSE},
515             {"",S_FALSE,FALSE},
516             {".mp3",S_OK,FALSE},
517             {"",S_FALSE,FALSE},
518             {"server",S_OK,FALSE},
519             {"",S_FALSE,FALSE},
520             {"/test.mp3",S_OK,FALSE},
521             {"/test.mp3",S_OK,FALSE},
522             {"",S_FALSE,FALSE},
523             {"\\\\Server/test.mp3",S_OK,FALSE},
524             {"file",S_OK,FALSE},
525             {"",S_FALSE,FALSE},
526             {"",S_FALSE,FALSE}
527         },
528         {
529             {Uri_HOST_DNS,S_OK,FALSE},
530             {0,S_FALSE,FALSE},
531             {URL_SCHEME_FILE,S_OK,FALSE},
532             {URLZONE_INVALID,E_NOTIMPL,FALSE}
533         }
534     },
535     {   "www.winehq.org/test", Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
536         {
537             {"*:www.winehq.org/test",S_OK,FALSE},
538             {"www.winehq.org",S_OK,FALSE},
539             {"*:www.winehq.org/test",S_OK,FALSE},
540             {"winehq.org",S_OK,FALSE},
541             {"",S_FALSE,FALSE},
542             {"",S_FALSE,FALSE},
543             {"www.winehq.org",S_OK,FALSE},
544             {"",S_FALSE,FALSE},
545             {"/test",S_OK,FALSE},
546             {"/test",S_OK,FALSE},
547             {"",S_FALSE,FALSE},
548             {"www.winehq.org/test",S_OK,FALSE},
549             {"*",S_OK,FALSE},
550             {"",S_FALSE,FALSE},
551             {"",S_FALSE,FALSE}
552         },
553         {
554             {Uri_HOST_DNS,S_OK,FALSE},
555             {0,S_FALSE,FALSE},
556             {URL_SCHEME_WILDCARD,S_OK,FALSE},
557             {URLZONE_INVALID,E_NOTIMPL,FALSE}
558         }
559     },
560     /* Valid since the '*' is the only character in the scheme name. */
561     {   "*:www.winehq.org/test", 0, S_OK, FALSE,
562         {
563             {"*:www.winehq.org/test",S_OK,FALSE},
564             {"www.winehq.org",S_OK,FALSE},
565             {"*:www.winehq.org/test",S_OK,FALSE},
566             {"winehq.org",S_OK,FALSE},
567             {"",S_FALSE,FALSE},
568             {"",S_FALSE,FALSE},
569             {"www.winehq.org",S_OK,FALSE},
570             {"",S_FALSE,FALSE},
571             {"/test",S_OK,FALSE},
572             {"/test",S_OK,FALSE},
573             {"",S_FALSE,FALSE},
574             {"*:www.winehq.org/test",S_OK,FALSE},
575             {"*",S_OK,FALSE},
576             {"",S_FALSE,FALSE},
577             {"",S_FALSE,FALSE}
578         },
579         {
580             {Uri_HOST_DNS,S_OK,FALSE},
581             {0,S_FALSE,FALSE},
582             {URL_SCHEME_WILDCARD,S_OK,FALSE},
583             {URLZONE_INVALID,E_NOTIMPL,FALSE}
584         }
585     },
586     {   "/../some dir/test.ext", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
587         {
588             {"/../some dir/test.ext",S_OK,FALSE},
589             {"",S_FALSE,FALSE},
590             {"/../some dir/test.ext",S_OK,FALSE},
591             {"",S_FALSE,FALSE},
592             {".ext",S_OK,FALSE},
593             {"",S_FALSE,FALSE},
594             {"",S_FALSE,FALSE},
595             {"",S_FALSE,FALSE},
596             {"/../some dir/test.ext",S_OK,FALSE},
597             {"/../some dir/test.ext",S_OK,FALSE},
598             {"",S_FALSE,FALSE},
599             {"/../some dir/test.ext",S_OK,FALSE},
600             {"",S_FALSE,FALSE},
601             {"",S_FALSE,FALSE},
602             {"",S_FALSE,FALSE}
603         },
604         {
605             {Uri_HOST_UNKNOWN,S_OK,FALSE},
606             {0,S_FALSE,FALSE},
607             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
608             {URLZONE_INVALID,E_NOTIMPL,FALSE}
609         }
610     },
611     {   "//implicit/wildcard/uri scheme", Uri_CREATE_ALLOW_RELATIVE|Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
612         {
613             {"*://implicit/wildcard/uri%20scheme",S_OK,FALSE},
614             {"",S_OK,FALSE},
615             {"*://implicit/wildcard/uri%20scheme",S_OK,FALSE},
616             {"",S_FALSE,FALSE},
617             {"",S_FALSE,FALSE},
618             {"",S_FALSE,FALSE},
619             {"",S_OK,FALSE},
620             {"",S_FALSE,FALSE},
621             {"//implicit/wildcard/uri%20scheme",S_OK,FALSE},
622             {"//implicit/wildcard/uri%20scheme",S_OK,FALSE},
623             {"",S_FALSE,FALSE},
624             {"//implicit/wildcard/uri scheme",S_OK,FALSE},
625             {"*",S_OK,FALSE},
626             {"",S_FALSE,FALSE},
627             {"",S_FALSE,FALSE},
628         },
629         {
630             {Uri_HOST_UNKNOWN,S_OK,FALSE},
631             {0,S_FALSE,FALSE},
632             {URL_SCHEME_WILDCARD,S_OK,FALSE},
633             {URLZONE_INVALID,E_NOTIMPL,FALSE}
634         }
635     },
636     /* URI is considered opaque since CREATE_NO_CRACK_UNKNOWN_SCHEMES is set and its an unknown scheme. */
637     {   "zip://google.com", Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, S_OK, FALSE,
638         {
639             {"zip:/.//google.com",S_OK,FALSE},
640             {"",S_FALSE,FALSE},
641             {"zip:/.//google.com",S_OK,FALSE},
642             {"",S_FALSE,FALSE},
643             {".com",S_OK,FALSE},
644             {"",S_FALSE,FALSE},
645             {"",S_FALSE,FALSE},
646             {"",S_FALSE,FALSE},
647             {"/.//google.com",S_OK,FALSE},
648             {"/.//google.com",S_OK,FALSE},
649             {"",S_FALSE,FALSE},
650             {"zip://google.com",S_OK,FALSE},
651             {"zip",S_OK,FALSE},
652             {"",S_FALSE,FALSE},
653             {"",S_FALSE,FALSE}
654         },
655         {
656             {Uri_HOST_UNKNOWN,S_OK,FALSE},
657             {0,S_FALSE,FALSE},
658             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
659             {URLZONE_INVALID,E_NOTIMPL,FALSE}
660         }
661     },
662     /* Windows uses the first occurrence of ':' to delimit the userinfo. */
663     {   "ftp://user:pass:word@winehq.org/", 0, S_OK, FALSE,
664         {
665             {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
666             {"user:pass:word@winehq.org",S_OK,FALSE},
667             {"ftp://winehq.org/",S_OK,FALSE},
668             {"winehq.org",S_OK,FALSE},
669             {"",S_FALSE,FALSE},
670             {"",S_FALSE,FALSE},
671             {"winehq.org",S_OK,FALSE},
672             {"pass:word",S_OK,FALSE},
673             {"/",S_OK,FALSE},
674             {"/",S_OK,FALSE},
675             {"",S_FALSE,FALSE},
676             {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
677             {"ftp",S_OK,FALSE},
678             {"user:pass:word",S_OK,FALSE},
679             {"user",S_OK,FALSE}
680         },
681         {
682             {Uri_HOST_DNS,S_OK,FALSE},
683             {21,S_OK,FALSE},
684             {URL_SCHEME_FTP,S_OK,FALSE},
685             {URLZONE_INVALID,E_NOTIMPL,FALSE}
686         }
687     },
688     /* Make sure % encoded unreserved characters are decoded. */
689     {   "ftp://w%49%4Ee:PA%53%53@ftp.google.com/", 0, S_OK, FALSE,
690         {
691             {"ftp://wINe:PASS@ftp.google.com/",S_OK,FALSE},
692             {"wINe:PASS@ftp.google.com",S_OK,FALSE},
693             {"ftp://ftp.google.com/",S_OK,FALSE},
694             {"google.com",S_OK,FALSE},
695             {"",S_FALSE,FALSE},
696             {"",S_FALSE,FALSE},
697             {"ftp.google.com",S_OK,FALSE},
698             {"PASS",S_OK,FALSE},
699             {"/",S_OK,FALSE},
700             {"/",S_OK,FALSE},
701             {"",S_FALSE,FALSE},
702             {"ftp://w%49%4Ee:PA%53%53@ftp.google.com/",S_OK,FALSE},
703             {"ftp",S_OK,FALSE},
704             {"wINe:PASS",S_OK,FALSE},
705             {"wINe",S_OK,FALSE}
706         },
707         {
708             {Uri_HOST_DNS,S_OK,FALSE},
709             {21,S_OK,FALSE},
710             {URL_SCHEME_FTP,S_OK,FALSE},
711             {URLZONE_INVALID,E_NOTIMPL,FALSE}
712         }
713     },
714     /* Make sure % encoded characters which are NOT unreserved are NOT decoded. */
715     {   "ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/", 0, S_OK, FALSE,
716         {
717             {"ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/",S_OK,FALSE},
718             {"w%5D%5Be:PA%7B%7D@ftp.google.com",S_OK,FALSE},
719             {"ftp://ftp.google.com/",S_OK,FALSE},
720             {"google.com",S_OK,FALSE},
721             {"",S_FALSE,FALSE},
722             {"",S_FALSE,FALSE},
723             {"ftp.google.com",S_OK,FALSE},
724             {"PA%7B%7D",S_OK,FALSE},
725             {"/",S_OK,FALSE},
726             {"/",S_OK,FALSE},
727             {"",S_FALSE,FALSE},
728             {"ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/",S_OK,FALSE},
729             {"ftp",S_OK,FALSE},
730             {"w%5D%5Be:PA%7B%7D",S_OK,FALSE},
731             {"w%5D%5Be",S_OK,FALSE}
732         },
733         {
734             {Uri_HOST_DNS,S_OK,FALSE},
735             {21,S_OK,FALSE},
736             {URL_SCHEME_FTP,S_OK,FALSE},
737             {URLZONE_INVALID,E_NOTIMPL,FALSE}
738         }
739     },
740     /* You're allowed to have an empty password portion in the userinfo section. */
741     {   "ftp://empty:@ftp.google.com/", 0, S_OK, FALSE,
742         {
743             {"ftp://empty:@ftp.google.com/",S_OK,FALSE},
744             {"empty:@ftp.google.com",S_OK,FALSE},
745             {"ftp://ftp.google.com/",S_OK,FALSE},
746             {"google.com",S_OK,FALSE},
747             {"",S_FALSE,FALSE},
748             {"",S_FALSE,FALSE},
749             {"ftp.google.com",S_OK,FALSE},
750             {"",S_OK,FALSE},
751             {"/",S_OK,FALSE},
752             {"/",S_OK,FALSE},
753             {"",S_FALSE,FALSE},
754             {"ftp://empty:@ftp.google.com/",S_OK,FALSE},
755             {"ftp",S_OK,FALSE},
756             {"empty:",S_OK,FALSE},
757             {"empty",S_OK,FALSE}
758         },
759         {
760             {Uri_HOST_DNS,S_OK,FALSE},
761             {21,S_OK,FALSE},
762             {URL_SCHEME_FTP,S_OK,FALSE},
763             {URLZONE_INVALID,E_NOTIMPL,FALSE}
764         }
765     },
766     /* Make sure forbidden characters in "userinfo" get encoded. */
767     {   "ftp://\" \"weird@ftp.google.com/", 0, S_OK, FALSE,
768         {
769             {"ftp://%22%20%22weird@ftp.google.com/",S_OK,FALSE},
770             {"%22%20%22weird@ftp.google.com",S_OK,FALSE},
771             {"ftp://ftp.google.com/",S_OK,FALSE},
772             {"google.com",S_OK,FALSE},
773             {"",S_FALSE,FALSE},
774             {"",S_FALSE,FALSE},
775             {"ftp.google.com",S_OK,FALSE},
776             {"",S_FALSE,FALSE},
777             {"/",S_OK,FALSE},
778             {"/",S_OK,FALSE},
779             {"",S_FALSE,FALSE},
780             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
781             {"ftp",S_OK,FALSE},
782             {"%22%20%22weird",S_OK,FALSE},
783             {"%22%20%22weird",S_OK,FALSE}
784         },
785         {
786             {Uri_HOST_DNS,S_OK,FALSE},
787             {21,S_OK,FALSE},
788             {URL_SCHEME_FTP,S_OK,FALSE},
789             {URLZONE_INVALID,E_NOTIMPL,FALSE}
790         }
791     },
792     /* Make sure the forbidden characters don't get percent encoded. */
793     {   "ftp://\" \"weird@ftp.google.com/", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
794         {
795             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
796             {"\" \"weird@ftp.google.com",S_OK,FALSE},
797             {"ftp://ftp.google.com/",S_OK,FALSE},
798             {"google.com",S_OK,FALSE},
799             {"",S_FALSE,FALSE},
800             {"",S_FALSE,FALSE},
801             {"ftp.google.com",S_OK,FALSE},
802             {"",S_FALSE,FALSE},
803             {"/",S_OK,FALSE},
804             {"/",S_OK,FALSE},
805             {"",S_FALSE,FALSE},
806             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
807             {"ftp",S_OK,FALSE},
808             {"\" \"weird",S_OK,FALSE},
809             {"\" \"weird",S_OK,FALSE}
810         },
811         {
812             {Uri_HOST_DNS,S_OK,FALSE},
813             {21,S_OK,FALSE},
814             {URL_SCHEME_FTP,S_OK,FALSE},
815             {URLZONE_INVALID,E_NOTIMPL,FALSE}
816         }
817     },
818     /* Make sure already percent encoded characters don't get unencoded. */
819     {   "ftp://\"%20\"weird@ftp.google.com/\"%20\"weird", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
820         {
821             {"ftp://\"%20\"weird@ftp.google.com/\"%20\"weird",S_OK,FALSE},
822             {"\"%20\"weird@ftp.google.com",S_OK,FALSE},
823             {"ftp://ftp.google.com/\"%20\"weird",S_OK,FALSE},
824             {"google.com",S_OK,FALSE},
825             {"",S_FALSE,FALSE},
826             {"",S_FALSE,FALSE},
827             {"ftp.google.com",S_OK,FALSE},
828             {"",S_FALSE,FALSE},
829             {"/\"%20\"weird",S_OK,FALSE},
830             {"/\"%20\"weird",S_OK,FALSE},
831             {"",S_FALSE,FALSE},
832             {"ftp://\"%20\"weird@ftp.google.com/\"%20\"weird",S_OK,FALSE},
833             {"ftp",S_OK,FALSE},
834             {"\"%20\"weird",S_OK,FALSE},
835             {"\"%20\"weird",S_OK,FALSE}
836         },
837         {
838             {Uri_HOST_DNS,S_OK,FALSE},
839             {21,S_OK,FALSE},
840             {URL_SCHEME_FTP,S_OK,FALSE},
841             {URLZONE_INVALID,E_NOTIMPL,FALSE}
842         }
843     },
844     /* Allowed to have invalid % encoded because its an unknown scheme type. */
845     {   "zip://%xy:word@winehq.org/", 0, S_OK, FALSE,
846         {
847             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
848             {"%xy:word@winehq.org",S_OK,FALSE},
849             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
850             {"winehq.org",S_OK,FALSE},
851             {"",S_FALSE,FALSE},
852             {"",S_FALSE,FALSE},
853             {"winehq.org",S_OK,FALSE},
854             {"word",S_OK,FALSE},
855             {"/",S_OK,FALSE},
856             {"/",S_OK,FALSE},
857             {"",S_FALSE,FALSE},
858             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
859             {"zip",S_OK,FALSE},
860             {"%xy:word",S_OK,FALSE},
861             {"%xy",S_OK,FALSE}
862         },
863         {
864             {Uri_HOST_DNS,S_OK,FALSE},
865             {0,S_FALSE,FALSE},
866             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
867             {URLZONE_INVALID,E_NOTIMPL,FALSE}
868         }
869     },
870     /* Unreserved, percent encoded characters aren't decoded in the userinfo because the scheme
871      * isn't known.
872      */
873     {   "zip://%2E:%52%53ord@winehq.org/", 0, S_OK, FALSE,
874         {
875             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
876             {"%2E:%52%53ord@winehq.org",S_OK,FALSE},
877             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
878             {"winehq.org",S_OK,FALSE},
879             {"",S_FALSE,FALSE},
880             {"",S_FALSE,FALSE},
881             {"winehq.org",S_OK,FALSE},
882             {"%52%53ord",S_OK,FALSE},
883             {"/",S_OK,FALSE},
884             {"/",S_OK,FALSE},
885             {"",S_FALSE,FALSE},
886             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
887             {"zip",S_OK,FALSE},
888             {"%2E:%52%53ord",S_OK,FALSE},
889             {"%2E",S_OK,FALSE}
890         },
891         {
892             {Uri_HOST_DNS,S_OK,FALSE},
893             {0,S_FALSE,FALSE},
894             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
895             {URLZONE_INVALID,E_NOTIMPL,FALSE}
896         }
897     },
898     {   "ftp://[](),'test':word@winehq.org/", 0, S_OK, FALSE,
899         {
900             {"ftp://[](),'test':word@winehq.org/",S_OK,FALSE},
901             {"[](),'test':word@winehq.org",S_OK,FALSE},
902             {"ftp://winehq.org/",S_OK,FALSE},
903             {"winehq.org",S_OK,FALSE},
904             {"",S_FALSE,FALSE},
905             {"",S_FALSE,FALSE},
906             {"winehq.org",S_OK,FALSE},
907             {"word",S_OK,FALSE},
908             {"/",S_OK,FALSE},
909             {"/",S_OK,FALSE},
910             {"",S_FALSE,FALSE},
911             {"ftp://[](),'test':word@winehq.org/",S_OK,FALSE},
912             {"ftp",S_OK,FALSE},
913             {"[](),'test':word",S_OK,FALSE},
914             {"[](),'test'",S_OK,FALSE}
915         },
916         {
917             {Uri_HOST_DNS,S_OK,FALSE},
918             {21,S_OK,FALSE},
919             {URL_SCHEME_FTP,S_OK,FALSE},
920             {URLZONE_INVALID,E_NOTIMPL,FALSE}
921         }
922     },
923     {   "ftp://test?:word@winehq.org/", 0, S_OK, FALSE,
924         {
925             {"ftp://test/?:word@winehq.org/",S_OK,FALSE},
926             {"test",S_OK,FALSE},
927             {"ftp://test/?:word@winehq.org/",S_OK,FALSE},
928             {"",S_FALSE,FALSE},
929             {"",S_FALSE,FALSE},
930             {"",S_FALSE,FALSE},
931             {"test",S_OK,FALSE},
932             {"",S_FALSE,FALSE},
933             {"/",S_OK,FALSE},
934             {"/?:word@winehq.org/",S_OK,FALSE},
935             {"?:word@winehq.org/",S_OK,FALSE},
936             {"ftp://test?:word@winehq.org/",S_OK,FALSE},
937             {"ftp",S_OK,FALSE},
938             {"",S_FALSE,FALSE},
939             {"",S_FALSE,FALSE}
940         },
941         {
942             {Uri_HOST_DNS,S_OK,FALSE},
943             {21,S_OK,FALSE},
944             {URL_SCHEME_FTP,S_OK,FALSE},
945             {URLZONE_INVALID,E_NOTIMPL,FALSE}
946         }
947     },
948     {   "ftp://test#:word@winehq.org/", 0, S_OK, FALSE,
949         {
950             {"ftp://test/#:word@winehq.org/",S_OK,FALSE},
951             {"test",S_OK,FALSE},
952             {"ftp://test/#:word@winehq.org/",S_OK,FALSE},
953             {"",S_FALSE,FALSE},
954             {"",S_FALSE,FALSE},
955             {"#:word@winehq.org/",S_OK,FALSE},
956             {"test",S_OK,FALSE},
957             {"",S_FALSE,FALSE},
958             {"/",S_OK,FALSE},
959             {"/",S_OK,FALSE},
960             {"",S_FALSE,FALSE},
961             {"ftp://test#:word@winehq.org/",S_OK,FALSE},
962             {"ftp",S_OK,FALSE},
963             {"",S_FALSE,FALSE},
964             {"",S_FALSE,FALSE}
965         },
966         {
967             {Uri_HOST_DNS,S_OK,FALSE},
968             {21,S_OK,FALSE},
969             {URL_SCHEME_FTP,S_OK,FALSE},
970             {URLZONE_INVALID,E_NOTIMPL,FALSE}
971         }
972     },
973     /* Allowed to have a backslash in the userinfo since it's an unknown scheme. */
974     {   "zip://test\\:word@winehq.org/", 0, S_OK, FALSE,
975         {
976             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
977             {"test\\:word@winehq.org",S_OK,FALSE},
978             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
979             {"winehq.org",S_OK,FALSE},
980             {"",S_FALSE,FALSE},
981             {"",S_FALSE,FALSE},
982             {"winehq.org",S_OK,FALSE},
983             {"word",S_OK,FALSE},
984             {"/",S_OK,FALSE},
985             {"/",S_OK,FALSE},
986             {"",S_FALSE,FALSE},
987             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
988             {"zip",S_OK,FALSE},
989             {"test\\:word",S_OK,FALSE},
990             {"test\\",S_OK,FALSE}
991         },
992         {
993             {Uri_HOST_DNS,S_OK,FALSE},
994             {0,S_FALSE,FALSE},
995             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
996             {URLZONE_INVALID,E_NOTIMPL,FALSE}
997         }
998     },
999     /* It normalizes IPv4 addresses correctly. */
1000     {   "http://127.000.000.100/", 0, S_OK, FALSE,
1001         {
1002             {"http://127.0.0.100/",S_OK,FALSE},
1003             {"127.0.0.100",S_OK,FALSE},
1004             {"http://127.0.0.100/",S_OK,FALSE},
1005             {"",S_FALSE,FALSE},
1006             {"",S_FALSE,FALSE},
1007             {"",S_FALSE,FALSE},
1008             {"127.0.0.100",S_OK,FALSE},
1009             {"",S_FALSE,FALSE},
1010             {"/",S_OK,FALSE},
1011             {"/",S_OK,FALSE},
1012             {"",S_FALSE,FALSE},
1013             {"http://127.000.000.100/",S_OK,FALSE},
1014             {"http",S_OK,FALSE},
1015             {"",S_FALSE,FALSE},
1016             {"",S_FALSE,FALSE}
1017         },
1018         {
1019             {Uri_HOST_IPV4,S_OK,FALSE},
1020             {80,S_OK,FALSE},
1021             {URL_SCHEME_HTTP,S_OK,FALSE},
1022             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1023         }
1024     },
1025     {   "http://127.0.0.1:8000", 0, S_OK, FALSE,
1026         {
1027             {"http://127.0.0.1:8000/",S_OK},
1028             {"127.0.0.1:8000",S_OK},
1029             {"http://127.0.0.1:8000/",S_OK},
1030             {"",S_FALSE},
1031             {"",S_FALSE},
1032             {"",S_FALSE},
1033             {"127.0.0.1",S_OK},
1034             {"",S_FALSE},
1035             {"/",S_OK},
1036             {"/",S_OK},
1037             {"",S_FALSE},
1038             {"http://127.0.0.1:8000",S_OK},
1039             {"http",S_OK},
1040             {"",S_FALSE},
1041             {"",S_FALSE}
1042         },
1043         {
1044             {Uri_HOST_IPV4,S_OK,FALSE},
1045             {8000,S_OK,FALSE},
1046             {URL_SCHEME_HTTP,S_OK,FALSE},
1047             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1048         }
1049     },
1050     /* Make sure it normalizes partial IPv4 addresses correctly. */
1051     {   "http://127.0/", 0, S_OK, FALSE,
1052         {
1053             {"http://127.0.0.0/",S_OK,FALSE},
1054             {"127.0.0.0",S_OK,FALSE},
1055             {"http://127.0.0.0/",S_OK,FALSE},
1056             {"",S_FALSE,FALSE},
1057             {"",S_FALSE,FALSE},
1058             {"",S_FALSE,FALSE},
1059             {"127.0.0.0",S_OK,FALSE},
1060             {"",S_FALSE,FALSE},
1061             {"/",S_OK,FALSE},
1062             {"/",S_OK,FALSE},
1063             {"",S_FALSE,FALSE},
1064             {"http://127.0/",S_OK,FALSE},
1065             {"http",S_OK,FALSE},
1066             {"",S_FALSE,FALSE},
1067             {"",S_FALSE,FALSE}
1068         },
1069         {
1070             {Uri_HOST_IPV4,S_OK,FALSE},
1071             {80,S_OK,FALSE},
1072             {URL_SCHEME_HTTP,S_OK,FALSE},
1073             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1074         }
1075     },
1076     /* Make sure it converts implicit IPv4's correctly. */
1077     {   "http://123456/", 0, S_OK, FALSE,
1078         {
1079             {"http://0.1.226.64/",S_OK,FALSE},
1080             {"0.1.226.64",S_OK,FALSE},
1081             {"http://0.1.226.64/",S_OK,FALSE},
1082             {"",S_FALSE,FALSE},
1083             {"",S_FALSE,FALSE},
1084             {"",S_FALSE,FALSE},
1085             {"0.1.226.64",S_OK,FALSE},
1086             {"",S_FALSE,FALSE},
1087             {"/",S_OK,FALSE},
1088             {"/",S_OK,FALSE},
1089             {"",S_FALSE,FALSE},
1090             {"http://123456/",S_OK,FALSE},
1091             {"http",S_OK,FALSE},
1092             {"",S_FALSE,FALSE},
1093             {"",S_FALSE,FALSE}
1094         },
1095         {
1096             {Uri_HOST_IPV4,S_OK,FALSE},
1097             {80,S_OK,FALSE},
1098             {URL_SCHEME_HTTP,S_OK,FALSE},
1099             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1100         }
1101     },
1102     /* UINT_MAX */
1103     {   "http://4294967295/", 0, S_OK, FALSE,
1104         {
1105             {"http://255.255.255.255/",S_OK,FALSE},
1106             {"255.255.255.255",S_OK,FALSE},
1107             {"http://255.255.255.255/",S_OK,FALSE},
1108             {"",S_FALSE,FALSE},
1109             {"",S_FALSE,FALSE},
1110             {"",S_FALSE,FALSE},
1111             {"255.255.255.255",S_OK,FALSE},
1112             {"",S_FALSE,FALSE},
1113             {"/",S_OK,FALSE},
1114             {"/",S_OK,FALSE},
1115             {"",S_FALSE,FALSE},
1116             {"http://4294967295/",S_OK,FALSE},
1117             {"http",S_OK,FALSE},
1118             {"",S_FALSE,FALSE},
1119             {"",S_FALSE,FALSE}
1120         },
1121         {
1122             {Uri_HOST_IPV4,S_OK,FALSE},
1123             {80,S_OK,FALSE},
1124             {URL_SCHEME_HTTP,S_OK,FALSE},
1125             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1126         }
1127     },
1128     /* UINT_MAX+1 */
1129     {   "http://4294967296/", 0, S_OK, FALSE,
1130         {
1131             {"http://4294967296/",S_OK,FALSE},
1132             {"4294967296",S_OK,FALSE},
1133             {"http://4294967296/",S_OK,FALSE},
1134             {"",S_FALSE,FALSE},
1135             {"",S_FALSE,FALSE},
1136             {"",S_FALSE,FALSE},
1137             {"4294967296",S_OK,FALSE},
1138             {"",S_FALSE,FALSE},
1139             {"/",S_OK,FALSE},
1140             {"/",S_OK,FALSE},
1141             {"",S_FALSE,FALSE},
1142             {"http://4294967296/",S_OK,FALSE},
1143             {"http",S_OK,FALSE},
1144             {"",S_FALSE,FALSE},
1145             {"",S_FALSE,FALSE}
1146         },
1147         {
1148             {Uri_HOST_DNS,S_OK,FALSE},
1149             {80,S_OK,FALSE},
1150             {URL_SCHEME_HTTP,S_OK,FALSE},
1151             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1152         }
1153     },
1154     /* Window's doesn't normalize IP address for unknown schemes. */
1155     {   "1234://4294967295/", 0, S_OK, FALSE,
1156         {
1157             {"1234://4294967295/",S_OK,FALSE},
1158             {"4294967295",S_OK,FALSE},
1159             {"1234://4294967295/",S_OK,FALSE},
1160             {"",S_FALSE,FALSE},
1161             {"",S_FALSE,FALSE},
1162             {"",S_FALSE,FALSE},
1163             {"4294967295",S_OK,FALSE},
1164             {"",S_FALSE,FALSE},
1165             {"/",S_OK,FALSE},
1166             {"/",S_OK,FALSE},
1167             {"",S_FALSE,FALSE},
1168             {"1234://4294967295/",S_OK,FALSE},
1169             {"1234",S_OK,FALSE},
1170             {"",S_FALSE,FALSE},
1171             {"",S_FALSE,FALSE}
1172         },
1173         {
1174             {Uri_HOST_IPV4,S_OK,FALSE},
1175             {0,S_FALSE,FALSE},
1176             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1177             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1178         }
1179     },
1180     /* Window's doesn't normalize IP address for unknown schemes. */
1181     {   "1234://127.001/", 0, S_OK, FALSE,
1182         {
1183             {"1234://127.001/",S_OK,FALSE},
1184             {"127.001",S_OK,FALSE},
1185             {"1234://127.001/",S_OK,FALSE},
1186             {"",S_FALSE,FALSE},
1187             {"",S_FALSE,FALSE},
1188             {"",S_FALSE,FALSE},
1189             {"127.001",S_OK,FALSE},
1190             {"",S_FALSE,FALSE},
1191             {"/",S_OK,FALSE},
1192             {"/",S_OK,FALSE},
1193             {"",S_FALSE,FALSE},
1194             {"1234://127.001/",S_OK,FALSE},
1195             {"1234",S_OK,FALSE},
1196             {"",S_FALSE,FALSE},
1197             {"",S_FALSE,FALSE}
1198         },
1199         {
1200             {Uri_HOST_IPV4,S_OK,FALSE},
1201             {0,S_FALSE,FALSE},
1202             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1203             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1204         }
1205     },
1206     {   "http://[FEDC:BA98::3210]", 0, S_OK, FALSE,
1207         {
1208             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
1209             {"[fedc:ba98::3210]",S_OK,FALSE},
1210             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
1211             {"",S_FALSE,FALSE},
1212             {"",S_FALSE,FALSE},
1213             {"",S_FALSE,FALSE},
1214             {"fedc:ba98::3210",S_OK,FALSE},
1215             {"",S_FALSE,FALSE},
1216             {"/",S_OK,FALSE},
1217             {"/",S_OK,FALSE},
1218             {"",S_FALSE,FALSE},
1219             {"http://[FEDC:BA98::3210]",S_OK,FALSE},
1220             {"http",S_OK,FALSE},
1221             {"",S_FALSE,FALSE},
1222             {"",S_FALSE,FALSE},
1223         },
1224         {
1225             {Uri_HOST_IPV6,S_OK,FALSE},
1226             {80,S_OK,FALSE},
1227             {URL_SCHEME_HTTP,S_OK,FALSE},
1228             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1229         }
1230     },
1231     {   "http://[::]", 0, S_OK, FALSE,
1232         {
1233             {"http://[::]/",S_OK,FALSE},
1234             {"[::]",S_OK,FALSE},
1235             {"http://[::]/",S_OK,FALSE},
1236             {"",S_FALSE,FALSE},
1237             {"",S_FALSE,FALSE},
1238             {"",S_FALSE,FALSE},
1239             {"::",S_OK,FALSE},
1240             {"",S_FALSE,FALSE},
1241             {"/",S_OK,FALSE},
1242             {"/",S_OK,FALSE},
1243             {"",S_FALSE,FALSE},
1244             {"http://[::]",S_OK,FALSE},
1245             {"http",S_OK,FALSE},
1246             {"",S_FALSE,FALSE},
1247             {"",S_FALSE,FALSE},
1248         },
1249         {
1250             {Uri_HOST_IPV6,S_OK,FALSE},
1251             {80,S_OK,FALSE},
1252             {URL_SCHEME_HTTP,S_OK,FALSE},
1253             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1254         }
1255     },
1256     {   "http://[FEDC:BA98::]", 0, S_OK, FALSE,
1257         {
1258             {"http://[fedc:ba98::]/",S_OK,FALSE},
1259             {"[fedc:ba98::]",S_OK,FALSE},
1260             {"http://[fedc:ba98::]/",S_OK,FALSE},
1261             {"",S_FALSE,FALSE},
1262             {"",S_FALSE,FALSE},
1263             {"",S_FALSE,FALSE},
1264             {"fedc:ba98::",S_OK,FALSE},
1265             {"",S_FALSE,FALSE},
1266             {"/",S_OK,FALSE},
1267             {"/",S_OK,FALSE},
1268             {"",S_FALSE,FALSE},
1269             {"http://[FEDC:BA98::]",S_OK,FALSE},
1270             {"http",S_OK,FALSE},
1271             {"",S_FALSE,FALSE},
1272             {"",S_FALSE,FALSE},
1273         },
1274         {
1275             {Uri_HOST_IPV6,S_OK,FALSE},
1276             {80,S_OK,FALSE},
1277             {URL_SCHEME_HTTP,S_OK,FALSE},
1278             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1279         }
1280     },
1281     /* Valid even with 2 byte elision because it doesn't appear the beginning or end. */
1282     {   "http://[1::3:4:5:6:7:8]", 0, S_OK, FALSE,
1283         {
1284             {"http://[1:0:3:4:5:6:7:8]/",S_OK,FALSE},
1285             {"[1:0:3:4:5:6:7:8]",S_OK,FALSE},
1286             {"http://[1:0:3:4:5:6:7:8]/",S_OK,FALSE},
1287             {"",S_FALSE,FALSE},
1288             {"",S_FALSE,FALSE},
1289             {"",S_FALSE,FALSE},
1290             {"1:0:3:4:5:6:7:8",S_OK,FALSE},
1291             {"",S_FALSE,FALSE},
1292             {"/",S_OK,FALSE},
1293             {"/",S_OK,FALSE},
1294             {"",S_FALSE,FALSE},
1295             {"http://[1::3:4:5:6:7:8]",S_OK,FALSE},
1296             {"http",S_OK,FALSE},
1297             {"",S_FALSE,FALSE},
1298             {"",S_FALSE,FALSE},
1299         },
1300         {
1301             {Uri_HOST_IPV6,S_OK,FALSE},
1302             {80,S_OK,FALSE},
1303             {URL_SCHEME_HTTP,S_OK,FALSE},
1304             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1305         }
1306     },
1307     {   "http://[v2.34]/", 0, S_OK, FALSE,
1308         {
1309             {"http://[v2.34]/",S_OK,FALSE},
1310             {"[v2.34]",S_OK,FALSE},
1311             {"http://[v2.34]/",S_OK,FALSE},
1312             {"",S_FALSE,FALSE},
1313             {"",S_FALSE,FALSE},
1314             {"",S_FALSE,FALSE},
1315             {"[v2.34]",S_OK,FALSE},
1316             {"",S_FALSE,FALSE},
1317             {"/",S_OK,FALSE},
1318             {"/",S_OK,FALSE},
1319             {"",S_FALSE,FALSE},
1320             {"http://[v2.34]/",S_OK,FALSE},
1321             {"http",S_OK,FALSE},
1322             {"",S_FALSE,FALSE},
1323             {"",S_FALSE,FALSE}
1324         },
1325         {
1326             {Uri_HOST_UNKNOWN,S_OK,FALSE},
1327             {80,S_OK,FALSE},
1328             {URL_SCHEME_HTTP,S_OK,FALSE},
1329             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1330         }
1331     },
1332     /* Windows ignores ':' if they appear after a '[' on a non-IPLiteral host. */
1333     {   "http://[xyz:12345.com/test", 0, S_OK, FALSE,
1334         {
1335             {"http://[xyz:12345.com/test",S_OK,FALSE},
1336             {"[xyz:12345.com",S_OK,FALSE},
1337             {"http://[xyz:12345.com/test",S_OK,FALSE},
1338             {"[xyz:12345.com",S_OK,FALSE},
1339             {"",S_FALSE,FALSE},
1340             {"",S_FALSE,FALSE},
1341             {"[xyz:12345.com",S_OK,FALSE},
1342             {"",S_FALSE,FALSE},
1343             {"/test",S_OK,FALSE},
1344             {"/test",S_OK,FALSE},
1345             {"",S_FALSE,FALSE},
1346             {"http://[xyz:12345.com/test",S_OK,FALSE},
1347             {"http",S_OK,FALSE},
1348             {"",S_FALSE,FALSE},
1349             {"",S_FALSE,FALSE}
1350         },
1351         {
1352             {Uri_HOST_DNS,S_OK,FALSE},
1353             {80,S_OK,FALSE},
1354             {URL_SCHEME_HTTP,S_OK,FALSE},
1355             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1356         }
1357     },
1358     /* Valid URI since the '[' and ']' don't appear at the beginning and end
1359      * of the host name (respectively).
1360      */
1361     {   "ftp://www.[works].com/", 0, S_OK, FALSE,
1362         {
1363             {"ftp://www.[works].com/",S_OK,FALSE},
1364             {"www.[works].com",S_OK,FALSE},
1365             {"ftp://www.[works].com/",S_OK,FALSE},
1366             {"[works].com",S_OK,FALSE},
1367             {"",S_FALSE,FALSE},
1368             {"",S_FALSE,FALSE},
1369             {"www.[works].com",S_OK,FALSE},
1370             {"",S_FALSE,FALSE},
1371             {"/",S_OK,FALSE},
1372             {"/",S_OK,FALSE},
1373             {"",S_FALSE,FALSE},
1374             {"ftp://www.[works].com/",S_OK,FALSE},
1375             {"ftp",S_OK,FALSE},
1376             {"",S_FALSE,FALSE},
1377             {"",S_FALSE,FALSE}
1378         },
1379         {
1380             {Uri_HOST_DNS,S_OK,FALSE},
1381             {21,S_OK,FALSE},
1382             {URL_SCHEME_FTP,S_OK,FALSE},
1383             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1384         }
1385     },
1386     /* Considers ':' a delimiter since it appears after the ']'. */
1387     {   "http://www.google.com]:12345/", 0, S_OK, FALSE,
1388         {
1389             {"http://www.google.com]:12345/",S_OK,FALSE},
1390             {"www.google.com]:12345",S_OK,FALSE},
1391             {"http://www.google.com]:12345/",S_OK,FALSE},
1392             {"google.com]",S_OK,FALSE},
1393             {"",S_FALSE,FALSE},
1394             {"",S_FALSE,FALSE},
1395             {"www.google.com]",S_OK,FALSE},
1396             {"",S_FALSE,FALSE},
1397             {"/",S_OK,FALSE},
1398             {"/",S_OK,FALSE},
1399             {"",S_FALSE,FALSE},
1400             {"http://www.google.com]:12345/",S_OK,FALSE},
1401             {"http",S_OK,FALSE},
1402             {"",S_FALSE,FALSE},
1403             {"",S_FALSE,FALSE}
1404         },
1405         {
1406             {Uri_HOST_DNS,S_OK,FALSE},
1407             {12345,S_OK,FALSE},
1408             {URL_SCHEME_HTTP,S_OK,FALSE},
1409             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1410         }
1411     },
1412     /* Unknown scheme types can have invalid % encoded data in the hostname. */
1413     {   "zip://w%XXw%GEw.google.com/", 0, S_OK, FALSE,
1414         {
1415             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1416             {"w%XXw%GEw.google.com",S_OK,FALSE},
1417             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1418             {"google.com",S_OK,FALSE},
1419             {"",S_FALSE,FALSE},
1420             {"",S_FALSE,FALSE},
1421             {"w%XXw%GEw.google.com",S_OK,FALSE},
1422             {"",S_FALSE,FALSE},
1423             {"/",S_OK,FALSE},
1424             {"/",S_OK,FALSE},
1425             {"",S_FALSE,FALSE},
1426             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1427             {"zip",S_OK,FALSE},
1428             {"",S_FALSE,FALSE},
1429             {"",S_FALSE,FALSE}
1430         },
1431         {
1432             {Uri_HOST_DNS,S_OK,FALSE},
1433             {0,S_FALSE,FALSE},
1434             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1435             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1436         }
1437     },
1438     /* Unknown scheme types hostname doesn't get lower cased. */
1439     {   "zip://GOOGLE.com/", 0, S_OK, FALSE,
1440         {
1441             {"zip://GOOGLE.com/",S_OK,FALSE},
1442             {"GOOGLE.com",S_OK,FALSE},
1443             {"zip://GOOGLE.com/",S_OK,FALSE},
1444             {"GOOGLE.com",S_OK,FALSE},
1445             {"",S_FALSE,FALSE},
1446             {"",S_FALSE,FALSE},
1447             {"GOOGLE.com",S_OK,FALSE},
1448             {"",S_FALSE,FALSE},
1449             {"/",S_OK,FALSE},
1450             {"/",S_OK,FALSE},
1451             {"",S_FALSE,FALSE},
1452             {"zip://GOOGLE.com/",S_OK,FALSE},
1453             {"zip",S_OK,FALSE},
1454             {"",S_FALSE,FALSE},
1455             {"",S_FALSE,FALSE}
1456         },
1457         {
1458             {Uri_HOST_DNS,S_OK,FALSE},
1459             {0,S_FALSE,FALSE},
1460             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1461             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1462         }
1463     },
1464     /* Hostname gets lower-cased for known scheme types. */
1465     {   "http://WWW.GOOGLE.com/", 0, S_OK, FALSE,
1466         {
1467             {"http://www.google.com/",S_OK,FALSE},
1468             {"www.google.com",S_OK,FALSE},
1469             {"http://www.google.com/",S_OK,FALSE},
1470             {"google.com",S_OK,FALSE},
1471             {"",S_FALSE,FALSE},
1472             {"",S_FALSE,FALSE},
1473             {"www.google.com",S_OK,FALSE},
1474             {"",S_FALSE,FALSE},
1475             {"/",S_OK,FALSE},
1476             {"/",S_OK,FALSE},
1477             {"",S_FALSE,FALSE},
1478             {"http://WWW.GOOGLE.com/",S_OK,FALSE},
1479             {"http",S_OK,FALSE},
1480             {"",S_FALSE,FALSE},
1481             {"",S_FALSE,FALSE}
1482         },
1483         {
1484             {Uri_HOST_DNS,S_OK,FALSE},
1485             {80,S_OK,FALSE},
1486             {URL_SCHEME_HTTP,S_OK,FALSE},
1487             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1488         }
1489     },
1490     /* Characters that get % encoded in the hostname also have their percent
1491      * encoded forms lower cased.
1492      */
1493     {   "http://www.%7Cgoogle|.com/", 0, S_OK, FALSE,
1494         {
1495             {"http://www.%7cgoogle%7c.com/",S_OK,FALSE},
1496             {"www.%7cgoogle%7c.com",S_OK,FALSE},
1497             {"http://www.%7cgoogle%7c.com/",S_OK,FALSE},
1498             {"%7cgoogle%7c.com",S_OK,FALSE},
1499             {"",S_FALSE,FALSE},
1500             {"",S_FALSE,FALSE},
1501             {"www.%7cgoogle%7c.com",S_OK,FALSE},
1502             {"",S_FALSE,FALSE},
1503             {"/",S_OK,FALSE},
1504             {"/",S_OK,FALSE},
1505             {"",S_FALSE,FALSE},
1506             {"http://www.%7Cgoogle|.com/",S_OK,FALSE},
1507             {"http",S_OK,FALSE},
1508             {"",S_FALSE,FALSE},
1509             {"",S_FALSE,FALSE}
1510         },
1511         {
1512             {Uri_HOST_DNS,S_OK,FALSE},
1513             {80,S_OK,FALSE},
1514             {URL_SCHEME_HTTP,S_OK,FALSE},
1515             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1516         }
1517     },
1518     /* IPv4 addresses attached to IPv6 can be included in elisions. */
1519     {   "http://[1:2:3:4:5:6:0.0.0.0]", 0, S_OK, FALSE,
1520         {
1521             {"http://[1:2:3:4:5:6::]/",S_OK,FALSE},
1522             {"[1:2:3:4:5:6::]",S_OK,FALSE},
1523             {"http://[1:2:3:4:5:6::]/",S_OK,FALSE},
1524             {"",S_FALSE,FALSE},
1525             {"",S_FALSE,FALSE},
1526             {"",S_FALSE,FALSE},
1527             {"1:2:3:4:5:6::",S_OK,FALSE},
1528             {"",S_FALSE,FALSE},
1529             {"/",S_OK,FALSE},
1530             {"/",S_OK,FALSE},
1531             {"",S_FALSE,FALSE},
1532             {"http://[1:2:3:4:5:6:0.0.0.0]",S_OK,FALSE},
1533             {"http",S_OK,FALSE},
1534             {"",S_FALSE,FALSE},
1535             {"",S_FALSE,FALSE},
1536         },
1537         {
1538             {Uri_HOST_IPV6,S_OK,FALSE},
1539             {80,S_OK,FALSE},
1540             {URL_SCHEME_HTTP,S_OK,FALSE},
1541             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1542         }
1543     },
1544     /* IPv4 addresses get normalized. */
1545     {   "http://[::001.002.003.000]", 0, S_OK, FALSE,
1546         {
1547             {"http://[::1.2.3.0]/",S_OK,FALSE},
1548             {"[::1.2.3.0]",S_OK,FALSE},
1549             {"http://[::1.2.3.0]/",S_OK,FALSE},
1550             {"",S_FALSE,FALSE},
1551             {"",S_FALSE,FALSE},
1552             {"",S_FALSE,FALSE},
1553             {"::1.2.3.0",S_OK,FALSE},
1554             {"",S_FALSE,FALSE},
1555             {"/",S_OK,FALSE},
1556             {"/",S_OK,FALSE},
1557             {"",S_FALSE,FALSE},
1558             {"http://[::001.002.003.000]",S_OK,FALSE},
1559             {"http",S_OK,FALSE},
1560             {"",S_FALSE,FALSE},
1561             {"",S_FALSE,FALSE},
1562         },
1563         {
1564             {Uri_HOST_IPV6,S_OK,FALSE},
1565             {80,S_OK,FALSE},
1566             {URL_SCHEME_HTTP,S_OK,FALSE},
1567             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1568         }
1569     },
1570     /* Windows doesn't do anything to IPv6's in unknown schemes. */
1571     {   "zip://[0001:0:000:0004:0005:0006:001.002.003.000]", 0, S_OK, FALSE,
1572         {
1573             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]/",S_OK,FALSE},
1574             {"[0001:0:000:0004:0005:0006:001.002.003.000]",S_OK,FALSE},
1575             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]/",S_OK,FALSE},
1576             {"",S_FALSE,FALSE},
1577             {"",S_FALSE,FALSE},
1578             {"",S_FALSE,FALSE},
1579             {"0001:0:000:0004:0005:0006:001.002.003.000",S_OK,FALSE},
1580             {"",S_FALSE,FALSE},
1581             {"/",S_OK,FALSE},
1582             {"/",S_OK,FALSE},
1583             {"",S_FALSE,FALSE},
1584             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]",S_OK,FALSE},
1585             {"zip",S_OK,FALSE},
1586             {"",S_FALSE,FALSE},
1587             {"",S_FALSE,FALSE},
1588         },
1589         {
1590             {Uri_HOST_IPV6,S_OK,FALSE},
1591             {0,S_FALSE,FALSE},
1592             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1593             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1594         }
1595     },
1596     /* IPv4 address is converted into 2 h16 components. */
1597     {   "http://[ffff::192.222.111.32]", 0, S_OK, FALSE,
1598         {
1599             {"http://[ffff::c0de:6f20]/",S_OK,FALSE},
1600             {"[ffff::c0de:6f20]",S_OK,FALSE},
1601             {"http://[ffff::c0de:6f20]/",S_OK,FALSE},
1602             {"",S_FALSE,FALSE},
1603             {"",S_FALSE,FALSE},
1604             {"",S_FALSE,FALSE},
1605             {"ffff::c0de:6f20",S_OK,FALSE},
1606             {"",S_FALSE,FALSE},
1607             {"/",S_OK,FALSE},
1608             {"/",S_OK,FALSE},
1609             {"",S_FALSE,FALSE},
1610             {"http://[ffff::192.222.111.32]",S_OK,FALSE},
1611             {"http",S_OK,FALSE},
1612             {"",S_FALSE,FALSE},
1613             {"",S_FALSE,FALSE},
1614         },
1615         {
1616             {Uri_HOST_IPV6,S_OK,FALSE},
1617             {80,S_OK,FALSE},
1618             {URL_SCHEME_HTTP,S_OK,FALSE},
1619             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1620         }
1621     },
1622     /* Max value for a port. */
1623     {   "http://google.com:65535", 0, S_OK, FALSE,
1624         {
1625             {"http://google.com:65535/",S_OK,FALSE},
1626             {"google.com:65535",S_OK,FALSE},
1627             {"http://google.com:65535/",S_OK,FALSE},
1628             {"google.com",S_OK,FALSE},
1629             {"",S_FALSE,FALSE},
1630             {"",S_FALSE,FALSE},
1631             {"google.com",S_OK,FALSE},
1632             {"",S_FALSE,FALSE},
1633             {"/",S_OK,FALSE},
1634             {"/",S_OK,FALSE},
1635             {"",S_FALSE,FALSE},
1636             {"http://google.com:65535",S_OK,FALSE},
1637             {"http",S_OK,FALSE},
1638             {"",S_FALSE,FALSE},
1639             {"",S_FALSE,FALSE}
1640         },
1641         {
1642             {Uri_HOST_DNS,S_OK,FALSE},
1643             {65535,S_OK,FALSE},
1644             {URL_SCHEME_HTTP,S_OK,FALSE},
1645             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1646         }
1647     },
1648     {   "zip://google.com:65536", 0, S_OK, FALSE,
1649         {
1650             {"zip://google.com:65536/",S_OK,FALSE},
1651             {"google.com:65536",S_OK,FALSE},
1652             {"zip://google.com:65536/",S_OK,FALSE},
1653             {"google.com:65536",S_OK,FALSE},
1654             {"",S_FALSE,FALSE},
1655             {"",S_FALSE,FALSE},
1656             {"google.com:65536",S_OK,FALSE},
1657             {"",S_FALSE,FALSE},
1658             {"/",S_OK,FALSE},
1659             {"/",S_OK,FALSE},
1660             {"",S_FALSE,FALSE},
1661             {"zip://google.com:65536",S_OK,FALSE},
1662             {"zip",S_OK,FALSE},
1663             {"",S_FALSE,FALSE},
1664             {"",S_FALSE,FALSE}
1665         },
1666         {
1667             {Uri_HOST_DNS,S_OK,FALSE},
1668             {0,S_FALSE,FALSE},
1669             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1670             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1671         }
1672     },
1673     {   "zip://google.com:65536:25", 0, S_OK, FALSE,
1674         {
1675             {"zip://google.com:65536:25/",S_OK,FALSE},
1676             {"google.com:65536:25",S_OK,FALSE},
1677             {"zip://google.com:65536:25/",S_OK,FALSE},
1678             {"google.com:65536:25",S_OK,FALSE},
1679             {"",S_FALSE,FALSE},
1680             {"",S_FALSE,FALSE},
1681             {"google.com:65536:25",S_OK,FALSE},
1682             {"",S_FALSE,FALSE},
1683             {"/",S_OK,FALSE},
1684             {"/",S_OK,FALSE},
1685             {"",S_FALSE,FALSE},
1686             {"zip://google.com:65536:25",S_OK,FALSE},
1687             {"zip",S_OK,FALSE},
1688             {"",S_FALSE,FALSE},
1689             {"",S_FALSE,FALSE}
1690         },
1691         {
1692             {Uri_HOST_DNS,S_OK,FALSE},
1693             {0,S_FALSE,FALSE},
1694             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1695             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1696         }
1697     },
1698     {   "zip://[::ffff]:abcd", 0, S_OK, FALSE,
1699         {
1700             {"zip://[::ffff]:abcd/",S_OK,FALSE},
1701             {"[::ffff]:abcd",S_OK,FALSE},
1702             {"zip://[::ffff]:abcd/",S_OK,FALSE},
1703             {"",S_FALSE,FALSE},
1704             {"",S_FALSE,FALSE},
1705             {"",S_FALSE,FALSE},
1706             {"[::ffff]:abcd",S_OK,FALSE},
1707             {"",S_FALSE,FALSE},
1708             {"/",S_OK,FALSE},
1709             {"/",S_OK,FALSE},
1710             {"",S_FALSE,FALSE},
1711             {"zip://[::ffff]:abcd",S_OK,FALSE},
1712             {"zip",S_OK,FALSE},
1713             {"",S_FALSE,FALSE},
1714             {"",S_FALSE,FALSE}
1715         },
1716         {
1717             {Uri_HOST_DNS,S_OK,FALSE},
1718             {0,S_FALSE,FALSE},
1719             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1720             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1721         }
1722     },
1723     {   "zip://127.0.0.1:abcd", 0, S_OK, FALSE,
1724         {
1725             {"zip://127.0.0.1:abcd/",S_OK,FALSE},
1726             {"127.0.0.1:abcd",S_OK,FALSE},
1727             {"zip://127.0.0.1:abcd/",S_OK,FALSE},
1728             {"0.1:abcd",S_OK,FALSE},
1729             {"",S_FALSE,FALSE},
1730             {"",S_FALSE,FALSE},
1731             {"127.0.0.1:abcd",S_OK,FALSE},
1732             {"",S_FALSE,FALSE},
1733             {"/",S_OK,FALSE},
1734             {"/",S_OK,FALSE},
1735             {"",S_FALSE,FALSE},
1736             {"zip://127.0.0.1:abcd",S_OK,FALSE},
1737             {"zip",S_OK,FALSE},
1738             {"",S_FALSE,FALSE},
1739             {"",S_FALSE,FALSE}
1740         },
1741         {
1742             {Uri_HOST_DNS,S_OK,FALSE},
1743             {0,S_FALSE,FALSE},
1744             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1745             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1746         }
1747     },
1748     /* Port is just copied over. */
1749     {   "http://google.com:00035", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1750         {
1751             {"http://google.com:00035",S_OK,FALSE},
1752             {"google.com:00035",S_OK,FALSE},
1753             {"http://google.com:00035",S_OK,FALSE,"http://google.com:35"},
1754             {"google.com",S_OK,FALSE},
1755             {"",S_FALSE,FALSE},
1756             {"",S_FALSE,FALSE},
1757             {"google.com",S_OK,FALSE},
1758             {"",S_FALSE,FALSE},
1759             {"",S_FALSE,FALSE},
1760             {"",S_FALSE,FALSE},
1761             {"",S_FALSE,FALSE},
1762             {"http://google.com:00035",S_OK,FALSE},
1763             {"http",S_OK,FALSE},
1764             {"",S_FALSE,FALSE},
1765             {"",S_FALSE,FALSE}
1766         },
1767         {
1768             {Uri_HOST_DNS,S_OK,FALSE},
1769             {35,S_OK,FALSE},
1770             {URL_SCHEME_HTTP,S_OK,FALSE},
1771             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1772         }
1773     },
1774     /* Default port is copied over. */
1775     {   "http://google.com:80", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1776         {
1777             {"http://google.com:80",S_OK,FALSE},
1778             {"google.com:80",S_OK,FALSE},
1779             {"http://google.com:80",S_OK,FALSE},
1780             {"google.com",S_OK,FALSE},
1781             {"",S_FALSE,FALSE},
1782             {"",S_FALSE,FALSE},
1783             {"google.com",S_OK,FALSE},
1784             {"",S_FALSE,FALSE},
1785             {"",S_FALSE,FALSE},
1786             {"",S_FALSE,FALSE},
1787             {"",S_FALSE,FALSE},
1788             {"http://google.com:80",S_OK,FALSE},
1789             {"http",S_OK,FALSE},
1790             {"",S_FALSE,FALSE},
1791             {"",S_FALSE,FALSE}
1792         },
1793         {
1794             {Uri_HOST_DNS,S_OK,FALSE},
1795             {80,S_OK,FALSE},
1796             {URL_SCHEME_HTTP,S_OK,FALSE},
1797             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1798         }
1799     },
1800     {   "http://google.com.uk", 0, S_OK, FALSE,
1801         {
1802             {"http://google.com.uk/",S_OK,FALSE},
1803             {"google.com.uk",S_OK,FALSE},
1804             {"http://google.com.uk/",S_OK,FALSE},
1805             {"google.com.uk",S_OK,FALSE},
1806             {"",S_FALSE,FALSE},
1807             {"",S_FALSE,FALSE},
1808             {"google.com.uk",S_OK,FALSE},
1809             {"",S_FALSE,FALSE},
1810             {"/",S_OK,FALSE},
1811             {"/",S_OK,FALSE},
1812             {"",S_FALSE,FALSE},
1813             {"http://google.com.uk",S_OK,FALSE},
1814             {"http",S_OK,FALSE},
1815             {"",S_FALSE,FALSE},
1816             {"",S_FALSE,FALSE}
1817         },
1818         {
1819             {Uri_HOST_DNS,S_OK,FALSE},
1820             {80,S_OK,FALSE},
1821             {URL_SCHEME_HTTP,S_OK,FALSE},
1822             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1823         }
1824     },
1825     {   "http://google.com.com", 0, S_OK, FALSE,
1826         {
1827             {"http://google.com.com/",S_OK,FALSE},
1828             {"google.com.com",S_OK,FALSE},
1829             {"http://google.com.com/",S_OK,FALSE},
1830             {"com.com",S_OK,FALSE},
1831             {"",S_FALSE,FALSE},
1832             {"",S_FALSE,FALSE},
1833             {"google.com.com",S_OK,FALSE},
1834             {"",S_FALSE,FALSE},
1835             {"/",S_OK,FALSE},
1836             {"/",S_OK,FALSE},
1837             {"",S_FALSE,FALSE},
1838             {"http://google.com.com",S_OK,FALSE},
1839             {"http",S_OK,FALSE},
1840             {"",S_FALSE,FALSE},
1841             {"",S_FALSE,FALSE}
1842         },
1843         {
1844             {Uri_HOST_DNS,S_OK,FALSE},
1845             {80,S_OK,FALSE},
1846             {URL_SCHEME_HTTP,S_OK,FALSE},
1847             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1848         }
1849     },
1850     {   "http://google.uk.1", 0, S_OK, FALSE,
1851         {
1852             {"http://google.uk.1/",S_OK,FALSE},
1853             {"google.uk.1",S_OK,FALSE},
1854             {"http://google.uk.1/",S_OK,FALSE},
1855             {"google.uk.1",S_OK,FALSE},
1856             {"",S_FALSE,FALSE},
1857             {"",S_FALSE,FALSE},
1858             {"google.uk.1",S_OK,FALSE},
1859             {"",S_FALSE,FALSE},
1860             {"/",S_OK,FALSE},
1861             {"/",S_OK,FALSE},
1862             {"",S_FALSE,FALSE},
1863             {"http://google.uk.1",S_OK,FALSE},
1864             {"http",S_OK,FALSE},
1865             {"",S_FALSE,FALSE},
1866             {"",S_FALSE,FALSE}
1867         },
1868         {
1869             {Uri_HOST_DNS,S_OK,FALSE},
1870             {80,S_OK,FALSE},
1871             {URL_SCHEME_HTTP,S_OK,FALSE},
1872             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1873         }
1874     },
1875     /* Since foo isn't a recognized 3 character TLD its considered the domain name. */
1876     {   "http://google.foo.uk", 0, S_OK, FALSE,
1877         {
1878             {"http://google.foo.uk/",S_OK,FALSE},
1879             {"google.foo.uk",S_OK,FALSE},
1880             {"http://google.foo.uk/",S_OK,FALSE},
1881             {"foo.uk",S_OK,FALSE},
1882             {"",S_FALSE,FALSE},
1883             {"",S_FALSE,FALSE},
1884             {"google.foo.uk",S_OK,FALSE},
1885             {"",S_FALSE,FALSE},
1886             {"/",S_OK,FALSE},
1887             {"/",S_OK,FALSE},
1888             {"",S_FALSE,FALSE},
1889             {"http://google.foo.uk",S_OK,FALSE},
1890             {"http",S_OK,FALSE},
1891             {"",S_FALSE,FALSE},
1892             {"",S_FALSE,FALSE}
1893         },
1894         {
1895             {Uri_HOST_DNS,S_OK,FALSE},
1896             {80,S_OK,FALSE},
1897             {URL_SCHEME_HTTP,S_OK,FALSE},
1898             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1899         }
1900     },
1901     {   "http://.com", 0, S_OK, FALSE,
1902         {
1903             {"http://.com/",S_OK,FALSE},
1904             {".com",S_OK,FALSE},
1905             {"http://.com/",S_OK,FALSE},
1906             {".com",S_OK,FALSE},
1907             {"",S_FALSE,FALSE},
1908             {"",S_FALSE,FALSE},
1909             {".com",S_OK,FALSE},
1910             {"",S_FALSE,FALSE},
1911             {"/",S_OK,FALSE},
1912             {"/",S_OK,FALSE},
1913             {"",S_FALSE,FALSE},
1914             {"http://.com",S_OK,FALSE},
1915             {"http",S_OK,FALSE},
1916             {"",S_FALSE,FALSE},
1917             {"",S_FALSE,FALSE}
1918         },
1919         {
1920             {Uri_HOST_DNS,S_OK,FALSE},
1921             {80,S_OK,FALSE},
1922             {URL_SCHEME_HTTP,S_OK,FALSE},
1923             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1924         }
1925     },
1926     {   "http://.uk", 0, S_OK, FALSE,
1927         {
1928             {"http://.uk/",S_OK,FALSE},
1929             {".uk",S_OK,FALSE},
1930             {"http://.uk/",S_OK,FALSE},
1931             {"",S_FALSE,FALSE},
1932             {"",S_FALSE,FALSE},
1933             {"",S_FALSE,FALSE},
1934             {".uk",S_OK,FALSE},
1935             {"",S_FALSE,FALSE},
1936             {"/",S_OK,FALSE},
1937             {"/",S_OK,FALSE},
1938             {"",S_FALSE,FALSE},
1939             {"http://.uk",S_OK,FALSE},
1940             {"http",S_OK,FALSE},
1941             {"",S_FALSE,FALSE},
1942             {"",S_FALSE,FALSE}
1943         },
1944         {
1945             {Uri_HOST_DNS,S_OK,FALSE},
1946             {80,S_OK,FALSE},
1947             {URL_SCHEME_HTTP,S_OK,FALSE},
1948             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1949         }
1950     },
1951     {   "http://www.co.google.com.[]", 0, S_OK, FALSE,
1952         {
1953             {"http://www.co.google.com.[]/",S_OK,FALSE},
1954             {"www.co.google.com.[]",S_OK,FALSE},
1955             {"http://www.co.google.com.[]/",S_OK,FALSE},
1956             {"google.com.[]",S_OK,FALSE},
1957             {"",S_FALSE,FALSE},
1958             {"",S_FALSE,FALSE},
1959             {"www.co.google.com.[]",S_OK,FALSE},
1960             {"",S_FALSE,FALSE},
1961             {"/",S_OK,FALSE},
1962             {"/",S_OK,FALSE},
1963             {"",S_FALSE,FALSE},
1964             {"http://www.co.google.com.[]",S_OK,FALSE},
1965             {"http",S_OK,FALSE},
1966             {"",S_FALSE,FALSE},
1967             {"",S_FALSE,FALSE}
1968         },
1969         {
1970             {Uri_HOST_DNS,S_OK,FALSE},
1971             {80,S_OK,FALSE},
1972             {URL_SCHEME_HTTP,S_OK,FALSE},
1973             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1974         }
1975     },
1976     {   "http://co.uk", 0, S_OK, FALSE,
1977         {
1978             {"http://co.uk/",S_OK,FALSE},
1979             {"co.uk",S_OK,FALSE},
1980             {"http://co.uk/",S_OK,FALSE},
1981             {"",S_FALSE,FALSE},
1982             {"",S_FALSE,FALSE},
1983             {"",S_FALSE,FALSE},
1984             {"co.uk",S_OK,FALSE},
1985             {"",S_FALSE,FALSE},
1986             {"/",S_OK,FALSE},
1987             {"/",S_OK,FALSE},
1988             {"",S_FALSE,FALSE},
1989             {"http://co.uk",S_OK,FALSE},
1990             {"http",S_OK,FALSE},
1991             {"",S_FALSE,FALSE},
1992             {"",S_FALSE,FALSE}
1993         },
1994         {
1995             {Uri_HOST_DNS,S_OK,FALSE},
1996             {80,S_OK,FALSE},
1997             {URL_SCHEME_HTTP,S_OK,FALSE},
1998             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1999         }
2000     },
2001     {   "http://www.co.google.us.test", 0, S_OK, FALSE,
2002         {
2003             {"http://www.co.google.us.test/",S_OK,FALSE},
2004             {"www.co.google.us.test",S_OK,FALSE},
2005             {"http://www.co.google.us.test/",S_OK,FALSE},
2006             {"us.test",S_OK,FALSE},
2007             {"",S_FALSE,FALSE},
2008             {"",S_FALSE,FALSE},
2009             {"www.co.google.us.test",S_OK,FALSE},
2010             {"",S_FALSE,FALSE},
2011             {"/",S_OK,FALSE},
2012             {"/",S_OK,FALSE},
2013             {"",S_FALSE,FALSE},
2014             {"http://www.co.google.us.test",S_OK,FALSE},
2015             {"http",S_OK,FALSE},
2016             {"",S_FALSE,FALSE},
2017             {"",S_FALSE,FALSE}
2018         },
2019         {
2020             {Uri_HOST_DNS,S_OK,FALSE},
2021             {80,S_OK,FALSE},
2022             {URL_SCHEME_HTTP,S_OK,FALSE},
2023             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2024         }
2025     },
2026     {   "http://gov.uk", 0, S_OK, FALSE,
2027         {
2028             {"http://gov.uk/",S_OK,FALSE},
2029             {"gov.uk",S_OK,FALSE},
2030             {"http://gov.uk/",S_OK,FALSE},
2031             {"",S_FALSE,FALSE},
2032             {"",S_FALSE,FALSE},
2033             {"",S_FALSE,FALSE},
2034             {"gov.uk",S_OK,FALSE},
2035             {"",S_FALSE,FALSE},
2036             {"/",S_OK,FALSE},
2037             {"/",S_OK,FALSE},
2038             {"",S_FALSE,FALSE},
2039             {"http://gov.uk",S_OK,FALSE},
2040             {"http",S_OK,FALSE},
2041             {"",S_FALSE,FALSE},
2042             {"",S_FALSE,FALSE}
2043         },
2044         {
2045             {Uri_HOST_DNS,S_OK,FALSE},
2046             {80,S_OK,FALSE},
2047             {URL_SCHEME_HTTP,S_OK,FALSE},
2048             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2049         }
2050     },
2051     {   "zip://www.google.com\\test", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2052         {
2053             {"zip://www.google.com\\test",S_OK,FALSE},
2054             {"www.google.com\\test",S_OK,FALSE},
2055             {"zip://www.google.com\\test",S_OK,FALSE},
2056             {"google.com\\test",S_OK,FALSE},
2057             {"",S_FALSE,FALSE},
2058             {"",S_FALSE,FALSE},
2059             {"www.google.com\\test",S_OK,FALSE},
2060             {"",S_FALSE,FALSE},
2061             {"",S_FALSE,FALSE},
2062             {"",S_FALSE,FALSE},
2063             {"",S_FALSE,FALSE},
2064             {"zip://www.google.com\\test",S_OK,FALSE},
2065             {"zip",S_OK,FALSE},
2066             {"",S_FALSE,FALSE},
2067             {"",S_FALSE,FALSE}
2068         },
2069         {
2070             {Uri_HOST_DNS,S_OK,FALSE},
2071             {0,S_FALSE,FALSE},
2072             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2073             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2074         }
2075     },
2076     {   "urn:excepts:bad:%XY:encoded", 0, S_OK, FALSE,
2077         {
2078             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2079             {"",S_FALSE,FALSE},
2080             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2081             {"",S_FALSE,FALSE},
2082             {"",S_FALSE,FALSE},
2083             {"",S_FALSE,FALSE},
2084             {"",S_FALSE,FALSE},
2085             {"",S_FALSE,FALSE},
2086             {"excepts:bad:%XY:encoded",S_OK,FALSE},
2087             {"excepts:bad:%XY:encoded",S_OK,FALSE},
2088             {"",S_FALSE,FALSE},
2089             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2090             {"urn",S_OK,FALSE},
2091             {"",S_FALSE,FALSE},
2092             {"",S_FALSE,FALSE}
2093         },
2094         {
2095             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2096             {0,S_FALSE,FALSE},
2097             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2098             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2099         }
2100     },
2101     /* Since the original URI doesn't contain an extra '/' before the path no % encoded values
2102      * are decoded and all '%' are encoded.
2103      */
2104     {   "file://C:/te%3Es%2Et/tes%t.mp3", 0, S_OK, FALSE,
2105         {
2106             {"file:///C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2107             {"",S_FALSE,FALSE},
2108             {"file:///C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2109             {"",S_FALSE,FALSE},
2110             {".mp3",S_OK,FALSE},
2111             {"",S_FALSE,FALSE},
2112             {"",S_FALSE,FALSE},
2113             {"",S_FALSE,FALSE},
2114             {"/C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2115             {"/C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2116             {"",S_FALSE,FALSE},
2117             {"file://C:/te%3Es%2Et/tes%t.mp3",S_OK,FALSE},
2118             {"file",S_OK,FALSE},
2119             {"",S_FALSE,FALSE},
2120             {"",S_FALSE,FALSE}
2121         },
2122         {
2123             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2124             {0,S_FALSE,FALSE},
2125             {URL_SCHEME_FILE,S_OK,FALSE},
2126             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2127         }
2128     },
2129     /* Since there's a '/' in front of the drive letter, any percent encoded, non-forbidden character
2130      * is decoded and only %'s in front of invalid hex digits are encoded.
2131      */
2132     {   "file:///C:/te%3Es%2Et/t%23es%t.mp3", 0, S_OK, FALSE,
2133         {
2134             {"file:///C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2135             {"",S_FALSE,FALSE},
2136             {"file:///C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2137             {"",S_FALSE,FALSE},
2138             {".mp3",S_OK,FALSE},
2139             {"",S_FALSE,FALSE},
2140             {"",S_FALSE,FALSE},
2141             {"",S_FALSE,FALSE},
2142             {"/C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2143             {"/C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2144             {"",S_FALSE,FALSE},
2145             {"file:///C:/te%3Es%2Et/t%23es%t.mp3",S_OK,FALSE},
2146             {"file",S_OK,FALSE},
2147             {"",S_FALSE,FALSE},
2148             {"",S_FALSE,FALSE}
2149         },
2150         {
2151             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2152             {0,S_FALSE,FALSE},
2153             {URL_SCHEME_FILE,S_OK,FALSE},
2154             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2155         }
2156     },
2157     /* Only unreserved percent encoded characters are decoded for known schemes that aren't file. */
2158     {   "http://[::001.002.003.000]/%3F%23%2E%54/test", 0, S_OK, FALSE,
2159         {
2160             {"http://[::1.2.3.0]/%3F%23.T/test",S_OK,FALSE},
2161             {"[::1.2.3.0]",S_OK,FALSE},
2162             {"http://[::1.2.3.0]/%3F%23.T/test",S_OK,FALSE},
2163             {"",S_FALSE,FALSE},
2164             {"",S_FALSE,FALSE},
2165             {"",S_FALSE,FALSE},
2166             {"::1.2.3.0",S_OK,FALSE},
2167             {"",S_FALSE,FALSE},
2168             {"/%3F%23.T/test",S_OK,FALSE},
2169             {"/%3F%23.T/test",S_OK,FALSE},
2170             {"",S_FALSE,FALSE},
2171             {"http://[::001.002.003.000]/%3F%23%2E%54/test",S_OK,FALSE},
2172             {"http",S_OK,FALSE},
2173             {"",S_FALSE,FALSE},
2174             {"",S_FALSE,FALSE},
2175         },
2176         {
2177             {Uri_HOST_IPV6,S_OK,FALSE},
2178             {80,S_OK,FALSE},
2179             {URL_SCHEME_HTTP,S_OK,FALSE},
2180             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2181         }
2182     },
2183     /* Forbidden characters are always encoded for file URIs. */
2184     {   "file:///C:/\"test\"/test.mp3", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2185         {
2186             {"file:///C:/%22test%22/test.mp3",S_OK,FALSE},
2187             {"",S_FALSE,FALSE},
2188             {"file:///C:/%22test%22/test.mp3",S_OK,FALSE},
2189             {"",S_FALSE,FALSE},
2190             {".mp3",S_OK,FALSE},
2191             {"",S_FALSE,FALSE},
2192             {"",S_FALSE,FALSE},
2193             {"",S_FALSE,FALSE},
2194             {"/C:/%22test%22/test.mp3",S_OK,FALSE},
2195             {"/C:/%22test%22/test.mp3",S_OK,FALSE},
2196             {"",S_FALSE,FALSE},
2197             {"file:///C:/\"test\"/test.mp3",S_OK,FALSE},
2198             {"file",S_OK,FALSE},
2199             {"",S_FALSE,FALSE},
2200             {"",S_FALSE,FALSE}
2201         },
2202         {
2203             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2204             {0,S_FALSE,FALSE},
2205             {URL_SCHEME_FILE,S_OK,FALSE},
2206             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2207         }
2208     },
2209     /* Forbidden characters are never encoded for unknown scheme types. */
2210     {   "1234://4294967295/<|>\" test<|>", 0, S_OK, FALSE,
2211         {
2212             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2213             {"4294967295",S_OK,FALSE},
2214             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2215             {"",S_FALSE,FALSE},
2216             {"",S_FALSE,FALSE},
2217             {"",S_FALSE,FALSE},
2218             {"4294967295",S_OK,FALSE},
2219             {"",S_FALSE,FALSE},
2220             {"/<|>\" test<|>",S_OK,FALSE},
2221             {"/<|>\" test<|>",S_OK,FALSE},
2222             {"",S_FALSE,FALSE},
2223             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2224             {"1234",S_OK,FALSE},
2225             {"",S_FALSE,FALSE},
2226             {"",S_FALSE,FALSE}
2227         },
2228         {
2229             {Uri_HOST_IPV4,S_OK,FALSE},
2230             {0,S_FALSE,FALSE},
2231             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2232             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2233         }
2234     },
2235     /* Make sure forbidden characters are percent encoded. */
2236     {   "http://gov.uk/<|> test<|>", 0, S_OK, FALSE,
2237         {
2238             {"http://gov.uk/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2239             {"gov.uk",S_OK,FALSE},
2240             {"http://gov.uk/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2241             {"",S_FALSE,FALSE},
2242             {"",S_FALSE,FALSE},
2243             {"",S_FALSE,FALSE},
2244             {"gov.uk",S_OK,FALSE},
2245             {"",S_FALSE,FALSE},
2246             {"/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2247             {"/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2248             {"",S_FALSE,FALSE},
2249             {"http://gov.uk/<|> test<|>",S_OK,FALSE},
2250             {"http",S_OK,FALSE},
2251             {"",S_FALSE,FALSE},
2252             {"",S_FALSE,FALSE}
2253         },
2254         {
2255             {Uri_HOST_DNS,S_OK,FALSE},
2256             {80,S_OK,FALSE},
2257             {URL_SCHEME_HTTP,S_OK,FALSE},
2258             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2259         }
2260     },
2261     {   "http://gov.uk/test/../test2/././../test3/.././././", 0, S_OK, FALSE,
2262         {
2263             {"http://gov.uk/",S_OK,FALSE},
2264             {"gov.uk",S_OK,FALSE},
2265             {"http://gov.uk/",S_OK,FALSE},
2266             {"",S_FALSE,FALSE},
2267             {"",S_FALSE,FALSE},
2268             {"",S_FALSE,FALSE},
2269             {"gov.uk",S_OK,FALSE},
2270             {"",S_FALSE,FALSE},
2271             {"/",S_OK,FALSE},
2272             {"/",S_OK,FALSE},
2273             {"",S_FALSE,FALSE},
2274             {"http://gov.uk/test/../test2/././../test3/.././././",S_OK,FALSE},
2275             {"http",S_OK,FALSE},
2276             {"",S_FALSE,FALSE},
2277             {"",S_FALSE,FALSE}
2278         },
2279         {
2280             {Uri_HOST_DNS,S_OK,FALSE},
2281             {80,S_OK,FALSE},
2282             {URL_SCHEME_HTTP,S_OK,FALSE},
2283             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2284         }
2285     },
2286     {   "http://gov.uk/test/test2/../../..", 0, S_OK, FALSE,
2287         {
2288             {"http://gov.uk/",S_OK,FALSE},
2289             {"gov.uk",S_OK,FALSE},
2290             {"http://gov.uk/",S_OK,FALSE},
2291             {"",S_FALSE,FALSE},
2292             {"",S_FALSE,FALSE},
2293             {"",S_FALSE,FALSE},
2294             {"gov.uk",S_OK,FALSE},
2295             {"",S_FALSE,FALSE},
2296             {"/",S_OK,FALSE},
2297             {"/",S_OK,FALSE},
2298             {"",S_FALSE,FALSE},
2299             {"http://gov.uk/test/test2/../../..",S_OK,FALSE},
2300             {"http",S_OK,FALSE},
2301             {"",S_FALSE,FALSE},
2302             {"",S_FALSE,FALSE}
2303         },
2304         {
2305             {Uri_HOST_DNS,S_OK,FALSE},
2306             {80,S_OK,FALSE},
2307             {URL_SCHEME_HTTP,S_OK,FALSE},
2308             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2309         }
2310     },
2311     {   "http://gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2312         {
2313             {"http://gov.uk/",S_OK,FALSE},
2314             {"gov.uk",S_OK,FALSE},
2315             {"http://gov.uk/",S_OK,FALSE},
2316             {"",S_FALSE,FALSE},
2317             {"",S_FALSE,FALSE},
2318             {"",S_FALSE,FALSE},
2319             {"gov.uk",S_OK,FALSE},
2320             {"",S_FALSE,FALSE},
2321             {"/",S_OK,FALSE},
2322             {"/",S_OK,FALSE},
2323             {"",S_FALSE,FALSE},
2324             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2325             {"http",S_OK,FALSE},
2326             {"",S_FALSE,FALSE},
2327             {"",S_FALSE,FALSE}
2328         },
2329         {
2330             {Uri_HOST_DNS,S_OK,FALSE},
2331             {80,S_OK,FALSE},
2332             {URL_SCHEME_HTTP,S_OK,FALSE},
2333             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2334         }
2335     },
2336     {   "file://c:\\tests\\../tests\\./.\\..\\foo%20bar.mp3", 0, S_OK, FALSE,
2337         {
2338             {"file:///c:/foo%2520bar.mp3",S_OK,FALSE},
2339             {"",S_FALSE,FALSE},
2340             {"file:///c:/foo%2520bar.mp3",S_OK,FALSE},
2341             {"",S_FALSE,FALSE},
2342             {".mp3",S_OK,FALSE},
2343             {"",S_FALSE,FALSE},
2344             {"",S_FALSE,FALSE},
2345             {"",S_FALSE,FALSE},
2346             {"/c:/foo%2520bar.mp3",S_OK,FALSE},
2347             {"/c:/foo%2520bar.mp3",S_OK,FALSE},
2348             {"",S_FALSE,FALSE},
2349             {"file://c:\\tests\\../tests\\./.\\..\\foo%20bar.mp3",S_OK,FALSE},
2350             {"file",S_OK,FALSE},
2351             {"",S_FALSE,FALSE},
2352             {"",S_FALSE,FALSE}
2353         },
2354         {
2355             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2356             {0,S_FALSE,FALSE},
2357             {URL_SCHEME_FILE,S_OK,FALSE},
2358             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2359         }
2360     },
2361     /* Dot removal happens for unknown scheme types. */
2362     {   "zip://gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2363         {
2364             {"zip://gov.uk/",S_OK,FALSE},
2365             {"gov.uk",S_OK,FALSE},
2366             {"zip://gov.uk/",S_OK,FALSE},
2367             {"",S_FALSE,FALSE},
2368             {"",S_FALSE,FALSE},
2369             {"",S_FALSE,FALSE},
2370             {"gov.uk",S_OK,FALSE},
2371             {"",S_FALSE,FALSE},
2372             {"/",S_OK,FALSE},
2373             {"/",S_OK,FALSE},
2374             {"",S_FALSE,FALSE},
2375             {"zip://gov.uk/test/test2/../../.",S_OK,FALSE},
2376             {"zip",S_OK,FALSE},
2377             {"",S_FALSE,FALSE},
2378             {"",S_FALSE,FALSE}
2379         },
2380         {
2381             {Uri_HOST_DNS,S_OK,FALSE},
2382             {0,S_FALSE,FALSE},
2383             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2384             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2385         }
2386     },
2387     /* Dot removal doesn't happen if NO_CANONICALIZE is set. */
2388     {   "http://gov.uk/test/test2/../../.", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2389         {
2390             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2391             {"gov.uk",S_OK,FALSE},
2392             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2393             {"",S_FALSE,FALSE},
2394             {".",S_OK,FALSE},
2395             {"",S_FALSE,FALSE},
2396             {"gov.uk",S_OK,FALSE},
2397             {"",S_FALSE,FALSE},
2398             {"/test/test2/../../.",S_OK,FALSE},
2399             {"/test/test2/../../.",S_OK,FALSE},
2400             {"",S_FALSE,FALSE},
2401             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2402             {"http",S_OK,FALSE},
2403             {"",S_FALSE,FALSE},
2404             {"",S_FALSE,FALSE}
2405         },
2406         {
2407             {Uri_HOST_DNS,S_OK,FALSE},
2408             {80,S_OK,FALSE},
2409             {URL_SCHEME_HTTP,S_OK,FALSE},
2410             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2411         }
2412     },
2413     /* Dot removal doesn't happen for wildcard scheme types. */
2414     {   "*:gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2415         {
2416             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2417             {"gov.uk",S_OK,FALSE},
2418             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2419             {"",S_FALSE,FALSE},
2420             {".",S_OK,FALSE},
2421             {"",S_FALSE,FALSE},
2422             {"gov.uk",S_OK,FALSE},
2423             {"",S_FALSE,FALSE},
2424             {"/test/test2/../../.",S_OK,FALSE},
2425             {"/test/test2/../../.",S_OK,FALSE},
2426             {"",S_FALSE,FALSE},
2427             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2428             {"*",S_OK,FALSE},
2429             {"",S_FALSE,FALSE},
2430             {"",S_FALSE,FALSE}
2431         },
2432         {
2433             {Uri_HOST_DNS,S_OK,FALSE},
2434             {0,S_FALSE,FALSE},
2435             {URL_SCHEME_WILDCARD,S_OK,FALSE},
2436             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2437         }
2438     },
2439     /* Forbidden characters are encoded for opaque known scheme types. */
2440     {   "mailto:\"acco<|>unt@example.com\"", 0, S_OK, FALSE,
2441         {
2442             {"mailto:%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2443             {"",S_FALSE,FALSE},
2444             {"mailto:%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2445             {"",S_FALSE,FALSE},
2446             {".com%22",S_OK,FALSE},
2447             {"",S_FALSE,FALSE},
2448             {"",S_FALSE,FALSE},
2449             {"",S_FALSE,FALSE},
2450             {"%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2451             {"%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2452             {"",S_FALSE,FALSE},
2453             {"mailto:\"acco<|>unt@example.com\"",S_OK,FALSE},
2454             {"mailto",S_OK,FALSE},
2455             {"",S_FALSE,FALSE},
2456             {"",S_FALSE,FALSE}
2457         },
2458         {
2459             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2460             {0,S_FALSE,FALSE},
2461             {URL_SCHEME_MAILTO,S_OK,FALSE},
2462             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2463         }
2464     },
2465     {   "news:test.tes<|>t.com", 0, S_OK, FALSE,
2466         {
2467             {"news:test.tes%3C%7C%3Et.com",S_OK,FALSE},
2468             {"",S_FALSE,FALSE},
2469             {"news:test.tes%3C%7C%3Et.com",S_OK,FALSE},
2470             {"",S_FALSE,FALSE},
2471             {".com",S_OK,FALSE},
2472             {"",S_FALSE,FALSE},
2473             {"",S_FALSE,FALSE},
2474             {"",S_FALSE,FALSE},
2475             {"test.tes%3C%7C%3Et.com",S_OK,FALSE},
2476             {"test.tes%3C%7C%3Et.com",S_OK,FALSE},
2477             {"",S_FALSE,FALSE},
2478             {"news:test.tes<|>t.com",S_OK,FALSE},
2479             {"news",S_OK,FALSE},
2480             {"",S_FALSE,FALSE},
2481             {"",S_FALSE,FALSE}
2482         },
2483         {
2484             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2485             {0,S_FALSE,FALSE},
2486             {URL_SCHEME_NEWS,S_OK,FALSE},
2487             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2488         }
2489     },
2490     /* Don't encode forbidden characters. */
2491     {   "news:test.tes<|>t.com", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2492         {
2493             {"news:test.tes<|>t.com",S_OK,FALSE},
2494             {"",S_FALSE,FALSE},
2495             {"news:test.tes<|>t.com",S_OK,FALSE},
2496             {"",S_FALSE,FALSE},
2497             {".com",S_OK,FALSE},
2498             {"",S_FALSE,FALSE},
2499             {"",S_FALSE,FALSE},
2500             {"",S_FALSE,FALSE},
2501             {"test.tes<|>t.com",S_OK,FALSE},
2502             {"test.tes<|>t.com",S_OK,FALSE},
2503             {"",S_FALSE,FALSE},
2504             {"news:test.tes<|>t.com",S_OK,FALSE},
2505             {"news",S_OK,FALSE},
2506             {"",S_FALSE,FALSE},
2507             {"",S_FALSE,FALSE}
2508         },
2509         {
2510             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2511             {0,S_FALSE,FALSE},
2512             {URL_SCHEME_NEWS,S_OK,FALSE},
2513             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2514         }
2515     },
2516     /* Forbidden characters aren't encoded for unknown, opaque URIs. */
2517     {   "urn:test.tes<|>t.com", 0, S_OK, FALSE,
2518         {
2519             {"urn:test.tes<|>t.com",S_OK,FALSE},
2520             {"",S_FALSE,FALSE},
2521             {"urn:test.tes<|>t.com",S_OK,FALSE},
2522             {"",S_FALSE,FALSE},
2523             {".com",S_OK,FALSE},
2524             {"",S_FALSE,FALSE},
2525             {"",S_FALSE,FALSE},
2526             {"",S_FALSE,FALSE},
2527             {"test.tes<|>t.com",S_OK,FALSE},
2528             {"test.tes<|>t.com",S_OK,FALSE},
2529             {"",S_FALSE,FALSE},
2530             {"urn:test.tes<|>t.com",S_OK,FALSE},
2531             {"urn",S_OK,FALSE},
2532             {"",S_FALSE,FALSE},
2533             {"",S_FALSE,FALSE}
2534         },
2535         {
2536             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2537             {0,S_FALSE,FALSE},
2538             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2539             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2540         }
2541     },
2542     /* Percent encoded unreserved characters are decoded for known opaque URIs. */
2543     {   "news:test.%74%65%73%74.com", 0, S_OK, FALSE,
2544         {
2545             {"news:test.test.com",S_OK,FALSE},
2546             {"",S_FALSE,FALSE},
2547             {"news:test.test.com",S_OK,FALSE},
2548             {"",S_FALSE,FALSE},
2549             {".com",S_OK,FALSE},
2550             {"",S_FALSE,FALSE},
2551             {"",S_FALSE,FALSE},
2552             {"",S_FALSE,FALSE},
2553             {"test.test.com",S_OK,FALSE},
2554             {"test.test.com",S_OK,FALSE},
2555             {"",S_FALSE,FALSE},
2556             {"news:test.%74%65%73%74.com",S_OK,FALSE},
2557             {"news",S_OK,FALSE},
2558             {"",S_FALSE,FALSE},
2559             {"",S_FALSE,FALSE}
2560         },
2561         {
2562             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2563             {0,S_FALSE,FALSE},
2564             {URL_SCHEME_NEWS,S_OK,FALSE},
2565             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2566         }
2567     },
2568     /* Percent encoded characters are still decoded for known scheme types. */
2569     {   "news:test.%74%65%73%74.com", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2570         {
2571             {"news:test.test.com",S_OK,FALSE},
2572             {"",S_FALSE,FALSE},
2573             {"news:test.test.com",S_OK,FALSE},
2574             {"",S_FALSE,FALSE},
2575             {".com",S_OK,FALSE},
2576             {"",S_FALSE,FALSE},
2577             {"",S_FALSE,FALSE},
2578             {"",S_FALSE,FALSE},
2579             {"test.test.com",S_OK,FALSE},
2580             {"test.test.com",S_OK,FALSE},
2581             {"",S_FALSE,FALSE},
2582             {"news:test.%74%65%73%74.com",S_OK,FALSE},
2583             {"news",S_OK,FALSE},
2584             {"",S_FALSE,FALSE},
2585             {"",S_FALSE,FALSE}
2586         },
2587         {
2588             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2589             {0,S_FALSE,FALSE},
2590             {URL_SCHEME_NEWS,S_OK,FALSE},
2591             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2592         }
2593     },
2594     /* Percent encoded characters aren't decoded for unknown scheme types. */
2595     {   "urn:test.%74%65%73%74.com", 0, S_OK, FALSE,
2596         {
2597             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2598             {"",S_FALSE,FALSE},
2599             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2600             {"",S_FALSE,FALSE},
2601             {".com",S_OK,FALSE},
2602             {"",S_FALSE,FALSE},
2603             {"",S_FALSE,FALSE},
2604             {"",S_FALSE,FALSE},
2605             {"test.%74%65%73%74.com",S_OK,FALSE},
2606             {"test.%74%65%73%74.com",S_OK,FALSE},
2607             {"",S_FALSE,FALSE},
2608             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2609             {"urn",S_OK,FALSE},
2610             {"",S_FALSE,FALSE},
2611             {"",S_FALSE,FALSE}
2612         },
2613         {
2614             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2615             {0,S_FALSE,FALSE},
2616             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2617             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2618         }
2619     },
2620     /* Unknown scheme types can have invalid % encoded data in query string. */
2621     {   "zip://www.winehq.org/tests/..?query=%xx&return=y", 0, S_OK, FALSE,
2622         {
2623             {"zip://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2624             {"www.winehq.org",S_OK,FALSE},
2625             {"zip://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2626             {"winehq.org",S_OK,FALSE},
2627             {"",S_FALSE,FALSE},
2628             {"",S_FALSE,FALSE},
2629             {"www.winehq.org",S_OK,FALSE},
2630             {"",S_FALSE,FALSE},
2631             {"/",S_OK,FALSE},
2632             {"/?query=%xx&return=y",S_OK,FALSE},
2633             {"?query=%xx&return=y",S_OK,FALSE},
2634             {"zip://www.winehq.org/tests/..?query=%xx&return=y",S_OK,FALSE},
2635             {"zip",S_OK,FALSE},
2636             {"",S_FALSE,FALSE},
2637             {"",S_FALSE,FALSE}
2638         },
2639         {
2640             {Uri_HOST_DNS,S_OK,FALSE},
2641             {0,S_FALSE,FALSE},
2642             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2643             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2644         }
2645     },
2646     /* Known scheme types can have invalid % encoded data with the right flags. */
2647     {   "http://www.winehq.org/tests/..?query=%xx&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2648         {
2649             {"http://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2650             {"www.winehq.org",S_OK,FALSE},
2651             {"http://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2652             {"winehq.org",S_OK,FALSE},
2653             {"",S_FALSE,FALSE},
2654             {"",S_FALSE,FALSE},
2655             {"www.winehq.org",S_OK,FALSE},
2656             {"",S_FALSE,FALSE},
2657             {"/",S_OK,FALSE},
2658             {"/?query=%xx&return=y",S_OK,FALSE},
2659             {"?query=%xx&return=y",S_OK,FALSE},
2660             {"http://www.winehq.org/tests/..?query=%xx&return=y",S_OK,FALSE},
2661             {"http",S_OK,FALSE},
2662             {"",S_FALSE,FALSE},
2663             {"",S_FALSE,FALSE}
2664         },
2665         {
2666             {Uri_HOST_DNS,S_OK,FALSE},
2667             {80,S_OK,FALSE},
2668             {URL_SCHEME_HTTP,S_OK,FALSE},
2669             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2670         }
2671     },
2672     /* Forbidden characters in query aren't percent encoded for known scheme types with this flag. */
2673     {   "http://www.winehq.org/tests/..?query=<|>&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2674         {
2675             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2676             {"www.winehq.org",S_OK,FALSE},
2677             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2678             {"winehq.org",S_OK,FALSE},
2679             {"",S_FALSE,FALSE},
2680             {"",S_FALSE,FALSE},
2681             {"www.winehq.org",S_OK,FALSE},
2682             {"",S_FALSE,FALSE},
2683             {"/",S_OK,FALSE},
2684             {"/?query=<|>&return=y",S_OK,FALSE},
2685             {"?query=<|>&return=y",S_OK,FALSE},
2686             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2687             {"http",S_OK,FALSE},
2688             {"",S_FALSE,FALSE},
2689             {"",S_FALSE,FALSE}
2690         },
2691         {
2692             {Uri_HOST_DNS,S_OK,FALSE},
2693             {80,S_OK,FALSE},
2694             {URL_SCHEME_HTTP,S_OK,FALSE},
2695             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2696         }
2697     },
2698     /* Forbidden characters in query aren't percent encoded for known scheme types with this flag. */
2699     {   "http://www.winehq.org/tests/..?query=<|>&return=y", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2700         {
2701             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2702             {"www.winehq.org",S_OK,FALSE},
2703             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2704             {"winehq.org",S_OK,FALSE},
2705             {"",S_FALSE,FALSE},
2706             {"",S_FALSE,FALSE},
2707             {"www.winehq.org",S_OK,FALSE},
2708             {"",S_FALSE,FALSE},
2709             {"/",S_OK,FALSE},
2710             {"/?query=<|>&return=y",S_OK,FALSE},
2711             {"?query=<|>&return=y",S_OK,FALSE},
2712             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2713             {"http",S_OK,FALSE},
2714             {"",S_FALSE,FALSE},
2715             {"",S_FALSE,FALSE}
2716         },
2717         {
2718             {Uri_HOST_DNS,S_OK,FALSE},
2719             {80,S_OK,FALSE},
2720             {URL_SCHEME_HTTP,S_OK,FALSE},
2721             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2722         }
2723     },
2724     /* Forbidden characters are encoded for known scheme types. */
2725     {   "http://www.winehq.org/tests/..?query=<|>&return=y", 0, S_OK, FALSE,
2726         {
2727             {"http://www.winehq.org/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2728             {"www.winehq.org",S_OK,FALSE},
2729             {"http://www.winehq.org/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2730             {"winehq.org",S_OK,FALSE},
2731             {"",S_FALSE,FALSE},
2732             {"",S_FALSE,FALSE},
2733             {"www.winehq.org",S_OK,FALSE},
2734             {"",S_FALSE,FALSE},
2735             {"/",S_OK,FALSE},
2736             {"/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2737             {"?query=%3C%7C%3E&return=y",S_OK,FALSE},
2738             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2739             {"http",S_OK,FALSE},
2740             {"",S_FALSE,FALSE},
2741             {"",S_FALSE,FALSE}
2742         },
2743         {
2744             {Uri_HOST_DNS,S_OK,FALSE},
2745             {80,S_OK,FALSE},
2746             {URL_SCHEME_HTTP,S_OK,FALSE},
2747             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2748         }
2749     },
2750     /* Forbidden characters are not encoded for unknown scheme types. */
2751     {   "zip://www.winehq.org/tests/..?query=<|>&return=y", 0, S_OK, FALSE,
2752         {
2753             {"zip://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2754             {"www.winehq.org",S_OK,FALSE},
2755             {"zip://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2756             {"winehq.org",S_OK,FALSE},
2757             {"",S_FALSE,FALSE},
2758             {"",S_FALSE,FALSE},
2759             {"www.winehq.org",S_OK,FALSE},
2760             {"",S_FALSE,FALSE},
2761             {"/",S_OK,FALSE},
2762             {"/?query=<|>&return=y",S_OK,FALSE},
2763             {"?query=<|>&return=y",S_OK,FALSE},
2764             {"zip://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2765             {"zip",S_OK,FALSE},
2766             {"",S_FALSE,FALSE},
2767             {"",S_FALSE,FALSE}
2768         },
2769         {
2770             {Uri_HOST_DNS,S_OK,FALSE},
2771             {0,S_FALSE,FALSE},
2772             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2773             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2774         }
2775     },
2776     /* Percent encoded, unreserved characters are decoded for known scheme types. */
2777     {   "http://www.winehq.org/tests/..?query=%30%31&return=y", 0, S_OK, FALSE,
2778         {
2779             {"http://www.winehq.org/?query=01&return=y",S_OK,FALSE},
2780             {"www.winehq.org",S_OK,FALSE},
2781             {"http://www.winehq.org/?query=01&return=y",S_OK,FALSE},
2782             {"winehq.org",S_OK,FALSE},
2783             {"",S_FALSE,FALSE},
2784             {"",S_FALSE,FALSE},
2785             {"www.winehq.org",S_OK,FALSE},
2786             {"",S_FALSE,FALSE},
2787             {"/",S_OK,FALSE},
2788             {"/?query=01&return=y",S_OK,FALSE},
2789             {"?query=01&return=y",S_OK,FALSE},
2790             {"http://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2791             {"http",S_OK,FALSE},
2792             {"",S_FALSE,FALSE},
2793             {"",S_FALSE,FALSE}
2794         },
2795         {
2796             {Uri_HOST_DNS,S_OK,FALSE},
2797             {80,S_OK,FALSE},
2798             {URL_SCHEME_HTTP,S_OK,FALSE},
2799             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2800         }
2801     },
2802     /* Percent encoded, unreserved characters aren't decoded for unknown scheme types. */
2803     {   "zip://www.winehq.org/tests/..?query=%30%31&return=y", 0, S_OK, FALSE,
2804         {
2805             {"zip://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2806             {"www.winehq.org",S_OK,FALSE},
2807             {"zip://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2808             {"winehq.org",S_OK,FALSE},
2809             {"",S_FALSE,FALSE},
2810             {"",S_FALSE,FALSE},
2811             {"www.winehq.org",S_OK,FALSE},
2812             {"",S_FALSE,FALSE},
2813             {"/",S_OK,FALSE},
2814             {"/?query=%30%31&return=y",S_OK,FALSE},
2815             {"?query=%30%31&return=y",S_OK,FALSE},
2816             {"zip://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2817             {"zip",S_OK,FALSE},
2818             {"",S_FALSE,FALSE},
2819             {"",S_FALSE,FALSE}
2820         },
2821         {
2822             {Uri_HOST_DNS,S_OK,FALSE},
2823             {0,S_FALSE,FALSE},
2824             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2825             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2826         }
2827     },
2828     /* Percent encoded characters aren't decoded when NO_DECODE_EXTRA_INFO is set. */
2829     {   "http://www.winehq.org/tests/..?query=%30%31&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2830         {
2831             {"http://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2832             {"www.winehq.org",S_OK,FALSE},
2833             {"http://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2834             {"winehq.org",S_OK,FALSE},
2835             {"",S_FALSE,FALSE},
2836             {"",S_FALSE,FALSE},
2837             {"www.winehq.org",S_OK,FALSE},
2838             {"",S_FALSE,FALSE},
2839             {"/",S_OK,FALSE},
2840             {"/?query=%30%31&return=y",S_OK,FALSE},
2841             {"?query=%30%31&return=y",S_OK,FALSE},
2842             {"http://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2843             {"http",S_OK,FALSE},
2844             {"",S_FALSE,FALSE},
2845             {"",S_FALSE,FALSE}
2846         },
2847         {
2848             {Uri_HOST_DNS,S_OK,FALSE},
2849             {80,S_OK,FALSE},
2850             {URL_SCHEME_HTTP,S_OK,FALSE},
2851             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2852         }
2853     },
2854     {   "http://www.winehq.org?query=12&return=y", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2855         {
2856             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2857             {"www.winehq.org",S_OK,FALSE},
2858             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2859             {"winehq.org",S_OK,FALSE},
2860             {"",S_FALSE,FALSE},
2861             {"",S_FALSE,FALSE},
2862             {"www.winehq.org",S_OK,FALSE},
2863             {"",S_FALSE,FALSE},
2864             {"",S_FALSE,FALSE},
2865             {"?query=12&return=y",S_OK,FALSE},
2866             {"?query=12&return=y",S_OK,FALSE},
2867             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2868             {"http",S_OK,FALSE},
2869             {"",S_FALSE,FALSE},
2870             {"",S_FALSE,FALSE}
2871         },
2872         {
2873             {Uri_HOST_DNS,S_OK,FALSE},
2874             {80,S_OK,FALSE},
2875             {URL_SCHEME_HTTP,S_OK,FALSE},
2876             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2877         }
2878     },
2879     /* Unknown scheme types can have invalid % encoded data in fragments. */
2880     {   "zip://www.winehq.org/tests/#Te%xx", 0, S_OK, FALSE,
2881         {
2882             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2883             {"www.winehq.org",S_OK,FALSE},
2884             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2885             {"winehq.org",S_OK,FALSE},
2886             {"",S_FALSE,FALSE},
2887             {"#Te%xx",S_OK,FALSE},
2888             {"www.winehq.org",S_OK,FALSE},
2889             {"",S_FALSE,FALSE},
2890             {"/tests/",S_OK,FALSE},
2891             {"/tests/",S_OK,FALSE},
2892             {"",S_FALSE,FALSE},
2893             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2894             {"zip",S_OK,FALSE},
2895             {"",S_FALSE,FALSE},
2896             {"",S_FALSE,FALSE}
2897         },
2898         {
2899             {Uri_HOST_DNS,S_OK,FALSE},
2900             {0,S_FALSE,FALSE},
2901             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2902             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2903         }
2904     },
2905     /* Forbidden characters in fragment aren't encoded for unknown schemes. */
2906     {   "zip://www.winehq.org/tests/#Te<|>", 0, S_OK, FALSE,
2907         {
2908             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2909             {"www.winehq.org",S_OK,FALSE},
2910             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2911             {"winehq.org",S_OK,FALSE},
2912             {"",S_FALSE,FALSE},
2913             {"#Te<|>",S_OK,FALSE},
2914             {"www.winehq.org",S_OK,FALSE},
2915             {"",S_FALSE,FALSE},
2916             {"/tests/",S_OK,FALSE},
2917             {"/tests/",S_OK,FALSE},
2918             {"",S_FALSE,FALSE},
2919             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2920             {"zip",S_OK,FALSE},
2921             {"",S_FALSE,FALSE},
2922             {"",S_FALSE,FALSE}
2923         },
2924         {
2925             {Uri_HOST_DNS,S_OK,FALSE},
2926             {0,S_FALSE,FALSE},
2927             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2928             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2929         }
2930     },
2931     /* Forbidden characters in the fragment are percent encoded for known schemes. */
2932     {   "http://www.winehq.org/tests/#Te<|>", 0, S_OK, FALSE,
2933         {
2934             {"http://www.winehq.org/tests/#Te%3C%7C%3E",S_OK,FALSE},
2935             {"www.winehq.org",S_OK,FALSE},
2936             {"http://www.winehq.org/tests/#Te%3C%7C%3E",S_OK,FALSE},
2937             {"winehq.org",S_OK,FALSE},
2938             {"",S_FALSE,FALSE},
2939             {"#Te%3C%7C%3E",S_OK,FALSE},
2940             {"www.winehq.org",S_OK,FALSE},
2941             {"",S_FALSE,FALSE},
2942             {"/tests/",S_OK,FALSE},
2943             {"/tests/",S_OK,FALSE},
2944             {"",S_FALSE,FALSE},
2945             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2946             {"http",S_OK,FALSE},
2947             {"",S_FALSE,FALSE},
2948             {"",S_FALSE,FALSE}
2949         },
2950         {
2951             {Uri_HOST_DNS,S_OK,FALSE},
2952             {80,S_OK,FALSE},
2953             {URL_SCHEME_HTTP,S_OK,FALSE},
2954             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2955         }
2956     },
2957     /* Forbidden characters aren't encoded in the fragment with this flag. */
2958     {   "http://www.winehq.org/tests/#Te<|>", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2959         {
2960             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2961             {"www.winehq.org",S_OK,FALSE},
2962             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2963             {"winehq.org",S_OK,FALSE},
2964             {"",S_FALSE,FALSE},
2965             {"#Te<|>",S_OK,FALSE},
2966             {"www.winehq.org",S_OK,FALSE},
2967             {"",S_FALSE,FALSE},
2968             {"/tests/",S_OK,FALSE},
2969             {"/tests/",S_OK,FALSE},
2970             {"",S_FALSE,FALSE},
2971             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2972             {"http",S_OK,FALSE},
2973             {"",S_FALSE,FALSE},
2974             {"",S_FALSE,FALSE}
2975         },
2976         {
2977             {Uri_HOST_DNS,S_OK,FALSE},
2978             {80,S_OK,FALSE},
2979             {URL_SCHEME_HTTP,S_OK,FALSE},
2980             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2981         }
2982     },
2983     /* Forbidden characters aren't encoded in the fragment with this flag. */
2984     {   "http://www.winehq.org/tests/#Te<|>", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2985         {
2986             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2987             {"www.winehq.org",S_OK,FALSE},
2988             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2989             {"winehq.org",S_OK,FALSE},
2990             {"",S_FALSE,FALSE},
2991             {"#Te<|>",S_OK,FALSE},
2992             {"www.winehq.org",S_OK,FALSE},
2993             {"",S_FALSE,FALSE},
2994             {"/tests/",S_OK,FALSE},
2995             {"/tests/",S_OK,FALSE},
2996             {"",S_FALSE,FALSE},
2997             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2998             {"http",S_OK,FALSE},
2999             {"",S_FALSE,FALSE},
3000             {"",S_FALSE,FALSE}
3001         },
3002         {
3003             {Uri_HOST_DNS,S_OK,FALSE},
3004             {80,S_OK,FALSE},
3005             {URL_SCHEME_HTTP,S_OK,FALSE},
3006             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3007         }
3008     },
3009     /* Percent encoded, unreserved characters aren't decoded for known scheme types. */
3010     {   "zip://www.winehq.org/tests/#Te%30%31%32", 0, S_OK, FALSE,
3011         {
3012             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3013             {"www.winehq.org",S_OK,FALSE},
3014             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3015             {"winehq.org",S_OK,FALSE},
3016             {"",S_FALSE,FALSE},
3017             {"#Te%30%31%32",S_OK,FALSE},
3018             {"www.winehq.org",S_OK,FALSE},
3019             {"",S_FALSE,FALSE},
3020             {"/tests/",S_OK,FALSE},
3021             {"/tests/",S_OK,FALSE},
3022             {"",S_FALSE,FALSE},
3023             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3024             {"zip",S_OK,FALSE},
3025             {"",S_FALSE,FALSE},
3026             {"",S_FALSE,FALSE}
3027         },
3028         {
3029             {Uri_HOST_DNS,S_OK,FALSE},
3030             {0,S_FALSE,FALSE},
3031             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3032             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3033         }
3034     },
3035     /* Percent encoded, unreserved characters are decoded for known schemes. */
3036     {   "http://www.winehq.org/tests/#Te%30%31%32", 0, S_OK, FALSE,
3037         {
3038             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
3039             {"www.winehq.org",S_OK,FALSE},
3040             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
3041             {"winehq.org",S_OK,FALSE},
3042             {"",S_FALSE,FALSE},
3043             {"#Te012",S_OK,FALSE},
3044             {"www.winehq.org",S_OK,FALSE},
3045             {"",S_FALSE,FALSE},
3046             {"/tests/",S_OK,FALSE},
3047             {"/tests/",S_OK,FALSE},
3048             {"",S_FALSE,FALSE},
3049             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3050             {"http",S_OK,FALSE},
3051             {"",S_FALSE,FALSE},
3052             {"",S_FALSE,FALSE}
3053         },
3054         {
3055             {Uri_HOST_DNS,S_OK,FALSE},
3056             {80,S_OK,FALSE},
3057             {URL_SCHEME_HTTP,S_OK,FALSE},
3058             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3059         }
3060     },
3061     /* Percent encoded, unreserved characters are decoded even if NO_CANONICALIZE is set. */
3062     {   "http://www.winehq.org/tests/#Te%30%31%32", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
3063         {
3064             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
3065             {"www.winehq.org",S_OK,FALSE},
3066             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
3067             {"winehq.org",S_OK,FALSE},
3068             {"",S_FALSE,FALSE},
3069             {"#Te012",S_OK,FALSE},
3070             {"www.winehq.org",S_OK,FALSE},
3071             {"",S_FALSE,FALSE},
3072             {"/tests/",S_OK,FALSE},
3073             {"/tests/",S_OK,FALSE},
3074             {"",S_FALSE,FALSE},
3075             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3076             {"http",S_OK,FALSE},
3077             {"",S_FALSE,FALSE},
3078             {"",S_FALSE,FALSE}
3079         },
3080         {
3081             {Uri_HOST_DNS,S_OK,FALSE},
3082             {80,S_OK,FALSE},
3083             {URL_SCHEME_HTTP,S_OK,FALSE},
3084             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3085         }
3086     },
3087     /* Percent encoded, unreserved characters aren't decoded when NO_DECODE_EXTRA is set. */
3088     {   "http://www.winehq.org/tests/#Te%30%31%32", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
3089         {
3090             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3091             {"www.winehq.org",S_OK,FALSE},
3092             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3093             {"winehq.org",S_OK,FALSE},
3094             {"",S_FALSE,FALSE},
3095             {"#Te%30%31%32",S_OK,FALSE},
3096             {"www.winehq.org",S_OK,FALSE},
3097             {"",S_FALSE,FALSE},
3098             {"/tests/",S_OK,FALSE},
3099             {"/tests/",S_OK,FALSE},
3100             {"",S_FALSE,FALSE},
3101             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3102             {"http",S_OK,FALSE},
3103             {"",S_FALSE,FALSE},
3104             {"",S_FALSE,FALSE}
3105         },
3106         {
3107             {Uri_HOST_DNS,S_OK,FALSE},
3108             {80,S_OK,FALSE},
3109             {URL_SCHEME_HTTP,S_OK,FALSE},
3110             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3111         }
3112     },
3113     /* Leading/Trailing whitespace is removed. */
3114     {   "    http://google.com/     ", 0, S_OK, FALSE,
3115         {
3116             {"http://google.com/",S_OK,FALSE},
3117             {"google.com",S_OK,FALSE},
3118             {"http://google.com/",S_OK,FALSE},
3119             {"google.com",S_OK,FALSE},
3120             {"",S_FALSE,FALSE},
3121             {"",S_FALSE,FALSE},
3122             {"google.com",S_OK,FALSE},
3123             {"",S_FALSE,FALSE},
3124             {"/",S_OK,FALSE},
3125             {"/",S_OK,FALSE},
3126             {"",S_FALSE,FALSE},
3127             {"http://google.com/",S_OK,FALSE},
3128             {"http",S_OK,FALSE},
3129             {"",S_FALSE,FALSE},
3130             {"",S_FALSE,FALSE}
3131         },
3132         {
3133             {Uri_HOST_DNS,S_OK,FALSE},
3134             {80,S_OK,FALSE},
3135             {URL_SCHEME_HTTP,S_OK,FALSE},
3136             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3137         }
3138     },
3139     {   "\t\t\r\nhttp\n://g\noogle.co\rm/\n\n\n", 0, S_OK, FALSE,
3140         {
3141             {"http://google.com/",S_OK,FALSE},
3142             {"google.com",S_OK,FALSE},
3143             {"http://google.com/",S_OK,FALSE},
3144             {"google.com",S_OK,FALSE},
3145             {"",S_FALSE,FALSE},
3146             {"",S_FALSE,FALSE},
3147             {"google.com",S_OK,FALSE},
3148             {"",S_FALSE,FALSE},
3149             {"/",S_OK,FALSE},
3150             {"/",S_OK,FALSE},
3151             {"",S_FALSE,FALSE},
3152             {"http://google.com/",S_OK,FALSE},
3153             {"http",S_OK,FALSE},
3154             {"",S_FALSE,FALSE},
3155             {"",S_FALSE,FALSE}
3156         },
3157         {
3158             {Uri_HOST_DNS,S_OK,FALSE},
3159             {80,S_OK,FALSE},
3160             {URL_SCHEME_HTTP,S_OK,FALSE},
3161             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3162         }
3163     },
3164     {   "http://g\noogle.co\rm/\n\n\n", Uri_CREATE_NO_PRE_PROCESS_HTML_URI, S_OK, FALSE,
3165         {
3166             {"http://g%0aoogle.co%0dm/%0A%0A%0A",S_OK,FALSE},
3167             {"g%0aoogle.co%0dm",S_OK,FALSE},
3168             {"http://g%0aoogle.co%0dm/%0A%0A%0A",S_OK,FALSE},
3169             {"g%0aoogle.co%0dm",S_OK,FALSE},
3170             {"",S_FALSE,FALSE},
3171             {"",S_FALSE,FALSE},
3172             {"g%0aoogle.co%0dm",S_OK,FALSE},
3173             {"",S_FALSE,FALSE},
3174             {"/%0A%0A%0A",S_OK,FALSE},
3175             {"/%0A%0A%0A",S_OK,FALSE},
3176             {"",S_FALSE,FALSE},
3177             {"http://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3178             {"http",S_OK,FALSE},
3179             {"",S_FALSE,FALSE},
3180             {"",S_FALSE,FALSE}
3181         },
3182         {
3183             {Uri_HOST_DNS,S_OK,FALSE},
3184             {80,S_OK,FALSE},
3185             {URL_SCHEME_HTTP,S_OK,FALSE},
3186             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3187         }
3188     },
3189     {   "zip://g\noogle.co\rm/\n\n\n", Uri_CREATE_NO_PRE_PROCESS_HTML_URI, S_OK, FALSE,
3190         {
3191             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3192             {"g\noogle.co\rm",S_OK,FALSE},
3193             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3194             {"g\noogle.co\rm",S_OK,FALSE},
3195             {"",S_FALSE,FALSE},
3196             {"",S_FALSE,FALSE},
3197             {"g\noogle.co\rm",S_OK,FALSE},
3198             {"",S_FALSE,FALSE},
3199             {"/\n\n\n",S_OK,FALSE},
3200             {"/\n\n\n",S_OK,FALSE},
3201             {"",S_FALSE,FALSE},
3202             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3203             {"zip",S_OK,FALSE},
3204             {"",S_FALSE,FALSE},
3205             {"",S_FALSE,FALSE}
3206         },
3207         {
3208             {Uri_HOST_DNS,S_OK,FALSE},
3209             {0,S_FALSE,FALSE},
3210             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3211             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3212         }
3213     },
3214     /* Since file URLs are usually hierarchical, it returns an empty string
3215      * for the absolute URI property since it was declared as an opaque URI.
3216      */
3217     {   "file:index.html", 0, S_OK, FALSE,
3218         {
3219             {"",S_FALSE,FALSE},
3220             {"",S_FALSE,FALSE},
3221             {"file:index.html",S_OK,FALSE},
3222             {"",S_FALSE,FALSE},
3223             {".html",S_OK,FALSE},
3224             {"",S_FALSE,FALSE},
3225             {"",S_FALSE,FALSE},
3226             {"",S_FALSE,FALSE},
3227             {"index.html",S_OK,FALSE},
3228             {"index.html",S_OK,FALSE},
3229             {"",S_FALSE,FALSE},
3230             {"file:index.html",S_OK,FALSE},
3231             {"file",S_OK,FALSE},
3232             {"",S_FALSE,FALSE},
3233             {"",S_FALSE,FALSE}
3234         },
3235         {
3236             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3237             {0,S_FALSE,FALSE},
3238             {URL_SCHEME_FILE,S_OK,FALSE},
3239             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3240         }
3241     },
3242     /* Doesn't have an absolute since it's opaque, but gets it port set. */
3243     {   "http:test.com/index.html", 0, S_OK, FALSE,
3244         {
3245             {"",S_FALSE,FALSE},
3246             {"",S_FALSE,FALSE},
3247             {"http:test.com/index.html",S_OK,FALSE},
3248             {"",S_FALSE,FALSE},
3249             {".html",S_OK,FALSE},
3250             {"",S_FALSE,FALSE},
3251             {"",S_FALSE,FALSE},
3252             {"",S_FALSE,FALSE},
3253             {"test.com/index.html",S_OK,FALSE},
3254             {"test.com/index.html",S_OK,FALSE},
3255             {"",S_FALSE,FALSE},
3256             {"http:test.com/index.html",S_OK,FALSE},
3257             {"http",S_OK,FALSE},
3258             {"",S_FALSE,FALSE},
3259             {"",S_FALSE,FALSE}
3260         },
3261         {
3262             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3263             {80,S_OK,FALSE},
3264             {URL_SCHEME_HTTP,S_OK,FALSE},
3265             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3266         }
3267     },
3268     {   "ftp:test.com/index.html", 0, S_OK, FALSE,
3269         {
3270             {"",S_FALSE,FALSE},
3271             {"",S_FALSE,FALSE},
3272             {"ftp:test.com/index.html",S_OK,FALSE},
3273             {"",S_FALSE,FALSE},
3274             {".html",S_OK,FALSE},
3275             {"",S_FALSE,FALSE},
3276             {"",S_FALSE,FALSE},
3277             {"",S_FALSE,FALSE},
3278             {"test.com/index.html",S_OK,FALSE},
3279             {"test.com/index.html",S_OK,FALSE},
3280             {"",S_FALSE,FALSE},
3281             {"ftp:test.com/index.html",S_OK,FALSE},
3282             {"ftp",S_OK,FALSE},
3283             {"",S_FALSE,FALSE},
3284             {"",S_FALSE,FALSE}
3285         },
3286         {
3287             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3288             {21,S_OK,FALSE},
3289             {URL_SCHEME_FTP,S_OK,FALSE},
3290             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3291         }
3292     },
3293     {   "file://C|/test.mp3", 0, S_OK, FALSE,
3294         {
3295             {"file:///C:/test.mp3",S_OK,FALSE},
3296             {"",S_FALSE,FALSE},
3297             {"file:///C:/test.mp3",S_OK,FALSE},
3298             {"",S_FALSE,FALSE},
3299             {".mp3",S_OK,FALSE},
3300             {"",S_FALSE,FALSE},
3301             {"",S_FALSE,FALSE},
3302             {"",S_FALSE,FALSE},
3303             {"/C:/test.mp3",S_OK,FALSE},
3304             {"/C:/test.mp3",S_OK,FALSE},
3305             {"",S_FALSE,FALSE},
3306             {"file://C|/test.mp3",S_OK,FALSE},
3307             {"file",S_OK,FALSE},
3308             {"",S_FALSE,FALSE},
3309             {"",S_FALSE,FALSE}
3310         },
3311         {
3312             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3313             {0,S_FALSE,FALSE},
3314             {URL_SCHEME_FILE,S_OK,FALSE},
3315             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3316         }
3317     },
3318     {   "file:///C|/test.mp3", 0, S_OK, FALSE,
3319         {
3320             {"file:///C:/test.mp3",S_OK,FALSE},
3321             {"",S_FALSE,FALSE},
3322             {"file:///C:/test.mp3",S_OK,FALSE},
3323             {"",S_FALSE,FALSE},
3324             {".mp3",S_OK,FALSE},
3325             {"",S_FALSE,FALSE},
3326             {"",S_FALSE,FALSE},
3327             {"",S_FALSE,FALSE},
3328             {"/C:/test.mp3",S_OK,FALSE},
3329             {"/C:/test.mp3",S_OK,FALSE},
3330             {"",S_FALSE,FALSE},
3331             {"file:///C|/test.mp3",S_OK,FALSE},
3332             {"file",S_OK,FALSE},
3333             {"",S_FALSE,FALSE},
3334             {"",S_FALSE,FALSE}
3335         },
3336         {
3337             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3338             {0,S_FALSE,FALSE},
3339             {URL_SCHEME_FILE,S_OK,FALSE},
3340             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3341         }
3342     },
3343     /* Extra '/' isn't added before "c:" since USE_DOS_PATH is set and '/' are converted
3344      * to '\\'.
3345      */
3346     {   "file://c:/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3347         {
3348             {"file://c:\\dir\\index.html",S_OK,FALSE},
3349             {"",S_FALSE,FALSE},
3350             {"file://c:\\dir\\index.html",S_OK,FALSE},
3351             {"",S_FALSE,FALSE},
3352             {".html",S_OK,FALSE},
3353             {"",S_FALSE,FALSE},
3354             {"",S_FALSE,FALSE},
3355             {"",S_FALSE,FALSE},
3356             {"c:\\dir\\index.html",S_OK,FALSE},
3357             {"c:\\dir\\index.html",S_OK,FALSE},
3358             {"",S_FALSE,FALSE},
3359             {"file://c:/dir/index.html",S_OK,FALSE},
3360             {"file",S_OK,FALSE},
3361             {"",S_FALSE,FALSE},
3362             {"",S_FALSE,FALSE}
3363         },
3364         {
3365             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3366             {0,S_FALSE,FALSE},
3367             {URL_SCHEME_FILE,S_OK,FALSE},
3368             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3369         }
3370     },
3371     /* Extra '/' after "file://" is removed. */
3372     {   "file:///c:/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3373         {
3374             {"file://c:\\dir\\index.html",S_OK,FALSE},
3375             {"",S_FALSE,FALSE},
3376             {"file://c:\\dir\\index.html",S_OK,FALSE},
3377             {"",S_FALSE,FALSE},
3378             {".html",S_OK,FALSE},
3379             {"",S_FALSE,FALSE},
3380             {"",S_FALSE,FALSE},
3381             {"",S_FALSE,FALSE},
3382             {"c:\\dir\\index.html",S_OK,FALSE},
3383             {"c:\\dir\\index.html",S_OK,FALSE},
3384             {"",S_FALSE,FALSE},
3385             {"file:///c:/dir/index.html",S_OK,FALSE},
3386             {"file",S_OK,FALSE},
3387             {"",S_FALSE,FALSE},
3388             {"",S_FALSE,FALSE}
3389         },
3390         {
3391             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3392             {0,S_FALSE,FALSE},
3393             {URL_SCHEME_FILE,S_OK,FALSE},
3394             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3395         }
3396     },
3397     /* Allow more characters when Uri_CREATE_FILE_USE_DOS_PATH is specified */
3398     {   "file:///c:/dir\\%%61%20%5Fname/file%2A.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3399         {
3400             {"file://c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3401             {"",S_FALSE,FALSE},
3402             {"file://c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3403             {"",S_FALSE,FALSE},
3404             {".html",S_OK,FALSE},
3405             {"",S_FALSE,FALSE},
3406             {"",S_FALSE,FALSE},
3407             {"",S_FALSE,FALSE},
3408             {"c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3409             {"c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3410             {"",S_FALSE,FALSE},
3411             {"file:///c:/dir\\%%61%20%5Fname/file%2A.html",S_OK,FALSE},
3412             {"file",S_OK,FALSE},
3413             {"",S_FALSE,FALSE},
3414             {"",S_FALSE,FALSE}
3415         },
3416         {
3417             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3418             {0,S_FALSE,FALSE},
3419             {URL_SCHEME_FILE,S_OK,FALSE},
3420             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3421         }
3422     },
3423     {   "file://c|/dir\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3424         {
3425             {"file://c:\\dir\\index.html",S_OK,FALSE},
3426             {"",S_FALSE,FALSE},
3427             {"file://c:\\dir\\index.html",S_OK,FALSE},
3428             {"",S_FALSE,FALSE},
3429             {".html",S_OK,FALSE},
3430             {"",S_FALSE,FALSE},
3431             {"",S_FALSE,FALSE},
3432             {"",S_FALSE,FALSE},
3433             {"c:\\dir\\index.html",S_OK,FALSE},
3434             {"c:\\dir\\index.html",S_OK,FALSE},
3435             {"",S_FALSE,FALSE},
3436             {"file://c|/dir\\index.html",S_OK,FALSE},
3437             {"file",S_OK,FALSE},
3438             {"",S_FALSE,FALSE},
3439             {"",S_FALSE,FALSE}
3440         },
3441         {
3442             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3443             {0,S_FALSE,FALSE},
3444             {URL_SCHEME_FILE,S_OK,FALSE},
3445             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3446         }
3447     },
3448     /* The backslashes after the scheme name are converted to forward slashes. */
3449     {   "file:\\\\c:\\dir\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3450         {
3451             {"file://c:\\dir\\index.html",S_OK,FALSE},
3452             {"",S_FALSE,FALSE},
3453             {"file://c:\\dir\\index.html",S_OK,FALSE},
3454             {"",S_FALSE,FALSE},
3455             {".html",S_OK,FALSE},
3456             {"",S_FALSE,FALSE},
3457             {"",S_FALSE,FALSE},
3458             {"",S_FALSE,FALSE},
3459             {"c:\\dir\\index.html",S_OK,FALSE},
3460             {"c:\\dir\\index.html",S_OK,FALSE},
3461             {"",S_FALSE,FALSE},
3462             {"file:\\\\c:\\dir\\index.html",S_OK,FALSE},
3463             {"file",S_OK,FALSE},
3464             {"",S_FALSE,FALSE},
3465             {"",S_FALSE,FALSE}
3466         },
3467         {
3468             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3469             {0,S_FALSE,FALSE},
3470             {URL_SCHEME_FILE,S_OK,FALSE},
3471             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3472         }
3473     },
3474     {   "file:\\\\c:/dir/index.html", 0, S_OK, FALSE,
3475         {
3476             {"file:///c:/dir/index.html",S_OK,FALSE},
3477             {"",S_FALSE,FALSE},
3478             {"file:///c:/dir/index.html",S_OK,FALSE},
3479             {"",S_FALSE,FALSE},
3480             {".html",S_OK,FALSE},
3481             {"",S_FALSE,FALSE},
3482             {"",S_FALSE,FALSE},
3483             {"",S_FALSE,FALSE},
3484             {"/c:/dir/index.html",S_OK,FALSE},
3485             {"/c:/dir/index.html",S_OK,FALSE},
3486             {"",S_FALSE,FALSE},
3487             {"file:\\\\c:/dir/index.html",S_OK,FALSE},
3488             {"file",S_OK,FALSE},
3489             {"",S_FALSE,FALSE},
3490             {"",S_FALSE,FALSE}
3491         },
3492         {
3493             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3494             {0,S_FALSE,FALSE},
3495             {URL_SCHEME_FILE,S_OK,FALSE},
3496             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3497         }
3498     },
3499     {   "http:\\\\google.com", 0, S_OK, FALSE,
3500         {
3501             {"http://google.com/",S_OK,FALSE},
3502             {"google.com",S_OK,FALSE},
3503             {"http://google.com/",S_OK,FALSE},
3504             {"google.com",S_OK,FALSE},
3505             {"",S_FALSE,FALSE},
3506             {"",S_FALSE,FALSE},
3507             {"google.com",S_OK,FALSE},
3508             {"",S_FALSE,FALSE},
3509             {"/",S_OK,FALSE},
3510             {"/",S_OK,FALSE},
3511             {"",S_FALSE,FALSE},
3512             {"http:\\\\google.com",S_OK,FALSE},
3513             {"http",S_OK,FALSE},
3514             {"",S_FALSE,FALSE},
3515             {"",S_FALSE,FALSE}
3516         },
3517         {
3518             {Uri_HOST_DNS,S_OK,FALSE},
3519             {80,S_OK,FALSE},
3520             {URL_SCHEME_HTTP,S_OK,FALSE},
3521             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3522         }
3523     },
3524     /* the "\\\\" aren't converted to "//" for unknown scheme types and it's considered opaque. */
3525     {   "zip:\\\\google.com", 0, S_OK, FALSE,
3526         {
3527             {"zip:\\\\google.com",S_OK,FALSE},
3528             {"",S_FALSE,FALSE},
3529             {"zip:\\\\google.com",S_OK,FALSE},
3530             {"",S_FALSE,FALSE},
3531             {".com",S_OK,FALSE},
3532             {"",S_FALSE,FALSE},
3533             {"",S_FALSE,FALSE},
3534             {"",S_FALSE,FALSE},
3535             {"\\\\google.com",S_OK,FALSE},
3536             {"\\\\google.com",S_OK,FALSE},
3537             {"",S_FALSE,FALSE},
3538             {"zip:\\\\google.com",S_OK,FALSE},
3539             {"zip",S_OK,FALSE},
3540             {"",S_FALSE,FALSE},
3541             {"",S_FALSE,FALSE}
3542         },
3543         {
3544             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3545             {0,S_FALSE,FALSE},
3546             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3547             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3548         }
3549     },
3550     /* Dot segments aren't removed. */
3551     {   "file://c:\\dir\\../..\\./index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3552         {
3553             {"file://c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3554             {"",S_FALSE,FALSE},
3555             {"file://c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3556             {"",S_FALSE,FALSE},
3557             {".html",S_OK,FALSE},
3558             {"",S_FALSE,FALSE},
3559             {"",S_FALSE,FALSE},
3560             {"",S_FALSE,FALSE},
3561             {"c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3562             {"c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3563             {"",S_FALSE,FALSE},
3564             {"file://c:\\dir\\../..\\./index.html",S_OK,FALSE},
3565             {"file",S_OK,FALSE},
3566             {"",S_FALSE,FALSE},
3567             {"",S_FALSE,FALSE}
3568         },
3569         {
3570             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3571             {0,S_FALSE,FALSE},
3572             {URL_SCHEME_FILE,S_OK,FALSE},
3573             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3574         }
3575     },
3576     /* Forbidden characters aren't percent encoded. */
3577     {   "file://c:\\dir\\i^|ndex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3578         {
3579             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3580             {"",S_FALSE,FALSE},
3581             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3582             {"",S_FALSE,FALSE},
3583             {".html",S_OK,FALSE},
3584             {"",S_FALSE,FALSE},
3585             {"",S_FALSE,FALSE},
3586             {"",S_FALSE,FALSE},
3587             {"c:\\dir\\i^|ndex.html",S_OK,FALSE},
3588             {"c:\\dir\\i^|ndex.html",S_OK,FALSE},
3589             {"",S_FALSE,FALSE},
3590             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3591             {"file",S_OK,FALSE},
3592             {"",S_FALSE,FALSE},
3593             {"",S_FALSE,FALSE}
3594         },
3595         {
3596             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3597             {0,S_FALSE,FALSE},
3598             {URL_SCHEME_FILE,S_OK,FALSE},
3599             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3600         }
3601     },
3602     /* The '\' are still converted to '/' even though it's an opaque file URI. */
3603     {   "file:c:\\dir\\../..\\index.html", 0, S_OK, FALSE,
3604         {
3605             {"",S_FALSE,FALSE},
3606             {"",S_FALSE,FALSE},
3607             {"file:c:/dir/../../index.html",S_OK,FALSE},
3608             {"",S_FALSE,FALSE},
3609             {".html",S_OK,FALSE},
3610             {"",S_FALSE,FALSE},
3611             {"",S_FALSE,FALSE},
3612             {"",S_FALSE,FALSE},
3613             {"c:/dir/../../index.html",S_OK,FALSE},
3614             {"c:/dir/../../index.html",S_OK,FALSE},
3615             {"",S_FALSE,FALSE},
3616             {"file:c:\\dir\\../..\\index.html",S_OK,FALSE},
3617             {"file",S_OK,FALSE},
3618             {"",S_FALSE,FALSE},
3619             {"",S_FALSE,FALSE}
3620         },
3621         {
3622             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3623             {0,S_FALSE,FALSE},
3624             {URL_SCHEME_FILE,S_OK,FALSE},
3625             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3626         }
3627     },
3628     /* '/' are still converted to '\' even though it's an opaque URI. */
3629     {   "file:c:/dir\\../..\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3630         {
3631             {"",S_FALSE,FALSE},
3632             {"",S_FALSE,FALSE},
3633             {"file:c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3634             {"",S_FALSE,FALSE},
3635             {".html",S_OK,FALSE},
3636             {"",S_FALSE,FALSE},
3637             {"",S_FALSE,FALSE},
3638             {"",S_FALSE,FALSE},
3639             {"c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3640             {"c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3641             {"",S_FALSE,FALSE},
3642             {"file:c:/dir\\../..\\index.html",S_OK,FALSE},
3643             {"file",S_OK,FALSE},
3644             {"",S_FALSE,FALSE},
3645             {"",S_FALSE,FALSE}
3646         },
3647         {
3648             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3649             {0,S_FALSE,FALSE},
3650             {URL_SCHEME_FILE,S_OK,FALSE},
3651             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3652         }
3653     },
3654     /* Forbidden characters aren't percent encoded. */
3655     {   "file:c:\\in^|dex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3656         {
3657             {"",S_FALSE,FALSE},
3658             {"",S_FALSE,FALSE},
3659             {"file:c:\\in^|dex.html",S_OK,FALSE},
3660             {"",S_FALSE,FALSE},
3661             {".html",S_OK,FALSE},
3662             {"",S_FALSE,FALSE},
3663             {"",S_FALSE,FALSE},
3664             {"",S_FALSE,FALSE},
3665             {"c:\\in^|dex.html",S_OK,FALSE},
3666             {"c:\\in^|dex.html",S_OK,FALSE},
3667             {"",S_FALSE,FALSE},
3668             {"file:c:\\in^|dex.html",S_OK,FALSE},
3669             {"file",S_OK,FALSE},
3670             {"",S_FALSE,FALSE},
3671             {"",S_FALSE,FALSE}
3672         },
3673         {
3674             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3675             {0,S_FALSE,FALSE},
3676             {URL_SCHEME_FILE,S_OK,FALSE},
3677             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3678         }
3679     },
3680     /* Doesn't have a UserName since the ':' appears at the beginning of the
3681      * userinfo section.
3682      */
3683     {   "http://:password@gov.uk", 0, S_OK, FALSE,
3684         {
3685             {"http://:password@gov.uk/",S_OK,FALSE},
3686             {":password@gov.uk",S_OK,FALSE},
3687             {"http://gov.uk/",S_OK,FALSE},
3688             {"",S_FALSE,FALSE},
3689             {"",S_FALSE,FALSE},
3690             {"",S_FALSE,FALSE},
3691             {"gov.uk",S_OK,FALSE},
3692             {"password",S_OK,FALSE},
3693             {"/",S_OK,FALSE},
3694             {"/",S_OK,FALSE},
3695             {"",S_FALSE,FALSE},
3696             {"http://:password@gov.uk",S_OK,FALSE},
3697             {"http",S_OK,FALSE},
3698             {":password",S_OK,FALSE},
3699             {"",S_FALSE,FALSE}
3700         },
3701         {
3702             {Uri_HOST_DNS,S_OK,FALSE},
3703             {80,S_OK,FALSE},
3704             {URL_SCHEME_HTTP,S_OK,FALSE},
3705             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3706         }
3707     },
3708     /* Has a UserName since the userinfo section doesn't contain a password. */
3709     {   "http://@gov.uk", 0, S_OK, FALSE,
3710         {
3711             {"http://gov.uk/",S_OK,FALSE,"http://@gov.uk/"},
3712             {"@gov.uk",S_OK,FALSE},
3713             {"http://gov.uk/",S_OK,FALSE},
3714             {"",S_FALSE,FALSE},
3715             {"",S_FALSE,FALSE},
3716             {"",S_FALSE,FALSE},
3717             {"gov.uk",S_OK,FALSE},
3718             {"",S_FALSE,FALSE},
3719             {"/",S_OK,FALSE},
3720             {"/",S_OK,FALSE},
3721             {"",S_FALSE,FALSE},
3722             {"http://@gov.uk",S_OK,FALSE},
3723             {"http",S_OK,FALSE},
3724             {"",S_OK,FALSE},
3725             {"",S_OK,FALSE}
3726         },
3727         {
3728             {Uri_HOST_DNS,S_OK,FALSE},
3729             {80,S_OK,FALSE},
3730             {URL_SCHEME_HTTP,S_OK,FALSE},
3731             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3732         }
3733     },
3734     /* ":@" not included in the absolute URI. */
3735     {   "http://:@gov.uk", 0, S_OK, FALSE,
3736         {
3737             {"http://gov.uk/",S_OK,FALSE,"http://:@gov.uk/"},
3738             {":@gov.uk",S_OK,FALSE},
3739             {"http://gov.uk/",S_OK,FALSE},
3740             {"",S_FALSE,FALSE},
3741             {"",S_FALSE,FALSE},
3742             {"",S_FALSE,FALSE},
3743             {"gov.uk",S_OK,FALSE},
3744             {"",S_OK,FALSE},
3745             {"/",S_OK,FALSE},
3746             {"/",S_OK,FALSE},
3747             {"",S_FALSE,FALSE},
3748             {"http://:@gov.uk",S_OK,FALSE},
3749             {"http",S_OK,FALSE},
3750             {":",S_OK,FALSE},
3751             {"",S_FALSE,FALSE}
3752         },
3753         {
3754             {Uri_HOST_DNS,S_OK,FALSE},
3755             {80,S_OK,FALSE},
3756             {URL_SCHEME_HTTP,S_OK,FALSE},
3757             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3758         }
3759     },
3760     /* '@' is included because it's an unknown scheme type. */
3761     {   "zip://@gov.uk", 0, S_OK, FALSE,
3762         {
3763             {"zip://@gov.uk/",S_OK,FALSE},
3764             {"@gov.uk",S_OK,FALSE},
3765             {"zip://@gov.uk/",S_OK,FALSE},
3766             {"",S_FALSE,FALSE},
3767             {"",S_FALSE,FALSE},
3768             {"",S_FALSE,FALSE},
3769             {"gov.uk",S_OK,FALSE},
3770             {"",S_FALSE,FALSE},
3771             {"/",S_OK,FALSE},
3772             {"/",S_OK,FALSE},
3773             {"",S_FALSE,FALSE},
3774             {"zip://@gov.uk",S_OK,FALSE},
3775             {"zip",S_OK,FALSE},
3776             {"",S_OK,FALSE},
3777             {"",S_OK,FALSE}
3778         },
3779         {
3780             {Uri_HOST_DNS,S_OK,FALSE},
3781             {0,S_FALSE,FALSE},
3782             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3783             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3784         }
3785     },
3786     /* ":@" are included because it's an unknown scheme type. */
3787     {   "zip://:@gov.uk", 0, S_OK, FALSE,
3788         {
3789             {"zip://:@gov.uk/",S_OK,FALSE},
3790             {":@gov.uk",S_OK,FALSE},
3791             {"zip://:@gov.uk/",S_OK,FALSE},
3792             {"",S_FALSE,FALSE},
3793             {"",S_FALSE,FALSE},
3794             {"",S_FALSE,FALSE},
3795             {"gov.uk",S_OK,FALSE},
3796             {"",S_OK,FALSE},
3797             {"/",S_OK,FALSE},
3798             {"/",S_OK,FALSE},
3799             {"",S_FALSE,FALSE},
3800             {"zip://:@gov.uk",S_OK,FALSE},
3801             {"zip",S_OK,FALSE},
3802             {":",S_OK,FALSE},
3803             {"",S_FALSE,FALSE}
3804         },
3805         {
3806             {Uri_HOST_DNS,S_OK,FALSE},
3807             {0,S_FALSE,FALSE},
3808             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3809             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3810         }
3811     },
3812     {   "about:blank", 0, S_OK, FALSE,
3813         {
3814             {"about:blank",S_OK,FALSE},
3815             {"",S_FALSE,FALSE},
3816             {"about:blank",S_OK,FALSE},
3817             {"",S_FALSE,FALSE},
3818             {"",S_FALSE,FALSE},
3819             {"",S_FALSE,FALSE},
3820             {"",S_FALSE,FALSE},
3821             {"",S_FALSE,FALSE},
3822             {"blank",S_OK,FALSE},
3823             {"blank",S_OK,FALSE},
3824             {"",S_FALSE,FALSE},
3825             {"about:blank",S_OK,FALSE},
3826             {"about",S_OK,FALSE},
3827             {"",S_FALSE,FALSE},
3828             {"",S_FALSE,FALSE}
3829         },
3830         {
3831             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3832             {0,S_FALSE,FALSE},
3833             {URL_SCHEME_ABOUT,S_OK,FALSE},
3834             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3835         }
3836     },
3837     {   "mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",0,S_OK,FALSE,
3838         {
3839             {"mk:@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3840             {"",S_FALSE,FALSE},
3841             {"mk:@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3842             {"",S_FALSE,FALSE},
3843             {".htm",S_OK,FALSE},
3844             {"",S_FALSE,FALSE},
3845             {"",S_FALSE,FALSE},
3846             {"",S_FALSE,FALSE},
3847             {"@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3848             {"@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3849             {"",S_FALSE,FALSE},
3850             {"mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3851             {"mk",S_OK,FALSE},
3852             {"",S_FALSE,FALSE},
3853             {"",S_FALSE,FALSE}
3854         },
3855         {
3856             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3857             {0,S_FALSE,FALSE},
3858             {URL_SCHEME_MK,S_OK,FALSE},
3859             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3860         }
3861     },
3862     {   "mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",0,S_OK,FALSE,
3863         {
3864             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3865             {"",S_FALSE,FALSE},
3866             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3867             {"",S_FALSE,FALSE},
3868             {".htm",S_OK,FALSE},
3869             {"",S_FALSE,FALSE},
3870             {"",S_FALSE,FALSE},
3871             {"",S_FALSE,FALSE},
3872             {"@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3873             {"@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3874             {"",S_FALSE,FALSE},
3875             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3876             {"mk",S_OK,FALSE},
3877             {"",S_FALSE,FALSE},
3878             {"",S_FALSE,FALSE}
3879         },
3880         {
3881             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3882             {0,S_FALSE,FALSE},
3883             {URL_SCHEME_MK,S_OK,FALSE},
3884             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3885         }
3886     },
3887     /* Two '\' are added to the URI when USE_DOS_PATH is set, and it's a UNC path. */
3888     {   "file://server/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3889         {
3890             {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
3891             {"server",S_OK,FALSE},
3892             {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
3893             {"",S_FALSE,FALSE},
3894             {".html",S_OK,FALSE},
3895             {"",S_FALSE,FALSE},
3896             {"server",S_OK,FALSE},
3897             {"",S_FALSE,FALSE},
3898             {"\\dir\\index.html",S_OK,FALSE},
3899             {"\\dir\\index.html",S_OK,FALSE},
3900             {"",S_FALSE,FALSE},
3901             {"file://server/dir/index.html",S_OK,FALSE},
3902             {"file",S_OK,FALSE},
3903             {"",S_FALSE,FALSE},
3904             {"",S_FALSE,FALSE}
3905         },
3906         {
3907             {Uri_HOST_DNS,S_OK,FALSE},
3908             {0,S_FALSE,FALSE},
3909             {URL_SCHEME_FILE,S_OK,FALSE},
3910             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3911         }
3912     },
3913     /* When CreateUri generates an IUri, it still displays the default port in the
3914      * authority.
3915      */
3916     {   "http://google.com:80/", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
3917         {
3918             {"http://google.com:80/",S_OK,FALSE},
3919             {"google.com:80",S_OK,FALSE},
3920             {"http://google.com:80/",S_OK,FALSE},
3921             {"google.com",S_OK,FALSE},
3922             {"",S_FALSE,FALSE},
3923             {"",S_FALSE,FALSE},
3924             {"google.com",S_OK,FALSE},
3925             {"",S_FALSE,FALSE},
3926             {"/",S_OK,FALSE},
3927             {"/",S_OK,FALSE},
3928             {"",S_FALSE,FALSE},
3929             {"http://google.com:80/",S_OK,FALSE},
3930             {"http",S_OK,FALSE},
3931             {"",S_FALSE,FALSE},
3932             {"",S_FALSE,FALSE}
3933         },
3934         {
3935             {Uri_HOST_DNS,S_OK,FALSE},
3936             {80,S_OK,FALSE},
3937             {URL_SCHEME_HTTP,S_OK,FALSE},
3938             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3939         }
3940     },
3941     /* For res URIs the host is everything up until the first '/'. */
3942     {   "res://C:\\dir\\file.exe/DATA/test.html", 0, S_OK, FALSE,
3943         {
3944             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3945             {"C:\\dir\\file.exe",S_OK,FALSE},
3946             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3947             {"",S_FALSE,FALSE},
3948             {".html",S_OK,FALSE},
3949             {"",S_FALSE,FALSE},
3950             {"C:\\dir\\file.exe",S_OK,FALSE},
3951             {"",S_FALSE,FALSE},
3952             {"/DATA/test.html",S_OK,FALSE},
3953             {"/DATA/test.html",S_OK,FALSE},
3954             {"",S_FALSE,FALSE},
3955             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3956             {"res",S_OK,FALSE},
3957             {"",S_FALSE,FALSE},
3958             {"",S_FALSE,FALSE}
3959         },
3960         {
3961             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3962             {0,S_FALSE,FALSE},
3963             {URL_SCHEME_RES,S_OK,FALSE},
3964             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3965         }
3966     },
3967     /* Res URI can contain a '|' in the host name. */
3968     {   "res://c:\\di|r\\file.exe/test", 0, S_OK, FALSE,
3969         {
3970             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3971             {"c:\\di|r\\file.exe",S_OK,FALSE},
3972             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3973             {"",S_FALSE,FALSE},
3974             {"",S_FALSE,FALSE},
3975             {"",S_FALSE,FALSE},
3976             {"c:\\di|r\\file.exe",S_OK,FALSE},
3977             {"",S_FALSE,FALSE},
3978             {"/test",S_OK,FALSE},
3979             {"/test",S_OK,FALSE},
3980             {"",S_FALSE,FALSE},
3981             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3982             {"res",S_OK,FALSE},
3983             {"",S_FALSE,FALSE},
3984             {"",S_FALSE,FALSE}
3985         },
3986         {
3987             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3988             {0,S_FALSE,FALSE},
3989             {URL_SCHEME_RES,S_OK,FALSE},
3990             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3991         }
3992     },
3993     /* Res URIs can have invalid percent encoded values. */
3994     {   "res://c:\\dir%xx\\file.exe/test", 0, S_OK, FALSE,
3995         {
3996             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3997             {"c:\\dir%xx\\file.exe",S_OK,FALSE},
3998             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3999             {"",S_FALSE,FALSE},
4000             {"",S_FALSE,FALSE},
4001             {"",S_FALSE,FALSE},
4002             {"c:\\dir%xx\\file.exe",S_OK,FALSE},
4003             {"",S_FALSE,FALSE},
4004             {"/test",S_OK,FALSE},
4005             {"/test",S_OK,FALSE},
4006             {"",S_FALSE,FALSE},
4007             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
4008             {"res",S_OK,FALSE},
4009             {"",S_FALSE,FALSE},
4010             {"",S_FALSE,FALSE}
4011         },
4012         {
4013             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4014             {0,S_FALSE,FALSE},
4015             {URL_SCHEME_RES,S_OK,FALSE},
4016             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4017         }
4018     },
4019     /* Res doesn't get forbidden characters percent encoded in it's path. */
4020     {   "res://c:\\test/tes<|>t", 0, S_OK, FALSE,
4021         {
4022             {"res://c:\\test/tes<|>t",S_OK,FALSE},
4023             {"c:\\test",S_OK,FALSE},
4024             {"res://c:\\test/tes<|>t",S_OK,FALSE},
4025             {"",S_FALSE,FALSE},
4026             {"",S_FALSE,FALSE},
4027             {"",S_FALSE,FALSE},
4028             {"c:\\test",S_OK,FALSE},
4029             {"",S_FALSE,FALSE},
4030             {"/tes<|>t",S_OK,FALSE},
4031             {"/tes<|>t",S_OK,FALSE},
4032             {"",S_FALSE,FALSE},
4033             {"res://c:\\test/tes<|>t",S_OK,FALSE},
4034             {"res",S_OK,FALSE},
4035             {"",S_FALSE,FALSE},
4036             {"",S_FALSE,FALSE}
4037         },
4038         {
4039             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4040             {0,S_FALSE,FALSE},
4041             {URL_SCHEME_RES,S_OK,FALSE},
4042             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4043         }
4044     },
4045     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg", 0, S_OK, FALSE,
4046         {
4047             {"mk:@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4048             {"",S_FALSE,FALSE},
4049             {"mk:@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4050             {"",S_FALSE,FALSE},
4051             {".jpg",S_OK,FALSE},
4052             {"",S_FALSE,FALSE},
4053             {"",S_FALSE,FALSE},
4054             {"",S_FALSE,FALSE},
4055             {"@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4056             {"@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4057             {"",S_FALSE,FALSE},
4058             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4059             {"mk",S_OK,FALSE},
4060             {"",S_FALSE,FALSE},
4061             {"",S_FALSE,FALSE}
4062         },
4063         {
4064             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4065             {0,S_FALSE,FALSE},
4066             {URL_SCHEME_MK,S_OK,FALSE},
4067             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4068         }
4069     },
4070     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
4071         {
4072             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4073             {"",S_FALSE,FALSE},
4074             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4075             {"",S_FALSE,FALSE},
4076             {".jpg",S_OK,FALSE},
4077             {"",S_FALSE,FALSE},
4078             {"",S_FALSE,FALSE},
4079             {"",S_FALSE,FALSE},
4080             {"@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4081             {"@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4082             {"",S_FALSE,FALSE},
4083             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4084             {"mk",S_OK,FALSE},
4085             {"",S_FALSE,FALSE},
4086             {"",S_FALSE,FALSE}
4087         },
4088         {
4089             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4090             {0,S_FALSE,FALSE},
4091             {URL_SCHEME_MK,S_OK,FALSE},
4092             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4093         }
4094     },
4095     {   "xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg", 0, S_OK, FALSE,
4096         {
4097             {"xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4098             {"",S_FALSE,FALSE},
4099             {"xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4100             {"",S_FALSE,FALSE},
4101             {".jpg",S_OK,FALSE},
4102             {"",S_FALSE,FALSE},
4103             {"",S_FALSE,FALSE},
4104             {"",S_FALSE,FALSE},
4105             {"@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4106             {"@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4107             {"",S_FALSE,FALSE},
4108             {"xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4109             {"xx",S_OK,FALSE},
4110             {"",S_FALSE,FALSE},
4111             {"",S_FALSE,FALSE}
4112         },
4113         {
4114             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4115             {0,S_FALSE,FALSE},
4116             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
4117             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4118         }
4119     },
4120     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../../images/xxx.jpg", 0, S_OK, FALSE,
4121         {
4122             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4123             {"",S_FALSE,FALSE},
4124             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4125             {"",S_FALSE,FALSE},
4126             {".jpg",S_OK,FALSE},
4127             {"",S_FALSE,FALSE},
4128             {"",S_FALSE,FALSE},
4129             {"",S_FALSE,FALSE},
4130             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4131             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4132             {"",S_FALSE,FALSE},
4133             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../../images/xxx.jpg",S_OK,FALSE},
4134             {"mk",S_OK,FALSE},
4135             {"",S_FALSE,FALSE},
4136             {"",S_FALSE,FALSE}
4137         },
4138         {
4139             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4140             {0,S_FALSE,FALSE},
4141             {URL_SCHEME_MK,S_OK,FALSE},
4142             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4143         }
4144     },
4145     {   "mk:@MSITStore:Z:\\dir\\dir2\\..\\test.chm::/html/../../images/xxx.jpg", 0, S_OK, FALSE,
4146         {
4147             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4148             {"",S_FALSE,FALSE},
4149             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4150             {"",S_FALSE,FALSE},
4151             {".jpg",S_OK,FALSE},
4152             {"",S_FALSE,FALSE},
4153             {"",S_FALSE,FALSE},
4154             {"",S_FALSE,FALSE},
4155             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4156             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4157             {"",S_FALSE,FALSE},
4158             {"mk:@MSITStore:Z:\\dir\\dir2\\..\\test.chm::/html/../../images/xxx.jpg",S_OK,FALSE},
4159             {"mk",S_OK,FALSE},
4160             {"",S_FALSE,FALSE},
4161             {"",S_FALSE,FALSE}
4162         },
4163         {
4164             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4165             {0,S_FALSE,FALSE},
4166             {URL_SCHEME_MK,S_OK,FALSE},
4167             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4168         }
4169     },
4170     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../../../../images/xxx.jpg", 0, S_OK, FALSE,
4171         {
4172             {"mk:images/xxx.jpg",S_OK,FALSE},
4173             {"",S_FALSE,FALSE},
4174             {"mk:images/xxx.jpg",S_OK,FALSE},
4175             {"",S_FALSE,FALSE},
4176             {".jpg",S_OK,FALSE},
4177             {"",S_FALSE,FALSE},
4178             {"",S_FALSE,FALSE},
4179             {"",S_FALSE,FALSE},
4180             {"images/xxx.jpg",S_OK,FALSE},
4181             {"images/xxx.jpg",S_OK,FALSE},
4182             {"",S_FALSE,FALSE},
4183             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../../../../images/xxx.jpg",S_OK,FALSE},
4184             {"mk",S_OK,FALSE},
4185             {"",S_FALSE,FALSE},
4186             {"",S_FALSE,FALSE}
4187         },
4188         {
4189             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4190             {0,S_FALSE,FALSE},
4191             {URL_SCHEME_MK,S_OK,FALSE},
4192             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4193         }
4194     },
4195     {   "", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
4196         {
4197             {"",S_OK,FALSE},
4198             {"",S_FALSE,FALSE},
4199             {"",S_OK,FALSE},
4200             {"",S_FALSE,FALSE},
4201             {"",S_FALSE,FALSE},
4202             {"",S_FALSE,FALSE},
4203             {"",S_FALSE,FALSE},
4204             {"",S_FALSE,FALSE},
4205             {"",S_OK,FALSE},
4206             {"",S_OK,FALSE},
4207             {"",S_FALSE,FALSE},
4208             {"",S_OK,FALSE},
4209             {"",S_FALSE,FALSE},
4210             {"",S_FALSE,FALSE},
4211             {"",S_FALSE,FALSE}
4212         },
4213         {
4214             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4215             {0,S_FALSE,FALSE},
4216             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
4217             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4218         }
4219     },
4220     {   " \t ", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
4221         {
4222             {"",S_OK,FALSE},
4223             {"",S_FALSE,FALSE},
4224             {"",S_OK,FALSE},
4225             {"",S_FALSE,FALSE},
4226             {"",S_FALSE,FALSE},
4227             {"",S_FALSE,FALSE},
4228             {"",S_FALSE,FALSE},
4229             {"",S_FALSE,FALSE},
4230             {"",S_OK,FALSE},
4231             {"",S_OK,FALSE},
4232             {"",S_FALSE,FALSE},
4233             {"",S_OK,FALSE},
4234             {"",S_FALSE,FALSE},
4235             {"",S_FALSE,FALSE},
4236             {"",S_FALSE,FALSE}
4237         },
4238         {
4239             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4240             {0,S_FALSE,FALSE},
4241             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
4242             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4243         }
4244     },
4245     {   "javascript:void", 0, S_OK, FALSE,
4246         {
4247             {"javascript:void",S_OK},
4248             {"",S_FALSE},
4249             {"javascript:void",S_OK},
4250             {"",S_FALSE},
4251             {"",S_FALSE},
4252             {"",S_FALSE},
4253             {"",S_FALSE},
4254             {"",S_FALSE},
4255             {"void",S_OK},
4256             {"void",S_OK},
4257             {"",S_FALSE},
4258             {"javascript:void",S_OK},
4259             {"javascript",S_OK},
4260             {"",S_FALSE},
4261             {"",S_FALSE}
4262         },
4263         {
4264             {Uri_HOST_UNKNOWN,S_OK},
4265             {0,S_FALSE},
4266             {URL_SCHEME_JAVASCRIPT,S_OK},
4267             {URLZONE_INVALID,E_NOTIMPL}
4268         }
4269     },
4270     {   "javascript://undefined", 0, S_OK, FALSE,
4271         {
4272             {"javascript://undefined",S_OK},
4273             {"",S_FALSE},
4274             {"javascript://undefined",S_OK},
4275             {"",S_FALSE},
4276             {"",S_FALSE},
4277             {"",S_FALSE},
4278             {"",S_FALSE},
4279             {"",S_FALSE},
4280             {"//undefined",S_OK},
4281             {"//undefined",S_OK},
4282             {"",S_FALSE},
4283             {"javascript://undefined",S_OK},
4284             {"javascript",S_OK},
4285             {"",S_FALSE},
4286             {"",S_FALSE}
4287         },
4288         {
4289             {Uri_HOST_UNKNOWN,S_OK},
4290             {0,S_FALSE},
4291             {URL_SCHEME_JAVASCRIPT,S_OK},
4292             {URLZONE_INVALID,E_NOTIMPL}
4293         }
4294     },
4295     {   "JavaSCript:escape('/\\?#?')", 0, S_OK, FALSE,
4296         {
4297             {"javascript:escape('/\\?#?')",S_OK},
4298             {"",S_FALSE},
4299             {"javascript:escape('/\\?#?')",S_OK},
4300             {"",S_FALSE},
4301             {"",S_FALSE},
4302             {"",S_FALSE},
4303             {"",S_FALSE},
4304             {"",S_FALSE},
4305             {"escape('/\\?#?')",S_OK},
4306             {"escape('/\\?#?')",S_OK},
4307             {"",S_FALSE},
4308             {"JavaSCript:escape('/\\?#?')",S_OK},
4309             {"javascript",S_OK},
4310             {"",S_FALSE},
4311             {"",S_FALSE}
4312         },
4313         {
4314             {Uri_HOST_UNKNOWN,S_OK},
4315             {0,S_FALSE},
4316             {URL_SCHEME_JAVASCRIPT,S_OK},
4317             {URLZONE_INVALID,E_NOTIMPL}
4318         }
4319     },
4320     {   "*://google.com", 0, S_OK, FALSE,
4321         {
4322             {"*:google.com/",S_OK,FALSE},
4323             {"google.com",S_OK},
4324             {"*:google.com/",S_OK,FALSE},
4325             {"google.com",S_OK,FALSE},
4326             {"",S_FALSE,FALSE},
4327             {"",S_FALSE,FALSE},
4328             {"google.com",S_OK,FALSE},
4329             {"",S_FALSE,FALSE},
4330             {"/",S_OK,FALSE},
4331             {"/",S_OK,FALSE},
4332             {"",S_FALSE,FALSE},
4333             {"*://google.com",S_OK,FALSE},
4334             {"*",S_OK,FALSE},
4335             {"",S_FALSE,FALSE},
4336             {"",S_FALSE,FALSE}
4337         },
4338         {
4339             {Uri_HOST_DNS,S_OK,FALSE},
4340             {0,S_FALSE,FALSE},
4341             {URL_SCHEME_WILDCARD,S_OK,FALSE},
4342             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4343         }
4344     },
4345     {   "mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",0,S_OK,FALSE,
4346         {
4347             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",S_OK},
4348             {"",S_FALSE},
4349             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",S_OK},
4350             {"",S_FALSE},
4351             {".txt",S_OK},
4352             {"",S_FALSE},
4353             {"",S_FALSE},
4354             {"",S_FALSE},
4355             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",S_OK},
4356             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",S_OK},
4357             {"",S_FALSE},
4358             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",S_OK},
4359             {"mk",S_OK},
4360             {"",S_FALSE},
4361             {"",S_FALSE}
4362         },
4363         {
4364             {Uri_HOST_UNKNOWN,S_OK},
4365             {0,S_FALSE},
4366             {URL_SCHEME_MK,S_OK},
4367             {URLZONE_INVALID,E_NOTIMPL}
4368         }
4369     },
4370 };
4371
4372 typedef struct _invalid_uri {
4373     const char* uri;
4374     DWORD       flags;
4375     BOOL        todo;
4376 } invalid_uri;
4377
4378 static const invalid_uri invalid_uri_tests[] = {
4379     /* Has to have a scheme name. */
4380     {"://www.winehq.org",0,FALSE},
4381     /* Window's doesn't like URI's which are implicitly file paths without the
4382      * ALLOW_IMPLICIT_FILE_SCHEME flag set.
4383      */
4384     {"C:/test/test.mp3",0,FALSE},
4385     {"\\\\Server/test/test.mp3",0,FALSE},
4386     {"C:/test/test.mp3",Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME,FALSE},
4387     {"\\\\Server/test/test.mp3",Uri_CREATE_ALLOW_RELATIVE,FALSE},
4388     /* Invalid schemes. */
4389     {"*abcd://not.valid.com",0,FALSE},
4390     {"*a*b*c*d://not.valid.com",0,FALSE},
4391     /* Not allowed to have invalid % encoded data. */
4392     {"ftp://google.co%XX/",0,FALSE},
4393     /* To many h16 components. */
4394     {"http://[1:2:3:4:5:6:7:8:9]",0,FALSE},
4395     /* Not enough room for IPv4 address. */
4396     {"http://[1:2:3:4:5:6:7:192.0.1.0]",0,FALSE},
4397     /* Not enough h16 components. */
4398     {"http://[1:2:3:4]",0,FALSE},
4399     /* Not enough components including IPv4. */
4400     {"http://[1:192.0.1.0]",0,FALSE},
4401     /* Not allowed to have partial IPv4 in IPv6. */
4402     {"http://[::192.0]",0,FALSE},
4403     /* Can't have elision of 1 h16 at beginning of address. */
4404     {"http://[::2:3:4:5:6:7:8]",0,FALSE},
4405     /* Can't have elision of 1 h16 at end of address. */
4406     {"http://[1:2:3:4:5:6:7::]",0,FALSE},
4407     /* Expects a valid IP Literal. */
4408     {"ftp://[not.valid.uri]/",0,FALSE},
4409     /* Expects valid port for a known scheme type. */
4410     {"ftp://www.winehq.org:123fgh",0,FALSE},
4411     /* Port exceeds USHORT_MAX for known scheme type. */
4412     {"ftp://www.winehq.org:65536",0,FALSE},
4413     /* Invalid port with IPv4 address. */
4414     {"http://www.winehq.org:1abcd",0,FALSE},
4415     /* Invalid port with IPv6 address. */
4416     {"http://[::ffff]:32xy",0,FALSE},
4417     /* Not allowed to have backslashes with NO_CANONICALIZE. */
4418     {"gopher://www.google.com\\test",Uri_CREATE_NO_CANONICALIZE,FALSE},
4419     /* Not allowed to have invalid % encoded data in opaque URI path. */
4420     {"news:test%XX",0,FALSE},
4421     {"mailto:wine@winehq%G8.com",0,FALSE},
4422     /* Known scheme types can't have invalid % encoded data in query string. */
4423     {"http://google.com/?query=te%xx",0,FALSE},
4424     /* Invalid % encoded data in fragment of know scheme type. */
4425     {"ftp://google.com/#Test%xx",0,FALSE},
4426     {"  http://google.com/",Uri_CREATE_NO_PRE_PROCESS_HTML_URI,FALSE},
4427     {"\n\nhttp://google.com/",Uri_CREATE_NO_PRE_PROCESS_HTML_URI,FALSE},
4428     {"file://c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4429     {"file://c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4430     {"file://c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4431     {"file:c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4432     {"file:c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4433     {"file:c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4434     /* res URIs aren't allowed to have forbidden dos path characters in the
4435      * hostname.
4436      */
4437     {"res://c:\\te<st\\test/test",0,FALSE},
4438     {"res://c:\\te>st\\test/test",0,FALSE},
4439     {"res://c:\\te\"st\\test/test",0,FALSE},
4440     {"res://c:\\test/te%xxst",0,FALSE}
4441 };
4442
4443 typedef struct _uri_equality {
4444     const char* a;
4445     DWORD       create_flags_a;
4446     const char* b;
4447     DWORD       create_flags_b;
4448     BOOL        equal;
4449     BOOL        todo;
4450 } uri_equality;
4451
4452 static const uri_equality equality_tests[] = {
4453     {
4454         "HTTP://www.winehq.org/test dir/./",0,
4455         "http://www.winehq.org/test dir/../test dir/",0,
4456         TRUE
4457     },
4458     {
4459         /* http://www.winehq.org/test%20dir */
4460         "http://%77%77%77%2E%77%69%6E%65%68%71%2E%6F%72%67/%74%65%73%74%20%64%69%72",0,
4461         "http://www.winehq.org/test dir",0,
4462         TRUE
4463     },
4464     {
4465         "c:\\test.mp3",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME,
4466         "file:///c:/test.mp3",0,
4467         TRUE
4468     },
4469     {
4470         "ftp://ftp.winehq.org/",0,
4471         "ftp://ftp.winehq.org",0,
4472         TRUE
4473     },
4474     {
4475         "ftp://ftp.winehq.org/test/test2/../../testB/",0,
4476         "ftp://ftp.winehq.org/t%45stB/",0,
4477         FALSE
4478     },
4479     {
4480         "http://google.com/TEST",0,
4481         "http://google.com/test",0,
4482         FALSE
4483     },
4484     {
4485         "http://GOOGLE.com/",0,
4486         "http://google.com/",0,
4487         TRUE
4488     },
4489     /* Performs case insensitive compare of host names (for known scheme types). */
4490     {
4491         "ftp://GOOGLE.com/",Uri_CREATE_NO_CANONICALIZE,
4492         "ftp://google.com/",0,
4493         TRUE
4494     },
4495     {
4496         "zip://GOOGLE.com/",0,
4497         "zip://google.com/",0,
4498         FALSE
4499     },
4500     {
4501         "file:///c:/TEST/TeST/",0,
4502         "file:///c:/test/test/",0,
4503         TRUE
4504     },
4505     {
4506         "file:///server/TEST",0,
4507         "file:///SERVER/TEST",0,
4508         TRUE
4509     },
4510     {
4511         "http://google.com",Uri_CREATE_NO_CANONICALIZE,
4512         "http://google.com/",0,
4513         TRUE
4514     },
4515     {
4516         "ftp://google.com:21/",0,
4517         "ftp://google.com/",0,
4518         TRUE
4519     },
4520     {
4521         "http://google.com:80/",Uri_CREATE_NO_CANONICALIZE,
4522         "http://google.com/",0,
4523         TRUE
4524     },
4525     {
4526         "http://google.com:70/",0,
4527         "http://google.com:71/",0,
4528         FALSE
4529     },
4530     {
4531         "file:///c:/dir/file.txt", 0,
4532         "file:///c:/dir/file.txt", Uri_CREATE_FILE_USE_DOS_PATH,
4533         TRUE
4534     },
4535     {
4536         "file:///c:/dir/file.txt", 0,
4537         "file:///c:\\dir\\file.txt", Uri_CREATE_NO_CANONICALIZE,
4538         TRUE
4539     },
4540     {
4541         "file:///c:/dir/file.txt", 0,
4542         "file:///c:\\dir2\\..\\dir\\file.txt", Uri_CREATE_NO_CANONICALIZE,
4543         TRUE
4544     },
4545     {
4546         "file:///c:\\dir2\\..\\ dir\\file.txt", Uri_CREATE_NO_CANONICALIZE,
4547         "file:///c:/%20dir/file.txt", 0,
4548         TRUE
4549     },
4550     {
4551         "file:///c:/Dir/file.txt", 0,
4552         "file:///C:/dir/file.TXT", Uri_CREATE_FILE_USE_DOS_PATH,
4553         TRUE
4554     },
4555     {
4556         "file:///c:/dir/file.txt", 0,
4557         "file:///c:\\dir\\file.txt", Uri_CREATE_FILE_USE_DOS_PATH,
4558         TRUE
4559     },
4560     {
4561         "file:///c:/dir/file.txt#a", 0,
4562         "file:///c:\\dir\\file.txt#b", Uri_CREATE_FILE_USE_DOS_PATH,
4563         FALSE
4564     }
4565 };
4566
4567 typedef struct _uri_with_fragment {
4568     const char* uri;
4569     const char* fragment;
4570     DWORD       create_flags;
4571     HRESULT     create_expected;
4572     BOOL        create_todo;
4573
4574     const char* expected_uri;
4575     BOOL        expected_todo;
4576 } uri_with_fragment;
4577
4578 static const uri_with_fragment uri_fragment_tests[] = {
4579     {
4580         "http://google.com/","#fragment",0,S_OK,FALSE,
4581         "http://google.com/#fragment",FALSE
4582     },
4583     {
4584         "http://google.com/","fragment",0,S_OK,FALSE,
4585         "http://google.com/#fragment",FALSE
4586     },
4587     {
4588         "zip://test.com/","?test",0,S_OK,FALSE,
4589         "zip://test.com/#?test",FALSE
4590     },
4591     /* The fragment can be empty. */
4592     {
4593         "ftp://ftp.google.com/","",0,S_OK,FALSE,
4594         "ftp://ftp.google.com/#",FALSE
4595     }
4596 };
4597
4598 typedef struct _uri_builder_property {
4599     BOOL            change;
4600     const char      *value;
4601     const char      *expected_value;
4602     Uri_PROPERTY    property;
4603     HRESULT         expected;
4604     BOOL            todo;
4605 } uri_builder_property;
4606
4607 typedef struct _uri_builder_port {
4608     BOOL    change;
4609     BOOL    set;
4610     DWORD   value;
4611     HRESULT expected;
4612     BOOL    todo;
4613 } uri_builder_port;
4614
4615 typedef struct _uri_builder_str_property {
4616     const char* expected;
4617     HRESULT     result;
4618     BOOL        todo;
4619 } uri_builder_str_property;
4620
4621 typedef struct _uri_builder_dword_property {
4622     DWORD   expected;
4623     HRESULT result;
4624     BOOL    todo;
4625 } uri_builder_dword_property;
4626
4627 typedef struct _uri_builder_test {
4628     const char                  *uri;
4629     DWORD                       create_flags;
4630     HRESULT                     create_builder_expected;
4631     BOOL                        create_builder_todo;
4632
4633     uri_builder_property        properties[URI_BUILDER_STR_PROPERTY_COUNT];
4634
4635     uri_builder_port            port_prop;
4636
4637     DWORD                       uri_flags;
4638     HRESULT                     uri_hres;
4639     BOOL                        uri_todo;
4640
4641     DWORD                       uri_simple_encode_flags;
4642     HRESULT                     uri_simple_hres;
4643     BOOL                        uri_simple_todo;
4644
4645     DWORD                       uri_with_flags;
4646     DWORD                       uri_with_builder_flags;
4647     DWORD                       uri_with_encode_flags;
4648     HRESULT                     uri_with_hres;
4649     BOOL                        uri_with_todo;
4650
4651     uri_builder_str_property    expected_str_props[URI_STR_PROPERTY_COUNT];
4652     uri_builder_dword_property  expected_dword_props[URI_DWORD_PROPERTY_COUNT];
4653 } uri_builder_test;
4654
4655 static const uri_builder_test uri_builder_tests[] = {
4656     {   "http://google.com/",0,S_OK,FALSE,
4657         {
4658             {TRUE,"#fragment",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4659             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE},
4660             {TRUE,"?query=x",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE},
4661             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4662         },
4663         {FALSE},
4664         0,S_OK,FALSE,
4665         0,S_OK,FALSE,
4666         0,0,0,S_OK,FALSE,
4667         {
4668             {"http://username:password@google.com/?query=x#fragment",S_OK},
4669             {"username:password@google.com",S_OK},
4670             {"http://google.com/?query=x#fragment",S_OK},
4671             {"google.com",S_OK},
4672             {"",S_FALSE},
4673             {"#fragment",S_OK},
4674             {"google.com",S_OK},
4675             {"password",S_OK},
4676             {"/",S_OK},
4677             {"/?query=x",S_OK},
4678             {"?query=x",S_OK},
4679             {"http://username:password@google.com/?query=x#fragment",S_OK},
4680             {"http",S_OK},
4681             {"username:password",S_OK},
4682             {"username",S_OK}
4683         },
4684         {
4685             {Uri_HOST_DNS,S_OK},
4686             {80,S_OK},
4687             {URL_SCHEME_HTTP,S_OK},
4688             {URLZONE_INVALID,E_NOTIMPL}
4689         }
4690     },
4691     {   "http://google.com/",0,S_OK,FALSE,
4692         {
4693             {TRUE,"test",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
4694         },
4695         {TRUE,TRUE,120,S_OK,FALSE},
4696         0,S_OK,FALSE,
4697         0,S_OK,FALSE,
4698         0,0,0,S_OK,FALSE,
4699         {
4700             {"test://google.com:120/",S_OK},
4701             {"google.com:120",S_OK},
4702             {"test://google.com:120/",S_OK},
4703             {"google.com",S_OK},
4704             {"",S_FALSE},
4705             {"",S_FALSE},
4706             {"google.com",S_OK},
4707             {"",S_FALSE},
4708             {"/",S_OK},
4709             {"/",S_OK},
4710             {"",S_FALSE},
4711             {"test://google.com:120/",S_OK},
4712             {"test",S_OK},
4713             {"",S_FALSE},
4714             {"",S_FALSE}
4715         },
4716         {
4717             {Uri_HOST_DNS,S_OK},
4718             {120,S_OK},
4719             {URL_SCHEME_UNKNOWN,S_OK},
4720             {URLZONE_INVALID,E_NOTIMPL}
4721         }
4722     },
4723     {   "/Test/test dir",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4724         {
4725             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
4726             {TRUE,"::192.2.3.4",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
4727             {TRUE,NULL,NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
4728         },
4729         {FALSE},
4730         0,S_OK,FALSE,
4731         0,S_OK,FALSE,
4732         0,0,0,S_OK,FALSE,
4733         {
4734             {"http://[::192.2.3.4]/",S_OK},
4735             {"[::192.2.3.4]",S_OK},
4736             {"http://[::192.2.3.4]/",S_OK},
4737             {"",S_FALSE},
4738             {"",S_FALSE},
4739             {"",S_FALSE},
4740             {"::192.2.3.4",S_OK},
4741             {"",S_FALSE},
4742             {"/",S_OK},
4743             {"/",S_OK},
4744             {"",S_FALSE},
4745             {"http://[::192.2.3.4]/",S_OK},
4746             {"http",S_OK},
4747             {"",S_FALSE},
4748             {"",S_FALSE}
4749         },
4750         {
4751             {Uri_HOST_IPV6,S_OK},
4752             {80,S_OK},
4753             {URL_SCHEME_HTTP,S_OK},
4754             {URLZONE_INVALID,E_NOTIMPL}
4755         }
4756     },
4757     {   "http://google.com/",0,S_OK,FALSE,
4758         {
4759             {TRUE,"Frag","#Frag",Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4760         },
4761         {FALSE},
4762         0,S_OK,FALSE,
4763         0,S_OK,FALSE,
4764         0,0,0,S_OK,FALSE,
4765         {
4766             {"http://google.com/#Frag",S_OK},
4767             {"google.com",S_OK},
4768             {"http://google.com/#Frag",S_OK},
4769             {"google.com",S_OK},
4770             {"",S_FALSE},
4771             {"#Frag",S_OK},
4772             {"google.com",S_OK},
4773             {"",S_FALSE},
4774             {"/",S_OK},
4775             {"/",S_OK},
4776             {"",S_FALSE},
4777             {"http://google.com/#Frag",S_OK},
4778             {"http",S_OK},
4779             {"",S_FALSE},
4780             {"",S_FALSE}
4781         },
4782         {
4783             {Uri_HOST_DNS,S_OK},
4784             {80,S_OK},
4785             {URL_SCHEME_HTTP,S_OK},
4786             {URLZONE_INVALID,E_NOTIMPL}
4787         }
4788     },
4789     {   "http://google.com/",0,S_OK,FALSE,
4790         {
4791             {TRUE,"","#",Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4792         },
4793         {FALSE},
4794         0,S_OK,FALSE,
4795         0,S_OK,FALSE,
4796         0,0,0,S_OK,FALSE,
4797         {
4798             {"http://google.com/#",S_OK},
4799             {"google.com",S_OK},
4800             {"http://google.com/#",S_OK},
4801             {"google.com",S_OK},
4802             {"",S_FALSE},
4803             {"#",S_OK},
4804             {"google.com",S_OK},
4805             {"",S_FALSE},
4806             {"/",S_OK},
4807             {"/",S_OK},
4808             {"",S_FALSE},
4809             {"http://google.com/#",S_OK},
4810             {"http",S_OK},
4811             {"",S_FALSE},
4812             {"",S_FALSE}
4813         },
4814         {
4815             {Uri_HOST_DNS,S_OK},
4816             {80,S_OK},
4817             {URL_SCHEME_HTTP,S_OK},
4818             {URLZONE_INVALID,E_NOTIMPL}
4819         }
4820     },
4821     {   "http://google.com/",0,S_OK,FALSE,
4822         {
4823             {TRUE,":password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4824         },
4825         {FALSE},
4826         0,S_OK,FALSE,
4827         0,S_OK,FALSE,
4828         0,0,0,S_OK,FALSE,
4829         {
4830             {"http://::password@google.com/",S_OK},
4831             {"::password@google.com",S_OK},
4832             {"http://google.com/",S_OK},
4833             {"google.com",S_OK},
4834             {"",S_FALSE},
4835             {"",S_FALSE},
4836             {"google.com",S_OK},
4837             {":password",S_OK},
4838             {"/",S_OK},
4839             {"/",S_OK},
4840             {"",S_FALSE},
4841             {"http://::password@google.com/",S_OK},
4842             {"http",S_OK},
4843             {"::password",S_OK},
4844             {"",S_FALSE}
4845         },
4846         {
4847             {Uri_HOST_DNS,S_OK},
4848             {80,S_OK},
4849             {URL_SCHEME_HTTP,S_OK},
4850             {URLZONE_INVALID,E_NOTIMPL}
4851         }
4852     },
4853     {   "test/test",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4854         {
4855             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4856         },
4857         {FALSE},
4858         Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4859         0,S_OK,FALSE,
4860         Uri_CREATE_ALLOW_RELATIVE,0,0,S_OK,FALSE,
4861         {
4862             {":password@test/test",S_OK},
4863             {":password@",S_OK},
4864             {":password@test/test",S_OK},
4865             {"",S_FALSE},
4866             {"",S_FALSE},
4867             {"",S_FALSE},
4868             {"",S_FALSE},
4869             {"password",S_OK},
4870             {"test/test",S_OK},
4871             {"test/test",S_OK},
4872             {"",S_FALSE},
4873             {":password@test/test",S_OK},
4874             {"",S_FALSE},
4875             {":password",S_OK},
4876             {"",S_FALSE}
4877         },
4878         {
4879             {Uri_HOST_UNKNOWN,S_OK},
4880             {0,S_FALSE},
4881             {URL_SCHEME_UNKNOWN,S_OK},
4882             {URLZONE_INVALID,E_NOTIMPL}
4883         }
4884     },
4885     {   "http://google.com/",0,S_OK,FALSE,
4886         {
4887             {TRUE,"test/test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4888         },
4889         {FALSE},
4890         0,S_OK,FALSE,
4891         0,S_OK,FALSE,
4892         0,0,0,S_OK,FALSE,
4893         {
4894             {"http://google.com/test/test",S_OK},
4895             {"google.com",S_OK},
4896             {"http://google.com/test/test",S_OK},
4897             {"google.com",S_OK},
4898             {"",S_FALSE},
4899             {"",S_FALSE},
4900             {"google.com",S_OK},
4901             {"",S_FALSE},
4902             {"/test/test",S_OK},
4903             {"/test/test",S_OK},
4904             {"",S_FALSE},
4905             {"http://google.com/test/test",S_OK},
4906             {"http",S_OK},
4907             {"",S_FALSE},
4908             {"",S_FALSE}
4909         },
4910         {
4911             {Uri_HOST_DNS,S_OK},
4912             {80,S_OK},
4913             {URL_SCHEME_HTTP,S_OK},
4914             {URLZONE_INVALID,E_NOTIMPL}
4915         }
4916     },
4917     {   "zip:testing/test",0,S_OK,FALSE,
4918         {
4919             {TRUE,"test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4920         },
4921         {FALSE},
4922         0,S_OK,FALSE,
4923         0,S_OK,FALSE,
4924         0,0,0,S_OK,FALSE,
4925         {
4926             {"zip:test",S_OK},
4927             {"",S_FALSE},
4928             {"zip:test",S_OK},
4929             {"",S_FALSE},
4930             {"",S_FALSE},
4931             {"",S_FALSE},
4932             {"",S_FALSE},
4933             {"",S_FALSE},
4934             {"test",S_OK},
4935             {"test",S_OK},
4936             {"",S_FALSE},
4937             {"zip:test",S_OK},
4938             {"zip",S_OK},
4939             {"",S_FALSE},
4940             {"",S_FALSE}
4941         },
4942         {
4943             {Uri_HOST_UNKNOWN,S_OK},
4944             {0,S_FALSE},
4945             {URL_SCHEME_UNKNOWN,S_OK},
4946             {URLZONE_INVALID,E_NOTIMPL}
4947         }
4948     },
4949     {   "http://google.com/",0,S_OK,FALSE,
4950         {
4951             {FALSE},
4952         },
4953         /* 555 will be returned from GetPort even though FALSE was passed as the hasPort parameter. */
4954         {TRUE,FALSE,555,S_OK,FALSE},
4955         0,S_OK,FALSE,
4956         0,S_OK,FALSE,
4957         0,0,0,S_OK,FALSE,
4958         {
4959             {"http://google.com/",S_OK},
4960             {"google.com",S_OK},
4961             {"http://google.com/",S_OK},
4962             {"google.com",S_OK},
4963             {"",S_FALSE},
4964             {"",S_FALSE},
4965             {"google.com",S_OK},
4966             {"",S_FALSE},
4967             {"/",S_OK},
4968             {"/",S_OK},
4969             {"",S_FALSE},
4970             {"http://google.com/",S_OK},
4971             {"http",S_OK},
4972             {"",S_FALSE},
4973             {"",S_FALSE}
4974         },
4975         {
4976             {Uri_HOST_DNS,S_OK},
4977             /* Still returns 80, even though earlier the port was disabled. */
4978             {80,S_OK},
4979             {URL_SCHEME_HTTP,S_OK},
4980             {URLZONE_INVALID,E_NOTIMPL}
4981         }
4982     },
4983     {   "http://google.com/",0,S_OK,FALSE,
4984         {
4985             {FALSE},
4986         },
4987         /* Instead of getting "TRUE" back as the "hasPort" parameter in GetPort,
4988          * you'll get 122345 instead.
4989          */
4990         {TRUE,122345,222,S_OK,FALSE},
4991         0,S_OK,FALSE,
4992         0,S_OK,FALSE,
4993         0,0,0,S_OK,FALSE,
4994         {
4995             {"http://google.com:222/",S_OK},
4996             {"google.com:222",S_OK},
4997             {"http://google.com:222/",S_OK},
4998             {"google.com",S_OK},
4999             {"",S_FALSE},
5000             {"",S_FALSE},
5001             {"google.com",S_OK},
5002             {"",S_FALSE},
5003             {"/",S_OK},
5004             {"/",S_OK},
5005             {"",S_FALSE},
5006             {"http://google.com:222/",S_OK},
5007             {"http",S_OK},
5008             {"",S_FALSE},
5009             {"",S_FALSE}
5010         },
5011         {
5012             {Uri_HOST_DNS,S_OK},
5013             {222,S_OK},
5014             {URL_SCHEME_HTTP,S_OK},
5015             {URLZONE_INVALID,E_NOTIMPL}
5016         }
5017     },
5018     /* IUri's created with the IUriBuilder can have ports that exceed USHORT_MAX. */
5019     {   "http://google.com/",0,S_OK,FALSE,
5020         {
5021             {FALSE},
5022         },
5023         {TRUE,TRUE,999999,S_OK,FALSE},
5024         0,S_OK,FALSE,
5025         0,S_OK,FALSE,
5026         0,0,0,S_OK,FALSE,
5027         {
5028             {"http://google.com:999999/",S_OK},
5029             {"google.com:999999",S_OK},
5030             {"http://google.com:999999/",S_OK},
5031             {"google.com",S_OK},
5032             {"",S_FALSE},
5033             {"",S_FALSE},
5034             {"google.com",S_OK},
5035             {"",S_FALSE},
5036             {"/",S_OK},
5037             {"/",S_OK},
5038             {"",S_FALSE},
5039             {"http://google.com:999999/",S_OK},
5040             {"http",S_OK},
5041             {"",S_FALSE},
5042             {"",S_FALSE}
5043         },
5044         {
5045             {Uri_HOST_DNS,S_OK},
5046             {999999,S_OK},
5047             {URL_SCHEME_HTTP,S_OK},
5048             {URLZONE_INVALID,E_NOTIMPL}
5049         }
5050     },
5051     {   "http://google.com/",0,S_OK,FALSE,
5052         {
5053             {TRUE,"test","?test",Uri_PROPERTY_QUERY,S_OK,FALSE},
5054         },
5055
5056         {FALSE},
5057         0,S_OK,FALSE,
5058         0,S_OK,FALSE,
5059         0,0,0,S_OK,FALSE,
5060         {
5061             {"http://google.com/?test",S_OK},
5062             {"google.com",S_OK},
5063             {"http://google.com/?test",S_OK},
5064             {"google.com",S_OK},
5065             {"",S_FALSE},
5066             {"",S_FALSE},
5067             {"google.com",S_OK},
5068             {"",S_FALSE},
5069             {"/",S_OK},
5070             {"/?test",S_OK},
5071             {"?test",S_OK},
5072             {"http://google.com/?test",S_OK},
5073             {"http",S_OK},
5074             {"",S_FALSE},
5075             {"",S_FALSE}
5076         },
5077         {
5078             {Uri_HOST_DNS,S_OK},
5079             {80,S_OK},
5080             {URL_SCHEME_HTTP,S_OK},
5081             {URLZONE_INVALID,E_NOTIMPL}
5082         }
5083     },
5084     {   "http://:password@google.com/",0,S_OK,FALSE,
5085         {
5086             {FALSE},
5087         },
5088         {FALSE},
5089         0,S_OK,FALSE,
5090         0,S_OK,FALSE,
5091         0,0,0,S_OK,FALSE,
5092         {
5093             {"http://:password@google.com/",S_OK},
5094             {":password@google.com",S_OK},
5095             {"http://google.com/",S_OK},
5096             {"google.com",S_OK},
5097             {"",S_FALSE},
5098             {"",S_FALSE},
5099             {"google.com",S_OK},
5100             {"password",S_OK},
5101             {"/",S_OK},
5102             {"/",S_OK},
5103             {"",S_FALSE},
5104             {"http://:password@google.com/",S_OK},
5105             {"http",S_OK},
5106             {":password",S_OK},
5107             {"",S_FALSE}
5108         },
5109         {
5110             {Uri_HOST_DNS,S_OK},
5111             {80,S_OK},
5112             {URL_SCHEME_HTTP,S_OK},
5113             {URLZONE_INVALID,E_NOTIMPL}
5114         }
5115     },
5116     /* IUriBuilder doesn't need a base IUri to build a IUri. */
5117     {   NULL,0,S_OK,FALSE,
5118         {
5119             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
5120             {TRUE,"google.com",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5121         },
5122         {FALSE},
5123         0,S_OK,FALSE,
5124         0,S_OK,FALSE,
5125         0,0,0,S_OK,FALSE,
5126         {
5127             {"http://google.com/",S_OK},
5128             {"google.com",S_OK},
5129             {"http://google.com/",S_OK},
5130             {"google.com",S_OK},
5131             {"",S_FALSE},
5132             {"",S_FALSE},
5133             {"google.com",S_OK},
5134             {"",S_FALSE},
5135             {"/",S_OK},
5136             {"/",S_OK},
5137             {"",S_FALSE},
5138             {"http://google.com/",S_OK},
5139             {"http",S_OK},
5140             {"",S_FALSE},
5141             {"",S_FALSE}
5142         },
5143         {
5144             {Uri_HOST_DNS,S_OK},
5145             {80,S_OK},
5146             {URL_SCHEME_HTTP,S_OK},
5147             {URLZONE_INVALID,E_NOTIMPL}
5148         }
5149     },
5150     /* Can't set the scheme name to NULL. */
5151     {   "zip://google.com/",0,S_OK,FALSE,
5152         {
5153             {TRUE,NULL,"zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
5154         },
5155         {FALSE},
5156         0,S_OK,FALSE,
5157         0,S_OK,FALSE,
5158         0,0,0,S_OK,FALSE,
5159         {
5160             {"zip://google.com/",S_OK},
5161             {"google.com",S_OK},
5162             {"zip://google.com/",S_OK},
5163             {"google.com",S_OK},
5164             {"",S_FALSE},
5165             {"",S_FALSE},
5166             {"google.com",S_OK},
5167             {"",S_FALSE},
5168             {"/",S_OK},
5169             {"/",S_OK},
5170             {"",S_FALSE},
5171             {"zip://google.com/",S_OK},
5172             {"zip",S_OK},
5173             {"",S_FALSE},
5174             {"",S_FALSE}
5175         },
5176         {
5177             {Uri_HOST_DNS,S_OK},
5178             {0,S_FALSE},
5179             {URL_SCHEME_UNKNOWN,S_OK},
5180             {URLZONE_INVALID,E_NOTIMPL}
5181         }
5182     },
5183     /* Can't set the scheme name to an empty string. */
5184     {   "zip://google.com/",0,S_OK,FALSE,
5185         {
5186             {TRUE,"","zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
5187         },
5188         {FALSE},
5189         0,S_OK,FALSE,
5190         0,S_OK,FALSE,
5191         0,0,0,S_OK,FALSE,
5192         {
5193             {"zip://google.com/",S_OK},
5194             {"google.com",S_OK},
5195             {"zip://google.com/",S_OK},
5196             {"google.com",S_OK},
5197             {"",S_FALSE},
5198             {"",S_FALSE},
5199             {"google.com",S_OK},
5200             {"",S_FALSE},
5201             {"/",S_OK},
5202             {"/",S_OK},
5203             {"",S_FALSE},
5204             {"zip://google.com/",S_OK},
5205             {"zip",S_OK},
5206             {"",S_FALSE},
5207             {"",S_FALSE}
5208         },
5209         {
5210             {Uri_HOST_DNS,S_OK},
5211             {0,S_FALSE},
5212             {URL_SCHEME_UNKNOWN,S_OK},
5213             {URLZONE_INVALID,E_NOTIMPL}
5214         }
5215     },
5216     /* -1 to CreateUri makes it use the same flags as the base IUri was created with.
5217      * CreateUriSimple always uses the flags the base IUri was created with (if any).
5218      */
5219     {   "http://google.com/../../",Uri_CREATE_NO_CANONICALIZE,S_OK,FALSE,
5220         {{FALSE}},
5221         {FALSE},
5222         -1,S_OK,FALSE,
5223         0,S_OK,FALSE,
5224         0,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5225         {
5226             {"http://google.com/../../",S_OK},
5227             {"google.com",S_OK},
5228             {"http://google.com/../../",S_OK},
5229             {"google.com",S_OK},
5230             {"",S_FALSE},
5231             {"",S_FALSE},
5232             {"google.com",S_OK},
5233             {"",S_FALSE},
5234             {"/../../",S_OK},
5235             {"/../../",S_OK},
5236             {"",S_FALSE},
5237             {"http://google.com/../../",S_OK},
5238             {"http",S_OK},
5239             {"",S_FALSE},
5240             {"",S_FALSE}
5241         },
5242         {
5243             {Uri_HOST_DNS,S_OK},
5244             {80,S_OK},
5245             {URL_SCHEME_HTTP,S_OK},
5246             {URLZONE_INVALID,E_NOTIMPL}
5247         }
5248     },
5249     {   "http://google.com/",0,S_OK,FALSE,
5250         {
5251             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5252         },
5253         {FALSE},
5254         -1,S_OK,FALSE,
5255         0,S_OK,FALSE,
5256         Uri_CREATE_NO_DECODE_EXTRA_INFO,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5257         {
5258             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5259             {"google.com",S_OK},
5260             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5261             {"google.com",S_OK},
5262             {"",S_FALSE},
5263             {"#Fr%3C%7C%3Eg",S_OK},
5264             {"google.com",S_OK},
5265             {"",S_FALSE},
5266             {"/",S_OK},
5267             {"/",S_OK},
5268             {"",S_FALSE},
5269             {"http://google.com/#Fr<|>g",S_OK},
5270             {"http",S_OK},
5271             {"",S_FALSE},
5272             {"",S_FALSE}
5273         },
5274         {
5275             {Uri_HOST_DNS,S_OK},
5276             {80,S_OK},
5277             {URL_SCHEME_HTTP,S_OK},
5278             {URLZONE_INVALID,E_NOTIMPL}
5279         }
5280     },
5281     {   "http://google.com/",0,S_OK,FALSE,
5282         {
5283             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5284         },
5285         {FALSE},
5286         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,E_INVALIDARG,FALSE,
5287         0,S_OK,FALSE,
5288         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5289         {
5290             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5291             {"google.com",S_OK},
5292             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5293             {"google.com",S_OK},
5294             {"",S_FALSE},
5295             {"#Fr%3C%7C%3Eg",S_OK},
5296             {"google.com",S_OK},
5297             {"",S_FALSE},
5298             {"/",S_OK},
5299             {"/",S_OK},
5300             {"",S_FALSE},
5301             {"http://google.com/#Fr<|>g",S_OK},
5302             {"http",S_OK},
5303             {"",S_FALSE},
5304             {"",S_FALSE}
5305         },
5306         {
5307             {Uri_HOST_DNS,S_OK},
5308             {80,S_OK},
5309             {URL_SCHEME_HTTP,S_OK},
5310             {URLZONE_INVALID,E_NOTIMPL}
5311         }
5312     },
5313     {   NULL,0,S_OK,FALSE,
5314         {
5315             {TRUE,"/test/test/",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
5316             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5317         },
5318         {FALSE},
5319         0,INET_E_INVALID_URL,FALSE,
5320         0,INET_E_INVALID_URL,FALSE,
5321         0,0,0,INET_E_INVALID_URL,FALSE
5322     },
5323     {   "http://google.com/",0,S_OK,FALSE,
5324         {
5325             {TRUE,"ht%xxtp",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
5326         },
5327         {FALSE},
5328         0,INET_E_INVALID_URL,FALSE,
5329         0,INET_E_INVALID_URL,FALSE,
5330         0,0,0,INET_E_INVALID_URL,FALSE
5331     },
5332     /* File scheme's can't have a username set. */
5333     {   "file://google.com/",0,S_OK,FALSE,
5334         {
5335             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5336         },
5337         {FALSE},
5338         0,INET_E_INVALID_URL,FALSE,
5339         0,INET_E_INVALID_URL,FALSE,
5340         0,0,0,INET_E_INVALID_URL,FALSE
5341     },
5342     /* File schemes can't have a password set. */
5343     {   "file://google.com/",0,S_OK,FALSE,
5344         {
5345             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5346         },
5347         {FALSE},
5348         0,INET_E_INVALID_URL,FALSE,
5349         0,INET_E_INVALID_URL,FALSE,
5350         0,0,0,INET_E_INVALID_URL,FALSE
5351     },
5352     /* UserName can't contain any character that is a delimeter for another
5353      * component that appears after it in a normal URI.
5354      */
5355     {   "http://google.com/",0,S_OK,FALSE,
5356         {
5357             {TRUE,"user:pass",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5358         },
5359         {FALSE},
5360         0,INET_E_INVALID_URL,FALSE,
5361         0,INET_E_INVALID_URL,FALSE,
5362         0,0,0,INET_E_INVALID_URL,FALSE
5363     },
5364     {   "http://google.com/",0,S_OK,FALSE,
5365         {
5366             {TRUE,"user@google.com",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5367         },
5368         {FALSE},
5369         0,INET_E_INVALID_URL,FALSE,
5370         0,INET_E_INVALID_URL,FALSE,
5371         0,0,0,INET_E_INVALID_URL,FALSE
5372     },
5373     {   "http://google.com/",0,S_OK,FALSE,
5374         {
5375             {TRUE,"user/path",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5376         },
5377         {FALSE},
5378         0,INET_E_INVALID_URL,FALSE,
5379         0,INET_E_INVALID_URL,FALSE,
5380         0,0,0,INET_E_INVALID_URL,FALSE
5381     },
5382     {   "http://google.com/",0,S_OK,FALSE,
5383         {
5384             {TRUE,"user?Query",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5385         },
5386         {FALSE},
5387         0,INET_E_INVALID_URL,FALSE,
5388         0,INET_E_INVALID_URL,FALSE,
5389         0,0,0,INET_E_INVALID_URL,FALSE
5390     },
5391     {   "http://google.com/",0,S_OK,FALSE,
5392         {
5393             {TRUE,"user#Frag",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5394         },
5395         {FALSE},
5396         0,INET_E_INVALID_URL,FALSE,
5397         0,INET_E_INVALID_URL,FALSE,
5398         0,0,0,INET_E_INVALID_URL,FALSE
5399     },
5400     {   "http://google.com/",0,S_OK,FALSE,
5401         {
5402             {TRUE,"pass@google.com",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5403         },
5404         {FALSE},
5405         0,INET_E_INVALID_URL,FALSE,
5406         0,INET_E_INVALID_URL,FALSE,
5407         0,0,0,INET_E_INVALID_URL,FALSE
5408     },
5409     {   "http://google.com/",0,S_OK,FALSE,
5410         {
5411             {TRUE,"pass/path",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5412         },
5413         {FALSE},
5414         0,INET_E_INVALID_URL,FALSE,
5415         0,INET_E_INVALID_URL,FALSE,
5416         0,0,0,INET_E_INVALID_URL,FALSE
5417     },
5418     {   "http://google.com/",0,S_OK,FALSE,
5419         {
5420             {TRUE,"pass?query",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5421         },
5422         {FALSE},
5423         0,INET_E_INVALID_URL,FALSE,
5424         0,INET_E_INVALID_URL,FALSE,
5425        0,0,0,INET_E_INVALID_URL,FALSE
5426     },
5427     {   "http://google.com/",0,S_OK,FALSE,
5428         {
5429             {TRUE,"pass#frag",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5430         },
5431         {FALSE},
5432         0,INET_E_INVALID_URL,FALSE,
5433         0,INET_E_INVALID_URL,FALSE,
5434         0,0,0,INET_E_INVALID_URL,FALSE
5435     },
5436     {   "http://google.com/",0,S_OK,FALSE,
5437         {
5438             {TRUE,"winehq.org/test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5439         },
5440         {FALSE},
5441         0,INET_E_INVALID_URL,FALSE,
5442         0,INET_E_INVALID_URL,FALSE,
5443         0,0,0,INET_E_INVALID_URL,FALSE
5444     },
5445     {   "http://google.com/",0,S_OK,FALSE,
5446         {
5447             {TRUE,"winehq.org?test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5448         },
5449         {FALSE},
5450         0,INET_E_INVALID_URL,FALSE,
5451         0,INET_E_INVALID_URL,FALSE,
5452         0,0,0,INET_E_INVALID_URL,FALSE
5453     },
5454     {   "http://google.com/",0,S_OK,FALSE,
5455         {
5456             {TRUE,"winehq.org#test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5457         },
5458         {FALSE},
5459         0,INET_E_INVALID_URL,FALSE,
5460         0,INET_E_INVALID_URL,FALSE,
5461         0,0,0,INET_E_INVALID_URL,FALSE
5462     },
5463     /* Hostname is allowed to contain a ':' (even for known scheme types). */
5464     {   "http://google.com/",0,S_OK,FALSE,
5465         {
5466             {TRUE,"winehq.org:test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
5467         },
5468         {FALSE},
5469         0,S_OK,FALSE,
5470         0,S_OK,FALSE,
5471         0,0,0,S_OK,FALSE,
5472         {
5473             {"http://winehq.org:test/",S_OK},
5474             {"winehq.org:test",S_OK},
5475             {"http://winehq.org:test/",S_OK},
5476             {"winehq.org:test",S_OK},
5477             {"",S_FALSE},
5478             {"",S_FALSE},
5479             {"winehq.org:test",S_OK},
5480             {"",S_FALSE},
5481             {"/",S_OK},
5482             {"/",S_OK},
5483             {"",S_FALSE},
5484             {"http://winehq.org:test/",S_OK},
5485             {"http",S_OK},
5486             {"",S_FALSE},
5487             {"",S_FALSE}
5488         },
5489         {
5490             {Uri_HOST_DNS,S_OK},
5491             {80,S_OK},
5492             {URL_SCHEME_HTTP,S_OK},
5493             {URLZONE_INVALID,E_NOTIMPL}
5494         }
5495     },
5496     /* Can't set the host name to NULL. */
5497     {   "http://google.com/",0,S_OK,FALSE,
5498         {
5499             {TRUE,NULL,"google.com",Uri_PROPERTY_HOST,E_INVALIDARG,FALSE}
5500         },
5501         {FALSE},
5502         0,S_OK,FALSE,
5503         0,S_OK,FALSE,
5504         0,0,0,S_OK,FALSE,
5505         {
5506             {"http://google.com/",S_OK},
5507             {"google.com",S_OK},
5508             {"http://google.com/",S_OK},
5509             {"google.com",S_OK},
5510             {"",S_FALSE},
5511             {"",S_FALSE},
5512             {"google.com",S_OK},
5513             {"",S_FALSE},
5514             {"/",S_OK},
5515             {"/",S_OK},
5516             {"",S_FALSE},
5517             {"http://google.com/",S_OK},
5518             {"http",S_OK},
5519             {"",S_FALSE},
5520             {"",S_FALSE}
5521         },
5522         {
5523             {Uri_HOST_DNS,S_OK},
5524             {80,S_OK},
5525             {URL_SCHEME_HTTP,S_OK},
5526             {URLZONE_INVALID,E_NOTIMPL}
5527         }
5528     },
5529     /* Can set the host name to an empty string. */
5530     {   "http://google.com/",0,S_OK,FALSE,
5531         {
5532             {TRUE,"",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5533         },
5534         {FALSE},
5535         0,S_OK,FALSE,
5536         0,S_OK,FALSE,
5537         0,0,0,S_OK,FALSE,
5538         {
5539             {"http:///",S_OK},
5540             {"",S_OK},
5541             {"http:///",S_OK},
5542             {"",S_FALSE},
5543             {"",S_FALSE},
5544             {"",S_FALSE},
5545             {"",S_OK},
5546             {"",S_FALSE},
5547             {"/",S_OK},
5548             {"/",S_OK},
5549             {"",S_FALSE},
5550             {"http:///",S_OK},
5551             {"http",S_OK},
5552             {"",S_FALSE},
5553             {"",S_FALSE}
5554         },
5555         {
5556             {Uri_HOST_UNKNOWN,S_OK},
5557             {80,S_OK},
5558             {URL_SCHEME_HTTP,S_OK},
5559             {URLZONE_INVALID,E_NOTIMPL}
5560         }
5561     },
5562     {   "http://google.com/",0,S_OK,FALSE,
5563         {
5564             {TRUE,"/path?query",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5565         },
5566         {FALSE},
5567         0,INET_E_INVALID_URL,FALSE,
5568         0,INET_E_INVALID_URL,FALSE,
5569         0,0,0,INET_E_INVALID_URL,FALSE
5570     },
5571     {   "http://google.com/",0,S_OK,FALSE,
5572         {
5573             {TRUE,"/path#test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5574         },
5575         {FALSE},
5576         0,INET_E_INVALID_URL,FALSE,
5577         0,INET_E_INVALID_URL,FALSE,
5578         0,0,0,INET_E_INVALID_URL,FALSE
5579     },
5580     {   "http://google.com/",0,S_OK,FALSE,
5581         {
5582             {TRUE,"?path#test",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE}
5583         },
5584         {FALSE},
5585         0,INET_E_INVALID_URL,FALSE,
5586         0,INET_E_INVALID_URL,FALSE,
5587         0,0,0,INET_E_INVALID_URL,FALSE
5588     },
5589     {   "file:///c:/dir/file.html",0,S_OK,FALSE,
5590         {
5591             {TRUE,NULL,NULL,Uri_PROPERTY_FRAGMENT,S_OK},
5592         },
5593         {FALSE},
5594         0,S_OK,FALSE,
5595         0,S_OK,FALSE,
5596         0,0,0,S_OK,FALSE,
5597         {
5598             {"file:///c:/dir/file.html",S_OK},
5599             {"",S_FALSE},
5600             {"file:///c:/dir/file.html",S_OK},
5601             {"",S_FALSE},
5602             {".html",S_OK},
5603             {"",S_FALSE},
5604             {"",S_FALSE},
5605             {"",S_FALSE},
5606             {"/c:/dir/file.html",S_OK},
5607             {"/c:/dir/file.html",S_OK},
5608             {"",S_FALSE},
5609             {"file:///c:/dir/file.html",S_OK},
5610             {"file",S_OK},
5611             {"",S_FALSE},
5612             {"",S_FALSE}
5613         },
5614         {
5615             {Uri_HOST_UNKNOWN,S_OK},
5616             {0,S_FALSE},
5617             {URL_SCHEME_FILE,S_OK},
5618             {URLZONE_INVALID,E_NOTIMPL}
5619         }
5620     },
5621     {   "file:///c:/dir/file.html",0,S_OK,FALSE,
5622         {
5623             {TRUE,"#",NULL,Uri_PROPERTY_FRAGMENT,S_OK},
5624         },
5625         {FALSE},
5626         0,S_OK,FALSE,
5627         0,S_OK,FALSE,
5628         0,0,0,S_OK,FALSE,
5629         {
5630             {"file:///c:/dir/file.html#",S_OK},
5631             {"",S_FALSE},
5632             {"file:///c:/dir/file.html#",S_OK},
5633             {"",S_FALSE},
5634             {".html",S_OK},
5635             {"#",S_OK},
5636             {"",S_FALSE},
5637             {"",S_FALSE},
5638             {"/c:/dir/file.html",S_OK},
5639             {"/c:/dir/file.html",S_OK},
5640             {"",S_FALSE},
5641             {"file:///c:/dir/file.html#",S_OK},
5642             {"file",S_OK},
5643             {"",S_FALSE},
5644             {"",S_FALSE}
5645         },
5646         {
5647             {Uri_HOST_UNKNOWN,S_OK},
5648             {0,S_FALSE},
5649             {URL_SCHEME_FILE,S_OK},
5650             {URLZONE_INVALID,E_NOTIMPL}
5651         }
5652     }
5653 };
5654
5655 typedef struct _uri_builder_remove_test {
5656     const char  *uri;
5657     DWORD       create_flags;
5658     HRESULT     create_builder_expected;
5659     BOOL        create_builder_todo;
5660
5661     DWORD       remove_properties;
5662     HRESULT     remove_expected;
5663     BOOL        remove_todo;
5664
5665     const char  *expected_uri;
5666     DWORD       expected_flags;
5667     HRESULT     expected_hres;
5668     BOOL        expected_todo;
5669 } uri_builder_remove_test;
5670
5671 static const uri_builder_remove_test uri_builder_remove_tests[] = {
5672     {   "http://google.com/test?test=y#Frag",0,S_OK,FALSE,
5673         Uri_HAS_FRAGMENT|Uri_HAS_PATH|Uri_HAS_QUERY,S_OK,FALSE,
5674         "http://google.com/",0,S_OK,FALSE
5675     },
5676     {   "http://user:pass@winehq.org/",0,S_OK,FALSE,
5677         Uri_HAS_USER_NAME|Uri_HAS_PASSWORD,S_OK,FALSE,
5678         "http://winehq.org/",0,S_OK,FALSE
5679     },
5680     {   "zip://google.com?Test=x",0,S_OK,FALSE,
5681         Uri_HAS_HOST,S_OK,FALSE,
5682         "zip:/?Test=x",0,S_OK,FALSE
5683     },
5684     /* Doesn't remove the whole userinfo component. */
5685     {   "http://username:pass@google.com/",0,S_OK,FALSE,
5686         Uri_HAS_USER_INFO,S_OK,FALSE,
5687         "http://username:pass@google.com/",0,S_OK,FALSE
5688     },
5689     /* Doesn't remove the domain. */
5690     {   "http://google.com/",0,S_OK,FALSE,
5691         Uri_HAS_DOMAIN,S_OK,FALSE,
5692         "http://google.com/",0,S_OK,FALSE
5693     },
5694     {   "http://google.com:120/",0,S_OK,FALSE,
5695         Uri_HAS_AUTHORITY,S_OK,FALSE,
5696         "http://google.com:120/",0,S_OK,FALSE
5697     },
5698     {   "http://google.com/test.com/",0,S_OK,FALSE,
5699         Uri_HAS_EXTENSION,S_OK,FALSE,
5700         "http://google.com/test.com/",0,S_OK,FALSE
5701     },
5702     {   "http://google.com/?test=x",0,S_OK,FALSE,
5703         Uri_HAS_PATH_AND_QUERY,S_OK,FALSE,
5704         "http://google.com/?test=x",0,S_OK,FALSE
5705     },
5706     /* Can't remove the scheme name. */
5707     {   "http://google.com/?test=x",0,S_OK,FALSE,
5708         Uri_HAS_SCHEME_NAME|Uri_HAS_QUERY,E_INVALIDARG,FALSE,
5709         "http://google.com/?test=x",0,S_OK,FALSE
5710     }
5711 };
5712
5713 typedef struct _uri_combine_str_property {
5714     const char  *value;
5715     HRESULT     expected;
5716     BOOL        todo;
5717     const char  *broken_value;
5718     const char  *value_ex;
5719 } uri_combine_str_property;
5720
5721 typedef struct _uri_combine_test {
5722     const char  *base_uri;
5723     DWORD       base_create_flags;
5724     const char  *relative_uri;
5725     DWORD       relative_create_flags;
5726     DWORD       combine_flags;
5727     HRESULT     expected;
5728     BOOL        todo;
5729
5730     uri_combine_str_property    str_props[URI_STR_PROPERTY_COUNT];
5731     uri_dword_property          dword_props[URI_DWORD_PROPERTY_COUNT];
5732 } uri_combine_test;
5733
5734 static const uri_combine_test uri_combine_tests[] = {
5735     {   "http://google.com/fun/stuff",0,
5736         "../not/fun/stuff",Uri_CREATE_ALLOW_RELATIVE,
5737         0,S_OK,FALSE,
5738         {
5739             {"http://google.com/not/fun/stuff",S_OK},
5740             {"google.com",S_OK},
5741             {"http://google.com/not/fun/stuff",S_OK},
5742             {"google.com",S_OK},
5743             {"",S_FALSE},
5744             {"",S_FALSE},
5745             {"google.com",S_OK},
5746             {"",S_FALSE},
5747             {"/not/fun/stuff",S_OK},
5748             {"/not/fun/stuff",S_OK},
5749             {"",S_FALSE},
5750             {"http://google.com/not/fun/stuff",S_OK},
5751             {"http",S_OK},
5752             {"",S_FALSE},
5753             {"",S_FALSE}
5754         },
5755         {
5756             {Uri_HOST_DNS,S_OK},
5757             {80,S_OK},
5758             {URL_SCHEME_HTTP,S_OK},
5759             {URLZONE_INVALID,E_NOTIMPL}
5760         }
5761     },
5762     {   "http://google.com/test",0,
5763         "zip://test.com/cool",0,
5764         0,S_OK,FALSE,
5765         {
5766             {"zip://test.com/cool",S_OK},
5767             {"test.com",S_OK},
5768             {"zip://test.com/cool",S_OK},
5769             {"test.com",S_OK},
5770             {"",S_FALSE},
5771             {"",S_FALSE},
5772             {"test.com",S_OK},
5773             {"",S_FALSE},
5774             {"/cool",S_OK},
5775             {"/cool",S_OK},
5776             {"",S_FALSE},
5777             {"zip://test.com/cool",S_OK},
5778             {"zip",S_OK},
5779             {"",S_FALSE},
5780             {"",S_FALSE}
5781         },
5782         {
5783             {Uri_HOST_DNS,S_OK},
5784             {0,S_FALSE},
5785             {URL_SCHEME_UNKNOWN,S_OK},
5786             {URLZONE_INVALID,E_NOTIMPL}
5787         }
5788     },
5789     {   "http://google.com/use/base/path",0,
5790         "?relative",Uri_CREATE_ALLOW_RELATIVE,
5791         0,S_OK,FALSE,
5792         {
5793             {"http://google.com/use/base/path?relative",S_OK},
5794             {"google.com",S_OK},
5795             {"http://google.com/use/base/path?relative",S_OK},
5796             {"google.com",S_OK},
5797             {"",S_FALSE},
5798             {"",S_FALSE},
5799             {"google.com",S_OK},
5800             {"",S_FALSE},
5801             {"/use/base/path",S_OK},
5802             {"/use/base/path?relative",S_OK},
5803             {"?relative",S_OK},
5804             {"http://google.com/use/base/path?relative",S_OK},
5805             {"http",S_OK},
5806             {"",S_FALSE},
5807             {"",S_FALSE}
5808         },
5809         {
5810             {Uri_HOST_DNS,S_OK},
5811             {80,S_OK},
5812             {URL_SCHEME_HTTP,S_OK},
5813             {URLZONE_INVALID,E_NOTIMPL}
5814         }
5815     },
5816     {   "http://google.com/path",0,
5817         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5818         0,S_OK,FALSE,
5819         {
5820             {"http://google.com/testing",S_OK},
5821             {"google.com",S_OK},
5822             {"http://google.com/testing",S_OK},
5823             {"google.com",S_OK},
5824             {"",S_FALSE},
5825             {"",S_FALSE},
5826             {"google.com",S_OK},
5827             {"",S_FALSE},
5828             {"/testing",S_OK},
5829             {"/testing",S_OK},
5830             {"",S_FALSE},
5831             {"http://google.com/testing",S_OK},
5832             {"http",S_OK},
5833             {"",S_FALSE},
5834             {"",S_FALSE}
5835         },
5836         {
5837             {Uri_HOST_DNS,S_OK},
5838             {80,S_OK},
5839             {URL_SCHEME_HTTP,S_OK},
5840             {URLZONE_INVALID,E_NOTIMPL}
5841         }
5842     },
5843     {   "http://google.com/path",0,
5844         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5845         URL_DONT_SIMPLIFY,S_OK,FALSE,
5846         {
5847             {"http://google.com:80/test/../test/.././testing",S_OK},
5848             {"google.com",S_OK},
5849             {"http://google.com:80/test/../test/.././testing",S_OK},
5850             {"google.com",S_OK},
5851             {"",S_FALSE},
5852             {"",S_FALSE},
5853             {"google.com",S_OK},
5854             {"",S_FALSE},
5855             {"/test/../test/.././testing",S_OK},
5856             {"/test/../test/.././testing",S_OK},
5857             {"",S_FALSE},
5858             {"http://google.com:80/test/../test/.././testing",S_OK},
5859             {"http",S_OK},
5860             {"",S_FALSE},
5861             {"",S_FALSE}
5862         },
5863         {
5864             {Uri_HOST_DNS,S_OK},
5865             {80,S_OK},
5866             {URL_SCHEME_HTTP,S_OK},
5867             {URLZONE_INVALID,E_NOTIMPL}
5868         }
5869     },
5870     {   "http://winehq.org/test/abc",0,
5871         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5872         0,S_OK,FALSE,
5873         {
5874             {"http://winehq.org/test/testing/test",S_OK},
5875             {"winehq.org",S_OK},
5876             {"http://winehq.org/test/testing/test",S_OK},
5877             {"winehq.org",S_OK},
5878             {"",S_FALSE},
5879             {"",S_FALSE},
5880             {"winehq.org",S_OK},
5881             {"",S_FALSE},
5882             {"/test/testing/test",S_OK},
5883             {"/test/testing/test",S_OK},
5884             {"",S_FALSE},
5885             {"http://winehq.org/test/testing/test",S_OK},
5886             {"http",S_OK},
5887             {"",S_FALSE},
5888             {"",S_FALSE}
5889         },
5890         {
5891             {Uri_HOST_DNS,S_OK},
5892             {80,S_OK},
5893             {URL_SCHEME_HTTP,S_OK},
5894             {URLZONE_INVALID,E_NOTIMPL}
5895         }
5896     },
5897     {   "http://winehq.org/test/abc",0,
5898         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5899         URL_DONT_SIMPLIFY,S_OK,FALSE,
5900         {
5901             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5902             /* Default port is hidden in the authority. */
5903             {"winehq.org",S_OK},
5904             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5905             {"winehq.org",S_OK},
5906             {"",S_FALSE},
5907             {"",S_FALSE},
5908             {"winehq.org",S_OK},
5909             {"",S_FALSE},
5910             {"/test/testing/abc/../test",S_OK},
5911             {"/test/testing/abc/../test",S_OK},
5912             {"",S_FALSE},
5913             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5914             {"http",S_OK},
5915             {"",S_FALSE},
5916             {"",S_FALSE}
5917         },
5918         {
5919             {Uri_HOST_DNS,S_OK},
5920             {80,S_OK},
5921             {URL_SCHEME_HTTP,S_OK},
5922             {URLZONE_INVALID,E_NOTIMPL}
5923         }
5924     },
5925     {   "http://winehq.org/test?query",0,
5926         "testing",Uri_CREATE_ALLOW_RELATIVE,
5927         0,S_OK,FALSE,
5928         {
5929             {"http://winehq.org/testing",S_OK},
5930             {"winehq.org",S_OK},
5931             {"http://winehq.org/testing",S_OK},
5932             {"winehq.org",S_OK},
5933             {"",S_FALSE},
5934             {"",S_FALSE},
5935             {"winehq.org",S_OK},
5936             {"",S_FALSE},
5937             {"/testing",S_OK},
5938             {"/testing",S_OK},
5939             {"",S_FALSE},
5940             {"http://winehq.org/testing",S_OK},
5941             {"http",S_OK},
5942             {"",S_FALSE},
5943             {"",S_FALSE}
5944         },
5945         {
5946             {Uri_HOST_DNS,S_OK},
5947             {80,S_OK},
5948             {URL_SCHEME_HTTP,S_OK},
5949             {URLZONE_INVALID,E_NOTIMPL}
5950         }
5951     },
5952     {   "http://winehq.org/test#frag",0,
5953         "testing",Uri_CREATE_ALLOW_RELATIVE,
5954         0,S_OK,FALSE,
5955         {
5956             {"http://winehq.org/testing",S_OK},
5957             {"winehq.org",S_OK},
5958             {"http://winehq.org/testing",S_OK},
5959             {"winehq.org",S_OK},
5960             {"",S_FALSE},
5961             {"",S_FALSE},
5962             {"winehq.org",S_OK},
5963             {"",S_FALSE},
5964             {"/testing",S_OK},
5965             {"/testing",S_OK},
5966             {"",S_FALSE},
5967             {"http://winehq.org/testing",S_OK},
5968             {"http",S_OK},
5969             {"",S_FALSE},
5970             {"",S_FALSE}
5971         },
5972         {
5973             {Uri_HOST_DNS,S_OK},
5974             {80,S_OK},
5975             {URL_SCHEME_HTTP,S_OK},
5976             {URLZONE_INVALID,E_NOTIMPL}
5977         }
5978     },
5979     {   "testing?query#frag",Uri_CREATE_ALLOW_RELATIVE,
5980         "test",Uri_CREATE_ALLOW_RELATIVE,
5981         0,S_OK,FALSE,
5982         {
5983             {"test",S_OK},
5984             {"",S_FALSE},
5985             {"test",S_OK},
5986             {"",S_FALSE},
5987             {"",S_FALSE},
5988             {"",S_FALSE},
5989             {"",S_FALSE},
5990             {"",S_FALSE},
5991             {"test",S_OK},
5992             {"test",S_OK},
5993             {"",S_FALSE},
5994             {"test",S_OK},
5995             {"",S_FALSE},
5996             {"",S_FALSE},
5997             {"",S_FALSE}
5998         },
5999         {
6000             {Uri_HOST_UNKNOWN,S_OK},
6001             {0,S_FALSE},
6002             {URL_SCHEME_UNKNOWN,S_OK},
6003             {URLZONE_INVALID,E_NOTIMPL}
6004         }
6005     },
6006     {   "file:///c:/test/test",0,
6007         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
6008         URL_FILE_USE_PATHURL,S_OK,FALSE,
6009         {
6010             {"file://c:\\testing.mp3",S_OK},
6011             {"",S_FALSE},
6012             {"file://c:\\testing.mp3",S_OK},
6013             {"",S_FALSE},
6014             {".mp3",S_OK},
6015             {"",S_FALSE},
6016             {"",S_FALSE},
6017             {"",S_FALSE},
6018             {"c:\\testing.mp3",S_OK},
6019             {"c:\\testing.mp3",S_OK},
6020             {"",S_FALSE},
6021             {"file://c:\\testing.mp3",S_OK},
6022             {"file",S_OK},
6023             {"",S_FALSE},
6024             {"",S_FALSE}
6025         },
6026         {
6027             {Uri_HOST_UNKNOWN,S_OK},
6028             {0,S_FALSE},
6029             {URL_SCHEME_FILE,S_OK},
6030             {URLZONE_INVALID,E_NOTIMPL}
6031         }
6032     },
6033     {   "file:///c:/test/test",0,
6034         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
6035         0,S_OK,FALSE,
6036         {
6037             {"file:///c:/testing.mp3",S_OK},
6038             {"",S_FALSE},
6039             {"file:///c:/testing.mp3",S_OK},
6040             {"",S_FALSE},
6041             {".mp3",S_OK},
6042             {"",S_FALSE},
6043             {"",S_FALSE},
6044             {"",S_FALSE},
6045             {"/c:/testing.mp3",S_OK},
6046             {"/c:/testing.mp3",S_OK},
6047             {"",S_FALSE},
6048             {"file:///c:/testing.mp3",S_OK},
6049             {"file",S_OK},
6050             {"",S_FALSE},
6051             {"",S_FALSE}
6052         },
6053         {
6054             {Uri_HOST_UNKNOWN,S_OK},
6055             {0,S_FALSE},
6056             {URL_SCHEME_FILE,S_OK},
6057             {URLZONE_INVALID,E_NOTIMPL}
6058         }
6059     },
6060     {   "file://test.com/test/test",0,
6061         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
6062         URL_FILE_USE_PATHURL,S_OK,FALSE,
6063         {
6064             {"file://\\\\test.com\\testing.mp3",S_OK},
6065             {"test.com",S_OK},
6066             {"file://\\\\test.com\\testing.mp3",S_OK},
6067             {"test.com",S_OK},
6068             {".mp3",S_OK},
6069             {"",S_FALSE},
6070             {"test.com",S_OK},
6071             {"",S_FALSE},
6072             {"\\testing.mp3",S_OK},
6073             {"\\testing.mp3",S_OK},
6074             {"",S_FALSE},
6075             {"file://\\\\test.com\\testing.mp3",S_OK},
6076             {"file",S_OK},
6077             {"",S_FALSE},
6078             {"",S_FALSE}
6079         },
6080         {
6081             {Uri_HOST_DNS,S_OK},
6082             {0,S_FALSE},
6083             {URL_SCHEME_FILE,S_OK},
6084             {URLZONE_INVALID,E_NOTIMPL}
6085         }
6086     },
6087     /* URL_DONT_SIMPLIFY has no effect. */
6088     {   "http://google.com/test",0,
6089         "zip://test.com/cool/../cool/test",0,
6090         URL_DONT_SIMPLIFY,S_OK,FALSE,
6091         {
6092             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
6093             {"test.com",S_OK},
6094             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
6095             {"test.com",S_OK},
6096             {"",S_FALSE},
6097             {"",S_FALSE},
6098             {"test.com",S_OK},
6099             {"",S_FALSE},
6100             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
6101             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
6102             {"",S_FALSE},
6103             /* The resulting IUri has the same Raw URI as the relative URI (only IE 8).
6104              * On IE 7 it reduces the path in the Raw URI.
6105              */
6106             {"zip://test.com/cool/../cool/test",S_OK,FALSE,"zip://test.com/cool/test"},
6107             {"zip",S_OK},
6108             {"",S_FALSE},
6109             {"",S_FALSE}
6110         },
6111         {
6112             {Uri_HOST_DNS,S_OK},
6113             {0,S_FALSE},
6114             {URL_SCHEME_UNKNOWN,S_OK},
6115             {URLZONE_INVALID,E_NOTIMPL}
6116         }
6117     },
6118     /* FILE_USE_PATHURL has no effect in IE 8, in IE 7 the
6119      * resulting URI is converted into a dos path.
6120      */
6121     {   "http://google.com/test",0,
6122         "file:///c:/test/",0,
6123         URL_FILE_USE_PATHURL,S_OK,FALSE,
6124         {
6125             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
6126             {"",S_FALSE},
6127             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
6128             {"",S_FALSE},
6129             {"",S_FALSE},
6130             {"",S_FALSE},
6131             {"",S_FALSE},
6132             {"",S_FALSE},
6133             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
6134             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
6135             {"",S_FALSE},
6136             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
6137             {"file",S_OK},
6138             {"",S_FALSE},
6139             {"",S_FALSE}
6140         },
6141         {
6142             {Uri_HOST_UNKNOWN,S_OK},
6143             {0,S_FALSE},
6144             {URL_SCHEME_FILE,S_OK},
6145             {URLZONE_INVALID,E_NOTIMPL}
6146         }
6147     },
6148     {   "http://google.com/test",0,
6149         "http://test.com/test#%30test",0,
6150         URL_DONT_UNESCAPE_EXTRA_INFO,S_OK,FALSE,
6151         {
6152             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
6153             {"test.com",S_OK},
6154             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
6155             {"test.com",S_OK},
6156             {"",S_FALSE},
6157             {"#0test",S_OK,FALSE,NULL,"#%30test"},
6158             {"test.com",S_OK},
6159             {"",S_FALSE},
6160             {"/test",S_OK},
6161             {"/test",S_OK},
6162             {"",S_FALSE},
6163             /* IE 7 decodes the %30 to a 0 in the Raw URI. */
6164             {"http://test.com/test#%30test",S_OK,FALSE,"http://test.com/test#0test"},
6165             {"http",S_OK},
6166             {"",S_FALSE},
6167             {"",S_FALSE}
6168         },
6169         {
6170             {Uri_HOST_DNS,S_OK},
6171             {80,S_OK},
6172             {URL_SCHEME_HTTP,S_OK},
6173             {URLZONE_INVALID,E_NOTIMPL}
6174         }
6175     },
6176     /* Windows validates the path component from the relative Uri. */
6177     {   "http://google.com/test",0,
6178         "/Te%XXst",Uri_CREATE_ALLOW_RELATIVE,
6179         0,E_INVALIDARG,FALSE
6180     },
6181     /* Windows doesn't validate the query from the relative Uri. */
6182     {   "http://google.com/test",0,
6183         "?Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
6184         0,S_OK,FALSE,
6185         {
6186             {"http://google.com/test?Tes%XXt",S_OK},
6187             {"google.com",S_OK},
6188             {"http://google.com/test?Tes%XXt",S_OK},
6189             {"google.com",S_OK},
6190             {"",S_FALSE},
6191             {"",S_FALSE},
6192             {"google.com",S_OK},
6193             {"",S_FALSE},
6194             {"/test",S_OK},
6195             {"/test?Tes%XXt",S_OK},
6196             {"?Tes%XXt",S_OK},
6197             {"http://google.com/test?Tes%XXt",S_OK},
6198             {"http",S_OK},
6199             {"",S_FALSE},
6200             {"",S_FALSE}
6201         },
6202         {
6203             {Uri_HOST_DNS,S_OK},
6204             {80,S_OK},
6205             {URL_SCHEME_HTTP,S_OK},
6206             {URLZONE_INVALID,E_NOTIMPL}
6207         }
6208     },
6209     /* Windows doesn't validate the fragment from the relative Uri. */
6210     {   "http://google.com/test",0,
6211         "#Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
6212         0,S_OK,FALSE,
6213         {
6214             {"http://google.com/test#Tes%XXt",S_OK},
6215             {"google.com",S_OK},
6216             {"http://google.com/test#Tes%XXt",S_OK},
6217             {"google.com",S_OK},
6218             {"",S_FALSE},
6219             {"#Tes%XXt",S_OK},
6220             {"google.com",S_OK},
6221             {"",S_FALSE},
6222             {"/test",S_OK},
6223             {"/test",S_OK},
6224             {"",S_FALSE},
6225             {"http://google.com/test#Tes%XXt",S_OK},
6226             {"http",S_OK},
6227             {"",S_FALSE},
6228             {"",S_FALSE}
6229         },
6230         {
6231             {Uri_HOST_DNS,S_OK},
6232             {80,S_OK},
6233             {URL_SCHEME_HTTP,S_OK},
6234             {URLZONE_INVALID,E_NOTIMPL}
6235         }
6236     },
6237     /* Creates an IUri which contains an invalid dos path char. */
6238     {   "file:///c:/test",0,
6239         "/test<ing",Uri_CREATE_ALLOW_RELATIVE,
6240         URL_FILE_USE_PATHURL,S_OK,FALSE,
6241         {
6242             {"file://c:\\test<ing",S_OK},
6243             {"",S_FALSE},
6244             {"file://c:\\test<ing",S_OK},
6245             {"",S_FALSE},
6246             {"",S_FALSE},
6247             {"",S_FALSE},
6248             {"",S_FALSE},
6249             {"",S_FALSE},
6250             {"c:\\test<ing",S_OK},
6251             {"c:\\test<ing",S_OK},
6252             {"",S_FALSE},
6253             {"file://c:\\test<ing",S_OK},
6254             {"file",S_OK},
6255             {"",S_FALSE},
6256             {"",S_FALSE}
6257         },
6258         {
6259             {Uri_HOST_UNKNOWN,S_OK},
6260             {0,S_FALSE},
6261             {URL_SCHEME_FILE,S_OK},
6262             {URLZONE_INVALID,E_NOTIMPL}
6263         }
6264     },
6265     /* Appends the path after the drive letter (if any). */
6266     {   "file:///c:/test",0,
6267         "/c:/testing",Uri_CREATE_ALLOW_RELATIVE,
6268         0,S_OK,FALSE,
6269         {
6270             {"file:///c:/c:/testing",S_OK},
6271             {"",S_FALSE},
6272             {"file:///c:/c:/testing",S_OK},
6273             {"",S_FALSE},
6274             {"",S_FALSE},
6275             {"",S_FALSE},
6276             {"",S_FALSE},
6277             {"",S_FALSE},
6278             {"/c:/c:/testing",S_OK},
6279             {"/c:/c:/testing",S_OK},
6280             {"",S_FALSE},
6281             {"file:///c:/c:/testing",S_OK},
6282             {"file",S_OK},
6283             {"",S_FALSE},
6284             {"",S_FALSE}
6285         },
6286         {
6287             {Uri_HOST_UNKNOWN,S_OK},
6288             {0,S_FALSE},
6289             {URL_SCHEME_FILE,S_OK},
6290             {URLZONE_INVALID,E_NOTIMPL}
6291         }
6292     },
6293     /* A '/' is added if the base URI doesn't have a path and the
6294      * relative URI doesn't contain a path (since the base URI is
6295      * hierarchical.
6296      */
6297     {   "http://google.com",Uri_CREATE_NO_CANONICALIZE,
6298         "?test",Uri_CREATE_ALLOW_RELATIVE,
6299         0,S_OK,FALSE,
6300         {
6301             {"http://google.com/?test",S_OK},
6302             {"google.com",S_OK},
6303             {"http://google.com/?test",S_OK},
6304             {"google.com",S_OK},
6305             {"",S_FALSE},
6306             {"",S_FALSE},
6307             {"google.com",S_OK},
6308             {"",S_FALSE},
6309             {"/",S_OK},
6310             {"/?test",S_OK},
6311             {"?test",S_OK},
6312             {"http://google.com/?test",S_OK},
6313             {"http",S_OK},
6314             {"",S_FALSE},
6315             {"",S_FALSE}
6316         },
6317         {
6318             {Uri_HOST_DNS,S_OK},
6319             {80,S_OK},
6320             {URL_SCHEME_HTTP,S_OK},
6321             {URLZONE_INVALID,E_NOTIMPL}
6322         }
6323     },
6324     {   "zip://google.com",Uri_CREATE_NO_CANONICALIZE,
6325         "?test",Uri_CREATE_ALLOW_RELATIVE,
6326         0,S_OK,FALSE,
6327         {
6328             {"zip://google.com/?test",S_OK},
6329             {"google.com",S_OK},
6330             {"zip://google.com/?test",S_OK},
6331             {"google.com",S_OK},
6332             {"",S_FALSE},
6333             {"",S_FALSE},
6334             {"google.com",S_OK},
6335             {"",S_FALSE},
6336             {"/",S_OK},
6337             {"/?test",S_OK},
6338             {"?test",S_OK},
6339             {"zip://google.com/?test",S_OK},
6340             {"zip",S_OK},
6341             {"",S_FALSE},
6342             {"",S_FALSE}
6343         },
6344         {
6345             {Uri_HOST_DNS,S_OK},
6346             {0,S_FALSE},
6347             {URL_SCHEME_UNKNOWN,S_OK},
6348             {URLZONE_INVALID,E_NOTIMPL}
6349         }
6350     },
6351     /* No path is appended since the base URI is opaque. */
6352     {   "zip:?testing",0,
6353         "?test",Uri_CREATE_ALLOW_RELATIVE,
6354         0,S_OK,FALSE,
6355         {
6356             {"zip:?test",S_OK},
6357             {"",S_FALSE},
6358             {"zip:?test",S_OK},
6359             {"",S_FALSE},
6360             {"",S_FALSE},
6361             {"",S_FALSE},
6362             {"",S_FALSE},
6363             {"",S_FALSE},
6364             {"",S_OK},
6365             {"?test",S_OK},
6366             {"?test",S_OK},
6367             {"zip:?test",S_OK},
6368             {"zip",S_OK},
6369             {"",S_FALSE},
6370             {"",S_FALSE}
6371         },
6372         {
6373             {Uri_HOST_UNKNOWN,S_OK},
6374             {0,S_FALSE},
6375             {URL_SCHEME_UNKNOWN,S_OK},
6376             {URLZONE_INVALID,E_NOTIMPL}
6377         }
6378     },
6379     {   "file:///c:/",0,
6380         "../testing/test",Uri_CREATE_ALLOW_RELATIVE,
6381         0,S_OK,FALSE,
6382         {
6383             {"file:///c:/testing/test",S_OK},
6384             {"",S_FALSE},
6385             {"file:///c:/testing/test",S_OK},
6386             {"",S_FALSE},
6387             {"",S_FALSE},
6388             {"",S_FALSE},
6389             {"",S_FALSE},
6390             {"",S_FALSE},
6391             {"/c:/testing/test",S_OK},
6392             {"/c:/testing/test",S_OK},
6393             {"",S_FALSE},
6394             {"file:///c:/testing/test",S_OK},
6395             {"file",S_OK},
6396             {"",S_FALSE},
6397             {"",S_FALSE}
6398         },
6399         {
6400             {Uri_HOST_UNKNOWN,S_OK},
6401             {0,S_FALSE},
6402             {URL_SCHEME_FILE,S_OK},
6403             {URLZONE_INVALID,E_NOTIMPL}
6404         }
6405     },
6406     {   "http://winehq.org/dir/testfile",0,
6407         "test?querystring",Uri_CREATE_ALLOW_RELATIVE,
6408         0,S_OK,FALSE,
6409         {
6410             {"http://winehq.org/dir/test?querystring",S_OK},
6411             {"winehq.org",S_OK},
6412             {"http://winehq.org/dir/test?querystring",S_OK},
6413             {"winehq.org",S_OK},
6414             {"",S_FALSE},
6415             {"",S_FALSE},
6416             {"winehq.org",S_OK},
6417             {"",S_FALSE},
6418             {"/dir/test",S_OK},
6419             {"/dir/test?querystring",S_OK},
6420             {"?querystring",S_OK},
6421             {"http://winehq.org/dir/test?querystring",S_OK},
6422             {"http",S_OK},
6423             {"",S_FALSE},
6424             {"",S_FALSE}
6425         },
6426         {
6427             {Uri_HOST_DNS,S_OK},
6428             {80,S_OK},
6429             {URL_SCHEME_HTTP,S_OK},
6430             {URLZONE_INVALID,E_NOTIMPL}
6431         }
6432     },
6433     {   "http://winehq.org/dir/test",0,
6434         "test?querystring",Uri_CREATE_ALLOW_RELATIVE,
6435         0,S_OK,FALSE,
6436         {
6437             {"http://winehq.org/dir/test?querystring",S_OK},
6438             {"winehq.org",S_OK},
6439             {"http://winehq.org/dir/test?querystring",S_OK},
6440             {"winehq.org",S_OK},
6441             {"",S_FALSE},
6442             {"",S_FALSE},
6443             {"winehq.org",S_OK},
6444             {"",S_FALSE},
6445             {"/dir/test",S_OK},
6446             {"/dir/test?querystring",S_OK},
6447             {"?querystring",S_OK},
6448             {"http://winehq.org/dir/test?querystring",S_OK},
6449             {"http",S_OK},
6450             {"",S_FALSE},
6451             {"",S_FALSE}
6452         },
6453         {
6454             {Uri_HOST_DNS,S_OK},
6455             {80,S_OK},
6456             {URL_SCHEME_HTTP,S_OK},
6457             {URLZONE_INVALID,E_NOTIMPL}
6458         }
6459     },
6460     {   "http://winehq.org/dir/test?querystring",0,
6461         "#hash",Uri_CREATE_ALLOW_RELATIVE,
6462         0,S_OK,FALSE,
6463         {
6464             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6465             {"winehq.org",S_OK},
6466             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6467             {"winehq.org",S_OK},
6468             {"",S_FALSE},
6469             {"#hash",S_OK},
6470             {"winehq.org",S_OK},
6471             {"",S_FALSE},
6472             {"/dir/test",S_OK},
6473             {"/dir/test?querystring",S_OK},
6474             {"?querystring",S_OK},
6475             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6476             {"http",S_OK},
6477             {"",S_FALSE},
6478             {"",S_FALSE}
6479         },
6480         {
6481             {Uri_HOST_DNS,S_OK},
6482             {80,S_OK},
6483             {URL_SCHEME_HTTP,S_OK},
6484             {URLZONE_INVALID,E_NOTIMPL}
6485         }
6486     },
6487     {   "mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir\\file.txt",0,
6488         "relative/path.txt",Uri_CREATE_ALLOW_RELATIVE,
6489         0,S_OK,FALSE,
6490         {
6491             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6492             {"",S_FALSE},
6493             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6494             {"",S_FALSE},
6495             {".txt",S_OK},
6496             {"",S_FALSE},
6497             {"",S_FALSE},
6498             {"",S_FALSE},
6499             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6500             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6501             {"",S_FALSE},
6502             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6503             {"mk",S_OK},
6504             {"",S_FALSE},
6505             {"",S_FALSE}
6506         },
6507         {
6508             {Uri_HOST_UNKNOWN,S_OK},
6509             {0,S_FALSE},
6510             {URL_SCHEME_MK,S_OK},
6511             {URLZONE_INVALID,E_NOTIMPL}
6512         }
6513     },
6514     {   "mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::\\subdir\\file.txt",0,
6515         "relative/path.txt",Uri_CREATE_ALLOW_RELATIVE,
6516         0,S_OK,FALSE,
6517         {
6518             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6519             {"",S_FALSE},
6520             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6521             {"",S_FALSE},
6522             {".txt",S_OK},
6523             {"",S_FALSE},
6524             {"",S_FALSE},
6525             {"",S_FALSE},
6526             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6527             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6528             {"",S_FALSE},
6529             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6530             {"mk",S_OK},
6531             {"",S_FALSE},
6532             {"",S_FALSE}
6533         },
6534         {
6535             {Uri_HOST_UNKNOWN,S_OK},
6536             {0,S_FALSE},
6537             {URL_SCHEME_MK,S_OK},
6538             {URLZONE_INVALID,E_NOTIMPL}
6539         }
6540     },
6541     {   "mk:@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir\\file.txt",0,
6542         "relative\\path.txt",Uri_CREATE_ALLOW_RELATIVE,
6543         0,S_OK,FALSE,
6544         {
6545             {"mk:@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6546             {"",S_FALSE},
6547             {"mk:@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6548             {"",S_FALSE},
6549             {".txt",S_OK},
6550             {"",S_FALSE},
6551             {"",S_FALSE},
6552             {"",S_FALSE},
6553             {"@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6554             {"@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6555             {"",S_FALSE},
6556             {"mk:@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6557             {"mk",S_OK},
6558             {"",S_FALSE},
6559             {"",S_FALSE}
6560         },
6561         {
6562             {Uri_HOST_UNKNOWN,S_OK},
6563             {0,S_FALSE},
6564             {URL_SCHEME_MK,S_OK},
6565             {URLZONE_INVALID,E_NOTIMPL}
6566         }
6567     }
6568 };
6569
6570 typedef struct _uri_parse_test {
6571     const char  *uri;
6572     DWORD       uri_flags;
6573     PARSEACTION action;
6574     DWORD       flags;
6575     const char  *property;
6576     HRESULT     expected;
6577     BOOL        todo;
6578 } uri_parse_test;
6579
6580 static const uri_parse_test uri_parse_tests[] = {
6581     /* PARSE_CANONICALIZE tests. */
6582     {"zip://google.com/test<|>",0,PARSE_CANONICALIZE,0,"zip://google.com/test<|>",S_OK,FALSE},
6583     {"http://google.com/test<|>",0,PARSE_CANONICALIZE,0,"http://google.com/test%3C%7C%3E",S_OK,FALSE},
6584     {"http://google.com/%30%23%3F",0,PARSE_CANONICALIZE,URL_UNESCAPE,"http://google.com/0#?",S_OK,FALSE},
6585     {"test <|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_ESCAPE_UNSAFE,"test %3C%7C%3E",S_OK,FALSE},
6586     {"test <|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_ESCAPE_SPACES_ONLY,"test%20<|>",S_OK,FALSE},
6587     {"test%20<|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_UNESCAPE|URL_ESCAPE_UNSAFE,"test%20%3C%7C%3E",S_OK,FALSE},
6588     {"http://google.com/%20",0,PARSE_CANONICALIZE,URL_ESCAPE_PERCENT,"http://google.com/%2520",S_OK,FALSE},
6589     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_DONT_SIMPLIFY,"http://google.com/test/../",S_OK,FALSE},
6590     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_NO_META,"http://google.com/test/../",S_OK,FALSE},
6591     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,0,"http://google.com/",S_OK,FALSE},
6592     {"zip://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,0,"zip://google.com/",S_OK,FALSE},
6593     {"file:///c:/test/../test",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_DONT_SIMPLIFY,"file:///c:/test/../test",S_OK,FALSE},
6594
6595     /* PARSE_FRIENDLY tests. */
6596     {"http://test@google.com/test#test",0,PARSE_FRIENDLY,0,"http://google.com/test#test",S_OK,FALSE},
6597     {"zip://test@google.com/test",0,PARSE_FRIENDLY,0,"zip://test@google.com/test",S_OK,FALSE},
6598
6599     /* PARSE_ROOTDOCUMENT tests. */
6600     {"http://google.com:200/test/test",0,PARSE_ROOTDOCUMENT,0,"http://google.com:200/",S_OK,FALSE},
6601     {"http://google.com",Uri_CREATE_NO_CANONICALIZE,PARSE_ROOTDOCUMENT,0,"http://google.com/",S_OK,FALSE},
6602     {"zip://google.com/",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6603     {"file:///c:/testing/",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6604     {"file://server/test",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6605     {"zip:test/test",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6606
6607     /* PARSE_DOCUMENT tests. */
6608     {"http://test@google.com/test?query#frag",0,PARSE_DOCUMENT,0,"http://test@google.com/test?query",S_OK,FALSE},
6609     {"http:testing#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6610     {"file:///c:/test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6611     {"zip://google.com/#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6612     {"zip:test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6613     {"testing#frag",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6614
6615     /* PARSE_PATH_FROM_URL tests. */
6616     {"file:///c:/test.mp3",0,PARSE_PATH_FROM_URL,0,"c:\\test.mp3",S_OK,FALSE},
6617     {"file:///c:/t<|>est.mp3",0,PARSE_PATH_FROM_URL,0,"c:\\t<|>est.mp3",S_OK,FALSE},
6618     {"file:///c:/te%XX t/",0,PARSE_PATH_FROM_URL,0,"c:\\te%XX t\\",S_OK,FALSE},
6619     {"file://server/test",0,PARSE_PATH_FROM_URL,0,"\\\\server\\test",S_OK,FALSE},
6620     {"http://google.com/",0,PARSE_PATH_FROM_URL,0,"",E_INVALIDARG,FALSE},
6621
6622     /* PARSE_URL_FROM_PATH tests. */
6623     /* This function almost seems to useless (just returns the absolute uri). */
6624     {"test.com",Uri_CREATE_ALLOW_RELATIVE,PARSE_URL_FROM_PATH,0,"test.com",S_OK,FALSE},
6625     {"/test/test",Uri_CREATE_ALLOW_RELATIVE,PARSE_URL_FROM_PATH,0,"/test/test",S_OK,FALSE},
6626     {"file://c:\\test\\test",Uri_CREATE_FILE_USE_DOS_PATH,PARSE_URL_FROM_PATH,0,"file://c:\\test\\test",S_OK,FALSE},
6627     {"file:c:/test",0,PARSE_URL_FROM_PATH,0,"",S_OK,FALSE},
6628     {"http:google.com/",0,PARSE_URL_FROM_PATH,0,"",S_OK,FALSE},
6629
6630     /* PARSE_SCHEMA tests. */
6631     {"http://google.com/test",0,PARSE_SCHEMA,0,"http",S_OK,FALSE},
6632     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_SCHEMA,0,"",S_OK,FALSE},
6633
6634     /* PARSE_SITE tests. */
6635     {"http://google.uk.com/",0,PARSE_SITE,0,"google.uk.com",S_OK,FALSE},
6636     {"http://google.com.com/",0,PARSE_SITE,0,"google.com.com",S_OK,FALSE},
6637     {"google.com",Uri_CREATE_ALLOW_RELATIVE,PARSE_SITE,0,"",S_OK,FALSE},
6638     {"file://server/test",0,PARSE_SITE,0,"server",S_OK,FALSE},
6639
6640     /* PARSE_DOMAIN tests. */
6641     {"http://google.com.uk/",0,PARSE_DOMAIN,0,"google.com.uk",S_OK,FALSE},
6642     {"http://google.com.com/",0,PARSE_DOMAIN,0,"com.com",S_OK,FALSE},
6643     {"test/test",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOMAIN,0,"",S_OK,FALSE},
6644     {"file://server/test",0,PARSE_DOMAIN,0,"",S_OK,FALSE},
6645
6646     /* PARSE_LOCATION and PARSE_ANCHOR tests. */
6647     {"http://google.com/test#Test",0,PARSE_ANCHOR,0,"#Test",S_OK,FALSE},
6648     {"http://google.com/test#Test",0,PARSE_LOCATION,0,"#Test",S_OK,FALSE},
6649     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_ANCHOR,0,"",S_OK,FALSE},
6650     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_LOCATION,0,"",S_OK,FALSE}
6651 };
6652
6653 static inline LPWSTR a2w(LPCSTR str) {
6654     LPWSTR ret = NULL;
6655
6656     if(str) {
6657         DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
6658         ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
6659         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
6660     }
6661
6662     return ret;
6663 }
6664
6665 static inline BOOL heap_free(void* mem) {
6666     return HeapFree(GetProcessHeap(), 0, mem);
6667 }
6668
6669 static inline DWORD strcmp_aw(LPCSTR strA, LPCWSTR strB) {
6670     LPWSTR strAW = a2w(strA);
6671     DWORD ret = lstrcmpW(strAW, strB);
6672     heap_free(strAW);
6673     return ret;
6674 }
6675
6676 static inline ULONG get_refcnt(IUri *uri) {
6677     IUri_AddRef(uri);
6678     return IUri_Release(uri);
6679 }
6680
6681 static void change_property(IUriBuilder *builder, const uri_builder_property *prop,
6682                             DWORD test_index) {
6683     HRESULT hr;
6684     LPWSTR valueW;
6685
6686     valueW = a2w(prop->value);
6687     switch(prop->property) {
6688     case Uri_PROPERTY_FRAGMENT:
6689         hr = IUriBuilder_SetFragment(builder, valueW);
6690         if(prop->todo) {
6691             todo_wine {
6692                 ok(hr == prop->expected,
6693                     "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6694                     hr, prop->expected, test_index);
6695             }
6696         } else {
6697             ok(hr == prop->expected,
6698                 "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6699                 hr, prop->expected, test_index);
6700         }
6701         break;
6702     case Uri_PROPERTY_HOST:
6703         hr = IUriBuilder_SetHost(builder, valueW);
6704         if(prop->todo) {
6705             todo_wine {
6706                 ok(hr == prop->expected,
6707                     "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6708                     hr, prop->expected, test_index);
6709             }
6710         } else {
6711             ok(hr == prop->expected,
6712                 "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6713                 hr, prop->expected, test_index);
6714         }
6715         break;
6716     case Uri_PROPERTY_PASSWORD:
6717         hr = IUriBuilder_SetPassword(builder, valueW);
6718         if(prop->todo) {
6719             todo_wine {
6720                 ok(hr == prop->expected,
6721                     "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6722                     hr, prop->expected, test_index);
6723             }
6724         } else {
6725             ok(hr == prop->expected,
6726                 "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6727                 hr, prop->expected, test_index);
6728         }
6729         break;
6730     case Uri_PROPERTY_PATH:
6731         hr = IUriBuilder_SetPath(builder, valueW);
6732         if(prop->todo) {
6733             todo_wine {
6734                 ok(hr == prop->expected,
6735                     "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6736                     hr, prop->expected, test_index);
6737             }
6738         } else {
6739             ok(hr == prop->expected,
6740                 "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6741                 hr, prop->expected, test_index);
6742         }
6743         break;
6744     case Uri_PROPERTY_QUERY:
6745         hr = IUriBuilder_SetQuery(builder, valueW);
6746         if(prop->todo) {
6747             todo_wine {
6748                 ok(hr == prop->expected,
6749                     "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6750                     hr, prop->expected, test_index);
6751             }
6752         } else {
6753             ok(hr == prop->expected,
6754                 "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6755                 hr, prop->expected, test_index);
6756         }
6757         break;
6758     case Uri_PROPERTY_SCHEME_NAME:
6759         hr = IUriBuilder_SetSchemeName(builder, valueW);
6760         if(prop->todo) {
6761             todo_wine {
6762                 ok(hr == prop->expected,
6763                     "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6764                     hr, prop->expected, test_index);
6765             }
6766         } else {
6767             ok(hr == prop->expected,
6768                 "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6769                 hr, prop->expected, test_index);
6770         }
6771         break;
6772     case Uri_PROPERTY_USER_NAME:
6773         hr = IUriBuilder_SetUserName(builder, valueW);
6774         if(prop->todo) {
6775             todo_wine {
6776                 ok(hr == prop->expected,
6777                     "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6778                     hr, prop->expected, test_index);
6779             }
6780         } else {
6781             ok(hr == prop->expected,
6782                 "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6783                 hr, prop->expected, test_index);
6784         }
6785         break;
6786     default:
6787         trace("Unsupported operation for %d on uri_builder_tests[%d].\n", prop->property, test_index);
6788     }
6789
6790     heap_free(valueW);
6791 }
6792
6793 /*
6794  * Simple tests to make sure the CreateUri function handles invalid flag combinations
6795  * correctly.
6796  */
6797 static void test_CreateUri_InvalidFlags(void) {
6798     DWORD i;
6799
6800     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
6801         HRESULT hr;
6802         IUri *uri = (void*) 0xdeadbeef;
6803
6804         hr = pCreateUri(http_urlW, invalid_flag_tests[i].flags, 0, &uri);
6805         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUri returned 0x%08x, expected 0x%08x, flags=0x%08x\n",
6806                 hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
6807         ok(uri == NULL, "Error: expected the IUri to be NULL, but it was %p instead\n", uri);
6808     }
6809 }
6810
6811 static void test_CreateUri_InvalidArgs(void) {
6812     HRESULT hr;
6813     IUri *uri = (void*) 0xdeadbeef;
6814
6815     const WCHAR invalidW[] = {'i','n','v','a','l','i','d',0};
6816     static const WCHAR emptyW[] = {0};
6817
6818     hr = pCreateUri(http_urlW, 0, 0, NULL);
6819     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6820
6821     hr = pCreateUri(NULL, 0, 0, &uri);
6822     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6823     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6824
6825     uri = (void*) 0xdeadbeef;
6826     hr = pCreateUri(invalidW, 0, 0, &uri);
6827     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6828     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6829
6830     uri = (void*) 0xdeadbeef;
6831     hr = pCreateUri(emptyW, 0, 0, &uri);
6832     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6833     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6834 }
6835
6836 static void test_CreateUri_InvalidUri(void) {
6837     DWORD i;
6838
6839     for(i = 0; i < sizeof(invalid_uri_tests)/sizeof(invalid_uri_tests[0]); ++i) {
6840         invalid_uri test = invalid_uri_tests[i];
6841         IUri *uri = NULL;
6842         LPWSTR uriW;
6843         HRESULT hr;
6844
6845         uriW = a2w(test.uri);
6846         hr = pCreateUri(uriW, test.flags, 0, &uri);
6847         if(test.todo) {
6848             todo_wine {
6849                 ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6850                     hr, E_INVALIDARG, i);
6851             }
6852         } else {
6853             ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6854                 hr, E_INVALIDARG, i);
6855         }
6856         if(uri) IUri_Release(uri);
6857
6858         heap_free(uriW);
6859     }
6860 }
6861
6862 static void test_IUri_GetPropertyBSTR(void) {
6863     IUri *uri = NULL;
6864     HRESULT hr;
6865     DWORD i;
6866
6867     /* Make sure GetPropertyBSTR handles invalid args correctly. */
6868     hr = pCreateUri(http_urlW, 0, 0, &uri);
6869     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6870     if(SUCCEEDED(hr)) {
6871         BSTR received = NULL;
6872
6873         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_RAW_URI, NULL, 0);
6874         ok(hr == E_POINTER, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6875
6876         /* Make sure it handles a invalid Uri_PROPERTY's correctly. */
6877         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_PORT, &received, 0);
6878         ok(hr == S_OK, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6879         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6880         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6881         SysFreeString(received);
6882
6883         /* Make sure it handles the ZONE property correctly. */
6884         received = NULL;
6885         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_ZONE, &received, 0);
6886         ok(hr == S_FALSE, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_FALSE);
6887         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6888         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6889         SysFreeString(received);
6890     }
6891     if(uri) IUri_Release(uri);
6892
6893     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6894         uri_properties test = uri_tests[i];
6895         LPWSTR uriW;
6896         uri = NULL;
6897
6898         uriW = a2w(test.uri);
6899         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6900         if(test.create_todo) {
6901             todo_wine {
6902                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6903                         hr, test.create_expected, i);
6904             }
6905         } else {
6906             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6907                     hr, test.create_expected, i);
6908         }
6909
6910         if(SUCCEEDED(hr)) {
6911             DWORD j;
6912
6913             /* Checks all the string properties of the uri. */
6914             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
6915                 BSTR received = NULL;
6916                 uri_str_property prop = test.str_props[j];
6917
6918                 hr = IUri_GetPropertyBSTR(uri, j, &received, 0);
6919                 if(prop.todo) {
6920                     todo_wine {
6921                         ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6922                                 hr, prop.expected, i, j);
6923                     }
6924                     todo_wine {
6925                         ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6926                                 "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6927                                 prop.value, wine_dbgstr_w(received), i, j);
6928                     }
6929                 } else {
6930                     ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6931                             hr, prop.expected, i, j);
6932                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6933                             "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6934                             prop.value, wine_dbgstr_w(received), i, j);
6935                 }
6936
6937                 SysFreeString(received);
6938             }
6939         }
6940
6941         if(uri) IUri_Release(uri);
6942
6943         heap_free(uriW);
6944     }
6945 }
6946
6947 static void test_IUri_GetPropertyDWORD(void) {
6948     IUri *uri = NULL;
6949     HRESULT hr;
6950     DWORD i;
6951
6952     hr = pCreateUri(http_urlW, 0, 0, &uri);
6953     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6954     if(SUCCEEDED(hr)) {
6955         DWORD received = 0xdeadbeef;
6956
6957         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_DWORD_START, NULL, 0);
6958         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6959
6960         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_ABSOLUTE_URI, &received, 0);
6961         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6962         ok(received == 0, "Error: Expected received=%d but instead received=%d.\n", 0, received);
6963     }
6964     if(uri) IUri_Release(uri);
6965
6966     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6967         uri_properties test = uri_tests[i];
6968         LPWSTR uriW;
6969         uri = NULL;
6970
6971         uriW = a2w(test.uri);
6972         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6973         if(test.create_todo) {
6974             todo_wine {
6975                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6976                         hr, test.create_expected, i);
6977             }
6978         } else {
6979             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6980                     hr, test.create_expected, i);
6981         }
6982
6983         if(SUCCEEDED(hr)) {
6984             DWORD j;
6985
6986             /* Checks all the DWORD properties of the uri. */
6987             for(j = 0; j < sizeof(test.dword_props)/sizeof(test.dword_props[0]); ++j) {
6988                 DWORD received;
6989                 uri_dword_property prop = test.dword_props[j];
6990
6991                 hr = IUri_GetPropertyDWORD(uri, j+Uri_PROPERTY_DWORD_START, &received, 0);
6992                 if(prop.todo) {
6993                     todo_wine {
6994                         ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
6995                                 hr, prop.expected, i, j);
6996                     }
6997                     todo_wine {
6998                         ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
6999                                 prop.value, received, i, j);
7000                     }
7001                 } else {
7002                     ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
7003                             hr, prop.expected, i, j);
7004                     ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
7005                             prop.value, received, i, j);
7006                 }
7007             }
7008         }
7009
7010         if(uri) IUri_Release(uri);
7011
7012         heap_free(uriW);
7013     }
7014 }
7015
7016 /* Tests all the 'Get*' property functions which deal with strings. */
7017 static void test_IUri_GetStrProperties(void) {
7018     IUri *uri = NULL;
7019     HRESULT hr;
7020     DWORD i;
7021
7022     /* Make sure all the 'Get*' string property functions handle invalid args correctly. */
7023     hr = pCreateUri(http_urlW, 0, 0, &uri);
7024     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7025     if(SUCCEEDED(hr)) {
7026         hr = IUri_GetAbsoluteUri(uri, NULL);
7027         ok(hr == E_POINTER, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7028
7029         hr = IUri_GetAuthority(uri, NULL);
7030         ok(hr == E_POINTER, "Error: GetAuthority returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7031
7032         hr = IUri_GetDisplayUri(uri, NULL);
7033         ok(hr == E_POINTER, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7034
7035         hr = IUri_GetDomain(uri, NULL);
7036         ok(hr == E_POINTER, "Error: GetDomain returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7037
7038         hr = IUri_GetExtension(uri, NULL);
7039         ok(hr == E_POINTER, "Error: GetExtension returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7040
7041         hr = IUri_GetFragment(uri, NULL);
7042         ok(hr == E_POINTER, "Error: GetFragment returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7043
7044         hr = IUri_GetHost(uri, NULL);
7045         ok(hr == E_POINTER, "Error: GetHost returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7046
7047         hr = IUri_GetPassword(uri, NULL);
7048         ok(hr == E_POINTER, "Error: GetPassword returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7049
7050         hr = IUri_GetPath(uri, NULL);
7051         ok(hr == E_POINTER, "Error: GetPath returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7052
7053         hr = IUri_GetPathAndQuery(uri, NULL);
7054         ok(hr == E_POINTER, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7055
7056         hr = IUri_GetQuery(uri, NULL);
7057         ok(hr == E_POINTER, "Error: GetQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7058
7059         hr = IUri_GetRawUri(uri, NULL);
7060         ok(hr == E_POINTER, "Error: GetRawUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7061
7062         hr = IUri_GetSchemeName(uri, NULL);
7063         ok(hr == E_POINTER, "Error: GetSchemeName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7064
7065         hr = IUri_GetUserInfo(uri, NULL);
7066         ok(hr == E_POINTER, "Error: GetUserInfo returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7067
7068         hr = IUri_GetUserName(uri, NULL);
7069         ok(hr == E_POINTER, "Error: GetUserName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7070     }
7071     if(uri) IUri_Release(uri);
7072
7073     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7074         uri_properties test = uri_tests[i];
7075         LPWSTR uriW;
7076         uri = NULL;
7077
7078         uriW = a2w(test.uri);
7079         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7080         if(test.create_todo) {
7081             todo_wine {
7082                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7083                         hr, test.create_expected, i);
7084             }
7085         } else {
7086             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7087                     hr, test.create_expected, i);
7088         }
7089
7090         if(SUCCEEDED(hr)) {
7091             uri_str_property prop;
7092             BSTR received = NULL;
7093
7094             /* GetAbsoluteUri() tests. */
7095             prop = test.str_props[Uri_PROPERTY_ABSOLUTE_URI];
7096             hr = IUri_GetAbsoluteUri(uri, &received);
7097             if(prop.todo) {
7098                 todo_wine {
7099                     ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7100                             hr, prop.expected, i);
7101                 }
7102                 todo_wine {
7103                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
7104                             "Error: Expected %s but got %s on uri_tests[%d].\n",
7105                             prop.value, wine_dbgstr_w(received), i);
7106                 }
7107             } else {
7108                 ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7109                         hr, prop.expected, i);
7110                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
7111                         "Error: Expected %s but got %s on uri_tests[%d].\n",
7112                         prop.value, wine_dbgstr_w(received), i);
7113             }
7114             SysFreeString(received);
7115             received = NULL;
7116
7117             /* GetAuthority() tests. */
7118             prop = test.str_props[Uri_PROPERTY_AUTHORITY];
7119             hr = IUri_GetAuthority(uri, &received);
7120             if(prop.todo) {
7121                 todo_wine {
7122                     ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7123                             hr, prop.expected, i);
7124                 }
7125                 todo_wine {
7126                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7127                             prop.value, wine_dbgstr_w(received), i);
7128                 }
7129             } else {
7130                 ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7131                         hr, prop.expected, i);
7132                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7133                         prop.value, wine_dbgstr_w(received), i);
7134             }
7135             SysFreeString(received);
7136             received = NULL;
7137
7138             /* GetDisplayUri() tests. */
7139             prop = test.str_props[Uri_PROPERTY_DISPLAY_URI];
7140             hr = IUri_GetDisplayUri(uri, &received);
7141             if(prop.todo) {
7142                 todo_wine {
7143                     ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7144                             hr, prop.expected, i);
7145                 }
7146                 todo_wine {
7147                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
7148                             "Error: Expected %s but got %s on uri_test[%d].\n",
7149                             prop.value, wine_dbgstr_w(received), i);
7150                 }
7151             } else {
7152                 ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7153                         hr, prop.expected, i);
7154                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
7155                         "Error: Expected %s but got %s on uri_tests[%d].\n",
7156                         prop.value, wine_dbgstr_w(received), i);
7157             }
7158             SysFreeString(received);
7159             received = NULL;
7160
7161             /* GetDomain() tests. */
7162             prop = test.str_props[Uri_PROPERTY_DOMAIN];
7163             hr = IUri_GetDomain(uri, &received);
7164             if(prop.todo) {
7165                 todo_wine {
7166                     ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7167                             hr, prop.expected, i);
7168                 }
7169                 todo_wine {
7170                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7171                             prop.value, wine_dbgstr_w(received), i);
7172                 }
7173             } else {
7174                 ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7175                         hr, prop.expected, i);
7176                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7177                         prop.value, wine_dbgstr_w(received), i);
7178             }
7179             SysFreeString(received);
7180             received = NULL;
7181
7182             /* GetExtension() tests. */
7183             prop = test.str_props[Uri_PROPERTY_EXTENSION];
7184             hr = IUri_GetExtension(uri, &received);
7185             if(prop.todo) {
7186                 todo_wine {
7187                     ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7188                             hr, prop.expected, i);
7189                 }
7190                 todo_wine {
7191                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7192                             prop.value, wine_dbgstr_w(received), i);
7193                 }
7194             } else {
7195                 ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7196                         hr, prop.expected, i);
7197                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7198                         prop.value, wine_dbgstr_w(received), i);
7199             }
7200             SysFreeString(received);
7201             received = NULL;
7202
7203             /* GetFragment() tests. */
7204             prop = test.str_props[Uri_PROPERTY_FRAGMENT];
7205             hr = IUri_GetFragment(uri, &received);
7206             if(prop.todo) {
7207                 todo_wine {
7208                     ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7209                             hr, prop.expected, i);
7210                 }
7211                 todo_wine {
7212                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7213                             prop.value, wine_dbgstr_w(received), i);
7214                 }
7215             } else {
7216                 ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7217                         hr, prop.expected, i);
7218                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7219                         prop.value, wine_dbgstr_w(received), i);
7220             }
7221             SysFreeString(received);
7222             received = NULL;
7223
7224             /* GetHost() tests. */
7225             prop = test.str_props[Uri_PROPERTY_HOST];
7226             hr = IUri_GetHost(uri, &received);
7227             if(prop.todo) {
7228                 todo_wine {
7229                     ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7230                             hr, prop.expected, i);
7231                 }
7232                 todo_wine {
7233                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7234                             prop.value, wine_dbgstr_w(received), i);
7235                 }
7236             } else {
7237                 ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7238                         hr, prop.expected, i);
7239                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7240                         prop.value, wine_dbgstr_w(received), i);
7241             }
7242             SysFreeString(received);
7243             received = NULL;
7244
7245             /* GetPassword() tests. */
7246             prop = test.str_props[Uri_PROPERTY_PASSWORD];
7247             hr = IUri_GetPassword(uri, &received);
7248             if(prop.todo) {
7249                 todo_wine {
7250                     ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7251                             hr, prop.expected, i);
7252                 }
7253                 todo_wine {
7254                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7255                             prop.value, wine_dbgstr_w(received), i);
7256                 }
7257             } else {
7258                 ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7259                         hr, prop.expected, i);
7260                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7261                         prop.value, wine_dbgstr_w(received), i);
7262             }
7263             SysFreeString(received);
7264             received = NULL;
7265
7266             /* GetPath() tests. */
7267             prop = test.str_props[Uri_PROPERTY_PATH];
7268             hr = IUri_GetPath(uri, &received);
7269             if(prop.todo) {
7270                 todo_wine {
7271                     ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7272                             hr, prop.expected, i);
7273                 }
7274                 todo_wine {
7275                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7276                             prop.value, wine_dbgstr_w(received), i);
7277                 }
7278             } else {
7279                 ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7280                         hr, prop.expected, i);
7281                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7282                         prop.value, wine_dbgstr_w(received), i);
7283             }
7284             SysFreeString(received);
7285             received = NULL;
7286
7287             /* GetPathAndQuery() tests. */
7288             prop = test.str_props[Uri_PROPERTY_PATH_AND_QUERY];
7289             hr = IUri_GetPathAndQuery(uri, &received);
7290             if(prop.todo) {
7291                 todo_wine {
7292                     ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7293                             hr, prop.expected, i);
7294                 }
7295                 todo_wine {
7296                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7297                             prop.value, wine_dbgstr_w(received), i);
7298                 }
7299             } else {
7300                 ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7301                         hr, prop.expected, i);
7302                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7303                         prop.value, wine_dbgstr_w(received), i);
7304             }
7305             SysFreeString(received);
7306             received = NULL;
7307
7308             /* GetQuery() tests. */
7309             prop = test.str_props[Uri_PROPERTY_QUERY];
7310             hr = IUri_GetQuery(uri, &received);
7311             if(prop.todo) {
7312                 todo_wine {
7313                     ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7314                             hr, prop.expected, i);
7315                 }
7316                 todo_wine {
7317                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7318                             prop.value, wine_dbgstr_w(received), i);
7319                 }
7320             } else {
7321                 ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7322                         hr, prop.expected, i);
7323                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7324                         prop.value, wine_dbgstr_w(received), i);
7325             }
7326             SysFreeString(received);
7327             received = NULL;
7328
7329             /* GetRawUri() tests. */
7330             prop = test.str_props[Uri_PROPERTY_RAW_URI];
7331             hr = IUri_GetRawUri(uri, &received);
7332             if(prop.todo) {
7333                 todo_wine {
7334                     ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7335                             hr, prop.expected, i);
7336                 }
7337                 todo_wine {
7338                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7339                             prop.value, wine_dbgstr_w(received), i);
7340                 }
7341             } else {
7342                 ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7343                         hr, prop.expected, i);
7344                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7345                         prop.value, wine_dbgstr_w(received), i);
7346             }
7347             SysFreeString(received);
7348             received = NULL;
7349
7350             /* GetSchemeName() tests. */
7351             prop = test.str_props[Uri_PROPERTY_SCHEME_NAME];
7352             hr = IUri_GetSchemeName(uri, &received);
7353             if(prop.todo) {
7354                 todo_wine {
7355                     ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7356                             hr, prop.expected, i);
7357                 }
7358                 todo_wine {
7359                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7360                             prop.value, wine_dbgstr_w(received), i);
7361                 }
7362             } else {
7363                 ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7364                         hr, prop.expected, i);
7365                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7366                         prop.value, wine_dbgstr_w(received), i);
7367             }
7368             SysFreeString(received);
7369             received = NULL;
7370
7371             /* GetUserInfo() tests. */
7372             prop = test.str_props[Uri_PROPERTY_USER_INFO];
7373             hr = IUri_GetUserInfo(uri, &received);
7374             if(prop.todo) {
7375                 todo_wine {
7376                     ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7377                             hr, prop.expected, i);
7378                 }
7379                 todo_wine {
7380                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7381                             prop.value, wine_dbgstr_w(received), i);
7382                 }
7383             } else {
7384                 ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7385                         hr, prop.expected, i);
7386                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7387                         prop.value, wine_dbgstr_w(received), i);
7388             }
7389             SysFreeString(received);
7390             received = NULL;
7391
7392             /* GetUserName() tests. */
7393             prop = test.str_props[Uri_PROPERTY_USER_NAME];
7394             hr = IUri_GetUserName(uri, &received);
7395             if(prop.todo) {
7396                 todo_wine {
7397                     ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7398                             hr, prop.expected, i);
7399                 }
7400                 todo_wine {
7401                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7402                             prop.value, wine_dbgstr_w(received), i);
7403                 }
7404             } else {
7405                 ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7406                         hr, prop.expected, i);
7407                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7408                         prop.value, wine_dbgstr_w(received), i);
7409             }
7410             SysFreeString(received);
7411         }
7412
7413         if(uri) IUri_Release(uri);
7414
7415         heap_free(uriW);
7416     }
7417 }
7418
7419 static void test_IUri_GetDwordProperties(void) {
7420     IUri *uri = NULL;
7421     HRESULT hr;
7422     DWORD i;
7423
7424     /* Make sure all the 'Get*' dword property functions handle invalid args correctly. */
7425     hr = pCreateUri(http_urlW, 0, 0, &uri);
7426     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7427     if(SUCCEEDED(hr)) {
7428         hr = IUri_GetHostType(uri, NULL);
7429         ok(hr == E_INVALIDARG, "Error: GetHostType returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7430
7431         hr = IUri_GetPort(uri, NULL);
7432         ok(hr == E_INVALIDARG, "Error: GetPort returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7433
7434         hr = IUri_GetScheme(uri, NULL);
7435         ok(hr == E_INVALIDARG, "Error: GetScheme returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7436
7437         hr = IUri_GetZone(uri, NULL);
7438         ok(hr == E_INVALIDARG, "Error: GetZone returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7439     }
7440     if(uri) IUri_Release(uri);
7441
7442     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7443         uri_properties test = uri_tests[i];
7444         LPWSTR uriW;
7445         uri = NULL;
7446
7447         uriW = a2w(test.uri);
7448         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7449         if(test.create_todo) {
7450             todo_wine {
7451                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7452                         hr, test.create_expected, i);
7453             }
7454         } else {
7455             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7456                     hr, test.create_expected, i);
7457         }
7458
7459         if(SUCCEEDED(hr)) {
7460             uri_dword_property prop;
7461             DWORD received;
7462
7463             /* Assign an insane value so tests don't accidentally pass when
7464              * they shouldn't!
7465              */
7466             received = -9999999;
7467
7468             /* GetHostType() tests. */
7469             prop = test.dword_props[Uri_PROPERTY_HOST_TYPE-Uri_PROPERTY_DWORD_START];
7470             hr = IUri_GetHostType(uri, &received);
7471             if(prop.todo) {
7472                 todo_wine {
7473                     ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7474                             hr, prop.expected, i);
7475                 }
7476                 todo_wine {
7477                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7478                 }
7479             } else {
7480                 ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7481                         hr, prop.expected, i);
7482                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7483             }
7484             received = -9999999;
7485
7486             /* GetPort() tests. */
7487             prop = test.dword_props[Uri_PROPERTY_PORT-Uri_PROPERTY_DWORD_START];
7488             hr = IUri_GetPort(uri, &received);
7489             if(prop.todo) {
7490                 todo_wine {
7491                     ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7492                             hr, prop.expected, i);
7493                 }
7494                 todo_wine {
7495                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7496                 }
7497             } else {
7498                 ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7499                         hr, prop.expected, i);
7500                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7501             }
7502             received = -9999999;
7503
7504             /* GetScheme() tests. */
7505             prop = test.dword_props[Uri_PROPERTY_SCHEME-Uri_PROPERTY_DWORD_START];
7506             hr = IUri_GetScheme(uri, &received);
7507             if(prop.todo) {
7508                 todo_wine {
7509                     ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7510                             hr, prop.expected, i);
7511                 }
7512                 todo_wine {
7513                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7514                 }
7515             } else {
7516                 ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7517                         hr, prop.expected, i);
7518                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7519             }
7520             received = -9999999;
7521
7522             /* GetZone() tests. */
7523             prop = test.dword_props[Uri_PROPERTY_ZONE-Uri_PROPERTY_DWORD_START];
7524             hr = IUri_GetZone(uri, &received);
7525             if(prop.todo) {
7526                 todo_wine {
7527                     ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7528                             hr, prop.expected, i);
7529                 }
7530                 todo_wine {
7531                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7532                 }
7533             } else {
7534                 ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7535                         hr, prop.expected, i);
7536                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7537             }
7538         }
7539
7540         if(uri) IUri_Release(uri);
7541
7542         heap_free(uriW);
7543     }
7544 }
7545
7546 static void test_IUri_GetPropertyLength(void) {
7547     IUri *uri = NULL;
7548     HRESULT hr;
7549     DWORD i;
7550
7551     /* Make sure it handles invalid args correctly. */
7552     hr = pCreateUri(http_urlW, 0, 0, &uri);
7553     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7554     if(SUCCEEDED(hr)) {
7555         DWORD received = 0xdeadbeef;
7556
7557         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_STRING_START, NULL, 0);
7558         ok(hr == E_INVALIDARG, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7559
7560         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_DWORD_START, &received, 0);
7561         ok(hr == E_INVALIDARG, "Error: GetPropertyLength return 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7562         ok(received == 0xdeadbeef, "Error: Expected 0xdeadbeef but got 0x%08x.\n", received);
7563     }
7564     if(uri) IUri_Release(uri);
7565
7566     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7567         uri_properties test = uri_tests[i];
7568         LPWSTR uriW;
7569         uri = NULL;
7570
7571         uriW = a2w(test.uri);
7572         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7573         if(test.create_todo) {
7574             todo_wine {
7575                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7576                         hr, test.create_expected, i);
7577             }
7578         } else {
7579             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_test[%d].\n",
7580                     hr, test.create_expected, i);
7581         }
7582
7583         if(SUCCEEDED(hr)) {
7584             DWORD j;
7585
7586             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
7587                 DWORD expectedLen, brokenLen, receivedLen;
7588                 uri_str_property prop = test.str_props[j];
7589
7590                 expectedLen = lstrlen(prop.value);
7591                 brokenLen = lstrlen(prop.broken_value);
7592
7593                 /* This won't be necessary once GetPropertyLength is implemented. */
7594                 receivedLen = -1;
7595
7596                 hr = IUri_GetPropertyLength(uri, j, &receivedLen, 0);
7597                 if(prop.todo) {
7598                     todo_wine {
7599                         ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
7600                                 hr, prop.expected, i, j);
7601                     }
7602                     todo_wine {
7603                         ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
7604                                 "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
7605                                 expectedLen, receivedLen, i, j);
7606                     }
7607                 } else {
7608                     ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
7609                             hr, prop.expected, i, j);
7610                     ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
7611                             "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
7612                             expectedLen, receivedLen, i, j);
7613                 }
7614             }
7615         }
7616
7617         if(uri) IUri_Release(uri);
7618
7619         heap_free(uriW);
7620     }
7621 }
7622
7623 static DWORD compute_expected_props(uri_properties *test)
7624 {
7625     DWORD ret = 0, i;
7626
7627     for(i=Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_STRING_LAST; i++) {
7628         if(test->str_props[i-Uri_PROPERTY_STRING_START].expected == S_OK)
7629             ret |= 1<<i;
7630     }
7631
7632     for(i=Uri_PROPERTY_DWORD_START; i <= Uri_PROPERTY_DWORD_LAST; i++) {
7633         if(test->dword_props[i-Uri_PROPERTY_DWORD_START].expected == S_OK)
7634             ret |= 1<<i;
7635     }
7636
7637     return ret;
7638 }
7639
7640 static void test_IUri_GetProperties(void) {
7641     IUri *uri = NULL;
7642     HRESULT hr;
7643     DWORD i;
7644
7645     hr = pCreateUri(http_urlW, 0, 0, &uri);
7646     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7647     if(SUCCEEDED(hr)) {
7648         hr = IUri_GetProperties(uri, NULL);
7649         ok(hr == E_INVALIDARG, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7650     }
7651     if(uri) IUri_Release(uri);
7652
7653     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7654         uri_properties test = uri_tests[i];
7655         LPWSTR uriW;
7656         uri = NULL;
7657
7658         uriW = a2w(test.uri);
7659         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7660         if(test.create_todo) {
7661             todo_wine {
7662                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7663             }
7664         } else {
7665             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7666         }
7667
7668         if(SUCCEEDED(hr)) {
7669             DWORD received = 0, expected_props;
7670             DWORD j;
7671
7672             hr = IUri_GetProperties(uri, &received);
7673             ok(hr == S_OK, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7674
7675             expected_props = compute_expected_props(&test);
7676
7677             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
7678                 /* (1 << j) converts a Uri_PROPERTY to its corresponding Uri_HAS_* flag mask. */
7679                 if(expected_props & (1 << j))
7680                     ok(received & (1 << j), "Error: Expected flag for property %d on uri_tests[%d].\n", j, i);
7681                 else
7682                     ok(!(received & (1 << j)), "Error: Received flag for property %d when not expected on uri_tests[%d].\n", j, i);
7683             }
7684         }
7685
7686         if(uri) IUri_Release(uri);
7687
7688         heap_free(uriW);
7689     }
7690 }
7691
7692 static void test_IUri_HasProperty(void) {
7693     IUri *uri = NULL;
7694     HRESULT hr;
7695     DWORD i;
7696
7697     hr = pCreateUri(http_urlW, 0, 0, &uri);
7698     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7699     if(SUCCEEDED(hr)) {
7700         hr = IUri_HasProperty(uri, Uri_PROPERTY_RAW_URI, NULL);
7701         ok(hr == E_INVALIDARG, "Error: HasProperty returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7702     }
7703     if(uri) IUri_Release(uri);
7704
7705     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7706         uri_properties test = uri_tests[i];
7707         LPWSTR uriW;
7708         uri = NULL;
7709
7710         uriW = a2w(test.uri);
7711
7712         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7713         if(test.create_todo) {
7714             todo_wine {
7715                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7716             }
7717         } else {
7718             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7719         }
7720
7721         if(SUCCEEDED(hr)) {
7722             DWORD expected_props, j;
7723
7724             expected_props = compute_expected_props(&test);
7725
7726             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
7727                 /* Assign -1, then explicitly test for TRUE or FALSE later. */
7728                 BOOL received = -1;
7729
7730                 hr = IUri_HasProperty(uri, j, &received);
7731                 ok(hr == S_OK, "Error: HasProperty returned 0x%08x, expected 0x%08x for property %d on uri_tests[%d].\n",
7732                         hr, S_OK, j, i);
7733
7734                 if(expected_props & (1 << j)) {
7735                     ok(received == TRUE, "Error: Expected to have property %d on uri_tests[%d].\n", j, i);
7736                 } else {
7737                     ok(received == FALSE, "Error: Wasn't expecting to have property %d on uri_tests[%d].\n", j, i);
7738                 }
7739             }
7740         }
7741
7742         if(uri) IUri_Release(uri);
7743
7744         heap_free(uriW);
7745     }
7746 }
7747
7748 static void test_IUri_IsEqual(void) {
7749     IUri *uriA, *uriB;
7750     BOOL equal;
7751     HRESULT hres;
7752     DWORD i;
7753
7754     uriA = uriB = NULL;
7755
7756     /* Make sure IsEqual handles invalid args correctly. */
7757     hres = pCreateUri(http_urlW, 0, 0, &uriA);
7758     ok(hres == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hres, S_OK);
7759     hres = pCreateUri(http_urlW, 0, 0, &uriB);
7760     ok(hres == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hres, S_OK);
7761
7762     equal = -1;
7763     hres = IUri_IsEqual(uriA, NULL, &equal);
7764     ok(hres == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hres, S_OK);
7765     ok(!equal, "Error: Expected equal to be FALSE, but was %d instead.\n", equal);
7766
7767     hres = IUri_IsEqual(uriA, uriB, NULL);
7768     ok(hres == E_POINTER, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hres, E_POINTER);
7769
7770     IUri_Release(uriA);
7771     IUri_Release(uriB);
7772
7773     for(i = 0; i < sizeof(equality_tests)/sizeof(equality_tests[0]); ++i) {
7774         uri_equality test = equality_tests[i];
7775         LPWSTR uriA_W, uriB_W;
7776
7777         uriA = uriB = NULL;
7778
7779         uriA_W = a2w(test.a);
7780         uriB_W = a2w(test.b);
7781
7782         hres = pCreateUri(uriA_W, test.create_flags_a, 0, &uriA);
7783         ok(hres == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n", hres, S_OK, i);
7784
7785         hres = pCreateUri(uriB_W, test.create_flags_b, 0, &uriB);
7786         ok(hres == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n", hres, S_OK, i);
7787
7788         equal = -1;
7789         hres = IUri_IsEqual(uriA, uriB, &equal);
7790         if(test.todo) todo_wine {
7791             ok(hres == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n", hres, S_OK, i);
7792             ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7793         } else {
7794             ok(hres == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n", hres, S_OK, i);
7795             ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7796         }
7797         if(uriA) IUri_Release(uriA);
7798         if(uriB) IUri_Release(uriB);
7799
7800         heap_free(uriA_W);
7801         heap_free(uriB_W);
7802     }
7803 }
7804
7805 static void test_CreateUriWithFragment_InvalidArgs(void) {
7806     HRESULT hr;
7807     IUri *uri = (void*) 0xdeadbeef;
7808     const WCHAR fragmentW[] = {'#','f','r','a','g','m','e','n','t',0};
7809
7810     hr = pCreateUriWithFragment(NULL, fragmentW, 0, 0, &uri);
7811     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7812     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7813
7814     hr = pCreateUriWithFragment(http_urlW, fragmentW, 0, 0, NULL);
7815     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7816
7817     /* Original URI can't already contain a fragment component. */
7818     uri = (void*) 0xdeadbeef;
7819     hr = pCreateUriWithFragment(http_url_fragW, fragmentW, 0, 0, &uri);
7820     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7821     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7822 }
7823
7824 /* CreateUriWithFragment has the same invalid flag combinations as CreateUri. */
7825 static void test_CreateUriWithFragment_InvalidFlags(void) {
7826     DWORD i;
7827
7828     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
7829         HRESULT hr;
7830         IUri *uri = (void*) 0xdeadbeef;
7831
7832         hr = pCreateUriWithFragment(http_urlW, NULL, invalid_flag_tests[i].flags, 0, &uri);
7833         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x. flags=0x%08x.\n",
7834             hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
7835         ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7836     }
7837 }
7838
7839 static void test_CreateUriWithFragment(void) {
7840     DWORD i;
7841
7842     for(i = 0; i < sizeof(uri_fragment_tests)/sizeof(uri_fragment_tests[0]); ++i) {
7843         HRESULT hr;
7844         IUri *uri = NULL;
7845         LPWSTR uriW, fragW;
7846         uri_with_fragment test = uri_fragment_tests[i];
7847
7848         uriW = a2w(test.uri);
7849         fragW = a2w(test.fragment);
7850
7851         hr = pCreateUriWithFragment(uriW, fragW, test.create_flags, 0, &uri);
7852         if(test.expected_todo) {
7853             todo_wine {
7854                 ok(hr == test.create_expected,
7855                     "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7856                     hr, test.create_expected, i);
7857             }
7858         } else
7859             ok(hr == test.create_expected,
7860                 "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7861                 hr, test.create_expected, i);
7862
7863         if(SUCCEEDED(hr)) {
7864             BSTR received = NULL;
7865
7866             hr = IUri_GetAbsoluteUri(uri, &received);
7867             if(test.expected_todo) {
7868                 todo_wine {
7869                     ok(hr == S_OK,
7870                         "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7871                         hr, S_OK, i);
7872                 }
7873                 todo_wine {
7874                     ok(!strcmp_aw(test.expected_uri, received),
7875                         "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7876                         test.expected_uri, wine_dbgstr_w(received), i);
7877                 }
7878             } else {
7879                 ok(hr == S_OK, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7880                     hr, S_OK, i);
7881                 ok(!strcmp_aw(test.expected_uri, received), "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7882                     test.expected_uri, wine_dbgstr_w(received), i);
7883             }
7884
7885             SysFreeString(received);
7886         }
7887
7888         if(uri) IUri_Release(uri);
7889         heap_free(uriW);
7890         heap_free(fragW);
7891     }
7892 }
7893
7894 static void test_CreateIUriBuilder(void) {
7895     HRESULT hr;
7896     IUriBuilder *builder = NULL;
7897     IUri *uri;
7898
7899     hr = pCreateIUriBuilder(NULL, 0, 0, NULL);
7900     ok(hr == E_POINTER, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x\n",
7901         hr, E_POINTER);
7902
7903     /* CreateIUriBuilder increases the ref count of the IUri it receives. */
7904     hr = pCreateUri(http_urlW, 0, 0, &uri);
7905     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7906     if(SUCCEEDED(hr)) {
7907         ULONG cur_count, orig_count;
7908
7909         orig_count = get_refcnt(uri);
7910         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
7911         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7912         ok(builder != NULL, "Error: Expecting builder not to be NULL\n");
7913
7914         cur_count = get_refcnt(uri);
7915         ok(cur_count == orig_count+1, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count+1, cur_count);
7916
7917         if(builder) IUriBuilder_Release(builder);
7918         cur_count = get_refcnt(uri);
7919         ok(cur_count == orig_count, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count, cur_count);
7920     }
7921     if(uri) IUri_Release(uri);
7922 }
7923
7924 static void test_IUriBuilder_CreateUri(IUriBuilder *builder, const uri_builder_test *test,
7925                                        DWORD test_index) {
7926     HRESULT hr;
7927     IUri *uri = NULL;
7928
7929     hr = IUriBuilder_CreateUri(builder, test->uri_flags, 0, 0, &uri);
7930     if(test->uri_todo) {
7931         todo_wine {
7932             ok(hr == test->uri_hres,
7933                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7934                 hr, test->uri_hres, test_index);
7935         }
7936     } else {
7937         ok(hr == test->uri_hres,
7938             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7939             hr, test->uri_hres, test_index);
7940     }
7941
7942     if(SUCCEEDED(hr)) {
7943         DWORD i;
7944
7945         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7946             uri_builder_str_property prop = test->expected_str_props[i];
7947             BSTR received = NULL;
7948
7949             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7950             if(prop.todo) {
7951                 todo_wine {
7952                     ok(hr == prop.result,
7953                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7954                         hr, prop.result, test_index, i);
7955                 }
7956             } else {
7957                 ok(hr == prop.result,
7958                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7959                     hr, prop.result, test_index, i);
7960             }
7961             if(SUCCEEDED(hr)) {
7962                 if(prop.todo) {
7963                     todo_wine {
7964                         ok(!strcmp_aw(prop.expected, received),
7965                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7966                             prop.expected, wine_dbgstr_w(received), test_index, i);
7967                     }
7968                 } else {
7969                     ok(!strcmp_aw(prop.expected, received),
7970                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7971                         prop.expected, wine_dbgstr_w(received), test_index, i);
7972                 }
7973             }
7974             SysFreeString(received);
7975         }
7976
7977         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7978             uri_builder_dword_property prop = test->expected_dword_props[i];
7979             DWORD received = -2;
7980
7981             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7982             if(prop.todo) {
7983                 todo_wine {
7984                     ok(hr == prop.result,
7985                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7986                         hr, prop.result, test_index, i);
7987                 }
7988             } else {
7989                 ok(hr == prop.result,
7990                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7991                     hr, prop.result, test_index, i);
7992             }
7993             if(SUCCEEDED(hr)) {
7994                 if(prop.todo) {
7995                     todo_wine {
7996                         ok(received == prop.expected,
7997                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7998                             prop.expected, received, test_index, i);
7999                     }
8000                 } else {
8001                     ok(received == prop.expected,
8002                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
8003                         prop.expected, received, test_index, i);
8004                 }
8005             }
8006         }
8007     }
8008     if(uri) IUri_Release(uri);
8009 }
8010
8011 static void test_IUriBuilder_CreateUriSimple(IUriBuilder *builder, const uri_builder_test *test,
8012                                        DWORD test_index) {
8013     HRESULT hr;
8014     IUri *uri = NULL;
8015
8016     hr = IUriBuilder_CreateUriSimple(builder, test->uri_simple_encode_flags, 0, &uri);
8017     if(test->uri_simple_todo) {
8018         todo_wine {
8019             ok(hr == test->uri_simple_hres,
8020                 "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8021                 hr, test->uri_simple_hres, test_index);
8022         }
8023     } else {
8024         ok(hr == test->uri_simple_hres,
8025             "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8026             hr, test->uri_simple_hres, test_index);
8027     }
8028
8029     if(SUCCEEDED(hr)) {
8030         DWORD i;
8031
8032         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
8033             uri_builder_str_property prop = test->expected_str_props[i];
8034             BSTR received = NULL;
8035
8036             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
8037             if(prop.todo) {
8038                 todo_wine {
8039                     ok(hr == prop.result,
8040                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
8041                         hr, prop.result, test_index, i);
8042                 }
8043             } else {
8044                 ok(hr == prop.result,
8045                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
8046                     hr, prop.result, test_index, i);
8047             }
8048             if(SUCCEEDED(hr)) {
8049                 if(prop.todo) {
8050                     todo_wine {
8051                         ok(!strcmp_aw(prop.expected, received),
8052                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
8053                             prop.expected, wine_dbgstr_w(received), test_index, i);
8054                     }
8055                 } else {
8056                     ok(!strcmp_aw(prop.expected, received),
8057                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
8058                         prop.expected, wine_dbgstr_w(received), test_index, i);
8059                 }
8060             }
8061             SysFreeString(received);
8062         }
8063
8064         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
8065             uri_builder_dword_property prop = test->expected_dword_props[i];
8066             DWORD received = -2;
8067
8068             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
8069             if(prop.todo) {
8070                 todo_wine {
8071                     ok(hr == prop.result,
8072                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
8073                         hr, prop.result, test_index, i);
8074                 }
8075             } else {
8076                 ok(hr == prop.result,
8077                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
8078                     hr, prop.result, test_index, i);
8079             }
8080             if(SUCCEEDED(hr)) {
8081                 if(prop.todo) {
8082                     todo_wine {
8083                         ok(received == prop.expected,
8084                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
8085                             prop.expected, received, test_index, i);
8086                     }
8087                 } else {
8088                     ok(received == prop.expected,
8089                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
8090                         prop.expected, received, test_index, i);
8091                 }
8092             }
8093         }
8094     }
8095     if(uri) IUri_Release(uri);
8096 }
8097
8098 static void test_IUriBuilder_CreateUriWithFlags(IUriBuilder *builder, const uri_builder_test *test,
8099                                                 DWORD test_index) {
8100     HRESULT hr;
8101     IUri *uri = NULL;
8102
8103     hr = IUriBuilder_CreateUriWithFlags(builder, test->uri_with_flags, test->uri_with_builder_flags,
8104                                         test->uri_with_encode_flags, 0, &uri);
8105     if(test->uri_with_todo) {
8106         todo_wine {
8107             ok(hr == test->uri_with_hres,
8108                 "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8109                 hr, test->uri_with_hres, test_index);
8110         }
8111     } else {
8112         ok(hr == test->uri_with_hres,
8113             "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8114             hr, test->uri_with_hres, test_index);
8115     }
8116
8117     if(SUCCEEDED(hr)) {
8118         DWORD i;
8119
8120         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
8121             uri_builder_str_property prop = test->expected_str_props[i];
8122             BSTR received = NULL;
8123
8124             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
8125             if(prop.todo) {
8126                 todo_wine {
8127                     ok(hr == prop.result,
8128                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
8129                         hr, prop.result, test_index, i);
8130                 }
8131             } else {
8132                 ok(hr == prop.result,
8133                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
8134                     hr, prop.result, test_index, i);
8135             }
8136             if(SUCCEEDED(hr)) {
8137                 if(prop.todo) {
8138                     todo_wine {
8139                         ok(!strcmp_aw(prop.expected, received),
8140                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
8141                             prop.expected, wine_dbgstr_w(received), test_index, i);
8142                     }
8143                 } else {
8144                     ok(!strcmp_aw(prop.expected, received),
8145                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
8146                         prop.expected, wine_dbgstr_w(received), test_index, i);
8147                 }
8148             }
8149             SysFreeString(received);
8150         }
8151
8152         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
8153             uri_builder_dword_property prop = test->expected_dword_props[i];
8154             DWORD received = -2;
8155
8156             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
8157             if(prop.todo) {
8158                 todo_wine {
8159                     ok(hr == prop.result,
8160                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
8161                         hr, prop.result, test_index, i);
8162                 }
8163             } else {
8164                 ok(hr == prop.result,
8165                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
8166                     hr, prop.result, test_index, i);
8167             }
8168             if(SUCCEEDED(hr)) {
8169                 if(prop.todo) {
8170                     todo_wine {
8171                         ok(received == prop.expected,
8172                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
8173                             prop.expected, received, test_index, i);
8174                     }
8175                 } else {
8176                     ok(received == prop.expected,
8177                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
8178                         prop.expected, received, test_index, i);
8179                 }
8180             }
8181         }
8182     }
8183     if(uri) IUri_Release(uri);
8184 }
8185
8186 static void test_IUriBuilder_CreateInvalidArgs(void) {
8187     IUriBuilder *builder;
8188     HRESULT hr;
8189
8190     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8191     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8192     if(SUCCEEDED(hr)) {
8193         IUri *test = NULL, *uri = (void*) 0xdeadbeef;
8194
8195         /* Test what happens if the IUriBuilder doesn't have a IUri set. */
8196         hr = IUriBuilder_CreateUri(builder, 0, 0, 0, NULL);
8197         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
8198
8199         uri = (void*) 0xdeadbeef;
8200         hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
8201         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_NOTIMPL);
8202         ok(uri == NULL, "Error: expected uri to be NULL, but was %p instead.\n", uri);
8203
8204         hr = IUriBuilder_CreateUriSimple(builder, 0, 0, NULL);
8205         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8206             hr, E_POINTER);
8207
8208         uri = (void*) 0xdeadbeef;
8209         hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
8210         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8211             hr, E_NOTIMPL);
8212         ok(!uri, "Error: Expected uri to NULL, but was %p instead.\n", uri);
8213
8214         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, NULL);
8215         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8216             hr, E_POINTER);
8217
8218         uri = (void*) 0xdeadbeef;
8219         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
8220         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8221             hr, E_NOTIMPL);
8222         ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
8223
8224         hr = pCreateUri(http_urlW, 0, 0, &test);
8225         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8226         if(SUCCEEDED(hr)) {
8227             hr = IUriBuilder_SetIUri(builder, test);
8228             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8229
8230             /* No longer returns E_NOTIMPL, since a IUri has been set and hasn't been modified. */
8231             uri = NULL;
8232             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
8233             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8234             ok(uri != NULL, "Error: The uri was NULL.\n");
8235             if(uri) IUri_Release(uri);
8236
8237             uri = NULL;
8238             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
8239             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8240                 hr, S_OK);
8241             ok(uri != NULL, "Error: uri was NULL.\n");
8242             if(uri) IUri_Release(uri);
8243
8244             uri = NULL;
8245             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &uri);
8246             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8247                 hr, S_OK);
8248             ok(uri != NULL, "Error: uri was NULL.\n");
8249             if(uri) IUri_Release(uri);
8250
8251             hr = IUriBuilder_SetFragment(builder, NULL);
8252             ok(hr == S_OK, "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8253
8254             /* The IUriBuilder is changed, so it returns E_NOTIMPL again. */
8255             uri = (void*) 0xdeadbeef;
8256             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
8257             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8258             ok(!uri, "Error: Expected uri to be NULL but was %p instead.\n", uri);
8259
8260             uri = (void*) 0xdeadbeef;
8261             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
8262             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8263                 hr, S_OK);
8264             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
8265
8266             uri = (void*) 0xdeadbeef;
8267             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
8268             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8269                 hr, E_NOTIMPL);
8270             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
8271         }
8272         if(test) IUri_Release(test);
8273     }
8274     if(builder) IUriBuilder_Release(builder);
8275 }
8276
8277 /* Tests invalid args to the "Get*" functions. */
8278 static void test_IUriBuilder_GetInvalidArgs(void) {
8279     IUriBuilder *builder = NULL;
8280     HRESULT hr;
8281
8282     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8283     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8284     if(SUCCEEDED(hr)) {
8285         LPCWSTR received = (void*) 0xdeadbeef;
8286         DWORD len = -1, port = -1;
8287         BOOL set = -1;
8288
8289         hr = IUriBuilder_GetFragment(builder, NULL, NULL);
8290         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
8291             hr, E_POINTER);
8292         hr = IUriBuilder_GetFragment(builder, NULL, &received);
8293         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
8294             hr, E_POINTER);
8295         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8296         hr = IUriBuilder_GetFragment(builder, &len, NULL);
8297         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
8298             hr, E_POINTER);
8299         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8300
8301         hr = IUriBuilder_GetHost(builder, NULL, NULL);
8302         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
8303             hr, E_POINTER);
8304         received = (void*) 0xdeadbeef;
8305         hr = IUriBuilder_GetHost(builder, NULL, &received);
8306         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
8307             hr, E_POINTER);
8308         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8309         len = -1;
8310         hr = IUriBuilder_GetHost(builder, &len, NULL);
8311         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
8312             hr, E_POINTER);
8313         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8314
8315         hr = IUriBuilder_GetPassword(builder, NULL, NULL);
8316         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
8317             hr, E_POINTER);
8318         received = (void*) 0xdeadbeef;
8319         hr = IUriBuilder_GetPassword(builder, NULL, &received);
8320         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
8321             hr, E_POINTER);
8322         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8323         len = -1;
8324         hr = IUriBuilder_GetPassword(builder, &len, NULL);
8325         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
8326             hr, E_POINTER);
8327         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8328
8329         hr = IUriBuilder_GetPath(builder, NULL, NULL);
8330         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8331             hr, E_POINTER);
8332         received = (void*) 0xdeadbeef;
8333         hr = IUriBuilder_GetPath(builder, NULL, &received);
8334         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8335             hr, E_POINTER);
8336         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8337         len = -1;
8338         hr = IUriBuilder_GetPath(builder, &len, NULL);
8339         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8340             hr, E_POINTER);
8341         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8342
8343         hr = IUriBuilder_GetPort(builder, NULL, NULL);
8344         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8345             hr, E_POINTER);
8346         hr = IUriBuilder_GetPort(builder, NULL, &port);
8347         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8348             hr, E_POINTER);
8349         ok(!port, "Error: Expected port to be 0, but was %d instead.\n", port);
8350         hr = IUriBuilder_GetPort(builder, &set, NULL);
8351         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8352             hr, E_POINTER);
8353         ok(!set, "Error: Expected set to be FALSE, but was %d instead.\n", set);
8354
8355         hr = IUriBuilder_GetQuery(builder, NULL, NULL);
8356         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8357             hr, E_POINTER);
8358         received = (void*) 0xdeadbeef;
8359         hr = IUriBuilder_GetQuery(builder, NULL, &received);
8360         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8361             hr, E_POINTER);
8362         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8363         len = -1;
8364         hr = IUriBuilder_GetQuery(builder, &len, NULL);
8365         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8366             hr, E_POINTER);
8367         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8368
8369         hr = IUriBuilder_GetSchemeName(builder, NULL, NULL);
8370         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8371             hr, E_POINTER);
8372         received = (void*) 0xdeadbeef;
8373         hr = IUriBuilder_GetSchemeName(builder, NULL, &received);
8374         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8375             hr, E_POINTER);
8376         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8377         len = -1;
8378         hr = IUriBuilder_GetSchemeName(builder, &len, NULL);
8379         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8380             hr, E_POINTER);
8381         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8382
8383         hr = IUriBuilder_GetUserName(builder, NULL, NULL);
8384         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8385             hr, E_POINTER);
8386         received = (void*) 0xdeadbeef;
8387         hr = IUriBuilder_GetUserName(builder, NULL, &received);
8388         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8389             hr, E_POINTER);
8390         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8391         len = -1;
8392         hr = IUriBuilder_GetUserName(builder, &len, NULL);
8393         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8394             hr, E_POINTER);
8395         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8396     }
8397     if(builder) IUriBuilder_Release(builder);
8398 }
8399
8400 static void test_IUriBuilder_GetFragment(IUriBuilder *builder, const uri_builder_test *test,
8401                                          DWORD test_index) {
8402     HRESULT hr;
8403     DWORD i;
8404     LPCWSTR received = NULL;
8405     DWORD len = -1;
8406     const uri_builder_property *prop = NULL;
8407
8408     /* Check if the property was set earlier. */
8409     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8410         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_FRAGMENT)
8411             prop = &(test->properties[i]);
8412     }
8413
8414     if(prop) {
8415         /* Use expected_value unless it's NULL, then use value. */
8416         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8417         hr = IUriBuilder_GetFragment(builder, &len, &received);
8418         if(prop->todo) {
8419             todo_wine {
8420                 ok(hr == (expected ? S_OK : S_FALSE),
8421                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8422                     hr, (expected ? S_OK : S_FALSE), test_index);
8423             }
8424             if(SUCCEEDED(hr)) {
8425                 todo_wine {
8426                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8427                         expected, wine_dbgstr_w(received), test_index);
8428                 }
8429                 todo_wine {
8430                     ok(lstrlen(expected) == len,
8431                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8432                         lstrlen(expected), len, test_index);
8433                 }
8434             }
8435         } else {
8436             ok(hr == (expected ? S_OK : S_FALSE),
8437                 "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8438                 hr, (expected ? S_OK : S_FALSE), test_index);
8439             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8440                 expected, wine_dbgstr_w(received), test_index);
8441             ok(lstrlen(expected) == len,
8442                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8443                 lstrlen(expected), len, test_index);
8444         }
8445     } else {
8446         /* The property wasn't set earlier, so it should return whatever
8447          * the base IUri contains (if anything).
8448          */
8449         IUri *uri = NULL;
8450         hr = IUriBuilder_GetIUri(builder, &uri);
8451         ok(hr == S_OK,
8452             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8453             hr, S_OK, test_index);
8454         if(SUCCEEDED(hr)) {
8455             if(!uri) {
8456                 received = (void*) 0xdeadbeef;
8457                 len = -1;
8458
8459                 hr = IUriBuilder_GetFragment(builder, &len, &received);
8460                 ok(hr == S_FALSE,
8461                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8462                     hr, S_FALSE, test_index);
8463                 if(SUCCEEDED(hr)) {
8464                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8465                         len, test_index);
8466                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8467                         received, test_index);
8468                 }
8469             } else {
8470                 BOOL has_prop = FALSE;
8471                 BSTR expected = NULL;
8472
8473                 hr = IUri_GetFragment(uri, &expected);
8474                 ok(SUCCEEDED(hr),
8475                     "Error: Expected IUri_GetFragment to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8476                     hr, test_index);
8477                 has_prop = hr == S_OK;
8478
8479                 hr = IUriBuilder_GetFragment(builder, &len, &received);
8480                 if(has_prop) {
8481                     ok(hr == S_OK,
8482                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8483                         hr, S_OK, test_index);
8484                     if(SUCCEEDED(hr)) {
8485                         ok(!lstrcmpW(expected, received),
8486                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8487                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8488                         ok(lstrlenW(expected) == len,
8489                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8490                             lstrlenW(expected), len, test_index);
8491                     }
8492                 } else {
8493                     ok(hr == S_FALSE,
8494                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8495                         hr, S_FALSE, test_index);
8496                     if(SUCCEEDED(hr)) {
8497                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8498                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8499                             len, test_index);
8500                     }
8501                 }
8502                 SysFreeString(expected);
8503             }
8504         }
8505         if(uri) IUri_Release(uri);
8506     }
8507 }
8508
8509 static void test_IUriBuilder_GetHost(IUriBuilder *builder, const uri_builder_test *test,
8510                                      DWORD test_index) {
8511     HRESULT hr;
8512     DWORD i;
8513     LPCWSTR received = NULL;
8514     DWORD len = -1;
8515     const uri_builder_property *prop = NULL;
8516
8517     /* Check if the property was set earlier. */
8518     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8519         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_HOST)
8520             prop = &(test->properties[i]);
8521     }
8522
8523     if(prop) {
8524         /* Use expected_value unless it's NULL, then use value. */
8525         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8526         hr = IUriBuilder_GetHost(builder, &len, &received);
8527         if(prop->todo) {
8528             todo_wine {
8529                 ok(hr == (expected ? S_OK : S_FALSE),
8530                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8531                     hr, (expected ? S_OK : S_FALSE), test_index);
8532             }
8533             if(SUCCEEDED(hr)) {
8534                 todo_wine {
8535                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8536                         expected, wine_dbgstr_w(received), test_index);
8537                 }
8538                 todo_wine {
8539                     ok(lstrlen(expected) == len,
8540                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8541                         lstrlen(expected), len, test_index);
8542                 }
8543             }
8544         } else {
8545             ok(hr == (expected ? S_OK : S_FALSE),
8546                 "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8547                 hr, (expected ? S_OK : S_FALSE), test_index);
8548             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8549                 expected, wine_dbgstr_w(received), test_index);
8550             ok(lstrlen(expected) == len,
8551                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8552                 lstrlen(expected), len, test_index);
8553         }
8554     } else {
8555         /* The property wasn't set earlier, so it should return whatever
8556          * the base IUri contains (if anything).
8557          */
8558         IUri *uri = NULL;
8559         hr = IUriBuilder_GetIUri(builder, &uri);
8560         ok(hr == S_OK,
8561             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8562             hr, S_OK, test_index);
8563         if(SUCCEEDED(hr)) {
8564             if(!uri) {
8565                 received = (void*) 0xdeadbeef;
8566                 len = -1;
8567
8568                 hr = IUriBuilder_GetHost(builder, &len, &received);
8569                 ok(hr == S_FALSE,
8570                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8571                     hr, S_FALSE, test_index);
8572                 if(SUCCEEDED(hr)) {
8573                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8574                         len, test_index);
8575                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8576                         received, test_index);
8577                 }
8578             } else {
8579                 BOOL has_prop = FALSE;
8580                 BSTR expected = NULL;
8581
8582                 hr = IUri_GetHost(uri, &expected);
8583                 ok(SUCCEEDED(hr),
8584                     "Error: Expected IUri_GetHost to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8585                     hr, test_index);
8586                 has_prop = hr == S_OK;
8587
8588                 hr = IUriBuilder_GetHost(builder, &len, &received);
8589                 if(has_prop) {
8590                     ok(hr == S_OK,
8591                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8592                         hr, S_OK, test_index);
8593                     if(SUCCEEDED(hr)) {
8594                         ok(!lstrcmpW(expected, received),
8595                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8596                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8597                         ok(lstrlenW(expected) == len,
8598                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8599                             lstrlenW(expected), len, test_index);
8600                     }
8601                 } else {
8602                     ok(hr == S_FALSE,
8603                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8604                         hr, S_FALSE, test_index);
8605                     if(SUCCEEDED(hr)) {
8606                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8607                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8608                             len, test_index);
8609                     }
8610                 }
8611                 SysFreeString(expected);
8612             }
8613         }
8614         if(uri) IUri_Release(uri);
8615     }
8616 }
8617
8618 static void test_IUriBuilder_GetPassword(IUriBuilder *builder, const uri_builder_test *test,
8619                                          DWORD test_index) {
8620     HRESULT hr;
8621     DWORD i;
8622     LPCWSTR received = NULL;
8623     DWORD len = -1;
8624     const uri_builder_property *prop = NULL;
8625
8626     /* Check if the property was set earlier. */
8627     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8628         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PASSWORD)
8629             prop = &(test->properties[i]);
8630     }
8631
8632     if(prop) {
8633         /* Use expected_value unless it's NULL, then use value. */
8634         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8635         hr = IUriBuilder_GetPassword(builder, &len, &received);
8636         if(prop->todo) {
8637             todo_wine {
8638                 ok(hr == (expected ? S_OK : S_FALSE),
8639                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8640                     hr, (expected ? S_OK : S_FALSE), test_index);
8641             }
8642             if(SUCCEEDED(hr)) {
8643                 todo_wine {
8644                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8645                         expected, wine_dbgstr_w(received), test_index);
8646                 }
8647                 todo_wine {
8648                     ok(lstrlen(expected) == len,
8649                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8650                         lstrlen(expected), len, test_index);
8651                 }
8652             }
8653         } else {
8654             ok(hr == (expected ? S_OK : S_FALSE),
8655                 "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8656                 hr, (expected ? S_OK : S_FALSE), test_index);
8657             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8658                 expected, wine_dbgstr_w(received), test_index);
8659             ok(lstrlen(expected) == len,
8660                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8661                 lstrlen(expected), len, test_index);
8662         }
8663     } else {
8664         /* The property wasn't set earlier, so it should return whatever
8665          * the base IUri contains (if anything).
8666          */
8667         IUri *uri = NULL;
8668         hr = IUriBuilder_GetIUri(builder, &uri);
8669         ok(hr == S_OK,
8670             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8671             hr, S_OK, test_index);
8672         if(SUCCEEDED(hr)) {
8673             if(!uri) {
8674                 received = (void*) 0xdeadbeef;
8675                 len = -1;
8676
8677                 hr = IUriBuilder_GetPassword(builder, &len, &received);
8678                 ok(hr == S_FALSE,
8679                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8680                     hr, S_FALSE, test_index);
8681                 if(SUCCEEDED(hr)) {
8682                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8683                         len, test_index);
8684                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8685                         received, test_index);
8686                 }
8687             } else {
8688                 BOOL has_prop = FALSE;
8689                 BSTR expected = NULL;
8690
8691                 hr = IUri_GetPassword(uri, &expected);
8692                 ok(SUCCEEDED(hr),
8693                     "Error: Expected IUri_GetPassword to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8694                     hr, test_index);
8695                 has_prop = hr == S_OK;
8696
8697                 hr = IUriBuilder_GetPassword(builder, &len, &received);
8698                 if(has_prop) {
8699                     ok(hr == S_OK,
8700                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8701                         hr, S_OK, test_index);
8702                     if(SUCCEEDED(hr)) {
8703                         ok(!lstrcmpW(expected, received),
8704                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8705                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8706                         ok(lstrlenW(expected) == len,
8707                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8708                             lstrlenW(expected), len, test_index);
8709                     }
8710                 } else {
8711                     ok(hr == S_FALSE,
8712                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8713                         hr, S_FALSE, test_index);
8714                     if(SUCCEEDED(hr)) {
8715                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8716                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8717                             len, test_index);
8718                     }
8719                 }
8720                 SysFreeString(expected);
8721             }
8722         }
8723         if(uri) IUri_Release(uri);
8724     }
8725 }
8726
8727 static void test_IUriBuilder_GetPath(IUriBuilder *builder, const uri_builder_test *test,
8728                                      DWORD test_index) {
8729     HRESULT hr;
8730     DWORD i;
8731     LPCWSTR received = NULL;
8732     DWORD len = -1;
8733     const uri_builder_property *prop = NULL;
8734
8735     /* Check if the property was set earlier. */
8736     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8737         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PATH)
8738             prop = &(test->properties[i]);
8739     }
8740
8741     if(prop) {
8742         /* Use expected_value unless it's NULL, then use value. */
8743         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8744         hr = IUriBuilder_GetPath(builder, &len, &received);
8745         if(prop->todo) {
8746             todo_wine {
8747                 ok(hr == (expected ? S_OK : S_FALSE),
8748                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8749                     hr, (expected ? S_OK : S_FALSE), test_index);
8750             }
8751             if(SUCCEEDED(hr)) {
8752                 todo_wine {
8753                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8754                         expected, wine_dbgstr_w(received), test_index);
8755                 }
8756                 todo_wine {
8757                     ok(lstrlen(expected) == len,
8758                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8759                         lstrlen(expected), len, test_index);
8760                 }
8761             }
8762         } else {
8763             ok(hr == (expected ? S_OK : S_FALSE),
8764                 "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8765                 hr, (expected ? S_OK : S_FALSE), test_index);
8766             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8767                 expected, wine_dbgstr_w(received), test_index);
8768             ok(lstrlen(expected) == len,
8769                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8770                 lstrlen(expected), len, test_index);
8771         }
8772     } else {
8773         /* The property wasn't set earlier, so it should return whatever
8774          * the base IUri contains (if anything).
8775          */
8776         IUri *uri = NULL;
8777         hr = IUriBuilder_GetIUri(builder, &uri);
8778         ok(hr == S_OK,
8779             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8780             hr, S_OK, test_index);
8781         if(SUCCEEDED(hr)) {
8782             if(!uri) {
8783                 received = (void*) 0xdeadbeef;
8784                 len = -1;
8785
8786                 hr = IUriBuilder_GetPath(builder, &len, &received);
8787                 ok(hr == S_FALSE,
8788                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8789                     hr, S_FALSE, test_index);
8790                 if(SUCCEEDED(hr)) {
8791                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8792                         len, test_index);
8793                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8794                         received, test_index);
8795                 }
8796             } else {
8797                 BOOL has_prop = FALSE;
8798                 BSTR expected = NULL;
8799
8800                 hr = IUri_GetPath(uri, &expected);
8801                 ok(SUCCEEDED(hr),
8802                     "Error: Expected IUri_GetPath to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8803                     hr, test_index);
8804                 has_prop = hr == S_OK;
8805
8806                 hr = IUriBuilder_GetPath(builder, &len, &received);
8807                 if(has_prop) {
8808                     ok(hr == S_OK,
8809                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8810                         hr, S_OK, test_index);
8811                     if(SUCCEEDED(hr)) {
8812                         ok(!lstrcmpW(expected, received),
8813                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8814                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8815                         ok(lstrlenW(expected) == len,
8816                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8817                             lstrlenW(expected), len, test_index);
8818                     }
8819                 } else {
8820                     ok(hr == S_FALSE,
8821                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8822                         hr, S_FALSE, test_index);
8823                     if(SUCCEEDED(hr)) {
8824                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8825                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8826                             len, test_index);
8827                     }
8828                 }
8829                 SysFreeString(expected);
8830             }
8831         }
8832         if(uri) IUri_Release(uri);
8833     }
8834 }
8835
8836 static void test_IUriBuilder_GetPort(IUriBuilder *builder, const uri_builder_test *test,
8837                                      DWORD test_index) {
8838     HRESULT hr;
8839     BOOL has_port = FALSE;
8840     DWORD received = -1;
8841
8842     if(test->port_prop.change) {
8843         DWORD expected = test->port_prop.value;
8844
8845         hr = IUriBuilder_GetPort(builder, &has_port, &received);
8846         if(test->port_prop.todo) {
8847             todo_wine {
8848                 ok(hr == S_OK,
8849                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8850                     hr, S_OK, test_index);
8851             }
8852             if(SUCCEEDED(hr)) {
8853                 todo_wine {
8854                     ok(has_port == test->port_prop.set,
8855                         "Error: Expected has_port to be %d but was %d instead on uri_builder_tests[%d].\n",
8856                         test->port_prop.set, has_port, test_index);
8857                 }
8858                 todo_wine {
8859                     ok(received == expected,
8860                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8861                         expected, received, test_index);
8862                 }
8863             }
8864         } else {
8865             ok(hr == S_OK,
8866                 "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8867                 hr, S_OK, test_index);
8868             ok(has_port == test->port_prop.set,
8869                 "Error: Expected has_port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8870                 test->port_prop.set, has_port, test_index);
8871             ok(received == test->port_prop.value,
8872                 "Error: Expected port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8873                 test->port_prop.value, received, test_index);
8874         }
8875     } else {
8876         IUri *uri = NULL;
8877
8878         hr = IUriBuilder_GetIUri(builder, &uri);
8879         ok(hr == S_OK,
8880             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8881             hr, S_OK, test_index);
8882         if(SUCCEEDED(hr)) {
8883             if(!uri) {
8884                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8885                 ok(hr == S_OK,
8886                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8887                     hr, S_OK, test_index);
8888                 if(SUCCEEDED(hr)) {
8889                     ok(has_port == FALSE,
8890                         "Error: Expected has_port to be FALSE, but was %d instead on uri_builder_tests[%d].\n",
8891                         has_port, test_index);
8892                     ok(!received, "Error: Expected received to be 0, but was %d instead on uri_builder_tests[%d].\n",
8893                         received, test_index);
8894                 }
8895             } else {
8896                 DWORD expected;
8897
8898                 hr = IUri_GetPort(uri, &expected);
8899                 ok(SUCCEEDED(hr),
8900                     "Error: Expected IUri_Port to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8901                     hr, test_index);
8902
8903                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8904                 ok(hr == S_OK,
8905                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8906                     hr, S_OK, test_index);
8907                 if(SUCCEEDED(hr)) {
8908                     ok(!has_port,
8909                         "Error: Expected has_port to be FALSE but was TRUE instead on uri_builder_tests[%d].\n",
8910                         test_index);
8911                     ok(received == expected,
8912                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8913                         expected, received, test_index);
8914                 }
8915             }
8916         }
8917         if(uri) IUri_Release(uri);
8918     }
8919 }
8920
8921 static void test_IUriBuilder_GetQuery(IUriBuilder *builder, const uri_builder_test *test,
8922                                       DWORD test_index) {
8923     HRESULT hr;
8924     DWORD i;
8925     LPCWSTR received = NULL;
8926     DWORD len = -1;
8927     const uri_builder_property *prop = NULL;
8928
8929     /* Check if the property was set earlier. */
8930     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8931         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_QUERY)
8932             prop = &(test->properties[i]);
8933     }
8934
8935     if(prop) {
8936         /* Use expected_value unless it's NULL, then use value. */
8937         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8938         hr = IUriBuilder_GetQuery(builder, &len, &received);
8939         if(prop->todo) {
8940             todo_wine {
8941                 ok(hr == (expected ? S_OK : S_FALSE),
8942                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8943                     hr, (expected ? S_OK : S_FALSE), test_index);
8944             }
8945             if(SUCCEEDED(hr)) {
8946                 todo_wine {
8947                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8948                         expected, wine_dbgstr_w(received), test_index);
8949                 }
8950                 todo_wine {
8951                     ok(lstrlen(expected) == len,
8952                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8953                         lstrlen(expected), len, test_index);
8954                 }
8955             }
8956         } else {
8957             ok(hr == (expected ? S_OK : S_FALSE),
8958                 "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8959                 hr, (expected ? S_OK : S_FALSE), test_index);
8960             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8961                 expected, wine_dbgstr_w(received), test_index);
8962             ok(lstrlen(expected) == len,
8963                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8964                 lstrlen(expected), len, test_index);
8965         }
8966     } else {
8967         /* The property wasn't set earlier, so it should return whatever
8968          * the base IUri contains (if anything).
8969          */
8970         IUri *uri = NULL;
8971         hr = IUriBuilder_GetIUri(builder, &uri);
8972         ok(hr == S_OK,
8973             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8974             hr, S_OK, test_index);
8975         if(SUCCEEDED(hr)) {
8976             if(!uri) {
8977                 received = (void*) 0xdeadbeef;
8978                 len = -1;
8979
8980                 hr = IUriBuilder_GetQuery(builder, &len, &received);
8981                 ok(hr == S_FALSE,
8982                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8983                     hr, S_FALSE, test_index);
8984                 if(SUCCEEDED(hr)) {
8985                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8986                         len, test_index);
8987                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8988                         received, test_index);
8989                 }
8990             } else {
8991                 BOOL has_prop = FALSE;
8992                 BSTR expected = NULL;
8993
8994                 hr = IUri_GetQuery(uri, &expected);
8995                 ok(SUCCEEDED(hr),
8996                     "Error: Expected IUri_GetQuery to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8997                     hr, test_index);
8998                 has_prop = hr == S_OK;
8999
9000                 hr = IUriBuilder_GetQuery(builder, &len, &received);
9001                 if(has_prop) {
9002                     ok(hr == S_OK,
9003                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9004                         hr, S_OK, test_index);
9005                     if(SUCCEEDED(hr)) {
9006                         ok(!lstrcmpW(expected, received),
9007                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
9008                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
9009                         ok(lstrlenW(expected) == len,
9010                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9011                             lstrlenW(expected), len, test_index);
9012                     }
9013                 } else {
9014                     ok(hr == S_FALSE,
9015                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9016                         hr, S_FALSE, test_index);
9017                     if(SUCCEEDED(hr)) {
9018                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
9019                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
9020                             len, test_index);
9021                     }
9022                 }
9023                 SysFreeString(expected);
9024             }
9025         }
9026         if(uri) IUri_Release(uri);
9027     }
9028 }
9029
9030 static void test_IUriBuilder_GetSchemeName(IUriBuilder *builder, const uri_builder_test *test,
9031                                            DWORD test_index) {
9032     HRESULT hr;
9033     DWORD i;
9034     LPCWSTR received = NULL;
9035     DWORD len = -1;
9036     const uri_builder_property *prop = NULL;
9037
9038     /* Check if the property was set earlier. */
9039     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
9040         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_SCHEME_NAME)
9041             prop = &(test->properties[i]);
9042     }
9043
9044     if(prop) {
9045         /* Use expected_value unless it's NULL, then use value. */
9046         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
9047         hr = IUriBuilder_GetSchemeName(builder, &len, &received);
9048         if(prop->todo) {
9049             todo_wine {
9050                 ok(hr == (expected ? S_OK : S_FALSE),
9051                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9052                     hr, (expected ? S_OK : S_FALSE), test_index);
9053             }
9054             if(SUCCEEDED(hr)) {
9055                 todo_wine {
9056                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
9057                         expected, wine_dbgstr_w(received), test_index);
9058                 }
9059                 todo_wine {
9060                     ok(lstrlen(expected) == len,
9061                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9062                         lstrlen(expected), len, test_index);
9063                 }
9064             }
9065         } else {
9066             ok(hr == (expected ? S_OK : S_FALSE),
9067                 "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9068                 hr, (expected ? S_OK : S_FALSE), test_index);
9069             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
9070                 expected, wine_dbgstr_w(received), test_index);
9071             ok(lstrlen(expected) == len,
9072                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9073                 lstrlen(expected), len, test_index);
9074         }
9075     } else {
9076         /* The property wasn't set earlier, so it should return whatever
9077          * the base IUri contains (if anything).
9078          */
9079         IUri *uri = NULL;
9080         hr = IUriBuilder_GetIUri(builder, &uri);
9081         ok(hr == S_OK,
9082             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9083             hr, S_OK, test_index);
9084         if(SUCCEEDED(hr)) {
9085             if(!uri) {
9086                 received = (void*) 0xdeadbeef;
9087                 len = -1;
9088
9089                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
9090                 ok(hr == S_FALSE,
9091                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9092                     hr, S_FALSE, test_index);
9093                 if(SUCCEEDED(hr)) {
9094                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
9095                         len, test_index);
9096                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
9097                         received, test_index);
9098                 }
9099             } else {
9100                 BOOL has_prop = FALSE;
9101                 BSTR expected = NULL;
9102
9103                 hr = IUri_GetSchemeName(uri, &expected);
9104                 ok(SUCCEEDED(hr),
9105                     "Error: Expected IUri_GetSchemeName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
9106                     hr, test_index);
9107                 has_prop = hr == S_OK;
9108
9109                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
9110                 if(has_prop) {
9111                     ok(hr == S_OK,
9112                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9113                         hr, S_OK, test_index);
9114                     if(SUCCEEDED(hr)) {
9115                         ok(!lstrcmpW(expected, received),
9116                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
9117                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
9118                         ok(lstrlenW(expected) == len,
9119                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9120                             lstrlenW(expected), len, test_index);
9121                     }
9122                 } else {
9123                     ok(hr == S_FALSE,
9124                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9125                         hr, S_FALSE, test_index);
9126                     if(SUCCEEDED(hr)) {
9127                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
9128                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
9129                             len, test_index);
9130                     }
9131                 }
9132                 SysFreeString(expected);
9133             }
9134         }
9135         if(uri) IUri_Release(uri);
9136     }
9137 }
9138
9139 static void test_IUriBuilder_GetUserName(IUriBuilder *builder, const uri_builder_test *test,
9140                                          DWORD test_index) {
9141     HRESULT hr;
9142     DWORD i;
9143     LPCWSTR received = NULL;
9144     DWORD len = -1;
9145     const uri_builder_property *prop = NULL;
9146
9147     /* Check if the property was set earlier. */
9148     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
9149         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_USER_NAME)
9150             prop = &(test->properties[i]);
9151     }
9152
9153     if(prop && prop->value && *prop->value) {
9154         /* Use expected_value unless it's NULL, then use value. */
9155         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
9156         hr = IUriBuilder_GetUserName(builder, &len, &received);
9157         if(prop->todo) {
9158             todo_wine {
9159                 ok(hr == (expected ? S_OK : S_FALSE),
9160                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9161                     hr, (expected ? S_OK : S_FALSE), test_index);
9162             }
9163             if(SUCCEEDED(hr)) {
9164                 todo_wine {
9165                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
9166                         expected, wine_dbgstr_w(received), test_index);
9167                 }
9168                 todo_wine {
9169                     ok(lstrlen(expected) == len,
9170                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9171                         lstrlen(expected), len, test_index);
9172                 }
9173             }
9174         } else {
9175             ok(hr == (expected ? S_OK : S_FALSE),
9176                 "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9177                 hr, (expected ? S_OK : S_FALSE), test_index);
9178             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
9179                 expected, wine_dbgstr_w(received), test_index);
9180             ok(lstrlen(expected) == len,
9181                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9182                 lstrlen(expected), len, test_index);
9183         }
9184     } else {
9185         /* The property wasn't set earlier, so it should return whatever
9186          * the base IUri contains (if anything).
9187          */
9188         IUri *uri = NULL;
9189         hr = IUriBuilder_GetIUri(builder, &uri);
9190         ok(hr == S_OK,
9191             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9192             hr, S_OK, test_index);
9193         if(SUCCEEDED(hr)) {
9194             if(!uri) {
9195                 received = (void*) 0xdeadbeef;
9196                 len = -1;
9197
9198                 hr = IUriBuilder_GetUserName(builder, &len, &received);
9199                 ok(hr == S_FALSE,
9200                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9201                     hr, S_FALSE, test_index);
9202                 if(SUCCEEDED(hr)) {
9203                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
9204                         len, test_index);
9205                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
9206                         received, test_index);
9207                 }
9208             } else {
9209                 BSTR expected = NULL;
9210                 BOOL has_prop = FALSE;
9211
9212                 hr = IUri_GetUserName(uri, &expected);
9213                 ok(SUCCEEDED(hr),
9214                     "Error: Expected IUri_GetUserName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
9215                     hr, test_index);
9216                 has_prop = hr == S_OK;
9217
9218                 hr = IUriBuilder_GetUserName(builder, &len, &received);
9219                 if(has_prop) {
9220                     ok(hr == S_OK,
9221                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9222                         hr, S_OK, test_index);
9223                     if(SUCCEEDED(hr)) {
9224                         ok(!lstrcmpW(expected, received),
9225                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
9226                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
9227                         ok(lstrlenW(expected) == len,
9228                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9229                             lstrlenW(expected), len, test_index);
9230                     }
9231                 } else {
9232                     ok(hr == S_FALSE,
9233                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9234                         hr, S_FALSE, test_index);
9235                     if(SUCCEEDED(hr)) {
9236                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
9237                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
9238                             len, test_index);
9239                     }
9240                 }
9241                 SysFreeString(expected);
9242             }
9243         }
9244         if(uri) IUri_Release(uri);
9245     }
9246 }
9247
9248 /* Tests IUriBuilder functions. */
9249 static void test_IUriBuilder(void) {
9250     HRESULT hr;
9251     IUriBuilder *builder;
9252     DWORD i;
9253
9254     for(i = 0; i < sizeof(uri_builder_tests)/sizeof(uri_builder_tests[0]); ++i) {
9255         IUri *uri = NULL;
9256         uri_builder_test test = uri_builder_tests[i];
9257         LPWSTR uriW = NULL;
9258
9259         if(test.uri) {
9260             uriW = a2w(test.uri);
9261             hr = pCreateUri(uriW, test.create_flags, 0, &uri);
9262             ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9263                 hr, S_OK, i);
9264             if(FAILED(hr)) continue;
9265         }
9266         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9267         if(test.create_builder_todo) {
9268             todo_wine {
9269                 ok(hr == test.create_builder_expected,
9270                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9271                     hr, test.create_builder_expected, i);
9272             }
9273         } else {
9274             ok(hr == test.create_builder_expected,
9275                 "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9276                 hr, test.create_builder_expected, i);
9277         }
9278         if(SUCCEEDED(hr)) {
9279             DWORD j;
9280             BOOL modified = FALSE, received = FALSE;
9281
9282             /* Perform all the string property changes. */
9283             for(j = 0; j < URI_BUILDER_STR_PROPERTY_COUNT; ++j) {
9284                 uri_builder_property prop = test.properties[j];
9285                 if(prop.change) {
9286                     change_property(builder, &prop, i);
9287                     if(prop.property != Uri_PROPERTY_SCHEME_NAME &&
9288                        prop.property != Uri_PROPERTY_HOST)
9289                         modified = TRUE;
9290                     else if(prop.value && *prop.value)
9291                         modified = TRUE;
9292                     else if(prop.value && !*prop.value && prop.property == Uri_PROPERTY_HOST)
9293                         /* Host name property can't be NULL, but it can be empty. */
9294                         modified = TRUE;
9295                 }
9296             }
9297
9298             if(test.port_prop.change) {
9299                 hr = IUriBuilder_SetPort(builder, test.port_prop.set, test.port_prop.value);
9300                 modified = TRUE;
9301                 if(test.port_prop.todo) {
9302                     todo_wine {
9303                         ok(hr == test.port_prop.expected,
9304                             "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9305                             hr, test.port_prop.expected, i);
9306                     }
9307                 } else {
9308                     ok(hr == test.port_prop.expected,
9309                         "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9310                         hr, test.port_prop.expected, i);
9311                 }
9312             }
9313
9314             hr = IUriBuilder_HasBeenModified(builder, &received);
9315             ok(hr == S_OK,
9316                 "Error IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9317                 hr, S_OK, i);
9318             if(SUCCEEDED(hr))
9319                 ok(received == modified,
9320                     "Error: Expected received to be %d but was %d instead on uri_builder_tests[%d].\n",
9321                     modified, received, i);
9322
9323             /* Test the "Get*" functions. */
9324             test_IUriBuilder_GetFragment(builder, &test, i);
9325             test_IUriBuilder_GetHost(builder, &test, i);
9326             test_IUriBuilder_GetPassword(builder, &test, i);
9327             test_IUriBuilder_GetPath(builder, &test, i);
9328             test_IUriBuilder_GetPort(builder, &test, i);
9329             test_IUriBuilder_GetQuery(builder, &test, i);
9330             test_IUriBuilder_GetSchemeName(builder, &test, i);
9331             test_IUriBuilder_GetUserName(builder, &test, i);
9332
9333             test_IUriBuilder_CreateUri(builder, &test, i);
9334             test_IUriBuilder_CreateUriSimple(builder, &test, i);
9335             test_IUriBuilder_CreateUriWithFlags(builder, &test, i);
9336         }
9337         if(builder) IUriBuilder_Release(builder);
9338         if(uri) IUri_Release(uri);
9339         heap_free(uriW);
9340     }
9341 }
9342
9343 static void test_IUriBuilder_HasBeenModified(void) {
9344     HRESULT hr;
9345     IUriBuilder *builder = NULL;
9346
9347     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9348     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9349     if(SUCCEEDED(hr)) {
9350         static const WCHAR hostW[] = {'g','o','o','g','l','e','.','c','o','m',0};
9351         IUri *uri = NULL;
9352         BOOL received;
9353
9354         hr = IUriBuilder_HasBeenModified(builder, NULL);
9355         ok(hr == E_POINTER, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9356             hr, E_POINTER);
9357
9358         hr = IUriBuilder_SetHost(builder, hostW);
9359         ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n",
9360             hr, S_OK);
9361
9362         hr = IUriBuilder_HasBeenModified(builder, &received);
9363         ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9364             hr, S_OK);
9365         if(SUCCEEDED(hr))
9366             ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9367
9368         hr = pCreateUri(http_urlW, 0, 0, &uri);
9369         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9370         if(SUCCEEDED(hr)) {
9371             LPCWSTR prop;
9372             DWORD len = -1;
9373
9374             hr = IUriBuilder_SetIUri(builder, uri);
9375             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n",
9376                 hr, S_OK);
9377
9378             hr = IUriBuilder_HasBeenModified(builder, &received);
9379             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9380                 hr, S_OK);
9381             if(SUCCEEDED(hr))
9382                 ok(received == FALSE, "Error: Expected received to be FALSE.\n");
9383
9384             /* Test what happens with you call SetIUri with the same IUri again. */
9385             hr = IUriBuilder_SetHost(builder, hostW);
9386             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9387
9388             hr = IUriBuilder_HasBeenModified(builder, &received);
9389             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9390                 hr, S_OK);
9391             if(SUCCEEDED(hr))
9392                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9393
9394             hr = IUriBuilder_SetIUri(builder, uri);
9395             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9396
9397             /* IUriBuilder already had 'uri' as it's IUri property and so Windows doesn't
9398              * reset any of the changes that were made to the IUriBuilder.
9399              */
9400             hr = IUriBuilder_HasBeenModified(builder, &received);
9401             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9402             if(SUCCEEDED(hr))
9403                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9404
9405             hr = IUriBuilder_GetHost(builder, &len, &prop);
9406             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9407             if(SUCCEEDED(hr)) {
9408                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
9409                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
9410                 ok(len == lstrlenW(hostW), "Error: Expected len to be %d, but was %d instead.\n",
9411                     lstrlenW(hostW), len);
9412             }
9413
9414             hr = IUriBuilder_SetIUri(builder, NULL);
9415             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9416
9417             hr = IUriBuilder_SetHost(builder, hostW);
9418             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9419             hr = IUriBuilder_HasBeenModified(builder, &received);
9420             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9421                 hr, S_OK);
9422             if(SUCCEEDED(hr))
9423                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9424
9425             hr = IUriBuilder_SetIUri(builder, NULL);
9426             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%09x.\n", hr, S_OK);
9427
9428             hr = IUriBuilder_HasBeenModified(builder, &received);
9429             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9430                 hr, S_OK);
9431             if(SUCCEEDED(hr))
9432                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9433
9434             hr = IUriBuilder_GetHost(builder, &len, &prop);
9435             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9436             if(SUCCEEDED(hr)) {
9437                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
9438                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
9439                 ok(len == lstrlenW(hostW), "Error: Expected len to %d, but was %d instead.\n",
9440                     lstrlenW(hostW), len);
9441             }
9442         }
9443         if(uri) IUri_Release(uri);
9444     }
9445     if(builder) IUriBuilder_Release(builder);
9446 }
9447
9448 /* Test IUriBuilder {Get,Set}IUri functions. */
9449 static void test_IUriBuilder_IUriProperty(void) {
9450     IUriBuilder *builder = NULL;
9451     HRESULT hr;
9452
9453     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9454     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9455     if(SUCCEEDED(hr)) {
9456         IUri *uri = NULL;
9457
9458         hr = IUriBuilder_GetIUri(builder, NULL);
9459         ok(hr == E_POINTER, "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x.\n",
9460             hr, E_POINTER);
9461
9462         hr = pCreateUri(http_urlW, 0, 0, &uri);
9463         if(SUCCEEDED(hr)) {
9464             IUri *test = NULL;
9465             ULONG cur_count, orig_count;
9466
9467             /* IUriBuilder doesn't clone the IUri, it use the same IUri. */
9468             orig_count = get_refcnt(uri);
9469             hr = IUriBuilder_SetIUri(builder, uri);
9470             cur_count = get_refcnt(uri);
9471             if(SUCCEEDED(hr))
9472                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9473                     orig_count+1, cur_count);
9474
9475             hr = IUriBuilder_SetIUri(builder, NULL);
9476             cur_count = get_refcnt(uri);
9477             if(SUCCEEDED(hr))
9478                 ok(cur_count == orig_count, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9479                     orig_count, cur_count);
9480
9481             /* CreateUri* functions will return back the same IUri if nothing has changed. */
9482             hr = IUriBuilder_SetIUri(builder, uri);
9483             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9484             orig_count = get_refcnt(uri);
9485
9486             hr = IUriBuilder_CreateUri(builder, 0, 0, 0, &test);
9487             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9488             if(SUCCEEDED(hr)) {
9489                 cur_count = get_refcnt(uri);
9490                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9491                     orig_count+1, cur_count);
9492                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n",
9493                     uri, test);
9494             }
9495             if(test) IUri_Release(test);
9496
9497             test = NULL;
9498             hr = IUriBuilder_CreateUri(builder, -1, 0, 0, &test);
9499             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9500             if(SUCCEEDED(hr)) {
9501                 cur_count = get_refcnt(uri);
9502                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9503                     orig_count+1, cur_count);
9504                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9505             }
9506             if(test) IUri_Release(test);
9507
9508             /* Doesn't return the same IUri, if the flag combination is different then the one that created
9509              * the base IUri.
9510              */
9511             test = NULL;
9512             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, &test);
9513             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9514             if(SUCCEEDED(hr))
9515                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
9516
9517             if(test) IUri_Release(test);
9518
9519             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
9520              * explicitly set (because it's a default flags).
9521              */
9522             test = NULL;
9523             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_CANONICALIZE, 0, 0, &test);
9524             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9525             if(SUCCEEDED(hr)) {
9526                 cur_count = get_refcnt(uri);
9527                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9528                     orig_count+1, cur_count);
9529                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
9530             }
9531             if(test) IUri_Release(test);
9532
9533             test = NULL;
9534             hr = IUriBuilder_CreateUriSimple(builder, 0, 0, &test);
9535             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9536             if(SUCCEEDED(hr)) {
9537                 cur_count = get_refcnt(uri);
9538                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9539                     orig_count+1, cur_count);
9540                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9541             }
9542             if(test) IUri_Release(test);
9543
9544             test = NULL;
9545             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &test);
9546             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
9547                 hr, S_OK);
9548             if(SUCCEEDED(hr)) {
9549                 cur_count = get_refcnt(uri);
9550                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9551                     orig_count+1, cur_count);
9552                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9553             }
9554             if(test) IUri_Release(test);
9555
9556             /* Doesn't return the same IUri, if the flag combination is different then the one that created
9557              * the base IUri.
9558              */
9559             test = NULL;
9560             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, 0, &test);
9561             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9562             if(SUCCEEDED(hr))
9563                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
9564
9565             if(test) IUri_Release(test);
9566
9567             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
9568              * explicitly set (because it's a default flags).
9569              */
9570             test = NULL;
9571             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_CANONICALIZE, 0, 0, 0, &test);
9572             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9573             if(SUCCEEDED(hr)) {
9574                 cur_count = get_refcnt(uri);
9575                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9576                     orig_count+1, cur_count);
9577                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
9578             }
9579             if(test) IUri_Release(test);
9580         }
9581         if(uri) IUri_Release(uri);
9582     }
9583     if(builder) IUriBuilder_Release(builder);
9584 }
9585
9586 static void test_IUriBuilder_RemoveProperties(void) {
9587     IUriBuilder *builder = NULL;
9588     HRESULT hr;
9589     DWORD i;
9590
9591     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9592     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9593     if(SUCCEEDED(hr)) {
9594         /* Properties that can't be removed. */
9595         const DWORD invalid = Uri_HAS_ABSOLUTE_URI|Uri_HAS_DISPLAY_URI|Uri_HAS_RAW_URI|Uri_HAS_HOST_TYPE|
9596                               Uri_HAS_SCHEME|Uri_HAS_ZONE;
9597
9598         for(i = Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_DWORD_LAST; ++i) {
9599             hr = IUriBuilder_RemoveProperties(builder, i << 1);
9600             if((i << 1) & invalid) {
9601                 ok(hr == E_INVALIDARG,
9602                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
9603                     hr, E_INVALIDARG, i);
9604             } else {
9605                 ok(hr == S_OK,
9606                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
9607                     hr, S_OK, i);
9608             }
9609         }
9610
9611         /* Also doesn't accept anything that's outside the range of the
9612          * Uri_HAS flags.
9613          */
9614         hr = IUriBuilder_RemoveProperties(builder, (Uri_PROPERTY_DWORD_LAST+1) << 1);
9615         ok(hr == E_INVALIDARG, "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x.\n",
9616             hr, E_INVALIDARG);
9617     }
9618     if(builder) IUriBuilder_Release(builder);
9619
9620     for(i = 0; i < sizeof(uri_builder_remove_tests)/sizeof(uri_builder_remove_tests[0]); ++i) {
9621         uri_builder_remove_test test = uri_builder_remove_tests[i];
9622         IUri *uri = NULL;
9623         LPWSTR uriW;
9624
9625         uriW = a2w(test.uri);
9626         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
9627         if(SUCCEEDED(hr)) {
9628             builder = NULL;
9629
9630             hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9631             if(test.create_builder_todo) {
9632                 todo_wine {
9633                     ok(hr == test.create_builder_expected,
9634                         "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9635                         hr, test.create_builder_expected, i);
9636                 }
9637             } else {
9638                 ok(hr == test.create_builder_expected,
9639                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9640                     hr, test.create_builder_expected, i);
9641             }
9642             if(SUCCEEDED(hr)) {
9643                 hr = IUriBuilder_RemoveProperties(builder, test.remove_properties);
9644                 if(test.remove_todo) {
9645                     todo_wine {
9646                         ok(hr == test.remove_expected,
9647                             "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x on test %d.\n",
9648                             hr, test.remove_expected, i);
9649                     }
9650                 } else {
9651                     ok(hr == test.remove_expected,
9652                         "Error: IUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9653                         hr, test.remove_expected, i);
9654                 }
9655                 if(SUCCEEDED(hr)) {
9656                     IUri *result = NULL;
9657
9658                     hr = IUriBuilder_CreateUri(builder, test.expected_flags, 0, 0, &result);
9659                     if(test.expected_todo) {
9660                         todo_wine {
9661                             ok(hr == test.expected_hres,
9662                                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
9663                                 hr, test.expected_hres, i);
9664                         }
9665                     } else {
9666                         ok(hr == test.expected_hres,
9667                             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
9668                             hr, test.expected_hres, i);
9669                     }
9670                     if(SUCCEEDED(hr)) {
9671                         BSTR received = NULL;
9672
9673                         hr = IUri_GetAbsoluteUri(result, &received);
9674                         ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
9675                         ok(!strcmp_aw(test.expected_uri, received),
9676                             "Error: Expected %s but got %s instead on test %d.\n",
9677                             test.expected_uri, wine_dbgstr_w(received), i);
9678                         SysFreeString(received);
9679                     }
9680                     if(result) IUri_Release(result);
9681                 }
9682             }
9683             if(builder) IUriBuilder_Release(builder);
9684         }
9685         if(uri) IUri_Release(uri);
9686         heap_free(uriW);
9687     }
9688 }
9689
9690 static void test_IUriBuilder_Misc(void) {
9691     HRESULT hr;
9692     IUri *uri;
9693
9694     hr = pCreateUri(http_urlW, 0, 0, &uri);
9695     if(SUCCEEDED(hr)) {
9696         IUriBuilder *builder;
9697
9698         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9699         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9700         if(SUCCEEDED(hr)) {
9701             BOOL has = -1;
9702             DWORD port = -1;
9703
9704             hr = IUriBuilder_GetPort(builder, &has, &port);
9705             ok(hr == S_OK, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9706             if(SUCCEEDED(hr)) {
9707                 /* 'has' will be set to FALSE, even though uri had a port. */
9708                 ok(has == FALSE, "Error: Expected 'has' to be FALSE, was %d instead.\n", has);
9709                 /* Still sets 'port' to 80. */
9710                 ok(port == 80, "Error: Expected the port to be 80, but, was %d instead.\n", port);
9711             }
9712         }
9713         if(builder) IUriBuilder_Release(builder);
9714     }
9715     if(uri) IUri_Release(uri);
9716 }
9717
9718 static void test_IUriBuilderFactory(void) {
9719     HRESULT hr;
9720     IUri *uri;
9721     IUriBuilderFactory *factory;
9722     IUriBuilder *builder;
9723
9724     hr = pCreateUri(http_urlW, 0, 0, &uri);
9725     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9726     if(SUCCEEDED(hr)) {
9727         factory = NULL;
9728         hr = IUri_QueryInterface(uri, &IID_IUriBuilderFactory, (void**)&factory);
9729         ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x.\n", hr);
9730         ok(factory != NULL, "Error: Expected 'factory' to not be NULL.\n");
9731
9732         if(SUCCEEDED(hr)) {
9733             builder = (void*) 0xdeadbeef;
9734             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 10, 0, &builder);
9735             ok(hr == E_INVALIDARG, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9736                 hr, E_INVALIDARG);
9737             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9738
9739             builder = (void*) 0xdeadbeef;
9740             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 10, &builder);
9741             ok(hr == E_INVALIDARG, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9742                 hr, E_INVALIDARG);
9743             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9744
9745             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 0, NULL);
9746             ok(hr == E_POINTER, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9747                 hr, E_POINTER);
9748
9749             builder = NULL;
9750             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 0, &builder);
9751             ok(hr == S_OK, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9752                 hr, S_OK);
9753             if(SUCCEEDED(hr)) {
9754                 IUri *tmp = (void*) 0xdeadbeef;
9755                 LPCWSTR result;
9756                 DWORD result_len;
9757
9758                 hr = IUriBuilder_GetIUri(builder, &tmp);
9759                 ok(hr == S_OK, "Error: GetIUri returned 0x%08x, expected 0x%08x.\n",
9760                     hr, S_OK);
9761                 ok(!tmp, "Error: Expected 'tmp' to be NULL, but was %p instead.\n", tmp);
9762
9763                 hr = IUriBuilder_GetHost(builder, &result_len, &result);
9764                 ok(hr == S_FALSE, "Error: GetHost returned 0x%08x, expected 0x%08x.\n",
9765                     hr, S_FALSE);
9766             }
9767             if(builder) IUriBuilder_Release(builder);
9768
9769             builder = (void*) 0xdeadbeef;
9770             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 10, 0, &builder);
9771             ok(hr == E_INVALIDARG, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9772                 hr, E_INVALIDARG);
9773             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9774
9775             builder = (void*) 0xdeadbeef;
9776             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 10, &builder);
9777             ok(hr == E_INVALIDARG, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9778                 hr, E_INVALIDARG);
9779             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9780
9781             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 0, NULL);
9782             ok(hr == E_POINTER, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9783                 hr, E_POINTER);
9784
9785             builder = NULL;
9786             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 0, &builder);
9787             ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9788                 hr, S_OK);
9789             if(SUCCEEDED(hr)) {
9790                 IUri *tmp = NULL;
9791
9792                 hr = IUriBuilder_GetIUri(builder, &tmp);
9793                 ok(hr == S_OK, "Error: GetIUri return 0x%08x, expected 0x%08x.\n",
9794                     hr, S_OK);
9795                 ok(tmp == uri, "Error: Expected tmp to be %p, but was %p.\n", uri, tmp);
9796                 if(uri) IUri_Release(uri);
9797             }
9798             if(builder) IUriBuilder_Release(builder);
9799         }
9800         if(factory) IUriBuilderFactory_Release(factory);
9801     }
9802     if(uri) IUri_Release(uri);
9803 }
9804
9805 static void test_CoInternetCombineIUri(void) {
9806     HRESULT hr;
9807     IUri *base, *relative, *result;
9808     DWORD i;
9809
9810     base = NULL;
9811     hr = pCreateUri(http_urlW, 0, 0, &base);
9812     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9813     if(SUCCEEDED(hr)) {
9814         result = (void*) 0xdeadbeef;
9815         hr = pCoInternetCombineIUri(base, NULL, 0, &result, 0);
9816         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9817         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9818     }
9819
9820     relative = NULL;
9821     hr = pCreateUri(http_urlW, 0, 0, &relative);
9822     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9823     if(SUCCEEDED(hr)) {
9824         result = (void*) 0xdeadbeef;
9825         hr = pCoInternetCombineIUri(NULL, relative, 0, &result, 0);
9826         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9827         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9828     }
9829
9830     hr = pCoInternetCombineIUri(base, relative, 0, NULL, 0);
9831     ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9832
9833     if(base) IUri_Release(base);
9834     if(relative) IUri_Release(relative);
9835
9836     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
9837         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
9838
9839         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
9840         ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9841         if(SUCCEEDED(hr)) {
9842             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
9843
9844             hr = pCreateUri(relativeW, uri_combine_tests[i].relative_create_flags, 0, &relative);
9845             ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9846             if(SUCCEEDED(hr)) {
9847                 result = NULL;
9848
9849                 hr = pCoInternetCombineIUri(base, relative, uri_combine_tests[i].combine_flags, &result, 0);
9850                 if(uri_combine_tests[i].todo) {
9851                     todo_wine {
9852                         ok(hr == uri_combine_tests[i].expected,
9853                             "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9854                             hr, uri_combine_tests[i].expected, i);
9855                     }
9856                 } else {
9857                     ok(hr == uri_combine_tests[i].expected,
9858                         "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9859                         hr, uri_combine_tests[i]. expected, i);
9860                 }
9861                 if(SUCCEEDED(hr)) {
9862                     DWORD j;
9863
9864                     for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
9865                         uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
9866                         BSTR received;
9867
9868                         hr = IUri_GetPropertyBSTR(result, j, &received, 0);
9869                         if(prop.todo) {
9870                             todo_wine {
9871                                 ok(hr == prop.expected,
9872                                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9873                                     hr, prop.expected, i, j);
9874                             }
9875                             todo_wine {
9876                                 ok(!strcmp_aw(prop.value, received) ||
9877                                    broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9878                                     "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9879                                     prop.value, wine_dbgstr_w(received), i, j);
9880                             }
9881                         } else {
9882                             ok(hr == prop.expected,
9883                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9884                                 hr, prop.expected, i, j);
9885                             ok(!strcmp_aw(prop.value, received) ||
9886                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9887                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9888                                 prop.value, wine_dbgstr_w(received), i, j);
9889                         }
9890                         SysFreeString(received);
9891                     }
9892
9893                     for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
9894                         uri_dword_property prop = uri_combine_tests[i].dword_props[j];
9895                         DWORD received;
9896
9897                         hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
9898                         if(prop.todo) {
9899                             todo_wine {
9900                                 ok(hr == prop.expected,
9901                                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9902                                     hr, prop.expected, i, j);
9903                             }
9904                             todo_wine {
9905                                 ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9906                                     prop.value, received, i, j);
9907                             }
9908                         } else {
9909                             ok(hr == prop.expected,
9910                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9911                                 hr, prop.expected, i, j);
9912                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9913                                 prop.value, received, i, j);
9914                         }
9915                     }
9916                 }
9917                 if(result) IUri_Release(result);
9918             }
9919             if(relative) IUri_Release(relative);
9920             heap_free(relativeW);
9921         }
9922         if(base) IUri_Release(base);
9923         heap_free(baseW);
9924     }
9925 }
9926
9927 static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface,
9928                                                           REFIID riid, void **ppv)
9929 {
9930     ok(0, "unexpected call\n");
9931     return E_NOINTERFACE;
9932 }
9933
9934 static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
9935 {
9936     return 2;
9937 }
9938
9939 static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
9940 {
9941     return 1;
9942 }
9943
9944 static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
9945         PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
9946         DWORD *pcchResult, DWORD dwReserved)
9947 {
9948     CHECK_EXPECT(ParseUrl);
9949     ok(!lstrcmpW(pwzUrl, parse_urlW), "Error: Expected %s, but got %s instead.\n",
9950         wine_dbgstr_w(parse_urlW), wine_dbgstr_w(pwzUrl));
9951     ok(ParseAction == parse_action, "Error: Expected %d, but got %d.\n", parse_action, ParseAction);
9952     ok(dwParseFlags == parse_flags, "Error: Expected 0x%08x, but got 0x%08x.\n", parse_flags, dwParseFlags);
9953     ok(cchResult == 200, "Error: Got %d.\n", cchResult);
9954
9955     memcpy(pwzResult, parse_resultW, sizeof(parse_resultW));
9956     *pcchResult = lstrlenW(parse_resultW);
9957
9958     return S_OK;
9959 }
9960
9961 static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
9962         LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags,
9963         LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
9964 {
9965     CHECK_EXPECT(CombineUrl);
9966     ok(!lstrcmpW(pwzBaseUrl, combine_baseW), "Error: Expected %s, but got %s instead.\n",
9967         wine_dbgstr_w(combine_baseW), wine_dbgstr_w(pwzBaseUrl));
9968     ok(!lstrcmpW(pwzRelativeUrl, combine_relativeW), "Error: Expected %s, but got %s instead.\n",
9969         wine_dbgstr_w(combine_relativeW), wine_dbgstr_w(pwzRelativeUrl));
9970     ok(dwCombineFlags == (URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO),
9971         "Error: Expected 0, but got 0x%08x.\n", dwCombineFlags);
9972     ok(cchResult == INTERNET_MAX_URL_LENGTH+1, "Error: Got %d.\n", cchResult);
9973
9974     memcpy(pwzResult, combine_resultW, sizeof(combine_resultW));
9975     *pcchResult = lstrlenW(combine_resultW);
9976
9977     return S_OK;
9978 }
9979
9980 static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface,
9981         LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
9982 {
9983     ok(0, "unexpected call\n");
9984     return E_NOTIMPL;
9985 }
9986
9987 static HRESULT WINAPI InternetProtocolInfo_QueryInfo(IInternetProtocolInfo *iface,
9988         LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer,
9989         DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
9990 {
9991     ok(0, "unexpected call\n");
9992     return E_NOTIMPL;
9993 }
9994
9995 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl = {
9996     InternetProtocolInfo_QueryInterface,
9997     InternetProtocolInfo_AddRef,
9998     InternetProtocolInfo_Release,
9999     InternetProtocolInfo_ParseUrl,
10000     InternetProtocolInfo_CombineUrl,
10001     InternetProtocolInfo_CompareUrl,
10002     InternetProtocolInfo_QueryInfo
10003 };
10004
10005 static IInternetProtocolInfo protocol_info = { &InternetProtocolInfoVtbl };
10006
10007 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
10008 {
10009     if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
10010         *ppv = &protocol_info;
10011         return S_OK;
10012     }
10013
10014     ok(0, "unexpected call\n");
10015     return E_NOINTERFACE;
10016 }
10017
10018 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
10019 {
10020     return 2;
10021 }
10022
10023 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
10024 {
10025     return 1;
10026 }
10027
10028 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
10029                                         REFIID riid, void **ppv)
10030 {
10031     ok(0, "unexpected call\n");
10032     return E_NOTIMPL;
10033 }
10034
10035 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
10036 {
10037     ok(0, "unexpected call\n");
10038     return S_OK;
10039 }
10040
10041 static const IClassFactoryVtbl ClassFactoryVtbl = {
10042     ClassFactory_QueryInterface,
10043     ClassFactory_AddRef,
10044     ClassFactory_Release,
10045     ClassFactory_CreateInstance,
10046     ClassFactory_LockServer
10047 };
10048
10049 static IClassFactory protocol_cf = { &ClassFactoryVtbl };
10050
10051 static void register_protocols(void)
10052 {
10053     IInternetSession *session;
10054     HRESULT hres;
10055
10056     hres = pCoInternetGetSession(0, &session, 0);
10057     ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
10058     if(FAILED(hres))
10059         return;
10060
10061     hres = IInternetSession_RegisterNameSpace(session, &protocol_cf, &IID_NULL,
10062             winetestW, 0, NULL, 0);
10063     ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
10064
10065     IInternetSession_Release(session);
10066 }
10067
10068 static void unregister_protocols(void) {
10069     IInternetSession *session;
10070     HRESULT hr;
10071
10072     hr = pCoInternetGetSession(0, &session, 0);
10073     ok(hr == S_OK, "CoInternetGetSession failed: 0x%08x\n", hr);
10074     if(FAILED(hr))
10075         return;
10076
10077     hr = IInternetSession_UnregisterNameSpace(session, &protocol_cf, winetestW);
10078     ok(hr == S_OK, "UnregisterNameSpace failed: 0x%08x\n", hr);
10079
10080     IInternetSession_Release(session);
10081 }
10082
10083 static void test_CoInternetCombineIUri_Pluggable(void) {
10084     HRESULT hr;
10085     IUri *base = NULL;
10086
10087     hr = pCreateUri(combine_baseW, 0, 0, &base);
10088     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10089     if(SUCCEEDED(hr)) {
10090         IUri *relative = NULL;
10091
10092         hr = pCreateUri(combine_relativeW, Uri_CREATE_ALLOW_RELATIVE, 0, &relative);
10093         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10094         if(SUCCEEDED(hr)) {
10095             IUri *result = NULL;
10096
10097             SET_EXPECT(CombineUrl);
10098
10099             hr = pCoInternetCombineIUri(base, relative, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
10100                                         &result, 0);
10101             ok(hr == S_OK, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
10102
10103             CHECK_CALLED(CombineUrl);
10104
10105             if(SUCCEEDED(hr)) {
10106                 BSTR received = NULL;
10107                 hr = IUri_GetAbsoluteUri(result, &received);
10108                 ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
10109                 if(SUCCEEDED(hr)) {
10110                     ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
10111                         wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
10112                 }
10113                 SysFreeString(received);
10114             }
10115             if(result) IUri_Release(result);
10116         }
10117         if(relative) IUri_Release(relative);
10118     }
10119     if(base) IUri_Release(base);
10120 }
10121
10122 static void test_CoInternetCombineUrlEx(void) {
10123     HRESULT hr;
10124     IUri *base, *result;
10125     DWORD i;
10126
10127     base = NULL;
10128     hr = pCreateUri(http_urlW, 0, 0, &base);
10129     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10130     if(SUCCEEDED(hr)) {
10131         result = (void*) 0xdeadbeef;
10132         hr = pCoInternetCombineUrlEx(base, NULL, 0, &result, 0);
10133         ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
10134             hr, E_UNEXPECTED);
10135         ok(!result, "Error: Expected 'result' to be NULL was %p instead.\n", result);
10136     }
10137
10138     result = (void*) 0xdeadbeef;
10139     hr = pCoInternetCombineUrlEx(NULL, http_urlW, 0, &result, 0);
10140     ok(hr == E_INVALIDARG, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
10141         hr, E_INVALIDARG);
10142     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
10143
10144     result = (void*) 0xdeadbeef;
10145     hr = pCoInternetCombineUrlEx(NULL, NULL, 0, &result, 0);
10146     ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
10147         hr, E_UNEXPECTED);
10148     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
10149
10150     hr = pCoInternetCombineUrlEx(base, http_urlW, 0, NULL, 0);
10151     ok(hr == E_POINTER, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
10152         hr, E_POINTER);
10153     if(base) IUri_Release(base);
10154
10155     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
10156         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
10157
10158         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
10159         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_combine_tests[%d].\n", hr, i);
10160         if(SUCCEEDED(hr)) {
10161             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
10162
10163             hr = pCoInternetCombineUrlEx(base, relativeW, uri_combine_tests[i].combine_flags,
10164                                          &result, 0);
10165             if(uri_combine_tests[i].todo) {
10166                 todo_wine {
10167                     ok(hr == uri_combine_tests[i].expected,
10168                         "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
10169                         hr, uri_combine_tests[i].expected, i);
10170                 }
10171             } else {
10172                 ok(hr == uri_combine_tests[i].expected,
10173                     "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
10174                     hr, uri_combine_tests[i]. expected, i);
10175             }
10176             if(SUCCEEDED(hr)) {
10177                 DWORD j;
10178
10179                 for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
10180                     uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
10181                     BSTR received;
10182                     LPCSTR value = (prop.value_ex) ? prop.value_ex : prop.value;
10183
10184                     hr = IUri_GetPropertyBSTR(result, j, &received, 0);
10185                     if(prop.todo) {
10186                         todo_wine {
10187                             ok(hr == prop.expected,
10188                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
10189                                 hr, prop.expected, i, j);
10190                         }
10191                         todo_wine {
10192                             ok(!strcmp_aw(value, received) ||
10193                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
10194                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
10195                                 value, wine_dbgstr_w(received), i, j);
10196                         }
10197                     } else {
10198                         ok(hr == prop.expected,
10199                             "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
10200                             hr, prop.expected, i, j);
10201                         ok(!strcmp_aw(value, received) ||
10202                            broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
10203                             "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
10204                             value, wine_dbgstr_w(received), i, j);
10205                     }
10206                     SysFreeString(received);
10207                 }
10208
10209                 for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
10210                     uri_dword_property prop = uri_combine_tests[i].dword_props[j];
10211                     DWORD received;
10212
10213                     hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
10214                     if(prop.todo) {
10215                         todo_wine {
10216                             ok(hr == prop.expected,
10217                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
10218                                 hr, prop.expected, i, j);
10219                         }
10220                         todo_wine {
10221                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
10222                                 prop.value, received, i, j);
10223                         }
10224                     } else {
10225                         ok(hr == prop.expected,
10226                             "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
10227                             hr, prop.expected, i, j);
10228                         ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
10229                             prop.value, received, i, j);
10230                     }
10231                 }
10232             }
10233             if(result) IUri_Release(result);
10234             heap_free(relativeW);
10235         }
10236         if(base) IUri_Release(base);
10237         heap_free(baseW);
10238     }
10239 }
10240
10241 static void test_CoInternetCombineUrlEx_Pluggable(void) {
10242     HRESULT hr;
10243     IUri *base = NULL;
10244
10245     hr = pCreateUri(combine_baseW, 0, 0, &base);
10246     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10247     if(SUCCEEDED(hr)) {
10248         IUri *result = NULL;
10249
10250         SET_EXPECT(CombineUrl);
10251
10252         hr = pCoInternetCombineUrlEx(base, combine_relativeW, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
10253                                      &result, 0);
10254         ok(hr == S_OK, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
10255
10256         CHECK_CALLED(CombineUrl);
10257
10258         if(SUCCEEDED(hr)) {
10259             BSTR received = NULL;
10260             hr = IUri_GetAbsoluteUri(result, &received);
10261             ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
10262             if(SUCCEEDED(hr)) {
10263                 ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
10264                     wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
10265             }
10266             SysFreeString(received);
10267         }
10268         if(result) IUri_Release(result);
10269     }
10270     if(base) IUri_Release(base);
10271 }
10272
10273 static void test_CoInternetParseIUri_InvalidArgs(void) {
10274     HRESULT hr;
10275     IUri *uri = NULL;
10276     WCHAR tmp[3];
10277     DWORD result = -1;
10278
10279     hr = pCoInternetParseIUri(NULL, PARSE_CANONICALIZE, 0, tmp, 3, &result, 0);
10280     ok(hr == E_INVALIDARG, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10281         hr, E_INVALIDARG);
10282     ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10283
10284     hr = pCreateUri(http_urlW, 0, 0, &uri);
10285     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10286     if(SUCCEEDED(hr)) {
10287         DWORD expected_len;
10288
10289         result = -1;
10290         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, NULL, 0, &result, 0);
10291         ok(hr == E_INVALIDARG, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10292             hr, E_INVALIDARG);
10293         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10294
10295         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, tmp, 3, NULL, 0);
10296         ok(hr == E_POINTER, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10297             hr, E_POINTER);
10298
10299         result = -1;
10300         hr = pCoInternetParseIUri(uri, PARSE_SECURITY_URL, 0, tmp, 3, &result, 0);
10301         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x expected 0x%08x.\n",
10302             hr, E_FAIL);
10303         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10304
10305         result = -1;
10306         hr = pCoInternetParseIUri(uri, PARSE_MIME, 0, tmp, 3, &result, 0);
10307         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10308             hr, E_FAIL);
10309         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10310
10311         result = -1;
10312         hr = pCoInternetParseIUri(uri, PARSE_SERVER, 0, tmp, 3, &result, 0);
10313         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10314             hr, E_FAIL);
10315         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10316
10317         result = -1;
10318         hr = pCoInternetParseIUri(uri, PARSE_SECURITY_DOMAIN, 0, tmp, 3, &result, 0);
10319         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10320             hr, E_FAIL);
10321         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10322
10323         expected_len = lstrlenW(http_urlW);
10324         result = -1;
10325         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, tmp, 3, &result, 0);
10326         ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER,
10327             "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10328             hr, STRSAFE_E_INSUFFICIENT_BUFFER);
10329         ok(result == expected_len, "Error: Expected 'result' to be %d, but was %d instead.\n",
10330             expected_len, result);
10331     }
10332     if(uri) IUri_Release(uri);
10333 }
10334
10335 static void test_CoInternetParseIUri(void) {
10336     DWORD i;
10337
10338     for(i = 0; i < sizeof(uri_parse_tests)/sizeof(uri_parse_tests[0]); ++i) {
10339         HRESULT hr;
10340         IUri *uri;
10341         LPWSTR uriW;
10342         uri_parse_test test = uri_parse_tests[i];
10343
10344         uriW = a2w(test.uri);
10345         hr = pCreateUri(uriW, test.uri_flags, 0, &uri);
10346         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_parse_tests[%d].\n", hr, i);
10347         if(SUCCEEDED(hr)) {
10348             WCHAR result[INTERNET_MAX_URL_LENGTH+1];
10349             DWORD result_len = -1;
10350
10351             hr = pCoInternetParseIUri(uri, test.action, test.flags, result, INTERNET_MAX_URL_LENGTH+1, &result_len, 0);
10352             if(test.todo) {
10353                 todo_wine {
10354                     ok(hr == test.expected,
10355                         "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x on uri_parse_tests[%d].\n",
10356                         hr, test.expected, i);
10357                 }
10358             } else {
10359                 ok(hr == test.expected,
10360                     "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x on uri_parse_tests[%d].\n",
10361                     hr, test.expected, i);
10362             }
10363             if(SUCCEEDED(hr)) {
10364                 DWORD len = lstrlenA(test.property);
10365                 ok(!strcmp_aw(test.property, result),
10366                     "Error: Expected %s but got %s instead on uri_parse_tests[%d].\n",
10367                     test.property, wine_dbgstr_w(result), i);
10368                 ok(len == result_len,
10369                     "Error: Expected %d, but got %d instead on uri_parse_tests[%d].\n",
10370                     len, result_len, i);
10371             } else {
10372                 ok(!result_len,
10373                     "Error: Expected 'result_len' to be 0, but was %d on uri_parse_tests[%d].\n",
10374                     result_len, i);
10375             }
10376         }
10377         if(uri) IUri_Release(uri);
10378         heap_free(uriW);
10379     }
10380 }
10381
10382 static void test_CoInternetParseIUri_Pluggable(void) {
10383     HRESULT hr;
10384     IUri *uri = NULL;
10385
10386     hr = pCreateUri(parse_urlW, 0, 0, &uri);
10387     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, but got 0x%08x.\n", hr);
10388     if(SUCCEEDED(hr)) {
10389         WCHAR result[200];
10390         DWORD result_len;
10391
10392         SET_EXPECT(ParseUrl);
10393
10394         parse_action = PARSE_CANONICALIZE;
10395         parse_flags = URL_UNESCAPE|URL_ESCAPE_UNSAFE;
10396
10397         hr = pCoInternetParseIUri(uri, parse_action, parse_flags, result, 200, &result_len, 0);
10398         ok(hr == S_OK, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
10399
10400         CHECK_CALLED(ParseUrl);
10401
10402         if(SUCCEEDED(hr)) {
10403             ok(result_len == lstrlenW(parse_resultW), "Error: Expected %d, but got %d.\n",
10404                 lstrlenW(parse_resultW), result_len);
10405             ok(!lstrcmpW(result, parse_resultW), "Error: Expected %s, but got %s.\n",
10406                 wine_dbgstr_w(parse_resultW), wine_dbgstr_w(result));
10407         }
10408     }
10409     if(uri) IUri_Release(uri);
10410 }
10411
10412 typedef struct {
10413     const char *url;
10414     DWORD uri_flags;
10415     const char *base_url;
10416     DWORD base_uri_flags;
10417     const char *legacy_url;
10418     const char *uniform_url;
10419     const char *no_canon_url;
10420     const char *uri_url;
10421 } create_urlmon_test_t;
10422
10423 static const create_urlmon_test_t create_urlmon_tests[] = {
10424     {
10425         "http://www.winehq.org",Uri_CREATE_NO_CANONICALIZE,
10426         NULL,0,
10427         "http://www.winehq.org/",
10428         "http://www.winehq.org/",
10429         "http://www.winehq.org",
10430         "http://www.winehq.org"
10431     },
10432     {
10433         "file://c:\\dir\\file.txt",Uri_CREATE_NO_CANONICALIZE,
10434         NULL,0,
10435         "file://c:\\dir\\file.txt",
10436         "file:///c:/dir/file.txt",
10437         "file:///c:/dir/file.txt",
10438         "file:///c:/dir/file.txt"
10439     },
10440     {
10441         "file://c:\\dir\\file.txt",Uri_CREATE_FILE_USE_DOS_PATH,
10442         NULL,0,
10443         "file://c:\\dir\\file.txt",
10444         "file:///c:/dir/file.txt",
10445         "file:///c:/dir/file.txt",
10446         "file://c:\\dir\\file.txt"
10447     },
10448     {
10449         "dat%61",Uri_CREATE_ALLOW_RELATIVE,
10450         "http://www.winehq.org",0,
10451         "http://www.winehq.org/data",
10452         "http://www.winehq.org/data",
10453         "http://www.winehq.org:80/data",
10454     },
10455     {
10456         "file.txt",Uri_CREATE_ALLOW_RELATIVE,
10457         "file://c:\\dir\\x.txt",Uri_CREATE_NO_CANONICALIZE,
10458         "file://c:\\dir\\file.txt",
10459         "file:///c:/dir/file.txt",
10460         "file:///c:/dir/file.txt",
10461     },
10462     {
10463         "",Uri_CREATE_ALLOW_RELATIVE,
10464         NULL,0,
10465         "",
10466         "",
10467         "",
10468         ""
10469     },
10470     {
10471         "test",Uri_CREATE_ALLOW_RELATIVE,
10472         NULL,0,
10473         "test",
10474         "test",
10475         "test",
10476         "test"
10477     },
10478     {
10479         "c:\\dir\\file.txt",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME,
10480         NULL,0,
10481         "file://c:\\dir\\file.txt",
10482         "file:///c:/dir/file.txt",
10483         "file:///c:/dir/file.txt",
10484         "file:///c:/dir/file.txt",
10485     }
10486 };
10487
10488 #define test_urlmon_display_name(a,b) _test_urlmon_display_name(__LINE__,a,b)
10489 static void _test_urlmon_display_name(unsigned line, IMoniker *mon, const char *exurl)
10490 {
10491     WCHAR *display_name;
10492     HRESULT hres;
10493
10494     hres = IMoniker_GetDisplayName(mon, NULL, NULL, &display_name);
10495     ok_(__FILE__,line)(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
10496     ok_(__FILE__,line)(!strcmp_aw(exurl, display_name), "unexpected display name: %s, expected %s\n",
10497             wine_dbgstr_w(display_name), exurl);
10498
10499     CoTaskMemFree(display_name);
10500 }
10501
10502 #define test_display_uri(a,b) _test_display_uri(__LINE__,a,b)
10503 static void _test_display_uri(unsigned line, IMoniker *mon, const char *exurl)
10504 {
10505     IUriContainer *uri_container;
10506     IUri *uri;
10507     BSTR display_uri;
10508     HRESULT hres;
10509
10510     hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container);
10511     ok(hres == S_OK, "Could not get IUriContainer iface: %08x\n", hres);
10512
10513     uri = NULL;
10514     hres = IUriContainer_GetIUri(uri_container, &uri);
10515     IUriContainer_Release(uri_container);
10516     ok(hres == S_OK, "GetIUri failed: %08x\n", hres);
10517     ok(uri != NULL, "uri == NULL\n");
10518
10519     hres = IUri_GetDisplayUri(uri, &display_uri);
10520     IUri_Release(uri);
10521     ok(hres == S_OK, "GetDisplayUri failed: %08x\n", hres);
10522     ok_(__FILE__,line)(!strcmp_aw(exurl, display_uri), "unexpected display uri: %s, expected %s\n",
10523             wine_dbgstr_w(display_uri), exurl);
10524     SysFreeString(display_uri);
10525 }
10526
10527 static void test_CreateURLMoniker(void)
10528 {
10529     const create_urlmon_test_t *test;
10530     IMoniker *mon, *base_mon;
10531     WCHAR *url, *base_url;
10532     IUri *uri, *base_uri;
10533     HRESULT hres;
10534
10535     for(test = create_urlmon_tests; test < create_urlmon_tests + sizeof(create_urlmon_tests)/sizeof(*create_urlmon_tests); test++) {
10536         url = a2w(test->url);
10537         base_url = a2w(test->base_url);
10538
10539         if(base_url) {
10540             hres = pCreateUri(base_url, test->base_uri_flags, 0, &base_uri);
10541             ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
10542
10543             hres = pCreateURLMonikerEx2(NULL, base_uri, &base_mon, URL_MK_NO_CANONICALIZE);
10544             ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10545         }else {
10546             base_uri = NULL;
10547             base_mon = NULL;
10548         }
10549
10550         hres = CreateURLMoniker(base_mon, url, &mon);
10551         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10552         test_urlmon_display_name(mon, test->legacy_url);
10553         test_display_uri(mon, test->legacy_url);
10554         IMoniker_Release(mon);
10555
10556         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_LEGACY);
10557         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10558         test_urlmon_display_name(mon, test->legacy_url);
10559         test_display_uri(mon, test->legacy_url);
10560         IMoniker_Release(mon);
10561
10562         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_UNIFORM);
10563         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10564         test_urlmon_display_name(mon, test->uniform_url);
10565         test_display_uri(mon, test->uniform_url);
10566         IMoniker_Release(mon);
10567
10568         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_NO_CANONICALIZE);
10569         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10570         test_urlmon_display_name(mon, test->no_canon_url);
10571         test_display_uri(mon, test->no_canon_url);
10572         IMoniker_Release(mon);
10573
10574         hres = pCreateUri(url, test->uri_flags, 0, &uri);
10575         ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
10576
10577         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_LEGACY);
10578         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10579         test_urlmon_display_name(mon, base_url ? test->legacy_url : test->uri_url);
10580         test_display_uri(mon, base_url ? test->legacy_url : test->uri_url);
10581         IMoniker_Release(mon);
10582
10583         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_UNIFORM);
10584         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10585         test_urlmon_display_name(mon, base_url ? test->uniform_url : test->uri_url);
10586         test_display_uri(mon, base_url ? test->uniform_url : test->uri_url);
10587         IMoniker_Release(mon);
10588
10589         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_NO_CANONICALIZE);
10590         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10591         test_urlmon_display_name(mon, base_url ? test->no_canon_url : test->uri_url);
10592         test_display_uri(mon, base_url ? test->no_canon_url : test->uri_url);
10593         IMoniker_Release(mon);
10594
10595         IUri_Release(uri);
10596         heap_free(url);
10597         heap_free(base_url);
10598         if(base_uri)
10599             IUri_Release(base_uri);
10600         if(base_mon)
10601             IMoniker_Release(base_mon);
10602     }
10603 }
10604
10605 START_TEST(uri) {
10606     HMODULE hurlmon;
10607
10608     hurlmon = GetModuleHandle("urlmon.dll");
10609     pCoInternetGetSession = (void*) GetProcAddress(hurlmon, "CoInternetGetSession");
10610     pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri");
10611     pCreateUriWithFragment = (void*) GetProcAddress(hurlmon, "CreateUriWithFragment");
10612     pCreateIUriBuilder = (void*) GetProcAddress(hurlmon, "CreateIUriBuilder");
10613     pCoInternetCombineIUri = (void*) GetProcAddress(hurlmon, "CoInternetCombineIUri");
10614     pCoInternetCombineUrlEx = (void*) GetProcAddress(hurlmon, "CoInternetCombineUrlEx");
10615     pCoInternetParseIUri = (void*) GetProcAddress(hurlmon, "CoInternetParseIUri");
10616     pCreateURLMonikerEx = (void*) GetProcAddress(hurlmon, "CreateURLMonikerEx");
10617     pCreateURLMonikerEx2 = (void*) GetProcAddress(hurlmon, "CreateURLMonikerEx2");
10618
10619     if(!pCreateUri) {
10620         win_skip("CreateUri is not present, skipping tests.\n");
10621         return;
10622     }
10623
10624     trace("test CreateUri invalid flags...\n");
10625     test_CreateUri_InvalidFlags();
10626
10627     trace("test CreateUri invalid args...\n");
10628     test_CreateUri_InvalidArgs();
10629
10630     trace("test CreateUri invalid URIs...\n");
10631     test_CreateUri_InvalidUri();
10632
10633     trace("test IUri_GetPropertyBSTR...\n");
10634     test_IUri_GetPropertyBSTR();
10635
10636     trace("test IUri_GetPropertyDWORD...\n");
10637     test_IUri_GetPropertyDWORD();
10638
10639     trace("test IUri_GetStrProperties...\n");
10640     test_IUri_GetStrProperties();
10641
10642     trace("test IUri_GetDwordProperties...\n");
10643     test_IUri_GetDwordProperties();
10644
10645     trace("test IUri_GetPropertyLength...\n");
10646     test_IUri_GetPropertyLength();
10647
10648     trace("test IUri_GetProperties...\n");
10649     test_IUri_GetProperties();
10650
10651     trace("test IUri_HasProperty...\n");
10652     test_IUri_HasProperty();
10653
10654     trace("test IUri_IsEqual...\n");
10655     test_IUri_IsEqual();
10656
10657     trace("test CreateUriWithFragment invalid args...\n");
10658     test_CreateUriWithFragment_InvalidArgs();
10659
10660     trace("test CreateUriWithFragment invalid flags...\n");
10661     test_CreateUriWithFragment_InvalidFlags();
10662
10663     trace("test CreateUriWithFragment...\n");
10664     test_CreateUriWithFragment();
10665
10666     trace("test CreateIUriBuilder...\n");
10667     test_CreateIUriBuilder();
10668
10669     trace("test IUriBuilder_CreateInvalidArgs...\n");
10670     test_IUriBuilder_CreateInvalidArgs();
10671
10672     trace("test IUriBuilder...\n");
10673     test_IUriBuilder();
10674
10675     trace("test IUriBuilder_GetInvalidArgs...\n");
10676     test_IUriBuilder_GetInvalidArgs();
10677
10678     trace("test IUriBuilder_HasBeenModified...\n");
10679     test_IUriBuilder_HasBeenModified();
10680
10681     trace("test IUriBuilder_IUriProperty...\n");
10682     test_IUriBuilder_IUriProperty();
10683
10684     trace("test IUriBuilder_RemoveProperties...\n");
10685     test_IUriBuilder_RemoveProperties();
10686
10687     trace("test IUriBuilder miscellaneous...\n");
10688     test_IUriBuilder_Misc();
10689
10690     trace("test IUriBuilderFactory...\n");
10691     test_IUriBuilderFactory();
10692
10693     trace("test CoInternetCombineIUri...\n");
10694     test_CoInternetCombineIUri();
10695
10696     trace("test CoInternetCombineUrlEx...\n");
10697     test_CoInternetCombineUrlEx();
10698
10699     trace("test CoInternetParseIUri Invalid Args...\n");
10700     test_CoInternetParseIUri_InvalidArgs();
10701
10702     trace("test CoInternetParseIUri...\n");
10703     test_CoInternetParseIUri();
10704
10705     register_protocols();
10706
10707     trace("test CoInternetCombineIUri pluggable...\n");
10708     test_CoInternetCombineIUri_Pluggable();
10709
10710     trace("test CoInternetCombineUrlEx Pluggable...\n");
10711     test_CoInternetCombineUrlEx_Pluggable();
10712
10713     trace("test CoInternetParseIUri pluggable...\n");
10714     test_CoInternetParseIUri_Pluggable();
10715
10716     trace("test CreateURLMoniker...\n");
10717     test_CreateURLMoniker();
10718
10719     unregister_protocols();
10720 }