urlmon: Don't set is_opaque for file URIs in validate_components.
[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://localhost/test dir\\../tests/test%20file.README.txt", 0, S_OK, FALSE,
284         {
285             {"file:///tests/test%20file.README.txt",S_OK,FALSE},
286             {"",S_FALSE,FALSE},
287             {"file:///tests/test%20file.README.txt",S_OK,FALSE},
288             {"",S_FALSE,FALSE},
289             {".txt",S_OK,FALSE},
290             {"",S_FALSE,FALSE},
291             {"",S_FALSE,FALSE},
292             {"",S_FALSE,FALSE},
293             {"/tests/test%20file.README.txt",S_OK,FALSE},
294             {"/tests/test%20file.README.txt",S_OK,FALSE},
295             {"",S_FALSE,FALSE},
296             {"FILE://localhost/test dir\\../tests/test%20file.README.txt",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     {   "urn:nothing:should:happen here", 0, S_OK, FALSE,
309         {
310             {"urn:nothing:should:happen here",S_OK,FALSE},
311             {"",S_FALSE,FALSE},
312             {"urn:nothing:should:happen here",S_OK,FALSE},
313             {"",S_FALSE,FALSE},
314             {"",S_FALSE,FALSE},
315             {"",S_FALSE,FALSE},
316             {"",S_FALSE,FALSE},
317             {"",S_FALSE,FALSE},
318             {"nothing:should:happen here",S_OK,FALSE},
319             {"nothing:should:happen here",S_OK,FALSE},
320             {"",S_FALSE,FALSE},
321             {"urn:nothing:should:happen here",S_OK,FALSE},
322             {"urn",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_UNKNOWN,S_OK,FALSE},
330             {URLZONE_INVALID,E_NOTIMPL,FALSE}
331         }
332     },
333     {   "http://127.0.0.1/tests/../test dir/./test.txt", 0, S_OK, FALSE,
334         {
335             {"http://127.0.0.1/test%20dir/test.txt",S_OK,FALSE},
336             {"127.0.0.1",S_OK,FALSE},
337             {"http://127.0.0.1/test%20dir/test.txt",S_OK,FALSE},
338             {"",S_FALSE,FALSE},
339             {".txt",S_OK,FALSE},
340             {"",S_FALSE,FALSE},
341             {"127.0.0.1",S_OK,FALSE},
342             {"",S_FALSE,FALSE},
343             {"/test%20dir/test.txt",S_OK,FALSE},
344             {"/test%20dir/test.txt",S_OK,FALSE},
345             {"",S_FALSE,FALSE},
346             {"http://127.0.0.1/tests/../test dir/./test.txt",S_OK,FALSE},
347             {"http",S_OK,FALSE},
348             {"",S_FALSE,FALSE},
349             {"",S_FALSE,FALSE}
350         },
351         {
352             {Uri_HOST_IPV4,S_OK,FALSE},
353             {80,S_OK,FALSE},
354             {URL_SCHEME_HTTP,S_OK,FALSE},
355             {URLZONE_INVALID,E_NOTIMPL,FALSE}
356         }
357     },
358     {   "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", 0, S_OK, FALSE,
359         {
360             {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,FALSE},
361             {"[fedc:ba98:7654:3210:fedc:ba98:7654:3210]",S_OK,FALSE},
362             {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,FALSE},
363             {"",S_FALSE,FALSE},
364             {"",S_FALSE,FALSE},
365             {"",S_FALSE,FALSE},
366             {"fedc:ba98:7654:3210:fedc:ba98:7654:3210",S_OK,FALSE},
367             {"",S_FALSE,FALSE},
368             {"/",S_OK,FALSE},
369             {"/",S_OK,FALSE},
370             {"",S_FALSE,FALSE},
371             {"http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]",S_OK,FALSE},
372             {"http",S_OK,FALSE},
373             {"",S_FALSE,FALSE},
374             {"",S_FALSE,FALSE}
375         },
376         {
377             {Uri_HOST_IPV6,S_OK,FALSE},
378             {80,S_OK,FALSE},
379             {URL_SCHEME_HTTP,S_OK,FALSE},
380             {URLZONE_INVALID,E_NOTIMPL,FALSE}
381         }
382     },
383     {   "ftp://[::13.1.68.3]", 0, S_OK, FALSE,
384         {
385             {"ftp://[::13.1.68.3]/",S_OK,FALSE},
386             {"[::13.1.68.3]",S_OK,FALSE},
387             {"ftp://[::13.1.68.3]/",S_OK,FALSE},
388             {"",S_FALSE,FALSE},
389             {"",S_FALSE,FALSE},
390             {"",S_FALSE,FALSE},
391             {"::13.1.68.3",S_OK,FALSE},
392             {"",S_FALSE,FALSE},
393             {"/",S_OK,FALSE},
394             {"/",S_OK,FALSE},
395             {"",S_FALSE,FALSE},
396             {"ftp://[::13.1.68.3]",S_OK,FALSE},
397             {"ftp",S_OK,FALSE},
398             {"",S_FALSE,FALSE},
399             {"",S_FALSE,FALSE}
400         },
401         {
402             {Uri_HOST_IPV6,S_OK,FALSE},
403             {21,S_OK,FALSE},
404             {URL_SCHEME_FTP,S_OK,FALSE},
405             {URLZONE_INVALID,E_NOTIMPL,FALSE}
406         }
407     },
408     {   "http://[FEDC:BA98:0:0:0:0:0:3210]", 0, S_OK, FALSE,
409         {
410             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
411             {"[fedc:ba98::3210]",S_OK,FALSE},
412             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
413             {"",S_FALSE,FALSE},
414             {"",S_FALSE,FALSE},
415             {"",S_FALSE,FALSE},
416             {"fedc:ba98::3210",S_OK,FALSE},
417             {"",S_FALSE,FALSE},
418             {"/",S_OK,FALSE},
419             {"/",S_OK,FALSE},
420             {"",S_FALSE,FALSE},
421             {"http://[FEDC:BA98:0:0:0:0:0:3210]",S_OK,FALSE},
422             {"http",S_OK,FALSE},
423             {"",S_FALSE,FALSE},
424             {"",S_FALSE,FALSE},
425         },
426         {
427             {Uri_HOST_IPV6,S_OK,FALSE},
428             {80,S_OK,FALSE},
429             {URL_SCHEME_HTTP,S_OK,FALSE},
430             {URLZONE_INVALID,E_NOTIMPL,FALSE}
431         }
432     },
433     {   "1234://www.winehq.org", 0, S_OK, FALSE,
434         {
435             {"1234://www.winehq.org/",S_OK,FALSE},
436             {"www.winehq.org",S_OK,FALSE},
437             {"1234://www.winehq.org/",S_OK,FALSE},
438             {"winehq.org",S_OK,FALSE},
439             {"",S_FALSE,FALSE},
440             {"",S_FALSE,FALSE},
441             {"www.winehq.org",S_OK,FALSE},
442             {"",S_FALSE,FALSE},
443             {"/",S_OK,FALSE},
444             {"/",S_OK,FALSE},
445             {"",S_FALSE,FALSE},
446             {"1234://www.winehq.org",S_OK,FALSE},
447             {"1234",S_OK,FALSE},
448             {"",S_FALSE,FALSE},
449             {"",S_FALSE,FALSE}
450         },
451         {
452             {Uri_HOST_DNS,S_OK,FALSE},
453             {0,S_FALSE,FALSE},
454             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
455             {URLZONE_INVALID,E_NOTIMPL,FALSE}
456         }
457     },
458     /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
459     {   "C:/test/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
460         {
461             {"file:///C:/test/test.mp3",S_OK,FALSE},
462             {"",S_FALSE,FALSE},
463             {"file:///C:/test/test.mp3",S_OK,FALSE},
464             {"",S_FALSE,FALSE},
465             {".mp3",S_OK,FALSE},
466             {"",S_FALSE,FALSE},
467             {"",S_FALSE,FALSE},
468             {"",S_FALSE,FALSE},
469             {"/C:/test/test.mp3",S_OK,FALSE},
470             {"/C:/test/test.mp3",S_OK,FALSE},
471             {"",S_FALSE,FALSE},
472             {"C:/test/test.mp3",S_OK,FALSE},
473             {"file",S_OK,FALSE},
474             {"",S_FALSE,FALSE},
475             {"",S_FALSE,FALSE}
476         },
477         {
478             {Uri_HOST_UNKNOWN,S_OK,FALSE},
479             {0,S_FALSE,FALSE},
480             {URL_SCHEME_FILE,S_OK,FALSE},
481             {URLZONE_INVALID,E_NOTIMPL,FALSE}
482         }
483     },
484     /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
485     {   "\\\\Server/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
486         {
487             {"file://server/test.mp3",S_OK,FALSE},
488             {"server",S_OK,FALSE},
489             {"file://server/test.mp3",S_OK,FALSE},
490             {"",S_FALSE,FALSE},
491             {".mp3",S_OK,FALSE},
492             {"",S_FALSE,FALSE},
493             {"server",S_OK,FALSE},
494             {"",S_FALSE,FALSE},
495             {"/test.mp3",S_OK,FALSE},
496             {"/test.mp3",S_OK,FALSE},
497             {"",S_FALSE,FALSE},
498             {"\\\\Server/test.mp3",S_OK,FALSE},
499             {"file",S_OK,FALSE},
500             {"",S_FALSE,FALSE},
501             {"",S_FALSE,FALSE}
502         },
503         {
504             {Uri_HOST_DNS,S_OK,FALSE},
505             {0,S_FALSE,FALSE},
506             {URL_SCHEME_FILE,S_OK,FALSE},
507             {URLZONE_INVALID,E_NOTIMPL,FALSE}
508         }
509     },
510     {   "www.winehq.org/test", Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
511         {
512             {"*:www.winehq.org/test",S_OK,FALSE},
513             {"www.winehq.org",S_OK,FALSE},
514             {"*:www.winehq.org/test",S_OK,FALSE},
515             {"winehq.org",S_OK,FALSE},
516             {"",S_FALSE,FALSE},
517             {"",S_FALSE,FALSE},
518             {"www.winehq.org",S_OK,FALSE},
519             {"",S_FALSE,FALSE},
520             {"/test",S_OK,FALSE},
521             {"/test",S_OK,FALSE},
522             {"",S_FALSE,FALSE},
523             {"www.winehq.org/test",S_OK,FALSE},
524             {"*",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_WILDCARD,S_OK,FALSE},
532             {URLZONE_INVALID,E_NOTIMPL,FALSE}
533         }
534     },
535     /* Valid since the '*' is the only character in the scheme name. */
536     {   "*:www.winehq.org/test", 0, S_OK, FALSE,
537         {
538             {"*:www.winehq.org/test",S_OK,FALSE},
539             {"www.winehq.org",S_OK,FALSE},
540             {"*:www.winehq.org/test",S_OK,FALSE},
541             {"winehq.org",S_OK,FALSE},
542             {"",S_FALSE,FALSE},
543             {"",S_FALSE,FALSE},
544             {"www.winehq.org",S_OK,FALSE},
545             {"",S_FALSE,FALSE},
546             {"/test",S_OK,FALSE},
547             {"/test",S_OK,FALSE},
548             {"",S_FALSE,FALSE},
549             {"*:www.winehq.org/test",S_OK,FALSE},
550             {"*",S_OK,FALSE},
551             {"",S_FALSE,FALSE},
552             {"",S_FALSE,FALSE}
553         },
554         {
555             {Uri_HOST_DNS,S_OK,FALSE},
556             {0,S_FALSE,FALSE},
557             {URL_SCHEME_WILDCARD,S_OK,FALSE},
558             {URLZONE_INVALID,E_NOTIMPL,FALSE}
559         }
560     },
561     {   "/../some dir/test.ext", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
562         {
563             {"/../some dir/test.ext",S_OK,FALSE},
564             {"",S_FALSE,FALSE},
565             {"/../some dir/test.ext",S_OK,FALSE},
566             {"",S_FALSE,FALSE},
567             {".ext",S_OK,FALSE},
568             {"",S_FALSE,FALSE},
569             {"",S_FALSE,FALSE},
570             {"",S_FALSE,FALSE},
571             {"/../some dir/test.ext",S_OK,FALSE},
572             {"/../some dir/test.ext",S_OK,FALSE},
573             {"",S_FALSE,FALSE},
574             {"/../some dir/test.ext",S_OK,FALSE},
575             {"",S_FALSE,FALSE},
576             {"",S_FALSE,FALSE},
577             {"",S_FALSE,FALSE}
578         },
579         {
580             {Uri_HOST_UNKNOWN,S_OK,FALSE},
581             {0,S_FALSE,FALSE},
582             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
583             {URLZONE_INVALID,E_NOTIMPL,FALSE}
584         }
585     },
586     {   "//implicit/wildcard/uri scheme", Uri_CREATE_ALLOW_RELATIVE|Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
587         {
588             {"*://implicit/wildcard/uri%20scheme",S_OK,FALSE},
589             {"",S_OK,FALSE},
590             {"*://implicit/wildcard/uri%20scheme",S_OK,FALSE},
591             {"",S_FALSE,FALSE},
592             {"",S_FALSE,FALSE},
593             {"",S_FALSE,FALSE},
594             {"",S_OK,FALSE},
595             {"",S_FALSE,FALSE},
596             {"//implicit/wildcard/uri%20scheme",S_OK,FALSE},
597             {"//implicit/wildcard/uri%20scheme",S_OK,FALSE},
598             {"",S_FALSE,FALSE},
599             {"//implicit/wildcard/uri scheme",S_OK,FALSE},
600             {"*",S_OK,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_WILDCARD,S_OK,FALSE},
608             {URLZONE_INVALID,E_NOTIMPL,FALSE}
609         }
610     },
611     /* URI is considered opaque since CREATE_NO_CRACK_UNKNOWN_SCHEMES is set and its an unknown scheme. */
612     {   "zip://google.com", Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, S_OK, FALSE,
613         {
614             {"zip:/.//google.com",S_OK,FALSE},
615             {"",S_FALSE,FALSE},
616             {"zip:/.//google.com",S_OK,FALSE},
617             {"",S_FALSE,FALSE},
618             {".com",S_OK,FALSE},
619             {"",S_FALSE,FALSE},
620             {"",S_FALSE,FALSE},
621             {"",S_FALSE,FALSE},
622             {"/.//google.com",S_OK,FALSE},
623             {"/.//google.com",S_OK,FALSE},
624             {"",S_FALSE,FALSE},
625             {"zip://google.com",S_OK,FALSE},
626             {"zip",S_OK,FALSE},
627             {"",S_FALSE,FALSE},
628             {"",S_FALSE,FALSE}
629         },
630         {
631             {Uri_HOST_UNKNOWN,S_OK,FALSE},
632             {0,S_FALSE,FALSE},
633             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
634             {URLZONE_INVALID,E_NOTIMPL,FALSE}
635         }
636     },
637     /* Windows uses the first occurrence of ':' to delimit the userinfo. */
638     {   "ftp://user:pass:word@winehq.org/", 0, S_OK, FALSE,
639         {
640             {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
641             {"user:pass:word@winehq.org",S_OK,FALSE},
642             {"ftp://winehq.org/",S_OK,FALSE},
643             {"winehq.org",S_OK,FALSE},
644             {"",S_FALSE,FALSE},
645             {"",S_FALSE,FALSE},
646             {"winehq.org",S_OK,FALSE},
647             {"pass:word",S_OK,FALSE},
648             {"/",S_OK,FALSE},
649             {"/",S_OK,FALSE},
650             {"",S_FALSE,FALSE},
651             {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
652             {"ftp",S_OK,FALSE},
653             {"user:pass:word",S_OK,FALSE},
654             {"user",S_OK,FALSE}
655         },
656         {
657             {Uri_HOST_DNS,S_OK,FALSE},
658             {21,S_OK,FALSE},
659             {URL_SCHEME_FTP,S_OK,FALSE},
660             {URLZONE_INVALID,E_NOTIMPL,FALSE}
661         }
662     },
663     /* Make sure % encoded unreserved characters are decoded. */
664     {   "ftp://w%49%4Ee:PA%53%53@ftp.google.com/", 0, S_OK, FALSE,
665         {
666             {"ftp://wINe:PASS@ftp.google.com/",S_OK,FALSE},
667             {"wINe:PASS@ftp.google.com",S_OK,FALSE},
668             {"ftp://ftp.google.com/",S_OK,FALSE},
669             {"google.com",S_OK,FALSE},
670             {"",S_FALSE,FALSE},
671             {"",S_FALSE,FALSE},
672             {"ftp.google.com",S_OK,FALSE},
673             {"PASS",S_OK,FALSE},
674             {"/",S_OK,FALSE},
675             {"/",S_OK,FALSE},
676             {"",S_FALSE,FALSE},
677             {"ftp://w%49%4Ee:PA%53%53@ftp.google.com/",S_OK,FALSE},
678             {"ftp",S_OK,FALSE},
679             {"wINe:PASS",S_OK,FALSE},
680             {"wINe",S_OK,FALSE}
681         },
682         {
683             {Uri_HOST_DNS,S_OK,FALSE},
684             {21,S_OK,FALSE},
685             {URL_SCHEME_FTP,S_OK,FALSE},
686             {URLZONE_INVALID,E_NOTIMPL,FALSE}
687         }
688     },
689     /* Make sure % encoded characters which are NOT unreserved are NOT decoded. */
690     {   "ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/", 0, S_OK, FALSE,
691         {
692             {"ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/",S_OK,FALSE},
693             {"w%5D%5Be:PA%7B%7D@ftp.google.com",S_OK,FALSE},
694             {"ftp://ftp.google.com/",S_OK,FALSE},
695             {"google.com",S_OK,FALSE},
696             {"",S_FALSE,FALSE},
697             {"",S_FALSE,FALSE},
698             {"ftp.google.com",S_OK,FALSE},
699             {"PA%7B%7D",S_OK,FALSE},
700             {"/",S_OK,FALSE},
701             {"/",S_OK,FALSE},
702             {"",S_FALSE,FALSE},
703             {"ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/",S_OK,FALSE},
704             {"ftp",S_OK,FALSE},
705             {"w%5D%5Be:PA%7B%7D",S_OK,FALSE},
706             {"w%5D%5Be",S_OK,FALSE}
707         },
708         {
709             {Uri_HOST_DNS,S_OK,FALSE},
710             {21,S_OK,FALSE},
711             {URL_SCHEME_FTP,S_OK,FALSE},
712             {URLZONE_INVALID,E_NOTIMPL,FALSE}
713         }
714     },
715     /* You're allowed to have an empty password portion in the userinfo section. */
716     {   "ftp://empty:@ftp.google.com/", 0, S_OK, FALSE,
717         {
718             {"ftp://empty:@ftp.google.com/",S_OK,FALSE},
719             {"empty:@ftp.google.com",S_OK,FALSE},
720             {"ftp://ftp.google.com/",S_OK,FALSE},
721             {"google.com",S_OK,FALSE},
722             {"",S_FALSE,FALSE},
723             {"",S_FALSE,FALSE},
724             {"ftp.google.com",S_OK,FALSE},
725             {"",S_OK,FALSE},
726             {"/",S_OK,FALSE},
727             {"/",S_OK,FALSE},
728             {"",S_FALSE,FALSE},
729             {"ftp://empty:@ftp.google.com/",S_OK,FALSE},
730             {"ftp",S_OK,FALSE},
731             {"empty:",S_OK,FALSE},
732             {"empty",S_OK,FALSE}
733         },
734         {
735             {Uri_HOST_DNS,S_OK,FALSE},
736             {21,S_OK,FALSE},
737             {URL_SCHEME_FTP,S_OK,FALSE},
738             {URLZONE_INVALID,E_NOTIMPL,FALSE}
739         }
740     },
741     /* Make sure forbidden characters in "userinfo" get encoded. */
742     {   "ftp://\" \"weird@ftp.google.com/", 0, S_OK, FALSE,
743         {
744             {"ftp://%22%20%22weird@ftp.google.com/",S_OK,FALSE},
745             {"%22%20%22weird@ftp.google.com",S_OK,FALSE},
746             {"ftp://ftp.google.com/",S_OK,FALSE},
747             {"google.com",S_OK,FALSE},
748             {"",S_FALSE,FALSE},
749             {"",S_FALSE,FALSE},
750             {"ftp.google.com",S_OK,FALSE},
751             {"",S_FALSE,FALSE},
752             {"/",S_OK,FALSE},
753             {"/",S_OK,FALSE},
754             {"",S_FALSE,FALSE},
755             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
756             {"ftp",S_OK,FALSE},
757             {"%22%20%22weird",S_OK,FALSE},
758             {"%22%20%22weird",S_OK,FALSE}
759         },
760         {
761             {Uri_HOST_DNS,S_OK,FALSE},
762             {21,S_OK,FALSE},
763             {URL_SCHEME_FTP,S_OK,FALSE},
764             {URLZONE_INVALID,E_NOTIMPL,FALSE}
765         }
766     },
767     /* Make sure the forbidden characters don't get percent encoded. */
768     {   "ftp://\" \"weird@ftp.google.com/", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
769         {
770             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
771             {"\" \"weird@ftp.google.com",S_OK,FALSE},
772             {"ftp://ftp.google.com/",S_OK,FALSE},
773             {"google.com",S_OK,FALSE},
774             {"",S_FALSE,FALSE},
775             {"",S_FALSE,FALSE},
776             {"ftp.google.com",S_OK,FALSE},
777             {"",S_FALSE,FALSE},
778             {"/",S_OK,FALSE},
779             {"/",S_OK,FALSE},
780             {"",S_FALSE,FALSE},
781             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
782             {"ftp",S_OK,FALSE},
783             {"\" \"weird",S_OK,FALSE},
784             {"\" \"weird",S_OK,FALSE}
785         },
786         {
787             {Uri_HOST_DNS,S_OK,FALSE},
788             {21,S_OK,FALSE},
789             {URL_SCHEME_FTP,S_OK,FALSE},
790             {URLZONE_INVALID,E_NOTIMPL,FALSE}
791         }
792     },
793     /* Make sure already percent encoded characters don't get unencoded. */
794     {   "ftp://\"%20\"weird@ftp.google.com/\"%20\"weird", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
795         {
796             {"ftp://\"%20\"weird@ftp.google.com/\"%20\"weird",S_OK,FALSE},
797             {"\"%20\"weird@ftp.google.com",S_OK,FALSE},
798             {"ftp://ftp.google.com/\"%20\"weird",S_OK,FALSE},
799             {"google.com",S_OK,FALSE},
800             {"",S_FALSE,FALSE},
801             {"",S_FALSE,FALSE},
802             {"ftp.google.com",S_OK,FALSE},
803             {"",S_FALSE,FALSE},
804             {"/\"%20\"weird",S_OK,FALSE},
805             {"/\"%20\"weird",S_OK,FALSE},
806             {"",S_FALSE,FALSE},
807             {"ftp://\"%20\"weird@ftp.google.com/\"%20\"weird",S_OK,FALSE},
808             {"ftp",S_OK,FALSE},
809             {"\"%20\"weird",S_OK,FALSE},
810             {"\"%20\"weird",S_OK,FALSE}
811         },
812         {
813             {Uri_HOST_DNS,S_OK,FALSE},
814             {21,S_OK,FALSE},
815             {URL_SCHEME_FTP,S_OK,FALSE},
816             {URLZONE_INVALID,E_NOTIMPL,FALSE}
817         }
818     },
819     /* Allowed to have invalid % encoded because its an unknown scheme type. */
820     {   "zip://%xy:word@winehq.org/", 0, S_OK, FALSE,
821         {
822             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
823             {"%xy:word@winehq.org",S_OK,FALSE},
824             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
825             {"winehq.org",S_OK,FALSE},
826             {"",S_FALSE,FALSE},
827             {"",S_FALSE,FALSE},
828             {"winehq.org",S_OK,FALSE},
829             {"word",S_OK,FALSE},
830             {"/",S_OK,FALSE},
831             {"/",S_OK,FALSE},
832             {"",S_FALSE,FALSE},
833             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
834             {"zip",S_OK,FALSE},
835             {"%xy:word",S_OK,FALSE},
836             {"%xy",S_OK,FALSE}
837         },
838         {
839             {Uri_HOST_DNS,S_OK,FALSE},
840             {0,S_FALSE,FALSE},
841             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
842             {URLZONE_INVALID,E_NOTIMPL,FALSE}
843         }
844     },
845     /* Unreserved, percent encoded characters aren't decoded in the userinfo because the scheme
846      * isn't known.
847      */
848     {   "zip://%2E:%52%53ord@winehq.org/", 0, S_OK, FALSE,
849         {
850             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
851             {"%2E:%52%53ord@winehq.org",S_OK,FALSE},
852             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
853             {"winehq.org",S_OK,FALSE},
854             {"",S_FALSE,FALSE},
855             {"",S_FALSE,FALSE},
856             {"winehq.org",S_OK,FALSE},
857             {"%52%53ord",S_OK,FALSE},
858             {"/",S_OK,FALSE},
859             {"/",S_OK,FALSE},
860             {"",S_FALSE,FALSE},
861             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
862             {"zip",S_OK,FALSE},
863             {"%2E:%52%53ord",S_OK,FALSE},
864             {"%2E",S_OK,FALSE}
865         },
866         {
867             {Uri_HOST_DNS,S_OK,FALSE},
868             {0,S_FALSE,FALSE},
869             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
870             {URLZONE_INVALID,E_NOTIMPL,FALSE}
871         }
872     },
873     {   "ftp://[](),'test':word@winehq.org/", 0, S_OK, FALSE,
874         {
875             {"ftp://[](),'test':word@winehq.org/",S_OK,FALSE},
876             {"[](),'test':word@winehq.org",S_OK,FALSE},
877             {"ftp://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             {"word",S_OK,FALSE},
883             {"/",S_OK,FALSE},
884             {"/",S_OK,FALSE},
885             {"",S_FALSE,FALSE},
886             {"ftp://[](),'test':word@winehq.org/",S_OK,FALSE},
887             {"ftp",S_OK,FALSE},
888             {"[](),'test':word",S_OK,FALSE},
889             {"[](),'test'",S_OK,FALSE}
890         },
891         {
892             {Uri_HOST_DNS,S_OK,FALSE},
893             {21,S_OK,FALSE},
894             {URL_SCHEME_FTP,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",S_OK,FALSE},
902             {"ftp://test/?:word@winehq.org/",S_OK,FALSE},
903             {"",S_FALSE,FALSE},
904             {"",S_FALSE,FALSE},
905             {"",S_FALSE,FALSE},
906             {"test",S_OK,FALSE},
907             {"",S_FALSE,FALSE},
908             {"/",S_OK,FALSE},
909             {"/?:word@winehq.org/",S_OK,FALSE},
910             {"?:word@winehq.org/",S_OK,FALSE},
911             {"ftp://test?:word@winehq.org/",S_OK,FALSE},
912             {"ftp",S_OK,FALSE},
913             {"",S_FALSE,FALSE},
914             {"",S_FALSE,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             {"#:word@winehq.org/",S_OK,FALSE},
931             {"test",S_OK,FALSE},
932             {"",S_FALSE,FALSE},
933             {"/",S_OK,FALSE},
934             {"/",S_OK,FALSE},
935             {"",S_FALSE,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     /* Allowed to have a backslash in the userinfo since it's an unknown scheme. */
949     {   "zip://test\\:word@winehq.org/", 0, S_OK, FALSE,
950         {
951             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
952             {"test\\:word@winehq.org",S_OK,FALSE},
953             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
954             {"winehq.org",S_OK,FALSE},
955             {"",S_FALSE,FALSE},
956             {"",S_FALSE,FALSE},
957             {"winehq.org",S_OK,FALSE},
958             {"word",S_OK,FALSE},
959             {"/",S_OK,FALSE},
960             {"/",S_OK,FALSE},
961             {"",S_FALSE,FALSE},
962             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
963             {"zip",S_OK,FALSE},
964             {"test\\:word",S_OK,FALSE},
965             {"test\\",S_OK,FALSE}
966         },
967         {
968             {Uri_HOST_DNS,S_OK,FALSE},
969             {0,S_FALSE,FALSE},
970             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
971             {URLZONE_INVALID,E_NOTIMPL,FALSE}
972         }
973     },
974     /* It normalizes IPv4 addresses correctly. */
975     {   "http://127.000.000.100/", 0, S_OK, FALSE,
976         {
977             {"http://127.0.0.100/",S_OK,FALSE},
978             {"127.0.0.100",S_OK,FALSE},
979             {"http://127.0.0.100/",S_OK,FALSE},
980             {"",S_FALSE,FALSE},
981             {"",S_FALSE,FALSE},
982             {"",S_FALSE,FALSE},
983             {"127.0.0.100",S_OK,FALSE},
984             {"",S_FALSE,FALSE},
985             {"/",S_OK,FALSE},
986             {"/",S_OK,FALSE},
987             {"",S_FALSE,FALSE},
988             {"http://127.000.000.100/",S_OK,FALSE},
989             {"http",S_OK,FALSE},
990             {"",S_FALSE,FALSE},
991             {"",S_FALSE,FALSE}
992         },
993         {
994             {Uri_HOST_IPV4,S_OK,FALSE},
995             {80,S_OK,FALSE},
996             {URL_SCHEME_HTTP,S_OK,FALSE},
997             {URLZONE_INVALID,E_NOTIMPL,FALSE}
998         }
999     },
1000     {   "http://127.0.0.1:8000", 0, S_OK, FALSE,
1001         {
1002             {"http://127.0.0.1:8000/",S_OK},
1003             {"127.0.0.1:8000",S_OK},
1004             {"http://127.0.0.1:8000/",S_OK},
1005             {"",S_FALSE},
1006             {"",S_FALSE},
1007             {"",S_FALSE},
1008             {"127.0.0.1",S_OK},
1009             {"",S_FALSE},
1010             {"/",S_OK},
1011             {"/",S_OK},
1012             {"",S_FALSE},
1013             {"http://127.0.0.1:8000",S_OK},
1014             {"http",S_OK},
1015             {"",S_FALSE},
1016             {"",S_FALSE}
1017         },
1018         {
1019             {Uri_HOST_IPV4,S_OK,FALSE},
1020             {8000,S_OK,FALSE},
1021             {URL_SCHEME_HTTP,S_OK,FALSE},
1022             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1023         }
1024     },
1025     /* Make sure it normalizes partial IPv4 addresses correctly. */
1026     {   "http://127.0/", 0, S_OK, FALSE,
1027         {
1028             {"http://127.0.0.0/",S_OK,FALSE},
1029             {"127.0.0.0",S_OK,FALSE},
1030             {"http://127.0.0.0/",S_OK,FALSE},
1031             {"",S_FALSE,FALSE},
1032             {"",S_FALSE,FALSE},
1033             {"",S_FALSE,FALSE},
1034             {"127.0.0.0",S_OK,FALSE},
1035             {"",S_FALSE,FALSE},
1036             {"/",S_OK,FALSE},
1037             {"/",S_OK,FALSE},
1038             {"",S_FALSE,FALSE},
1039             {"http://127.0/",S_OK,FALSE},
1040             {"http",S_OK,FALSE},
1041             {"",S_FALSE,FALSE},
1042             {"",S_FALSE,FALSE}
1043         },
1044         {
1045             {Uri_HOST_IPV4,S_OK,FALSE},
1046             {80,S_OK,FALSE},
1047             {URL_SCHEME_HTTP,S_OK,FALSE},
1048             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1049         }
1050     },
1051     /* Make sure it converts implicit IPv4's correctly. */
1052     {   "http://123456/", 0, S_OK, FALSE,
1053         {
1054             {"http://0.1.226.64/",S_OK,FALSE},
1055             {"0.1.226.64",S_OK,FALSE},
1056             {"http://0.1.226.64/",S_OK,FALSE},
1057             {"",S_FALSE,FALSE},
1058             {"",S_FALSE,FALSE},
1059             {"",S_FALSE,FALSE},
1060             {"0.1.226.64",S_OK,FALSE},
1061             {"",S_FALSE,FALSE},
1062             {"/",S_OK,FALSE},
1063             {"/",S_OK,FALSE},
1064             {"",S_FALSE,FALSE},
1065             {"http://123456/",S_OK,FALSE},
1066             {"http",S_OK,FALSE},
1067             {"",S_FALSE,FALSE},
1068             {"",S_FALSE,FALSE}
1069         },
1070         {
1071             {Uri_HOST_IPV4,S_OK,FALSE},
1072             {80,S_OK,FALSE},
1073             {URL_SCHEME_HTTP,S_OK,FALSE},
1074             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1075         }
1076     },
1077     /* UINT_MAX */
1078     {   "http://4294967295/", 0, S_OK, FALSE,
1079         {
1080             {"http://255.255.255.255/",S_OK,FALSE},
1081             {"255.255.255.255",S_OK,FALSE},
1082             {"http://255.255.255.255/",S_OK,FALSE},
1083             {"",S_FALSE,FALSE},
1084             {"",S_FALSE,FALSE},
1085             {"",S_FALSE,FALSE},
1086             {"255.255.255.255",S_OK,FALSE},
1087             {"",S_FALSE,FALSE},
1088             {"/",S_OK,FALSE},
1089             {"/",S_OK,FALSE},
1090             {"",S_FALSE,FALSE},
1091             {"http://4294967295/",S_OK,FALSE},
1092             {"http",S_OK,FALSE},
1093             {"",S_FALSE,FALSE},
1094             {"",S_FALSE,FALSE}
1095         },
1096         {
1097             {Uri_HOST_IPV4,S_OK,FALSE},
1098             {80,S_OK,FALSE},
1099             {URL_SCHEME_HTTP,S_OK,FALSE},
1100             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1101         }
1102     },
1103     /* UINT_MAX+1 */
1104     {   "http://4294967296/", 0, S_OK, FALSE,
1105         {
1106             {"http://4294967296/",S_OK,FALSE},
1107             {"4294967296",S_OK,FALSE},
1108             {"http://4294967296/",S_OK,FALSE},
1109             {"",S_FALSE,FALSE},
1110             {"",S_FALSE,FALSE},
1111             {"",S_FALSE,FALSE},
1112             {"4294967296",S_OK,FALSE},
1113             {"",S_FALSE,FALSE},
1114             {"/",S_OK,FALSE},
1115             {"/",S_OK,FALSE},
1116             {"",S_FALSE,FALSE},
1117             {"http://4294967296/",S_OK,FALSE},
1118             {"http",S_OK,FALSE},
1119             {"",S_FALSE,FALSE},
1120             {"",S_FALSE,FALSE}
1121         },
1122         {
1123             {Uri_HOST_DNS,S_OK,FALSE},
1124             {80,S_OK,FALSE},
1125             {URL_SCHEME_HTTP,S_OK,FALSE},
1126             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1127         }
1128     },
1129     /* Window's doesn't normalize IP address for unknown schemes. */
1130     {   "1234://4294967295/", 0, S_OK, FALSE,
1131         {
1132             {"1234://4294967295/",S_OK,FALSE},
1133             {"4294967295",S_OK,FALSE},
1134             {"1234://4294967295/",S_OK,FALSE},
1135             {"",S_FALSE,FALSE},
1136             {"",S_FALSE,FALSE},
1137             {"",S_FALSE,FALSE},
1138             {"4294967295",S_OK,FALSE},
1139             {"",S_FALSE,FALSE},
1140             {"/",S_OK,FALSE},
1141             {"/",S_OK,FALSE},
1142             {"",S_FALSE,FALSE},
1143             {"1234://4294967295/",S_OK,FALSE},
1144             {"1234",S_OK,FALSE},
1145             {"",S_FALSE,FALSE},
1146             {"",S_FALSE,FALSE}
1147         },
1148         {
1149             {Uri_HOST_IPV4,S_OK,FALSE},
1150             {0,S_FALSE,FALSE},
1151             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1152             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1153         }
1154     },
1155     /* Window's doesn't normalize IP address for unknown schemes. */
1156     {   "1234://127.001/", 0, S_OK, FALSE,
1157         {
1158             {"1234://127.001/",S_OK,FALSE},
1159             {"127.001",S_OK,FALSE},
1160             {"1234://127.001/",S_OK,FALSE},
1161             {"",S_FALSE,FALSE},
1162             {"",S_FALSE,FALSE},
1163             {"",S_FALSE,FALSE},
1164             {"127.001",S_OK,FALSE},
1165             {"",S_FALSE,FALSE},
1166             {"/",S_OK,FALSE},
1167             {"/",S_OK,FALSE},
1168             {"",S_FALSE,FALSE},
1169             {"1234://127.001/",S_OK,FALSE},
1170             {"1234",S_OK,FALSE},
1171             {"",S_FALSE,FALSE},
1172             {"",S_FALSE,FALSE}
1173         },
1174         {
1175             {Uri_HOST_IPV4,S_OK,FALSE},
1176             {0,S_FALSE,FALSE},
1177             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1178             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1179         }
1180     },
1181     {   "http://[FEDC:BA98::3210]", 0, S_OK, FALSE,
1182         {
1183             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
1184             {"[fedc:ba98::3210]",S_OK,FALSE},
1185             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
1186             {"",S_FALSE,FALSE},
1187             {"",S_FALSE,FALSE},
1188             {"",S_FALSE,FALSE},
1189             {"fedc:ba98::3210",S_OK,FALSE},
1190             {"",S_FALSE,FALSE},
1191             {"/",S_OK,FALSE},
1192             {"/",S_OK,FALSE},
1193             {"",S_FALSE,FALSE},
1194             {"http://[FEDC:BA98::3210]",S_OK,FALSE},
1195             {"http",S_OK,FALSE},
1196             {"",S_FALSE,FALSE},
1197             {"",S_FALSE,FALSE},
1198         },
1199         {
1200             {Uri_HOST_IPV6,S_OK,FALSE},
1201             {80,S_OK,FALSE},
1202             {URL_SCHEME_HTTP,S_OK,FALSE},
1203             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1204         }
1205     },
1206     {   "http://[::]", 0, S_OK, FALSE,
1207         {
1208             {"http://[::]/",S_OK,FALSE},
1209             {"[::]",S_OK,FALSE},
1210             {"http://[::]/",S_OK,FALSE},
1211             {"",S_FALSE,FALSE},
1212             {"",S_FALSE,FALSE},
1213             {"",S_FALSE,FALSE},
1214             {"::",S_OK,FALSE},
1215             {"",S_FALSE,FALSE},
1216             {"/",S_OK,FALSE},
1217             {"/",S_OK,FALSE},
1218             {"",S_FALSE,FALSE},
1219             {"http://[::]",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://[FEDC:BA98::]", 0, S_OK, FALSE,
1232         {
1233             {"http://[fedc:ba98::]/",S_OK,FALSE},
1234             {"[fedc:ba98::]",S_OK,FALSE},
1235             {"http://[fedc:ba98::]/",S_OK,FALSE},
1236             {"",S_FALSE,FALSE},
1237             {"",S_FALSE,FALSE},
1238             {"",S_FALSE,FALSE},
1239             {"fedc:ba98::",S_OK,FALSE},
1240             {"",S_FALSE,FALSE},
1241             {"/",S_OK,FALSE},
1242             {"/",S_OK,FALSE},
1243             {"",S_FALSE,FALSE},
1244             {"http://[FEDC:BA98::]",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     /* Valid even with 2 byte elision because it doesn't appear the beginning or end. */
1257     {   "http://[1::3:4:5:6:7:8]", 0, S_OK, FALSE,
1258         {
1259             {"http://[1:0:3:4:5:6:7:8]/",S_OK,FALSE},
1260             {"[1:0:3:4:5:6:7:8]",S_OK,FALSE},
1261             {"http://[1:0:3:4:5:6:7:8]/",S_OK,FALSE},
1262             {"",S_FALSE,FALSE},
1263             {"",S_FALSE,FALSE},
1264             {"",S_FALSE,FALSE},
1265             {"1:0:3:4:5:6:7:8",S_OK,FALSE},
1266             {"",S_FALSE,FALSE},
1267             {"/",S_OK,FALSE},
1268             {"/",S_OK,FALSE},
1269             {"",S_FALSE,FALSE},
1270             {"http://[1::3:4:5:6:7:8]",S_OK,FALSE},
1271             {"http",S_OK,FALSE},
1272             {"",S_FALSE,FALSE},
1273             {"",S_FALSE,FALSE},
1274         },
1275         {
1276             {Uri_HOST_IPV6,S_OK,FALSE},
1277             {80,S_OK,FALSE},
1278             {URL_SCHEME_HTTP,S_OK,FALSE},
1279             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1280         }
1281     },
1282     {   "http://[v2.34]/", 0, S_OK, FALSE,
1283         {
1284             {"http://[v2.34]/",S_OK,FALSE},
1285             {"[v2.34]",S_OK,FALSE},
1286             {"http://[v2.34]/",S_OK,FALSE},
1287             {"",S_FALSE,FALSE},
1288             {"",S_FALSE,FALSE},
1289             {"",S_FALSE,FALSE},
1290             {"[v2.34]",S_OK,FALSE},
1291             {"",S_FALSE,FALSE},
1292             {"/",S_OK,FALSE},
1293             {"/",S_OK,FALSE},
1294             {"",S_FALSE,FALSE},
1295             {"http://[v2.34]/",S_OK,FALSE},
1296             {"http",S_OK,FALSE},
1297             {"",S_FALSE,FALSE},
1298             {"",S_FALSE,FALSE}
1299         },
1300         {
1301             {Uri_HOST_UNKNOWN,S_OK,FALSE},
1302             {80,S_OK,FALSE},
1303             {URL_SCHEME_HTTP,S_OK,FALSE},
1304             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1305         }
1306     },
1307     /* Windows ignores ':' if they appear after a '[' on a non-IPLiteral host. */
1308     {   "http://[xyz:12345.com/test", 0, S_OK, FALSE,
1309         {
1310             {"http://[xyz:12345.com/test",S_OK,FALSE},
1311             {"[xyz:12345.com",S_OK,FALSE},
1312             {"http://[xyz:12345.com/test",S_OK,FALSE},
1313             {"[xyz:12345.com",S_OK,FALSE},
1314             {"",S_FALSE,FALSE},
1315             {"",S_FALSE,FALSE},
1316             {"[xyz:12345.com",S_OK,FALSE},
1317             {"",S_FALSE,FALSE},
1318             {"/test",S_OK,FALSE},
1319             {"/test",S_OK,FALSE},
1320             {"",S_FALSE,FALSE},
1321             {"http://[xyz:12345.com/test",S_OK,FALSE},
1322             {"http",S_OK,FALSE},
1323             {"",S_FALSE,FALSE},
1324             {"",S_FALSE,FALSE}
1325         },
1326         {
1327             {Uri_HOST_DNS,S_OK,FALSE},
1328             {80,S_OK,FALSE},
1329             {URL_SCHEME_HTTP,S_OK,FALSE},
1330             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1331         }
1332     },
1333     /* Valid URI since the '[' and ']' don't appear at the beginning and end
1334      * of the host name (respectively).
1335      */
1336     {   "ftp://www.[works].com/", 0, S_OK, FALSE,
1337         {
1338             {"ftp://www.[works].com/",S_OK,FALSE},
1339             {"www.[works].com",S_OK,FALSE},
1340             {"ftp://www.[works].com/",S_OK,FALSE},
1341             {"[works].com",S_OK,FALSE},
1342             {"",S_FALSE,FALSE},
1343             {"",S_FALSE,FALSE},
1344             {"www.[works].com",S_OK,FALSE},
1345             {"",S_FALSE,FALSE},
1346             {"/",S_OK,FALSE},
1347             {"/",S_OK,FALSE},
1348             {"",S_FALSE,FALSE},
1349             {"ftp://www.[works].com/",S_OK,FALSE},
1350             {"ftp",S_OK,FALSE},
1351             {"",S_FALSE,FALSE},
1352             {"",S_FALSE,FALSE}
1353         },
1354         {
1355             {Uri_HOST_DNS,S_OK,FALSE},
1356             {21,S_OK,FALSE},
1357             {URL_SCHEME_FTP,S_OK,FALSE},
1358             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1359         }
1360     },
1361     /* Considers ':' a delimiter since it appears after the ']'. */
1362     {   "http://www.google.com]:12345/", 0, S_OK, FALSE,
1363         {
1364             {"http://www.google.com]:12345/",S_OK,FALSE},
1365             {"www.google.com]:12345",S_OK,FALSE},
1366             {"http://www.google.com]:12345/",S_OK,FALSE},
1367             {"google.com]",S_OK,FALSE},
1368             {"",S_FALSE,FALSE},
1369             {"",S_FALSE,FALSE},
1370             {"www.google.com]",S_OK,FALSE},
1371             {"",S_FALSE,FALSE},
1372             {"/",S_OK,FALSE},
1373             {"/",S_OK,FALSE},
1374             {"",S_FALSE,FALSE},
1375             {"http://www.google.com]:12345/",S_OK,FALSE},
1376             {"http",S_OK,FALSE},
1377             {"",S_FALSE,FALSE},
1378             {"",S_FALSE,FALSE}
1379         },
1380         {
1381             {Uri_HOST_DNS,S_OK,FALSE},
1382             {12345,S_OK,FALSE},
1383             {URL_SCHEME_HTTP,S_OK,FALSE},
1384             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1385         }
1386     },
1387     /* Unknown scheme types can have invalid % encoded data in the hostname. */
1388     {   "zip://w%XXw%GEw.google.com/", 0, S_OK, FALSE,
1389         {
1390             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1391             {"w%XXw%GEw.google.com",S_OK,FALSE},
1392             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1393             {"google.com",S_OK,FALSE},
1394             {"",S_FALSE,FALSE},
1395             {"",S_FALSE,FALSE},
1396             {"w%XXw%GEw.google.com",S_OK,FALSE},
1397             {"",S_FALSE,FALSE},
1398             {"/",S_OK,FALSE},
1399             {"/",S_OK,FALSE},
1400             {"",S_FALSE,FALSE},
1401             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1402             {"zip",S_OK,FALSE},
1403             {"",S_FALSE,FALSE},
1404             {"",S_FALSE,FALSE}
1405         },
1406         {
1407             {Uri_HOST_DNS,S_OK,FALSE},
1408             {0,S_FALSE,FALSE},
1409             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1410             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1411         }
1412     },
1413     /* Unknown scheme types hostname doesn't get lower cased. */
1414     {   "zip://GOOGLE.com/", 0, S_OK, FALSE,
1415         {
1416             {"zip://GOOGLE.com/",S_OK,FALSE},
1417             {"GOOGLE.com",S_OK,FALSE},
1418             {"zip://GOOGLE.com/",S_OK,FALSE},
1419             {"GOOGLE.com",S_OK,FALSE},
1420             {"",S_FALSE,FALSE},
1421             {"",S_FALSE,FALSE},
1422             {"GOOGLE.com",S_OK,FALSE},
1423             {"",S_FALSE,FALSE},
1424             {"/",S_OK,FALSE},
1425             {"/",S_OK,FALSE},
1426             {"",S_FALSE,FALSE},
1427             {"zip://GOOGLE.com/",S_OK,FALSE},
1428             {"zip",S_OK,FALSE},
1429             {"",S_FALSE,FALSE},
1430             {"",S_FALSE,FALSE}
1431         },
1432         {
1433             {Uri_HOST_DNS,S_OK,FALSE},
1434             {0,S_FALSE,FALSE},
1435             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1436             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1437         }
1438     },
1439     /* Hostname gets lower-cased for known scheme types. */
1440     {   "http://WWW.GOOGLE.com/", 0, S_OK, FALSE,
1441         {
1442             {"http://www.google.com/",S_OK,FALSE},
1443             {"www.google.com",S_OK,FALSE},
1444             {"http://www.google.com/",S_OK,FALSE},
1445             {"google.com",S_OK,FALSE},
1446             {"",S_FALSE,FALSE},
1447             {"",S_FALSE,FALSE},
1448             {"www.google.com",S_OK,FALSE},
1449             {"",S_FALSE,FALSE},
1450             {"/",S_OK,FALSE},
1451             {"/",S_OK,FALSE},
1452             {"",S_FALSE,FALSE},
1453             {"http://WWW.GOOGLE.com/",S_OK,FALSE},
1454             {"http",S_OK,FALSE},
1455             {"",S_FALSE,FALSE},
1456             {"",S_FALSE,FALSE}
1457         },
1458         {
1459             {Uri_HOST_DNS,S_OK,FALSE},
1460             {80,S_OK,FALSE},
1461             {URL_SCHEME_HTTP,S_OK,FALSE},
1462             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1463         }
1464     },
1465     /* Characters that get % encoded in the hostname also have their percent
1466      * encoded forms lower cased.
1467      */
1468     {   "http://www.%7Cgoogle|.com/", 0, S_OK, FALSE,
1469         {
1470             {"http://www.%7cgoogle%7c.com/",S_OK,FALSE},
1471             {"www.%7cgoogle%7c.com",S_OK,FALSE},
1472             {"http://www.%7cgoogle%7c.com/",S_OK,FALSE},
1473             {"%7cgoogle%7c.com",S_OK,FALSE},
1474             {"",S_FALSE,FALSE},
1475             {"",S_FALSE,FALSE},
1476             {"www.%7cgoogle%7c.com",S_OK,FALSE},
1477             {"",S_FALSE,FALSE},
1478             {"/",S_OK,FALSE},
1479             {"/",S_OK,FALSE},
1480             {"",S_FALSE,FALSE},
1481             {"http://www.%7Cgoogle|.com/",S_OK,FALSE},
1482             {"http",S_OK,FALSE},
1483             {"",S_FALSE,FALSE},
1484             {"",S_FALSE,FALSE}
1485         },
1486         {
1487             {Uri_HOST_DNS,S_OK,FALSE},
1488             {80,S_OK,FALSE},
1489             {URL_SCHEME_HTTP,S_OK,FALSE},
1490             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1491         }
1492     },
1493     /* IPv4 addresses attached to IPv6 can be included in elisions. */
1494     {   "http://[1:2:3:4:5:6:0.0.0.0]", 0, S_OK, FALSE,
1495         {
1496             {"http://[1:2:3:4:5:6::]/",S_OK,FALSE},
1497             {"[1:2:3:4:5:6::]",S_OK,FALSE},
1498             {"http://[1:2:3:4:5:6::]/",S_OK,FALSE},
1499             {"",S_FALSE,FALSE},
1500             {"",S_FALSE,FALSE},
1501             {"",S_FALSE,FALSE},
1502             {"1:2:3:4:5:6::",S_OK,FALSE},
1503             {"",S_FALSE,FALSE},
1504             {"/",S_OK,FALSE},
1505             {"/",S_OK,FALSE},
1506             {"",S_FALSE,FALSE},
1507             {"http://[1:2:3:4:5:6:0.0.0.0]",S_OK,FALSE},
1508             {"http",S_OK,FALSE},
1509             {"",S_FALSE,FALSE},
1510             {"",S_FALSE,FALSE},
1511         },
1512         {
1513             {Uri_HOST_IPV6,S_OK,FALSE},
1514             {80,S_OK,FALSE},
1515             {URL_SCHEME_HTTP,S_OK,FALSE},
1516             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1517         }
1518     },
1519     /* IPv4 addresses get normalized. */
1520     {   "http://[::001.002.003.000]", 0, S_OK, FALSE,
1521         {
1522             {"http://[::1.2.3.0]/",S_OK,FALSE},
1523             {"[::1.2.3.0]",S_OK,FALSE},
1524             {"http://[::1.2.3.0]/",S_OK,FALSE},
1525             {"",S_FALSE,FALSE},
1526             {"",S_FALSE,FALSE},
1527             {"",S_FALSE,FALSE},
1528             {"::1.2.3.0",S_OK,FALSE},
1529             {"",S_FALSE,FALSE},
1530             {"/",S_OK,FALSE},
1531             {"/",S_OK,FALSE},
1532             {"",S_FALSE,FALSE},
1533             {"http://[::001.002.003.000]",S_OK,FALSE},
1534             {"http",S_OK,FALSE},
1535             {"",S_FALSE,FALSE},
1536             {"",S_FALSE,FALSE},
1537         },
1538         {
1539             {Uri_HOST_IPV6,S_OK,FALSE},
1540             {80,S_OK,FALSE},
1541             {URL_SCHEME_HTTP,S_OK,FALSE},
1542             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1543         }
1544     },
1545     /* Windows doesn't do anything to IPv6's in unknown schemes. */
1546     {   "zip://[0001:0:000:0004:0005:0006:001.002.003.000]", 0, S_OK, FALSE,
1547         {
1548             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]/",S_OK,FALSE},
1549             {"[0001:0:000:0004:0005:0006:001.002.003.000]",S_OK,FALSE},
1550             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]/",S_OK,FALSE},
1551             {"",S_FALSE,FALSE},
1552             {"",S_FALSE,FALSE},
1553             {"",S_FALSE,FALSE},
1554             {"0001:0:000:0004:0005:0006:001.002.003.000",S_OK,FALSE},
1555             {"",S_FALSE,FALSE},
1556             {"/",S_OK,FALSE},
1557             {"/",S_OK,FALSE},
1558             {"",S_FALSE,FALSE},
1559             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]",S_OK,FALSE},
1560             {"zip",S_OK,FALSE},
1561             {"",S_FALSE,FALSE},
1562             {"",S_FALSE,FALSE},
1563         },
1564         {
1565             {Uri_HOST_IPV6,S_OK,FALSE},
1566             {0,S_FALSE,FALSE},
1567             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1568             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1569         }
1570     },
1571     /* IPv4 address is converted into 2 h16 components. */
1572     {   "http://[ffff::192.222.111.32]", 0, S_OK, FALSE,
1573         {
1574             {"http://[ffff::c0de:6f20]/",S_OK,FALSE},
1575             {"[ffff::c0de:6f20]",S_OK,FALSE},
1576             {"http://[ffff::c0de:6f20]/",S_OK,FALSE},
1577             {"",S_FALSE,FALSE},
1578             {"",S_FALSE,FALSE},
1579             {"",S_FALSE,FALSE},
1580             {"ffff::c0de:6f20",S_OK,FALSE},
1581             {"",S_FALSE,FALSE},
1582             {"/",S_OK,FALSE},
1583             {"/",S_OK,FALSE},
1584             {"",S_FALSE,FALSE},
1585             {"http://[ffff::192.222.111.32]",S_OK,FALSE},
1586             {"http",S_OK,FALSE},
1587             {"",S_FALSE,FALSE},
1588             {"",S_FALSE,FALSE},
1589         },
1590         {
1591             {Uri_HOST_IPV6,S_OK,FALSE},
1592             {80,S_OK,FALSE},
1593             {URL_SCHEME_HTTP,S_OK,FALSE},
1594             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1595         }
1596     },
1597     /* Max value for a port. */
1598     {   "http://google.com:65535", 0, S_OK, FALSE,
1599         {
1600             {"http://google.com:65535/",S_OK,FALSE},
1601             {"google.com:65535",S_OK,FALSE},
1602             {"http://google.com:65535/",S_OK,FALSE},
1603             {"google.com",S_OK,FALSE},
1604             {"",S_FALSE,FALSE},
1605             {"",S_FALSE,FALSE},
1606             {"google.com",S_OK,FALSE},
1607             {"",S_FALSE,FALSE},
1608             {"/",S_OK,FALSE},
1609             {"/",S_OK,FALSE},
1610             {"",S_FALSE,FALSE},
1611             {"http://google.com:65535",S_OK,FALSE},
1612             {"http",S_OK,FALSE},
1613             {"",S_FALSE,FALSE},
1614             {"",S_FALSE,FALSE}
1615         },
1616         {
1617             {Uri_HOST_DNS,S_OK,FALSE},
1618             {65535,S_OK,FALSE},
1619             {URL_SCHEME_HTTP,S_OK,FALSE},
1620             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1621         }
1622     },
1623     {   "zip://google.com:65536", 0, S_OK, FALSE,
1624         {
1625             {"zip://google.com:65536/",S_OK,FALSE},
1626             {"google.com:65536",S_OK,FALSE},
1627             {"zip://google.com:65536/",S_OK,FALSE},
1628             {"google.com:65536",S_OK,FALSE},
1629             {"",S_FALSE,FALSE},
1630             {"",S_FALSE,FALSE},
1631             {"google.com:65536",S_OK,FALSE},
1632             {"",S_FALSE,FALSE},
1633             {"/",S_OK,FALSE},
1634             {"/",S_OK,FALSE},
1635             {"",S_FALSE,FALSE},
1636             {"zip://google.com:65536",S_OK,FALSE},
1637             {"zip",S_OK,FALSE},
1638             {"",S_FALSE,FALSE},
1639             {"",S_FALSE,FALSE}
1640         },
1641         {
1642             {Uri_HOST_DNS,S_OK,FALSE},
1643             {0,S_FALSE,FALSE},
1644             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1645             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1646         }
1647     },
1648     {   "zip://google.com:65536:25", 0, S_OK, FALSE,
1649         {
1650             {"zip://google.com:65536:25/",S_OK,FALSE},
1651             {"google.com:65536:25",S_OK,FALSE},
1652             {"zip://google.com:65536:25/",S_OK,FALSE},
1653             {"google.com:65536:25",S_OK,FALSE},
1654             {"",S_FALSE,FALSE},
1655             {"",S_FALSE,FALSE},
1656             {"google.com:65536:25",S_OK,FALSE},
1657             {"",S_FALSE,FALSE},
1658             {"/",S_OK,FALSE},
1659             {"/",S_OK,FALSE},
1660             {"",S_FALSE,FALSE},
1661             {"zip://google.com:65536:25",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://[::ffff]:abcd", 0, S_OK, FALSE,
1674         {
1675             {"zip://[::ffff]:abcd/",S_OK,FALSE},
1676             {"[::ffff]:abcd",S_OK,FALSE},
1677             {"zip://[::ffff]:abcd/",S_OK,FALSE},
1678             {"",S_FALSE,FALSE},
1679             {"",S_FALSE,FALSE},
1680             {"",S_FALSE,FALSE},
1681             {"[::ffff]:abcd",S_OK,FALSE},
1682             {"",S_FALSE,FALSE},
1683             {"/",S_OK,FALSE},
1684             {"/",S_OK,FALSE},
1685             {"",S_FALSE,FALSE},
1686             {"zip://[::ffff]:abcd",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://127.0.0.1:abcd", 0, S_OK, FALSE,
1699         {
1700             {"zip://127.0.0.1:abcd/",S_OK,FALSE},
1701             {"127.0.0.1:abcd",S_OK,FALSE},
1702             {"zip://127.0.0.1:abcd/",S_OK,FALSE},
1703             {"0.1:abcd",S_OK,FALSE},
1704             {"",S_FALSE,FALSE},
1705             {"",S_FALSE,FALSE},
1706             {"127.0.0.1:abcd",S_OK,FALSE},
1707             {"",S_FALSE,FALSE},
1708             {"/",S_OK,FALSE},
1709             {"/",S_OK,FALSE},
1710             {"",S_FALSE,FALSE},
1711             {"zip://127.0.0.1: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     /* Port is just copied over. */
1724     {   "http://google.com:00035", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1725         {
1726             {"http://google.com:00035",S_OK,FALSE},
1727             {"google.com:00035",S_OK,FALSE},
1728             {"http://google.com:00035",S_OK,FALSE,"http://google.com:35"},
1729             {"google.com",S_OK,FALSE},
1730             {"",S_FALSE,FALSE},
1731             {"",S_FALSE,FALSE},
1732             {"google.com",S_OK,FALSE},
1733             {"",S_FALSE,FALSE},
1734             {"",S_FALSE,FALSE},
1735             {"",S_FALSE,FALSE},
1736             {"",S_FALSE,FALSE},
1737             {"http://google.com:00035",S_OK,FALSE},
1738             {"http",S_OK,FALSE},
1739             {"",S_FALSE,FALSE},
1740             {"",S_FALSE,FALSE}
1741         },
1742         {
1743             {Uri_HOST_DNS,S_OK,FALSE},
1744             {35,S_OK,FALSE},
1745             {URL_SCHEME_HTTP,S_OK,FALSE},
1746             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1747         }
1748     },
1749     /* Default port is copied over. */
1750     {   "http://google.com:80", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1751         {
1752             {"http://google.com:80",S_OK,FALSE},
1753             {"google.com:80",S_OK,FALSE},
1754             {"http://google.com:80",S_OK,FALSE},
1755             {"google.com",S_OK,FALSE},
1756             {"",S_FALSE,FALSE},
1757             {"",S_FALSE,FALSE},
1758             {"google.com",S_OK,FALSE},
1759             {"",S_FALSE,FALSE},
1760             {"",S_FALSE,FALSE},
1761             {"",S_FALSE,FALSE},
1762             {"",S_FALSE,FALSE},
1763             {"http://google.com:80",S_OK,FALSE},
1764             {"http",S_OK,FALSE},
1765             {"",S_FALSE,FALSE},
1766             {"",S_FALSE,FALSE}
1767         },
1768         {
1769             {Uri_HOST_DNS,S_OK,FALSE},
1770             {80,S_OK,FALSE},
1771             {URL_SCHEME_HTTP,S_OK,FALSE},
1772             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1773         }
1774     },
1775     {   "http://google.com.uk", 0, S_OK, FALSE,
1776         {
1777             {"http://google.com.uk/",S_OK,FALSE},
1778             {"google.com.uk",S_OK,FALSE},
1779             {"http://google.com.uk/",S_OK,FALSE},
1780             {"google.com.uk",S_OK,FALSE},
1781             {"",S_FALSE,FALSE},
1782             {"",S_FALSE,FALSE},
1783             {"google.com.uk",S_OK,FALSE},
1784             {"",S_FALSE,FALSE},
1785             {"/",S_OK,FALSE},
1786             {"/",S_OK,FALSE},
1787             {"",S_FALSE,FALSE},
1788             {"http://google.com.uk",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.com", 0, S_OK, FALSE,
1801         {
1802             {"http://google.com.com/",S_OK,FALSE},
1803             {"google.com.com",S_OK,FALSE},
1804             {"http://google.com.com/",S_OK,FALSE},
1805             {"com.com",S_OK,FALSE},
1806             {"",S_FALSE,FALSE},
1807             {"",S_FALSE,FALSE},
1808             {"google.com.com",S_OK,FALSE},
1809             {"",S_FALSE,FALSE},
1810             {"/",S_OK,FALSE},
1811             {"/",S_OK,FALSE},
1812             {"",S_FALSE,FALSE},
1813             {"http://google.com.com",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.uk.1", 0, S_OK, FALSE,
1826         {
1827             {"http://google.uk.1/",S_OK,FALSE},
1828             {"google.uk.1",S_OK,FALSE},
1829             {"http://google.uk.1/",S_OK,FALSE},
1830             {"google.uk.1",S_OK,FALSE},
1831             {"",S_FALSE,FALSE},
1832             {"",S_FALSE,FALSE},
1833             {"google.uk.1",S_OK,FALSE},
1834             {"",S_FALSE,FALSE},
1835             {"/",S_OK,FALSE},
1836             {"/",S_OK,FALSE},
1837             {"",S_FALSE,FALSE},
1838             {"http://google.uk.1",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     /* Since foo isn't a recognized 3 character TLD its considered the domain name. */
1851     {   "http://google.foo.uk", 0, S_OK, FALSE,
1852         {
1853             {"http://google.foo.uk/",S_OK,FALSE},
1854             {"google.foo.uk",S_OK,FALSE},
1855             {"http://google.foo.uk/",S_OK,FALSE},
1856             {"foo.uk",S_OK,FALSE},
1857             {"",S_FALSE,FALSE},
1858             {"",S_FALSE,FALSE},
1859             {"google.foo.uk",S_OK,FALSE},
1860             {"",S_FALSE,FALSE},
1861             {"/",S_OK,FALSE},
1862             {"/",S_OK,FALSE},
1863             {"",S_FALSE,FALSE},
1864             {"http://google.foo.uk",S_OK,FALSE},
1865             {"http",S_OK,FALSE},
1866             {"",S_FALSE,FALSE},
1867             {"",S_FALSE,FALSE}
1868         },
1869         {
1870             {Uri_HOST_DNS,S_OK,FALSE},
1871             {80,S_OK,FALSE},
1872             {URL_SCHEME_HTTP,S_OK,FALSE},
1873             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1874         }
1875     },
1876     {   "http://.com", 0, S_OK, FALSE,
1877         {
1878             {"http://.com/",S_OK,FALSE},
1879             {".com",S_OK,FALSE},
1880             {"http://.com/",S_OK,FALSE},
1881             {".com",S_OK,FALSE},
1882             {"",S_FALSE,FALSE},
1883             {"",S_FALSE,FALSE},
1884             {".com",S_OK,FALSE},
1885             {"",S_FALSE,FALSE},
1886             {"/",S_OK,FALSE},
1887             {"/",S_OK,FALSE},
1888             {"",S_FALSE,FALSE},
1889             {"http://.com",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://.uk", 0, S_OK, FALSE,
1902         {
1903             {"http://.uk/",S_OK,FALSE},
1904             {".uk",S_OK,FALSE},
1905             {"http://.uk/",S_OK,FALSE},
1906             {"",S_FALSE,FALSE},
1907             {"",S_FALSE,FALSE},
1908             {"",S_FALSE,FALSE},
1909             {".uk",S_OK,FALSE},
1910             {"",S_FALSE,FALSE},
1911             {"/",S_OK,FALSE},
1912             {"/",S_OK,FALSE},
1913             {"",S_FALSE,FALSE},
1914             {"http://.uk",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://www.co.google.com.[]", 0, S_OK, FALSE,
1927         {
1928             {"http://www.co.google.com.[]/",S_OK,FALSE},
1929             {"www.co.google.com.[]",S_OK,FALSE},
1930             {"http://www.co.google.com.[]/",S_OK,FALSE},
1931             {"google.com.[]",S_OK,FALSE},
1932             {"",S_FALSE,FALSE},
1933             {"",S_FALSE,FALSE},
1934             {"www.co.google.com.[]",S_OK,FALSE},
1935             {"",S_FALSE,FALSE},
1936             {"/",S_OK,FALSE},
1937             {"/",S_OK,FALSE},
1938             {"",S_FALSE,FALSE},
1939             {"http://www.co.google.com.[]",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://co.uk", 0, S_OK, FALSE,
1952         {
1953             {"http://co.uk/",S_OK,FALSE},
1954             {"co.uk",S_OK,FALSE},
1955             {"http://co.uk/",S_OK,FALSE},
1956             {"",S_FALSE,FALSE},
1957             {"",S_FALSE,FALSE},
1958             {"",S_FALSE,FALSE},
1959             {"co.uk",S_OK,FALSE},
1960             {"",S_FALSE,FALSE},
1961             {"/",S_OK,FALSE},
1962             {"/",S_OK,FALSE},
1963             {"",S_FALSE,FALSE},
1964             {"http://co.uk",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://www.co.google.us.test", 0, S_OK, FALSE,
1977         {
1978             {"http://www.co.google.us.test/",S_OK,FALSE},
1979             {"www.co.google.us.test",S_OK,FALSE},
1980             {"http://www.co.google.us.test/",S_OK,FALSE},
1981             {"us.test",S_OK,FALSE},
1982             {"",S_FALSE,FALSE},
1983             {"",S_FALSE,FALSE},
1984             {"www.co.google.us.test",S_OK,FALSE},
1985             {"",S_FALSE,FALSE},
1986             {"/",S_OK,FALSE},
1987             {"/",S_OK,FALSE},
1988             {"",S_FALSE,FALSE},
1989             {"http://www.co.google.us.test",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://gov.uk", 0, S_OK, FALSE,
2002         {
2003             {"http://gov.uk/",S_OK,FALSE},
2004             {"gov.uk",S_OK,FALSE},
2005             {"http://gov.uk/",S_OK,FALSE},
2006             {"",S_FALSE,FALSE},
2007             {"",S_FALSE,FALSE},
2008             {"",S_FALSE,FALSE},
2009             {"gov.uk",S_OK,FALSE},
2010             {"",S_FALSE,FALSE},
2011             {"/",S_OK,FALSE},
2012             {"/",S_OK,FALSE},
2013             {"",S_FALSE,FALSE},
2014             {"http://gov.uk",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     {   "zip://www.google.com\\test", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2027         {
2028             {"zip://www.google.com\\test",S_OK,FALSE},
2029             {"www.google.com\\test",S_OK,FALSE},
2030             {"zip://www.google.com\\test",S_OK,FALSE},
2031             {"google.com\\test",S_OK,FALSE},
2032             {"",S_FALSE,FALSE},
2033             {"",S_FALSE,FALSE},
2034             {"www.google.com\\test",S_OK,FALSE},
2035             {"",S_FALSE,FALSE},
2036             {"",S_FALSE,FALSE},
2037             {"",S_FALSE,FALSE},
2038             {"",S_FALSE,FALSE},
2039             {"zip://www.google.com\\test",S_OK,FALSE},
2040             {"zip",S_OK,FALSE},
2041             {"",S_FALSE,FALSE},
2042             {"",S_FALSE,FALSE}
2043         },
2044         {
2045             {Uri_HOST_DNS,S_OK,FALSE},
2046             {0,S_FALSE,FALSE},
2047             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2048             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2049         }
2050     },
2051     {   "urn:excepts:bad:%XY:encoded", 0, S_OK, FALSE,
2052         {
2053             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2054             {"",S_FALSE,FALSE},
2055             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2056             {"",S_FALSE,FALSE},
2057             {"",S_FALSE,FALSE},
2058             {"",S_FALSE,FALSE},
2059             {"",S_FALSE,FALSE},
2060             {"",S_FALSE,FALSE},
2061             {"excepts:bad:%XY:encoded",S_OK,FALSE},
2062             {"excepts:bad:%XY:encoded",S_OK,FALSE},
2063             {"",S_FALSE,FALSE},
2064             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2065             {"urn",S_OK,FALSE},
2066             {"",S_FALSE,FALSE},
2067             {"",S_FALSE,FALSE}
2068         },
2069         {
2070             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2071             {0,S_FALSE,FALSE},
2072             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2073             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2074         }
2075     },
2076     /* Since the original URI doesn't contain an extra '/' before the path no % encoded values
2077      * are decoded and all '%' are encoded.
2078      */
2079     {   "file://C:/te%3Es%2Et/tes%t.mp3", 0, S_OK, FALSE,
2080         {
2081             {"file:///C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2082             {"",S_FALSE,FALSE},
2083             {"file:///C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2084             {"",S_FALSE,FALSE},
2085             {".mp3",S_OK,FALSE},
2086             {"",S_FALSE,FALSE},
2087             {"",S_FALSE,FALSE},
2088             {"",S_FALSE,FALSE},
2089             {"/C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2090             {"/C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2091             {"",S_FALSE,FALSE},
2092             {"file://C:/te%3Es%2Et/tes%t.mp3",S_OK,FALSE},
2093             {"file",S_OK,FALSE},
2094             {"",S_FALSE,FALSE},
2095             {"",S_FALSE,FALSE}
2096         },
2097         {
2098             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2099             {0,S_FALSE,FALSE},
2100             {URL_SCHEME_FILE,S_OK,FALSE},
2101             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2102         }
2103     },
2104     /* Since there's a '/' in front of the drive letter, any percent encoded, non-forbidden character
2105      * is decoded and only %'s in front of invalid hex digits are encoded.
2106      */
2107     {   "file:///C:/te%3Es%2Et/t%23es%t.mp3", 0, S_OK, FALSE,
2108         {
2109             {"file:///C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2110             {"",S_FALSE,FALSE},
2111             {"file:///C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2112             {"",S_FALSE,FALSE},
2113             {".mp3",S_OK,FALSE},
2114             {"",S_FALSE,FALSE},
2115             {"",S_FALSE,FALSE},
2116             {"",S_FALSE,FALSE},
2117             {"/C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2118             {"/C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2119             {"",S_FALSE,FALSE},
2120             {"file:///C:/te%3Es%2Et/t%23es%t.mp3",S_OK,FALSE},
2121             {"file",S_OK,FALSE},
2122             {"",S_FALSE,FALSE},
2123             {"",S_FALSE,FALSE}
2124         },
2125         {
2126             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2127             {0,S_FALSE,FALSE},
2128             {URL_SCHEME_FILE,S_OK,FALSE},
2129             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2130         }
2131     },
2132     /* Only unreserved percent encoded characters are decoded for known schemes that aren't file. */
2133     {   "http://[::001.002.003.000]/%3F%23%2E%54/test", 0, S_OK, FALSE,
2134         {
2135             {"http://[::1.2.3.0]/%3F%23.T/test",S_OK,FALSE},
2136             {"[::1.2.3.0]",S_OK,FALSE},
2137             {"http://[::1.2.3.0]/%3F%23.T/test",S_OK,FALSE},
2138             {"",S_FALSE,FALSE},
2139             {"",S_FALSE,FALSE},
2140             {"",S_FALSE,FALSE},
2141             {"::1.2.3.0",S_OK,FALSE},
2142             {"",S_FALSE,FALSE},
2143             {"/%3F%23.T/test",S_OK,FALSE},
2144             {"/%3F%23.T/test",S_OK,FALSE},
2145             {"",S_FALSE,FALSE},
2146             {"http://[::001.002.003.000]/%3F%23%2E%54/test",S_OK,FALSE},
2147             {"http",S_OK,FALSE},
2148             {"",S_FALSE,FALSE},
2149             {"",S_FALSE,FALSE},
2150         },
2151         {
2152             {Uri_HOST_IPV6,S_OK,FALSE},
2153             {80,S_OK,FALSE},
2154             {URL_SCHEME_HTTP,S_OK,FALSE},
2155             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2156         }
2157     },
2158     /* Forbidden characters are always encoded for file URIs. */
2159     {   "file:///C:/\"test\"/test.mp3", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2160         {
2161             {"file:///C:/%22test%22/test.mp3",S_OK,FALSE},
2162             {"",S_FALSE,FALSE},
2163             {"file:///C:/%22test%22/test.mp3",S_OK,FALSE},
2164             {"",S_FALSE,FALSE},
2165             {".mp3",S_OK,FALSE},
2166             {"",S_FALSE,FALSE},
2167             {"",S_FALSE,FALSE},
2168             {"",S_FALSE,FALSE},
2169             {"/C:/%22test%22/test.mp3",S_OK,FALSE},
2170             {"/C:/%22test%22/test.mp3",S_OK,FALSE},
2171             {"",S_FALSE,FALSE},
2172             {"file:///C:/\"test\"/test.mp3",S_OK,FALSE},
2173             {"file",S_OK,FALSE},
2174             {"",S_FALSE,FALSE},
2175             {"",S_FALSE,FALSE}
2176         },
2177         {
2178             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2179             {0,S_FALSE,FALSE},
2180             {URL_SCHEME_FILE,S_OK,FALSE},
2181             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2182         }
2183     },
2184     /* Forbidden characters are never encoded for unknown scheme types. */
2185     {   "1234://4294967295/<|>\" test<|>", 0, S_OK, FALSE,
2186         {
2187             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2188             {"4294967295",S_OK,FALSE},
2189             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2190             {"",S_FALSE,FALSE},
2191             {"",S_FALSE,FALSE},
2192             {"",S_FALSE,FALSE},
2193             {"4294967295",S_OK,FALSE},
2194             {"",S_FALSE,FALSE},
2195             {"/<|>\" test<|>",S_OK,FALSE},
2196             {"/<|>\" test<|>",S_OK,FALSE},
2197             {"",S_FALSE,FALSE},
2198             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2199             {"1234",S_OK,FALSE},
2200             {"",S_FALSE,FALSE},
2201             {"",S_FALSE,FALSE}
2202         },
2203         {
2204             {Uri_HOST_IPV4,S_OK,FALSE},
2205             {0,S_FALSE,FALSE},
2206             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2207             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2208         }
2209     },
2210     /* Make sure forbidden characters are percent encoded. */
2211     {   "http://gov.uk/<|> test<|>", 0, S_OK, FALSE,
2212         {
2213             {"http://gov.uk/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2214             {"gov.uk",S_OK,FALSE},
2215             {"http://gov.uk/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2216             {"",S_FALSE,FALSE},
2217             {"",S_FALSE,FALSE},
2218             {"",S_FALSE,FALSE},
2219             {"gov.uk",S_OK,FALSE},
2220             {"",S_FALSE,FALSE},
2221             {"/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2222             {"/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2223             {"",S_FALSE,FALSE},
2224             {"http://gov.uk/<|> test<|>",S_OK,FALSE},
2225             {"http",S_OK,FALSE},
2226             {"",S_FALSE,FALSE},
2227             {"",S_FALSE,FALSE}
2228         },
2229         {
2230             {Uri_HOST_DNS,S_OK,FALSE},
2231             {80,S_OK,FALSE},
2232             {URL_SCHEME_HTTP,S_OK,FALSE},
2233             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2234         }
2235     },
2236     {   "http://gov.uk/test/../test2/././../test3/.././././", 0, S_OK, FALSE,
2237         {
2238             {"http://gov.uk/",S_OK,FALSE},
2239             {"gov.uk",S_OK,FALSE},
2240             {"http://gov.uk/",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             {"/",S_OK,FALSE},
2247             {"/",S_OK,FALSE},
2248             {"",S_FALSE,FALSE},
2249             {"http://gov.uk/test/../test2/././../test3/.././././",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/../../..", 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/../../..",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     {   "file://c:\\tests\\../tests\\./.\\..\\foo%20bar.mp3", 0, S_OK, FALSE,
2312         {
2313             {"file:///c:/foo%2520bar.mp3",S_OK,FALSE},
2314             {"",S_FALSE,FALSE},
2315             {"file:///c:/foo%2520bar.mp3",S_OK,FALSE},
2316             {"",S_FALSE,FALSE},
2317             {".mp3",S_OK,FALSE},
2318             {"",S_FALSE,FALSE},
2319             {"",S_FALSE,FALSE},
2320             {"",S_FALSE,FALSE},
2321             {"/c:/foo%2520bar.mp3",S_OK,FALSE},
2322             {"/c:/foo%2520bar.mp3",S_OK,FALSE},
2323             {"",S_FALSE,FALSE},
2324             {"file://c:\\tests\\../tests\\./.\\..\\foo%20bar.mp3",S_OK,FALSE},
2325             {"file",S_OK,FALSE},
2326             {"",S_FALSE,FALSE},
2327             {"",S_FALSE,FALSE}
2328         },
2329         {
2330             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2331             {0,S_FALSE,FALSE},
2332             {URL_SCHEME_FILE,S_OK,FALSE},
2333             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2334         }
2335     },
2336     /* Dot removal happens for unknown scheme types. */
2337     {   "zip://gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2338         {
2339             {"zip://gov.uk/",S_OK,FALSE},
2340             {"gov.uk",S_OK,FALSE},
2341             {"zip://gov.uk/",S_OK,FALSE},
2342             {"",S_FALSE,FALSE},
2343             {"",S_FALSE,FALSE},
2344             {"",S_FALSE,FALSE},
2345             {"gov.uk",S_OK,FALSE},
2346             {"",S_FALSE,FALSE},
2347             {"/",S_OK,FALSE},
2348             {"/",S_OK,FALSE},
2349             {"",S_FALSE,FALSE},
2350             {"zip://gov.uk/test/test2/../../.",S_OK,FALSE},
2351             {"zip",S_OK,FALSE},
2352             {"",S_FALSE,FALSE},
2353             {"",S_FALSE,FALSE}
2354         },
2355         {
2356             {Uri_HOST_DNS,S_OK,FALSE},
2357             {0,S_FALSE,FALSE},
2358             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2359             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2360         }
2361     },
2362     /* Dot removal doesn't happen if NO_CANONICALIZE is set. */
2363     {   "http://gov.uk/test/test2/../../.", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2364         {
2365             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2366             {"gov.uk",S_OK,FALSE},
2367             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2368             {"",S_FALSE,FALSE},
2369             {".",S_OK,FALSE},
2370             {"",S_FALSE,FALSE},
2371             {"gov.uk",S_OK,FALSE},
2372             {"",S_FALSE,FALSE},
2373             {"/test/test2/../../.",S_OK,FALSE},
2374             {"/test/test2/../../.",S_OK,FALSE},
2375             {"",S_FALSE,FALSE},
2376             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2377             {"http",S_OK,FALSE},
2378             {"",S_FALSE,FALSE},
2379             {"",S_FALSE,FALSE}
2380         },
2381         {
2382             {Uri_HOST_DNS,S_OK,FALSE},
2383             {80,S_OK,FALSE},
2384             {URL_SCHEME_HTTP,S_OK,FALSE},
2385             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2386         }
2387     },
2388     /* Dot removal doesn't happen for wildcard scheme types. */
2389     {   "*:gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2390         {
2391             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2392             {"gov.uk",S_OK,FALSE},
2393             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2394             {"",S_FALSE,FALSE},
2395             {".",S_OK,FALSE},
2396             {"",S_FALSE,FALSE},
2397             {"gov.uk",S_OK,FALSE},
2398             {"",S_FALSE,FALSE},
2399             {"/test/test2/../../.",S_OK,FALSE},
2400             {"/test/test2/../../.",S_OK,FALSE},
2401             {"",S_FALSE,FALSE},
2402             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2403             {"*",S_OK,FALSE},
2404             {"",S_FALSE,FALSE},
2405             {"",S_FALSE,FALSE}
2406         },
2407         {
2408             {Uri_HOST_DNS,S_OK,FALSE},
2409             {0,S_FALSE,FALSE},
2410             {URL_SCHEME_WILDCARD,S_OK,FALSE},
2411             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2412         }
2413     },
2414     /* Forbidden characters are encoded for opaque known scheme types. */
2415     {   "mailto:\"acco<|>unt@example.com\"", 0, S_OK, FALSE,
2416         {
2417             {"mailto:%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2418             {"",S_FALSE,FALSE},
2419             {"mailto:%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2420             {"",S_FALSE,FALSE},
2421             {".com%22",S_OK,FALSE},
2422             {"",S_FALSE,FALSE},
2423             {"",S_FALSE,FALSE},
2424             {"",S_FALSE,FALSE},
2425             {"%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2426             {"%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2427             {"",S_FALSE,FALSE},
2428             {"mailto:\"acco<|>unt@example.com\"",S_OK,FALSE},
2429             {"mailto",S_OK,FALSE},
2430             {"",S_FALSE,FALSE},
2431             {"",S_FALSE,FALSE}
2432         },
2433         {
2434             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2435             {0,S_FALSE,FALSE},
2436             {URL_SCHEME_MAILTO,S_OK,FALSE},
2437             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2438         }
2439     },
2440     {   "news:test.tes<|>t.com", 0, S_OK, FALSE,
2441         {
2442             {"news:test.tes%3C%7C%3Et.com",S_OK,FALSE},
2443             {"",S_FALSE,FALSE},
2444             {"news:test.tes%3C%7C%3Et.com",S_OK,FALSE},
2445             {"",S_FALSE,FALSE},
2446             {".com",S_OK,FALSE},
2447             {"",S_FALSE,FALSE},
2448             {"",S_FALSE,FALSE},
2449             {"",S_FALSE,FALSE},
2450             {"test.tes%3C%7C%3Et.com",S_OK,FALSE},
2451             {"test.tes%3C%7C%3Et.com",S_OK,FALSE},
2452             {"",S_FALSE,FALSE},
2453             {"news:test.tes<|>t.com",S_OK,FALSE},
2454             {"news",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_NEWS,S_OK,FALSE},
2462             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2463         }
2464     },
2465     /* Don't encode forbidden characters. */
2466     {   "news:test.tes<|>t.com", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2467         {
2468             {"news:test.tes<|>t.com",S_OK,FALSE},
2469             {"",S_FALSE,FALSE},
2470             {"news:test.tes<|>t.com",S_OK,FALSE},
2471             {"",S_FALSE,FALSE},
2472             {".com",S_OK,FALSE},
2473             {"",S_FALSE,FALSE},
2474             {"",S_FALSE,FALSE},
2475             {"",S_FALSE,FALSE},
2476             {"test.tes<|>t.com",S_OK,FALSE},
2477             {"test.tes<|>t.com",S_OK,FALSE},
2478             {"",S_FALSE,FALSE},
2479             {"news:test.tes<|>t.com",S_OK,FALSE},
2480             {"news",S_OK,FALSE},
2481             {"",S_FALSE,FALSE},
2482             {"",S_FALSE,FALSE}
2483         },
2484         {
2485             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2486             {0,S_FALSE,FALSE},
2487             {URL_SCHEME_NEWS,S_OK,FALSE},
2488             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2489         }
2490     },
2491     /* Forbidden characters aren't encoded for unknown, opaque URIs. */
2492     {   "urn:test.tes<|>t.com", 0, S_OK, FALSE,
2493         {
2494             {"urn:test.tes<|>t.com",S_OK,FALSE},
2495             {"",S_FALSE,FALSE},
2496             {"urn:test.tes<|>t.com",S_OK,FALSE},
2497             {"",S_FALSE,FALSE},
2498             {".com",S_OK,FALSE},
2499             {"",S_FALSE,FALSE},
2500             {"",S_FALSE,FALSE},
2501             {"",S_FALSE,FALSE},
2502             {"test.tes<|>t.com",S_OK,FALSE},
2503             {"test.tes<|>t.com",S_OK,FALSE},
2504             {"",S_FALSE,FALSE},
2505             {"urn:test.tes<|>t.com",S_OK,FALSE},
2506             {"urn",S_OK,FALSE},
2507             {"",S_FALSE,FALSE},
2508             {"",S_FALSE,FALSE}
2509         },
2510         {
2511             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2512             {0,S_FALSE,FALSE},
2513             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2514             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2515         }
2516     },
2517     /* Percent encoded unreserved characters are decoded for known opaque URIs. */
2518     {   "news:test.%74%65%73%74.com", 0, S_OK, FALSE,
2519         {
2520             {"news:test.test.com",S_OK,FALSE},
2521             {"",S_FALSE,FALSE},
2522             {"news:test.test.com",S_OK,FALSE},
2523             {"",S_FALSE,FALSE},
2524             {".com",S_OK,FALSE},
2525             {"",S_FALSE,FALSE},
2526             {"",S_FALSE,FALSE},
2527             {"",S_FALSE,FALSE},
2528             {"test.test.com",S_OK,FALSE},
2529             {"test.test.com",S_OK,FALSE},
2530             {"",S_FALSE,FALSE},
2531             {"news:test.%74%65%73%74.com",S_OK,FALSE},
2532             {"news",S_OK,FALSE},
2533             {"",S_FALSE,FALSE},
2534             {"",S_FALSE,FALSE}
2535         },
2536         {
2537             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2538             {0,S_FALSE,FALSE},
2539             {URL_SCHEME_NEWS,S_OK,FALSE},
2540             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2541         }
2542     },
2543     /* Percent encoded characters are still decoded for known scheme types. */
2544     {   "news:test.%74%65%73%74.com", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2545         {
2546             {"news:test.test.com",S_OK,FALSE},
2547             {"",S_FALSE,FALSE},
2548             {"news:test.test.com",S_OK,FALSE},
2549             {"",S_FALSE,FALSE},
2550             {".com",S_OK,FALSE},
2551             {"",S_FALSE,FALSE},
2552             {"",S_FALSE,FALSE},
2553             {"",S_FALSE,FALSE},
2554             {"test.test.com",S_OK,FALSE},
2555             {"test.test.com",S_OK,FALSE},
2556             {"",S_FALSE,FALSE},
2557             {"news:test.%74%65%73%74.com",S_OK,FALSE},
2558             {"news",S_OK,FALSE},
2559             {"",S_FALSE,FALSE},
2560             {"",S_FALSE,FALSE}
2561         },
2562         {
2563             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2564             {0,S_FALSE,FALSE},
2565             {URL_SCHEME_NEWS,S_OK,FALSE},
2566             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2567         }
2568     },
2569     /* Percent encoded characters aren't decoded for unknown scheme types. */
2570     {   "urn:test.%74%65%73%74.com", 0, S_OK, FALSE,
2571         {
2572             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2573             {"",S_FALSE,FALSE},
2574             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2575             {"",S_FALSE,FALSE},
2576             {".com",S_OK,FALSE},
2577             {"",S_FALSE,FALSE},
2578             {"",S_FALSE,FALSE},
2579             {"",S_FALSE,FALSE},
2580             {"test.%74%65%73%74.com",S_OK,FALSE},
2581             {"test.%74%65%73%74.com",S_OK,FALSE},
2582             {"",S_FALSE,FALSE},
2583             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2584             {"urn",S_OK,FALSE},
2585             {"",S_FALSE,FALSE},
2586             {"",S_FALSE,FALSE}
2587         },
2588         {
2589             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2590             {0,S_FALSE,FALSE},
2591             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2592             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2593         }
2594     },
2595     /* Unknown scheme types can have invalid % encoded data in query string. */
2596     {   "zip://www.winehq.org/tests/..?query=%xx&return=y", 0, S_OK, FALSE,
2597         {
2598             {"zip://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2599             {"www.winehq.org",S_OK,FALSE},
2600             {"zip://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2601             {"winehq.org",S_OK,FALSE},
2602             {"",S_FALSE,FALSE},
2603             {"",S_FALSE,FALSE},
2604             {"www.winehq.org",S_OK,FALSE},
2605             {"",S_FALSE,FALSE},
2606             {"/",S_OK,FALSE},
2607             {"/?query=%xx&return=y",S_OK,FALSE},
2608             {"?query=%xx&return=y",S_OK,FALSE},
2609             {"zip://www.winehq.org/tests/..?query=%xx&return=y",S_OK,FALSE},
2610             {"zip",S_OK,FALSE},
2611             {"",S_FALSE,FALSE},
2612             {"",S_FALSE,FALSE}
2613         },
2614         {
2615             {Uri_HOST_DNS,S_OK,FALSE},
2616             {0,S_FALSE,FALSE},
2617             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2618             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2619         }
2620     },
2621     /* Known scheme types can have invalid % encoded data with the right flags. */
2622     {   "http://www.winehq.org/tests/..?query=%xx&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2623         {
2624             {"http://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2625             {"www.winehq.org",S_OK,FALSE},
2626             {"http://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2627             {"winehq.org",S_OK,FALSE},
2628             {"",S_FALSE,FALSE},
2629             {"",S_FALSE,FALSE},
2630             {"www.winehq.org",S_OK,FALSE},
2631             {"",S_FALSE,FALSE},
2632             {"/",S_OK,FALSE},
2633             {"/?query=%xx&return=y",S_OK,FALSE},
2634             {"?query=%xx&return=y",S_OK,FALSE},
2635             {"http://www.winehq.org/tests/..?query=%xx&return=y",S_OK,FALSE},
2636             {"http",S_OK,FALSE},
2637             {"",S_FALSE,FALSE},
2638             {"",S_FALSE,FALSE}
2639         },
2640         {
2641             {Uri_HOST_DNS,S_OK,FALSE},
2642             {80,S_OK,FALSE},
2643             {URL_SCHEME_HTTP,S_OK,FALSE},
2644             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2645         }
2646     },
2647     /* Forbidden characters in query aren't percent encoded for known scheme types with this flag. */
2648     {   "http://www.winehq.org/tests/..?query=<|>&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2649         {
2650             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2651             {"www.winehq.org",S_OK,FALSE},
2652             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2653             {"winehq.org",S_OK,FALSE},
2654             {"",S_FALSE,FALSE},
2655             {"",S_FALSE,FALSE},
2656             {"www.winehq.org",S_OK,FALSE},
2657             {"",S_FALSE,FALSE},
2658             {"/",S_OK,FALSE},
2659             {"/?query=<|>&return=y",S_OK,FALSE},
2660             {"?query=<|>&return=y",S_OK,FALSE},
2661             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2662             {"http",S_OK,FALSE},
2663             {"",S_FALSE,FALSE},
2664             {"",S_FALSE,FALSE}
2665         },
2666         {
2667             {Uri_HOST_DNS,S_OK,FALSE},
2668             {80,S_OK,FALSE},
2669             {URL_SCHEME_HTTP,S_OK,FALSE},
2670             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2671         }
2672     },
2673     /* Forbidden characters in query aren't percent encoded for known scheme types with this flag. */
2674     {   "http://www.winehq.org/tests/..?query=<|>&return=y", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2675         {
2676             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2677             {"www.winehq.org",S_OK,FALSE},
2678             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2679             {"winehq.org",S_OK,FALSE},
2680             {"",S_FALSE,FALSE},
2681             {"",S_FALSE,FALSE},
2682             {"www.winehq.org",S_OK,FALSE},
2683             {"",S_FALSE,FALSE},
2684             {"/",S_OK,FALSE},
2685             {"/?query=<|>&return=y",S_OK,FALSE},
2686             {"?query=<|>&return=y",S_OK,FALSE},
2687             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2688             {"http",S_OK,FALSE},
2689             {"",S_FALSE,FALSE},
2690             {"",S_FALSE,FALSE}
2691         },
2692         {
2693             {Uri_HOST_DNS,S_OK,FALSE},
2694             {80,S_OK,FALSE},
2695             {URL_SCHEME_HTTP,S_OK,FALSE},
2696             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2697         }
2698     },
2699     /* Forbidden characters are encoded for known scheme types. */
2700     {   "http://www.winehq.org/tests/..?query=<|>&return=y", 0, S_OK, FALSE,
2701         {
2702             {"http://www.winehq.org/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2703             {"www.winehq.org",S_OK,FALSE},
2704             {"http://www.winehq.org/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2705             {"winehq.org",S_OK,FALSE},
2706             {"",S_FALSE,FALSE},
2707             {"",S_FALSE,FALSE},
2708             {"www.winehq.org",S_OK,FALSE},
2709             {"",S_FALSE,FALSE},
2710             {"/",S_OK,FALSE},
2711             {"/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2712             {"?query=%3C%7C%3E&return=y",S_OK,FALSE},
2713             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2714             {"http",S_OK,FALSE},
2715             {"",S_FALSE,FALSE},
2716             {"",S_FALSE,FALSE}
2717         },
2718         {
2719             {Uri_HOST_DNS,S_OK,FALSE},
2720             {80,S_OK,FALSE},
2721             {URL_SCHEME_HTTP,S_OK,FALSE},
2722             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2723         }
2724     },
2725     /* Forbidden characters are not encoded for unknown scheme types. */
2726     {   "zip://www.winehq.org/tests/..?query=<|>&return=y", 0, S_OK, FALSE,
2727         {
2728             {"zip://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2729             {"www.winehq.org",S_OK,FALSE},
2730             {"zip://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2731             {"winehq.org",S_OK,FALSE},
2732             {"",S_FALSE,FALSE},
2733             {"",S_FALSE,FALSE},
2734             {"www.winehq.org",S_OK,FALSE},
2735             {"",S_FALSE,FALSE},
2736             {"/",S_OK,FALSE},
2737             {"/?query=<|>&return=y",S_OK,FALSE},
2738             {"?query=<|>&return=y",S_OK,FALSE},
2739             {"zip://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2740             {"zip",S_OK,FALSE},
2741             {"",S_FALSE,FALSE},
2742             {"",S_FALSE,FALSE}
2743         },
2744         {
2745             {Uri_HOST_DNS,S_OK,FALSE},
2746             {0,S_FALSE,FALSE},
2747             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2748             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2749         }
2750     },
2751     /* Percent encoded, unreserved characters are decoded for known scheme types. */
2752     {   "http://www.winehq.org/tests/..?query=%30%31&return=y", 0, S_OK, FALSE,
2753         {
2754             {"http://www.winehq.org/?query=01&return=y",S_OK,FALSE},
2755             {"www.winehq.org",S_OK,FALSE},
2756             {"http://www.winehq.org/?query=01&return=y",S_OK,FALSE},
2757             {"winehq.org",S_OK,FALSE},
2758             {"",S_FALSE,FALSE},
2759             {"",S_FALSE,FALSE},
2760             {"www.winehq.org",S_OK,FALSE},
2761             {"",S_FALSE,FALSE},
2762             {"/",S_OK,FALSE},
2763             {"/?query=01&return=y",S_OK,FALSE},
2764             {"?query=01&return=y",S_OK,FALSE},
2765             {"http://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2766             {"http",S_OK,FALSE},
2767             {"",S_FALSE,FALSE},
2768             {"",S_FALSE,FALSE}
2769         },
2770         {
2771             {Uri_HOST_DNS,S_OK,FALSE},
2772             {80,S_OK,FALSE},
2773             {URL_SCHEME_HTTP,S_OK,FALSE},
2774             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2775         }
2776     },
2777     /* Percent encoded, unreserved characters aren't decoded for unknown scheme types. */
2778     {   "zip://www.winehq.org/tests/..?query=%30%31&return=y", 0, S_OK, FALSE,
2779         {
2780             {"zip://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2781             {"www.winehq.org",S_OK,FALSE},
2782             {"zip://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2783             {"winehq.org",S_OK,FALSE},
2784             {"",S_FALSE,FALSE},
2785             {"",S_FALSE,FALSE},
2786             {"www.winehq.org",S_OK,FALSE},
2787             {"",S_FALSE,FALSE},
2788             {"/",S_OK,FALSE},
2789             {"/?query=%30%31&return=y",S_OK,FALSE},
2790             {"?query=%30%31&return=y",S_OK,FALSE},
2791             {"zip://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2792             {"zip",S_OK,FALSE},
2793             {"",S_FALSE,FALSE},
2794             {"",S_FALSE,FALSE}
2795         },
2796         {
2797             {Uri_HOST_DNS,S_OK,FALSE},
2798             {0,S_FALSE,FALSE},
2799             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2800             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2801         }
2802     },
2803     /* Percent encoded characters aren't decoded when NO_DECODE_EXTRA_INFO is set. */
2804     {   "http://www.winehq.org/tests/..?query=%30%31&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2805         {
2806             {"http://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2807             {"www.winehq.org",S_OK,FALSE},
2808             {"http://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2809             {"winehq.org",S_OK,FALSE},
2810             {"",S_FALSE,FALSE},
2811             {"",S_FALSE,FALSE},
2812             {"www.winehq.org",S_OK,FALSE},
2813             {"",S_FALSE,FALSE},
2814             {"/",S_OK,FALSE},
2815             {"/?query=%30%31&return=y",S_OK,FALSE},
2816             {"?query=%30%31&return=y",S_OK,FALSE},
2817             {"http://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2818             {"http",S_OK,FALSE},
2819             {"",S_FALSE,FALSE},
2820             {"",S_FALSE,FALSE}
2821         },
2822         {
2823             {Uri_HOST_DNS,S_OK,FALSE},
2824             {80,S_OK,FALSE},
2825             {URL_SCHEME_HTTP,S_OK,FALSE},
2826             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2827         }
2828     },
2829     {   "http://www.winehq.org?query=12&return=y", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2830         {
2831             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2832             {"www.winehq.org",S_OK,FALSE},
2833             {"http://www.winehq.org?query=12&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_FALSE,FALSE},
2840             {"?query=12&return=y",S_OK,FALSE},
2841             {"?query=12&return=y",S_OK,FALSE},
2842             {"http://www.winehq.org?query=12&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     /* Unknown scheme types can have invalid % encoded data in fragments. */
2855     {   "zip://www.winehq.org/tests/#Te%xx", 0, S_OK, FALSE,
2856         {
2857             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2858             {"www.winehq.org",S_OK,FALSE},
2859             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2860             {"winehq.org",S_OK,FALSE},
2861             {"",S_FALSE,FALSE},
2862             {"#Te%xx",S_OK,FALSE},
2863             {"www.winehq.org",S_OK,FALSE},
2864             {"",S_FALSE,FALSE},
2865             {"/tests/",S_OK,FALSE},
2866             {"/tests/",S_OK,FALSE},
2867             {"",S_FALSE,FALSE},
2868             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2869             {"zip",S_OK,FALSE},
2870             {"",S_FALSE,FALSE},
2871             {"",S_FALSE,FALSE}
2872         },
2873         {
2874             {Uri_HOST_DNS,S_OK,FALSE},
2875             {0,S_FALSE,FALSE},
2876             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2877             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2878         }
2879     },
2880     /* Forbidden characters in fragment aren't encoded for unknown schemes. */
2881     {   "zip://www.winehq.org/tests/#Te<|>", 0, S_OK, FALSE,
2882         {
2883             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2884             {"www.winehq.org",S_OK,FALSE},
2885             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2886             {"winehq.org",S_OK,FALSE},
2887             {"",S_FALSE,FALSE},
2888             {"#Te<|>",S_OK,FALSE},
2889             {"www.winehq.org",S_OK,FALSE},
2890             {"",S_FALSE,FALSE},
2891             {"/tests/",S_OK,FALSE},
2892             {"/tests/",S_OK,FALSE},
2893             {"",S_FALSE,FALSE},
2894             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2895             {"zip",S_OK,FALSE},
2896             {"",S_FALSE,FALSE},
2897             {"",S_FALSE,FALSE}
2898         },
2899         {
2900             {Uri_HOST_DNS,S_OK,FALSE},
2901             {0,S_FALSE,FALSE},
2902             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2903             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2904         }
2905     },
2906     /* Forbidden characters in the fragment are percent encoded for known schemes. */
2907     {   "http://www.winehq.org/tests/#Te<|>", 0, S_OK, FALSE,
2908         {
2909             {"http://www.winehq.org/tests/#Te%3C%7C%3E",S_OK,FALSE},
2910             {"www.winehq.org",S_OK,FALSE},
2911             {"http://www.winehq.org/tests/#Te%3C%7C%3E",S_OK,FALSE},
2912             {"winehq.org",S_OK,FALSE},
2913             {"",S_FALSE,FALSE},
2914             {"#Te%3C%7C%3E",S_OK,FALSE},
2915             {"www.winehq.org",S_OK,FALSE},
2916             {"",S_FALSE,FALSE},
2917             {"/tests/",S_OK,FALSE},
2918             {"/tests/",S_OK,FALSE},
2919             {"",S_FALSE,FALSE},
2920             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2921             {"http",S_OK,FALSE},
2922             {"",S_FALSE,FALSE},
2923             {"",S_FALSE,FALSE}
2924         },
2925         {
2926             {Uri_HOST_DNS,S_OK,FALSE},
2927             {80,S_OK,FALSE},
2928             {URL_SCHEME_HTTP,S_OK,FALSE},
2929             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2930         }
2931     },
2932     /* Forbidden characters aren't encoded in the fragment with this flag. */
2933     {   "http://www.winehq.org/tests/#Te<|>", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2934         {
2935             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2936             {"www.winehq.org",S_OK,FALSE},
2937             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2938             {"winehq.org",S_OK,FALSE},
2939             {"",S_FALSE,FALSE},
2940             {"#Te<|>",S_OK,FALSE},
2941             {"www.winehq.org",S_OK,FALSE},
2942             {"",S_FALSE,FALSE},
2943             {"/tests/",S_OK,FALSE},
2944             {"/tests/",S_OK,FALSE},
2945             {"",S_FALSE,FALSE},
2946             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2947             {"http",S_OK,FALSE},
2948             {"",S_FALSE,FALSE},
2949             {"",S_FALSE,FALSE}
2950         },
2951         {
2952             {Uri_HOST_DNS,S_OK,FALSE},
2953             {80,S_OK,FALSE},
2954             {URL_SCHEME_HTTP,S_OK,FALSE},
2955             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2956         }
2957     },
2958     /* Forbidden characters aren't encoded in the fragment with this flag. */
2959     {   "http://www.winehq.org/tests/#Te<|>", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2960         {
2961             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2962             {"www.winehq.org",S_OK,FALSE},
2963             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2964             {"winehq.org",S_OK,FALSE},
2965             {"",S_FALSE,FALSE},
2966             {"#Te<|>",S_OK,FALSE},
2967             {"www.winehq.org",S_OK,FALSE},
2968             {"",S_FALSE,FALSE},
2969             {"/tests/",S_OK,FALSE},
2970             {"/tests/",S_OK,FALSE},
2971             {"",S_FALSE,FALSE},
2972             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2973             {"http",S_OK,FALSE},
2974             {"",S_FALSE,FALSE},
2975             {"",S_FALSE,FALSE}
2976         },
2977         {
2978             {Uri_HOST_DNS,S_OK,FALSE},
2979             {80,S_OK,FALSE},
2980             {URL_SCHEME_HTTP,S_OK,FALSE},
2981             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2982         }
2983     },
2984     /* Percent encoded, unreserved characters aren't decoded for known scheme types. */
2985     {   "zip://www.winehq.org/tests/#Te%30%31%32", 0, S_OK, FALSE,
2986         {
2987             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2988             {"www.winehq.org",S_OK,FALSE},
2989             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2990             {"winehq.org",S_OK,FALSE},
2991             {"",S_FALSE,FALSE},
2992             {"#Te%30%31%32",S_OK,FALSE},
2993             {"www.winehq.org",S_OK,FALSE},
2994             {"",S_FALSE,FALSE},
2995             {"/tests/",S_OK,FALSE},
2996             {"/tests/",S_OK,FALSE},
2997             {"",S_FALSE,FALSE},
2998             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2999             {"zip",S_OK,FALSE},
3000             {"",S_FALSE,FALSE},
3001             {"",S_FALSE,FALSE}
3002         },
3003         {
3004             {Uri_HOST_DNS,S_OK,FALSE},
3005             {0,S_FALSE,FALSE},
3006             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3007             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3008         }
3009     },
3010     /* Percent encoded, unreserved characters are decoded for known schemes. */
3011     {   "http://www.winehq.org/tests/#Te%30%31%32", 0, S_OK, FALSE,
3012         {
3013             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
3014             {"www.winehq.org",S_OK,FALSE},
3015             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
3016             {"winehq.org",S_OK,FALSE},
3017             {"",S_FALSE,FALSE},
3018             {"#Te012",S_OK,FALSE},
3019             {"www.winehq.org",S_OK,FALSE},
3020             {"",S_FALSE,FALSE},
3021             {"/tests/",S_OK,FALSE},
3022             {"/tests/",S_OK,FALSE},
3023             {"",S_FALSE,FALSE},
3024             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3025             {"http",S_OK,FALSE},
3026             {"",S_FALSE,FALSE},
3027             {"",S_FALSE,FALSE}
3028         },
3029         {
3030             {Uri_HOST_DNS,S_OK,FALSE},
3031             {80,S_OK,FALSE},
3032             {URL_SCHEME_HTTP,S_OK,FALSE},
3033             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3034         }
3035     },
3036     /* Percent encoded, unreserved characters are decoded even if NO_CANONICALIZE is set. */
3037     {   "http://www.winehq.org/tests/#Te%30%31%32", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
3038         {
3039             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
3040             {"www.winehq.org",S_OK,FALSE},
3041             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
3042             {"winehq.org",S_OK,FALSE},
3043             {"",S_FALSE,FALSE},
3044             {"#Te012",S_OK,FALSE},
3045             {"www.winehq.org",S_OK,FALSE},
3046             {"",S_FALSE,FALSE},
3047             {"/tests/",S_OK,FALSE},
3048             {"/tests/",S_OK,FALSE},
3049             {"",S_FALSE,FALSE},
3050             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3051             {"http",S_OK,FALSE},
3052             {"",S_FALSE,FALSE},
3053             {"",S_FALSE,FALSE}
3054         },
3055         {
3056             {Uri_HOST_DNS,S_OK,FALSE},
3057             {80,S_OK,FALSE},
3058             {URL_SCHEME_HTTP,S_OK,FALSE},
3059             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3060         }
3061     },
3062     /* Percent encoded, unreserved characters aren't decoded when NO_DECODE_EXTRA is set. */
3063     {   "http://www.winehq.org/tests/#Te%30%31%32", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
3064         {
3065             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3066             {"www.winehq.org",S_OK,FALSE},
3067             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3068             {"winehq.org",S_OK,FALSE},
3069             {"",S_FALSE,FALSE},
3070             {"#Te%30%31%32",S_OK,FALSE},
3071             {"www.winehq.org",S_OK,FALSE},
3072             {"",S_FALSE,FALSE},
3073             {"/tests/",S_OK,FALSE},
3074             {"/tests/",S_OK,FALSE},
3075             {"",S_FALSE,FALSE},
3076             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3077             {"http",S_OK,FALSE},
3078             {"",S_FALSE,FALSE},
3079             {"",S_FALSE,FALSE}
3080         },
3081         {
3082             {Uri_HOST_DNS,S_OK,FALSE},
3083             {80,S_OK,FALSE},
3084             {URL_SCHEME_HTTP,S_OK,FALSE},
3085             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3086         }
3087     },
3088     /* Leading/Trailing whitespace is removed. */
3089     {   "    http://google.com/     ", 0, S_OK, FALSE,
3090         {
3091             {"http://google.com/",S_OK,FALSE},
3092             {"google.com",S_OK,FALSE},
3093             {"http://google.com/",S_OK,FALSE},
3094             {"google.com",S_OK,FALSE},
3095             {"",S_FALSE,FALSE},
3096             {"",S_FALSE,FALSE},
3097             {"google.com",S_OK,FALSE},
3098             {"",S_FALSE,FALSE},
3099             {"/",S_OK,FALSE},
3100             {"/",S_OK,FALSE},
3101             {"",S_FALSE,FALSE},
3102             {"http://google.com/",S_OK,FALSE},
3103             {"http",S_OK,FALSE},
3104             {"",S_FALSE,FALSE},
3105             {"",S_FALSE,FALSE}
3106         },
3107         {
3108             {Uri_HOST_DNS,S_OK,FALSE},
3109             {80,S_OK,FALSE},
3110             {URL_SCHEME_HTTP,S_OK,FALSE},
3111             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3112         }
3113     },
3114     {   "\t\t\r\nhttp\n://g\noogle.co\rm/\n\n\n", 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     {   "http://g\noogle.co\rm/\n\n\n", Uri_CREATE_NO_PRE_PROCESS_HTML_URI, S_OK, FALSE,
3140         {
3141             {"http://g%0aoogle.co%0dm/%0A%0A%0A",S_OK,FALSE},
3142             {"g%0aoogle.co%0dm",S_OK,FALSE},
3143             {"http://g%0aoogle.co%0dm/%0A%0A%0A",S_OK,FALSE},
3144             {"g%0aoogle.co%0dm",S_OK,FALSE},
3145             {"",S_FALSE,FALSE},
3146             {"",S_FALSE,FALSE},
3147             {"g%0aoogle.co%0dm",S_OK,FALSE},
3148             {"",S_FALSE,FALSE},
3149             {"/%0A%0A%0A",S_OK,FALSE},
3150             {"/%0A%0A%0A",S_OK,FALSE},
3151             {"",S_FALSE,FALSE},
3152             {"http://g\noogle.co\rm/\n\n\n",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     {   "zip://g\noogle.co\rm/\n\n\n", Uri_CREATE_NO_PRE_PROCESS_HTML_URI, S_OK, FALSE,
3165         {
3166             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3167             {"g\noogle.co\rm",S_OK,FALSE},
3168             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3169             {"g\noogle.co\rm",S_OK,FALSE},
3170             {"",S_FALSE,FALSE},
3171             {"",S_FALSE,FALSE},
3172             {"g\noogle.co\rm",S_OK,FALSE},
3173             {"",S_FALSE,FALSE},
3174             {"/\n\n\n",S_OK,FALSE},
3175             {"/\n\n\n",S_OK,FALSE},
3176             {"",S_FALSE,FALSE},
3177             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3178             {"zip",S_OK,FALSE},
3179             {"",S_FALSE,FALSE},
3180             {"",S_FALSE,FALSE}
3181         },
3182         {
3183             {Uri_HOST_DNS,S_OK,FALSE},
3184             {0,S_FALSE,FALSE},
3185             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3186             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3187         }
3188     },
3189     /* Since file URLs are usually hierarchical, it returns an empty string
3190      * for the absolute URI property since it was declared as an opaque URI.
3191      */
3192     {   "file:index.html", 0, S_OK, FALSE,
3193         {
3194             {"",S_FALSE,FALSE},
3195             {"",S_FALSE,FALSE},
3196             {"file:index.html",S_OK,FALSE},
3197             {"",S_FALSE,FALSE},
3198             {".html",S_OK,FALSE},
3199             {"",S_FALSE,FALSE},
3200             {"",S_FALSE,FALSE},
3201             {"",S_FALSE,FALSE},
3202             {"index.html",S_OK,FALSE},
3203             {"index.html",S_OK,FALSE},
3204             {"",S_FALSE,FALSE},
3205             {"file:index.html",S_OK,FALSE},
3206             {"file",S_OK,FALSE},
3207             {"",S_FALSE,FALSE},
3208             {"",S_FALSE,FALSE}
3209         },
3210         {
3211             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3212             {0,S_FALSE,FALSE},
3213             {URL_SCHEME_FILE,S_OK,FALSE},
3214             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3215         }
3216     },
3217     /* Doesn't have an absolute since it's opaque, but gets it port set. */
3218     {   "http:test.com/index.html", 0, S_OK, FALSE,
3219         {
3220             {"",S_FALSE,FALSE},
3221             {"",S_FALSE,FALSE},
3222             {"http:test.com/index.html",S_OK,FALSE},
3223             {"",S_FALSE,FALSE},
3224             {".html",S_OK,FALSE},
3225             {"",S_FALSE,FALSE},
3226             {"",S_FALSE,FALSE},
3227             {"",S_FALSE,FALSE},
3228             {"test.com/index.html",S_OK,FALSE},
3229             {"test.com/index.html",S_OK,FALSE},
3230             {"",S_FALSE,FALSE},
3231             {"http:test.com/index.html",S_OK,FALSE},
3232             {"http",S_OK,FALSE},
3233             {"",S_FALSE,FALSE},
3234             {"",S_FALSE,FALSE}
3235         },
3236         {
3237             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3238             {80,S_OK,FALSE},
3239             {URL_SCHEME_HTTP,S_OK,FALSE},
3240             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3241         }
3242     },
3243     {   "ftp:test.com/index.html", 0, S_OK, FALSE,
3244         {
3245             {"",S_FALSE,FALSE},
3246             {"",S_FALSE,FALSE},
3247             {"ftp: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             {"ftp:test.com/index.html",S_OK,FALSE},
3257             {"ftp",S_OK,FALSE},
3258             {"",S_FALSE,FALSE},
3259             {"",S_FALSE,FALSE}
3260         },
3261         {
3262             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3263             {21,S_OK,FALSE},
3264             {URL_SCHEME_FTP,S_OK,FALSE},
3265             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3266         }
3267     },
3268     {   "file://C|/test.mp3", 0, S_OK, FALSE,
3269         {
3270             {"file:///C:/test.mp3",S_OK,FALSE},
3271             {"",S_FALSE,FALSE},
3272             {"file:///C:/test.mp3",S_OK,FALSE},
3273             {"",S_FALSE,FALSE},
3274             {".mp3",S_OK,FALSE},
3275             {"",S_FALSE,FALSE},
3276             {"",S_FALSE,FALSE},
3277             {"",S_FALSE,FALSE},
3278             {"/C:/test.mp3",S_OK,FALSE},
3279             {"/C:/test.mp3",S_OK,FALSE},
3280             {"",S_FALSE,FALSE},
3281             {"file://C|/test.mp3",S_OK,FALSE},
3282             {"file",S_OK,FALSE},
3283             {"",S_FALSE,FALSE},
3284             {"",S_FALSE,FALSE}
3285         },
3286         {
3287             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3288             {0,S_FALSE,FALSE},
3289             {URL_SCHEME_FILE,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     /* Extra '/' isn't added before "c:" since USE_DOS_PATH is set and '/' are converted
3319      * to '\\'.
3320      */
3321     {   "file://c:/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3322         {
3323             {"file://c:\\dir\\index.html",S_OK,FALSE},
3324             {"",S_FALSE,FALSE},
3325             {"file://c:\\dir\\index.html",S_OK,FALSE},
3326             {"",S_FALSE,FALSE},
3327             {".html",S_OK,FALSE},
3328             {"",S_FALSE,FALSE},
3329             {"",S_FALSE,FALSE},
3330             {"",S_FALSE,FALSE},
3331             {"c:\\dir\\index.html",S_OK,FALSE},
3332             {"c:\\dir\\index.html",S_OK,FALSE},
3333             {"",S_FALSE,FALSE},
3334             {"file://c:/dir/index.html",S_OK,FALSE},
3335             {"file",S_OK,FALSE},
3336             {"",S_FALSE,FALSE},
3337             {"",S_FALSE,FALSE}
3338         },
3339         {
3340             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3341             {0,S_FALSE,FALSE},
3342             {URL_SCHEME_FILE,S_OK,FALSE},
3343             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3344         }
3345     },
3346     /* Extra '/' after "file://" is removed. */
3347     {   "file:///c:/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3348         {
3349             {"file://c:\\dir\\index.html",S_OK,FALSE},
3350             {"",S_FALSE,FALSE},
3351             {"file://c:\\dir\\index.html",S_OK,FALSE},
3352             {"",S_FALSE,FALSE},
3353             {".html",S_OK,FALSE},
3354             {"",S_FALSE,FALSE},
3355             {"",S_FALSE,FALSE},
3356             {"",S_FALSE,FALSE},
3357             {"c:\\dir\\index.html",S_OK,FALSE},
3358             {"c:\\dir\\index.html",S_OK,FALSE},
3359             {"",S_FALSE,FALSE},
3360             {"file:///c:/dir/index.html",S_OK,FALSE},
3361             {"file",S_OK,FALSE},
3362             {"",S_FALSE,FALSE},
3363             {"",S_FALSE,FALSE}
3364         },
3365         {
3366             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3367             {0,S_FALSE,FALSE},
3368             {URL_SCHEME_FILE,S_OK,FALSE},
3369             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3370         }
3371     },
3372     /* Allow more characters when Uri_CREATE_FILE_USE_DOS_PATH is specified */
3373     {   "file:///c:/dir\\%%61%20%5Fname/file%2A.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3374         {
3375             {"file://c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3376             {"",S_FALSE,FALSE},
3377             {"file://c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3378             {"",S_FALSE,FALSE},
3379             {".html",S_OK,FALSE},
3380             {"",S_FALSE,FALSE},
3381             {"",S_FALSE,FALSE},
3382             {"",S_FALSE,FALSE},
3383             {"c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3384             {"c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3385             {"",S_FALSE,FALSE},
3386             {"file:///c:/dir\\%%61%20%5Fname/file%2A.html",S_OK,FALSE},
3387             {"file",S_OK,FALSE},
3388             {"",S_FALSE,FALSE},
3389             {"",S_FALSE,FALSE}
3390         },
3391         {
3392             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3393             {0,S_FALSE,FALSE},
3394             {URL_SCHEME_FILE,S_OK,FALSE},
3395             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3396         }
3397     },
3398     {   "file://c|/dir\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3399         {
3400             {"file://c:\\dir\\index.html",S_OK,FALSE},
3401             {"",S_FALSE,FALSE},
3402             {"file://c:\\dir\\index.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\\index.html",S_OK,FALSE},
3409             {"c:\\dir\\index.html",S_OK,FALSE},
3410             {"",S_FALSE,FALSE},
3411             {"file://c|/dir\\index.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     /* The backslashes after the scheme name are converted to forward slashes. */
3424     {   "file:\\\\c:\\dir\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3425         {
3426             {"file://c:\\dir\\index.html",S_OK,FALSE},
3427             {"",S_FALSE,FALSE},
3428             {"file://c:\\dir\\index.html",S_OK,FALSE},
3429             {"",S_FALSE,FALSE},
3430             {".html",S_OK,FALSE},
3431             {"",S_FALSE,FALSE},
3432             {"",S_FALSE,FALSE},
3433             {"",S_FALSE,FALSE},
3434             {"c:\\dir\\index.html",S_OK,FALSE},
3435             {"c:\\dir\\index.html",S_OK,FALSE},
3436             {"",S_FALSE,FALSE},
3437             {"file:\\\\c:\\dir\\index.html",S_OK,FALSE},
3438             {"file",S_OK,FALSE},
3439             {"",S_FALSE,FALSE},
3440             {"",S_FALSE,FALSE}
3441         },
3442         {
3443             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3444             {0,S_FALSE,FALSE},
3445             {URL_SCHEME_FILE,S_OK,FALSE},
3446             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3447         }
3448     },
3449     {   "file:\\\\c:/dir/index.html", 0, 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     {   "http:\\\\google.com", 0, S_OK, FALSE,
3475         {
3476             {"http://google.com/",S_OK,FALSE},
3477             {"google.com",S_OK,FALSE},
3478             {"http://google.com/",S_OK,FALSE},
3479             {"google.com",S_OK,FALSE},
3480             {"",S_FALSE,FALSE},
3481             {"",S_FALSE,FALSE},
3482             {"google.com",S_OK,FALSE},
3483             {"",S_FALSE,FALSE},
3484             {"/",S_OK,FALSE},
3485             {"/",S_OK,FALSE},
3486             {"",S_FALSE,FALSE},
3487             {"http:\\\\google.com",S_OK,FALSE},
3488             {"http",S_OK,FALSE},
3489             {"",S_FALSE,FALSE},
3490             {"",S_FALSE,FALSE}
3491         },
3492         {
3493             {Uri_HOST_DNS,S_OK,FALSE},
3494             {80,S_OK,FALSE},
3495             {URL_SCHEME_HTTP,S_OK,FALSE},
3496             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3497         }
3498     },
3499     /* the "\\\\" aren't converted to "//" for unknown scheme types and it's considered opaque. */
3500     {   "zip:\\\\google.com", 0, S_OK, FALSE,
3501         {
3502             {"zip:\\\\google.com",S_OK,FALSE},
3503             {"",S_FALSE,FALSE},
3504             {"zip:\\\\google.com",S_OK,FALSE},
3505             {"",S_FALSE,FALSE},
3506             {".com",S_OK,FALSE},
3507             {"",S_FALSE,FALSE},
3508             {"",S_FALSE,FALSE},
3509             {"",S_FALSE,FALSE},
3510             {"\\\\google.com",S_OK,FALSE},
3511             {"\\\\google.com",S_OK,FALSE},
3512             {"",S_FALSE,FALSE},
3513             {"zip:\\\\google.com",S_OK,FALSE},
3514             {"zip",S_OK,FALSE},
3515             {"",S_FALSE,FALSE},
3516             {"",S_FALSE,FALSE}
3517         },
3518         {
3519             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3520             {0,S_FALSE,FALSE},
3521             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3522             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3523         }
3524     },
3525     /* Dot segments aren't removed. */
3526     {   "file://c:\\dir\\../..\\./index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3527         {
3528             {"file://c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3529             {"",S_FALSE,FALSE},
3530             {"file://c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3531             {"",S_FALSE,FALSE},
3532             {".html",S_OK,FALSE},
3533             {"",S_FALSE,FALSE},
3534             {"",S_FALSE,FALSE},
3535             {"",S_FALSE,FALSE},
3536             {"c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3537             {"c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3538             {"",S_FALSE,FALSE},
3539             {"file://c:\\dir\\../..\\./index.html",S_OK,FALSE},
3540             {"file",S_OK,FALSE},
3541             {"",S_FALSE,FALSE},
3542             {"",S_FALSE,FALSE}
3543         },
3544         {
3545             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3546             {0,S_FALSE,FALSE},
3547             {URL_SCHEME_FILE,S_OK,FALSE},
3548             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3549         }
3550     },
3551     /* Forbidden characters aren't percent encoded. */
3552     {   "file://c:\\dir\\i^|ndex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3553         {
3554             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3555             {"",S_FALSE,FALSE},
3556             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3557             {"",S_FALSE,FALSE},
3558             {".html",S_OK,FALSE},
3559             {"",S_FALSE,FALSE},
3560             {"",S_FALSE,FALSE},
3561             {"",S_FALSE,FALSE},
3562             {"c:\\dir\\i^|ndex.html",S_OK,FALSE},
3563             {"c:\\dir\\i^|ndex.html",S_OK,FALSE},
3564             {"",S_FALSE,FALSE},
3565             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3566             {"file",S_OK,FALSE},
3567             {"",S_FALSE,FALSE},
3568             {"",S_FALSE,FALSE}
3569         },
3570         {
3571             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3572             {0,S_FALSE,FALSE},
3573             {URL_SCHEME_FILE,S_OK,FALSE},
3574             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3575         }
3576     },
3577     /* The '\' are still converted to '/' even though it's an opaque file URI. */
3578     {   "file:c:\\dir\\../..\\index.html", 0, S_OK, FALSE,
3579         {
3580             {"",S_FALSE,FALSE},
3581             {"",S_FALSE,FALSE},
3582             {"file:c:/dir/../../index.html",S_OK,FALSE},
3583             {"",S_FALSE,FALSE},
3584             {".html",S_OK,FALSE},
3585             {"",S_FALSE,FALSE},
3586             {"",S_FALSE,FALSE},
3587             {"",S_FALSE,FALSE},
3588             {"c:/dir/../../index.html",S_OK,FALSE},
3589             {"c:/dir/../../index.html",S_OK,FALSE},
3590             {"",S_FALSE,FALSE},
3591             {"file:c:\\dir\\../..\\index.html",S_OK,FALSE},
3592             {"file",S_OK,FALSE},
3593             {"",S_FALSE,FALSE},
3594             {"",S_FALSE,FALSE}
3595         },
3596         {
3597             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3598             {0,S_FALSE,FALSE},
3599             {URL_SCHEME_FILE,S_OK,FALSE},
3600             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3601         }
3602     },
3603     /* '/' are still converted to '\' even though it's an opaque URI. */
3604     {   "file:c:/dir\\../..\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3605         {
3606             {"",S_FALSE,FALSE},
3607             {"",S_FALSE,FALSE},
3608             {"file:c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3609             {"",S_FALSE,FALSE},
3610             {".html",S_OK,FALSE},
3611             {"",S_FALSE,FALSE},
3612             {"",S_FALSE,FALSE},
3613             {"",S_FALSE,FALSE},
3614             {"c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3615             {"c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3616             {"",S_FALSE,FALSE},
3617             {"file:c:/dir\\../..\\index.html",S_OK,FALSE},
3618             {"file",S_OK,FALSE},
3619             {"",S_FALSE,FALSE},
3620             {"",S_FALSE,FALSE}
3621         },
3622         {
3623             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3624             {0,S_FALSE,FALSE},
3625             {URL_SCHEME_FILE,S_OK,FALSE},
3626             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3627         }
3628     },
3629     /* Forbidden characters aren't percent encoded. */
3630     {   "file:c:\\in^|dex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3631         {
3632             {"",S_FALSE,FALSE},
3633             {"",S_FALSE,FALSE},
3634             {"file:c:\\in^|dex.html",S_OK,FALSE},
3635             {"",S_FALSE,FALSE},
3636             {".html",S_OK,FALSE},
3637             {"",S_FALSE,FALSE},
3638             {"",S_FALSE,FALSE},
3639             {"",S_FALSE,FALSE},
3640             {"c:\\in^|dex.html",S_OK,FALSE},
3641             {"c:\\in^|dex.html",S_OK,FALSE},
3642             {"",S_FALSE,FALSE},
3643             {"file:c:\\in^|dex.html",S_OK,FALSE},
3644             {"file",S_OK,FALSE},
3645             {"",S_FALSE,FALSE},
3646             {"",S_FALSE,FALSE}
3647         },
3648         {
3649             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3650             {0,S_FALSE,FALSE},
3651             {URL_SCHEME_FILE,S_OK,FALSE},
3652             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3653         }
3654     },
3655     /* Doesn't have a UserName since the ':' appears at the beginning of the
3656      * userinfo section.
3657      */
3658     {   "http://:password@gov.uk", 0, S_OK, FALSE,
3659         {
3660             {"http://:password@gov.uk/",S_OK,FALSE},
3661             {":password@gov.uk",S_OK,FALSE},
3662             {"http://gov.uk/",S_OK,FALSE},
3663             {"",S_FALSE,FALSE},
3664             {"",S_FALSE,FALSE},
3665             {"",S_FALSE,FALSE},
3666             {"gov.uk",S_OK,FALSE},
3667             {"password",S_OK,FALSE},
3668             {"/",S_OK,FALSE},
3669             {"/",S_OK,FALSE},
3670             {"",S_FALSE,FALSE},
3671             {"http://:password@gov.uk",S_OK,FALSE},
3672             {"http",S_OK,FALSE},
3673             {":password",S_OK,FALSE},
3674             {"",S_FALSE,FALSE}
3675         },
3676         {
3677             {Uri_HOST_DNS,S_OK,FALSE},
3678             {80,S_OK,FALSE},
3679             {URL_SCHEME_HTTP,S_OK,FALSE},
3680             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3681         }
3682     },
3683     /* Has a UserName since the userinfo section doesn't contain a password. */
3684     {   "http://@gov.uk", 0, S_OK, FALSE,
3685         {
3686             {"http://gov.uk/",S_OK,FALSE,"http://@gov.uk/"},
3687             {"@gov.uk",S_OK,FALSE},
3688             {"http://gov.uk/",S_OK,FALSE},
3689             {"",S_FALSE,FALSE},
3690             {"",S_FALSE,FALSE},
3691             {"",S_FALSE,FALSE},
3692             {"gov.uk",S_OK,FALSE},
3693             {"",S_FALSE,FALSE},
3694             {"/",S_OK,FALSE},
3695             {"/",S_OK,FALSE},
3696             {"",S_FALSE,FALSE},
3697             {"http://@gov.uk",S_OK,FALSE},
3698             {"http",S_OK,FALSE},
3699             {"",S_OK,FALSE},
3700             {"",S_OK,FALSE}
3701         },
3702         {
3703             {Uri_HOST_DNS,S_OK,FALSE},
3704             {80,S_OK,FALSE},
3705             {URL_SCHEME_HTTP,S_OK,FALSE},
3706             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3707         }
3708     },
3709     /* ":@" not included in the absolute URI. */
3710     {   "http://:@gov.uk", 0, S_OK, FALSE,
3711         {
3712             {"http://gov.uk/",S_OK,FALSE,"http://:@gov.uk/"},
3713             {":@gov.uk",S_OK,FALSE},
3714             {"http://gov.uk/",S_OK,FALSE},
3715             {"",S_FALSE,FALSE},
3716             {"",S_FALSE,FALSE},
3717             {"",S_FALSE,FALSE},
3718             {"gov.uk",S_OK,FALSE},
3719             {"",S_OK,FALSE},
3720             {"/",S_OK,FALSE},
3721             {"/",S_OK,FALSE},
3722             {"",S_FALSE,FALSE},
3723             {"http://:@gov.uk",S_OK,FALSE},
3724             {"http",S_OK,FALSE},
3725             {":",S_OK,FALSE},
3726             {"",S_FALSE,FALSE}
3727         },
3728         {
3729             {Uri_HOST_DNS,S_OK,FALSE},
3730             {80,S_OK,FALSE},
3731             {URL_SCHEME_HTTP,S_OK,FALSE},
3732             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3733         }
3734     },
3735     /* '@' is included because it's an unknown scheme type. */
3736     {   "zip://@gov.uk", 0, S_OK, FALSE,
3737         {
3738             {"zip://@gov.uk/",S_OK,FALSE},
3739             {"@gov.uk",S_OK,FALSE},
3740             {"zip://@gov.uk/",S_OK,FALSE},
3741             {"",S_FALSE,FALSE},
3742             {"",S_FALSE,FALSE},
3743             {"",S_FALSE,FALSE},
3744             {"gov.uk",S_OK,FALSE},
3745             {"",S_FALSE,FALSE},
3746             {"/",S_OK,FALSE},
3747             {"/",S_OK,FALSE},
3748             {"",S_FALSE,FALSE},
3749             {"zip://@gov.uk",S_OK,FALSE},
3750             {"zip",S_OK,FALSE},
3751             {"",S_OK,FALSE},
3752             {"",S_OK,FALSE}
3753         },
3754         {
3755             {Uri_HOST_DNS,S_OK,FALSE},
3756             {0,S_FALSE,FALSE},
3757             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3758             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3759         }
3760     },
3761     /* ":@" are included because it's an unknown scheme type. */
3762     {   "zip://:@gov.uk", 0, S_OK, FALSE,
3763         {
3764             {"zip://:@gov.uk/",S_OK,FALSE},
3765             {":@gov.uk",S_OK,FALSE},
3766             {"zip://:@gov.uk/",S_OK,FALSE},
3767             {"",S_FALSE,FALSE},
3768             {"",S_FALSE,FALSE},
3769             {"",S_FALSE,FALSE},
3770             {"gov.uk",S_OK,FALSE},
3771             {"",S_OK,FALSE},
3772             {"/",S_OK,FALSE},
3773             {"/",S_OK,FALSE},
3774             {"",S_FALSE,FALSE},
3775             {"zip://:@gov.uk",S_OK,FALSE},
3776             {"zip",S_OK,FALSE},
3777             {":",S_OK,FALSE},
3778             {"",S_FALSE,FALSE}
3779         },
3780         {
3781             {Uri_HOST_DNS,S_OK,FALSE},
3782             {0,S_FALSE,FALSE},
3783             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3784             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3785         }
3786     },
3787     {   "about:blank", 0, S_OK, FALSE,
3788         {
3789             {"about:blank",S_OK,FALSE},
3790             {"",S_FALSE,FALSE},
3791             {"about:blank",S_OK,FALSE},
3792             {"",S_FALSE,FALSE},
3793             {"",S_FALSE,FALSE},
3794             {"",S_FALSE,FALSE},
3795             {"",S_FALSE,FALSE},
3796             {"",S_FALSE,FALSE},
3797             {"blank",S_OK,FALSE},
3798             {"blank",S_OK,FALSE},
3799             {"",S_FALSE,FALSE},
3800             {"about:blank",S_OK,FALSE},
3801             {"about",S_OK,FALSE},
3802             {"",S_FALSE,FALSE},
3803             {"",S_FALSE,FALSE}
3804         },
3805         {
3806             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3807             {0,S_FALSE,FALSE},
3808             {URL_SCHEME_ABOUT,S_OK,FALSE},
3809             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3810         }
3811     },
3812     {   "mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",0,S_OK,FALSE,
3813         {
3814             {"mk:@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3815             {"",S_FALSE,FALSE},
3816             {"mk:@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3817             {"",S_FALSE,FALSE},
3818             {".htm",S_OK,FALSE},
3819             {"",S_FALSE,FALSE},
3820             {"",S_FALSE,FALSE},
3821             {"",S_FALSE,FALSE},
3822             {"@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3823             {"@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3824             {"",S_FALSE,FALSE},
3825             {"mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3826             {"mk",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_MK,S_OK,FALSE},
3834             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3835         }
3836     },
3837     {   "mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",0,S_OK,FALSE,
3838         {
3839             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3840             {"",S_FALSE,FALSE},
3841             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.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:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3848             {"@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3849             {"",S_FALSE,FALSE},
3850             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.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     /* Two '\' are added to the URI when USE_DOS_PATH is set, and it's a UNC path. */
3863     {   "file://server/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3864         {
3865             {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
3866             {"server",S_OK,FALSE},
3867             {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
3868             {"",S_FALSE,FALSE},
3869             {".html",S_OK,FALSE},
3870             {"",S_FALSE,FALSE},
3871             {"server",S_OK,FALSE},
3872             {"",S_FALSE,FALSE},
3873             {"\\dir\\index.html",S_OK,FALSE},
3874             {"\\dir\\index.html",S_OK,FALSE},
3875             {"",S_FALSE,FALSE},
3876             {"file://server/dir/index.html",S_OK,FALSE},
3877             {"file",S_OK,FALSE},
3878             {"",S_FALSE,FALSE},
3879             {"",S_FALSE,FALSE}
3880         },
3881         {
3882             {Uri_HOST_DNS,S_OK,FALSE},
3883             {0,S_FALSE,FALSE},
3884             {URL_SCHEME_FILE,S_OK,FALSE},
3885             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3886         }
3887     },
3888     /* When CreateUri generates an IUri, it still displays the default port in the
3889      * authority.
3890      */
3891     {   "http://google.com:80/", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
3892         {
3893             {"http://google.com:80/",S_OK,FALSE},
3894             {"google.com:80",S_OK,FALSE},
3895             {"http://google.com:80/",S_OK,FALSE},
3896             {"google.com",S_OK,FALSE},
3897             {"",S_FALSE,FALSE},
3898             {"",S_FALSE,FALSE},
3899             {"google.com",S_OK,FALSE},
3900             {"",S_FALSE,FALSE},
3901             {"/",S_OK,FALSE},
3902             {"/",S_OK,FALSE},
3903             {"",S_FALSE,FALSE},
3904             {"http://google.com:80/",S_OK,FALSE},
3905             {"http",S_OK,FALSE},
3906             {"",S_FALSE,FALSE},
3907             {"",S_FALSE,FALSE}
3908         },
3909         {
3910             {Uri_HOST_DNS,S_OK,FALSE},
3911             {80,S_OK,FALSE},
3912             {URL_SCHEME_HTTP,S_OK,FALSE},
3913             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3914         }
3915     },
3916     /* For res URIs the host is everything up until the first '/'. */
3917     {   "res://C:\\dir\\file.exe/DATA/test.html", 0, S_OK, FALSE,
3918         {
3919             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3920             {"C:\\dir\\file.exe",S_OK,FALSE},
3921             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3922             {"",S_FALSE,FALSE},
3923             {".html",S_OK,FALSE},
3924             {"",S_FALSE,FALSE},
3925             {"C:\\dir\\file.exe",S_OK,FALSE},
3926             {"",S_FALSE,FALSE},
3927             {"/DATA/test.html",S_OK,FALSE},
3928             {"/DATA/test.html",S_OK,FALSE},
3929             {"",S_FALSE,FALSE},
3930             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3931             {"res",S_OK,FALSE},
3932             {"",S_FALSE,FALSE},
3933             {"",S_FALSE,FALSE}
3934         },
3935         {
3936             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3937             {0,S_FALSE,FALSE},
3938             {URL_SCHEME_RES,S_OK,FALSE},
3939             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3940         }
3941     },
3942     /* Res URI can contain a '|' in the host name. */
3943     {   "res://c:\\di|r\\file.exe/test", 0, S_OK, FALSE,
3944         {
3945             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3946             {"c:\\di|r\\file.exe",S_OK,FALSE},
3947             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3948             {"",S_FALSE,FALSE},
3949             {"",S_FALSE,FALSE},
3950             {"",S_FALSE,FALSE},
3951             {"c:\\di|r\\file.exe",S_OK,FALSE},
3952             {"",S_FALSE,FALSE},
3953             {"/test",S_OK,FALSE},
3954             {"/test",S_OK,FALSE},
3955             {"",S_FALSE,FALSE},
3956             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3957             {"res",S_OK,FALSE},
3958             {"",S_FALSE,FALSE},
3959             {"",S_FALSE,FALSE}
3960         },
3961         {
3962             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3963             {0,S_FALSE,FALSE},
3964             {URL_SCHEME_RES,S_OK,FALSE},
3965             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3966         }
3967     },
3968     /* Res URIs can have invalid percent encoded values. */
3969     {   "res://c:\\dir%xx\\file.exe/test", 0, S_OK, FALSE,
3970         {
3971             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3972             {"c:\\dir%xx\\file.exe",S_OK,FALSE},
3973             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3974             {"",S_FALSE,FALSE},
3975             {"",S_FALSE,FALSE},
3976             {"",S_FALSE,FALSE},
3977             {"c:\\dir%xx\\file.exe",S_OK,FALSE},
3978             {"",S_FALSE,FALSE},
3979             {"/test",S_OK,FALSE},
3980             {"/test",S_OK,FALSE},
3981             {"",S_FALSE,FALSE},
3982             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3983             {"res",S_OK,FALSE},
3984             {"",S_FALSE,FALSE},
3985             {"",S_FALSE,FALSE}
3986         },
3987         {
3988             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3989             {0,S_FALSE,FALSE},
3990             {URL_SCHEME_RES,S_OK,FALSE},
3991             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3992         }
3993     },
3994     /* Res doesn't get forbidden characters percent encoded in it's path. */
3995     {   "res://c:\\test/tes<|>t", 0, S_OK, FALSE,
3996         {
3997             {"res://c:\\test/tes<|>t",S_OK,FALSE},
3998             {"c:\\test",S_OK,FALSE},
3999             {"res://c:\\test/tes<|>t",S_OK,FALSE},
4000             {"",S_FALSE,FALSE},
4001             {"",S_FALSE,FALSE},
4002             {"",S_FALSE,FALSE},
4003             {"c:\\test",S_OK,FALSE},
4004             {"",S_FALSE,FALSE},
4005             {"/tes<|>t",S_OK,FALSE},
4006             {"/tes<|>t",S_OK,FALSE},
4007             {"",S_FALSE,FALSE},
4008             {"res://c:\\test/tes<|>t",S_OK,FALSE},
4009             {"res",S_OK,FALSE},
4010             {"",S_FALSE,FALSE},
4011             {"",S_FALSE,FALSE}
4012         },
4013         {
4014             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4015             {0,S_FALSE,FALSE},
4016             {URL_SCHEME_RES,S_OK,FALSE},
4017             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4018         }
4019     },
4020     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg", 0, S_OK, FALSE,
4021         {
4022             {"mk:@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4023             {"",S_FALSE,FALSE},
4024             {"mk:@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4025             {"",S_FALSE,FALSE},
4026             {".jpg",S_OK,FALSE},
4027             {"",S_FALSE,FALSE},
4028             {"",S_FALSE,FALSE},
4029             {"",S_FALSE,FALSE},
4030             {"@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4031             {"@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4032             {"",S_FALSE,FALSE},
4033             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4034             {"mk",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_MK,S_OK,FALSE},
4042             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4043         }
4044     },
4045     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
4046         {
4047             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4048             {"",S_FALSE,FALSE},
4049             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../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::/html/../images/xxx.jpg",S_OK,FALSE},
4056             {"@MSITStore:Z:\\dir\\test.chm::/html/../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     {   "xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg", 0, S_OK, FALSE,
4071         {
4072             {"xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4073             {"",S_FALSE,FALSE},
4074             {"xx:@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             {"xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4084             {"xx",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_UNKNOWN,S_OK,FALSE},
4092             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4093         }
4094     },
4095     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../../images/xxx.jpg", 0, S_OK, FALSE,
4096         {
4097             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4098             {"",S_FALSE,FALSE},
4099             {"mk:@MSITStore:Z:\\dir\\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\\images/xxx.jpg",S_OK,FALSE},
4106             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4107             {"",S_FALSE,FALSE},
4108             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../../images/xxx.jpg",S_OK,FALSE},
4109             {"mk",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_MK,S_OK,FALSE},
4117             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4118         }
4119     },
4120     {   "mk:@MSITStore:Z:\\dir\\dir2\\..\\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\\dir2\\..\\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\\test.chm::/html/../../../../images/xxx.jpg", 0, S_OK, FALSE,
4146         {
4147             {"mk:images/xxx.jpg",S_OK,FALSE},
4148             {"",S_FALSE,FALSE},
4149             {"mk: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             {"images/xxx.jpg",S_OK,FALSE},
4156             {"images/xxx.jpg",S_OK,FALSE},
4157             {"",S_FALSE,FALSE},
4158             {"mk:@MSITStore:Z:\\dir\\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     {   "", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
4171         {
4172             {"",S_OK,FALSE},
4173             {"",S_FALSE,FALSE},
4174             {"",S_OK,FALSE},
4175             {"",S_FALSE,FALSE},
4176             {"",S_FALSE,FALSE},
4177             {"",S_FALSE,FALSE},
4178             {"",S_FALSE,FALSE},
4179             {"",S_FALSE,FALSE},
4180             {"",S_OK,FALSE},
4181             {"",S_OK,FALSE},
4182             {"",S_FALSE,FALSE},
4183             {"",S_OK,FALSE},
4184             {"",S_FALSE,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_UNKNOWN,S_OK,FALSE},
4192             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4193         }
4194     },
4195     {   " \t ", 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     {   "javascript:void", 0, S_OK, FALSE,
4221         {
4222             {"javascript:void",S_OK},
4223             {"",S_FALSE},
4224             {"javascript:void",S_OK},
4225             {"",S_FALSE},
4226             {"",S_FALSE},
4227             {"",S_FALSE},
4228             {"",S_FALSE},
4229             {"",S_FALSE},
4230             {"void",S_OK},
4231             {"void",S_OK},
4232             {"",S_FALSE},
4233             {"javascript:void",S_OK},
4234             {"javascript",S_OK},
4235             {"",S_FALSE},
4236             {"",S_FALSE}
4237         },
4238         {
4239             {Uri_HOST_UNKNOWN,S_OK},
4240             {0,S_FALSE},
4241             {URL_SCHEME_JAVASCRIPT,S_OK},
4242             {URLZONE_INVALID,E_NOTIMPL}
4243         }
4244     },
4245     {   "javascript://undefined", 0, S_OK, FALSE,
4246         {
4247             {"javascript://undefined",S_OK},
4248             {"",S_FALSE},
4249             {"javascript://undefined",S_OK},
4250             {"",S_FALSE},
4251             {"",S_FALSE},
4252             {"",S_FALSE},
4253             {"",S_FALSE},
4254             {"",S_FALSE},
4255             {"//undefined",S_OK},
4256             {"//undefined",S_OK},
4257             {"",S_FALSE},
4258             {"javascript://undefined",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:escape('/\\?#?')", 0, S_OK, FALSE,
4271         {
4272             {"javascript:escape('/\\?#?')",S_OK},
4273             {"",S_FALSE},
4274             {"javascript:escape('/\\?#?')",S_OK},
4275             {"",S_FALSE},
4276             {"",S_FALSE},
4277             {"",S_FALSE},
4278             {"",S_FALSE},
4279             {"",S_FALSE},
4280             {"escape('/\\?#?')",S_OK},
4281             {"escape('/\\?#?')",S_OK},
4282             {"",S_FALSE},
4283             {"JavaSCript:escape('/\\?#?')",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     {   "*://google.com", 0, S_OK, FALSE,
4296         {
4297             {"*:google.com/",S_OK,FALSE},
4298             {"google.com",S_OK},
4299             {"*:google.com/",S_OK,FALSE},
4300             {"google.com",S_OK,FALSE},
4301             {"",S_FALSE,FALSE},
4302             {"",S_FALSE,FALSE},
4303             {"google.com",S_OK,FALSE},
4304             {"",S_FALSE,FALSE},
4305             {"/",S_OK,FALSE},
4306             {"/",S_OK,FALSE},
4307             {"",S_FALSE,FALSE},
4308             {"*://google.com",S_OK,FALSE},
4309             {"*",S_OK,FALSE},
4310             {"",S_FALSE,FALSE},
4311             {"",S_FALSE,FALSE}
4312         },
4313         {
4314             {Uri_HOST_DNS,S_OK,FALSE},
4315             {0,S_FALSE,FALSE},
4316             {URL_SCHEME_WILDCARD,S_OK,FALSE},
4317             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4318         }
4319     },
4320     {   "mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",0,S_OK,FALSE,
4321         {
4322             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",S_OK},
4323             {"",S_FALSE},
4324             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",S_OK},
4325             {"",S_FALSE},
4326             {".txt",S_OK},
4327             {"",S_FALSE},
4328             {"",S_FALSE},
4329             {"",S_FALSE},
4330             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",S_OK},
4331             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",S_OK},
4332             {"",S_FALSE},
4333             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",S_OK},
4334             {"mk",S_OK},
4335             {"",S_FALSE},
4336             {"",S_FALSE}
4337         },
4338         {
4339             {Uri_HOST_UNKNOWN,S_OK},
4340             {0,S_FALSE},
4341             {URL_SCHEME_MK,S_OK},
4342             {URLZONE_INVALID,E_NOTIMPL}
4343         }
4344     },
4345 };
4346
4347 typedef struct _invalid_uri {
4348     const char* uri;
4349     DWORD       flags;
4350     BOOL        todo;
4351 } invalid_uri;
4352
4353 static const invalid_uri invalid_uri_tests[] = {
4354     /* Has to have a scheme name. */
4355     {"://www.winehq.org",0,FALSE},
4356     /* Window's doesn't like URI's which are implicitly file paths without the
4357      * ALLOW_IMPLICIT_FILE_SCHEME flag set.
4358      */
4359     {"C:/test/test.mp3",0,FALSE},
4360     {"\\\\Server/test/test.mp3",0,FALSE},
4361     {"C:/test/test.mp3",Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME,FALSE},
4362     {"\\\\Server/test/test.mp3",Uri_CREATE_ALLOW_RELATIVE,FALSE},
4363     /* Invalid schemes. */
4364     {"*abcd://not.valid.com",0,FALSE},
4365     {"*a*b*c*d://not.valid.com",0,FALSE},
4366     /* Not allowed to have invalid % encoded data. */
4367     {"ftp://google.co%XX/",0,FALSE},
4368     /* To many h16 components. */
4369     {"http://[1:2:3:4:5:6:7:8:9]",0,FALSE},
4370     /* Not enough room for IPv4 address. */
4371     {"http://[1:2:3:4:5:6:7:192.0.1.0]",0,FALSE},
4372     /* Not enough h16 components. */
4373     {"http://[1:2:3:4]",0,FALSE},
4374     /* Not enough components including IPv4. */
4375     {"http://[1:192.0.1.0]",0,FALSE},
4376     /* Not allowed to have partial IPv4 in IPv6. */
4377     {"http://[::192.0]",0,FALSE},
4378     /* Can't have elision of 1 h16 at beginning of address. */
4379     {"http://[::2:3:4:5:6:7:8]",0,FALSE},
4380     /* Can't have elision of 1 h16 at end of address. */
4381     {"http://[1:2:3:4:5:6:7::]",0,FALSE},
4382     /* Expects a valid IP Literal. */
4383     {"ftp://[not.valid.uri]/",0,FALSE},
4384     /* Expects valid port for a known scheme type. */
4385     {"ftp://www.winehq.org:123fgh",0,FALSE},
4386     /* Port exceeds USHORT_MAX for known scheme type. */
4387     {"ftp://www.winehq.org:65536",0,FALSE},
4388     /* Invalid port with IPv4 address. */
4389     {"http://www.winehq.org:1abcd",0,FALSE},
4390     /* Invalid port with IPv6 address. */
4391     {"http://[::ffff]:32xy",0,FALSE},
4392     /* Not allowed to have backslashes with NO_CANONICALIZE. */
4393     {"gopher://www.google.com\\test",Uri_CREATE_NO_CANONICALIZE,FALSE},
4394     /* Not allowed to have invalid % encoded data in opaque URI path. */
4395     {"news:test%XX",0,FALSE},
4396     {"mailto:wine@winehq%G8.com",0,FALSE},
4397     /* Known scheme types can't have invalid % encoded data in query string. */
4398     {"http://google.com/?query=te%xx",0,FALSE},
4399     /* Invalid % encoded data in fragment of know scheme type. */
4400     {"ftp://google.com/#Test%xx",0,FALSE},
4401     {"  http://google.com/",Uri_CREATE_NO_PRE_PROCESS_HTML_URI,FALSE},
4402     {"\n\nhttp://google.com/",Uri_CREATE_NO_PRE_PROCESS_HTML_URI,FALSE},
4403     {"file://c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4404     {"file://c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4405     {"file://c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4406     {"file:c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4407     {"file:c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4408     {"file:c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4409     /* res URIs aren't allowed to have forbidden dos path characters in the
4410      * hostname.
4411      */
4412     {"res://c:\\te<st\\test/test",0,FALSE},
4413     {"res://c:\\te>st\\test/test",0,FALSE},
4414     {"res://c:\\te\"st\\test/test",0,FALSE},
4415     {"res://c:\\test/te%xxst",0,FALSE}
4416 };
4417
4418 typedef struct _uri_equality {
4419     const char* a;
4420     DWORD       create_flags_a;
4421     const char* b;
4422     DWORD       create_flags_b;
4423     BOOL        equal;
4424     BOOL        todo;
4425 } uri_equality;
4426
4427 static const uri_equality equality_tests[] = {
4428     {
4429         "HTTP://www.winehq.org/test dir/./",0,
4430         "http://www.winehq.org/test dir/../test dir/",0,
4431         TRUE
4432     },
4433     {
4434         /* http://www.winehq.org/test%20dir */
4435         "http://%77%77%77%2E%77%69%6E%65%68%71%2E%6F%72%67/%74%65%73%74%20%64%69%72",0,
4436         "http://www.winehq.org/test dir",0,
4437         TRUE
4438     },
4439     {
4440         "c:\\test.mp3",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME,
4441         "file:///c:/test.mp3",0,
4442         TRUE
4443     },
4444     {
4445         "ftp://ftp.winehq.org/",0,
4446         "ftp://ftp.winehq.org",0,
4447         TRUE
4448     },
4449     {
4450         "ftp://ftp.winehq.org/test/test2/../../testB/",0,
4451         "ftp://ftp.winehq.org/t%45stB/",0,
4452         FALSE
4453     },
4454     {
4455         "http://google.com/TEST",0,
4456         "http://google.com/test",0,
4457         FALSE
4458     },
4459     {
4460         "http://GOOGLE.com/",0,
4461         "http://google.com/",0,
4462         TRUE
4463     },
4464     /* Performs case insensitive compare of host names (for known scheme types). */
4465     {
4466         "ftp://GOOGLE.com/",Uri_CREATE_NO_CANONICALIZE,
4467         "ftp://google.com/",0,
4468         TRUE
4469     },
4470     {
4471         "zip://GOOGLE.com/",0,
4472         "zip://google.com/",0,
4473         FALSE
4474     },
4475     {
4476         "file:///c:/TEST/TeST/",0,
4477         "file:///c:/test/test/",0,
4478         TRUE
4479     },
4480     {
4481         "file:///server/TEST",0,
4482         "file:///SERVER/TEST",0,
4483         TRUE
4484     },
4485     {
4486         "http://google.com",Uri_CREATE_NO_CANONICALIZE,
4487         "http://google.com/",0,
4488         TRUE
4489     },
4490     {
4491         "ftp://google.com:21/",0,
4492         "ftp://google.com/",0,
4493         TRUE
4494     },
4495     {
4496         "http://google.com:80/",Uri_CREATE_NO_CANONICALIZE,
4497         "http://google.com/",0,
4498         TRUE
4499     },
4500     {
4501         "http://google.com:70/",0,
4502         "http://google.com:71/",0,
4503         FALSE
4504     }
4505 };
4506
4507 typedef struct _uri_with_fragment {
4508     const char* uri;
4509     const char* fragment;
4510     DWORD       create_flags;
4511     HRESULT     create_expected;
4512     BOOL        create_todo;
4513
4514     const char* expected_uri;
4515     BOOL        expected_todo;
4516 } uri_with_fragment;
4517
4518 static const uri_with_fragment uri_fragment_tests[] = {
4519     {
4520         "http://google.com/","#fragment",0,S_OK,FALSE,
4521         "http://google.com/#fragment",FALSE
4522     },
4523     {
4524         "http://google.com/","fragment",0,S_OK,FALSE,
4525         "http://google.com/#fragment",FALSE
4526     },
4527     {
4528         "zip://test.com/","?test",0,S_OK,FALSE,
4529         "zip://test.com/#?test",FALSE
4530     },
4531     /* The fragment can be empty. */
4532     {
4533         "ftp://ftp.google.com/","",0,S_OK,FALSE,
4534         "ftp://ftp.google.com/#",FALSE
4535     }
4536 };
4537
4538 typedef struct _uri_builder_property {
4539     BOOL            change;
4540     const char      *value;
4541     const char      *expected_value;
4542     Uri_PROPERTY    property;
4543     HRESULT         expected;
4544     BOOL            todo;
4545 } uri_builder_property;
4546
4547 typedef struct _uri_builder_port {
4548     BOOL    change;
4549     BOOL    set;
4550     DWORD   value;
4551     HRESULT expected;
4552     BOOL    todo;
4553 } uri_builder_port;
4554
4555 typedef struct _uri_builder_str_property {
4556     const char* expected;
4557     HRESULT     result;
4558     BOOL        todo;
4559 } uri_builder_str_property;
4560
4561 typedef struct _uri_builder_dword_property {
4562     DWORD   expected;
4563     HRESULT result;
4564     BOOL    todo;
4565 } uri_builder_dword_property;
4566
4567 typedef struct _uri_builder_test {
4568     const char                  *uri;
4569     DWORD                       create_flags;
4570     HRESULT                     create_builder_expected;
4571     BOOL                        create_builder_todo;
4572
4573     uri_builder_property        properties[URI_BUILDER_STR_PROPERTY_COUNT];
4574
4575     uri_builder_port            port_prop;
4576
4577     DWORD                       uri_flags;
4578     HRESULT                     uri_hres;
4579     BOOL                        uri_todo;
4580
4581     DWORD                       uri_simple_encode_flags;
4582     HRESULT                     uri_simple_hres;
4583     BOOL                        uri_simple_todo;
4584
4585     DWORD                       uri_with_flags;
4586     DWORD                       uri_with_builder_flags;
4587     DWORD                       uri_with_encode_flags;
4588     HRESULT                     uri_with_hres;
4589     BOOL                        uri_with_todo;
4590
4591     uri_builder_str_property    expected_str_props[URI_STR_PROPERTY_COUNT];
4592     uri_builder_dword_property  expected_dword_props[URI_DWORD_PROPERTY_COUNT];
4593 } uri_builder_test;
4594
4595 static const uri_builder_test uri_builder_tests[] = {
4596     {   "http://google.com/",0,S_OK,FALSE,
4597         {
4598             {TRUE,"#fragment",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4599             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE},
4600             {TRUE,"?query=x",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE},
4601             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4602         },
4603         {FALSE},
4604         0,S_OK,FALSE,
4605         0,S_OK,FALSE,
4606         0,0,0,S_OK,FALSE,
4607         {
4608             {"http://username:password@google.com/?query=x#fragment",S_OK},
4609             {"username:password@google.com",S_OK},
4610             {"http://google.com/?query=x#fragment",S_OK},
4611             {"google.com",S_OK},
4612             {"",S_FALSE},
4613             {"#fragment",S_OK},
4614             {"google.com",S_OK},
4615             {"password",S_OK},
4616             {"/",S_OK},
4617             {"/?query=x",S_OK},
4618             {"?query=x",S_OK},
4619             {"http://username:password@google.com/?query=x#fragment",S_OK},
4620             {"http",S_OK},
4621             {"username:password",S_OK},
4622             {"username",S_OK}
4623         },
4624         {
4625             {Uri_HOST_DNS,S_OK},
4626             {80,S_OK},
4627             {URL_SCHEME_HTTP,S_OK},
4628             {URLZONE_INVALID,E_NOTIMPL}
4629         }
4630     },
4631     {   "http://google.com/",0,S_OK,FALSE,
4632         {
4633             {TRUE,"test",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
4634         },
4635         {TRUE,TRUE,120,S_OK,FALSE},
4636         0,S_OK,FALSE,
4637         0,S_OK,FALSE,
4638         0,0,0,S_OK,FALSE,
4639         {
4640             {"test://google.com:120/",S_OK},
4641             {"google.com:120",S_OK},
4642             {"test://google.com:120/",S_OK},
4643             {"google.com",S_OK},
4644             {"",S_FALSE},
4645             {"",S_FALSE},
4646             {"google.com",S_OK},
4647             {"",S_FALSE},
4648             {"/",S_OK},
4649             {"/",S_OK},
4650             {"",S_FALSE},
4651             {"test://google.com:120/",S_OK},
4652             {"test",S_OK},
4653             {"",S_FALSE},
4654             {"",S_FALSE}
4655         },
4656         {
4657             {Uri_HOST_DNS,S_OK},
4658             {120,S_OK},
4659             {URL_SCHEME_UNKNOWN,S_OK},
4660             {URLZONE_INVALID,E_NOTIMPL}
4661         }
4662     },
4663     {   "/Test/test dir",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4664         {
4665             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
4666             {TRUE,"::192.2.3.4",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
4667             {TRUE,NULL,NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
4668         },
4669         {FALSE},
4670         0,S_OK,FALSE,
4671         0,S_OK,FALSE,
4672         0,0,0,S_OK,FALSE,
4673         {
4674             {"http://[::192.2.3.4]/",S_OK},
4675             {"[::192.2.3.4]",S_OK},
4676             {"http://[::192.2.3.4]/",S_OK},
4677             {"",S_FALSE},
4678             {"",S_FALSE},
4679             {"",S_FALSE},
4680             {"::192.2.3.4",S_OK},
4681             {"",S_FALSE},
4682             {"/",S_OK},
4683             {"/",S_OK},
4684             {"",S_FALSE},
4685             {"http://[::192.2.3.4]/",S_OK},
4686             {"http",S_OK},
4687             {"",S_FALSE},
4688             {"",S_FALSE}
4689         },
4690         {
4691             {Uri_HOST_IPV6,S_OK},
4692             {80,S_OK},
4693             {URL_SCHEME_HTTP,S_OK},
4694             {URLZONE_INVALID,E_NOTIMPL}
4695         }
4696     },
4697     {   "http://google.com/",0,S_OK,FALSE,
4698         {
4699             {TRUE,"Frag","#Frag",Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4700         },
4701         {FALSE},
4702         0,S_OK,FALSE,
4703         0,S_OK,FALSE,
4704         0,0,0,S_OK,FALSE,
4705         {
4706             {"http://google.com/#Frag",S_OK},
4707             {"google.com",S_OK},
4708             {"http://google.com/#Frag",S_OK},
4709             {"google.com",S_OK},
4710             {"",S_FALSE},
4711             {"#Frag",S_OK},
4712             {"google.com",S_OK},
4713             {"",S_FALSE},
4714             {"/",S_OK},
4715             {"/",S_OK},
4716             {"",S_FALSE},
4717             {"http://google.com/#Frag",S_OK},
4718             {"http",S_OK},
4719             {"",S_FALSE},
4720             {"",S_FALSE}
4721         },
4722         {
4723             {Uri_HOST_DNS,S_OK},
4724             {80,S_OK},
4725             {URL_SCHEME_HTTP,S_OK},
4726             {URLZONE_INVALID,E_NOTIMPL}
4727         }
4728     },
4729     {   "http://google.com/",0,S_OK,FALSE,
4730         {
4731             {TRUE,"","#",Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4732         },
4733         {FALSE},
4734         0,S_OK,FALSE,
4735         0,S_OK,FALSE,
4736         0,0,0,S_OK,FALSE,
4737         {
4738             {"http://google.com/#",S_OK},
4739             {"google.com",S_OK},
4740             {"http://google.com/#",S_OK},
4741             {"google.com",S_OK},
4742             {"",S_FALSE},
4743             {"#",S_OK},
4744             {"google.com",S_OK},
4745             {"",S_FALSE},
4746             {"/",S_OK},
4747             {"/",S_OK},
4748             {"",S_FALSE},
4749             {"http://google.com/#",S_OK},
4750             {"http",S_OK},
4751             {"",S_FALSE},
4752             {"",S_FALSE}
4753         },
4754         {
4755             {Uri_HOST_DNS,S_OK},
4756             {80,S_OK},
4757             {URL_SCHEME_HTTP,S_OK},
4758             {URLZONE_INVALID,E_NOTIMPL}
4759         }
4760     },
4761     {   "http://google.com/",0,S_OK,FALSE,
4762         {
4763             {TRUE,":password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4764         },
4765         {FALSE},
4766         0,S_OK,FALSE,
4767         0,S_OK,FALSE,
4768         0,0,0,S_OK,FALSE,
4769         {
4770             {"http://::password@google.com/",S_OK},
4771             {"::password@google.com",S_OK},
4772             {"http://google.com/",S_OK},
4773             {"google.com",S_OK},
4774             {"",S_FALSE},
4775             {"",S_FALSE},
4776             {"google.com",S_OK},
4777             {":password",S_OK},
4778             {"/",S_OK},
4779             {"/",S_OK},
4780             {"",S_FALSE},
4781             {"http://::password@google.com/",S_OK},
4782             {"http",S_OK},
4783             {"::password",S_OK},
4784             {"",S_FALSE}
4785         },
4786         {
4787             {Uri_HOST_DNS,S_OK},
4788             {80,S_OK},
4789             {URL_SCHEME_HTTP,S_OK},
4790             {URLZONE_INVALID,E_NOTIMPL}
4791         }
4792     },
4793     {   "test/test",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4794         {
4795             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4796         },
4797         {FALSE},
4798         Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4799         0,S_OK,FALSE,
4800         Uri_CREATE_ALLOW_RELATIVE,0,0,S_OK,FALSE,
4801         {
4802             {":password@test/test",S_OK},
4803             {":password@",S_OK},
4804             {":password@test/test",S_OK},
4805             {"",S_FALSE},
4806             {"",S_FALSE},
4807             {"",S_FALSE},
4808             {"",S_FALSE},
4809             {"password",S_OK},
4810             {"test/test",S_OK},
4811             {"test/test",S_OK},
4812             {"",S_FALSE},
4813             {":password@test/test",S_OK},
4814             {"",S_FALSE},
4815             {":password",S_OK},
4816             {"",S_FALSE}
4817         },
4818         {
4819             {Uri_HOST_UNKNOWN,S_OK},
4820             {0,S_FALSE},
4821             {URL_SCHEME_UNKNOWN,S_OK},
4822             {URLZONE_INVALID,E_NOTIMPL}
4823         }
4824     },
4825     {   "http://google.com/",0,S_OK,FALSE,
4826         {
4827             {TRUE,"test/test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4828         },
4829         {FALSE},
4830         0,S_OK,FALSE,
4831         0,S_OK,FALSE,
4832         0,0,0,S_OK,FALSE,
4833         {
4834             {"http://google.com/test/test",S_OK},
4835             {"google.com",S_OK},
4836             {"http://google.com/test/test",S_OK},
4837             {"google.com",S_OK},
4838             {"",S_FALSE},
4839             {"",S_FALSE},
4840             {"google.com",S_OK},
4841             {"",S_FALSE},
4842             {"/test/test",S_OK},
4843             {"/test/test",S_OK},
4844             {"",S_FALSE},
4845             {"http://google.com/test/test",S_OK},
4846             {"http",S_OK},
4847             {"",S_FALSE},
4848             {"",S_FALSE}
4849         },
4850         {
4851             {Uri_HOST_DNS,S_OK},
4852             {80,S_OK},
4853             {URL_SCHEME_HTTP,S_OK},
4854             {URLZONE_INVALID,E_NOTIMPL}
4855         }
4856     },
4857     {   "zip:testing/test",0,S_OK,FALSE,
4858         {
4859             {TRUE,"test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4860         },
4861         {FALSE},
4862         0,S_OK,FALSE,
4863         0,S_OK,FALSE,
4864         0,0,0,S_OK,FALSE,
4865         {
4866             {"zip:test",S_OK},
4867             {"",S_FALSE},
4868             {"zip:test",S_OK},
4869             {"",S_FALSE},
4870             {"",S_FALSE},
4871             {"",S_FALSE},
4872             {"",S_FALSE},
4873             {"",S_FALSE},
4874             {"test",S_OK},
4875             {"test",S_OK},
4876             {"",S_FALSE},
4877             {"zip:test",S_OK},
4878             {"zip",S_OK},
4879             {"",S_FALSE},
4880             {"",S_FALSE}
4881         },
4882         {
4883             {Uri_HOST_UNKNOWN,S_OK},
4884             {0,S_FALSE},
4885             {URL_SCHEME_UNKNOWN,S_OK},
4886             {URLZONE_INVALID,E_NOTIMPL}
4887         }
4888     },
4889     {   "http://google.com/",0,S_OK,FALSE,
4890         {
4891             {FALSE},
4892         },
4893         /* 555 will be returned from GetPort even though FALSE was passed as the hasPort parameter. */
4894         {TRUE,FALSE,555,S_OK,FALSE},
4895         0,S_OK,FALSE,
4896         0,S_OK,FALSE,
4897         0,0,0,S_OK,FALSE,
4898         {
4899             {"http://google.com/",S_OK},
4900             {"google.com",S_OK},
4901             {"http://google.com/",S_OK},
4902             {"google.com",S_OK},
4903             {"",S_FALSE},
4904             {"",S_FALSE},
4905             {"google.com",S_OK},
4906             {"",S_FALSE},
4907             {"/",S_OK},
4908             {"/",S_OK},
4909             {"",S_FALSE},
4910             {"http://google.com/",S_OK},
4911             {"http",S_OK},
4912             {"",S_FALSE},
4913             {"",S_FALSE}
4914         },
4915         {
4916             {Uri_HOST_DNS,S_OK},
4917             /* Still returns 80, even though earlier the port was disabled. */
4918             {80,S_OK},
4919             {URL_SCHEME_HTTP,S_OK},
4920             {URLZONE_INVALID,E_NOTIMPL}
4921         }
4922     },
4923     {   "http://google.com/",0,S_OK,FALSE,
4924         {
4925             {FALSE},
4926         },
4927         /* Instead of getting "TRUE" back as the "hasPort" parameter in GetPort,
4928          * you'll get 122345 instead.
4929          */
4930         {TRUE,122345,222,S_OK,FALSE},
4931         0,S_OK,FALSE,
4932         0,S_OK,FALSE,
4933         0,0,0,S_OK,FALSE,
4934         {
4935             {"http://google.com:222/",S_OK},
4936             {"google.com:222",S_OK},
4937             {"http://google.com:222/",S_OK},
4938             {"google.com",S_OK},
4939             {"",S_FALSE},
4940             {"",S_FALSE},
4941             {"google.com",S_OK},
4942             {"",S_FALSE},
4943             {"/",S_OK},
4944             {"/",S_OK},
4945             {"",S_FALSE},
4946             {"http://google.com:222/",S_OK},
4947             {"http",S_OK},
4948             {"",S_FALSE},
4949             {"",S_FALSE}
4950         },
4951         {
4952             {Uri_HOST_DNS,S_OK},
4953             {222,S_OK},
4954             {URL_SCHEME_HTTP,S_OK},
4955             {URLZONE_INVALID,E_NOTIMPL}
4956         }
4957     },
4958     /* IUri's created with the IUriBuilder can have ports that exceed USHORT_MAX. */
4959     {   "http://google.com/",0,S_OK,FALSE,
4960         {
4961             {FALSE},
4962         },
4963         {TRUE,TRUE,999999,S_OK,FALSE},
4964         0,S_OK,FALSE,
4965         0,S_OK,FALSE,
4966         0,0,0,S_OK,FALSE,
4967         {
4968             {"http://google.com:999999/",S_OK},
4969             {"google.com:999999",S_OK},
4970             {"http://google.com:999999/",S_OK},
4971             {"google.com",S_OK},
4972             {"",S_FALSE},
4973             {"",S_FALSE},
4974             {"google.com",S_OK},
4975             {"",S_FALSE},
4976             {"/",S_OK},
4977             {"/",S_OK},
4978             {"",S_FALSE},
4979             {"http://google.com:999999/",S_OK},
4980             {"http",S_OK},
4981             {"",S_FALSE},
4982             {"",S_FALSE}
4983         },
4984         {
4985             {Uri_HOST_DNS,S_OK},
4986             {999999,S_OK},
4987             {URL_SCHEME_HTTP,S_OK},
4988             {URLZONE_INVALID,E_NOTIMPL}
4989         }
4990     },
4991     {   "http://google.com/",0,S_OK,FALSE,
4992         {
4993             {TRUE,"test","?test",Uri_PROPERTY_QUERY,S_OK,FALSE},
4994         },
4995
4996         {FALSE},
4997         0,S_OK,FALSE,
4998         0,S_OK,FALSE,
4999         0,0,0,S_OK,FALSE,
5000         {
5001             {"http://google.com/?test",S_OK},
5002             {"google.com",S_OK},
5003             {"http://google.com/?test",S_OK},
5004             {"google.com",S_OK},
5005             {"",S_FALSE},
5006             {"",S_FALSE},
5007             {"google.com",S_OK},
5008             {"",S_FALSE},
5009             {"/",S_OK},
5010             {"/?test",S_OK},
5011             {"?test",S_OK},
5012             {"http://google.com/?test",S_OK},
5013             {"http",S_OK},
5014             {"",S_FALSE},
5015             {"",S_FALSE}
5016         },
5017         {
5018             {Uri_HOST_DNS,S_OK},
5019             {80,S_OK},
5020             {URL_SCHEME_HTTP,S_OK},
5021             {URLZONE_INVALID,E_NOTIMPL}
5022         }
5023     },
5024     {   "http://:password@google.com/",0,S_OK,FALSE,
5025         {
5026             {FALSE},
5027         },
5028         {FALSE},
5029         0,S_OK,FALSE,
5030         0,S_OK,FALSE,
5031         0,0,0,S_OK,FALSE,
5032         {
5033             {"http://:password@google.com/",S_OK},
5034             {":password@google.com",S_OK},
5035             {"http://google.com/",S_OK},
5036             {"google.com",S_OK},
5037             {"",S_FALSE},
5038             {"",S_FALSE},
5039             {"google.com",S_OK},
5040             {"password",S_OK},
5041             {"/",S_OK},
5042             {"/",S_OK},
5043             {"",S_FALSE},
5044             {"http://:password@google.com/",S_OK},
5045             {"http",S_OK},
5046             {":password",S_OK},
5047             {"",S_FALSE}
5048         },
5049         {
5050             {Uri_HOST_DNS,S_OK},
5051             {80,S_OK},
5052             {URL_SCHEME_HTTP,S_OK},
5053             {URLZONE_INVALID,E_NOTIMPL}
5054         }
5055     },
5056     /* IUriBuilder doesn't need a base IUri to build a IUri. */
5057     {   NULL,0,S_OK,FALSE,
5058         {
5059             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
5060             {TRUE,"google.com",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5061         },
5062         {FALSE},
5063         0,S_OK,FALSE,
5064         0,S_OK,FALSE,
5065         0,0,0,S_OK,FALSE,
5066         {
5067             {"http://google.com/",S_OK},
5068             {"google.com",S_OK},
5069             {"http://google.com/",S_OK},
5070             {"google.com",S_OK},
5071             {"",S_FALSE},
5072             {"",S_FALSE},
5073             {"google.com",S_OK},
5074             {"",S_FALSE},
5075             {"/",S_OK},
5076             {"/",S_OK},
5077             {"",S_FALSE},
5078             {"http://google.com/",S_OK},
5079             {"http",S_OK},
5080             {"",S_FALSE},
5081             {"",S_FALSE}
5082         },
5083         {
5084             {Uri_HOST_DNS,S_OK},
5085             {80,S_OK},
5086             {URL_SCHEME_HTTP,S_OK},
5087             {URLZONE_INVALID,E_NOTIMPL}
5088         }
5089     },
5090     /* Can't set the scheme name to NULL. */
5091     {   "zip://google.com/",0,S_OK,FALSE,
5092         {
5093             {TRUE,NULL,"zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
5094         },
5095         {FALSE},
5096         0,S_OK,FALSE,
5097         0,S_OK,FALSE,
5098         0,0,0,S_OK,FALSE,
5099         {
5100             {"zip://google.com/",S_OK},
5101             {"google.com",S_OK},
5102             {"zip://google.com/",S_OK},
5103             {"google.com",S_OK},
5104             {"",S_FALSE},
5105             {"",S_FALSE},
5106             {"google.com",S_OK},
5107             {"",S_FALSE},
5108             {"/",S_OK},
5109             {"/",S_OK},
5110             {"",S_FALSE},
5111             {"zip://google.com/",S_OK},
5112             {"zip",S_OK},
5113             {"",S_FALSE},
5114             {"",S_FALSE}
5115         },
5116         {
5117             {Uri_HOST_DNS,S_OK},
5118             {0,S_FALSE},
5119             {URL_SCHEME_UNKNOWN,S_OK},
5120             {URLZONE_INVALID,E_NOTIMPL}
5121         }
5122     },
5123     /* Can't set the scheme name to an empty string. */
5124     {   "zip://google.com/",0,S_OK,FALSE,
5125         {
5126             {TRUE,"","zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
5127         },
5128         {FALSE},
5129         0,S_OK,FALSE,
5130         0,S_OK,FALSE,
5131         0,0,0,S_OK,FALSE,
5132         {
5133             {"zip://google.com/",S_OK},
5134             {"google.com",S_OK},
5135             {"zip://google.com/",S_OK},
5136             {"google.com",S_OK},
5137             {"",S_FALSE},
5138             {"",S_FALSE},
5139             {"google.com",S_OK},
5140             {"",S_FALSE},
5141             {"/",S_OK},
5142             {"/",S_OK},
5143             {"",S_FALSE},
5144             {"zip://google.com/",S_OK},
5145             {"zip",S_OK},
5146             {"",S_FALSE},
5147             {"",S_FALSE}
5148         },
5149         {
5150             {Uri_HOST_DNS,S_OK},
5151             {0,S_FALSE},
5152             {URL_SCHEME_UNKNOWN,S_OK},
5153             {URLZONE_INVALID,E_NOTIMPL}
5154         }
5155     },
5156     /* -1 to CreateUri makes it use the same flags as the base IUri was created with.
5157      * CreateUriSimple always uses the flags the base IUri was created with (if any).
5158      */
5159     {   "http://google.com/../../",Uri_CREATE_NO_CANONICALIZE,S_OK,FALSE,
5160         {{FALSE}},
5161         {FALSE},
5162         -1,S_OK,FALSE,
5163         0,S_OK,FALSE,
5164         0,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5165         {
5166             {"http://google.com/../../",S_OK},
5167             {"google.com",S_OK},
5168             {"http://google.com/../../",S_OK},
5169             {"google.com",S_OK},
5170             {"",S_FALSE},
5171             {"",S_FALSE},
5172             {"google.com",S_OK},
5173             {"",S_FALSE},
5174             {"/../../",S_OK},
5175             {"/../../",S_OK},
5176             {"",S_FALSE},
5177             {"http://google.com/../../",S_OK},
5178             {"http",S_OK},
5179             {"",S_FALSE},
5180             {"",S_FALSE}
5181         },
5182         {
5183             {Uri_HOST_DNS,S_OK},
5184             {80,S_OK},
5185             {URL_SCHEME_HTTP,S_OK},
5186             {URLZONE_INVALID,E_NOTIMPL}
5187         }
5188     },
5189     {   "http://google.com/",0,S_OK,FALSE,
5190         {
5191             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5192         },
5193         {FALSE},
5194         -1,S_OK,FALSE,
5195         0,S_OK,FALSE,
5196         Uri_CREATE_NO_DECODE_EXTRA_INFO,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5197         {
5198             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5199             {"google.com",S_OK},
5200             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5201             {"google.com",S_OK},
5202             {"",S_FALSE},
5203             {"#Fr%3C%7C%3Eg",S_OK},
5204             {"google.com",S_OK},
5205             {"",S_FALSE},
5206             {"/",S_OK},
5207             {"/",S_OK},
5208             {"",S_FALSE},
5209             {"http://google.com/#Fr<|>g",S_OK},
5210             {"http",S_OK},
5211             {"",S_FALSE},
5212             {"",S_FALSE}
5213         },
5214         {
5215             {Uri_HOST_DNS,S_OK},
5216             {80,S_OK},
5217             {URL_SCHEME_HTTP,S_OK},
5218             {URLZONE_INVALID,E_NOTIMPL}
5219         }
5220     },
5221     {   "http://google.com/",0,S_OK,FALSE,
5222         {
5223             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5224         },
5225         {FALSE},
5226         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,E_INVALIDARG,FALSE,
5227         0,S_OK,FALSE,
5228         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5229         {
5230             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5231             {"google.com",S_OK},
5232             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5233             {"google.com",S_OK},
5234             {"",S_FALSE},
5235             {"#Fr%3C%7C%3Eg",S_OK},
5236             {"google.com",S_OK},
5237             {"",S_FALSE},
5238             {"/",S_OK},
5239             {"/",S_OK},
5240             {"",S_FALSE},
5241             {"http://google.com/#Fr<|>g",S_OK},
5242             {"http",S_OK},
5243             {"",S_FALSE},
5244             {"",S_FALSE}
5245         },
5246         {
5247             {Uri_HOST_DNS,S_OK},
5248             {80,S_OK},
5249             {URL_SCHEME_HTTP,S_OK},
5250             {URLZONE_INVALID,E_NOTIMPL}
5251         }
5252     },
5253     {   NULL,0,S_OK,FALSE,
5254         {
5255             {TRUE,"/test/test/",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
5256             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5257         },
5258         {FALSE},
5259         0,INET_E_INVALID_URL,FALSE,
5260         0,INET_E_INVALID_URL,FALSE,
5261         0,0,0,INET_E_INVALID_URL,FALSE
5262     },
5263     {   "http://google.com/",0,S_OK,FALSE,
5264         {
5265             {TRUE,"ht%xxtp",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
5266         },
5267         {FALSE},
5268         0,INET_E_INVALID_URL,FALSE,
5269         0,INET_E_INVALID_URL,FALSE,
5270         0,0,0,INET_E_INVALID_URL,FALSE
5271     },
5272     /* File scheme's can't have a username set. */
5273     {   "file://google.com/",0,S_OK,FALSE,
5274         {
5275             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5276         },
5277         {FALSE},
5278         0,INET_E_INVALID_URL,FALSE,
5279         0,INET_E_INVALID_URL,FALSE,
5280         0,0,0,INET_E_INVALID_URL,FALSE
5281     },
5282     /* File schemes can't have a password set. */
5283     {   "file://google.com/",0,S_OK,FALSE,
5284         {
5285             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5286         },
5287         {FALSE},
5288         0,INET_E_INVALID_URL,FALSE,
5289         0,INET_E_INVALID_URL,FALSE,
5290         0,0,0,INET_E_INVALID_URL,FALSE
5291     },
5292     /* UserName can't contain any character that is a delimeter for another
5293      * component that appears after it in a normal URI.
5294      */
5295     {   "http://google.com/",0,S_OK,FALSE,
5296         {
5297             {TRUE,"user:pass",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5298         },
5299         {FALSE},
5300         0,INET_E_INVALID_URL,FALSE,
5301         0,INET_E_INVALID_URL,FALSE,
5302         0,0,0,INET_E_INVALID_URL,FALSE
5303     },
5304     {   "http://google.com/",0,S_OK,FALSE,
5305         {
5306             {TRUE,"user@google.com",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5307         },
5308         {FALSE},
5309         0,INET_E_INVALID_URL,FALSE,
5310         0,INET_E_INVALID_URL,FALSE,
5311         0,0,0,INET_E_INVALID_URL,FALSE
5312     },
5313     {   "http://google.com/",0,S_OK,FALSE,
5314         {
5315             {TRUE,"user/path",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5316         },
5317         {FALSE},
5318         0,INET_E_INVALID_URL,FALSE,
5319         0,INET_E_INVALID_URL,FALSE,
5320         0,0,0,INET_E_INVALID_URL,FALSE
5321     },
5322     {   "http://google.com/",0,S_OK,FALSE,
5323         {
5324             {TRUE,"user?Query",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5325         },
5326         {FALSE},
5327         0,INET_E_INVALID_URL,FALSE,
5328         0,INET_E_INVALID_URL,FALSE,
5329         0,0,0,INET_E_INVALID_URL,FALSE
5330     },
5331     {   "http://google.com/",0,S_OK,FALSE,
5332         {
5333             {TRUE,"user#Frag",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5334         },
5335         {FALSE},
5336         0,INET_E_INVALID_URL,FALSE,
5337         0,INET_E_INVALID_URL,FALSE,
5338         0,0,0,INET_E_INVALID_URL,FALSE
5339     },
5340     {   "http://google.com/",0,S_OK,FALSE,
5341         {
5342             {TRUE,"pass@google.com",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5343         },
5344         {FALSE},
5345         0,INET_E_INVALID_URL,FALSE,
5346         0,INET_E_INVALID_URL,FALSE,
5347         0,0,0,INET_E_INVALID_URL,FALSE
5348     },
5349     {   "http://google.com/",0,S_OK,FALSE,
5350         {
5351             {TRUE,"pass/path",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5352         },
5353         {FALSE},
5354         0,INET_E_INVALID_URL,FALSE,
5355         0,INET_E_INVALID_URL,FALSE,
5356         0,0,0,INET_E_INVALID_URL,FALSE
5357     },
5358     {   "http://google.com/",0,S_OK,FALSE,
5359         {
5360             {TRUE,"pass?query",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5361         },
5362         {FALSE},
5363         0,INET_E_INVALID_URL,FALSE,
5364         0,INET_E_INVALID_URL,FALSE,
5365        0,0,0,INET_E_INVALID_URL,FALSE
5366     },
5367     {   "http://google.com/",0,S_OK,FALSE,
5368         {
5369             {TRUE,"pass#frag",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5370         },
5371         {FALSE},
5372         0,INET_E_INVALID_URL,FALSE,
5373         0,INET_E_INVALID_URL,FALSE,
5374         0,0,0,INET_E_INVALID_URL,FALSE
5375     },
5376     {   "http://google.com/",0,S_OK,FALSE,
5377         {
5378             {TRUE,"winehq.org/test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5379         },
5380         {FALSE},
5381         0,INET_E_INVALID_URL,FALSE,
5382         0,INET_E_INVALID_URL,FALSE,
5383         0,0,0,INET_E_INVALID_URL,FALSE
5384     },
5385     {   "http://google.com/",0,S_OK,FALSE,
5386         {
5387             {TRUE,"winehq.org?test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5388         },
5389         {FALSE},
5390         0,INET_E_INVALID_URL,FALSE,
5391         0,INET_E_INVALID_URL,FALSE,
5392         0,0,0,INET_E_INVALID_URL,FALSE
5393     },
5394     {   "http://google.com/",0,S_OK,FALSE,
5395         {
5396             {TRUE,"winehq.org#test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5397         },
5398         {FALSE},
5399         0,INET_E_INVALID_URL,FALSE,
5400         0,INET_E_INVALID_URL,FALSE,
5401         0,0,0,INET_E_INVALID_URL,FALSE
5402     },
5403     /* Hostname is allowed to contain a ':' (even for known scheme types). */
5404     {   "http://google.com/",0,S_OK,FALSE,
5405         {
5406             {TRUE,"winehq.org:test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
5407         },
5408         {FALSE},
5409         0,S_OK,FALSE,
5410         0,S_OK,FALSE,
5411         0,0,0,S_OK,FALSE,
5412         {
5413             {"http://winehq.org:test/",S_OK},
5414             {"winehq.org:test",S_OK},
5415             {"http://winehq.org:test/",S_OK},
5416             {"winehq.org:test",S_OK},
5417             {"",S_FALSE},
5418             {"",S_FALSE},
5419             {"winehq.org:test",S_OK},
5420             {"",S_FALSE},
5421             {"/",S_OK},
5422             {"/",S_OK},
5423             {"",S_FALSE},
5424             {"http://winehq.org:test/",S_OK},
5425             {"http",S_OK},
5426             {"",S_FALSE},
5427             {"",S_FALSE}
5428         },
5429         {
5430             {Uri_HOST_DNS,S_OK},
5431             {80,S_OK},
5432             {URL_SCHEME_HTTP,S_OK},
5433             {URLZONE_INVALID,E_NOTIMPL}
5434         }
5435     },
5436     /* Can't set the host name to NULL. */
5437     {   "http://google.com/",0,S_OK,FALSE,
5438         {
5439             {TRUE,NULL,"google.com",Uri_PROPERTY_HOST,E_INVALIDARG,FALSE}
5440         },
5441         {FALSE},
5442         0,S_OK,FALSE,
5443         0,S_OK,FALSE,
5444         0,0,0,S_OK,FALSE,
5445         {
5446             {"http://google.com/",S_OK},
5447             {"google.com",S_OK},
5448             {"http://google.com/",S_OK},
5449             {"google.com",S_OK},
5450             {"",S_FALSE},
5451             {"",S_FALSE},
5452             {"google.com",S_OK},
5453             {"",S_FALSE},
5454             {"/",S_OK},
5455             {"/",S_OK},
5456             {"",S_FALSE},
5457             {"http://google.com/",S_OK},
5458             {"http",S_OK},
5459             {"",S_FALSE},
5460             {"",S_FALSE}
5461         },
5462         {
5463             {Uri_HOST_DNS,S_OK},
5464             {80,S_OK},
5465             {URL_SCHEME_HTTP,S_OK},
5466             {URLZONE_INVALID,E_NOTIMPL}
5467         }
5468     },
5469     /* Can set the host name to an empty string. */
5470     {   "http://google.com/",0,S_OK,FALSE,
5471         {
5472             {TRUE,"",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5473         },
5474         {FALSE},
5475         0,S_OK,FALSE,
5476         0,S_OK,FALSE,
5477         0,0,0,S_OK,FALSE,
5478         {
5479             {"http:///",S_OK},
5480             {"",S_OK},
5481             {"http:///",S_OK},
5482             {"",S_FALSE},
5483             {"",S_FALSE},
5484             {"",S_FALSE},
5485             {"",S_OK},
5486             {"",S_FALSE},
5487             {"/",S_OK},
5488             {"/",S_OK},
5489             {"",S_FALSE},
5490             {"http:///",S_OK},
5491             {"http",S_OK},
5492             {"",S_FALSE},
5493             {"",S_FALSE}
5494         },
5495         {
5496             {Uri_HOST_UNKNOWN,S_OK},
5497             {80,S_OK},
5498             {URL_SCHEME_HTTP,S_OK},
5499             {URLZONE_INVALID,E_NOTIMPL}
5500         }
5501     },
5502     {   "http://google.com/",0,S_OK,FALSE,
5503         {
5504             {TRUE,"/path?query",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5505         },
5506         {FALSE},
5507         0,INET_E_INVALID_URL,FALSE,
5508         0,INET_E_INVALID_URL,FALSE,
5509         0,0,0,INET_E_INVALID_URL,FALSE
5510     },
5511     {   "http://google.com/",0,S_OK,FALSE,
5512         {
5513             {TRUE,"/path#test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5514         },
5515         {FALSE},
5516         0,INET_E_INVALID_URL,FALSE,
5517         0,INET_E_INVALID_URL,FALSE,
5518         0,0,0,INET_E_INVALID_URL,FALSE
5519     },
5520     {   "http://google.com/",0,S_OK,FALSE,
5521         {
5522             {TRUE,"?path#test",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE}
5523         },
5524         {FALSE},
5525         0,INET_E_INVALID_URL,FALSE,
5526         0,INET_E_INVALID_URL,FALSE,
5527         0,0,0,INET_E_INVALID_URL,FALSE
5528     },
5529     {   "file:///c:/dir/file.html",0,S_OK,FALSE,
5530         {
5531             {TRUE,NULL,NULL,Uri_PROPERTY_FRAGMENT,S_OK},
5532         },
5533         {FALSE},
5534         0,S_OK,FALSE,
5535         0,S_OK,FALSE,
5536         0,0,0,S_OK,FALSE,
5537         {
5538             {"file:///c:/dir/file.html",S_OK},
5539             {"",S_FALSE},
5540             {"file:///c:/dir/file.html",S_OK},
5541             {"",S_FALSE},
5542             {".html",S_OK},
5543             {"",S_FALSE},
5544             {"",S_FALSE},
5545             {"",S_FALSE},
5546             {"/c:/dir/file.html",S_OK},
5547             {"/c:/dir/file.html",S_OK},
5548             {"",S_FALSE},
5549             {"file:///c:/dir/file.html",S_OK},
5550             {"file",S_OK},
5551             {"",S_FALSE},
5552             {"",S_FALSE}
5553         },
5554         {
5555             {Uri_HOST_UNKNOWN,S_OK},
5556             {0,S_FALSE},
5557             {URL_SCHEME_FILE,S_OK},
5558             {URLZONE_INVALID,E_NOTIMPL}
5559         }
5560     },
5561     {   "file:///c:/dir/file.html",0,S_OK,FALSE,
5562         {
5563             {TRUE,"#",NULL,Uri_PROPERTY_FRAGMENT,S_OK},
5564         },
5565         {FALSE},
5566         0,S_OK,FALSE,
5567         0,S_OK,FALSE,
5568         0,0,0,S_OK,FALSE,
5569         {
5570             {"file:///c:/dir/file.html#",S_OK},
5571             {"",S_FALSE},
5572             {"file:///c:/dir/file.html#",S_OK},
5573             {"",S_FALSE},
5574             {".html",S_OK},
5575             {"#",S_OK},
5576             {"",S_FALSE},
5577             {"",S_FALSE},
5578             {"/c:/dir/file.html",S_OK},
5579             {"/c:/dir/file.html",S_OK},
5580             {"",S_FALSE},
5581             {"file:///c:/dir/file.html#",S_OK},
5582             {"file",S_OK},
5583             {"",S_FALSE},
5584             {"",S_FALSE}
5585         },
5586         {
5587             {Uri_HOST_UNKNOWN,S_OK},
5588             {0,S_FALSE},
5589             {URL_SCHEME_FILE,S_OK},
5590             {URLZONE_INVALID,E_NOTIMPL}
5591         }
5592     }
5593 };
5594
5595 typedef struct _uri_builder_remove_test {
5596     const char  *uri;
5597     DWORD       create_flags;
5598     HRESULT     create_builder_expected;
5599     BOOL        create_builder_todo;
5600
5601     DWORD       remove_properties;
5602     HRESULT     remove_expected;
5603     BOOL        remove_todo;
5604
5605     const char  *expected_uri;
5606     DWORD       expected_flags;
5607     HRESULT     expected_hres;
5608     BOOL        expected_todo;
5609 } uri_builder_remove_test;
5610
5611 static const uri_builder_remove_test uri_builder_remove_tests[] = {
5612     {   "http://google.com/test?test=y#Frag",0,S_OK,FALSE,
5613         Uri_HAS_FRAGMENT|Uri_HAS_PATH|Uri_HAS_QUERY,S_OK,FALSE,
5614         "http://google.com/",0,S_OK,FALSE
5615     },
5616     {   "http://user:pass@winehq.org/",0,S_OK,FALSE,
5617         Uri_HAS_USER_NAME|Uri_HAS_PASSWORD,S_OK,FALSE,
5618         "http://winehq.org/",0,S_OK,FALSE
5619     },
5620     {   "zip://google.com?Test=x",0,S_OK,FALSE,
5621         Uri_HAS_HOST,S_OK,FALSE,
5622         "zip:/?Test=x",0,S_OK,FALSE
5623     },
5624     /* Doesn't remove the whole userinfo component. */
5625     {   "http://username:pass@google.com/",0,S_OK,FALSE,
5626         Uri_HAS_USER_INFO,S_OK,FALSE,
5627         "http://username:pass@google.com/",0,S_OK,FALSE
5628     },
5629     /* Doesn't remove the domain. */
5630     {   "http://google.com/",0,S_OK,FALSE,
5631         Uri_HAS_DOMAIN,S_OK,FALSE,
5632         "http://google.com/",0,S_OK,FALSE
5633     },
5634     {   "http://google.com:120/",0,S_OK,FALSE,
5635         Uri_HAS_AUTHORITY,S_OK,FALSE,
5636         "http://google.com:120/",0,S_OK,FALSE
5637     },
5638     {   "http://google.com/test.com/",0,S_OK,FALSE,
5639         Uri_HAS_EXTENSION,S_OK,FALSE,
5640         "http://google.com/test.com/",0,S_OK,FALSE
5641     },
5642     {   "http://google.com/?test=x",0,S_OK,FALSE,
5643         Uri_HAS_PATH_AND_QUERY,S_OK,FALSE,
5644         "http://google.com/?test=x",0,S_OK,FALSE
5645     },
5646     /* Can't remove the scheme name. */
5647     {   "http://google.com/?test=x",0,S_OK,FALSE,
5648         Uri_HAS_SCHEME_NAME|Uri_HAS_QUERY,E_INVALIDARG,FALSE,
5649         "http://google.com/?test=x",0,S_OK,FALSE
5650     }
5651 };
5652
5653 typedef struct _uri_combine_str_property {
5654     const char  *value;
5655     HRESULT     expected;
5656     BOOL        todo;
5657     const char  *broken_value;
5658     const char  *value_ex;
5659 } uri_combine_str_property;
5660
5661 typedef struct _uri_combine_test {
5662     const char  *base_uri;
5663     DWORD       base_create_flags;
5664     const char  *relative_uri;
5665     DWORD       relative_create_flags;
5666     DWORD       combine_flags;
5667     HRESULT     expected;
5668     BOOL        todo;
5669
5670     uri_combine_str_property    str_props[URI_STR_PROPERTY_COUNT];
5671     uri_dword_property          dword_props[URI_DWORD_PROPERTY_COUNT];
5672 } uri_combine_test;
5673
5674 static const uri_combine_test uri_combine_tests[] = {
5675     {   "http://google.com/fun/stuff",0,
5676         "../not/fun/stuff",Uri_CREATE_ALLOW_RELATIVE,
5677         0,S_OK,FALSE,
5678         {
5679             {"http://google.com/not/fun/stuff",S_OK},
5680             {"google.com",S_OK},
5681             {"http://google.com/not/fun/stuff",S_OK},
5682             {"google.com",S_OK},
5683             {"",S_FALSE},
5684             {"",S_FALSE},
5685             {"google.com",S_OK},
5686             {"",S_FALSE},
5687             {"/not/fun/stuff",S_OK},
5688             {"/not/fun/stuff",S_OK},
5689             {"",S_FALSE},
5690             {"http://google.com/not/fun/stuff",S_OK},
5691             {"http",S_OK},
5692             {"",S_FALSE},
5693             {"",S_FALSE}
5694         },
5695         {
5696             {Uri_HOST_DNS,S_OK},
5697             {80,S_OK},
5698             {URL_SCHEME_HTTP,S_OK},
5699             {URLZONE_INVALID,E_NOTIMPL}
5700         }
5701     },
5702     {   "http://google.com/test",0,
5703         "zip://test.com/cool",0,
5704         0,S_OK,FALSE,
5705         {
5706             {"zip://test.com/cool",S_OK},
5707             {"test.com",S_OK},
5708             {"zip://test.com/cool",S_OK},
5709             {"test.com",S_OK},
5710             {"",S_FALSE},
5711             {"",S_FALSE},
5712             {"test.com",S_OK},
5713             {"",S_FALSE},
5714             {"/cool",S_OK},
5715             {"/cool",S_OK},
5716             {"",S_FALSE},
5717             {"zip://test.com/cool",S_OK},
5718             {"zip",S_OK},
5719             {"",S_FALSE},
5720             {"",S_FALSE}
5721         },
5722         {
5723             {Uri_HOST_DNS,S_OK},
5724             {0,S_FALSE},
5725             {URL_SCHEME_UNKNOWN,S_OK},
5726             {URLZONE_INVALID,E_NOTIMPL}
5727         }
5728     },
5729     {   "http://google.com/use/base/path",0,
5730         "?relative",Uri_CREATE_ALLOW_RELATIVE,
5731         0,S_OK,FALSE,
5732         {
5733             {"http://google.com/use/base/path?relative",S_OK},
5734             {"google.com",S_OK},
5735             {"http://google.com/use/base/path?relative",S_OK},
5736             {"google.com",S_OK},
5737             {"",S_FALSE},
5738             {"",S_FALSE},
5739             {"google.com",S_OK},
5740             {"",S_FALSE},
5741             {"/use/base/path",S_OK},
5742             {"/use/base/path?relative",S_OK},
5743             {"?relative",S_OK},
5744             {"http://google.com/use/base/path?relative",S_OK},
5745             {"http",S_OK},
5746             {"",S_FALSE},
5747             {"",S_FALSE}
5748         },
5749         {
5750             {Uri_HOST_DNS,S_OK},
5751             {80,S_OK},
5752             {URL_SCHEME_HTTP,S_OK},
5753             {URLZONE_INVALID,E_NOTIMPL}
5754         }
5755     },
5756     {   "http://google.com/path",0,
5757         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5758         0,S_OK,FALSE,
5759         {
5760             {"http://google.com/testing",S_OK},
5761             {"google.com",S_OK},
5762             {"http://google.com/testing",S_OK},
5763             {"google.com",S_OK},
5764             {"",S_FALSE},
5765             {"",S_FALSE},
5766             {"google.com",S_OK},
5767             {"",S_FALSE},
5768             {"/testing",S_OK},
5769             {"/testing",S_OK},
5770             {"",S_FALSE},
5771             {"http://google.com/testing",S_OK},
5772             {"http",S_OK},
5773             {"",S_FALSE},
5774             {"",S_FALSE}
5775         },
5776         {
5777             {Uri_HOST_DNS,S_OK},
5778             {80,S_OK},
5779             {URL_SCHEME_HTTP,S_OK},
5780             {URLZONE_INVALID,E_NOTIMPL}
5781         }
5782     },
5783     {   "http://google.com/path",0,
5784         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5785         URL_DONT_SIMPLIFY,S_OK,FALSE,
5786         {
5787             {"http://google.com:80/test/../test/.././testing",S_OK},
5788             {"google.com",S_OK},
5789             {"http://google.com:80/test/../test/.././testing",S_OK},
5790             {"google.com",S_OK},
5791             {"",S_FALSE},
5792             {"",S_FALSE},
5793             {"google.com",S_OK},
5794             {"",S_FALSE},
5795             {"/test/../test/.././testing",S_OK},
5796             {"/test/../test/.././testing",S_OK},
5797             {"",S_FALSE},
5798             {"http://google.com:80/test/../test/.././testing",S_OK},
5799             {"http",S_OK},
5800             {"",S_FALSE},
5801             {"",S_FALSE}
5802         },
5803         {
5804             {Uri_HOST_DNS,S_OK},
5805             {80,S_OK},
5806             {URL_SCHEME_HTTP,S_OK},
5807             {URLZONE_INVALID,E_NOTIMPL}
5808         }
5809     },
5810     {   "http://winehq.org/test/abc",0,
5811         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5812         0,S_OK,FALSE,
5813         {
5814             {"http://winehq.org/test/testing/test",S_OK},
5815             {"winehq.org",S_OK},
5816             {"http://winehq.org/test/testing/test",S_OK},
5817             {"winehq.org",S_OK},
5818             {"",S_FALSE},
5819             {"",S_FALSE},
5820             {"winehq.org",S_OK},
5821             {"",S_FALSE},
5822             {"/test/testing/test",S_OK},
5823             {"/test/testing/test",S_OK},
5824             {"",S_FALSE},
5825             {"http://winehq.org/test/testing/test",S_OK},
5826             {"http",S_OK},
5827             {"",S_FALSE},
5828             {"",S_FALSE}
5829         },
5830         {
5831             {Uri_HOST_DNS,S_OK},
5832             {80,S_OK},
5833             {URL_SCHEME_HTTP,S_OK},
5834             {URLZONE_INVALID,E_NOTIMPL}
5835         }
5836     },
5837     {   "http://winehq.org/test/abc",0,
5838         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5839         URL_DONT_SIMPLIFY,S_OK,FALSE,
5840         {
5841             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5842             /* Default port is hidden in the authority. */
5843             {"winehq.org",S_OK},
5844             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5845             {"winehq.org",S_OK},
5846             {"",S_FALSE},
5847             {"",S_FALSE},
5848             {"winehq.org",S_OK},
5849             {"",S_FALSE},
5850             {"/test/testing/abc/../test",S_OK},
5851             {"/test/testing/abc/../test",S_OK},
5852             {"",S_FALSE},
5853             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5854             {"http",S_OK},
5855             {"",S_FALSE},
5856             {"",S_FALSE}
5857         },
5858         {
5859             {Uri_HOST_DNS,S_OK},
5860             {80,S_OK},
5861             {URL_SCHEME_HTTP,S_OK},
5862             {URLZONE_INVALID,E_NOTIMPL}
5863         }
5864     },
5865     {   "http://winehq.org/test?query",0,
5866         "testing",Uri_CREATE_ALLOW_RELATIVE,
5867         0,S_OK,FALSE,
5868         {
5869             {"http://winehq.org/testing",S_OK},
5870             {"winehq.org",S_OK},
5871             {"http://winehq.org/testing",S_OK},
5872             {"winehq.org",S_OK},
5873             {"",S_FALSE},
5874             {"",S_FALSE},
5875             {"winehq.org",S_OK},
5876             {"",S_FALSE},
5877             {"/testing",S_OK},
5878             {"/testing",S_OK},
5879             {"",S_FALSE},
5880             {"http://winehq.org/testing",S_OK},
5881             {"http",S_OK},
5882             {"",S_FALSE},
5883             {"",S_FALSE}
5884         },
5885         {
5886             {Uri_HOST_DNS,S_OK},
5887             {80,S_OK},
5888             {URL_SCHEME_HTTP,S_OK},
5889             {URLZONE_INVALID,E_NOTIMPL}
5890         }
5891     },
5892     {   "http://winehq.org/test#frag",0,
5893         "testing",Uri_CREATE_ALLOW_RELATIVE,
5894         0,S_OK,FALSE,
5895         {
5896             {"http://winehq.org/testing",S_OK},
5897             {"winehq.org",S_OK},
5898             {"http://winehq.org/testing",S_OK},
5899             {"winehq.org",S_OK},
5900             {"",S_FALSE},
5901             {"",S_FALSE},
5902             {"winehq.org",S_OK},
5903             {"",S_FALSE},
5904             {"/testing",S_OK},
5905             {"/testing",S_OK},
5906             {"",S_FALSE},
5907             {"http://winehq.org/testing",S_OK},
5908             {"http",S_OK},
5909             {"",S_FALSE},
5910             {"",S_FALSE}
5911         },
5912         {
5913             {Uri_HOST_DNS,S_OK},
5914             {80,S_OK},
5915             {URL_SCHEME_HTTP,S_OK},
5916             {URLZONE_INVALID,E_NOTIMPL}
5917         }
5918     },
5919     {   "testing?query#frag",Uri_CREATE_ALLOW_RELATIVE,
5920         "test",Uri_CREATE_ALLOW_RELATIVE,
5921         0,S_OK,FALSE,
5922         {
5923             {"test",S_OK},
5924             {"",S_FALSE},
5925             {"test",S_OK},
5926             {"",S_FALSE},
5927             {"",S_FALSE},
5928             {"",S_FALSE},
5929             {"",S_FALSE},
5930             {"",S_FALSE},
5931             {"test",S_OK},
5932             {"test",S_OK},
5933             {"",S_FALSE},
5934             {"test",S_OK},
5935             {"",S_FALSE},
5936             {"",S_FALSE},
5937             {"",S_FALSE}
5938         },
5939         {
5940             {Uri_HOST_UNKNOWN,S_OK},
5941             {0,S_FALSE},
5942             {URL_SCHEME_UNKNOWN,S_OK},
5943             {URLZONE_INVALID,E_NOTIMPL}
5944         }
5945     },
5946     {   "file:///c:/test/test",0,
5947         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5948         URL_FILE_USE_PATHURL,S_OK,FALSE,
5949         {
5950             {"file://c:\\testing.mp3",S_OK},
5951             {"",S_FALSE},
5952             {"file://c:\\testing.mp3",S_OK},
5953             {"",S_FALSE},
5954             {".mp3",S_OK},
5955             {"",S_FALSE},
5956             {"",S_FALSE},
5957             {"",S_FALSE},
5958             {"c:\\testing.mp3",S_OK},
5959             {"c:\\testing.mp3",S_OK},
5960             {"",S_FALSE},
5961             {"file://c:\\testing.mp3",S_OK},
5962             {"file",S_OK},
5963             {"",S_FALSE},
5964             {"",S_FALSE}
5965         },
5966         {
5967             {Uri_HOST_UNKNOWN,S_OK},
5968             {0,S_FALSE},
5969             {URL_SCHEME_FILE,S_OK},
5970             {URLZONE_INVALID,E_NOTIMPL}
5971         }
5972     },
5973     {   "file:///c:/test/test",0,
5974         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5975         0,S_OK,FALSE,
5976         {
5977             {"file:///c:/testing.mp3",S_OK},
5978             {"",S_FALSE},
5979             {"file:///c:/testing.mp3",S_OK},
5980             {"",S_FALSE},
5981             {".mp3",S_OK},
5982             {"",S_FALSE},
5983             {"",S_FALSE},
5984             {"",S_FALSE},
5985             {"/c:/testing.mp3",S_OK},
5986             {"/c:/testing.mp3",S_OK},
5987             {"",S_FALSE},
5988             {"file:///c:/testing.mp3",S_OK},
5989             {"file",S_OK},
5990             {"",S_FALSE},
5991             {"",S_FALSE}
5992         },
5993         {
5994             {Uri_HOST_UNKNOWN,S_OK},
5995             {0,S_FALSE},
5996             {URL_SCHEME_FILE,S_OK},
5997             {URLZONE_INVALID,E_NOTIMPL}
5998         }
5999     },
6000     {   "file://test.com/test/test",0,
6001         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
6002         URL_FILE_USE_PATHURL,S_OK,FALSE,
6003         {
6004             {"file://\\\\test.com\\testing.mp3",S_OK},
6005             {"test.com",S_OK},
6006             {"file://\\\\test.com\\testing.mp3",S_OK},
6007             {"test.com",S_OK},
6008             {".mp3",S_OK},
6009             {"",S_FALSE},
6010             {"test.com",S_OK},
6011             {"",S_FALSE},
6012             {"\\testing.mp3",S_OK},
6013             {"\\testing.mp3",S_OK},
6014             {"",S_FALSE},
6015             {"file://\\\\test.com\\testing.mp3",S_OK},
6016             {"file",S_OK},
6017             {"",S_FALSE},
6018             {"",S_FALSE}
6019         },
6020         {
6021             {Uri_HOST_DNS,S_OK},
6022             {0,S_FALSE},
6023             {URL_SCHEME_FILE,S_OK},
6024             {URLZONE_INVALID,E_NOTIMPL}
6025         }
6026     },
6027     /* URL_DONT_SIMPLIFY has no effect. */
6028     {   "http://google.com/test",0,
6029         "zip://test.com/cool/../cool/test",0,
6030         URL_DONT_SIMPLIFY,S_OK,FALSE,
6031         {
6032             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
6033             {"test.com",S_OK},
6034             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
6035             {"test.com",S_OK},
6036             {"",S_FALSE},
6037             {"",S_FALSE},
6038             {"test.com",S_OK},
6039             {"",S_FALSE},
6040             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
6041             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
6042             {"",S_FALSE},
6043             /* The resulting IUri has the same Raw URI as the relative URI (only IE 8).
6044              * On IE 7 it reduces the path in the Raw URI.
6045              */
6046             {"zip://test.com/cool/../cool/test",S_OK,FALSE,"zip://test.com/cool/test"},
6047             {"zip",S_OK},
6048             {"",S_FALSE},
6049             {"",S_FALSE}
6050         },
6051         {
6052             {Uri_HOST_DNS,S_OK},
6053             {0,S_FALSE},
6054             {URL_SCHEME_UNKNOWN,S_OK},
6055             {URLZONE_INVALID,E_NOTIMPL}
6056         }
6057     },
6058     /* FILE_USE_PATHURL has no effect in IE 8, in IE 7 the
6059      * resulting URI is converted into a dos path.
6060      */
6061     {   "http://google.com/test",0,
6062         "file:///c:/test/",0,
6063         URL_FILE_USE_PATHURL,S_OK,FALSE,
6064         {
6065             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
6066             {"",S_FALSE},
6067             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
6068             {"",S_FALSE},
6069             {"",S_FALSE},
6070             {"",S_FALSE},
6071             {"",S_FALSE},
6072             {"",S_FALSE},
6073             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
6074             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
6075             {"",S_FALSE},
6076             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
6077             {"file",S_OK},
6078             {"",S_FALSE},
6079             {"",S_FALSE}
6080         },
6081         {
6082             {Uri_HOST_UNKNOWN,S_OK},
6083             {0,S_FALSE},
6084             {URL_SCHEME_FILE,S_OK},
6085             {URLZONE_INVALID,E_NOTIMPL}
6086         }
6087     },
6088     {   "http://google.com/test",0,
6089         "http://test.com/test#%30test",0,
6090         URL_DONT_UNESCAPE_EXTRA_INFO,S_OK,FALSE,
6091         {
6092             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
6093             {"test.com",S_OK},
6094             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
6095             {"test.com",S_OK},
6096             {"",S_FALSE},
6097             {"#0test",S_OK,FALSE,NULL,"#%30test"},
6098             {"test.com",S_OK},
6099             {"",S_FALSE},
6100             {"/test",S_OK},
6101             {"/test",S_OK},
6102             {"",S_FALSE},
6103             /* IE 7 decodes the %30 to a 0 in the Raw URI. */
6104             {"http://test.com/test#%30test",S_OK,FALSE,"http://test.com/test#0test"},
6105             {"http",S_OK},
6106             {"",S_FALSE},
6107             {"",S_FALSE}
6108         },
6109         {
6110             {Uri_HOST_DNS,S_OK},
6111             {80,S_OK},
6112             {URL_SCHEME_HTTP,S_OK},
6113             {URLZONE_INVALID,E_NOTIMPL}
6114         }
6115     },
6116     /* Windows validates the path component from the relative Uri. */
6117     {   "http://google.com/test",0,
6118         "/Te%XXst",Uri_CREATE_ALLOW_RELATIVE,
6119         0,E_INVALIDARG,FALSE
6120     },
6121     /* Windows doesn't validate the query from the relative Uri. */
6122     {   "http://google.com/test",0,
6123         "?Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
6124         0,S_OK,FALSE,
6125         {
6126             {"http://google.com/test?Tes%XXt",S_OK},
6127             {"google.com",S_OK},
6128             {"http://google.com/test?Tes%XXt",S_OK},
6129             {"google.com",S_OK},
6130             {"",S_FALSE},
6131             {"",S_FALSE},
6132             {"google.com",S_OK},
6133             {"",S_FALSE},
6134             {"/test",S_OK},
6135             {"/test?Tes%XXt",S_OK},
6136             {"?Tes%XXt",S_OK},
6137             {"http://google.com/test?Tes%XXt",S_OK},
6138             {"http",S_OK},
6139             {"",S_FALSE},
6140             {"",S_FALSE}
6141         },
6142         {
6143             {Uri_HOST_DNS,S_OK},
6144             {80,S_OK},
6145             {URL_SCHEME_HTTP,S_OK},
6146             {URLZONE_INVALID,E_NOTIMPL}
6147         }
6148     },
6149     /* Windows doesn't validate the fragment from the relative Uri. */
6150     {   "http://google.com/test",0,
6151         "#Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
6152         0,S_OK,FALSE,
6153         {
6154             {"http://google.com/test#Tes%XXt",S_OK},
6155             {"google.com",S_OK},
6156             {"http://google.com/test#Tes%XXt",S_OK},
6157             {"google.com",S_OK},
6158             {"",S_FALSE},
6159             {"#Tes%XXt",S_OK},
6160             {"google.com",S_OK},
6161             {"",S_FALSE},
6162             {"/test",S_OK},
6163             {"/test",S_OK},
6164             {"",S_FALSE},
6165             {"http://google.com/test#Tes%XXt",S_OK},
6166             {"http",S_OK},
6167             {"",S_FALSE},
6168             {"",S_FALSE}
6169         },
6170         {
6171             {Uri_HOST_DNS,S_OK},
6172             {80,S_OK},
6173             {URL_SCHEME_HTTP,S_OK},
6174             {URLZONE_INVALID,E_NOTIMPL}
6175         }
6176     },
6177     /* Creates an IUri which contains an invalid dos path char. */
6178     {   "file:///c:/test",0,
6179         "/test<ing",Uri_CREATE_ALLOW_RELATIVE,
6180         URL_FILE_USE_PATHURL,S_OK,FALSE,
6181         {
6182             {"file://c:\\test<ing",S_OK},
6183             {"",S_FALSE},
6184             {"file://c:\\test<ing",S_OK},
6185             {"",S_FALSE},
6186             {"",S_FALSE},
6187             {"",S_FALSE},
6188             {"",S_FALSE},
6189             {"",S_FALSE},
6190             {"c:\\test<ing",S_OK},
6191             {"c:\\test<ing",S_OK},
6192             {"",S_FALSE},
6193             {"file://c:\\test<ing",S_OK},
6194             {"file",S_OK},
6195             {"",S_FALSE},
6196             {"",S_FALSE}
6197         },
6198         {
6199             {Uri_HOST_UNKNOWN,S_OK},
6200             {0,S_FALSE},
6201             {URL_SCHEME_FILE,S_OK},
6202             {URLZONE_INVALID,E_NOTIMPL}
6203         }
6204     },
6205     /* Appends the path after the drive letter (if any). */
6206     {   "file:///c:/test",0,
6207         "/c:/testing",Uri_CREATE_ALLOW_RELATIVE,
6208         0,S_OK,FALSE,
6209         {
6210             {"file:///c:/c:/testing",S_OK},
6211             {"",S_FALSE},
6212             {"file:///c:/c:/testing",S_OK},
6213             {"",S_FALSE},
6214             {"",S_FALSE},
6215             {"",S_FALSE},
6216             {"",S_FALSE},
6217             {"",S_FALSE},
6218             {"/c:/c:/testing",S_OK},
6219             {"/c:/c:/testing",S_OK},
6220             {"",S_FALSE},
6221             {"file:///c:/c:/testing",S_OK},
6222             {"file",S_OK},
6223             {"",S_FALSE},
6224             {"",S_FALSE}
6225         },
6226         {
6227             {Uri_HOST_UNKNOWN,S_OK},
6228             {0,S_FALSE},
6229             {URL_SCHEME_FILE,S_OK},
6230             {URLZONE_INVALID,E_NOTIMPL}
6231         }
6232     },
6233     /* A '/' is added if the base URI doesn't have a path and the
6234      * relative URI doesn't contain a path (since the base URI is
6235      * hierarchical.
6236      */
6237     {   "http://google.com",Uri_CREATE_NO_CANONICALIZE,
6238         "?test",Uri_CREATE_ALLOW_RELATIVE,
6239         0,S_OK,FALSE,
6240         {
6241             {"http://google.com/?test",S_OK},
6242             {"google.com",S_OK},
6243             {"http://google.com/?test",S_OK},
6244             {"google.com",S_OK},
6245             {"",S_FALSE},
6246             {"",S_FALSE},
6247             {"google.com",S_OK},
6248             {"",S_FALSE},
6249             {"/",S_OK},
6250             {"/?test",S_OK},
6251             {"?test",S_OK},
6252             {"http://google.com/?test",S_OK},
6253             {"http",S_OK},
6254             {"",S_FALSE},
6255             {"",S_FALSE}
6256         },
6257         {
6258             {Uri_HOST_DNS,S_OK},
6259             {80,S_OK},
6260             {URL_SCHEME_HTTP,S_OK},
6261             {URLZONE_INVALID,E_NOTIMPL}
6262         }
6263     },
6264     {   "zip://google.com",Uri_CREATE_NO_CANONICALIZE,
6265         "?test",Uri_CREATE_ALLOW_RELATIVE,
6266         0,S_OK,FALSE,
6267         {
6268             {"zip://google.com/?test",S_OK},
6269             {"google.com",S_OK},
6270             {"zip://google.com/?test",S_OK},
6271             {"google.com",S_OK},
6272             {"",S_FALSE},
6273             {"",S_FALSE},
6274             {"google.com",S_OK},
6275             {"",S_FALSE},
6276             {"/",S_OK},
6277             {"/?test",S_OK},
6278             {"?test",S_OK},
6279             {"zip://google.com/?test",S_OK},
6280             {"zip",S_OK},
6281             {"",S_FALSE},
6282             {"",S_FALSE}
6283         },
6284         {
6285             {Uri_HOST_DNS,S_OK},
6286             {0,S_FALSE},
6287             {URL_SCHEME_UNKNOWN,S_OK},
6288             {URLZONE_INVALID,E_NOTIMPL}
6289         }
6290     },
6291     /* No path is appended since the base URI is opaque. */
6292     {   "zip:?testing",0,
6293         "?test",Uri_CREATE_ALLOW_RELATIVE,
6294         0,S_OK,FALSE,
6295         {
6296             {"zip:?test",S_OK},
6297             {"",S_FALSE},
6298             {"zip:?test",S_OK},
6299             {"",S_FALSE},
6300             {"",S_FALSE},
6301             {"",S_FALSE},
6302             {"",S_FALSE},
6303             {"",S_FALSE},
6304             {"",S_OK},
6305             {"?test",S_OK},
6306             {"?test",S_OK},
6307             {"zip:?test",S_OK},
6308             {"zip",S_OK},
6309             {"",S_FALSE},
6310             {"",S_FALSE}
6311         },
6312         {
6313             {Uri_HOST_UNKNOWN,S_OK},
6314             {0,S_FALSE},
6315             {URL_SCHEME_UNKNOWN,S_OK},
6316             {URLZONE_INVALID,E_NOTIMPL}
6317         }
6318     },
6319     {   "file:///c:/",0,
6320         "../testing/test",Uri_CREATE_ALLOW_RELATIVE,
6321         0,S_OK,FALSE,
6322         {
6323             {"file:///c:/testing/test",S_OK},
6324             {"",S_FALSE},
6325             {"file:///c:/testing/test",S_OK},
6326             {"",S_FALSE},
6327             {"",S_FALSE},
6328             {"",S_FALSE},
6329             {"",S_FALSE},
6330             {"",S_FALSE},
6331             {"/c:/testing/test",S_OK},
6332             {"/c:/testing/test",S_OK},
6333             {"",S_FALSE},
6334             {"file:///c:/testing/test",S_OK},
6335             {"file",S_OK},
6336             {"",S_FALSE},
6337             {"",S_FALSE}
6338         },
6339         {
6340             {Uri_HOST_UNKNOWN,S_OK},
6341             {0,S_FALSE},
6342             {URL_SCHEME_FILE,S_OK},
6343             {URLZONE_INVALID,E_NOTIMPL}
6344         }
6345     },
6346     {   "http://winehq.org/dir/testfile",0,
6347         "test?querystring",Uri_CREATE_ALLOW_RELATIVE,
6348         0,S_OK,FALSE,
6349         {
6350             {"http://winehq.org/dir/test?querystring",S_OK},
6351             {"winehq.org",S_OK},
6352             {"http://winehq.org/dir/test?querystring",S_OK},
6353             {"winehq.org",S_OK},
6354             {"",S_FALSE},
6355             {"",S_FALSE},
6356             {"winehq.org",S_OK},
6357             {"",S_FALSE},
6358             {"/dir/test",S_OK},
6359             {"/dir/test?querystring",S_OK},
6360             {"?querystring",S_OK},
6361             {"http://winehq.org/dir/test?querystring",S_OK},
6362             {"http",S_OK},
6363             {"",S_FALSE},
6364             {"",S_FALSE}
6365         },
6366         {
6367             {Uri_HOST_DNS,S_OK},
6368             {80,S_OK},
6369             {URL_SCHEME_HTTP,S_OK},
6370             {URLZONE_INVALID,E_NOTIMPL}
6371         }
6372     },
6373     {   "http://winehq.org/dir/test",0,
6374         "test?querystring",Uri_CREATE_ALLOW_RELATIVE,
6375         0,S_OK,FALSE,
6376         {
6377             {"http://winehq.org/dir/test?querystring",S_OK},
6378             {"winehq.org",S_OK},
6379             {"http://winehq.org/dir/test?querystring",S_OK},
6380             {"winehq.org",S_OK},
6381             {"",S_FALSE},
6382             {"",S_FALSE},
6383             {"winehq.org",S_OK},
6384             {"",S_FALSE},
6385             {"/dir/test",S_OK},
6386             {"/dir/test?querystring",S_OK},
6387             {"?querystring",S_OK},
6388             {"http://winehq.org/dir/test?querystring",S_OK},
6389             {"http",S_OK},
6390             {"",S_FALSE},
6391             {"",S_FALSE}
6392         },
6393         {
6394             {Uri_HOST_DNS,S_OK},
6395             {80,S_OK},
6396             {URL_SCHEME_HTTP,S_OK},
6397             {URLZONE_INVALID,E_NOTIMPL}
6398         }
6399     },
6400     {   "http://winehq.org/dir/test?querystring",0,
6401         "#hash",Uri_CREATE_ALLOW_RELATIVE,
6402         0,S_OK,FALSE,
6403         {
6404             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6405             {"winehq.org",S_OK},
6406             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6407             {"winehq.org",S_OK},
6408             {"",S_FALSE},
6409             {"#hash",S_OK},
6410             {"winehq.org",S_OK},
6411             {"",S_FALSE},
6412             {"/dir/test",S_OK},
6413             {"/dir/test?querystring",S_OK},
6414             {"?querystring",S_OK},
6415             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6416             {"http",S_OK},
6417             {"",S_FALSE},
6418             {"",S_FALSE}
6419         },
6420         {
6421             {Uri_HOST_DNS,S_OK},
6422             {80,S_OK},
6423             {URL_SCHEME_HTTP,S_OK},
6424             {URLZONE_INVALID,E_NOTIMPL}
6425         }
6426     },
6427     {   "mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir\\file.txt",0,
6428         "relative/path.txt",Uri_CREATE_ALLOW_RELATIVE,
6429         0,S_OK,FALSE,
6430         {
6431             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6432             {"",S_FALSE},
6433             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6434             {"",S_FALSE},
6435             {".txt",S_OK},
6436             {"",S_FALSE},
6437             {"",S_FALSE},
6438             {"",S_FALSE},
6439             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6440             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6441             {"",S_FALSE},
6442             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6443             {"mk",S_OK},
6444             {"",S_FALSE},
6445             {"",S_FALSE}
6446         },
6447         {
6448             {Uri_HOST_UNKNOWN,S_OK},
6449             {0,S_FALSE},
6450             {URL_SCHEME_MK,S_OK},
6451             {URLZONE_INVALID,E_NOTIMPL}
6452         }
6453     },
6454     {   "mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::\\subdir\\file.txt",0,
6455         "relative/path.txt",Uri_CREATE_ALLOW_RELATIVE,
6456         0,S_OK,FALSE,
6457         {
6458             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6459             {"",S_FALSE},
6460             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6461             {"",S_FALSE},
6462             {".txt",S_OK},
6463             {"",S_FALSE},
6464             {"",S_FALSE},
6465             {"",S_FALSE},
6466             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6467             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6468             {"",S_FALSE},
6469             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6470             {"mk",S_OK},
6471             {"",S_FALSE},
6472             {"",S_FALSE}
6473         },
6474         {
6475             {Uri_HOST_UNKNOWN,S_OK},
6476             {0,S_FALSE},
6477             {URL_SCHEME_MK,S_OK},
6478             {URLZONE_INVALID,E_NOTIMPL}
6479         }
6480     },
6481     {   "mk:@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir\\file.txt",0,
6482         "relative\\path.txt",Uri_CREATE_ALLOW_RELATIVE,
6483         0,S_OK,FALSE,
6484         {
6485             {"mk:@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6486             {"",S_FALSE},
6487             {"mk:@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6488             {"",S_FALSE},
6489             {".txt",S_OK},
6490             {"",S_FALSE},
6491             {"",S_FALSE},
6492             {"",S_FALSE},
6493             {"@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6494             {"@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6495             {"",S_FALSE},
6496             {"mk:@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6497             {"mk",S_OK},
6498             {"",S_FALSE},
6499             {"",S_FALSE}
6500         },
6501         {
6502             {Uri_HOST_UNKNOWN,S_OK},
6503             {0,S_FALSE},
6504             {URL_SCHEME_MK,S_OK},
6505             {URLZONE_INVALID,E_NOTIMPL}
6506         }
6507     }
6508 };
6509
6510 typedef struct _uri_parse_test {
6511     const char  *uri;
6512     DWORD       uri_flags;
6513     PARSEACTION action;
6514     DWORD       flags;
6515     const char  *property;
6516     HRESULT     expected;
6517     BOOL        todo;
6518 } uri_parse_test;
6519
6520 static const uri_parse_test uri_parse_tests[] = {
6521     /* PARSE_CANONICALIZE tests. */
6522     {"zip://google.com/test<|>",0,PARSE_CANONICALIZE,0,"zip://google.com/test<|>",S_OK,FALSE},
6523     {"http://google.com/test<|>",0,PARSE_CANONICALIZE,0,"http://google.com/test%3C%7C%3E",S_OK,FALSE},
6524     {"http://google.com/%30%23%3F",0,PARSE_CANONICALIZE,URL_UNESCAPE,"http://google.com/0#?",S_OK,FALSE},
6525     {"test <|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_ESCAPE_UNSAFE,"test %3C%7C%3E",S_OK,FALSE},
6526     {"test <|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_ESCAPE_SPACES_ONLY,"test%20<|>",S_OK,FALSE},
6527     {"test%20<|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_UNESCAPE|URL_ESCAPE_UNSAFE,"test%20%3C%7C%3E",S_OK,FALSE},
6528     {"http://google.com/%20",0,PARSE_CANONICALIZE,URL_ESCAPE_PERCENT,"http://google.com/%2520",S_OK,FALSE},
6529     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_DONT_SIMPLIFY,"http://google.com/test/../",S_OK,FALSE},
6530     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_NO_META,"http://google.com/test/../",S_OK,FALSE},
6531     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,0,"http://google.com/",S_OK,FALSE},
6532     {"zip://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,0,"zip://google.com/",S_OK,FALSE},
6533     {"file:///c:/test/../test",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_DONT_SIMPLIFY,"file:///c:/test/../test",S_OK,FALSE},
6534
6535     /* PARSE_FRIENDLY tests. */
6536     {"http://test@google.com/test#test",0,PARSE_FRIENDLY,0,"http://google.com/test#test",S_OK,FALSE},
6537     {"zip://test@google.com/test",0,PARSE_FRIENDLY,0,"zip://test@google.com/test",S_OK,FALSE},
6538
6539     /* PARSE_ROOTDOCUMENT tests. */
6540     {"http://google.com:200/test/test",0,PARSE_ROOTDOCUMENT,0,"http://google.com:200/",S_OK,FALSE},
6541     {"http://google.com",Uri_CREATE_NO_CANONICALIZE,PARSE_ROOTDOCUMENT,0,"http://google.com/",S_OK,FALSE},
6542     {"zip://google.com/",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6543     {"file:///c:/testing/",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6544     {"file://server/test",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6545     {"zip:test/test",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6546
6547     /* PARSE_DOCUMENT tests. */
6548     {"http://test@google.com/test?query#frag",0,PARSE_DOCUMENT,0,"http://test@google.com/test?query",S_OK,FALSE},
6549     {"http:testing#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6550     {"file:///c:/test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6551     {"zip://google.com/#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6552     {"zip:test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6553     {"testing#frag",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6554
6555     /* PARSE_PATH_FROM_URL tests. */
6556     {"file:///c:/test.mp3",0,PARSE_PATH_FROM_URL,0,"c:\\test.mp3",S_OK,FALSE},
6557     {"file:///c:/t<|>est.mp3",0,PARSE_PATH_FROM_URL,0,"c:\\t<|>est.mp3",S_OK,FALSE},
6558     {"file:///c:/te%XX t/",0,PARSE_PATH_FROM_URL,0,"c:\\te%XX t\\",S_OK,FALSE},
6559     {"file://server/test",0,PARSE_PATH_FROM_URL,0,"\\\\server\\test",S_OK,FALSE},
6560     {"http://google.com/",0,PARSE_PATH_FROM_URL,0,"",E_INVALIDARG,FALSE},
6561
6562     /* PARSE_URL_FROM_PATH tests. */
6563     /* This function almost seems to useless (just returns the absolute uri). */
6564     {"test.com",Uri_CREATE_ALLOW_RELATIVE,PARSE_URL_FROM_PATH,0,"test.com",S_OK,FALSE},
6565     {"/test/test",Uri_CREATE_ALLOW_RELATIVE,PARSE_URL_FROM_PATH,0,"/test/test",S_OK,FALSE},
6566     {"file://c:\\test\\test",Uri_CREATE_FILE_USE_DOS_PATH,PARSE_URL_FROM_PATH,0,"file://c:\\test\\test",S_OK,FALSE},
6567     {"file:c:/test",0,PARSE_URL_FROM_PATH,0,"",S_OK,FALSE},
6568     {"http:google.com/",0,PARSE_URL_FROM_PATH,0,"",S_OK,FALSE},
6569
6570     /* PARSE_SCHEMA tests. */
6571     {"http://google.com/test",0,PARSE_SCHEMA,0,"http",S_OK,FALSE},
6572     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_SCHEMA,0,"",S_OK,FALSE},
6573
6574     /* PARSE_SITE tests. */
6575     {"http://google.uk.com/",0,PARSE_SITE,0,"google.uk.com",S_OK,FALSE},
6576     {"http://google.com.com/",0,PARSE_SITE,0,"google.com.com",S_OK,FALSE},
6577     {"google.com",Uri_CREATE_ALLOW_RELATIVE,PARSE_SITE,0,"",S_OK,FALSE},
6578     {"file://server/test",0,PARSE_SITE,0,"server",S_OK,FALSE},
6579
6580     /* PARSE_DOMAIN tests. */
6581     {"http://google.com.uk/",0,PARSE_DOMAIN,0,"google.com.uk",S_OK,FALSE},
6582     {"http://google.com.com/",0,PARSE_DOMAIN,0,"com.com",S_OK,FALSE},
6583     {"test/test",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOMAIN,0,"",S_OK,FALSE},
6584     {"file://server/test",0,PARSE_DOMAIN,0,"",S_OK,FALSE},
6585
6586     /* PARSE_LOCATION and PARSE_ANCHOR tests. */
6587     {"http://google.com/test#Test",0,PARSE_ANCHOR,0,"#Test",S_OK,FALSE},
6588     {"http://google.com/test#Test",0,PARSE_LOCATION,0,"#Test",S_OK,FALSE},
6589     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_ANCHOR,0,"",S_OK,FALSE},
6590     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_LOCATION,0,"",S_OK,FALSE}
6591 };
6592
6593 static inline LPWSTR a2w(LPCSTR str) {
6594     LPWSTR ret = NULL;
6595
6596     if(str) {
6597         DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
6598         ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
6599         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
6600     }
6601
6602     return ret;
6603 }
6604
6605 static inline BOOL heap_free(void* mem) {
6606     return HeapFree(GetProcessHeap(), 0, mem);
6607 }
6608
6609 static inline DWORD strcmp_aw(LPCSTR strA, LPCWSTR strB) {
6610     LPWSTR strAW = a2w(strA);
6611     DWORD ret = lstrcmpW(strAW, strB);
6612     heap_free(strAW);
6613     return ret;
6614 }
6615
6616 static inline ULONG get_refcnt(IUri *uri) {
6617     IUri_AddRef(uri);
6618     return IUri_Release(uri);
6619 }
6620
6621 static void change_property(IUriBuilder *builder, const uri_builder_property *prop,
6622                             DWORD test_index) {
6623     HRESULT hr;
6624     LPWSTR valueW;
6625
6626     valueW = a2w(prop->value);
6627     switch(prop->property) {
6628     case Uri_PROPERTY_FRAGMENT:
6629         hr = IUriBuilder_SetFragment(builder, valueW);
6630         if(prop->todo) {
6631             todo_wine {
6632                 ok(hr == prop->expected,
6633                     "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6634                     hr, prop->expected, test_index);
6635             }
6636         } else {
6637             ok(hr == prop->expected,
6638                 "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6639                 hr, prop->expected, test_index);
6640         }
6641         break;
6642     case Uri_PROPERTY_HOST:
6643         hr = IUriBuilder_SetHost(builder, valueW);
6644         if(prop->todo) {
6645             todo_wine {
6646                 ok(hr == prop->expected,
6647                     "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6648                     hr, prop->expected, test_index);
6649             }
6650         } else {
6651             ok(hr == prop->expected,
6652                 "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6653                 hr, prop->expected, test_index);
6654         }
6655         break;
6656     case Uri_PROPERTY_PASSWORD:
6657         hr = IUriBuilder_SetPassword(builder, valueW);
6658         if(prop->todo) {
6659             todo_wine {
6660                 ok(hr == prop->expected,
6661                     "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6662                     hr, prop->expected, test_index);
6663             }
6664         } else {
6665             ok(hr == prop->expected,
6666                 "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6667                 hr, prop->expected, test_index);
6668         }
6669         break;
6670     case Uri_PROPERTY_PATH:
6671         hr = IUriBuilder_SetPath(builder, valueW);
6672         if(prop->todo) {
6673             todo_wine {
6674                 ok(hr == prop->expected,
6675                     "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6676                     hr, prop->expected, test_index);
6677             }
6678         } else {
6679             ok(hr == prop->expected,
6680                 "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6681                 hr, prop->expected, test_index);
6682         }
6683         break;
6684     case Uri_PROPERTY_QUERY:
6685         hr = IUriBuilder_SetQuery(builder, valueW);
6686         if(prop->todo) {
6687             todo_wine {
6688                 ok(hr == prop->expected,
6689                     "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6690                     hr, prop->expected, test_index);
6691             }
6692         } else {
6693             ok(hr == prop->expected,
6694                 "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6695                 hr, prop->expected, test_index);
6696         }
6697         break;
6698     case Uri_PROPERTY_SCHEME_NAME:
6699         hr = IUriBuilder_SetSchemeName(builder, valueW);
6700         if(prop->todo) {
6701             todo_wine {
6702                 ok(hr == prop->expected,
6703                     "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6704                     hr, prop->expected, test_index);
6705             }
6706         } else {
6707             ok(hr == prop->expected,
6708                 "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6709                 hr, prop->expected, test_index);
6710         }
6711         break;
6712     case Uri_PROPERTY_USER_NAME:
6713         hr = IUriBuilder_SetUserName(builder, valueW);
6714         if(prop->todo) {
6715             todo_wine {
6716                 ok(hr == prop->expected,
6717                     "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6718                     hr, prop->expected, test_index);
6719             }
6720         } else {
6721             ok(hr == prop->expected,
6722                 "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6723                 hr, prop->expected, test_index);
6724         }
6725         break;
6726     default:
6727         trace("Unsupported operation for %d on uri_builder_tests[%d].\n", prop->property, test_index);
6728     }
6729
6730     heap_free(valueW);
6731 }
6732
6733 /*
6734  * Simple tests to make sure the CreateUri function handles invalid flag combinations
6735  * correctly.
6736  */
6737 static void test_CreateUri_InvalidFlags(void) {
6738     DWORD i;
6739
6740     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
6741         HRESULT hr;
6742         IUri *uri = (void*) 0xdeadbeef;
6743
6744         hr = pCreateUri(http_urlW, invalid_flag_tests[i].flags, 0, &uri);
6745         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUri returned 0x%08x, expected 0x%08x, flags=0x%08x\n",
6746                 hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
6747         ok(uri == NULL, "Error: expected the IUri to be NULL, but it was %p instead\n", uri);
6748     }
6749 }
6750
6751 static void test_CreateUri_InvalidArgs(void) {
6752     HRESULT hr;
6753     IUri *uri = (void*) 0xdeadbeef;
6754
6755     const WCHAR invalidW[] = {'i','n','v','a','l','i','d',0};
6756     static const WCHAR emptyW[] = {0};
6757
6758     hr = pCreateUri(http_urlW, 0, 0, NULL);
6759     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6760
6761     hr = pCreateUri(NULL, 0, 0, &uri);
6762     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6763     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6764
6765     uri = (void*) 0xdeadbeef;
6766     hr = pCreateUri(invalidW, 0, 0, &uri);
6767     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6768     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6769
6770     uri = (void*) 0xdeadbeef;
6771     hr = pCreateUri(emptyW, 0, 0, &uri);
6772     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6773     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6774 }
6775
6776 static void test_CreateUri_InvalidUri(void) {
6777     DWORD i;
6778
6779     for(i = 0; i < sizeof(invalid_uri_tests)/sizeof(invalid_uri_tests[0]); ++i) {
6780         invalid_uri test = invalid_uri_tests[i];
6781         IUri *uri = NULL;
6782         LPWSTR uriW;
6783         HRESULT hr;
6784
6785         uriW = a2w(test.uri);
6786         hr = pCreateUri(uriW, test.flags, 0, &uri);
6787         if(test.todo) {
6788             todo_wine {
6789                 ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6790                     hr, E_INVALIDARG, i);
6791             }
6792         } else {
6793             ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6794                 hr, E_INVALIDARG, i);
6795         }
6796         if(uri) IUri_Release(uri);
6797
6798         heap_free(uriW);
6799     }
6800 }
6801
6802 static void test_IUri_GetPropertyBSTR(void) {
6803     IUri *uri = NULL;
6804     HRESULT hr;
6805     DWORD i;
6806
6807     /* Make sure GetPropertyBSTR handles invalid args correctly. */
6808     hr = pCreateUri(http_urlW, 0, 0, &uri);
6809     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6810     if(SUCCEEDED(hr)) {
6811         BSTR received = NULL;
6812
6813         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_RAW_URI, NULL, 0);
6814         ok(hr == E_POINTER, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6815
6816         /* Make sure it handles a invalid Uri_PROPERTY's correctly. */
6817         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_PORT, &received, 0);
6818         ok(hr == S_OK, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6819         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6820         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6821         SysFreeString(received);
6822
6823         /* Make sure it handles the ZONE property correctly. */
6824         received = NULL;
6825         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_ZONE, &received, 0);
6826         ok(hr == S_FALSE, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_FALSE);
6827         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6828         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6829         SysFreeString(received);
6830     }
6831     if(uri) IUri_Release(uri);
6832
6833     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6834         uri_properties test = uri_tests[i];
6835         LPWSTR uriW;
6836         uri = NULL;
6837
6838         uriW = a2w(test.uri);
6839         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6840         if(test.create_todo) {
6841             todo_wine {
6842                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6843                         hr, test.create_expected, i);
6844             }
6845         } else {
6846             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6847                     hr, test.create_expected, i);
6848         }
6849
6850         if(SUCCEEDED(hr)) {
6851             DWORD j;
6852
6853             /* Checks all the string properties of the uri. */
6854             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
6855                 BSTR received = NULL;
6856                 uri_str_property prop = test.str_props[j];
6857
6858                 hr = IUri_GetPropertyBSTR(uri, j, &received, 0);
6859                 if(prop.todo) {
6860                     todo_wine {
6861                         ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6862                                 hr, prop.expected, i, j);
6863                     }
6864                     todo_wine {
6865                         ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6866                                 "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6867                                 prop.value, wine_dbgstr_w(received), i, j);
6868                     }
6869                 } else {
6870                     ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6871                             hr, prop.expected, i, j);
6872                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6873                             "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6874                             prop.value, wine_dbgstr_w(received), i, j);
6875                 }
6876
6877                 SysFreeString(received);
6878             }
6879         }
6880
6881         if(uri) IUri_Release(uri);
6882
6883         heap_free(uriW);
6884     }
6885 }
6886
6887 static void test_IUri_GetPropertyDWORD(void) {
6888     IUri *uri = NULL;
6889     HRESULT hr;
6890     DWORD i;
6891
6892     hr = pCreateUri(http_urlW, 0, 0, &uri);
6893     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6894     if(SUCCEEDED(hr)) {
6895         DWORD received = 0xdeadbeef;
6896
6897         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_DWORD_START, NULL, 0);
6898         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6899
6900         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_ABSOLUTE_URI, &received, 0);
6901         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6902         ok(received == 0, "Error: Expected received=%d but instead received=%d.\n", 0, received);
6903     }
6904     if(uri) IUri_Release(uri);
6905
6906     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6907         uri_properties test = uri_tests[i];
6908         LPWSTR uriW;
6909         uri = NULL;
6910
6911         uriW = a2w(test.uri);
6912         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6913         if(test.create_todo) {
6914             todo_wine {
6915                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6916                         hr, test.create_expected, i);
6917             }
6918         } else {
6919             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6920                     hr, test.create_expected, i);
6921         }
6922
6923         if(SUCCEEDED(hr)) {
6924             DWORD j;
6925
6926             /* Checks all the DWORD properties of the uri. */
6927             for(j = 0; j < sizeof(test.dword_props)/sizeof(test.dword_props[0]); ++j) {
6928                 DWORD received;
6929                 uri_dword_property prop = test.dword_props[j];
6930
6931                 hr = IUri_GetPropertyDWORD(uri, j+Uri_PROPERTY_DWORD_START, &received, 0);
6932                 if(prop.todo) {
6933                     todo_wine {
6934                         ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
6935                                 hr, prop.expected, i, j);
6936                     }
6937                     todo_wine {
6938                         ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
6939                                 prop.value, received, i, j);
6940                     }
6941                 } else {
6942                     ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
6943                             hr, prop.expected, i, j);
6944                     ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
6945                             prop.value, received, i, j);
6946                 }
6947             }
6948         }
6949
6950         if(uri) IUri_Release(uri);
6951
6952         heap_free(uriW);
6953     }
6954 }
6955
6956 /* Tests all the 'Get*' property functions which deal with strings. */
6957 static void test_IUri_GetStrProperties(void) {
6958     IUri *uri = NULL;
6959     HRESULT hr;
6960     DWORD i;
6961
6962     /* Make sure all the 'Get*' string property functions handle invalid args correctly. */
6963     hr = pCreateUri(http_urlW, 0, 0, &uri);
6964     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6965     if(SUCCEEDED(hr)) {
6966         hr = IUri_GetAbsoluteUri(uri, NULL);
6967         ok(hr == E_POINTER, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6968
6969         hr = IUri_GetAuthority(uri, NULL);
6970         ok(hr == E_POINTER, "Error: GetAuthority returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6971
6972         hr = IUri_GetDisplayUri(uri, NULL);
6973         ok(hr == E_POINTER, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6974
6975         hr = IUri_GetDomain(uri, NULL);
6976         ok(hr == E_POINTER, "Error: GetDomain returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6977
6978         hr = IUri_GetExtension(uri, NULL);
6979         ok(hr == E_POINTER, "Error: GetExtension returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6980
6981         hr = IUri_GetFragment(uri, NULL);
6982         ok(hr == E_POINTER, "Error: GetFragment returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6983
6984         hr = IUri_GetHost(uri, NULL);
6985         ok(hr == E_POINTER, "Error: GetHost returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6986
6987         hr = IUri_GetPassword(uri, NULL);
6988         ok(hr == E_POINTER, "Error: GetPassword returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6989
6990         hr = IUri_GetPath(uri, NULL);
6991         ok(hr == E_POINTER, "Error: GetPath returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6992
6993         hr = IUri_GetPathAndQuery(uri, NULL);
6994         ok(hr == E_POINTER, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6995
6996         hr = IUri_GetQuery(uri, NULL);
6997         ok(hr == E_POINTER, "Error: GetQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6998
6999         hr = IUri_GetRawUri(uri, NULL);
7000         ok(hr == E_POINTER, "Error: GetRawUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7001
7002         hr = IUri_GetSchemeName(uri, NULL);
7003         ok(hr == E_POINTER, "Error: GetSchemeName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7004
7005         hr = IUri_GetUserInfo(uri, NULL);
7006         ok(hr == E_POINTER, "Error: GetUserInfo returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7007
7008         hr = IUri_GetUserName(uri, NULL);
7009         ok(hr == E_POINTER, "Error: GetUserName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7010     }
7011     if(uri) IUri_Release(uri);
7012
7013     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7014         uri_properties test = uri_tests[i];
7015         LPWSTR uriW;
7016         uri = NULL;
7017
7018         uriW = a2w(test.uri);
7019         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7020         if(test.create_todo) {
7021             todo_wine {
7022                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7023                         hr, test.create_expected, i);
7024             }
7025         } else {
7026             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7027                     hr, test.create_expected, i);
7028         }
7029
7030         if(SUCCEEDED(hr)) {
7031             uri_str_property prop;
7032             BSTR received = NULL;
7033
7034             /* GetAbsoluteUri() tests. */
7035             prop = test.str_props[Uri_PROPERTY_ABSOLUTE_URI];
7036             hr = IUri_GetAbsoluteUri(uri, &received);
7037             if(prop.todo) {
7038                 todo_wine {
7039                     ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7040                             hr, prop.expected, i);
7041                 }
7042                 todo_wine {
7043                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
7044                             "Error: Expected %s but got %s on uri_tests[%d].\n",
7045                             prop.value, wine_dbgstr_w(received), i);
7046                 }
7047             } else {
7048                 ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7049                         hr, prop.expected, i);
7050                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
7051                         "Error: Expected %s but got %s on uri_tests[%d].\n",
7052                         prop.value, wine_dbgstr_w(received), i);
7053             }
7054             SysFreeString(received);
7055             received = NULL;
7056
7057             /* GetAuthority() tests. */
7058             prop = test.str_props[Uri_PROPERTY_AUTHORITY];
7059             hr = IUri_GetAuthority(uri, &received);
7060             if(prop.todo) {
7061                 todo_wine {
7062                     ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7063                             hr, prop.expected, i);
7064                 }
7065                 todo_wine {
7066                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7067                             prop.value, wine_dbgstr_w(received), i);
7068                 }
7069             } else {
7070                 ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7071                         hr, prop.expected, i);
7072                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7073                         prop.value, wine_dbgstr_w(received), i);
7074             }
7075             SysFreeString(received);
7076             received = NULL;
7077
7078             /* GetDisplayUri() tests. */
7079             prop = test.str_props[Uri_PROPERTY_DISPLAY_URI];
7080             hr = IUri_GetDisplayUri(uri, &received);
7081             if(prop.todo) {
7082                 todo_wine {
7083                     ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7084                             hr, prop.expected, i);
7085                 }
7086                 todo_wine {
7087                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
7088                             "Error: Expected %s but got %s on uri_test[%d].\n",
7089                             prop.value, wine_dbgstr_w(received), i);
7090                 }
7091             } else {
7092                 ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7093                         hr, prop.expected, i);
7094                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
7095                         "Error: Expected %s but got %s on uri_tests[%d].\n",
7096                         prop.value, wine_dbgstr_w(received), i);
7097             }
7098             SysFreeString(received);
7099             received = NULL;
7100
7101             /* GetDomain() tests. */
7102             prop = test.str_props[Uri_PROPERTY_DOMAIN];
7103             hr = IUri_GetDomain(uri, &received);
7104             if(prop.todo) {
7105                 todo_wine {
7106                     ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7107                             hr, prop.expected, i);
7108                 }
7109                 todo_wine {
7110                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7111                             prop.value, wine_dbgstr_w(received), i);
7112                 }
7113             } else {
7114                 ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7115                         hr, prop.expected, i);
7116                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7117                         prop.value, wine_dbgstr_w(received), i);
7118             }
7119             SysFreeString(received);
7120             received = NULL;
7121
7122             /* GetExtension() tests. */
7123             prop = test.str_props[Uri_PROPERTY_EXTENSION];
7124             hr = IUri_GetExtension(uri, &received);
7125             if(prop.todo) {
7126                 todo_wine {
7127                     ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7128                             hr, prop.expected, i);
7129                 }
7130                 todo_wine {
7131                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7132                             prop.value, wine_dbgstr_w(received), i);
7133                 }
7134             } else {
7135                 ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7136                         hr, prop.expected, i);
7137                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7138                         prop.value, wine_dbgstr_w(received), i);
7139             }
7140             SysFreeString(received);
7141             received = NULL;
7142
7143             /* GetFragment() tests. */
7144             prop = test.str_props[Uri_PROPERTY_FRAGMENT];
7145             hr = IUri_GetFragment(uri, &received);
7146             if(prop.todo) {
7147                 todo_wine {
7148                     ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7149                             hr, prop.expected, i);
7150                 }
7151                 todo_wine {
7152                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7153                             prop.value, wine_dbgstr_w(received), i);
7154                 }
7155             } else {
7156                 ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7157                         hr, prop.expected, i);
7158                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7159                         prop.value, wine_dbgstr_w(received), i);
7160             }
7161             SysFreeString(received);
7162             received = NULL;
7163
7164             /* GetHost() tests. */
7165             prop = test.str_props[Uri_PROPERTY_HOST];
7166             hr = IUri_GetHost(uri, &received);
7167             if(prop.todo) {
7168                 todo_wine {
7169                     ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7170                             hr, prop.expected, i);
7171                 }
7172                 todo_wine {
7173                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7174                             prop.value, wine_dbgstr_w(received), i);
7175                 }
7176             } else {
7177                 ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7178                         hr, prop.expected, i);
7179                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7180                         prop.value, wine_dbgstr_w(received), i);
7181             }
7182             SysFreeString(received);
7183             received = NULL;
7184
7185             /* GetPassword() tests. */
7186             prop = test.str_props[Uri_PROPERTY_PASSWORD];
7187             hr = IUri_GetPassword(uri, &received);
7188             if(prop.todo) {
7189                 todo_wine {
7190                     ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7191                             hr, prop.expected, i);
7192                 }
7193                 todo_wine {
7194                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7195                             prop.value, wine_dbgstr_w(received), i);
7196                 }
7197             } else {
7198                 ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7199                         hr, prop.expected, i);
7200                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7201                         prop.value, wine_dbgstr_w(received), i);
7202             }
7203             SysFreeString(received);
7204             received = NULL;
7205
7206             /* GetPath() tests. */
7207             prop = test.str_props[Uri_PROPERTY_PATH];
7208             hr = IUri_GetPath(uri, &received);
7209             if(prop.todo) {
7210                 todo_wine {
7211                     ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7212                             hr, prop.expected, i);
7213                 }
7214                 todo_wine {
7215                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7216                             prop.value, wine_dbgstr_w(received), i);
7217                 }
7218             } else {
7219                 ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7220                         hr, prop.expected, i);
7221                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7222                         prop.value, wine_dbgstr_w(received), i);
7223             }
7224             SysFreeString(received);
7225             received = NULL;
7226
7227             /* GetPathAndQuery() tests. */
7228             prop = test.str_props[Uri_PROPERTY_PATH_AND_QUERY];
7229             hr = IUri_GetPathAndQuery(uri, &received);
7230             if(prop.todo) {
7231                 todo_wine {
7232                     ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7233                             hr, prop.expected, i);
7234                 }
7235                 todo_wine {
7236                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7237                             prop.value, wine_dbgstr_w(received), i);
7238                 }
7239             } else {
7240                 ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7241                         hr, prop.expected, i);
7242                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7243                         prop.value, wine_dbgstr_w(received), i);
7244             }
7245             SysFreeString(received);
7246             received = NULL;
7247
7248             /* GetQuery() tests. */
7249             prop = test.str_props[Uri_PROPERTY_QUERY];
7250             hr = IUri_GetQuery(uri, &received);
7251             if(prop.todo) {
7252                 todo_wine {
7253                     ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7254                             hr, prop.expected, i);
7255                 }
7256                 todo_wine {
7257                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7258                             prop.value, wine_dbgstr_w(received), i);
7259                 }
7260             } else {
7261                 ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7262                         hr, prop.expected, i);
7263                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7264                         prop.value, wine_dbgstr_w(received), i);
7265             }
7266             SysFreeString(received);
7267             received = NULL;
7268
7269             /* GetRawUri() tests. */
7270             prop = test.str_props[Uri_PROPERTY_RAW_URI];
7271             hr = IUri_GetRawUri(uri, &received);
7272             if(prop.todo) {
7273                 todo_wine {
7274                     ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7275                             hr, prop.expected, i);
7276                 }
7277                 todo_wine {
7278                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7279                             prop.value, wine_dbgstr_w(received), i);
7280                 }
7281             } else {
7282                 ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7283                         hr, prop.expected, i);
7284                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7285                         prop.value, wine_dbgstr_w(received), i);
7286             }
7287             SysFreeString(received);
7288             received = NULL;
7289
7290             /* GetSchemeName() tests. */
7291             prop = test.str_props[Uri_PROPERTY_SCHEME_NAME];
7292             hr = IUri_GetSchemeName(uri, &received);
7293             if(prop.todo) {
7294                 todo_wine {
7295                     ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7296                             hr, prop.expected, i);
7297                 }
7298                 todo_wine {
7299                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7300                             prop.value, wine_dbgstr_w(received), i);
7301                 }
7302             } else {
7303                 ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7304                         hr, prop.expected, i);
7305                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7306                         prop.value, wine_dbgstr_w(received), i);
7307             }
7308             SysFreeString(received);
7309             received = NULL;
7310
7311             /* GetUserInfo() tests. */
7312             prop = test.str_props[Uri_PROPERTY_USER_INFO];
7313             hr = IUri_GetUserInfo(uri, &received);
7314             if(prop.todo) {
7315                 todo_wine {
7316                     ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7317                             hr, prop.expected, i);
7318                 }
7319                 todo_wine {
7320                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7321                             prop.value, wine_dbgstr_w(received), i);
7322                 }
7323             } else {
7324                 ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7325                         hr, prop.expected, i);
7326                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7327                         prop.value, wine_dbgstr_w(received), i);
7328             }
7329             SysFreeString(received);
7330             received = NULL;
7331
7332             /* GetUserName() tests. */
7333             prop = test.str_props[Uri_PROPERTY_USER_NAME];
7334             hr = IUri_GetUserName(uri, &received);
7335             if(prop.todo) {
7336                 todo_wine {
7337                     ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7338                             hr, prop.expected, i);
7339                 }
7340                 todo_wine {
7341                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7342                             prop.value, wine_dbgstr_w(received), i);
7343                 }
7344             } else {
7345                 ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7346                         hr, prop.expected, i);
7347                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7348                         prop.value, wine_dbgstr_w(received), i);
7349             }
7350             SysFreeString(received);
7351         }
7352
7353         if(uri) IUri_Release(uri);
7354
7355         heap_free(uriW);
7356     }
7357 }
7358
7359 static void test_IUri_GetDwordProperties(void) {
7360     IUri *uri = NULL;
7361     HRESULT hr;
7362     DWORD i;
7363
7364     /* Make sure all the 'Get*' dword property functions handle invalid args correctly. */
7365     hr = pCreateUri(http_urlW, 0, 0, &uri);
7366     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7367     if(SUCCEEDED(hr)) {
7368         hr = IUri_GetHostType(uri, NULL);
7369         ok(hr == E_INVALIDARG, "Error: GetHostType returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7370
7371         hr = IUri_GetPort(uri, NULL);
7372         ok(hr == E_INVALIDARG, "Error: GetPort returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7373
7374         hr = IUri_GetScheme(uri, NULL);
7375         ok(hr == E_INVALIDARG, "Error: GetScheme returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7376
7377         hr = IUri_GetZone(uri, NULL);
7378         ok(hr == E_INVALIDARG, "Error: GetZone returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7379     }
7380     if(uri) IUri_Release(uri);
7381
7382     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7383         uri_properties test = uri_tests[i];
7384         LPWSTR uriW;
7385         uri = NULL;
7386
7387         uriW = a2w(test.uri);
7388         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7389         if(test.create_todo) {
7390             todo_wine {
7391                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7392                         hr, test.create_expected, i);
7393             }
7394         } else {
7395             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7396                     hr, test.create_expected, i);
7397         }
7398
7399         if(SUCCEEDED(hr)) {
7400             uri_dword_property prop;
7401             DWORD received;
7402
7403             /* Assign an insane value so tests don't accidentally pass when
7404              * they shouldn't!
7405              */
7406             received = -9999999;
7407
7408             /* GetHostType() tests. */
7409             prop = test.dword_props[Uri_PROPERTY_HOST_TYPE-Uri_PROPERTY_DWORD_START];
7410             hr = IUri_GetHostType(uri, &received);
7411             if(prop.todo) {
7412                 todo_wine {
7413                     ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7414                             hr, prop.expected, i);
7415                 }
7416                 todo_wine {
7417                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7418                 }
7419             } else {
7420                 ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7421                         hr, prop.expected, i);
7422                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7423             }
7424             received = -9999999;
7425
7426             /* GetPort() tests. */
7427             prop = test.dword_props[Uri_PROPERTY_PORT-Uri_PROPERTY_DWORD_START];
7428             hr = IUri_GetPort(uri, &received);
7429             if(prop.todo) {
7430                 todo_wine {
7431                     ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7432                             hr, prop.expected, i);
7433                 }
7434                 todo_wine {
7435                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7436                 }
7437             } else {
7438                 ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7439                         hr, prop.expected, i);
7440                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7441             }
7442             received = -9999999;
7443
7444             /* GetScheme() tests. */
7445             prop = test.dword_props[Uri_PROPERTY_SCHEME-Uri_PROPERTY_DWORD_START];
7446             hr = IUri_GetScheme(uri, &received);
7447             if(prop.todo) {
7448                 todo_wine {
7449                     ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7450                             hr, prop.expected, i);
7451                 }
7452                 todo_wine {
7453                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7454                 }
7455             } else {
7456                 ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7457                         hr, prop.expected, i);
7458                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7459             }
7460             received = -9999999;
7461
7462             /* GetZone() tests. */
7463             prop = test.dword_props[Uri_PROPERTY_ZONE-Uri_PROPERTY_DWORD_START];
7464             hr = IUri_GetZone(uri, &received);
7465             if(prop.todo) {
7466                 todo_wine {
7467                     ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7468                             hr, prop.expected, i);
7469                 }
7470                 todo_wine {
7471                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7472                 }
7473             } else {
7474                 ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7475                         hr, prop.expected, i);
7476                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7477             }
7478         }
7479
7480         if(uri) IUri_Release(uri);
7481
7482         heap_free(uriW);
7483     }
7484 }
7485
7486 static void test_IUri_GetPropertyLength(void) {
7487     IUri *uri = NULL;
7488     HRESULT hr;
7489     DWORD i;
7490
7491     /* Make sure it handles invalid args correctly. */
7492     hr = pCreateUri(http_urlW, 0, 0, &uri);
7493     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7494     if(SUCCEEDED(hr)) {
7495         DWORD received = 0xdeadbeef;
7496
7497         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_STRING_START, NULL, 0);
7498         ok(hr == E_INVALIDARG, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7499
7500         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_DWORD_START, &received, 0);
7501         ok(hr == E_INVALIDARG, "Error: GetPropertyLength return 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7502         ok(received == 0xdeadbeef, "Error: Expected 0xdeadbeef but got 0x%08x.\n", received);
7503     }
7504     if(uri) IUri_Release(uri);
7505
7506     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7507         uri_properties test = uri_tests[i];
7508         LPWSTR uriW;
7509         uri = NULL;
7510
7511         uriW = a2w(test.uri);
7512         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7513         if(test.create_todo) {
7514             todo_wine {
7515                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7516                         hr, test.create_expected, i);
7517             }
7518         } else {
7519             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_test[%d].\n",
7520                     hr, test.create_expected, i);
7521         }
7522
7523         if(SUCCEEDED(hr)) {
7524             DWORD j;
7525
7526             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
7527                 DWORD expectedLen, brokenLen, receivedLen;
7528                 uri_str_property prop = test.str_props[j];
7529
7530                 expectedLen = lstrlen(prop.value);
7531                 brokenLen = lstrlen(prop.broken_value);
7532
7533                 /* This won't be necessary once GetPropertyLength is implemented. */
7534                 receivedLen = -1;
7535
7536                 hr = IUri_GetPropertyLength(uri, j, &receivedLen, 0);
7537                 if(prop.todo) {
7538                     todo_wine {
7539                         ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
7540                                 hr, prop.expected, i, j);
7541                     }
7542                     todo_wine {
7543                         ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
7544                                 "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
7545                                 expectedLen, receivedLen, i, j);
7546                     }
7547                 } else {
7548                     ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
7549                             hr, prop.expected, i, j);
7550                     ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
7551                             "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
7552                             expectedLen, receivedLen, i, j);
7553                 }
7554             }
7555         }
7556
7557         if(uri) IUri_Release(uri);
7558
7559         heap_free(uriW);
7560     }
7561 }
7562
7563 static DWORD compute_expected_props(uri_properties *test)
7564 {
7565     DWORD ret = 0, i;
7566
7567     for(i=Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_STRING_LAST; i++) {
7568         if(test->str_props[i-Uri_PROPERTY_STRING_START].expected == S_OK)
7569             ret |= 1<<i;
7570     }
7571
7572     for(i=Uri_PROPERTY_DWORD_START; i <= Uri_PROPERTY_DWORD_LAST; i++) {
7573         if(test->dword_props[i-Uri_PROPERTY_DWORD_START].expected == S_OK)
7574             ret |= 1<<i;
7575     }
7576
7577     return ret;
7578 }
7579
7580 static void test_IUri_GetProperties(void) {
7581     IUri *uri = NULL;
7582     HRESULT hr;
7583     DWORD i;
7584
7585     hr = pCreateUri(http_urlW, 0, 0, &uri);
7586     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7587     if(SUCCEEDED(hr)) {
7588         hr = IUri_GetProperties(uri, NULL);
7589         ok(hr == E_INVALIDARG, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7590     }
7591     if(uri) IUri_Release(uri);
7592
7593     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7594         uri_properties test = uri_tests[i];
7595         LPWSTR uriW;
7596         uri = NULL;
7597
7598         uriW = a2w(test.uri);
7599         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7600         if(test.create_todo) {
7601             todo_wine {
7602                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7603             }
7604         } else {
7605             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7606         }
7607
7608         if(SUCCEEDED(hr)) {
7609             DWORD received = 0, expected_props;
7610             DWORD j;
7611
7612             hr = IUri_GetProperties(uri, &received);
7613             ok(hr == S_OK, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7614
7615             expected_props = compute_expected_props(&test);
7616
7617             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
7618                 /* (1 << j) converts a Uri_PROPERTY to its corresponding Uri_HAS_* flag mask. */
7619                 if(expected_props & (1 << j))
7620                     ok(received & (1 << j), "Error: Expected flag for property %d on uri_tests[%d].\n", j, i);
7621                 else
7622                     ok(!(received & (1 << j)), "Error: Received flag for property %d when not expected on uri_tests[%d].\n", j, i);
7623             }
7624         }
7625
7626         if(uri) IUri_Release(uri);
7627
7628         heap_free(uriW);
7629     }
7630 }
7631
7632 static void test_IUri_HasProperty(void) {
7633     IUri *uri = NULL;
7634     HRESULT hr;
7635     DWORD i;
7636
7637     hr = pCreateUri(http_urlW, 0, 0, &uri);
7638     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7639     if(SUCCEEDED(hr)) {
7640         hr = IUri_HasProperty(uri, Uri_PROPERTY_RAW_URI, NULL);
7641         ok(hr == E_INVALIDARG, "Error: HasProperty returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7642     }
7643     if(uri) IUri_Release(uri);
7644
7645     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7646         uri_properties test = uri_tests[i];
7647         LPWSTR uriW;
7648         uri = NULL;
7649
7650         uriW = a2w(test.uri);
7651
7652         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7653         if(test.create_todo) {
7654             todo_wine {
7655                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7656             }
7657         } else {
7658             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7659         }
7660
7661         if(SUCCEEDED(hr)) {
7662             DWORD expected_props, j;
7663
7664             expected_props = compute_expected_props(&test);
7665
7666             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
7667                 /* Assign -1, then explicitly test for TRUE or FALSE later. */
7668                 BOOL received = -1;
7669
7670                 hr = IUri_HasProperty(uri, j, &received);
7671                 ok(hr == S_OK, "Error: HasProperty returned 0x%08x, expected 0x%08x for property %d on uri_tests[%d].\n",
7672                         hr, S_OK, j, i);
7673
7674                 if(expected_props & (1 << j)) {
7675                     ok(received == TRUE, "Error: Expected to have property %d on uri_tests[%d].\n", j, i);
7676                 } else {
7677                     ok(received == FALSE, "Error: Wasn't expecting to have property %d on uri_tests[%d].\n", j, i);
7678                 }
7679             }
7680         }
7681
7682         if(uri) IUri_Release(uri);
7683
7684         heap_free(uriW);
7685     }
7686 }
7687
7688 static void test_IUri_IsEqual(void) {
7689     IUri *uriA, *uriB;
7690     BOOL equal;
7691     HRESULT hres;
7692     DWORD i;
7693
7694     uriA = uriB = NULL;
7695
7696     /* Make sure IsEqual handles invalid args correctly. */
7697     hres = pCreateUri(http_urlW, 0, 0, &uriA);
7698     ok(hres == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hres, S_OK);
7699     hres = pCreateUri(http_urlW, 0, 0, &uriB);
7700     ok(hres == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hres, S_OK);
7701
7702     equal = -1;
7703     hres = IUri_IsEqual(uriA, NULL, &equal);
7704     ok(hres == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hres, S_OK);
7705     ok(!equal, "Error: Expected equal to be FALSE, but was %d instead.\n", equal);
7706
7707     hres = IUri_IsEqual(uriA, uriB, NULL);
7708     ok(hres == E_POINTER, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hres, E_POINTER);
7709
7710     IUri_Release(uriA);
7711     IUri_Release(uriB);
7712
7713     for(i = 0; i < sizeof(equality_tests)/sizeof(equality_tests[0]); ++i) {
7714         uri_equality test = equality_tests[i];
7715         LPWSTR uriA_W, uriB_W;
7716
7717         uriA = uriB = NULL;
7718
7719         uriA_W = a2w(test.a);
7720         uriB_W = a2w(test.b);
7721
7722         hres = pCreateUri(uriA_W, test.create_flags_a, 0, &uriA);
7723         ok(hres == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n", hres, S_OK, i);
7724
7725         hres = pCreateUri(uriB_W, test.create_flags_b, 0, &uriB);
7726         ok(hres == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n", hres, S_OK, i);
7727
7728         equal = -1;
7729         hres = IUri_IsEqual(uriA, uriB, &equal);
7730         if(test.todo) todo_wine {
7731             ok(hres == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n", hres, S_OK, i);
7732             ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7733         } else {
7734             ok(hres == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n", hres, S_OK, i);
7735             ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7736         }
7737         if(uriA) IUri_Release(uriA);
7738         if(uriB) IUri_Release(uriB);
7739
7740         heap_free(uriA_W);
7741         heap_free(uriB_W);
7742     }
7743 }
7744
7745 static void test_CreateUriWithFragment_InvalidArgs(void) {
7746     HRESULT hr;
7747     IUri *uri = (void*) 0xdeadbeef;
7748     const WCHAR fragmentW[] = {'#','f','r','a','g','m','e','n','t',0};
7749
7750     hr = pCreateUriWithFragment(NULL, fragmentW, 0, 0, &uri);
7751     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7752     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7753
7754     hr = pCreateUriWithFragment(http_urlW, fragmentW, 0, 0, NULL);
7755     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7756
7757     /* Original URI can't already contain a fragment component. */
7758     uri = (void*) 0xdeadbeef;
7759     hr = pCreateUriWithFragment(http_url_fragW, fragmentW, 0, 0, &uri);
7760     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7761     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7762 }
7763
7764 /* CreateUriWithFragment has the same invalid flag combinations as CreateUri. */
7765 static void test_CreateUriWithFragment_InvalidFlags(void) {
7766     DWORD i;
7767
7768     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
7769         HRESULT hr;
7770         IUri *uri = (void*) 0xdeadbeef;
7771
7772         hr = pCreateUriWithFragment(http_urlW, NULL, invalid_flag_tests[i].flags, 0, &uri);
7773         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x. flags=0x%08x.\n",
7774             hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
7775         ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7776     }
7777 }
7778
7779 static void test_CreateUriWithFragment(void) {
7780     DWORD i;
7781
7782     for(i = 0; i < sizeof(uri_fragment_tests)/sizeof(uri_fragment_tests[0]); ++i) {
7783         HRESULT hr;
7784         IUri *uri = NULL;
7785         LPWSTR uriW, fragW;
7786         uri_with_fragment test = uri_fragment_tests[i];
7787
7788         uriW = a2w(test.uri);
7789         fragW = a2w(test.fragment);
7790
7791         hr = pCreateUriWithFragment(uriW, fragW, test.create_flags, 0, &uri);
7792         if(test.expected_todo) {
7793             todo_wine {
7794                 ok(hr == test.create_expected,
7795                     "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7796                     hr, test.create_expected, i);
7797             }
7798         } else
7799             ok(hr == test.create_expected,
7800                 "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7801                 hr, test.create_expected, i);
7802
7803         if(SUCCEEDED(hr)) {
7804             BSTR received = NULL;
7805
7806             hr = IUri_GetAbsoluteUri(uri, &received);
7807             if(test.expected_todo) {
7808                 todo_wine {
7809                     ok(hr == S_OK,
7810                         "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7811                         hr, S_OK, i);
7812                 }
7813                 todo_wine {
7814                     ok(!strcmp_aw(test.expected_uri, received),
7815                         "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7816                         test.expected_uri, wine_dbgstr_w(received), i);
7817                 }
7818             } else {
7819                 ok(hr == S_OK, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7820                     hr, S_OK, i);
7821                 ok(!strcmp_aw(test.expected_uri, received), "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7822                     test.expected_uri, wine_dbgstr_w(received), i);
7823             }
7824
7825             SysFreeString(received);
7826         }
7827
7828         if(uri) IUri_Release(uri);
7829         heap_free(uriW);
7830         heap_free(fragW);
7831     }
7832 }
7833
7834 static void test_CreateIUriBuilder(void) {
7835     HRESULT hr;
7836     IUriBuilder *builder = NULL;
7837     IUri *uri;
7838
7839     hr = pCreateIUriBuilder(NULL, 0, 0, NULL);
7840     ok(hr == E_POINTER, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x\n",
7841         hr, E_POINTER);
7842
7843     /* CreateIUriBuilder increases the ref count of the IUri it receives. */
7844     hr = pCreateUri(http_urlW, 0, 0, &uri);
7845     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7846     if(SUCCEEDED(hr)) {
7847         ULONG cur_count, orig_count;
7848
7849         orig_count = get_refcnt(uri);
7850         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
7851         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7852         ok(builder != NULL, "Error: Expecting builder not to be NULL\n");
7853
7854         cur_count = get_refcnt(uri);
7855         ok(cur_count == orig_count+1, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count+1, cur_count);
7856
7857         if(builder) IUriBuilder_Release(builder);
7858         cur_count = get_refcnt(uri);
7859         ok(cur_count == orig_count, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count, cur_count);
7860     }
7861     if(uri) IUri_Release(uri);
7862 }
7863
7864 static void test_IUriBuilder_CreateUri(IUriBuilder *builder, const uri_builder_test *test,
7865                                        DWORD test_index) {
7866     HRESULT hr;
7867     IUri *uri = NULL;
7868
7869     hr = IUriBuilder_CreateUri(builder, test->uri_flags, 0, 0, &uri);
7870     if(test->uri_todo) {
7871         todo_wine {
7872             ok(hr == test->uri_hres,
7873                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7874                 hr, test->uri_hres, test_index);
7875         }
7876     } else {
7877         ok(hr == test->uri_hres,
7878             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7879             hr, test->uri_hres, test_index);
7880     }
7881
7882     if(SUCCEEDED(hr)) {
7883         DWORD i;
7884
7885         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7886             uri_builder_str_property prop = test->expected_str_props[i];
7887             BSTR received = NULL;
7888
7889             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7890             if(prop.todo) {
7891                 todo_wine {
7892                     ok(hr == prop.result,
7893                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7894                         hr, prop.result, test_index, i);
7895                 }
7896             } else {
7897                 ok(hr == prop.result,
7898                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7899                     hr, prop.result, test_index, i);
7900             }
7901             if(SUCCEEDED(hr)) {
7902                 if(prop.todo) {
7903                     todo_wine {
7904                         ok(!strcmp_aw(prop.expected, received),
7905                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7906                             prop.expected, wine_dbgstr_w(received), test_index, i);
7907                     }
7908                 } else {
7909                     ok(!strcmp_aw(prop.expected, received),
7910                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7911                         prop.expected, wine_dbgstr_w(received), test_index, i);
7912                 }
7913             }
7914             SysFreeString(received);
7915         }
7916
7917         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7918             uri_builder_dword_property prop = test->expected_dword_props[i];
7919             DWORD received = -2;
7920
7921             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7922             if(prop.todo) {
7923                 todo_wine {
7924                     ok(hr == prop.result,
7925                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7926                         hr, prop.result, test_index, i);
7927                 }
7928             } else {
7929                 ok(hr == prop.result,
7930                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7931                     hr, prop.result, test_index, i);
7932             }
7933             if(SUCCEEDED(hr)) {
7934                 if(prop.todo) {
7935                     todo_wine {
7936                         ok(received == prop.expected,
7937                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7938                             prop.expected, received, test_index, i);
7939                     }
7940                 } else {
7941                     ok(received == prop.expected,
7942                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7943                         prop.expected, received, test_index, i);
7944                 }
7945             }
7946         }
7947     }
7948     if(uri) IUri_Release(uri);
7949 }
7950
7951 static void test_IUriBuilder_CreateUriSimple(IUriBuilder *builder, const uri_builder_test *test,
7952                                        DWORD test_index) {
7953     HRESULT hr;
7954     IUri *uri = NULL;
7955
7956     hr = IUriBuilder_CreateUriSimple(builder, test->uri_simple_encode_flags, 0, &uri);
7957     if(test->uri_simple_todo) {
7958         todo_wine {
7959             ok(hr == test->uri_simple_hres,
7960                 "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7961                 hr, test->uri_simple_hres, test_index);
7962         }
7963     } else {
7964         ok(hr == test->uri_simple_hres,
7965             "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7966             hr, test->uri_simple_hres, test_index);
7967     }
7968
7969     if(SUCCEEDED(hr)) {
7970         DWORD i;
7971
7972         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7973             uri_builder_str_property prop = test->expected_str_props[i];
7974             BSTR received = NULL;
7975
7976             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7977             if(prop.todo) {
7978                 todo_wine {
7979                     ok(hr == prop.result,
7980                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7981                         hr, prop.result, test_index, i);
7982                 }
7983             } else {
7984                 ok(hr == prop.result,
7985                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7986                     hr, prop.result, test_index, i);
7987             }
7988             if(SUCCEEDED(hr)) {
7989                 if(prop.todo) {
7990                     todo_wine {
7991                         ok(!strcmp_aw(prop.expected, received),
7992                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7993                             prop.expected, wine_dbgstr_w(received), test_index, i);
7994                     }
7995                 } else {
7996                     ok(!strcmp_aw(prop.expected, received),
7997                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7998                         prop.expected, wine_dbgstr_w(received), test_index, i);
7999                 }
8000             }
8001             SysFreeString(received);
8002         }
8003
8004         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
8005             uri_builder_dword_property prop = test->expected_dword_props[i];
8006             DWORD received = -2;
8007
8008             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
8009             if(prop.todo) {
8010                 todo_wine {
8011                     ok(hr == prop.result,
8012                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
8013                         hr, prop.result, test_index, i);
8014                 }
8015             } else {
8016                 ok(hr == prop.result,
8017                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
8018                     hr, prop.result, test_index, i);
8019             }
8020             if(SUCCEEDED(hr)) {
8021                 if(prop.todo) {
8022                     todo_wine {
8023                         ok(received == prop.expected,
8024                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
8025                             prop.expected, received, test_index, i);
8026                     }
8027                 } else {
8028                     ok(received == prop.expected,
8029                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
8030                         prop.expected, received, test_index, i);
8031                 }
8032             }
8033         }
8034     }
8035     if(uri) IUri_Release(uri);
8036 }
8037
8038 static void test_IUriBuilder_CreateUriWithFlags(IUriBuilder *builder, const uri_builder_test *test,
8039                                                 DWORD test_index) {
8040     HRESULT hr;
8041     IUri *uri = NULL;
8042
8043     hr = IUriBuilder_CreateUriWithFlags(builder, test->uri_with_flags, test->uri_with_builder_flags,
8044                                         test->uri_with_encode_flags, 0, &uri);
8045     if(test->uri_with_todo) {
8046         todo_wine {
8047             ok(hr == test->uri_with_hres,
8048                 "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8049                 hr, test->uri_with_hres, test_index);
8050         }
8051     } else {
8052         ok(hr == test->uri_with_hres,
8053             "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8054             hr, test->uri_with_hres, test_index);
8055     }
8056
8057     if(SUCCEEDED(hr)) {
8058         DWORD i;
8059
8060         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
8061             uri_builder_str_property prop = test->expected_str_props[i];
8062             BSTR received = NULL;
8063
8064             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
8065             if(prop.todo) {
8066                 todo_wine {
8067                     ok(hr == prop.result,
8068                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
8069                         hr, prop.result, test_index, i);
8070                 }
8071             } else {
8072                 ok(hr == prop.result,
8073                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
8074                     hr, prop.result, test_index, i);
8075             }
8076             if(SUCCEEDED(hr)) {
8077                 if(prop.todo) {
8078                     todo_wine {
8079                         ok(!strcmp_aw(prop.expected, received),
8080                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
8081                             prop.expected, wine_dbgstr_w(received), test_index, i);
8082                     }
8083                 } else {
8084                     ok(!strcmp_aw(prop.expected, received),
8085                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
8086                         prop.expected, wine_dbgstr_w(received), test_index, i);
8087                 }
8088             }
8089             SysFreeString(received);
8090         }
8091
8092         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
8093             uri_builder_dword_property prop = test->expected_dword_props[i];
8094             DWORD received = -2;
8095
8096             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
8097             if(prop.todo) {
8098                 todo_wine {
8099                     ok(hr == prop.result,
8100                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
8101                         hr, prop.result, test_index, i);
8102                 }
8103             } else {
8104                 ok(hr == prop.result,
8105                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
8106                     hr, prop.result, test_index, i);
8107             }
8108             if(SUCCEEDED(hr)) {
8109                 if(prop.todo) {
8110                     todo_wine {
8111                         ok(received == prop.expected,
8112                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
8113                             prop.expected, received, test_index, i);
8114                     }
8115                 } else {
8116                     ok(received == prop.expected,
8117                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
8118                         prop.expected, received, test_index, i);
8119                 }
8120             }
8121         }
8122     }
8123     if(uri) IUri_Release(uri);
8124 }
8125
8126 static void test_IUriBuilder_CreateInvalidArgs(void) {
8127     IUriBuilder *builder;
8128     HRESULT hr;
8129
8130     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8131     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8132     if(SUCCEEDED(hr)) {
8133         IUri *test = NULL, *uri = (void*) 0xdeadbeef;
8134
8135         /* Test what happens if the IUriBuilder doesn't have a IUri set. */
8136         hr = IUriBuilder_CreateUri(builder, 0, 0, 0, NULL);
8137         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
8138
8139         uri = (void*) 0xdeadbeef;
8140         hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
8141         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_NOTIMPL);
8142         ok(uri == NULL, "Error: expected uri to be NULL, but was %p instead.\n", uri);
8143
8144         hr = IUriBuilder_CreateUriSimple(builder, 0, 0, NULL);
8145         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8146             hr, E_POINTER);
8147
8148         uri = (void*) 0xdeadbeef;
8149         hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
8150         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8151             hr, E_NOTIMPL);
8152         ok(!uri, "Error: Expected uri to NULL, but was %p instead.\n", uri);
8153
8154         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, NULL);
8155         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8156             hr, E_POINTER);
8157
8158         uri = (void*) 0xdeadbeef;
8159         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
8160         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8161             hr, E_NOTIMPL);
8162         ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
8163
8164         hr = pCreateUri(http_urlW, 0, 0, &test);
8165         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8166         if(SUCCEEDED(hr)) {
8167             hr = IUriBuilder_SetIUri(builder, test);
8168             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8169
8170             /* No longer returns E_NOTIMPL, since a IUri has been set and hasn't been modified. */
8171             uri = NULL;
8172             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
8173             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8174             ok(uri != NULL, "Error: The uri was NULL.\n");
8175             if(uri) IUri_Release(uri);
8176
8177             uri = NULL;
8178             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
8179             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8180                 hr, S_OK);
8181             ok(uri != NULL, "Error: uri was NULL.\n");
8182             if(uri) IUri_Release(uri);
8183
8184             uri = NULL;
8185             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &uri);
8186             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8187                 hr, S_OK);
8188             ok(uri != NULL, "Error: uri was NULL.\n");
8189             if(uri) IUri_Release(uri);
8190
8191             hr = IUriBuilder_SetFragment(builder, NULL);
8192             ok(hr == S_OK, "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8193
8194             /* The IUriBuilder is changed, so it returns E_NOTIMPL again. */
8195             uri = (void*) 0xdeadbeef;
8196             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
8197             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8198             ok(!uri, "Error: Expected uri to be NULL but was %p instead.\n", uri);
8199
8200             uri = (void*) 0xdeadbeef;
8201             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
8202             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8203                 hr, S_OK);
8204             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
8205
8206             uri = (void*) 0xdeadbeef;
8207             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
8208             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8209                 hr, E_NOTIMPL);
8210             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
8211         }
8212         if(test) IUri_Release(test);
8213     }
8214     if(builder) IUriBuilder_Release(builder);
8215 }
8216
8217 /* Tests invalid args to the "Get*" functions. */
8218 static void test_IUriBuilder_GetInvalidArgs(void) {
8219     IUriBuilder *builder = NULL;
8220     HRESULT hr;
8221
8222     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8223     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8224     if(SUCCEEDED(hr)) {
8225         LPCWSTR received = (void*) 0xdeadbeef;
8226         DWORD len = -1, port = -1;
8227         BOOL set = -1;
8228
8229         hr = IUriBuilder_GetFragment(builder, NULL, NULL);
8230         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
8231             hr, E_POINTER);
8232         hr = IUriBuilder_GetFragment(builder, NULL, &received);
8233         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
8234             hr, E_POINTER);
8235         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8236         hr = IUriBuilder_GetFragment(builder, &len, NULL);
8237         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
8238             hr, E_POINTER);
8239         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8240
8241         hr = IUriBuilder_GetHost(builder, NULL, NULL);
8242         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
8243             hr, E_POINTER);
8244         received = (void*) 0xdeadbeef;
8245         hr = IUriBuilder_GetHost(builder, NULL, &received);
8246         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
8247             hr, E_POINTER);
8248         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8249         len = -1;
8250         hr = IUriBuilder_GetHost(builder, &len, NULL);
8251         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
8252             hr, E_POINTER);
8253         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8254
8255         hr = IUriBuilder_GetPassword(builder, NULL, NULL);
8256         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
8257             hr, E_POINTER);
8258         received = (void*) 0xdeadbeef;
8259         hr = IUriBuilder_GetPassword(builder, NULL, &received);
8260         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
8261             hr, E_POINTER);
8262         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8263         len = -1;
8264         hr = IUriBuilder_GetPassword(builder, &len, NULL);
8265         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
8266             hr, E_POINTER);
8267         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8268
8269         hr = IUriBuilder_GetPath(builder, NULL, NULL);
8270         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8271             hr, E_POINTER);
8272         received = (void*) 0xdeadbeef;
8273         hr = IUriBuilder_GetPath(builder, NULL, &received);
8274         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8275             hr, E_POINTER);
8276         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8277         len = -1;
8278         hr = IUriBuilder_GetPath(builder, &len, NULL);
8279         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8280             hr, E_POINTER);
8281         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8282
8283         hr = IUriBuilder_GetPort(builder, NULL, NULL);
8284         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8285             hr, E_POINTER);
8286         hr = IUriBuilder_GetPort(builder, NULL, &port);
8287         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8288             hr, E_POINTER);
8289         ok(!port, "Error: Expected port to be 0, but was %d instead.\n", port);
8290         hr = IUriBuilder_GetPort(builder, &set, NULL);
8291         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8292             hr, E_POINTER);
8293         ok(!set, "Error: Expected set to be FALSE, but was %d instead.\n", set);
8294
8295         hr = IUriBuilder_GetQuery(builder, NULL, NULL);
8296         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8297             hr, E_POINTER);
8298         received = (void*) 0xdeadbeef;
8299         hr = IUriBuilder_GetQuery(builder, NULL, &received);
8300         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8301             hr, E_POINTER);
8302         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8303         len = -1;
8304         hr = IUriBuilder_GetQuery(builder, &len, NULL);
8305         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8306             hr, E_POINTER);
8307         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8308
8309         hr = IUriBuilder_GetSchemeName(builder, NULL, NULL);
8310         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8311             hr, E_POINTER);
8312         received = (void*) 0xdeadbeef;
8313         hr = IUriBuilder_GetSchemeName(builder, NULL, &received);
8314         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8315             hr, E_POINTER);
8316         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8317         len = -1;
8318         hr = IUriBuilder_GetSchemeName(builder, &len, NULL);
8319         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8320             hr, E_POINTER);
8321         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8322
8323         hr = IUriBuilder_GetUserName(builder, NULL, NULL);
8324         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8325             hr, E_POINTER);
8326         received = (void*) 0xdeadbeef;
8327         hr = IUriBuilder_GetUserName(builder, NULL, &received);
8328         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8329             hr, E_POINTER);
8330         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8331         len = -1;
8332         hr = IUriBuilder_GetUserName(builder, &len, NULL);
8333         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8334             hr, E_POINTER);
8335         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8336     }
8337     if(builder) IUriBuilder_Release(builder);
8338 }
8339
8340 static void test_IUriBuilder_GetFragment(IUriBuilder *builder, const uri_builder_test *test,
8341                                          DWORD test_index) {
8342     HRESULT hr;
8343     DWORD i;
8344     LPCWSTR received = NULL;
8345     DWORD len = -1;
8346     const uri_builder_property *prop = NULL;
8347
8348     /* Check if the property was set earlier. */
8349     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8350         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_FRAGMENT)
8351             prop = &(test->properties[i]);
8352     }
8353
8354     if(prop) {
8355         /* Use expected_value unless it's NULL, then use value. */
8356         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8357         hr = IUriBuilder_GetFragment(builder, &len, &received);
8358         if(prop->todo) {
8359             todo_wine {
8360                 ok(hr == (expected ? S_OK : S_FALSE),
8361                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8362                     hr, (expected ? S_OK : S_FALSE), test_index);
8363             }
8364             if(SUCCEEDED(hr)) {
8365                 todo_wine {
8366                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8367                         expected, wine_dbgstr_w(received), test_index);
8368                 }
8369                 todo_wine {
8370                     ok(lstrlen(expected) == len,
8371                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8372                         lstrlen(expected), len, test_index);
8373                 }
8374             }
8375         } else {
8376             ok(hr == (expected ? S_OK : S_FALSE),
8377                 "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8378                 hr, (expected ? S_OK : S_FALSE), test_index);
8379             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8380                 expected, wine_dbgstr_w(received), test_index);
8381             ok(lstrlen(expected) == len,
8382                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8383                 lstrlen(expected), len, test_index);
8384         }
8385     } else {
8386         /* The property wasn't set earlier, so it should return whatever
8387          * the base IUri contains (if anything).
8388          */
8389         IUri *uri = NULL;
8390         hr = IUriBuilder_GetIUri(builder, &uri);
8391         ok(hr == S_OK,
8392             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8393             hr, S_OK, test_index);
8394         if(SUCCEEDED(hr)) {
8395             if(!uri) {
8396                 received = (void*) 0xdeadbeef;
8397                 len = -1;
8398
8399                 hr = IUriBuilder_GetFragment(builder, &len, &received);
8400                 ok(hr == S_FALSE,
8401                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8402                     hr, S_FALSE, test_index);
8403                 if(SUCCEEDED(hr)) {
8404                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8405                         len, test_index);
8406                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8407                         received, test_index);
8408                 }
8409             } else {
8410                 BOOL has_prop = FALSE;
8411                 BSTR expected = NULL;
8412
8413                 hr = IUri_GetFragment(uri, &expected);
8414                 ok(SUCCEEDED(hr),
8415                     "Error: Expected IUri_GetFragment to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8416                     hr, test_index);
8417                 has_prop = hr == S_OK;
8418
8419                 hr = IUriBuilder_GetFragment(builder, &len, &received);
8420                 if(has_prop) {
8421                     ok(hr == S_OK,
8422                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8423                         hr, S_OK, test_index);
8424                     if(SUCCEEDED(hr)) {
8425                         ok(!lstrcmpW(expected, received),
8426                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8427                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8428                         ok(lstrlenW(expected) == len,
8429                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8430                             lstrlenW(expected), len, test_index);
8431                     }
8432                 } else {
8433                     ok(hr == S_FALSE,
8434                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8435                         hr, S_FALSE, test_index);
8436                     if(SUCCEEDED(hr)) {
8437                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8438                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8439                             len, test_index);
8440                     }
8441                 }
8442                 SysFreeString(expected);
8443             }
8444         }
8445         if(uri) IUri_Release(uri);
8446     }
8447 }
8448
8449 static void test_IUriBuilder_GetHost(IUriBuilder *builder, const uri_builder_test *test,
8450                                      DWORD test_index) {
8451     HRESULT hr;
8452     DWORD i;
8453     LPCWSTR received = NULL;
8454     DWORD len = -1;
8455     const uri_builder_property *prop = NULL;
8456
8457     /* Check if the property was set earlier. */
8458     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8459         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_HOST)
8460             prop = &(test->properties[i]);
8461     }
8462
8463     if(prop) {
8464         /* Use expected_value unless it's NULL, then use value. */
8465         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8466         hr = IUriBuilder_GetHost(builder, &len, &received);
8467         if(prop->todo) {
8468             todo_wine {
8469                 ok(hr == (expected ? S_OK : S_FALSE),
8470                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8471                     hr, (expected ? S_OK : S_FALSE), test_index);
8472             }
8473             if(SUCCEEDED(hr)) {
8474                 todo_wine {
8475                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8476                         expected, wine_dbgstr_w(received), test_index);
8477                 }
8478                 todo_wine {
8479                     ok(lstrlen(expected) == len,
8480                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8481                         lstrlen(expected), len, test_index);
8482                 }
8483             }
8484         } else {
8485             ok(hr == (expected ? S_OK : S_FALSE),
8486                 "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8487                 hr, (expected ? S_OK : S_FALSE), test_index);
8488             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8489                 expected, wine_dbgstr_w(received), test_index);
8490             ok(lstrlen(expected) == len,
8491                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8492                 lstrlen(expected), len, test_index);
8493         }
8494     } else {
8495         /* The property wasn't set earlier, so it should return whatever
8496          * the base IUri contains (if anything).
8497          */
8498         IUri *uri = NULL;
8499         hr = IUriBuilder_GetIUri(builder, &uri);
8500         ok(hr == S_OK,
8501             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8502             hr, S_OK, test_index);
8503         if(SUCCEEDED(hr)) {
8504             if(!uri) {
8505                 received = (void*) 0xdeadbeef;
8506                 len = -1;
8507
8508                 hr = IUriBuilder_GetHost(builder, &len, &received);
8509                 ok(hr == S_FALSE,
8510                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8511                     hr, S_FALSE, test_index);
8512                 if(SUCCEEDED(hr)) {
8513                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8514                         len, test_index);
8515                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8516                         received, test_index);
8517                 }
8518             } else {
8519                 BOOL has_prop = FALSE;
8520                 BSTR expected = NULL;
8521
8522                 hr = IUri_GetHost(uri, &expected);
8523                 ok(SUCCEEDED(hr),
8524                     "Error: Expected IUri_GetHost to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8525                     hr, test_index);
8526                 has_prop = hr == S_OK;
8527
8528                 hr = IUriBuilder_GetHost(builder, &len, &received);
8529                 if(has_prop) {
8530                     ok(hr == S_OK,
8531                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8532                         hr, S_OK, test_index);
8533                     if(SUCCEEDED(hr)) {
8534                         ok(!lstrcmpW(expected, received),
8535                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8536                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8537                         ok(lstrlenW(expected) == len,
8538                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8539                             lstrlenW(expected), len, test_index);
8540                     }
8541                 } else {
8542                     ok(hr == S_FALSE,
8543                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8544                         hr, S_FALSE, test_index);
8545                     if(SUCCEEDED(hr)) {
8546                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8547                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8548                             len, test_index);
8549                     }
8550                 }
8551                 SysFreeString(expected);
8552             }
8553         }
8554         if(uri) IUri_Release(uri);
8555     }
8556 }
8557
8558 static void test_IUriBuilder_GetPassword(IUriBuilder *builder, const uri_builder_test *test,
8559                                          DWORD test_index) {
8560     HRESULT hr;
8561     DWORD i;
8562     LPCWSTR received = NULL;
8563     DWORD len = -1;
8564     const uri_builder_property *prop = NULL;
8565
8566     /* Check if the property was set earlier. */
8567     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8568         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PASSWORD)
8569             prop = &(test->properties[i]);
8570     }
8571
8572     if(prop) {
8573         /* Use expected_value unless it's NULL, then use value. */
8574         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8575         hr = IUriBuilder_GetPassword(builder, &len, &received);
8576         if(prop->todo) {
8577             todo_wine {
8578                 ok(hr == (expected ? S_OK : S_FALSE),
8579                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8580                     hr, (expected ? S_OK : S_FALSE), test_index);
8581             }
8582             if(SUCCEEDED(hr)) {
8583                 todo_wine {
8584                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8585                         expected, wine_dbgstr_w(received), test_index);
8586                 }
8587                 todo_wine {
8588                     ok(lstrlen(expected) == len,
8589                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8590                         lstrlen(expected), len, test_index);
8591                 }
8592             }
8593         } else {
8594             ok(hr == (expected ? S_OK : S_FALSE),
8595                 "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8596                 hr, (expected ? S_OK : S_FALSE), test_index);
8597             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8598                 expected, wine_dbgstr_w(received), test_index);
8599             ok(lstrlen(expected) == len,
8600                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8601                 lstrlen(expected), len, test_index);
8602         }
8603     } else {
8604         /* The property wasn't set earlier, so it should return whatever
8605          * the base IUri contains (if anything).
8606          */
8607         IUri *uri = NULL;
8608         hr = IUriBuilder_GetIUri(builder, &uri);
8609         ok(hr == S_OK,
8610             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8611             hr, S_OK, test_index);
8612         if(SUCCEEDED(hr)) {
8613             if(!uri) {
8614                 received = (void*) 0xdeadbeef;
8615                 len = -1;
8616
8617                 hr = IUriBuilder_GetPassword(builder, &len, &received);
8618                 ok(hr == S_FALSE,
8619                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8620                     hr, S_FALSE, test_index);
8621                 if(SUCCEEDED(hr)) {
8622                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8623                         len, test_index);
8624                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8625                         received, test_index);
8626                 }
8627             } else {
8628                 BOOL has_prop = FALSE;
8629                 BSTR expected = NULL;
8630
8631                 hr = IUri_GetPassword(uri, &expected);
8632                 ok(SUCCEEDED(hr),
8633                     "Error: Expected IUri_GetPassword to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8634                     hr, test_index);
8635                 has_prop = hr == S_OK;
8636
8637                 hr = IUriBuilder_GetPassword(builder, &len, &received);
8638                 if(has_prop) {
8639                     ok(hr == S_OK,
8640                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8641                         hr, S_OK, test_index);
8642                     if(SUCCEEDED(hr)) {
8643                         ok(!lstrcmpW(expected, received),
8644                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8645                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8646                         ok(lstrlenW(expected) == len,
8647                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8648                             lstrlenW(expected), len, test_index);
8649                     }
8650                 } else {
8651                     ok(hr == S_FALSE,
8652                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8653                         hr, S_FALSE, test_index);
8654                     if(SUCCEEDED(hr)) {
8655                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8656                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8657                             len, test_index);
8658                     }
8659                 }
8660                 SysFreeString(expected);
8661             }
8662         }
8663         if(uri) IUri_Release(uri);
8664     }
8665 }
8666
8667 static void test_IUriBuilder_GetPath(IUriBuilder *builder, const uri_builder_test *test,
8668                                      DWORD test_index) {
8669     HRESULT hr;
8670     DWORD i;
8671     LPCWSTR received = NULL;
8672     DWORD len = -1;
8673     const uri_builder_property *prop = NULL;
8674
8675     /* Check if the property was set earlier. */
8676     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8677         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PATH)
8678             prop = &(test->properties[i]);
8679     }
8680
8681     if(prop) {
8682         /* Use expected_value unless it's NULL, then use value. */
8683         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8684         hr = IUriBuilder_GetPath(builder, &len, &received);
8685         if(prop->todo) {
8686             todo_wine {
8687                 ok(hr == (expected ? S_OK : S_FALSE),
8688                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8689                     hr, (expected ? S_OK : S_FALSE), test_index);
8690             }
8691             if(SUCCEEDED(hr)) {
8692                 todo_wine {
8693                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8694                         expected, wine_dbgstr_w(received), test_index);
8695                 }
8696                 todo_wine {
8697                     ok(lstrlen(expected) == len,
8698                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8699                         lstrlen(expected), len, test_index);
8700                 }
8701             }
8702         } else {
8703             ok(hr == (expected ? S_OK : S_FALSE),
8704                 "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8705                 hr, (expected ? S_OK : S_FALSE), test_index);
8706             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8707                 expected, wine_dbgstr_w(received), test_index);
8708             ok(lstrlen(expected) == len,
8709                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8710                 lstrlen(expected), len, test_index);
8711         }
8712     } else {
8713         /* The property wasn't set earlier, so it should return whatever
8714          * the base IUri contains (if anything).
8715          */
8716         IUri *uri = NULL;
8717         hr = IUriBuilder_GetIUri(builder, &uri);
8718         ok(hr == S_OK,
8719             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8720             hr, S_OK, test_index);
8721         if(SUCCEEDED(hr)) {
8722             if(!uri) {
8723                 received = (void*) 0xdeadbeef;
8724                 len = -1;
8725
8726                 hr = IUriBuilder_GetPath(builder, &len, &received);
8727                 ok(hr == S_FALSE,
8728                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8729                     hr, S_FALSE, test_index);
8730                 if(SUCCEEDED(hr)) {
8731                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8732                         len, test_index);
8733                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8734                         received, test_index);
8735                 }
8736             } else {
8737                 BOOL has_prop = FALSE;
8738                 BSTR expected = NULL;
8739
8740                 hr = IUri_GetPath(uri, &expected);
8741                 ok(SUCCEEDED(hr),
8742                     "Error: Expected IUri_GetPath to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8743                     hr, test_index);
8744                 has_prop = hr == S_OK;
8745
8746                 hr = IUriBuilder_GetPath(builder, &len, &received);
8747                 if(has_prop) {
8748                     ok(hr == S_OK,
8749                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8750                         hr, S_OK, test_index);
8751                     if(SUCCEEDED(hr)) {
8752                         ok(!lstrcmpW(expected, received),
8753                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8754                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8755                         ok(lstrlenW(expected) == len,
8756                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8757                             lstrlenW(expected), len, test_index);
8758                     }
8759                 } else {
8760                     ok(hr == S_FALSE,
8761                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8762                         hr, S_FALSE, test_index);
8763                     if(SUCCEEDED(hr)) {
8764                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8765                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8766                             len, test_index);
8767                     }
8768                 }
8769                 SysFreeString(expected);
8770             }
8771         }
8772         if(uri) IUri_Release(uri);
8773     }
8774 }
8775
8776 static void test_IUriBuilder_GetPort(IUriBuilder *builder, const uri_builder_test *test,
8777                                      DWORD test_index) {
8778     HRESULT hr;
8779     BOOL has_port = FALSE;
8780     DWORD received = -1;
8781
8782     if(test->port_prop.change) {
8783         DWORD expected = test->port_prop.value;
8784
8785         hr = IUriBuilder_GetPort(builder, &has_port, &received);
8786         if(test->port_prop.todo) {
8787             todo_wine {
8788                 ok(hr == S_OK,
8789                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8790                     hr, S_OK, test_index);
8791             }
8792             if(SUCCEEDED(hr)) {
8793                 todo_wine {
8794                     ok(has_port == test->port_prop.set,
8795                         "Error: Expected has_port to be %d but was %d instead on uri_builder_tests[%d].\n",
8796                         test->port_prop.set, has_port, test_index);
8797                 }
8798                 todo_wine {
8799                     ok(received == expected,
8800                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8801                         expected, received, test_index);
8802                 }
8803             }
8804         } else {
8805             ok(hr == S_OK,
8806                 "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8807                 hr, S_OK, test_index);
8808             ok(has_port == test->port_prop.set,
8809                 "Error: Expected has_port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8810                 test->port_prop.set, has_port, test_index);
8811             ok(received == test->port_prop.value,
8812                 "Error: Expected port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8813                 test->port_prop.value, received, test_index);
8814         }
8815     } else {
8816         IUri *uri = NULL;
8817
8818         hr = IUriBuilder_GetIUri(builder, &uri);
8819         ok(hr == S_OK,
8820             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8821             hr, S_OK, test_index);
8822         if(SUCCEEDED(hr)) {
8823             if(!uri) {
8824                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8825                 ok(hr == S_OK,
8826                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8827                     hr, S_OK, test_index);
8828                 if(SUCCEEDED(hr)) {
8829                     ok(has_port == FALSE,
8830                         "Error: Expected has_port to be FALSE, but was %d instead on uri_builder_tests[%d].\n",
8831                         has_port, test_index);
8832                     ok(!received, "Error: Expected received to be 0, but was %d instead on uri_builder_tests[%d].\n",
8833                         received, test_index);
8834                 }
8835             } else {
8836                 DWORD expected;
8837
8838                 hr = IUri_GetPort(uri, &expected);
8839                 ok(SUCCEEDED(hr),
8840                     "Error: Expected IUri_Port to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8841                     hr, test_index);
8842
8843                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8844                 ok(hr == S_OK,
8845                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8846                     hr, S_OK, test_index);
8847                 if(SUCCEEDED(hr)) {
8848                     ok(!has_port,
8849                         "Error: Expected has_port to be FALSE but was TRUE instead on uri_builder_tests[%d].\n",
8850                         test_index);
8851                     ok(received == expected,
8852                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8853                         expected, received, test_index);
8854                 }
8855             }
8856         }
8857         if(uri) IUri_Release(uri);
8858     }
8859 }
8860
8861 static void test_IUriBuilder_GetQuery(IUriBuilder *builder, const uri_builder_test *test,
8862                                       DWORD test_index) {
8863     HRESULT hr;
8864     DWORD i;
8865     LPCWSTR received = NULL;
8866     DWORD len = -1;
8867     const uri_builder_property *prop = NULL;
8868
8869     /* Check if the property was set earlier. */
8870     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8871         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_QUERY)
8872             prop = &(test->properties[i]);
8873     }
8874
8875     if(prop) {
8876         /* Use expected_value unless it's NULL, then use value. */
8877         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8878         hr = IUriBuilder_GetQuery(builder, &len, &received);
8879         if(prop->todo) {
8880             todo_wine {
8881                 ok(hr == (expected ? S_OK : S_FALSE),
8882                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8883                     hr, (expected ? S_OK : S_FALSE), test_index);
8884             }
8885             if(SUCCEEDED(hr)) {
8886                 todo_wine {
8887                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8888                         expected, wine_dbgstr_w(received), test_index);
8889                 }
8890                 todo_wine {
8891                     ok(lstrlen(expected) == len,
8892                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8893                         lstrlen(expected), len, test_index);
8894                 }
8895             }
8896         } else {
8897             ok(hr == (expected ? S_OK : S_FALSE),
8898                 "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8899                 hr, (expected ? S_OK : S_FALSE), test_index);
8900             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8901                 expected, wine_dbgstr_w(received), test_index);
8902             ok(lstrlen(expected) == len,
8903                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8904                 lstrlen(expected), len, test_index);
8905         }
8906     } else {
8907         /* The property wasn't set earlier, so it should return whatever
8908          * the base IUri contains (if anything).
8909          */
8910         IUri *uri = NULL;
8911         hr = IUriBuilder_GetIUri(builder, &uri);
8912         ok(hr == S_OK,
8913             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8914             hr, S_OK, test_index);
8915         if(SUCCEEDED(hr)) {
8916             if(!uri) {
8917                 received = (void*) 0xdeadbeef;
8918                 len = -1;
8919
8920                 hr = IUriBuilder_GetQuery(builder, &len, &received);
8921                 ok(hr == S_FALSE,
8922                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8923                     hr, S_FALSE, test_index);
8924                 if(SUCCEEDED(hr)) {
8925                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8926                         len, test_index);
8927                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8928                         received, test_index);
8929                 }
8930             } else {
8931                 BOOL has_prop = FALSE;
8932                 BSTR expected = NULL;
8933
8934                 hr = IUri_GetQuery(uri, &expected);
8935                 ok(SUCCEEDED(hr),
8936                     "Error: Expected IUri_GetQuery to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8937                     hr, test_index);
8938                 has_prop = hr == S_OK;
8939
8940                 hr = IUriBuilder_GetQuery(builder, &len, &received);
8941                 if(has_prop) {
8942                     ok(hr == S_OK,
8943                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8944                         hr, S_OK, test_index);
8945                     if(SUCCEEDED(hr)) {
8946                         ok(!lstrcmpW(expected, received),
8947                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8948                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8949                         ok(lstrlenW(expected) == len,
8950                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8951                             lstrlenW(expected), len, test_index);
8952                     }
8953                 } else {
8954                     ok(hr == S_FALSE,
8955                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8956                         hr, S_FALSE, test_index);
8957                     if(SUCCEEDED(hr)) {
8958                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8959                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8960                             len, test_index);
8961                     }
8962                 }
8963                 SysFreeString(expected);
8964             }
8965         }
8966         if(uri) IUri_Release(uri);
8967     }
8968 }
8969
8970 static void test_IUriBuilder_GetSchemeName(IUriBuilder *builder, const uri_builder_test *test,
8971                                            DWORD test_index) {
8972     HRESULT hr;
8973     DWORD i;
8974     LPCWSTR received = NULL;
8975     DWORD len = -1;
8976     const uri_builder_property *prop = NULL;
8977
8978     /* Check if the property was set earlier. */
8979     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8980         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_SCHEME_NAME)
8981             prop = &(test->properties[i]);
8982     }
8983
8984     if(prop) {
8985         /* Use expected_value unless it's NULL, then use value. */
8986         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8987         hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8988         if(prop->todo) {
8989             todo_wine {
8990                 ok(hr == (expected ? S_OK : S_FALSE),
8991                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8992                     hr, (expected ? S_OK : S_FALSE), test_index);
8993             }
8994             if(SUCCEEDED(hr)) {
8995                 todo_wine {
8996                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8997                         expected, wine_dbgstr_w(received), test_index);
8998                 }
8999                 todo_wine {
9000                     ok(lstrlen(expected) == len,
9001                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9002                         lstrlen(expected), len, test_index);
9003                 }
9004             }
9005         } else {
9006             ok(hr == (expected ? S_OK : S_FALSE),
9007                 "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9008                 hr, (expected ? S_OK : S_FALSE), test_index);
9009             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
9010                 expected, wine_dbgstr_w(received), test_index);
9011             ok(lstrlen(expected) == len,
9012                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9013                 lstrlen(expected), len, test_index);
9014         }
9015     } else {
9016         /* The property wasn't set earlier, so it should return whatever
9017          * the base IUri contains (if anything).
9018          */
9019         IUri *uri = NULL;
9020         hr = IUriBuilder_GetIUri(builder, &uri);
9021         ok(hr == S_OK,
9022             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9023             hr, S_OK, test_index);
9024         if(SUCCEEDED(hr)) {
9025             if(!uri) {
9026                 received = (void*) 0xdeadbeef;
9027                 len = -1;
9028
9029                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
9030                 ok(hr == S_FALSE,
9031                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9032                     hr, S_FALSE, test_index);
9033                 if(SUCCEEDED(hr)) {
9034                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
9035                         len, test_index);
9036                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
9037                         received, test_index);
9038                 }
9039             } else {
9040                 BOOL has_prop = FALSE;
9041                 BSTR expected = NULL;
9042
9043                 hr = IUri_GetSchemeName(uri, &expected);
9044                 ok(SUCCEEDED(hr),
9045                     "Error: Expected IUri_GetSchemeName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
9046                     hr, test_index);
9047                 has_prop = hr == S_OK;
9048
9049                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
9050                 if(has_prop) {
9051                     ok(hr == S_OK,
9052                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9053                         hr, S_OK, test_index);
9054                     if(SUCCEEDED(hr)) {
9055                         ok(!lstrcmpW(expected, received),
9056                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
9057                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
9058                         ok(lstrlenW(expected) == len,
9059                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9060                             lstrlenW(expected), len, test_index);
9061                     }
9062                 } else {
9063                     ok(hr == S_FALSE,
9064                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9065                         hr, S_FALSE, test_index);
9066                     if(SUCCEEDED(hr)) {
9067                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
9068                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
9069                             len, test_index);
9070                     }
9071                 }
9072                 SysFreeString(expected);
9073             }
9074         }
9075         if(uri) IUri_Release(uri);
9076     }
9077 }
9078
9079 static void test_IUriBuilder_GetUserName(IUriBuilder *builder, const uri_builder_test *test,
9080                                          DWORD test_index) {
9081     HRESULT hr;
9082     DWORD i;
9083     LPCWSTR received = NULL;
9084     DWORD len = -1;
9085     const uri_builder_property *prop = NULL;
9086
9087     /* Check if the property was set earlier. */
9088     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
9089         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_USER_NAME)
9090             prop = &(test->properties[i]);
9091     }
9092
9093     if(prop && prop->value && *prop->value) {
9094         /* Use expected_value unless it's NULL, then use value. */
9095         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
9096         hr = IUriBuilder_GetUserName(builder, &len, &received);
9097         if(prop->todo) {
9098             todo_wine {
9099                 ok(hr == (expected ? S_OK : S_FALSE),
9100                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9101                     hr, (expected ? S_OK : S_FALSE), test_index);
9102             }
9103             if(SUCCEEDED(hr)) {
9104                 todo_wine {
9105                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
9106                         expected, wine_dbgstr_w(received), test_index);
9107                 }
9108                 todo_wine {
9109                     ok(lstrlen(expected) == len,
9110                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9111                         lstrlen(expected), len, test_index);
9112                 }
9113             }
9114         } else {
9115             ok(hr == (expected ? S_OK : S_FALSE),
9116                 "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9117                 hr, (expected ? S_OK : S_FALSE), test_index);
9118             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
9119                 expected, wine_dbgstr_w(received), test_index);
9120             ok(lstrlen(expected) == len,
9121                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9122                 lstrlen(expected), len, test_index);
9123         }
9124     } else {
9125         /* The property wasn't set earlier, so it should return whatever
9126          * the base IUri contains (if anything).
9127          */
9128         IUri *uri = NULL;
9129         hr = IUriBuilder_GetIUri(builder, &uri);
9130         ok(hr == S_OK,
9131             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9132             hr, S_OK, test_index);
9133         if(SUCCEEDED(hr)) {
9134             if(!uri) {
9135                 received = (void*) 0xdeadbeef;
9136                 len = -1;
9137
9138                 hr = IUriBuilder_GetUserName(builder, &len, &received);
9139                 ok(hr == S_FALSE,
9140                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9141                     hr, S_FALSE, test_index);
9142                 if(SUCCEEDED(hr)) {
9143                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
9144                         len, test_index);
9145                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
9146                         received, test_index);
9147                 }
9148             } else {
9149                 BSTR expected = NULL;
9150                 BOOL has_prop = FALSE;
9151
9152                 hr = IUri_GetUserName(uri, &expected);
9153                 ok(SUCCEEDED(hr),
9154                     "Error: Expected IUri_GetUserName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
9155                     hr, test_index);
9156                 has_prop = hr == S_OK;
9157
9158                 hr = IUriBuilder_GetUserName(builder, &len, &received);
9159                 if(has_prop) {
9160                     ok(hr == S_OK,
9161                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9162                         hr, S_OK, test_index);
9163                     if(SUCCEEDED(hr)) {
9164                         ok(!lstrcmpW(expected, received),
9165                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
9166                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
9167                         ok(lstrlenW(expected) == len,
9168                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9169                             lstrlenW(expected), len, test_index);
9170                     }
9171                 } else {
9172                     ok(hr == S_FALSE,
9173                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9174                         hr, S_FALSE, test_index);
9175                     if(SUCCEEDED(hr)) {
9176                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
9177                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
9178                             len, test_index);
9179                     }
9180                 }
9181                 SysFreeString(expected);
9182             }
9183         }
9184         if(uri) IUri_Release(uri);
9185     }
9186 }
9187
9188 /* Tests IUriBuilder functions. */
9189 static void test_IUriBuilder(void) {
9190     HRESULT hr;
9191     IUriBuilder *builder;
9192     DWORD i;
9193
9194     for(i = 0; i < sizeof(uri_builder_tests)/sizeof(uri_builder_tests[0]); ++i) {
9195         IUri *uri = NULL;
9196         uri_builder_test test = uri_builder_tests[i];
9197         LPWSTR uriW = NULL;
9198
9199         if(test.uri) {
9200             uriW = a2w(test.uri);
9201             hr = pCreateUri(uriW, test.create_flags, 0, &uri);
9202             ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9203                 hr, S_OK, i);
9204             if(FAILED(hr)) continue;
9205         }
9206         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9207         if(test.create_builder_todo) {
9208             todo_wine {
9209                 ok(hr == test.create_builder_expected,
9210                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9211                     hr, test.create_builder_expected, i);
9212             }
9213         } else {
9214             ok(hr == test.create_builder_expected,
9215                 "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9216                 hr, test.create_builder_expected, i);
9217         }
9218         if(SUCCEEDED(hr)) {
9219             DWORD j;
9220             BOOL modified = FALSE, received = FALSE;
9221
9222             /* Perform all the string property changes. */
9223             for(j = 0; j < URI_BUILDER_STR_PROPERTY_COUNT; ++j) {
9224                 uri_builder_property prop = test.properties[j];
9225                 if(prop.change) {
9226                     change_property(builder, &prop, i);
9227                     if(prop.property != Uri_PROPERTY_SCHEME_NAME &&
9228                        prop.property != Uri_PROPERTY_HOST)
9229                         modified = TRUE;
9230                     else if(prop.value && *prop.value)
9231                         modified = TRUE;
9232                     else if(prop.value && !*prop.value && prop.property == Uri_PROPERTY_HOST)
9233                         /* Host name property can't be NULL, but it can be empty. */
9234                         modified = TRUE;
9235                 }
9236             }
9237
9238             if(test.port_prop.change) {
9239                 hr = IUriBuilder_SetPort(builder, test.port_prop.set, test.port_prop.value);
9240                 modified = TRUE;
9241                 if(test.port_prop.todo) {
9242                     todo_wine {
9243                         ok(hr == test.port_prop.expected,
9244                             "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9245                             hr, test.port_prop.expected, i);
9246                     }
9247                 } else {
9248                     ok(hr == test.port_prop.expected,
9249                         "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9250                         hr, test.port_prop.expected, i);
9251                 }
9252             }
9253
9254             hr = IUriBuilder_HasBeenModified(builder, &received);
9255             ok(hr == S_OK,
9256                 "Error IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9257                 hr, S_OK, i);
9258             if(SUCCEEDED(hr))
9259                 ok(received == modified,
9260                     "Error: Expected received to be %d but was %d instead on uri_builder_tests[%d].\n",
9261                     modified, received, i);
9262
9263             /* Test the "Get*" functions. */
9264             test_IUriBuilder_GetFragment(builder, &test, i);
9265             test_IUriBuilder_GetHost(builder, &test, i);
9266             test_IUriBuilder_GetPassword(builder, &test, i);
9267             test_IUriBuilder_GetPath(builder, &test, i);
9268             test_IUriBuilder_GetPort(builder, &test, i);
9269             test_IUriBuilder_GetQuery(builder, &test, i);
9270             test_IUriBuilder_GetSchemeName(builder, &test, i);
9271             test_IUriBuilder_GetUserName(builder, &test, i);
9272
9273             test_IUriBuilder_CreateUri(builder, &test, i);
9274             test_IUriBuilder_CreateUriSimple(builder, &test, i);
9275             test_IUriBuilder_CreateUriWithFlags(builder, &test, i);
9276         }
9277         if(builder) IUriBuilder_Release(builder);
9278         if(uri) IUri_Release(uri);
9279         heap_free(uriW);
9280     }
9281 }
9282
9283 static void test_IUriBuilder_HasBeenModified(void) {
9284     HRESULT hr;
9285     IUriBuilder *builder = NULL;
9286
9287     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9288     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9289     if(SUCCEEDED(hr)) {
9290         static const WCHAR hostW[] = {'g','o','o','g','l','e','.','c','o','m',0};
9291         IUri *uri = NULL;
9292         BOOL received;
9293
9294         hr = IUriBuilder_HasBeenModified(builder, NULL);
9295         ok(hr == E_POINTER, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9296             hr, E_POINTER);
9297
9298         hr = IUriBuilder_SetHost(builder, hostW);
9299         ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n",
9300             hr, S_OK);
9301
9302         hr = IUriBuilder_HasBeenModified(builder, &received);
9303         ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9304             hr, S_OK);
9305         if(SUCCEEDED(hr))
9306             ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9307
9308         hr = pCreateUri(http_urlW, 0, 0, &uri);
9309         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9310         if(SUCCEEDED(hr)) {
9311             LPCWSTR prop;
9312             DWORD len = -1;
9313
9314             hr = IUriBuilder_SetIUri(builder, uri);
9315             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n",
9316                 hr, S_OK);
9317
9318             hr = IUriBuilder_HasBeenModified(builder, &received);
9319             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9320                 hr, S_OK);
9321             if(SUCCEEDED(hr))
9322                 ok(received == FALSE, "Error: Expected received to be FALSE.\n");
9323
9324             /* Test what happens with you call SetIUri with the same IUri again. */
9325             hr = IUriBuilder_SetHost(builder, hostW);
9326             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9327
9328             hr = IUriBuilder_HasBeenModified(builder, &received);
9329             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9330                 hr, S_OK);
9331             if(SUCCEEDED(hr))
9332                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9333
9334             hr = IUriBuilder_SetIUri(builder, uri);
9335             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9336
9337             /* IUriBuilder already had 'uri' as it's IUri property and so Windows doesn't
9338              * reset any of the changes that were made to the IUriBuilder.
9339              */
9340             hr = IUriBuilder_HasBeenModified(builder, &received);
9341             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9342             if(SUCCEEDED(hr))
9343                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9344
9345             hr = IUriBuilder_GetHost(builder, &len, &prop);
9346             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9347             if(SUCCEEDED(hr)) {
9348                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
9349                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
9350                 ok(len == lstrlenW(hostW), "Error: Expected len to be %d, but was %d instead.\n",
9351                     lstrlenW(hostW), len);
9352             }
9353
9354             hr = IUriBuilder_SetIUri(builder, NULL);
9355             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9356
9357             hr = IUriBuilder_SetHost(builder, hostW);
9358             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9359             hr = IUriBuilder_HasBeenModified(builder, &received);
9360             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9361                 hr, S_OK);
9362             if(SUCCEEDED(hr))
9363                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9364
9365             hr = IUriBuilder_SetIUri(builder, NULL);
9366             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%09x.\n", hr, S_OK);
9367
9368             hr = IUriBuilder_HasBeenModified(builder, &received);
9369             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9370                 hr, S_OK);
9371             if(SUCCEEDED(hr))
9372                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9373
9374             hr = IUriBuilder_GetHost(builder, &len, &prop);
9375             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9376             if(SUCCEEDED(hr)) {
9377                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
9378                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
9379                 ok(len == lstrlenW(hostW), "Error: Expected len to %d, but was %d instead.\n",
9380                     lstrlenW(hostW), len);
9381             }
9382         }
9383         if(uri) IUri_Release(uri);
9384     }
9385     if(builder) IUriBuilder_Release(builder);
9386 }
9387
9388 /* Test IUriBuilder {Get,Set}IUri functions. */
9389 static void test_IUriBuilder_IUriProperty(void) {
9390     IUriBuilder *builder = NULL;
9391     HRESULT hr;
9392
9393     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9394     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9395     if(SUCCEEDED(hr)) {
9396         IUri *uri = NULL;
9397
9398         hr = IUriBuilder_GetIUri(builder, NULL);
9399         ok(hr == E_POINTER, "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x.\n",
9400             hr, E_POINTER);
9401
9402         hr = pCreateUri(http_urlW, 0, 0, &uri);
9403         if(SUCCEEDED(hr)) {
9404             IUri *test = NULL;
9405             ULONG cur_count, orig_count;
9406
9407             /* IUriBuilder doesn't clone the IUri, it use the same IUri. */
9408             orig_count = get_refcnt(uri);
9409             hr = IUriBuilder_SetIUri(builder, uri);
9410             cur_count = get_refcnt(uri);
9411             if(SUCCEEDED(hr))
9412                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9413                     orig_count+1, cur_count);
9414
9415             hr = IUriBuilder_SetIUri(builder, NULL);
9416             cur_count = get_refcnt(uri);
9417             if(SUCCEEDED(hr))
9418                 ok(cur_count == orig_count, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9419                     orig_count, cur_count);
9420
9421             /* CreateUri* functions will return back the same IUri if nothing has changed. */
9422             hr = IUriBuilder_SetIUri(builder, uri);
9423             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9424             orig_count = get_refcnt(uri);
9425
9426             hr = IUriBuilder_CreateUri(builder, 0, 0, 0, &test);
9427             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9428             if(SUCCEEDED(hr)) {
9429                 cur_count = get_refcnt(uri);
9430                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9431                     orig_count+1, cur_count);
9432                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n",
9433                     uri, test);
9434             }
9435             if(test) IUri_Release(test);
9436
9437             test = NULL;
9438             hr = IUriBuilder_CreateUri(builder, -1, 0, 0, &test);
9439             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9440             if(SUCCEEDED(hr)) {
9441                 cur_count = get_refcnt(uri);
9442                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9443                     orig_count+1, cur_count);
9444                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9445             }
9446             if(test) IUri_Release(test);
9447
9448             /* Doesn't return the same IUri, if the flag combination is different then the one that created
9449              * the base IUri.
9450              */
9451             test = NULL;
9452             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, &test);
9453             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9454             if(SUCCEEDED(hr))
9455                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
9456
9457             if(test) IUri_Release(test);
9458
9459             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
9460              * explicitly set (because it's a default flags).
9461              */
9462             test = NULL;
9463             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_CANONICALIZE, 0, 0, &test);
9464             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9465             if(SUCCEEDED(hr)) {
9466                 cur_count = get_refcnt(uri);
9467                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9468                     orig_count+1, cur_count);
9469                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
9470             }
9471             if(test) IUri_Release(test);
9472
9473             test = NULL;
9474             hr = IUriBuilder_CreateUriSimple(builder, 0, 0, &test);
9475             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9476             if(SUCCEEDED(hr)) {
9477                 cur_count = get_refcnt(uri);
9478                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9479                     orig_count+1, cur_count);
9480                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9481             }
9482             if(test) IUri_Release(test);
9483
9484             test = NULL;
9485             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &test);
9486             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
9487                 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", uri, test);
9493             }
9494             if(test) IUri_Release(test);
9495
9496             /* Doesn't return the same IUri, if the flag combination is different then the one that created
9497              * the base IUri.
9498              */
9499             test = NULL;
9500             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, 0, &test);
9501             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9502             if(SUCCEEDED(hr))
9503                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
9504
9505             if(test) IUri_Release(test);
9506
9507             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
9508              * explicitly set (because it's a default flags).
9509              */
9510             test = NULL;
9511             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_CANONICALIZE, 0, 0, 0, &test);
9512             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9513             if(SUCCEEDED(hr)) {
9514                 cur_count = get_refcnt(uri);
9515                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9516                     orig_count+1, cur_count);
9517                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
9518             }
9519             if(test) IUri_Release(test);
9520         }
9521         if(uri) IUri_Release(uri);
9522     }
9523     if(builder) IUriBuilder_Release(builder);
9524 }
9525
9526 static void test_IUriBuilder_RemoveProperties(void) {
9527     IUriBuilder *builder = NULL;
9528     HRESULT hr;
9529     DWORD i;
9530
9531     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9532     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9533     if(SUCCEEDED(hr)) {
9534         /* Properties that can't be removed. */
9535         const DWORD invalid = Uri_HAS_ABSOLUTE_URI|Uri_HAS_DISPLAY_URI|Uri_HAS_RAW_URI|Uri_HAS_HOST_TYPE|
9536                               Uri_HAS_SCHEME|Uri_HAS_ZONE;
9537
9538         for(i = Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_DWORD_LAST; ++i) {
9539             hr = IUriBuilder_RemoveProperties(builder, i << 1);
9540             if((i << 1) & invalid) {
9541                 ok(hr == E_INVALIDARG,
9542                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
9543                     hr, E_INVALIDARG, i);
9544             } else {
9545                 ok(hr == S_OK,
9546                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
9547                     hr, S_OK, i);
9548             }
9549         }
9550
9551         /* Also doesn't accept anything that's outside the range of the
9552          * Uri_HAS flags.
9553          */
9554         hr = IUriBuilder_RemoveProperties(builder, (Uri_PROPERTY_DWORD_LAST+1) << 1);
9555         ok(hr == E_INVALIDARG, "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x.\n",
9556             hr, E_INVALIDARG);
9557     }
9558     if(builder) IUriBuilder_Release(builder);
9559
9560     for(i = 0; i < sizeof(uri_builder_remove_tests)/sizeof(uri_builder_remove_tests[0]); ++i) {
9561         uri_builder_remove_test test = uri_builder_remove_tests[i];
9562         IUri *uri = NULL;
9563         LPWSTR uriW;
9564
9565         uriW = a2w(test.uri);
9566         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
9567         if(SUCCEEDED(hr)) {
9568             builder = NULL;
9569
9570             hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9571             if(test.create_builder_todo) {
9572                 todo_wine {
9573                     ok(hr == test.create_builder_expected,
9574                         "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9575                         hr, test.create_builder_expected, i);
9576                 }
9577             } else {
9578                 ok(hr == test.create_builder_expected,
9579                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9580                     hr, test.create_builder_expected, i);
9581             }
9582             if(SUCCEEDED(hr)) {
9583                 hr = IUriBuilder_RemoveProperties(builder, test.remove_properties);
9584                 if(test.remove_todo) {
9585                     todo_wine {
9586                         ok(hr == test.remove_expected,
9587                             "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x on test %d.\n",
9588                             hr, test.remove_expected, i);
9589                     }
9590                 } else {
9591                     ok(hr == test.remove_expected,
9592                         "Error: IUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9593                         hr, test.remove_expected, i);
9594                 }
9595                 if(SUCCEEDED(hr)) {
9596                     IUri *result = NULL;
9597
9598                     hr = IUriBuilder_CreateUri(builder, test.expected_flags, 0, 0, &result);
9599                     if(test.expected_todo) {
9600                         todo_wine {
9601                             ok(hr == test.expected_hres,
9602                                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
9603                                 hr, test.expected_hres, i);
9604                         }
9605                     } else {
9606                         ok(hr == test.expected_hres,
9607                             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
9608                             hr, test.expected_hres, i);
9609                     }
9610                     if(SUCCEEDED(hr)) {
9611                         BSTR received = NULL;
9612
9613                         hr = IUri_GetAbsoluteUri(result, &received);
9614                         ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
9615                         ok(!strcmp_aw(test.expected_uri, received),
9616                             "Error: Expected %s but got %s instead on test %d.\n",
9617                             test.expected_uri, wine_dbgstr_w(received), i);
9618                         SysFreeString(received);
9619                     }
9620                     if(result) IUri_Release(result);
9621                 }
9622             }
9623             if(builder) IUriBuilder_Release(builder);
9624         }
9625         if(uri) IUri_Release(uri);
9626         heap_free(uriW);
9627     }
9628 }
9629
9630 static void test_IUriBuilder_Misc(void) {
9631     HRESULT hr;
9632     IUri *uri;
9633
9634     hr = pCreateUri(http_urlW, 0, 0, &uri);
9635     if(SUCCEEDED(hr)) {
9636         IUriBuilder *builder;
9637
9638         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9639         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9640         if(SUCCEEDED(hr)) {
9641             BOOL has = -1;
9642             DWORD port = -1;
9643
9644             hr = IUriBuilder_GetPort(builder, &has, &port);
9645             ok(hr == S_OK, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9646             if(SUCCEEDED(hr)) {
9647                 /* 'has' will be set to FALSE, even though uri had a port. */
9648                 ok(has == FALSE, "Error: Expected 'has' to be FALSE, was %d instead.\n", has);
9649                 /* Still sets 'port' to 80. */
9650                 ok(port == 80, "Error: Expected the port to be 80, but, was %d instead.\n", port);
9651             }
9652         }
9653         if(builder) IUriBuilder_Release(builder);
9654     }
9655     if(uri) IUri_Release(uri);
9656 }
9657
9658 static void test_IUriBuilderFactory(void) {
9659     HRESULT hr;
9660     IUri *uri;
9661     IUriBuilderFactory *factory;
9662     IUriBuilder *builder;
9663
9664     hr = pCreateUri(http_urlW, 0, 0, &uri);
9665     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9666     if(SUCCEEDED(hr)) {
9667         factory = NULL;
9668         hr = IUri_QueryInterface(uri, &IID_IUriBuilderFactory, (void**)&factory);
9669         ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x.\n", hr);
9670         ok(factory != NULL, "Error: Expected 'factory' to not be NULL.\n");
9671
9672         if(SUCCEEDED(hr)) {
9673             builder = (void*) 0xdeadbeef;
9674             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 10, 0, &builder);
9675             ok(hr == E_INVALIDARG, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9676                 hr, E_INVALIDARG);
9677             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9678
9679             builder = (void*) 0xdeadbeef;
9680             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 10, &builder);
9681             ok(hr == E_INVALIDARG, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9682                 hr, E_INVALIDARG);
9683             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9684
9685             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 0, NULL);
9686             ok(hr == E_POINTER, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9687                 hr, E_POINTER);
9688
9689             builder = NULL;
9690             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 0, &builder);
9691             ok(hr == S_OK, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9692                 hr, S_OK);
9693             if(SUCCEEDED(hr)) {
9694                 IUri *tmp = (void*) 0xdeadbeef;
9695                 LPCWSTR result;
9696                 DWORD result_len;
9697
9698                 hr = IUriBuilder_GetIUri(builder, &tmp);
9699                 ok(hr == S_OK, "Error: GetIUri returned 0x%08x, expected 0x%08x.\n",
9700                     hr, S_OK);
9701                 ok(!tmp, "Error: Expected 'tmp' to be NULL, but was %p instead.\n", tmp);
9702
9703                 hr = IUriBuilder_GetHost(builder, &result_len, &result);
9704                 ok(hr == S_FALSE, "Error: GetHost returned 0x%08x, expected 0x%08x.\n",
9705                     hr, S_FALSE);
9706             }
9707             if(builder) IUriBuilder_Release(builder);
9708
9709             builder = (void*) 0xdeadbeef;
9710             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 10, 0, &builder);
9711             ok(hr == E_INVALIDARG, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9712                 hr, E_INVALIDARG);
9713             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9714
9715             builder = (void*) 0xdeadbeef;
9716             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 10, &builder);
9717             ok(hr == E_INVALIDARG, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9718                 hr, E_INVALIDARG);
9719             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9720
9721             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 0, NULL);
9722             ok(hr == E_POINTER, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9723                 hr, E_POINTER);
9724
9725             builder = NULL;
9726             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 0, &builder);
9727             ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9728                 hr, S_OK);
9729             if(SUCCEEDED(hr)) {
9730                 IUri *tmp = NULL;
9731
9732                 hr = IUriBuilder_GetIUri(builder, &tmp);
9733                 ok(hr == S_OK, "Error: GetIUri return 0x%08x, expected 0x%08x.\n",
9734                     hr, S_OK);
9735                 ok(tmp == uri, "Error: Expected tmp to be %p, but was %p.\n", uri, tmp);
9736                 if(uri) IUri_Release(uri);
9737             }
9738             if(builder) IUriBuilder_Release(builder);
9739         }
9740         if(factory) IUriBuilderFactory_Release(factory);
9741     }
9742     if(uri) IUri_Release(uri);
9743 }
9744
9745 static void test_CoInternetCombineIUri(void) {
9746     HRESULT hr;
9747     IUri *base, *relative, *result;
9748     DWORD i;
9749
9750     base = NULL;
9751     hr = pCreateUri(http_urlW, 0, 0, &base);
9752     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9753     if(SUCCEEDED(hr)) {
9754         result = (void*) 0xdeadbeef;
9755         hr = pCoInternetCombineIUri(base, NULL, 0, &result, 0);
9756         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9757         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9758     }
9759
9760     relative = NULL;
9761     hr = pCreateUri(http_urlW, 0, 0, &relative);
9762     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9763     if(SUCCEEDED(hr)) {
9764         result = (void*) 0xdeadbeef;
9765         hr = pCoInternetCombineIUri(NULL, relative, 0, &result, 0);
9766         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9767         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9768     }
9769
9770     hr = pCoInternetCombineIUri(base, relative, 0, NULL, 0);
9771     ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9772
9773     if(base) IUri_Release(base);
9774     if(relative) IUri_Release(relative);
9775
9776     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
9777         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
9778
9779         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
9780         ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9781         if(SUCCEEDED(hr)) {
9782             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
9783
9784             hr = pCreateUri(relativeW, uri_combine_tests[i].relative_create_flags, 0, &relative);
9785             ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9786             if(SUCCEEDED(hr)) {
9787                 result = NULL;
9788
9789                 hr = pCoInternetCombineIUri(base, relative, uri_combine_tests[i].combine_flags, &result, 0);
9790                 if(uri_combine_tests[i].todo) {
9791                     todo_wine {
9792                         ok(hr == uri_combine_tests[i].expected,
9793                             "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9794                             hr, uri_combine_tests[i].expected, i);
9795                     }
9796                 } else {
9797                     ok(hr == uri_combine_tests[i].expected,
9798                         "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9799                         hr, uri_combine_tests[i]. expected, i);
9800                 }
9801                 if(SUCCEEDED(hr)) {
9802                     DWORD j;
9803
9804                     for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
9805                         uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
9806                         BSTR received;
9807
9808                         hr = IUri_GetPropertyBSTR(result, j, &received, 0);
9809                         if(prop.todo) {
9810                             todo_wine {
9811                                 ok(hr == prop.expected,
9812                                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9813                                     hr, prop.expected, i, j);
9814                             }
9815                             todo_wine {
9816                                 ok(!strcmp_aw(prop.value, received) ||
9817                                    broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9818                                     "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9819                                     prop.value, wine_dbgstr_w(received), i, j);
9820                             }
9821                         } else {
9822                             ok(hr == prop.expected,
9823                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9824                                 hr, prop.expected, i, j);
9825                             ok(!strcmp_aw(prop.value, received) ||
9826                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9827                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9828                                 prop.value, wine_dbgstr_w(received), i, j);
9829                         }
9830                         SysFreeString(received);
9831                     }
9832
9833                     for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
9834                         uri_dword_property prop = uri_combine_tests[i].dword_props[j];
9835                         DWORD received;
9836
9837                         hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
9838                         if(prop.todo) {
9839                             todo_wine {
9840                                 ok(hr == prop.expected,
9841                                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9842                                     hr, prop.expected, i, j);
9843                             }
9844                             todo_wine {
9845                                 ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9846                                     prop.value, received, i, j);
9847                             }
9848                         } else {
9849                             ok(hr == prop.expected,
9850                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9851                                 hr, prop.expected, i, j);
9852                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9853                                 prop.value, received, i, j);
9854                         }
9855                     }
9856                 }
9857                 if(result) IUri_Release(result);
9858             }
9859             if(relative) IUri_Release(relative);
9860             heap_free(relativeW);
9861         }
9862         if(base) IUri_Release(base);
9863         heap_free(baseW);
9864     }
9865 }
9866
9867 static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface,
9868                                                           REFIID riid, void **ppv)
9869 {
9870     ok(0, "unexpected call\n");
9871     return E_NOINTERFACE;
9872 }
9873
9874 static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
9875 {
9876     return 2;
9877 }
9878
9879 static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
9880 {
9881     return 1;
9882 }
9883
9884 static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
9885         PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
9886         DWORD *pcchResult, DWORD dwReserved)
9887 {
9888     CHECK_EXPECT(ParseUrl);
9889     ok(!lstrcmpW(pwzUrl, parse_urlW), "Error: Expected %s, but got %s instead.\n",
9890         wine_dbgstr_w(parse_urlW), wine_dbgstr_w(pwzUrl));
9891     ok(ParseAction == parse_action, "Error: Expected %d, but got %d.\n", parse_action, ParseAction);
9892     ok(dwParseFlags == parse_flags, "Error: Expected 0x%08x, but got 0x%08x.\n", parse_flags, dwParseFlags);
9893     ok(cchResult == 200, "Error: Got %d.\n", cchResult);
9894
9895     memcpy(pwzResult, parse_resultW, sizeof(parse_resultW));
9896     *pcchResult = lstrlenW(parse_resultW);
9897
9898     return S_OK;
9899 }
9900
9901 static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
9902         LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags,
9903         LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
9904 {
9905     CHECK_EXPECT(CombineUrl);
9906     ok(!lstrcmpW(pwzBaseUrl, combine_baseW), "Error: Expected %s, but got %s instead.\n",
9907         wine_dbgstr_w(combine_baseW), wine_dbgstr_w(pwzBaseUrl));
9908     ok(!lstrcmpW(pwzRelativeUrl, combine_relativeW), "Error: Expected %s, but got %s instead.\n",
9909         wine_dbgstr_w(combine_relativeW), wine_dbgstr_w(pwzRelativeUrl));
9910     ok(dwCombineFlags == (URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO),
9911         "Error: Expected 0, but got 0x%08x.\n", dwCombineFlags);
9912     ok(cchResult == INTERNET_MAX_URL_LENGTH+1, "Error: Got %d.\n", cchResult);
9913
9914     memcpy(pwzResult, combine_resultW, sizeof(combine_resultW));
9915     *pcchResult = lstrlenW(combine_resultW);
9916
9917     return S_OK;
9918 }
9919
9920 static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface,
9921         LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
9922 {
9923     ok(0, "unexpected call\n");
9924     return E_NOTIMPL;
9925 }
9926
9927 static HRESULT WINAPI InternetProtocolInfo_QueryInfo(IInternetProtocolInfo *iface,
9928         LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer,
9929         DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
9930 {
9931     ok(0, "unexpected call\n");
9932     return E_NOTIMPL;
9933 }
9934
9935 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl = {
9936     InternetProtocolInfo_QueryInterface,
9937     InternetProtocolInfo_AddRef,
9938     InternetProtocolInfo_Release,
9939     InternetProtocolInfo_ParseUrl,
9940     InternetProtocolInfo_CombineUrl,
9941     InternetProtocolInfo_CompareUrl,
9942     InternetProtocolInfo_QueryInfo
9943 };
9944
9945 static IInternetProtocolInfo protocol_info = { &InternetProtocolInfoVtbl };
9946
9947 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
9948 {
9949     if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
9950         *ppv = &protocol_info;
9951         return S_OK;
9952     }
9953
9954     ok(0, "unexpected call\n");
9955     return E_NOINTERFACE;
9956 }
9957
9958 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
9959 {
9960     return 2;
9961 }
9962
9963 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
9964 {
9965     return 1;
9966 }
9967
9968 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
9969                                         REFIID riid, void **ppv)
9970 {
9971     ok(0, "unexpected call\n");
9972     return E_NOTIMPL;
9973 }
9974
9975 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
9976 {
9977     ok(0, "unexpected call\n");
9978     return S_OK;
9979 }
9980
9981 static const IClassFactoryVtbl ClassFactoryVtbl = {
9982     ClassFactory_QueryInterface,
9983     ClassFactory_AddRef,
9984     ClassFactory_Release,
9985     ClassFactory_CreateInstance,
9986     ClassFactory_LockServer
9987 };
9988
9989 static IClassFactory protocol_cf = { &ClassFactoryVtbl };
9990
9991 static void register_protocols(void)
9992 {
9993     IInternetSession *session;
9994     HRESULT hres;
9995
9996     hres = pCoInternetGetSession(0, &session, 0);
9997     ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
9998     if(FAILED(hres))
9999         return;
10000
10001     hres = IInternetSession_RegisterNameSpace(session, &protocol_cf, &IID_NULL,
10002             winetestW, 0, NULL, 0);
10003     ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
10004
10005     IInternetSession_Release(session);
10006 }
10007
10008 static void unregister_protocols(void) {
10009     IInternetSession *session;
10010     HRESULT hr;
10011
10012     hr = pCoInternetGetSession(0, &session, 0);
10013     ok(hr == S_OK, "CoInternetGetSession failed: 0x%08x\n", hr);
10014     if(FAILED(hr))
10015         return;
10016
10017     hr = IInternetSession_UnregisterNameSpace(session, &protocol_cf, winetestW);
10018     ok(hr == S_OK, "UnregisterNameSpace failed: 0x%08x\n", hr);
10019
10020     IInternetSession_Release(session);
10021 }
10022
10023 static void test_CoInternetCombineIUri_Pluggable(void) {
10024     HRESULT hr;
10025     IUri *base = NULL;
10026
10027     hr = pCreateUri(combine_baseW, 0, 0, &base);
10028     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10029     if(SUCCEEDED(hr)) {
10030         IUri *relative = NULL;
10031
10032         hr = pCreateUri(combine_relativeW, Uri_CREATE_ALLOW_RELATIVE, 0, &relative);
10033         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10034         if(SUCCEEDED(hr)) {
10035             IUri *result = NULL;
10036
10037             SET_EXPECT(CombineUrl);
10038
10039             hr = pCoInternetCombineIUri(base, relative, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
10040                                         &result, 0);
10041             ok(hr == S_OK, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
10042
10043             CHECK_CALLED(CombineUrl);
10044
10045             if(SUCCEEDED(hr)) {
10046                 BSTR received = NULL;
10047                 hr = IUri_GetAbsoluteUri(result, &received);
10048                 ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
10049                 if(SUCCEEDED(hr)) {
10050                     ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
10051                         wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
10052                 }
10053                 SysFreeString(received);
10054             }
10055             if(result) IUri_Release(result);
10056         }
10057         if(relative) IUri_Release(relative);
10058     }
10059     if(base) IUri_Release(base);
10060 }
10061
10062 static void test_CoInternetCombineUrlEx(void) {
10063     HRESULT hr;
10064     IUri *base, *result;
10065     DWORD i;
10066
10067     base = NULL;
10068     hr = pCreateUri(http_urlW, 0, 0, &base);
10069     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10070     if(SUCCEEDED(hr)) {
10071         result = (void*) 0xdeadbeef;
10072         hr = pCoInternetCombineUrlEx(base, NULL, 0, &result, 0);
10073         ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
10074             hr, E_UNEXPECTED);
10075         ok(!result, "Error: Expected 'result' to be NULL was %p instead.\n", result);
10076     }
10077
10078     result = (void*) 0xdeadbeef;
10079     hr = pCoInternetCombineUrlEx(NULL, http_urlW, 0, &result, 0);
10080     ok(hr == E_INVALIDARG, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
10081         hr, E_INVALIDARG);
10082     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
10083
10084     result = (void*) 0xdeadbeef;
10085     hr = pCoInternetCombineUrlEx(NULL, NULL, 0, &result, 0);
10086     ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
10087         hr, E_UNEXPECTED);
10088     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
10089
10090     hr = pCoInternetCombineUrlEx(base, http_urlW, 0, NULL, 0);
10091     ok(hr == E_POINTER, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
10092         hr, E_POINTER);
10093     if(base) IUri_Release(base);
10094
10095     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
10096         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
10097
10098         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
10099         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_combine_tests[%d].\n", hr, i);
10100         if(SUCCEEDED(hr)) {
10101             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
10102
10103             hr = pCoInternetCombineUrlEx(base, relativeW, uri_combine_tests[i].combine_flags,
10104                                          &result, 0);
10105             if(uri_combine_tests[i].todo) {
10106                 todo_wine {
10107                     ok(hr == uri_combine_tests[i].expected,
10108                         "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
10109                         hr, uri_combine_tests[i].expected, i);
10110                 }
10111             } else {
10112                 ok(hr == uri_combine_tests[i].expected,
10113                     "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
10114                     hr, uri_combine_tests[i]. expected, i);
10115             }
10116             if(SUCCEEDED(hr)) {
10117                 DWORD j;
10118
10119                 for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
10120                     uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
10121                     BSTR received;
10122                     LPCSTR value = (prop.value_ex) ? prop.value_ex : prop.value;
10123
10124                     hr = IUri_GetPropertyBSTR(result, j, &received, 0);
10125                     if(prop.todo) {
10126                         todo_wine {
10127                             ok(hr == prop.expected,
10128                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
10129                                 hr, prop.expected, i, j);
10130                         }
10131                         todo_wine {
10132                             ok(!strcmp_aw(value, received) ||
10133                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
10134                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
10135                                 value, wine_dbgstr_w(received), i, j);
10136                         }
10137                     } else {
10138                         ok(hr == prop.expected,
10139                             "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
10140                             hr, prop.expected, i, j);
10141                         ok(!strcmp_aw(value, received) ||
10142                            broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
10143                             "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
10144                             value, wine_dbgstr_w(received), i, j);
10145                     }
10146                     SysFreeString(received);
10147                 }
10148
10149                 for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
10150                     uri_dword_property prop = uri_combine_tests[i].dword_props[j];
10151                     DWORD received;
10152
10153                     hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
10154                     if(prop.todo) {
10155                         todo_wine {
10156                             ok(hr == prop.expected,
10157                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
10158                                 hr, prop.expected, i, j);
10159                         }
10160                         todo_wine {
10161                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
10162                                 prop.value, received, i, j);
10163                         }
10164                     } else {
10165                         ok(hr == prop.expected,
10166                             "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
10167                             hr, prop.expected, i, j);
10168                         ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
10169                             prop.value, received, i, j);
10170                     }
10171                 }
10172             }
10173             if(result) IUri_Release(result);
10174             heap_free(relativeW);
10175         }
10176         if(base) IUri_Release(base);
10177         heap_free(baseW);
10178     }
10179 }
10180
10181 static void test_CoInternetCombineUrlEx_Pluggable(void) {
10182     HRESULT hr;
10183     IUri *base = NULL;
10184
10185     hr = pCreateUri(combine_baseW, 0, 0, &base);
10186     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10187     if(SUCCEEDED(hr)) {
10188         IUri *result = NULL;
10189
10190         SET_EXPECT(CombineUrl);
10191
10192         hr = pCoInternetCombineUrlEx(base, combine_relativeW, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
10193                                      &result, 0);
10194         ok(hr == S_OK, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
10195
10196         CHECK_CALLED(CombineUrl);
10197
10198         if(SUCCEEDED(hr)) {
10199             BSTR received = NULL;
10200             hr = IUri_GetAbsoluteUri(result, &received);
10201             ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
10202             if(SUCCEEDED(hr)) {
10203                 ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
10204                     wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
10205             }
10206             SysFreeString(received);
10207         }
10208         if(result) IUri_Release(result);
10209     }
10210     if(base) IUri_Release(base);
10211 }
10212
10213 static void test_CoInternetParseIUri_InvalidArgs(void) {
10214     HRESULT hr;
10215     IUri *uri = NULL;
10216     WCHAR tmp[3];
10217     DWORD result = -1;
10218
10219     hr = pCoInternetParseIUri(NULL, PARSE_CANONICALIZE, 0, tmp, 3, &result, 0);
10220     ok(hr == E_INVALIDARG, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10221         hr, E_INVALIDARG);
10222     ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10223
10224     hr = pCreateUri(http_urlW, 0, 0, &uri);
10225     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10226     if(SUCCEEDED(hr)) {
10227         DWORD expected_len;
10228
10229         result = -1;
10230         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, NULL, 0, &result, 0);
10231         ok(hr == E_INVALIDARG, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10232             hr, E_INVALIDARG);
10233         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10234
10235         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, tmp, 3, NULL, 0);
10236         ok(hr == E_POINTER, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10237             hr, E_POINTER);
10238
10239         result = -1;
10240         hr = pCoInternetParseIUri(uri, PARSE_SECURITY_URL, 0, tmp, 3, &result, 0);
10241         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x expected 0x%08x.\n",
10242             hr, E_FAIL);
10243         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10244
10245         result = -1;
10246         hr = pCoInternetParseIUri(uri, PARSE_MIME, 0, tmp, 3, &result, 0);
10247         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10248             hr, E_FAIL);
10249         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10250
10251         result = -1;
10252         hr = pCoInternetParseIUri(uri, PARSE_SERVER, 0, tmp, 3, &result, 0);
10253         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10254             hr, E_FAIL);
10255         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10256
10257         result = -1;
10258         hr = pCoInternetParseIUri(uri, PARSE_SECURITY_DOMAIN, 0, tmp, 3, &result, 0);
10259         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10260             hr, E_FAIL);
10261         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10262
10263         expected_len = lstrlenW(http_urlW);
10264         result = -1;
10265         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, tmp, 3, &result, 0);
10266         ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER,
10267             "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10268             hr, STRSAFE_E_INSUFFICIENT_BUFFER);
10269         ok(result == expected_len, "Error: Expected 'result' to be %d, but was %d instead.\n",
10270             expected_len, result);
10271     }
10272     if(uri) IUri_Release(uri);
10273 }
10274
10275 static void test_CoInternetParseIUri(void) {
10276     DWORD i;
10277
10278     for(i = 0; i < sizeof(uri_parse_tests)/sizeof(uri_parse_tests[0]); ++i) {
10279         HRESULT hr;
10280         IUri *uri;
10281         LPWSTR uriW;
10282         uri_parse_test test = uri_parse_tests[i];
10283
10284         uriW = a2w(test.uri);
10285         hr = pCreateUri(uriW, test.uri_flags, 0, &uri);
10286         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_parse_tests[%d].\n", hr, i);
10287         if(SUCCEEDED(hr)) {
10288             WCHAR result[INTERNET_MAX_URL_LENGTH+1];
10289             DWORD result_len = -1;
10290
10291             hr = pCoInternetParseIUri(uri, test.action, test.flags, result, INTERNET_MAX_URL_LENGTH+1, &result_len, 0);
10292             if(test.todo) {
10293                 todo_wine {
10294                     ok(hr == test.expected,
10295                         "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x on uri_parse_tests[%d].\n",
10296                         hr, test.expected, i);
10297                 }
10298             } else {
10299                 ok(hr == test.expected,
10300                     "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x on uri_parse_tests[%d].\n",
10301                     hr, test.expected, i);
10302             }
10303             if(SUCCEEDED(hr)) {
10304                 DWORD len = lstrlenA(test.property);
10305                 ok(!strcmp_aw(test.property, result),
10306                     "Error: Expected %s but got %s instead on uri_parse_tests[%d].\n",
10307                     test.property, wine_dbgstr_w(result), i);
10308                 ok(len == result_len,
10309                     "Error: Expected %d, but got %d instead on uri_parse_tests[%d].\n",
10310                     len, result_len, i);
10311             } else {
10312                 ok(!result_len,
10313                     "Error: Expected 'result_len' to be 0, but was %d on uri_parse_tests[%d].\n",
10314                     result_len, i);
10315             }
10316         }
10317         if(uri) IUri_Release(uri);
10318         heap_free(uriW);
10319     }
10320 }
10321
10322 static void test_CoInternetParseIUri_Pluggable(void) {
10323     HRESULT hr;
10324     IUri *uri = NULL;
10325
10326     hr = pCreateUri(parse_urlW, 0, 0, &uri);
10327     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, but got 0x%08x.\n", hr);
10328     if(SUCCEEDED(hr)) {
10329         WCHAR result[200];
10330         DWORD result_len;
10331
10332         SET_EXPECT(ParseUrl);
10333
10334         parse_action = PARSE_CANONICALIZE;
10335         parse_flags = URL_UNESCAPE|URL_ESCAPE_UNSAFE;
10336
10337         hr = pCoInternetParseIUri(uri, parse_action, parse_flags, result, 200, &result_len, 0);
10338         ok(hr == S_OK, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
10339
10340         CHECK_CALLED(ParseUrl);
10341
10342         if(SUCCEEDED(hr)) {
10343             ok(result_len == lstrlenW(parse_resultW), "Error: Expected %d, but got %d.\n",
10344                 lstrlenW(parse_resultW), result_len);
10345             ok(!lstrcmpW(result, parse_resultW), "Error: Expected %s, but got %s.\n",
10346                 wine_dbgstr_w(parse_resultW), wine_dbgstr_w(result));
10347         }
10348     }
10349     if(uri) IUri_Release(uri);
10350 }
10351
10352 typedef struct {
10353     const char *url;
10354     DWORD uri_flags;
10355     const char *base_url;
10356     DWORD base_uri_flags;
10357     const char *legacy_url;
10358     const char *uniform_url;
10359     const char *no_canon_url;
10360     const char *uri_url;
10361 } create_urlmon_test_t;
10362
10363 static const create_urlmon_test_t create_urlmon_tests[] = {
10364     {
10365         "http://www.winehq.org",Uri_CREATE_NO_CANONICALIZE,
10366         NULL,0,
10367         "http://www.winehq.org/",
10368         "http://www.winehq.org/",
10369         "http://www.winehq.org",
10370         "http://www.winehq.org"
10371     },
10372     {
10373         "file://c:\\dir\\file.txt",Uri_CREATE_NO_CANONICALIZE,
10374         NULL,0,
10375         "file://c:\\dir\\file.txt",
10376         "file:///c:/dir/file.txt",
10377         "file:///c:/dir/file.txt",
10378         "file:///c:/dir/file.txt"
10379     },
10380     {
10381         "file://c:\\dir\\file.txt",Uri_CREATE_FILE_USE_DOS_PATH,
10382         NULL,0,
10383         "file://c:\\dir\\file.txt",
10384         "file:///c:/dir/file.txt",
10385         "file:///c:/dir/file.txt",
10386         "file://c:\\dir\\file.txt"
10387     },
10388     {
10389         "dat%61",Uri_CREATE_ALLOW_RELATIVE,
10390         "http://www.winehq.org",0,
10391         "http://www.winehq.org/data",
10392         "http://www.winehq.org/data",
10393         "http://www.winehq.org:80/data",
10394     },
10395     {
10396         "file.txt",Uri_CREATE_ALLOW_RELATIVE,
10397         "file://c:\\dir\\x.txt",Uri_CREATE_NO_CANONICALIZE,
10398         "file://c:\\dir\\file.txt",
10399         "file:///c:/dir/file.txt",
10400         "file:///c:/dir/file.txt",
10401     },
10402     {
10403         "",Uri_CREATE_ALLOW_RELATIVE,
10404         NULL,0,
10405         "",
10406         "",
10407         "",
10408         ""
10409     },
10410     {
10411         "test",Uri_CREATE_ALLOW_RELATIVE,
10412         NULL,0,
10413         "test",
10414         "test",
10415         "test",
10416         "test"
10417     },
10418     {
10419         "c:\\dir\\file.txt",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME,
10420         NULL,0,
10421         "file://c:\\dir\\file.txt",
10422         "file:///c:/dir/file.txt",
10423         "file:///c:/dir/file.txt",
10424         "file:///c:/dir/file.txt",
10425     }
10426 };
10427
10428 #define test_urlmon_display_name(a,b) _test_urlmon_display_name(__LINE__,a,b)
10429 static void _test_urlmon_display_name(unsigned line, IMoniker *mon, const char *exurl)
10430 {
10431     WCHAR *display_name;
10432     HRESULT hres;
10433
10434     hres = IMoniker_GetDisplayName(mon, NULL, NULL, &display_name);
10435     ok_(__FILE__,line)(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
10436     ok_(__FILE__,line)(!strcmp_aw(exurl, display_name), "unexpected display name: %s, expected %s\n",
10437             wine_dbgstr_w(display_name), exurl);
10438
10439     CoTaskMemFree(display_name);
10440 }
10441
10442 #define test_display_uri(a,b) _test_display_uri(__LINE__,a,b)
10443 static void _test_display_uri(unsigned line, IMoniker *mon, const char *exurl)
10444 {
10445     IUriContainer *uri_container;
10446     IUri *uri;
10447     BSTR display_uri;
10448     HRESULT hres;
10449
10450     hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container);
10451     ok(hres == S_OK, "Could not get IUriContainer iface: %08x\n", hres);
10452
10453     uri = NULL;
10454     hres = IUriContainer_GetIUri(uri_container, &uri);
10455     IUriContainer_Release(uri_container);
10456     ok(hres == S_OK, "GetIUri failed: %08x\n", hres);
10457     ok(uri != NULL, "uri == NULL\n");
10458
10459     hres = IUri_GetDisplayUri(uri, &display_uri);
10460     IUri_Release(uri);
10461     ok(hres == S_OK, "GetDisplayUri failed: %08x\n", hres);
10462     ok_(__FILE__,line)(!strcmp_aw(exurl, display_uri), "unexpected display uri: %s, expected %s\n",
10463             wine_dbgstr_w(display_uri), exurl);
10464     SysFreeString(display_uri);
10465 }
10466
10467 static void test_CreateURLMoniker(void)
10468 {
10469     const create_urlmon_test_t *test;
10470     IMoniker *mon, *base_mon;
10471     WCHAR *url, *base_url;
10472     IUri *uri, *base_uri;
10473     HRESULT hres;
10474
10475     for(test = create_urlmon_tests; test < create_urlmon_tests + sizeof(create_urlmon_tests)/sizeof(*create_urlmon_tests); test++) {
10476         url = a2w(test->url);
10477         base_url = a2w(test->base_url);
10478
10479         if(base_url) {
10480             hres = pCreateUri(base_url, test->base_uri_flags, 0, &base_uri);
10481             ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
10482
10483             hres = pCreateURLMonikerEx2(NULL, base_uri, &base_mon, URL_MK_NO_CANONICALIZE);
10484             ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10485         }else {
10486             base_uri = NULL;
10487             base_mon = NULL;
10488         }
10489
10490         hres = CreateURLMoniker(base_mon, url, &mon);
10491         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10492         test_urlmon_display_name(mon, test->legacy_url);
10493         test_display_uri(mon, test->legacy_url);
10494         IMoniker_Release(mon);
10495
10496         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_LEGACY);
10497         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10498         test_urlmon_display_name(mon, test->legacy_url);
10499         test_display_uri(mon, test->legacy_url);
10500         IMoniker_Release(mon);
10501
10502         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_UNIFORM);
10503         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10504         test_urlmon_display_name(mon, test->uniform_url);
10505         test_display_uri(mon, test->uniform_url);
10506         IMoniker_Release(mon);
10507
10508         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_NO_CANONICALIZE);
10509         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10510         test_urlmon_display_name(mon, test->no_canon_url);
10511         test_display_uri(mon, test->no_canon_url);
10512         IMoniker_Release(mon);
10513
10514         hres = pCreateUri(url, test->uri_flags, 0, &uri);
10515         ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
10516
10517         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_LEGACY);
10518         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10519         test_urlmon_display_name(mon, base_url ? test->legacy_url : test->uri_url);
10520         test_display_uri(mon, base_url ? test->legacy_url : test->uri_url);
10521         IMoniker_Release(mon);
10522
10523         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_UNIFORM);
10524         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10525         test_urlmon_display_name(mon, base_url ? test->uniform_url : test->uri_url);
10526         test_display_uri(mon, base_url ? test->uniform_url : test->uri_url);
10527         IMoniker_Release(mon);
10528
10529         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_NO_CANONICALIZE);
10530         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10531         test_urlmon_display_name(mon, base_url ? test->no_canon_url : test->uri_url);
10532         test_display_uri(mon, base_url ? test->no_canon_url : test->uri_url);
10533         IMoniker_Release(mon);
10534
10535         IUri_Release(uri);
10536         heap_free(url);
10537         heap_free(base_url);
10538         if(base_uri)
10539             IUri_Release(base_uri);
10540         if(base_mon)
10541             IMoniker_Release(base_mon);
10542     }
10543 }
10544
10545 START_TEST(uri) {
10546     HMODULE hurlmon;
10547
10548     hurlmon = GetModuleHandle("urlmon.dll");
10549     pCoInternetGetSession = (void*) GetProcAddress(hurlmon, "CoInternetGetSession");
10550     pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri");
10551     pCreateUriWithFragment = (void*) GetProcAddress(hurlmon, "CreateUriWithFragment");
10552     pCreateIUriBuilder = (void*) GetProcAddress(hurlmon, "CreateIUriBuilder");
10553     pCoInternetCombineIUri = (void*) GetProcAddress(hurlmon, "CoInternetCombineIUri");
10554     pCoInternetCombineUrlEx = (void*) GetProcAddress(hurlmon, "CoInternetCombineUrlEx");
10555     pCoInternetParseIUri = (void*) GetProcAddress(hurlmon, "CoInternetParseIUri");
10556     pCreateURLMonikerEx = (void*) GetProcAddress(hurlmon, "CreateURLMonikerEx");
10557     pCreateURLMonikerEx2 = (void*) GetProcAddress(hurlmon, "CreateURLMonikerEx2");
10558
10559     if(!pCreateUri) {
10560         win_skip("CreateUri is not present, skipping tests.\n");
10561         return;
10562     }
10563
10564     trace("test CreateUri invalid flags...\n");
10565     test_CreateUri_InvalidFlags();
10566
10567     trace("test CreateUri invalid args...\n");
10568     test_CreateUri_InvalidArgs();
10569
10570     trace("test CreateUri invalid URIs...\n");
10571     test_CreateUri_InvalidUri();
10572
10573     trace("test IUri_GetPropertyBSTR...\n");
10574     test_IUri_GetPropertyBSTR();
10575
10576     trace("test IUri_GetPropertyDWORD...\n");
10577     test_IUri_GetPropertyDWORD();
10578
10579     trace("test IUri_GetStrProperties...\n");
10580     test_IUri_GetStrProperties();
10581
10582     trace("test IUri_GetDwordProperties...\n");
10583     test_IUri_GetDwordProperties();
10584
10585     trace("test IUri_GetPropertyLength...\n");
10586     test_IUri_GetPropertyLength();
10587
10588     trace("test IUri_GetProperties...\n");
10589     test_IUri_GetProperties();
10590
10591     trace("test IUri_HasProperty...\n");
10592     test_IUri_HasProperty();
10593
10594     trace("test IUri_IsEqual...\n");
10595     test_IUri_IsEqual();
10596
10597     trace("test CreateUriWithFragment invalid args...\n");
10598     test_CreateUriWithFragment_InvalidArgs();
10599
10600     trace("test CreateUriWithFragment invalid flags...\n");
10601     test_CreateUriWithFragment_InvalidFlags();
10602
10603     trace("test CreateUriWithFragment...\n");
10604     test_CreateUriWithFragment();
10605
10606     trace("test CreateIUriBuilder...\n");
10607     test_CreateIUriBuilder();
10608
10609     trace("test IUriBuilder_CreateInvalidArgs...\n");
10610     test_IUriBuilder_CreateInvalidArgs();
10611
10612     trace("test IUriBuilder...\n");
10613     test_IUriBuilder();
10614
10615     trace("test IUriBuilder_GetInvalidArgs...\n");
10616     test_IUriBuilder_GetInvalidArgs();
10617
10618     trace("test IUriBuilder_HasBeenModified...\n");
10619     test_IUriBuilder_HasBeenModified();
10620
10621     trace("test IUriBuilder_IUriProperty...\n");
10622     test_IUriBuilder_IUriProperty();
10623
10624     trace("test IUriBuilder_RemoveProperties...\n");
10625     test_IUriBuilder_RemoveProperties();
10626
10627     trace("test IUriBuilder miscellaneous...\n");
10628     test_IUriBuilder_Misc();
10629
10630     trace("test IUriBuilderFactory...\n");
10631     test_IUriBuilderFactory();
10632
10633     trace("test CoInternetCombineIUri...\n");
10634     test_CoInternetCombineIUri();
10635
10636     trace("test CoInternetCombineUrlEx...\n");
10637     test_CoInternetCombineUrlEx();
10638
10639     trace("test CoInternetParseIUri Invalid Args...\n");
10640     test_CoInternetParseIUri_InvalidArgs();
10641
10642     trace("test CoInternetParseIUri...\n");
10643     test_CoInternetParseIUri();
10644
10645     register_protocols();
10646
10647     trace("test CoInternetCombineIUri pluggable...\n");
10648     test_CoInternetCombineIUri_Pluggable();
10649
10650     trace("test CoInternetCombineUrlEx Pluggable...\n");
10651     test_CoInternetCombineUrlEx_Pluggable();
10652
10653     trace("test CoInternetParseIUri pluggable...\n");
10654     test_CoInternetParseIUri_Pluggable();
10655
10656     trace("test CreateURLMoniker...\n");
10657     test_CreateURLMoniker();
10658
10659     unregister_protocols();
10660 }