urlmon: Improve parsing of SCHEME_MK URIs.
[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     BOOL        create_todo_a;
4422     const char* b;
4423     DWORD       create_flags_b;
4424     BOOL        create_todo_b;
4425     BOOL        equal;
4426     BOOL        todo;
4427 } uri_equality;
4428
4429 static const uri_equality equality_tests[] = {
4430     {
4431         "HTTP://www.winehq.org/test dir/./",0,FALSE,
4432         "http://www.winehq.org/test dir/../test dir/",0,FALSE,
4433         TRUE, FALSE
4434     },
4435     {
4436         /* http://www.winehq.org/test%20dir */
4437         "http://%77%77%77%2E%77%69%6E%65%68%71%2E%6F%72%67/%74%65%73%74%20%64%69%72",0,FALSE,
4438         "http://www.winehq.org/test dir",0,FALSE,
4439         TRUE, FALSE
4440     },
4441     {
4442         "c:\\test.mp3",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME,FALSE,
4443         "file:///c:/test.mp3",0,FALSE,
4444         TRUE, FALSE
4445     },
4446     {
4447         "ftp://ftp.winehq.org/",0,FALSE,
4448         "ftp://ftp.winehq.org",0,FALSE,
4449         TRUE, FALSE
4450     },
4451     {
4452         "ftp://ftp.winehq.org/test/test2/../../testB/",0,FALSE,
4453         "ftp://ftp.winehq.org/t%45stB/",0,FALSE,
4454         FALSE, FALSE
4455     },
4456     {
4457         "http://google.com/TEST",0,FALSE,
4458         "http://google.com/test",0,FALSE,
4459         FALSE, FALSE
4460     },
4461     {
4462         "http://GOOGLE.com/",0,FALSE,
4463         "http://google.com/",0,FALSE,
4464         TRUE, FALSE
4465     },
4466     /* Performs case insensitive compare of host names (for known scheme types). */
4467     {
4468         "ftp://GOOGLE.com/",Uri_CREATE_NO_CANONICALIZE,FALSE,
4469         "ftp://google.com/",0,FALSE,
4470         TRUE, FALSE
4471     },
4472     {
4473         "zip://GOOGLE.com/",0,FALSE,
4474         "zip://google.com/",0,FALSE,
4475         FALSE, FALSE
4476     },
4477     {
4478         "file:///c:/TEST/TeST/",0,FALSE,
4479         "file:///c:/test/test/",0,FALSE,
4480         TRUE, FALSE
4481     },
4482     {
4483         "file:///server/TEST",0,FALSE,
4484         "file:///SERVER/TEST",0,FALSE,
4485         TRUE, FALSE
4486     },
4487     {
4488         "http://google.com",Uri_CREATE_NO_CANONICALIZE,FALSE,
4489         "http://google.com/",0,FALSE,
4490         TRUE, FALSE
4491     },
4492     {
4493         "ftp://google.com:21/",0,FALSE,
4494         "ftp://google.com/",0,FALSE,
4495         TRUE, FALSE
4496     },
4497     {
4498         "http://google.com:80/",Uri_CREATE_NO_CANONICALIZE,FALSE,
4499         "http://google.com/",0,FALSE,
4500         TRUE, FALSE
4501     },
4502     {
4503         "http://google.com:70/",0,FALSE,
4504         "http://google.com:71/",0,FALSE,
4505         FALSE, FALSE
4506     }
4507 };
4508
4509 typedef struct _uri_with_fragment {
4510     const char* uri;
4511     const char* fragment;
4512     DWORD       create_flags;
4513     HRESULT     create_expected;
4514     BOOL        create_todo;
4515
4516     const char* expected_uri;
4517     BOOL        expected_todo;
4518 } uri_with_fragment;
4519
4520 static const uri_with_fragment uri_fragment_tests[] = {
4521     {
4522         "http://google.com/","#fragment",0,S_OK,FALSE,
4523         "http://google.com/#fragment",FALSE
4524     },
4525     {
4526         "http://google.com/","fragment",0,S_OK,FALSE,
4527         "http://google.com/#fragment",FALSE
4528     },
4529     {
4530         "zip://test.com/","?test",0,S_OK,FALSE,
4531         "zip://test.com/#?test",FALSE
4532     },
4533     /* The fragment can be empty. */
4534     {
4535         "ftp://ftp.google.com/","",0,S_OK,FALSE,
4536         "ftp://ftp.google.com/#",FALSE
4537     }
4538 };
4539
4540 typedef struct _uri_builder_property {
4541     BOOL            change;
4542     const char      *value;
4543     const char      *expected_value;
4544     Uri_PROPERTY    property;
4545     HRESULT         expected;
4546     BOOL            todo;
4547 } uri_builder_property;
4548
4549 typedef struct _uri_builder_port {
4550     BOOL    change;
4551     BOOL    set;
4552     DWORD   value;
4553     HRESULT expected;
4554     BOOL    todo;
4555 } uri_builder_port;
4556
4557 typedef struct _uri_builder_str_property {
4558     const char* expected;
4559     HRESULT     result;
4560     BOOL        todo;
4561 } uri_builder_str_property;
4562
4563 typedef struct _uri_builder_dword_property {
4564     DWORD   expected;
4565     HRESULT result;
4566     BOOL    todo;
4567 } uri_builder_dword_property;
4568
4569 typedef struct _uri_builder_test {
4570     const char                  *uri;
4571     DWORD                       create_flags;
4572     HRESULT                     create_builder_expected;
4573     BOOL                        create_builder_todo;
4574
4575     uri_builder_property        properties[URI_BUILDER_STR_PROPERTY_COUNT];
4576
4577     uri_builder_port            port_prop;
4578
4579     DWORD                       uri_flags;
4580     HRESULT                     uri_hres;
4581     BOOL                        uri_todo;
4582
4583     DWORD                       uri_simple_encode_flags;
4584     HRESULT                     uri_simple_hres;
4585     BOOL                        uri_simple_todo;
4586
4587     DWORD                       uri_with_flags;
4588     DWORD                       uri_with_builder_flags;
4589     DWORD                       uri_with_encode_flags;
4590     HRESULT                     uri_with_hres;
4591     BOOL                        uri_with_todo;
4592
4593     uri_builder_str_property    expected_str_props[URI_STR_PROPERTY_COUNT];
4594     uri_builder_dword_property  expected_dword_props[URI_DWORD_PROPERTY_COUNT];
4595 } uri_builder_test;
4596
4597 static const uri_builder_test uri_builder_tests[] = {
4598     {   "http://google.com/",0,S_OK,FALSE,
4599         {
4600             {TRUE,"#fragment",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4601             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE},
4602             {TRUE,"?query=x",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE},
4603             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4604         },
4605         {FALSE},
4606         0,S_OK,FALSE,
4607         0,S_OK,FALSE,
4608         0,0,0,S_OK,FALSE,
4609         {
4610             {"http://username:password@google.com/?query=x#fragment",S_OK},
4611             {"username:password@google.com",S_OK},
4612             {"http://google.com/?query=x#fragment",S_OK},
4613             {"google.com",S_OK},
4614             {"",S_FALSE},
4615             {"#fragment",S_OK},
4616             {"google.com",S_OK},
4617             {"password",S_OK},
4618             {"/",S_OK},
4619             {"/?query=x",S_OK},
4620             {"?query=x",S_OK},
4621             {"http://username:password@google.com/?query=x#fragment",S_OK},
4622             {"http",S_OK},
4623             {"username:password",S_OK},
4624             {"username",S_OK}
4625         },
4626         {
4627             {Uri_HOST_DNS,S_OK},
4628             {80,S_OK},
4629             {URL_SCHEME_HTTP,S_OK},
4630             {URLZONE_INVALID,E_NOTIMPL}
4631         }
4632     },
4633     {   "http://google.com/",0,S_OK,FALSE,
4634         {
4635             {TRUE,"test",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
4636         },
4637         {TRUE,TRUE,120,S_OK,FALSE},
4638         0,S_OK,FALSE,
4639         0,S_OK,FALSE,
4640         0,0,0,S_OK,FALSE,
4641         {
4642             {"test://google.com:120/",S_OK},
4643             {"google.com:120",S_OK},
4644             {"test://google.com:120/",S_OK},
4645             {"google.com",S_OK},
4646             {"",S_FALSE},
4647             {"",S_FALSE},
4648             {"google.com",S_OK},
4649             {"",S_FALSE},
4650             {"/",S_OK},
4651             {"/",S_OK},
4652             {"",S_FALSE},
4653             {"test://google.com:120/",S_OK},
4654             {"test",S_OK},
4655             {"",S_FALSE},
4656             {"",S_FALSE}
4657         },
4658         {
4659             {Uri_HOST_DNS,S_OK},
4660             {120,S_OK},
4661             {URL_SCHEME_UNKNOWN,S_OK},
4662             {URLZONE_INVALID,E_NOTIMPL}
4663         }
4664     },
4665     {   "/Test/test dir",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4666         {
4667             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
4668             {TRUE,"::192.2.3.4",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
4669             {TRUE,NULL,NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
4670         },
4671         {FALSE},
4672         0,S_OK,FALSE,
4673         0,S_OK,FALSE,
4674         0,0,0,S_OK,FALSE,
4675         {
4676             {"http://[::192.2.3.4]/",S_OK},
4677             {"[::192.2.3.4]",S_OK},
4678             {"http://[::192.2.3.4]/",S_OK},
4679             {"",S_FALSE},
4680             {"",S_FALSE},
4681             {"",S_FALSE},
4682             {"::192.2.3.4",S_OK},
4683             {"",S_FALSE},
4684             {"/",S_OK},
4685             {"/",S_OK},
4686             {"",S_FALSE},
4687             {"http://[::192.2.3.4]/",S_OK},
4688             {"http",S_OK},
4689             {"",S_FALSE},
4690             {"",S_FALSE}
4691         },
4692         {
4693             {Uri_HOST_IPV6,S_OK},
4694             {80,S_OK},
4695             {URL_SCHEME_HTTP,S_OK},
4696             {URLZONE_INVALID,E_NOTIMPL}
4697         }
4698     },
4699     {   "http://google.com/",0,S_OK,FALSE,
4700         {
4701             {TRUE,"Frag","#Frag",Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4702         },
4703         {FALSE},
4704         0,S_OK,FALSE,
4705         0,S_OK,FALSE,
4706         0,0,0,S_OK,FALSE,
4707         {
4708             {"http://google.com/#Frag",S_OK},
4709             {"google.com",S_OK},
4710             {"http://google.com/#Frag",S_OK},
4711             {"google.com",S_OK},
4712             {"",S_FALSE},
4713             {"#Frag",S_OK},
4714             {"google.com",S_OK},
4715             {"",S_FALSE},
4716             {"/",S_OK},
4717             {"/",S_OK},
4718             {"",S_FALSE},
4719             {"http://google.com/#Frag",S_OK},
4720             {"http",S_OK},
4721             {"",S_FALSE},
4722             {"",S_FALSE}
4723         },
4724         {
4725             {Uri_HOST_DNS,S_OK},
4726             {80,S_OK},
4727             {URL_SCHEME_HTTP,S_OK},
4728             {URLZONE_INVALID,E_NOTIMPL}
4729         }
4730     },
4731     {   "http://google.com/",0,S_OK,FALSE,
4732         {
4733             {TRUE,"","#",Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4734         },
4735         {FALSE},
4736         0,S_OK,FALSE,
4737         0,S_OK,FALSE,
4738         0,0,0,S_OK,FALSE,
4739         {
4740             {"http://google.com/#",S_OK},
4741             {"google.com",S_OK},
4742             {"http://google.com/#",S_OK},
4743             {"google.com",S_OK},
4744             {"",S_FALSE},
4745             {"#",S_OK},
4746             {"google.com",S_OK},
4747             {"",S_FALSE},
4748             {"/",S_OK},
4749             {"/",S_OK},
4750             {"",S_FALSE},
4751             {"http://google.com/#",S_OK},
4752             {"http",S_OK},
4753             {"",S_FALSE},
4754             {"",S_FALSE}
4755         },
4756         {
4757             {Uri_HOST_DNS,S_OK},
4758             {80,S_OK},
4759             {URL_SCHEME_HTTP,S_OK},
4760             {URLZONE_INVALID,E_NOTIMPL}
4761         }
4762     },
4763     {   "http://google.com/",0,S_OK,FALSE,
4764         {
4765             {TRUE,":password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4766         },
4767         {FALSE},
4768         0,S_OK,FALSE,
4769         0,S_OK,FALSE,
4770         0,0,0,S_OK,FALSE,
4771         {
4772             {"http://::password@google.com/",S_OK},
4773             {"::password@google.com",S_OK},
4774             {"http://google.com/",S_OK},
4775             {"google.com",S_OK},
4776             {"",S_FALSE},
4777             {"",S_FALSE},
4778             {"google.com",S_OK},
4779             {":password",S_OK},
4780             {"/",S_OK},
4781             {"/",S_OK},
4782             {"",S_FALSE},
4783             {"http://::password@google.com/",S_OK},
4784             {"http",S_OK},
4785             {"::password",S_OK},
4786             {"",S_FALSE}
4787         },
4788         {
4789             {Uri_HOST_DNS,S_OK},
4790             {80,S_OK},
4791             {URL_SCHEME_HTTP,S_OK},
4792             {URLZONE_INVALID,E_NOTIMPL}
4793         }
4794     },
4795     {   "test/test",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4796         {
4797             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4798         },
4799         {FALSE},
4800         Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4801         0,S_OK,FALSE,
4802         Uri_CREATE_ALLOW_RELATIVE,0,0,S_OK,FALSE,
4803         {
4804             {":password@test/test",S_OK},
4805             {":password@",S_OK},
4806             {":password@test/test",S_OK},
4807             {"",S_FALSE},
4808             {"",S_FALSE},
4809             {"",S_FALSE},
4810             {"",S_FALSE},
4811             {"password",S_OK},
4812             {"test/test",S_OK},
4813             {"test/test",S_OK},
4814             {"",S_FALSE},
4815             {":password@test/test",S_OK},
4816             {"",S_FALSE},
4817             {":password",S_OK},
4818             {"",S_FALSE}
4819         },
4820         {
4821             {Uri_HOST_UNKNOWN,S_OK},
4822             {0,S_FALSE},
4823             {URL_SCHEME_UNKNOWN,S_OK},
4824             {URLZONE_INVALID,E_NOTIMPL}
4825         }
4826     },
4827     {   "http://google.com/",0,S_OK,FALSE,
4828         {
4829             {TRUE,"test/test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4830         },
4831         {FALSE},
4832         0,S_OK,FALSE,
4833         0,S_OK,FALSE,
4834         0,0,0,S_OK,FALSE,
4835         {
4836             {"http://google.com/test/test",S_OK},
4837             {"google.com",S_OK},
4838             {"http://google.com/test/test",S_OK},
4839             {"google.com",S_OK},
4840             {"",S_FALSE},
4841             {"",S_FALSE},
4842             {"google.com",S_OK},
4843             {"",S_FALSE},
4844             {"/test/test",S_OK},
4845             {"/test/test",S_OK},
4846             {"",S_FALSE},
4847             {"http://google.com/test/test",S_OK},
4848             {"http",S_OK},
4849             {"",S_FALSE},
4850             {"",S_FALSE}
4851         },
4852         {
4853             {Uri_HOST_DNS,S_OK},
4854             {80,S_OK},
4855             {URL_SCHEME_HTTP,S_OK},
4856             {URLZONE_INVALID,E_NOTIMPL}
4857         }
4858     },
4859     {   "zip:testing/test",0,S_OK,FALSE,
4860         {
4861             {TRUE,"test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4862         },
4863         {FALSE},
4864         0,S_OK,FALSE,
4865         0,S_OK,FALSE,
4866         0,0,0,S_OK,FALSE,
4867         {
4868             {"zip:test",S_OK},
4869             {"",S_FALSE},
4870             {"zip:test",S_OK},
4871             {"",S_FALSE},
4872             {"",S_FALSE},
4873             {"",S_FALSE},
4874             {"",S_FALSE},
4875             {"",S_FALSE},
4876             {"test",S_OK},
4877             {"test",S_OK},
4878             {"",S_FALSE},
4879             {"zip:test",S_OK},
4880             {"zip",S_OK},
4881             {"",S_FALSE},
4882             {"",S_FALSE}
4883         },
4884         {
4885             {Uri_HOST_UNKNOWN,S_OK},
4886             {0,S_FALSE},
4887             {URL_SCHEME_UNKNOWN,S_OK},
4888             {URLZONE_INVALID,E_NOTIMPL}
4889         }
4890     },
4891     {   "http://google.com/",0,S_OK,FALSE,
4892         {
4893             {FALSE},
4894         },
4895         /* 555 will be returned from GetPort even though FALSE was passed as the hasPort parameter. */
4896         {TRUE,FALSE,555,S_OK,FALSE},
4897         0,S_OK,FALSE,
4898         0,S_OK,FALSE,
4899         0,0,0,S_OK,FALSE,
4900         {
4901             {"http://google.com/",S_OK},
4902             {"google.com",S_OK},
4903             {"http://google.com/",S_OK},
4904             {"google.com",S_OK},
4905             {"",S_FALSE},
4906             {"",S_FALSE},
4907             {"google.com",S_OK},
4908             {"",S_FALSE},
4909             {"/",S_OK},
4910             {"/",S_OK},
4911             {"",S_FALSE},
4912             {"http://google.com/",S_OK},
4913             {"http",S_OK},
4914             {"",S_FALSE},
4915             {"",S_FALSE}
4916         },
4917         {
4918             {Uri_HOST_DNS,S_OK},
4919             /* Still returns 80, even though earlier the port was disabled. */
4920             {80,S_OK},
4921             {URL_SCHEME_HTTP,S_OK},
4922             {URLZONE_INVALID,E_NOTIMPL}
4923         }
4924     },
4925     {   "http://google.com/",0,S_OK,FALSE,
4926         {
4927             {FALSE},
4928         },
4929         /* Instead of getting "TRUE" back as the "hasPort" parameter in GetPort,
4930          * you'll get 122345 instead.
4931          */
4932         {TRUE,122345,222,S_OK,FALSE},
4933         0,S_OK,FALSE,
4934         0,S_OK,FALSE,
4935         0,0,0,S_OK,FALSE,
4936         {
4937             {"http://google.com:222/",S_OK},
4938             {"google.com:222",S_OK},
4939             {"http://google.com:222/",S_OK},
4940             {"google.com",S_OK},
4941             {"",S_FALSE},
4942             {"",S_FALSE},
4943             {"google.com",S_OK},
4944             {"",S_FALSE},
4945             {"/",S_OK},
4946             {"/",S_OK},
4947             {"",S_FALSE},
4948             {"http://google.com:222/",S_OK},
4949             {"http",S_OK},
4950             {"",S_FALSE},
4951             {"",S_FALSE}
4952         },
4953         {
4954             {Uri_HOST_DNS,S_OK},
4955             {222,S_OK},
4956             {URL_SCHEME_HTTP,S_OK},
4957             {URLZONE_INVALID,E_NOTIMPL}
4958         }
4959     },
4960     /* IUri's created with the IUriBuilder can have ports that exceed USHORT_MAX. */
4961     {   "http://google.com/",0,S_OK,FALSE,
4962         {
4963             {FALSE},
4964         },
4965         {TRUE,TRUE,999999,S_OK,FALSE},
4966         0,S_OK,FALSE,
4967         0,S_OK,FALSE,
4968         0,0,0,S_OK,FALSE,
4969         {
4970             {"http://google.com:999999/",S_OK},
4971             {"google.com:999999",S_OK},
4972             {"http://google.com:999999/",S_OK},
4973             {"google.com",S_OK},
4974             {"",S_FALSE},
4975             {"",S_FALSE},
4976             {"google.com",S_OK},
4977             {"",S_FALSE},
4978             {"/",S_OK},
4979             {"/",S_OK},
4980             {"",S_FALSE},
4981             {"http://google.com:999999/",S_OK},
4982             {"http",S_OK},
4983             {"",S_FALSE},
4984             {"",S_FALSE}
4985         },
4986         {
4987             {Uri_HOST_DNS,S_OK},
4988             {999999,S_OK},
4989             {URL_SCHEME_HTTP,S_OK},
4990             {URLZONE_INVALID,E_NOTIMPL}
4991         }
4992     },
4993     {   "http://google.com/",0,S_OK,FALSE,
4994         {
4995             {TRUE,"test","?test",Uri_PROPERTY_QUERY,S_OK,FALSE},
4996         },
4997
4998         {FALSE},
4999         0,S_OK,FALSE,
5000         0,S_OK,FALSE,
5001         0,0,0,S_OK,FALSE,
5002         {
5003             {"http://google.com/?test",S_OK},
5004             {"google.com",S_OK},
5005             {"http://google.com/?test",S_OK},
5006             {"google.com",S_OK},
5007             {"",S_FALSE},
5008             {"",S_FALSE},
5009             {"google.com",S_OK},
5010             {"",S_FALSE},
5011             {"/",S_OK},
5012             {"/?test",S_OK},
5013             {"?test",S_OK},
5014             {"http://google.com/?test",S_OK},
5015             {"http",S_OK},
5016             {"",S_FALSE},
5017             {"",S_FALSE}
5018         },
5019         {
5020             {Uri_HOST_DNS,S_OK},
5021             {80,S_OK},
5022             {URL_SCHEME_HTTP,S_OK},
5023             {URLZONE_INVALID,E_NOTIMPL}
5024         }
5025     },
5026     {   "http://:password@google.com/",0,S_OK,FALSE,
5027         {
5028             {FALSE},
5029         },
5030         {FALSE},
5031         0,S_OK,FALSE,
5032         0,S_OK,FALSE,
5033         0,0,0,S_OK,FALSE,
5034         {
5035             {"http://:password@google.com/",S_OK},
5036             {":password@google.com",S_OK},
5037             {"http://google.com/",S_OK},
5038             {"google.com",S_OK},
5039             {"",S_FALSE},
5040             {"",S_FALSE},
5041             {"google.com",S_OK},
5042             {"password",S_OK},
5043             {"/",S_OK},
5044             {"/",S_OK},
5045             {"",S_FALSE},
5046             {"http://:password@google.com/",S_OK},
5047             {"http",S_OK},
5048             {":password",S_OK},
5049             {"",S_FALSE}
5050         },
5051         {
5052             {Uri_HOST_DNS,S_OK},
5053             {80,S_OK},
5054             {URL_SCHEME_HTTP,S_OK},
5055             {URLZONE_INVALID,E_NOTIMPL}
5056         }
5057     },
5058     /* IUriBuilder doesn't need a base IUri to build a IUri. */
5059     {   NULL,0,S_OK,FALSE,
5060         {
5061             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
5062             {TRUE,"google.com",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5063         },
5064         {FALSE},
5065         0,S_OK,FALSE,
5066         0,S_OK,FALSE,
5067         0,0,0,S_OK,FALSE,
5068         {
5069             {"http://google.com/",S_OK},
5070             {"google.com",S_OK},
5071             {"http://google.com/",S_OK},
5072             {"google.com",S_OK},
5073             {"",S_FALSE},
5074             {"",S_FALSE},
5075             {"google.com",S_OK},
5076             {"",S_FALSE},
5077             {"/",S_OK},
5078             {"/",S_OK},
5079             {"",S_FALSE},
5080             {"http://google.com/",S_OK},
5081             {"http",S_OK},
5082             {"",S_FALSE},
5083             {"",S_FALSE}
5084         },
5085         {
5086             {Uri_HOST_DNS,S_OK},
5087             {80,S_OK},
5088             {URL_SCHEME_HTTP,S_OK},
5089             {URLZONE_INVALID,E_NOTIMPL}
5090         }
5091     },
5092     /* Can't set the scheme name to NULL. */
5093     {   "zip://google.com/",0,S_OK,FALSE,
5094         {
5095             {TRUE,NULL,"zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
5096         },
5097         {FALSE},
5098         0,S_OK,FALSE,
5099         0,S_OK,FALSE,
5100         0,0,0,S_OK,FALSE,
5101         {
5102             {"zip://google.com/",S_OK},
5103             {"google.com",S_OK},
5104             {"zip://google.com/",S_OK},
5105             {"google.com",S_OK},
5106             {"",S_FALSE},
5107             {"",S_FALSE},
5108             {"google.com",S_OK},
5109             {"",S_FALSE},
5110             {"/",S_OK},
5111             {"/",S_OK},
5112             {"",S_FALSE},
5113             {"zip://google.com/",S_OK},
5114             {"zip",S_OK},
5115             {"",S_FALSE},
5116             {"",S_FALSE}
5117         },
5118         {
5119             {Uri_HOST_DNS,S_OK},
5120             {0,S_FALSE},
5121             {URL_SCHEME_UNKNOWN,S_OK},
5122             {URLZONE_INVALID,E_NOTIMPL}
5123         }
5124     },
5125     /* Can't set the scheme name to an empty string. */
5126     {   "zip://google.com/",0,S_OK,FALSE,
5127         {
5128             {TRUE,"","zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
5129         },
5130         {FALSE},
5131         0,S_OK,FALSE,
5132         0,S_OK,FALSE,
5133         0,0,0,S_OK,FALSE,
5134         {
5135             {"zip://google.com/",S_OK},
5136             {"google.com",S_OK},
5137             {"zip://google.com/",S_OK},
5138             {"google.com",S_OK},
5139             {"",S_FALSE},
5140             {"",S_FALSE},
5141             {"google.com",S_OK},
5142             {"",S_FALSE},
5143             {"/",S_OK},
5144             {"/",S_OK},
5145             {"",S_FALSE},
5146             {"zip://google.com/",S_OK},
5147             {"zip",S_OK},
5148             {"",S_FALSE},
5149             {"",S_FALSE}
5150         },
5151         {
5152             {Uri_HOST_DNS,S_OK},
5153             {0,S_FALSE},
5154             {URL_SCHEME_UNKNOWN,S_OK},
5155             {URLZONE_INVALID,E_NOTIMPL}
5156         }
5157     },
5158     /* -1 to CreateUri makes it use the same flags as the base IUri was created with.
5159      * CreateUriSimple always uses the flags the base IUri was created with (if any).
5160      */
5161     {   "http://google.com/../../",Uri_CREATE_NO_CANONICALIZE,S_OK,FALSE,
5162         {{FALSE}},
5163         {FALSE},
5164         -1,S_OK,FALSE,
5165         0,S_OK,FALSE,
5166         0,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5167         {
5168             {"http://google.com/../../",S_OK},
5169             {"google.com",S_OK},
5170             {"http://google.com/../../",S_OK},
5171             {"google.com",S_OK},
5172             {"",S_FALSE},
5173             {"",S_FALSE},
5174             {"google.com",S_OK},
5175             {"",S_FALSE},
5176             {"/../../",S_OK},
5177             {"/../../",S_OK},
5178             {"",S_FALSE},
5179             {"http://google.com/../../",S_OK},
5180             {"http",S_OK},
5181             {"",S_FALSE},
5182             {"",S_FALSE}
5183         },
5184         {
5185             {Uri_HOST_DNS,S_OK},
5186             {80,S_OK},
5187             {URL_SCHEME_HTTP,S_OK},
5188             {URLZONE_INVALID,E_NOTIMPL}
5189         }
5190     },
5191     {   "http://google.com/",0,S_OK,FALSE,
5192         {
5193             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5194         },
5195         {FALSE},
5196         -1,S_OK,FALSE,
5197         0,S_OK,FALSE,
5198         Uri_CREATE_NO_DECODE_EXTRA_INFO,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5199         {
5200             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5201             {"google.com",S_OK},
5202             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5203             {"google.com",S_OK},
5204             {"",S_FALSE},
5205             {"#Fr%3C%7C%3Eg",S_OK},
5206             {"google.com",S_OK},
5207             {"",S_FALSE},
5208             {"/",S_OK},
5209             {"/",S_OK},
5210             {"",S_FALSE},
5211             {"http://google.com/#Fr<|>g",S_OK},
5212             {"http",S_OK},
5213             {"",S_FALSE},
5214             {"",S_FALSE}
5215         },
5216         {
5217             {Uri_HOST_DNS,S_OK},
5218             {80,S_OK},
5219             {URL_SCHEME_HTTP,S_OK},
5220             {URLZONE_INVALID,E_NOTIMPL}
5221         }
5222     },
5223     {   "http://google.com/",0,S_OK,FALSE,
5224         {
5225             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5226         },
5227         {FALSE},
5228         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,E_INVALIDARG,FALSE,
5229         0,S_OK,FALSE,
5230         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5231         {
5232             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5233             {"google.com",S_OK},
5234             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5235             {"google.com",S_OK},
5236             {"",S_FALSE},
5237             {"#Fr%3C%7C%3Eg",S_OK},
5238             {"google.com",S_OK},
5239             {"",S_FALSE},
5240             {"/",S_OK},
5241             {"/",S_OK},
5242             {"",S_FALSE},
5243             {"http://google.com/#Fr<|>g",S_OK},
5244             {"http",S_OK},
5245             {"",S_FALSE},
5246             {"",S_FALSE}
5247         },
5248         {
5249             {Uri_HOST_DNS,S_OK},
5250             {80,S_OK},
5251             {URL_SCHEME_HTTP,S_OK},
5252             {URLZONE_INVALID,E_NOTIMPL}
5253         }
5254     },
5255     {   NULL,0,S_OK,FALSE,
5256         {
5257             {TRUE,"/test/test/",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
5258             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5259         },
5260         {FALSE},
5261         0,INET_E_INVALID_URL,FALSE,
5262         0,INET_E_INVALID_URL,FALSE,
5263         0,0,0,INET_E_INVALID_URL,FALSE
5264     },
5265     {   "http://google.com/",0,S_OK,FALSE,
5266         {
5267             {TRUE,"ht%xxtp",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
5268         },
5269         {FALSE},
5270         0,INET_E_INVALID_URL,FALSE,
5271         0,INET_E_INVALID_URL,FALSE,
5272         0,0,0,INET_E_INVALID_URL,FALSE
5273     },
5274     /* File scheme's can't have a username set. */
5275     {   "file://google.com/",0,S_OK,FALSE,
5276         {
5277             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5278         },
5279         {FALSE},
5280         0,INET_E_INVALID_URL,FALSE,
5281         0,INET_E_INVALID_URL,FALSE,
5282         0,0,0,INET_E_INVALID_URL,FALSE
5283     },
5284     /* File schemes can't have a password set. */
5285     {   "file://google.com/",0,S_OK,FALSE,
5286         {
5287             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5288         },
5289         {FALSE},
5290         0,INET_E_INVALID_URL,FALSE,
5291         0,INET_E_INVALID_URL,FALSE,
5292         0,0,0,INET_E_INVALID_URL,FALSE
5293     },
5294     /* UserName can't contain any character that is a delimeter for another
5295      * component that appears after it in a normal URI.
5296      */
5297     {   "http://google.com/",0,S_OK,FALSE,
5298         {
5299             {TRUE,"user:pass",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5300         },
5301         {FALSE},
5302         0,INET_E_INVALID_URL,FALSE,
5303         0,INET_E_INVALID_URL,FALSE,
5304         0,0,0,INET_E_INVALID_URL,FALSE
5305     },
5306     {   "http://google.com/",0,S_OK,FALSE,
5307         {
5308             {TRUE,"user@google.com",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5309         },
5310         {FALSE},
5311         0,INET_E_INVALID_URL,FALSE,
5312         0,INET_E_INVALID_URL,FALSE,
5313         0,0,0,INET_E_INVALID_URL,FALSE
5314     },
5315     {   "http://google.com/",0,S_OK,FALSE,
5316         {
5317             {TRUE,"user/path",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5318         },
5319         {FALSE},
5320         0,INET_E_INVALID_URL,FALSE,
5321         0,INET_E_INVALID_URL,FALSE,
5322         0,0,0,INET_E_INVALID_URL,FALSE
5323     },
5324     {   "http://google.com/",0,S_OK,FALSE,
5325         {
5326             {TRUE,"user?Query",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5327         },
5328         {FALSE},
5329         0,INET_E_INVALID_URL,FALSE,
5330         0,INET_E_INVALID_URL,FALSE,
5331         0,0,0,INET_E_INVALID_URL,FALSE
5332     },
5333     {   "http://google.com/",0,S_OK,FALSE,
5334         {
5335             {TRUE,"user#Frag",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5336         },
5337         {FALSE},
5338         0,INET_E_INVALID_URL,FALSE,
5339         0,INET_E_INVALID_URL,FALSE,
5340         0,0,0,INET_E_INVALID_URL,FALSE
5341     },
5342     {   "http://google.com/",0,S_OK,FALSE,
5343         {
5344             {TRUE,"pass@google.com",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5345         },
5346         {FALSE},
5347         0,INET_E_INVALID_URL,FALSE,
5348         0,INET_E_INVALID_URL,FALSE,
5349         0,0,0,INET_E_INVALID_URL,FALSE
5350     },
5351     {   "http://google.com/",0,S_OK,FALSE,
5352         {
5353             {TRUE,"pass/path",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5354         },
5355         {FALSE},
5356         0,INET_E_INVALID_URL,FALSE,
5357         0,INET_E_INVALID_URL,FALSE,
5358         0,0,0,INET_E_INVALID_URL,FALSE
5359     },
5360     {   "http://google.com/",0,S_OK,FALSE,
5361         {
5362             {TRUE,"pass?query",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5363         },
5364         {FALSE},
5365         0,INET_E_INVALID_URL,FALSE,
5366         0,INET_E_INVALID_URL,FALSE,
5367        0,0,0,INET_E_INVALID_URL,FALSE
5368     },
5369     {   "http://google.com/",0,S_OK,FALSE,
5370         {
5371             {TRUE,"pass#frag",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5372         },
5373         {FALSE},
5374         0,INET_E_INVALID_URL,FALSE,
5375         0,INET_E_INVALID_URL,FALSE,
5376         0,0,0,INET_E_INVALID_URL,FALSE
5377     },
5378     {   "http://google.com/",0,S_OK,FALSE,
5379         {
5380             {TRUE,"winehq.org/test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5381         },
5382         {FALSE},
5383         0,INET_E_INVALID_URL,FALSE,
5384         0,INET_E_INVALID_URL,FALSE,
5385         0,0,0,INET_E_INVALID_URL,FALSE
5386     },
5387     {   "http://google.com/",0,S_OK,FALSE,
5388         {
5389             {TRUE,"winehq.org?test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5390         },
5391         {FALSE},
5392         0,INET_E_INVALID_URL,FALSE,
5393         0,INET_E_INVALID_URL,FALSE,
5394         0,0,0,INET_E_INVALID_URL,FALSE
5395     },
5396     {   "http://google.com/",0,S_OK,FALSE,
5397         {
5398             {TRUE,"winehq.org#test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5399         },
5400         {FALSE},
5401         0,INET_E_INVALID_URL,FALSE,
5402         0,INET_E_INVALID_URL,FALSE,
5403         0,0,0,INET_E_INVALID_URL,FALSE
5404     },
5405     /* Hostname is allowed to contain a ':' (even for known scheme types). */
5406     {   "http://google.com/",0,S_OK,FALSE,
5407         {
5408             {TRUE,"winehq.org:test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
5409         },
5410         {FALSE},
5411         0,S_OK,FALSE,
5412         0,S_OK,FALSE,
5413         0,0,0,S_OK,FALSE,
5414         {
5415             {"http://winehq.org:test/",S_OK},
5416             {"winehq.org:test",S_OK},
5417             {"http://winehq.org:test/",S_OK},
5418             {"winehq.org:test",S_OK},
5419             {"",S_FALSE},
5420             {"",S_FALSE},
5421             {"winehq.org:test",S_OK},
5422             {"",S_FALSE},
5423             {"/",S_OK},
5424             {"/",S_OK},
5425             {"",S_FALSE},
5426             {"http://winehq.org:test/",S_OK},
5427             {"http",S_OK},
5428             {"",S_FALSE},
5429             {"",S_FALSE}
5430         },
5431         {
5432             {Uri_HOST_DNS,S_OK},
5433             {80,S_OK},
5434             {URL_SCHEME_HTTP,S_OK},
5435             {URLZONE_INVALID,E_NOTIMPL}
5436         }
5437     },
5438     /* Can't set the host name to NULL. */
5439     {   "http://google.com/",0,S_OK,FALSE,
5440         {
5441             {TRUE,NULL,"google.com",Uri_PROPERTY_HOST,E_INVALIDARG,FALSE}
5442         },
5443         {FALSE},
5444         0,S_OK,FALSE,
5445         0,S_OK,FALSE,
5446         0,0,0,S_OK,FALSE,
5447         {
5448             {"http://google.com/",S_OK},
5449             {"google.com",S_OK},
5450             {"http://google.com/",S_OK},
5451             {"google.com",S_OK},
5452             {"",S_FALSE},
5453             {"",S_FALSE},
5454             {"google.com",S_OK},
5455             {"",S_FALSE},
5456             {"/",S_OK},
5457             {"/",S_OK},
5458             {"",S_FALSE},
5459             {"http://google.com/",S_OK},
5460             {"http",S_OK},
5461             {"",S_FALSE},
5462             {"",S_FALSE}
5463         },
5464         {
5465             {Uri_HOST_DNS,S_OK},
5466             {80,S_OK},
5467             {URL_SCHEME_HTTP,S_OK},
5468             {URLZONE_INVALID,E_NOTIMPL}
5469         }
5470     },
5471     /* Can set the host name to an empty string. */
5472     {   "http://google.com/",0,S_OK,FALSE,
5473         {
5474             {TRUE,"",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5475         },
5476         {FALSE},
5477         0,S_OK,FALSE,
5478         0,S_OK,FALSE,
5479         0,0,0,S_OK,FALSE,
5480         {
5481             {"http:///",S_OK},
5482             {"",S_OK},
5483             {"http:///",S_OK},
5484             {"",S_FALSE},
5485             {"",S_FALSE},
5486             {"",S_FALSE},
5487             {"",S_OK},
5488             {"",S_FALSE},
5489             {"/",S_OK},
5490             {"/",S_OK},
5491             {"",S_FALSE},
5492             {"http:///",S_OK},
5493             {"http",S_OK},
5494             {"",S_FALSE},
5495             {"",S_FALSE}
5496         },
5497         {
5498             {Uri_HOST_UNKNOWN,S_OK},
5499             {80,S_OK},
5500             {URL_SCHEME_HTTP,S_OK},
5501             {URLZONE_INVALID,E_NOTIMPL}
5502         }
5503     },
5504     {   "http://google.com/",0,S_OK,FALSE,
5505         {
5506             {TRUE,"/path?query",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5507         },
5508         {FALSE},
5509         0,INET_E_INVALID_URL,FALSE,
5510         0,INET_E_INVALID_URL,FALSE,
5511         0,0,0,INET_E_INVALID_URL,FALSE
5512     },
5513     {   "http://google.com/",0,S_OK,FALSE,
5514         {
5515             {TRUE,"/path#test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5516         },
5517         {FALSE},
5518         0,INET_E_INVALID_URL,FALSE,
5519         0,INET_E_INVALID_URL,FALSE,
5520         0,0,0,INET_E_INVALID_URL,FALSE
5521     },
5522     {   "http://google.com/",0,S_OK,FALSE,
5523         {
5524             {TRUE,"?path#test",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE}
5525         },
5526         {FALSE},
5527         0,INET_E_INVALID_URL,FALSE,
5528         0,INET_E_INVALID_URL,FALSE,
5529         0,0,0,INET_E_INVALID_URL,FALSE
5530     }
5531 };
5532
5533 typedef struct _uri_builder_remove_test {
5534     const char  *uri;
5535     DWORD       create_flags;
5536     HRESULT     create_builder_expected;
5537     BOOL        create_builder_todo;
5538
5539     DWORD       remove_properties;
5540     HRESULT     remove_expected;
5541     BOOL        remove_todo;
5542
5543     const char  *expected_uri;
5544     DWORD       expected_flags;
5545     HRESULT     expected_hres;
5546     BOOL        expected_todo;
5547 } uri_builder_remove_test;
5548
5549 static const uri_builder_remove_test uri_builder_remove_tests[] = {
5550     {   "http://google.com/test?test=y#Frag",0,S_OK,FALSE,
5551         Uri_HAS_FRAGMENT|Uri_HAS_PATH|Uri_HAS_QUERY,S_OK,FALSE,
5552         "http://google.com/",0,S_OK,FALSE
5553     },
5554     {   "http://user:pass@winehq.org/",0,S_OK,FALSE,
5555         Uri_HAS_USER_NAME|Uri_HAS_PASSWORD,S_OK,FALSE,
5556         "http://winehq.org/",0,S_OK,FALSE
5557     },
5558     {   "zip://google.com?Test=x",0,S_OK,FALSE,
5559         Uri_HAS_HOST,S_OK,FALSE,
5560         "zip:/?Test=x",0,S_OK,FALSE
5561     },
5562     /* Doesn't remove the whole userinfo component. */
5563     {   "http://username:pass@google.com/",0,S_OK,FALSE,
5564         Uri_HAS_USER_INFO,S_OK,FALSE,
5565         "http://username:pass@google.com/",0,S_OK,FALSE
5566     },
5567     /* Doesn't remove the domain. */
5568     {   "http://google.com/",0,S_OK,FALSE,
5569         Uri_HAS_DOMAIN,S_OK,FALSE,
5570         "http://google.com/",0,S_OK,FALSE
5571     },
5572     {   "http://google.com:120/",0,S_OK,FALSE,
5573         Uri_HAS_AUTHORITY,S_OK,FALSE,
5574         "http://google.com:120/",0,S_OK,FALSE
5575     },
5576     {   "http://google.com/test.com/",0,S_OK,FALSE,
5577         Uri_HAS_EXTENSION,S_OK,FALSE,
5578         "http://google.com/test.com/",0,S_OK,FALSE
5579     },
5580     {   "http://google.com/?test=x",0,S_OK,FALSE,
5581         Uri_HAS_PATH_AND_QUERY,S_OK,FALSE,
5582         "http://google.com/?test=x",0,S_OK,FALSE
5583     },
5584     /* Can't remove the scheme name. */
5585     {   "http://google.com/?test=x",0,S_OK,FALSE,
5586         Uri_HAS_SCHEME_NAME|Uri_HAS_QUERY,E_INVALIDARG,FALSE,
5587         "http://google.com/?test=x",0,S_OK,FALSE
5588     }
5589 };
5590
5591 typedef struct _uri_combine_str_property {
5592     const char  *value;
5593     HRESULT     expected;
5594     BOOL        todo;
5595     const char  *broken_value;
5596     const char  *value_ex;
5597 } uri_combine_str_property;
5598
5599 typedef struct _uri_combine_test {
5600     const char  *base_uri;
5601     DWORD       base_create_flags;
5602     const char  *relative_uri;
5603     DWORD       relative_create_flags;
5604     DWORD       combine_flags;
5605     HRESULT     expected;
5606     BOOL        todo;
5607
5608     uri_combine_str_property    str_props[URI_STR_PROPERTY_COUNT];
5609     uri_dword_property          dword_props[URI_DWORD_PROPERTY_COUNT];
5610 } uri_combine_test;
5611
5612 static const uri_combine_test uri_combine_tests[] = {
5613     {   "http://google.com/fun/stuff",0,
5614         "../not/fun/stuff",Uri_CREATE_ALLOW_RELATIVE,
5615         0,S_OK,FALSE,
5616         {
5617             {"http://google.com/not/fun/stuff",S_OK},
5618             {"google.com",S_OK},
5619             {"http://google.com/not/fun/stuff",S_OK},
5620             {"google.com",S_OK},
5621             {"",S_FALSE},
5622             {"",S_FALSE},
5623             {"google.com",S_OK},
5624             {"",S_FALSE},
5625             {"/not/fun/stuff",S_OK},
5626             {"/not/fun/stuff",S_OK},
5627             {"",S_FALSE},
5628             {"http://google.com/not/fun/stuff",S_OK},
5629             {"http",S_OK},
5630             {"",S_FALSE},
5631             {"",S_FALSE}
5632         },
5633         {
5634             {Uri_HOST_DNS,S_OK},
5635             {80,S_OK},
5636             {URL_SCHEME_HTTP,S_OK},
5637             {URLZONE_INVALID,E_NOTIMPL}
5638         }
5639     },
5640     {   "http://google.com/test",0,
5641         "zip://test.com/cool",0,
5642         0,S_OK,FALSE,
5643         {
5644             {"zip://test.com/cool",S_OK},
5645             {"test.com",S_OK},
5646             {"zip://test.com/cool",S_OK},
5647             {"test.com",S_OK},
5648             {"",S_FALSE},
5649             {"",S_FALSE},
5650             {"test.com",S_OK},
5651             {"",S_FALSE},
5652             {"/cool",S_OK},
5653             {"/cool",S_OK},
5654             {"",S_FALSE},
5655             {"zip://test.com/cool",S_OK},
5656             {"zip",S_OK},
5657             {"",S_FALSE},
5658             {"",S_FALSE}
5659         },
5660         {
5661             {Uri_HOST_DNS,S_OK},
5662             {0,S_FALSE},
5663             {URL_SCHEME_UNKNOWN,S_OK},
5664             {URLZONE_INVALID,E_NOTIMPL}
5665         }
5666     },
5667     {   "http://google.com/use/base/path",0,
5668         "?relative",Uri_CREATE_ALLOW_RELATIVE,
5669         0,S_OK,FALSE,
5670         {
5671             {"http://google.com/use/base/path?relative",S_OK},
5672             {"google.com",S_OK},
5673             {"http://google.com/use/base/path?relative",S_OK},
5674             {"google.com",S_OK},
5675             {"",S_FALSE},
5676             {"",S_FALSE},
5677             {"google.com",S_OK},
5678             {"",S_FALSE},
5679             {"/use/base/path",S_OK},
5680             {"/use/base/path?relative",S_OK},
5681             {"?relative",S_OK},
5682             {"http://google.com/use/base/path?relative",S_OK},
5683             {"http",S_OK},
5684             {"",S_FALSE},
5685             {"",S_FALSE}
5686         },
5687         {
5688             {Uri_HOST_DNS,S_OK},
5689             {80,S_OK},
5690             {URL_SCHEME_HTTP,S_OK},
5691             {URLZONE_INVALID,E_NOTIMPL}
5692         }
5693     },
5694     {   "http://google.com/path",0,
5695         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5696         0,S_OK,FALSE,
5697         {
5698             {"http://google.com/testing",S_OK},
5699             {"google.com",S_OK},
5700             {"http://google.com/testing",S_OK},
5701             {"google.com",S_OK},
5702             {"",S_FALSE},
5703             {"",S_FALSE},
5704             {"google.com",S_OK},
5705             {"",S_FALSE},
5706             {"/testing",S_OK},
5707             {"/testing",S_OK},
5708             {"",S_FALSE},
5709             {"http://google.com/testing",S_OK},
5710             {"http",S_OK},
5711             {"",S_FALSE},
5712             {"",S_FALSE}
5713         },
5714         {
5715             {Uri_HOST_DNS,S_OK},
5716             {80,S_OK},
5717             {URL_SCHEME_HTTP,S_OK},
5718             {URLZONE_INVALID,E_NOTIMPL}
5719         }
5720     },
5721     {   "http://google.com/path",0,
5722         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5723         URL_DONT_SIMPLIFY,S_OK,FALSE,
5724         {
5725             {"http://google.com:80/test/../test/.././testing",S_OK},
5726             {"google.com",S_OK},
5727             {"http://google.com:80/test/../test/.././testing",S_OK},
5728             {"google.com",S_OK},
5729             {"",S_FALSE},
5730             {"",S_FALSE},
5731             {"google.com",S_OK},
5732             {"",S_FALSE},
5733             {"/test/../test/.././testing",S_OK},
5734             {"/test/../test/.././testing",S_OK},
5735             {"",S_FALSE},
5736             {"http://google.com:80/test/../test/.././testing",S_OK},
5737             {"http",S_OK},
5738             {"",S_FALSE},
5739             {"",S_FALSE}
5740         },
5741         {
5742             {Uri_HOST_DNS,S_OK},
5743             {80,S_OK},
5744             {URL_SCHEME_HTTP,S_OK},
5745             {URLZONE_INVALID,E_NOTIMPL}
5746         }
5747     },
5748     {   "http://winehq.org/test/abc",0,
5749         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5750         0,S_OK,FALSE,
5751         {
5752             {"http://winehq.org/test/testing/test",S_OK},
5753             {"winehq.org",S_OK},
5754             {"http://winehq.org/test/testing/test",S_OK},
5755             {"winehq.org",S_OK},
5756             {"",S_FALSE},
5757             {"",S_FALSE},
5758             {"winehq.org",S_OK},
5759             {"",S_FALSE},
5760             {"/test/testing/test",S_OK},
5761             {"/test/testing/test",S_OK},
5762             {"",S_FALSE},
5763             {"http://winehq.org/test/testing/test",S_OK},
5764             {"http",S_OK},
5765             {"",S_FALSE},
5766             {"",S_FALSE}
5767         },
5768         {
5769             {Uri_HOST_DNS,S_OK},
5770             {80,S_OK},
5771             {URL_SCHEME_HTTP,S_OK},
5772             {URLZONE_INVALID,E_NOTIMPL}
5773         }
5774     },
5775     {   "http://winehq.org/test/abc",0,
5776         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5777         URL_DONT_SIMPLIFY,S_OK,FALSE,
5778         {
5779             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5780             /* Default port is hidden in the authority. */
5781             {"winehq.org",S_OK},
5782             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5783             {"winehq.org",S_OK},
5784             {"",S_FALSE},
5785             {"",S_FALSE},
5786             {"winehq.org",S_OK},
5787             {"",S_FALSE},
5788             {"/test/testing/abc/../test",S_OK},
5789             {"/test/testing/abc/../test",S_OK},
5790             {"",S_FALSE},
5791             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5792             {"http",S_OK},
5793             {"",S_FALSE},
5794             {"",S_FALSE}
5795         },
5796         {
5797             {Uri_HOST_DNS,S_OK},
5798             {80,S_OK},
5799             {URL_SCHEME_HTTP,S_OK},
5800             {URLZONE_INVALID,E_NOTIMPL}
5801         }
5802     },
5803     {   "http://winehq.org/test?query",0,
5804         "testing",Uri_CREATE_ALLOW_RELATIVE,
5805         0,S_OK,FALSE,
5806         {
5807             {"http://winehq.org/testing",S_OK},
5808             {"winehq.org",S_OK},
5809             {"http://winehq.org/testing",S_OK},
5810             {"winehq.org",S_OK},
5811             {"",S_FALSE},
5812             {"",S_FALSE},
5813             {"winehq.org",S_OK},
5814             {"",S_FALSE},
5815             {"/testing",S_OK},
5816             {"/testing",S_OK},
5817             {"",S_FALSE},
5818             {"http://winehq.org/testing",S_OK},
5819             {"http",S_OK},
5820             {"",S_FALSE},
5821             {"",S_FALSE}
5822         },
5823         {
5824             {Uri_HOST_DNS,S_OK},
5825             {80,S_OK},
5826             {URL_SCHEME_HTTP,S_OK},
5827             {URLZONE_INVALID,E_NOTIMPL}
5828         }
5829     },
5830     {   "http://winehq.org/test#frag",0,
5831         "testing",Uri_CREATE_ALLOW_RELATIVE,
5832         0,S_OK,FALSE,
5833         {
5834             {"http://winehq.org/testing",S_OK},
5835             {"winehq.org",S_OK},
5836             {"http://winehq.org/testing",S_OK},
5837             {"winehq.org",S_OK},
5838             {"",S_FALSE},
5839             {"",S_FALSE},
5840             {"winehq.org",S_OK},
5841             {"",S_FALSE},
5842             {"/testing",S_OK},
5843             {"/testing",S_OK},
5844             {"",S_FALSE},
5845             {"http://winehq.org/testing",S_OK},
5846             {"http",S_OK},
5847             {"",S_FALSE},
5848             {"",S_FALSE}
5849         },
5850         {
5851             {Uri_HOST_DNS,S_OK},
5852             {80,S_OK},
5853             {URL_SCHEME_HTTP,S_OK},
5854             {URLZONE_INVALID,E_NOTIMPL}
5855         }
5856     },
5857     {   "testing?query#frag",Uri_CREATE_ALLOW_RELATIVE,
5858         "test",Uri_CREATE_ALLOW_RELATIVE,
5859         0,S_OK,FALSE,
5860         {
5861             {"test",S_OK},
5862             {"",S_FALSE},
5863             {"test",S_OK},
5864             {"",S_FALSE},
5865             {"",S_FALSE},
5866             {"",S_FALSE},
5867             {"",S_FALSE},
5868             {"",S_FALSE},
5869             {"test",S_OK},
5870             {"test",S_OK},
5871             {"",S_FALSE},
5872             {"test",S_OK},
5873             {"",S_FALSE},
5874             {"",S_FALSE},
5875             {"",S_FALSE}
5876         },
5877         {
5878             {Uri_HOST_UNKNOWN,S_OK},
5879             {0,S_FALSE},
5880             {URL_SCHEME_UNKNOWN,S_OK},
5881             {URLZONE_INVALID,E_NOTIMPL}
5882         }
5883     },
5884     {   "file:///c:/test/test",0,
5885         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5886         URL_FILE_USE_PATHURL,S_OK,FALSE,
5887         {
5888             {"file://c:\\testing.mp3",S_OK},
5889             {"",S_FALSE},
5890             {"file://c:\\testing.mp3",S_OK},
5891             {"",S_FALSE},
5892             {".mp3",S_OK},
5893             {"",S_FALSE},
5894             {"",S_FALSE},
5895             {"",S_FALSE},
5896             {"c:\\testing.mp3",S_OK},
5897             {"c:\\testing.mp3",S_OK},
5898             {"",S_FALSE},
5899             {"file://c:\\testing.mp3",S_OK},
5900             {"file",S_OK},
5901             {"",S_FALSE},
5902             {"",S_FALSE}
5903         },
5904         {
5905             {Uri_HOST_UNKNOWN,S_OK},
5906             {0,S_FALSE},
5907             {URL_SCHEME_FILE,S_OK},
5908             {URLZONE_INVALID,E_NOTIMPL}
5909         }
5910     },
5911     {   "file:///c:/test/test",0,
5912         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5913         0,S_OK,FALSE,
5914         {
5915             {"file:///c:/testing.mp3",S_OK},
5916             {"",S_FALSE},
5917             {"file:///c:/testing.mp3",S_OK},
5918             {"",S_FALSE},
5919             {".mp3",S_OK},
5920             {"",S_FALSE},
5921             {"",S_FALSE},
5922             {"",S_FALSE},
5923             {"/c:/testing.mp3",S_OK},
5924             {"/c:/testing.mp3",S_OK},
5925             {"",S_FALSE},
5926             {"file:///c:/testing.mp3",S_OK},
5927             {"file",S_OK},
5928             {"",S_FALSE},
5929             {"",S_FALSE}
5930         },
5931         {
5932             {Uri_HOST_UNKNOWN,S_OK},
5933             {0,S_FALSE},
5934             {URL_SCHEME_FILE,S_OK},
5935             {URLZONE_INVALID,E_NOTIMPL}
5936         }
5937     },
5938     {   "file://test.com/test/test",0,
5939         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5940         URL_FILE_USE_PATHURL,S_OK,FALSE,
5941         {
5942             {"file://\\\\test.com\\testing.mp3",S_OK},
5943             {"test.com",S_OK},
5944             {"file://\\\\test.com\\testing.mp3",S_OK},
5945             {"test.com",S_OK},
5946             {".mp3",S_OK},
5947             {"",S_FALSE},
5948             {"test.com",S_OK},
5949             {"",S_FALSE},
5950             {"\\testing.mp3",S_OK},
5951             {"\\testing.mp3",S_OK},
5952             {"",S_FALSE},
5953             {"file://\\\\test.com\\testing.mp3",S_OK},
5954             {"file",S_OK},
5955             {"",S_FALSE},
5956             {"",S_FALSE}
5957         },
5958         {
5959             {Uri_HOST_DNS,S_OK},
5960             {0,S_FALSE},
5961             {URL_SCHEME_FILE,S_OK},
5962             {URLZONE_INVALID,E_NOTIMPL}
5963         }
5964     },
5965     /* URL_DONT_SIMPLIFY has no effect. */
5966     {   "http://google.com/test",0,
5967         "zip://test.com/cool/../cool/test",0,
5968         URL_DONT_SIMPLIFY,S_OK,FALSE,
5969         {
5970             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
5971             {"test.com",S_OK},
5972             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
5973             {"test.com",S_OK},
5974             {"",S_FALSE},
5975             {"",S_FALSE},
5976             {"test.com",S_OK},
5977             {"",S_FALSE},
5978             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
5979             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
5980             {"",S_FALSE},
5981             /* The resulting IUri has the same Raw URI as the relative URI (only IE 8).
5982              * On IE 7 it reduces the path in the Raw URI.
5983              */
5984             {"zip://test.com/cool/../cool/test",S_OK,FALSE,"zip://test.com/cool/test"},
5985             {"zip",S_OK},
5986             {"",S_FALSE},
5987             {"",S_FALSE}
5988         },
5989         {
5990             {Uri_HOST_DNS,S_OK},
5991             {0,S_FALSE},
5992             {URL_SCHEME_UNKNOWN,S_OK},
5993             {URLZONE_INVALID,E_NOTIMPL}
5994         }
5995     },
5996     /* FILE_USE_PATHURL has no effect in IE 8, in IE 7 the
5997      * resulting URI is converted into a dos path.
5998      */
5999     {   "http://google.com/test",0,
6000         "file:///c:/test/",0,
6001         URL_FILE_USE_PATHURL,S_OK,FALSE,
6002         {
6003             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
6004             {"",S_FALSE},
6005             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
6006             {"",S_FALSE},
6007             {"",S_FALSE},
6008             {"",S_FALSE},
6009             {"",S_FALSE},
6010             {"",S_FALSE},
6011             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
6012             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
6013             {"",S_FALSE},
6014             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
6015             {"file",S_OK},
6016             {"",S_FALSE},
6017             {"",S_FALSE}
6018         },
6019         {
6020             {Uri_HOST_UNKNOWN,S_OK},
6021             {0,S_FALSE},
6022             {URL_SCHEME_FILE,S_OK},
6023             {URLZONE_INVALID,E_NOTIMPL}
6024         }
6025     },
6026     {   "http://google.com/test",0,
6027         "http://test.com/test#%30test",0,
6028         URL_DONT_UNESCAPE_EXTRA_INFO,S_OK,FALSE,
6029         {
6030             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
6031             {"test.com",S_OK},
6032             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
6033             {"test.com",S_OK},
6034             {"",S_FALSE},
6035             {"#0test",S_OK,FALSE,NULL,"#%30test"},
6036             {"test.com",S_OK},
6037             {"",S_FALSE},
6038             {"/test",S_OK},
6039             {"/test",S_OK},
6040             {"",S_FALSE},
6041             /* IE 7 decodes the %30 to a 0 in the Raw URI. */
6042             {"http://test.com/test#%30test",S_OK,FALSE,"http://test.com/test#0test"},
6043             {"http",S_OK},
6044             {"",S_FALSE},
6045             {"",S_FALSE}
6046         },
6047         {
6048             {Uri_HOST_DNS,S_OK},
6049             {80,S_OK},
6050             {URL_SCHEME_HTTP,S_OK},
6051             {URLZONE_INVALID,E_NOTIMPL}
6052         }
6053     },
6054     /* Windows validates the path component from the relative Uri. */
6055     {   "http://google.com/test",0,
6056         "/Te%XXst",Uri_CREATE_ALLOW_RELATIVE,
6057         0,E_INVALIDARG,FALSE
6058     },
6059     /* Windows doesn't validate the query from the relative Uri. */
6060     {   "http://google.com/test",0,
6061         "?Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
6062         0,S_OK,FALSE,
6063         {
6064             {"http://google.com/test?Tes%XXt",S_OK},
6065             {"google.com",S_OK},
6066             {"http://google.com/test?Tes%XXt",S_OK},
6067             {"google.com",S_OK},
6068             {"",S_FALSE},
6069             {"",S_FALSE},
6070             {"google.com",S_OK},
6071             {"",S_FALSE},
6072             {"/test",S_OK},
6073             {"/test?Tes%XXt",S_OK},
6074             {"?Tes%XXt",S_OK},
6075             {"http://google.com/test?Tes%XXt",S_OK},
6076             {"http",S_OK},
6077             {"",S_FALSE},
6078             {"",S_FALSE}
6079         },
6080         {
6081             {Uri_HOST_DNS,S_OK},
6082             {80,S_OK},
6083             {URL_SCHEME_HTTP,S_OK},
6084             {URLZONE_INVALID,E_NOTIMPL}
6085         }
6086     },
6087     /* Windows doesn't validate the fragment from the relative Uri. */
6088     {   "http://google.com/test",0,
6089         "#Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
6090         0,S_OK,FALSE,
6091         {
6092             {"http://google.com/test#Tes%XXt",S_OK},
6093             {"google.com",S_OK},
6094             {"http://google.com/test#Tes%XXt",S_OK},
6095             {"google.com",S_OK},
6096             {"",S_FALSE},
6097             {"#Tes%XXt",S_OK},
6098             {"google.com",S_OK},
6099             {"",S_FALSE},
6100             {"/test",S_OK},
6101             {"/test",S_OK},
6102             {"",S_FALSE},
6103             {"http://google.com/test#Tes%XXt",S_OK},
6104             {"http",S_OK},
6105             {"",S_FALSE},
6106             {"",S_FALSE}
6107         },
6108         {
6109             {Uri_HOST_DNS,S_OK},
6110             {80,S_OK},
6111             {URL_SCHEME_HTTP,S_OK},
6112             {URLZONE_INVALID,E_NOTIMPL}
6113         }
6114     },
6115     /* Creates an IUri which contains an invalid dos path char. */
6116     {   "file:///c:/test",0,
6117         "/test<ing",Uri_CREATE_ALLOW_RELATIVE,
6118         URL_FILE_USE_PATHURL,S_OK,FALSE,
6119         {
6120             {"file://c:\\test<ing",S_OK},
6121             {"",S_FALSE},
6122             {"file://c:\\test<ing",S_OK},
6123             {"",S_FALSE},
6124             {"",S_FALSE},
6125             {"",S_FALSE},
6126             {"",S_FALSE},
6127             {"",S_FALSE},
6128             {"c:\\test<ing",S_OK},
6129             {"c:\\test<ing",S_OK},
6130             {"",S_FALSE},
6131             {"file://c:\\test<ing",S_OK},
6132             {"file",S_OK},
6133             {"",S_FALSE},
6134             {"",S_FALSE}
6135         },
6136         {
6137             {Uri_HOST_UNKNOWN,S_OK},
6138             {0,S_FALSE},
6139             {URL_SCHEME_FILE,S_OK},
6140             {URLZONE_INVALID,E_NOTIMPL}
6141         }
6142     },
6143     /* Appends the path after the drive letter (if any). */
6144     {   "file:///c:/test",0,
6145         "/c:/testing",Uri_CREATE_ALLOW_RELATIVE,
6146         0,S_OK,FALSE,
6147         {
6148             {"file:///c:/c:/testing",S_OK},
6149             {"",S_FALSE},
6150             {"file:///c:/c:/testing",S_OK},
6151             {"",S_FALSE},
6152             {"",S_FALSE},
6153             {"",S_FALSE},
6154             {"",S_FALSE},
6155             {"",S_FALSE},
6156             {"/c:/c:/testing",S_OK},
6157             {"/c:/c:/testing",S_OK},
6158             {"",S_FALSE},
6159             {"file:///c:/c:/testing",S_OK},
6160             {"file",S_OK},
6161             {"",S_FALSE},
6162             {"",S_FALSE}
6163         },
6164         {
6165             {Uri_HOST_UNKNOWN,S_OK},
6166             {0,S_FALSE},
6167             {URL_SCHEME_FILE,S_OK},
6168             {URLZONE_INVALID,E_NOTIMPL}
6169         }
6170     },
6171     /* A '/' is added if the base URI doesn't have a path and the
6172      * relative URI doesn't contain a path (since the base URI is
6173      * hierarchical.
6174      */
6175     {   "http://google.com",Uri_CREATE_NO_CANONICALIZE,
6176         "?test",Uri_CREATE_ALLOW_RELATIVE,
6177         0,S_OK,FALSE,
6178         {
6179             {"http://google.com/?test",S_OK},
6180             {"google.com",S_OK},
6181             {"http://google.com/?test",S_OK},
6182             {"google.com",S_OK},
6183             {"",S_FALSE},
6184             {"",S_FALSE},
6185             {"google.com",S_OK},
6186             {"",S_FALSE},
6187             {"/",S_OK},
6188             {"/?test",S_OK},
6189             {"?test",S_OK},
6190             {"http://google.com/?test",S_OK},
6191             {"http",S_OK},
6192             {"",S_FALSE},
6193             {"",S_FALSE}
6194         },
6195         {
6196             {Uri_HOST_DNS,S_OK},
6197             {80,S_OK},
6198             {URL_SCHEME_HTTP,S_OK},
6199             {URLZONE_INVALID,E_NOTIMPL}
6200         }
6201     },
6202     {   "zip://google.com",Uri_CREATE_NO_CANONICALIZE,
6203         "?test",Uri_CREATE_ALLOW_RELATIVE,
6204         0,S_OK,FALSE,
6205         {
6206             {"zip://google.com/?test",S_OK},
6207             {"google.com",S_OK},
6208             {"zip://google.com/?test",S_OK},
6209             {"google.com",S_OK},
6210             {"",S_FALSE},
6211             {"",S_FALSE},
6212             {"google.com",S_OK},
6213             {"",S_FALSE},
6214             {"/",S_OK},
6215             {"/?test",S_OK},
6216             {"?test",S_OK},
6217             {"zip://google.com/?test",S_OK},
6218             {"zip",S_OK},
6219             {"",S_FALSE},
6220             {"",S_FALSE}
6221         },
6222         {
6223             {Uri_HOST_DNS,S_OK},
6224             {0,S_FALSE},
6225             {URL_SCHEME_UNKNOWN,S_OK},
6226             {URLZONE_INVALID,E_NOTIMPL}
6227         }
6228     },
6229     /* No path is appended since the base URI is opaque. */
6230     {   "zip:?testing",0,
6231         "?test",Uri_CREATE_ALLOW_RELATIVE,
6232         0,S_OK,FALSE,
6233         {
6234             {"zip:?test",S_OK},
6235             {"",S_FALSE},
6236             {"zip:?test",S_OK},
6237             {"",S_FALSE},
6238             {"",S_FALSE},
6239             {"",S_FALSE},
6240             {"",S_FALSE},
6241             {"",S_FALSE},
6242             {"",S_OK},
6243             {"?test",S_OK},
6244             {"?test",S_OK},
6245             {"zip:?test",S_OK},
6246             {"zip",S_OK},
6247             {"",S_FALSE},
6248             {"",S_FALSE}
6249         },
6250         {
6251             {Uri_HOST_UNKNOWN,S_OK},
6252             {0,S_FALSE},
6253             {URL_SCHEME_UNKNOWN,S_OK},
6254             {URLZONE_INVALID,E_NOTIMPL}
6255         }
6256     },
6257     {   "file:///c:/",0,
6258         "../testing/test",Uri_CREATE_ALLOW_RELATIVE,
6259         0,S_OK,FALSE,
6260         {
6261             {"file:///c:/testing/test",S_OK},
6262             {"",S_FALSE},
6263             {"file:///c:/testing/test",S_OK},
6264             {"",S_FALSE},
6265             {"",S_FALSE},
6266             {"",S_FALSE},
6267             {"",S_FALSE},
6268             {"",S_FALSE},
6269             {"/c:/testing/test",S_OK},
6270             {"/c:/testing/test",S_OK},
6271             {"",S_FALSE},
6272             {"file:///c:/testing/test",S_OK},
6273             {"file",S_OK},
6274             {"",S_FALSE},
6275             {"",S_FALSE}
6276         },
6277         {
6278             {Uri_HOST_UNKNOWN,S_OK},
6279             {0,S_FALSE},
6280             {URL_SCHEME_FILE,S_OK},
6281             {URLZONE_INVALID,E_NOTIMPL}
6282         }
6283     },
6284     {   "http://winehq.org/dir/testfile",0,
6285         "test?querystring",Uri_CREATE_ALLOW_RELATIVE,
6286         0,S_OK,FALSE,
6287         {
6288             {"http://winehq.org/dir/test?querystring",S_OK},
6289             {"winehq.org",S_OK},
6290             {"http://winehq.org/dir/test?querystring",S_OK},
6291             {"winehq.org",S_OK},
6292             {"",S_FALSE},
6293             {"",S_FALSE},
6294             {"winehq.org",S_OK},
6295             {"",S_FALSE},
6296             {"/dir/test",S_OK},
6297             {"/dir/test?querystring",S_OK},
6298             {"?querystring",S_OK},
6299             {"http://winehq.org/dir/test?querystring",S_OK},
6300             {"http",S_OK},
6301             {"",S_FALSE},
6302             {"",S_FALSE}
6303         },
6304         {
6305             {Uri_HOST_DNS,S_OK},
6306             {80,S_OK},
6307             {URL_SCHEME_HTTP,S_OK},
6308             {URLZONE_INVALID,E_NOTIMPL}
6309         }
6310     },
6311     {   "http://winehq.org/dir/test",0,
6312         "test?querystring",Uri_CREATE_ALLOW_RELATIVE,
6313         0,S_OK,FALSE,
6314         {
6315             {"http://winehq.org/dir/test?querystring",S_OK},
6316             {"winehq.org",S_OK},
6317             {"http://winehq.org/dir/test?querystring",S_OK},
6318             {"winehq.org",S_OK},
6319             {"",S_FALSE},
6320             {"",S_FALSE},
6321             {"winehq.org",S_OK},
6322             {"",S_FALSE},
6323             {"/dir/test",S_OK},
6324             {"/dir/test?querystring",S_OK},
6325             {"?querystring",S_OK},
6326             {"http://winehq.org/dir/test?querystring",S_OK},
6327             {"http",S_OK},
6328             {"",S_FALSE},
6329             {"",S_FALSE}
6330         },
6331         {
6332             {Uri_HOST_DNS,S_OK},
6333             {80,S_OK},
6334             {URL_SCHEME_HTTP,S_OK},
6335             {URLZONE_INVALID,E_NOTIMPL}
6336         }
6337     },
6338     {   "http://winehq.org/dir/test?querystring",0,
6339         "#hash",Uri_CREATE_ALLOW_RELATIVE,
6340         0,S_OK,FALSE,
6341         {
6342             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6343             {"winehq.org",S_OK},
6344             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6345             {"winehq.org",S_OK},
6346             {"",S_FALSE},
6347             {"#hash",S_OK},
6348             {"winehq.org",S_OK},
6349             {"",S_FALSE},
6350             {"/dir/test",S_OK},
6351             {"/dir/test?querystring",S_OK},
6352             {"?querystring",S_OK},
6353             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6354             {"http",S_OK},
6355             {"",S_FALSE},
6356             {"",S_FALSE}
6357         },
6358         {
6359             {Uri_HOST_DNS,S_OK},
6360             {80,S_OK},
6361             {URL_SCHEME_HTTP,S_OK},
6362             {URLZONE_INVALID,E_NOTIMPL}
6363         }
6364     },
6365     {   "mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir\\file.txt",0,
6366         "relative/path.txt",Uri_CREATE_ALLOW_RELATIVE,
6367         0,S_OK,FALSE,
6368         {
6369             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6370             {"",S_FALSE},
6371             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6372             {"",S_FALSE},
6373             {".txt",S_OK},
6374             {"",S_FALSE},
6375             {"",S_FALSE},
6376             {"",S_FALSE},
6377             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6378             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6379             {"",S_FALSE},
6380             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6381             {"mk",S_OK},
6382             {"",S_FALSE},
6383             {"",S_FALSE}
6384         },
6385         {
6386             {Uri_HOST_UNKNOWN,S_OK},
6387             {0,S_FALSE},
6388             {URL_SCHEME_MK,S_OK},
6389             {URLZONE_INVALID,E_NOTIMPL}
6390         }
6391     },
6392     {   "mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::\\subdir\\file.txt",0,
6393         "relative/path.txt",Uri_CREATE_ALLOW_RELATIVE,
6394         0,S_OK,FALSE,
6395         {
6396             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6397             {"",S_FALSE},
6398             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6399             {"",S_FALSE},
6400             {".txt",S_OK},
6401             {"",S_FALSE},
6402             {"",S_FALSE},
6403             {"",S_FALSE},
6404             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6405             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6406             {"",S_FALSE},
6407             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6408             {"mk",S_OK},
6409             {"",S_FALSE},
6410             {"",S_FALSE}
6411         },
6412         {
6413             {Uri_HOST_UNKNOWN,S_OK},
6414             {0,S_FALSE},
6415             {URL_SCHEME_MK,S_OK},
6416             {URLZONE_INVALID,E_NOTIMPL}
6417         }
6418     },
6419     {   "mk:@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir\\file.txt",0,
6420         "relative\\path.txt",Uri_CREATE_ALLOW_RELATIVE,
6421         0,S_OK,FALSE,
6422         {
6423             {"mk:@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6424             {"",S_FALSE},
6425             {"mk:@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6426             {"",S_FALSE},
6427             {".txt",S_OK},
6428             {"",S_FALSE},
6429             {"",S_FALSE},
6430             {"",S_FALSE},
6431             {"@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6432             {"@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6433             {"",S_FALSE},
6434             {"mk:@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6435             {"mk",S_OK},
6436             {"",S_FALSE},
6437             {"",S_FALSE}
6438         },
6439         {
6440             {Uri_HOST_UNKNOWN,S_OK},
6441             {0,S_FALSE},
6442             {URL_SCHEME_MK,S_OK},
6443             {URLZONE_INVALID,E_NOTIMPL}
6444         }
6445     }
6446 };
6447
6448 typedef struct _uri_parse_test {
6449     const char  *uri;
6450     DWORD       uri_flags;
6451     PARSEACTION action;
6452     DWORD       flags;
6453     const char  *property;
6454     HRESULT     expected;
6455     BOOL        todo;
6456 } uri_parse_test;
6457
6458 static const uri_parse_test uri_parse_tests[] = {
6459     /* PARSE_CANONICALIZE tests. */
6460     {"zip://google.com/test<|>",0,PARSE_CANONICALIZE,0,"zip://google.com/test<|>",S_OK,FALSE},
6461     {"http://google.com/test<|>",0,PARSE_CANONICALIZE,0,"http://google.com/test%3C%7C%3E",S_OK,FALSE},
6462     {"http://google.com/%30%23%3F",0,PARSE_CANONICALIZE,URL_UNESCAPE,"http://google.com/0#?",S_OK,FALSE},
6463     {"test <|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_ESCAPE_UNSAFE,"test %3C%7C%3E",S_OK,FALSE},
6464     {"test <|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_ESCAPE_SPACES_ONLY,"test%20<|>",S_OK,FALSE},
6465     {"test%20<|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_UNESCAPE|URL_ESCAPE_UNSAFE,"test%20%3C%7C%3E",S_OK,FALSE},
6466     {"http://google.com/%20",0,PARSE_CANONICALIZE,URL_ESCAPE_PERCENT,"http://google.com/%2520",S_OK,FALSE},
6467     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_DONT_SIMPLIFY,"http://google.com/test/../",S_OK,FALSE},
6468     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_NO_META,"http://google.com/test/../",S_OK,FALSE},
6469     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,0,"http://google.com/",S_OK,FALSE},
6470     {"zip://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,0,"zip://google.com/",S_OK,FALSE},
6471     {"file:///c:/test/../test",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_DONT_SIMPLIFY,"file:///c:/test/../test",S_OK,FALSE},
6472
6473     /* PARSE_FRIENDLY tests. */
6474     {"http://test@google.com/test#test",0,PARSE_FRIENDLY,0,"http://google.com/test#test",S_OK,FALSE},
6475     {"zip://test@google.com/test",0,PARSE_FRIENDLY,0,"zip://test@google.com/test",S_OK,FALSE},
6476
6477     /* PARSE_ROOTDOCUMENT tests. */
6478     {"http://google.com:200/test/test",0,PARSE_ROOTDOCUMENT,0,"http://google.com:200/",S_OK,FALSE},
6479     {"http://google.com",Uri_CREATE_NO_CANONICALIZE,PARSE_ROOTDOCUMENT,0,"http://google.com/",S_OK,FALSE},
6480     {"zip://google.com/",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6481     {"file:///c:/testing/",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6482     {"file://server/test",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6483     {"zip:test/test",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6484
6485     /* PARSE_DOCUMENT tests. */
6486     {"http://test@google.com/test?query#frag",0,PARSE_DOCUMENT,0,"http://test@google.com/test?query",S_OK,FALSE},
6487     {"http:testing#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6488     {"file:///c:/test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6489     {"zip://google.com/#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6490     {"zip:test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6491     {"testing#frag",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6492
6493     /* PARSE_PATH_FROM_URL tests. */
6494     {"file:///c:/test.mp3",0,PARSE_PATH_FROM_URL,0,"c:\\test.mp3",S_OK,FALSE},
6495     {"file:///c:/t<|>est.mp3",0,PARSE_PATH_FROM_URL,0,"c:\\t<|>est.mp3",S_OK,FALSE},
6496     {"file:///c:/te%XX t/",0,PARSE_PATH_FROM_URL,0,"c:\\te%XX t\\",S_OK,FALSE},
6497     {"file://server/test",0,PARSE_PATH_FROM_URL,0,"\\\\server\\test",S_OK,FALSE},
6498     {"http://google.com/",0,PARSE_PATH_FROM_URL,0,"",E_INVALIDARG,FALSE},
6499
6500     /* PARSE_URL_FROM_PATH tests. */
6501     /* This function almost seems to useless (just returns the absolute uri). */
6502     {"test.com",Uri_CREATE_ALLOW_RELATIVE,PARSE_URL_FROM_PATH,0,"test.com",S_OK,FALSE},
6503     {"/test/test",Uri_CREATE_ALLOW_RELATIVE,PARSE_URL_FROM_PATH,0,"/test/test",S_OK,FALSE},
6504     {"file://c:\\test\\test",Uri_CREATE_FILE_USE_DOS_PATH,PARSE_URL_FROM_PATH,0,"file://c:\\test\\test",S_OK,FALSE},
6505     {"file:c:/test",0,PARSE_URL_FROM_PATH,0,"",S_OK,FALSE},
6506     {"http:google.com/",0,PARSE_URL_FROM_PATH,0,"",S_OK,FALSE},
6507
6508     /* PARSE_SCHEMA tests. */
6509     {"http://google.com/test",0,PARSE_SCHEMA,0,"http",S_OK,FALSE},
6510     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_SCHEMA,0,"",S_OK,FALSE},
6511
6512     /* PARSE_SITE tests. */
6513     {"http://google.uk.com/",0,PARSE_SITE,0,"google.uk.com",S_OK,FALSE},
6514     {"http://google.com.com/",0,PARSE_SITE,0,"google.com.com",S_OK,FALSE},
6515     {"google.com",Uri_CREATE_ALLOW_RELATIVE,PARSE_SITE,0,"",S_OK,FALSE},
6516     {"file://server/test",0,PARSE_SITE,0,"server",S_OK,FALSE},
6517
6518     /* PARSE_DOMAIN tests. */
6519     {"http://google.com.uk/",0,PARSE_DOMAIN,0,"google.com.uk",S_OK,FALSE},
6520     {"http://google.com.com/",0,PARSE_DOMAIN,0,"com.com",S_OK,FALSE},
6521     {"test/test",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOMAIN,0,"",S_OK,FALSE},
6522     {"file://server/test",0,PARSE_DOMAIN,0,"",S_OK,FALSE},
6523
6524     /* PARSE_LOCATION and PARSE_ANCHOR tests. */
6525     {"http://google.com/test#Test",0,PARSE_ANCHOR,0,"#Test",S_OK,FALSE},
6526     {"http://google.com/test#Test",0,PARSE_LOCATION,0,"#Test",S_OK,FALSE},
6527     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_ANCHOR,0,"",S_OK,FALSE},
6528     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_LOCATION,0,"",S_OK,FALSE}
6529 };
6530
6531 static inline LPWSTR a2w(LPCSTR str) {
6532     LPWSTR ret = NULL;
6533
6534     if(str) {
6535         DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
6536         ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
6537         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
6538     }
6539
6540     return ret;
6541 }
6542
6543 static inline BOOL heap_free(void* mem) {
6544     return HeapFree(GetProcessHeap(), 0, mem);
6545 }
6546
6547 static inline DWORD strcmp_aw(LPCSTR strA, LPCWSTR strB) {
6548     LPWSTR strAW = a2w(strA);
6549     DWORD ret = lstrcmpW(strAW, strB);
6550     heap_free(strAW);
6551     return ret;
6552 }
6553
6554 static inline ULONG get_refcnt(IUri *uri) {
6555     IUri_AddRef(uri);
6556     return IUri_Release(uri);
6557 }
6558
6559 static void change_property(IUriBuilder *builder, const uri_builder_property *prop,
6560                             DWORD test_index) {
6561     HRESULT hr;
6562     LPWSTR valueW;
6563
6564     valueW = a2w(prop->value);
6565     switch(prop->property) {
6566     case Uri_PROPERTY_FRAGMENT:
6567         hr = IUriBuilder_SetFragment(builder, valueW);
6568         if(prop->todo) {
6569             todo_wine {
6570                 ok(hr == prop->expected,
6571                     "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6572                     hr, prop->expected, test_index);
6573             }
6574         } else {
6575             ok(hr == prop->expected,
6576                 "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6577                 hr, prop->expected, test_index);
6578         }
6579         break;
6580     case Uri_PROPERTY_HOST:
6581         hr = IUriBuilder_SetHost(builder, valueW);
6582         if(prop->todo) {
6583             todo_wine {
6584                 ok(hr == prop->expected,
6585                     "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6586                     hr, prop->expected, test_index);
6587             }
6588         } else {
6589             ok(hr == prop->expected,
6590                 "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6591                 hr, prop->expected, test_index);
6592         }
6593         break;
6594     case Uri_PROPERTY_PASSWORD:
6595         hr = IUriBuilder_SetPassword(builder, valueW);
6596         if(prop->todo) {
6597             todo_wine {
6598                 ok(hr == prop->expected,
6599                     "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6600                     hr, prop->expected, test_index);
6601             }
6602         } else {
6603             ok(hr == prop->expected,
6604                 "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6605                 hr, prop->expected, test_index);
6606         }
6607         break;
6608     case Uri_PROPERTY_PATH:
6609         hr = IUriBuilder_SetPath(builder, valueW);
6610         if(prop->todo) {
6611             todo_wine {
6612                 ok(hr == prop->expected,
6613                     "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6614                     hr, prop->expected, test_index);
6615             }
6616         } else {
6617             ok(hr == prop->expected,
6618                 "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6619                 hr, prop->expected, test_index);
6620         }
6621         break;
6622     case Uri_PROPERTY_QUERY:
6623         hr = IUriBuilder_SetQuery(builder, valueW);
6624         if(prop->todo) {
6625             todo_wine {
6626                 ok(hr == prop->expected,
6627                     "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6628                     hr, prop->expected, test_index);
6629             }
6630         } else {
6631             ok(hr == prop->expected,
6632                 "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6633                 hr, prop->expected, test_index);
6634         }
6635         break;
6636     case Uri_PROPERTY_SCHEME_NAME:
6637         hr = IUriBuilder_SetSchemeName(builder, valueW);
6638         if(prop->todo) {
6639             todo_wine {
6640                 ok(hr == prop->expected,
6641                     "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6642                     hr, prop->expected, test_index);
6643             }
6644         } else {
6645             ok(hr == prop->expected,
6646                 "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6647                 hr, prop->expected, test_index);
6648         }
6649         break;
6650     case Uri_PROPERTY_USER_NAME:
6651         hr = IUriBuilder_SetUserName(builder, valueW);
6652         if(prop->todo) {
6653             todo_wine {
6654                 ok(hr == prop->expected,
6655                     "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6656                     hr, prop->expected, test_index);
6657             }
6658         } else {
6659             ok(hr == prop->expected,
6660                 "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6661                 hr, prop->expected, test_index);
6662         }
6663         break;
6664     default:
6665         trace("Unsupported operation for %d on uri_builder_tests[%d].\n", prop->property, test_index);
6666     }
6667
6668     heap_free(valueW);
6669 }
6670
6671 /*
6672  * Simple tests to make sure the CreateUri function handles invalid flag combinations
6673  * correctly.
6674  */
6675 static void test_CreateUri_InvalidFlags(void) {
6676     DWORD i;
6677
6678     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
6679         HRESULT hr;
6680         IUri *uri = (void*) 0xdeadbeef;
6681
6682         hr = pCreateUri(http_urlW, invalid_flag_tests[i].flags, 0, &uri);
6683         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUri returned 0x%08x, expected 0x%08x, flags=0x%08x\n",
6684                 hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
6685         ok(uri == NULL, "Error: expected the IUri to be NULL, but it was %p instead\n", uri);
6686     }
6687 }
6688
6689 static void test_CreateUri_InvalidArgs(void) {
6690     HRESULT hr;
6691     IUri *uri = (void*) 0xdeadbeef;
6692
6693     const WCHAR invalidW[] = {'i','n','v','a','l','i','d',0};
6694     static const WCHAR emptyW[] = {0};
6695
6696     hr = pCreateUri(http_urlW, 0, 0, NULL);
6697     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6698
6699     hr = pCreateUri(NULL, 0, 0, &uri);
6700     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6701     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6702
6703     uri = (void*) 0xdeadbeef;
6704     hr = pCreateUri(invalidW, 0, 0, &uri);
6705     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6706     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6707
6708     uri = (void*) 0xdeadbeef;
6709     hr = pCreateUri(emptyW, 0, 0, &uri);
6710     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6711     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6712 }
6713
6714 static void test_CreateUri_InvalidUri(void) {
6715     DWORD i;
6716
6717     for(i = 0; i < sizeof(invalid_uri_tests)/sizeof(invalid_uri_tests[0]); ++i) {
6718         invalid_uri test = invalid_uri_tests[i];
6719         IUri *uri = NULL;
6720         LPWSTR uriW;
6721         HRESULT hr;
6722
6723         uriW = a2w(test.uri);
6724         hr = pCreateUri(uriW, test.flags, 0, &uri);
6725         if(test.todo) {
6726             todo_wine {
6727                 ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6728                     hr, E_INVALIDARG, i);
6729             }
6730         } else {
6731             ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6732                 hr, E_INVALIDARG, i);
6733         }
6734         if(uri) IUri_Release(uri);
6735
6736         heap_free(uriW);
6737     }
6738 }
6739
6740 static void test_IUri_GetPropertyBSTR(void) {
6741     IUri *uri = NULL;
6742     HRESULT hr;
6743     DWORD i;
6744
6745     /* Make sure GetPropertyBSTR handles invalid args correctly. */
6746     hr = pCreateUri(http_urlW, 0, 0, &uri);
6747     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6748     if(SUCCEEDED(hr)) {
6749         BSTR received = NULL;
6750
6751         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_RAW_URI, NULL, 0);
6752         ok(hr == E_POINTER, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6753
6754         /* Make sure it handles a invalid Uri_PROPERTY's correctly. */
6755         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_PORT, &received, 0);
6756         ok(hr == S_OK, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6757         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6758         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6759         SysFreeString(received);
6760
6761         /* Make sure it handles the ZONE property correctly. */
6762         received = NULL;
6763         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_ZONE, &received, 0);
6764         ok(hr == S_FALSE, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_FALSE);
6765         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6766         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6767         SysFreeString(received);
6768     }
6769     if(uri) IUri_Release(uri);
6770
6771     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6772         uri_properties test = uri_tests[i];
6773         LPWSTR uriW;
6774         uri = NULL;
6775
6776         uriW = a2w(test.uri);
6777         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6778         if(test.create_todo) {
6779             todo_wine {
6780                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6781                         hr, test.create_expected, i);
6782             }
6783         } else {
6784             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6785                     hr, test.create_expected, i);
6786         }
6787
6788         if(SUCCEEDED(hr)) {
6789             DWORD j;
6790
6791             /* Checks all the string properties of the uri. */
6792             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
6793                 BSTR received = NULL;
6794                 uri_str_property prop = test.str_props[j];
6795
6796                 hr = IUri_GetPropertyBSTR(uri, j, &received, 0);
6797                 if(prop.todo) {
6798                     todo_wine {
6799                         ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6800                                 hr, prop.expected, i, j);
6801                     }
6802                     todo_wine {
6803                         ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6804                                 "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6805                                 prop.value, wine_dbgstr_w(received), i, j);
6806                     }
6807                 } else {
6808                     ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6809                             hr, prop.expected, i, j);
6810                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6811                             "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6812                             prop.value, wine_dbgstr_w(received), i, j);
6813                 }
6814
6815                 SysFreeString(received);
6816             }
6817         }
6818
6819         if(uri) IUri_Release(uri);
6820
6821         heap_free(uriW);
6822     }
6823 }
6824
6825 static void test_IUri_GetPropertyDWORD(void) {
6826     IUri *uri = NULL;
6827     HRESULT hr;
6828     DWORD i;
6829
6830     hr = pCreateUri(http_urlW, 0, 0, &uri);
6831     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6832     if(SUCCEEDED(hr)) {
6833         DWORD received = 0xdeadbeef;
6834
6835         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_DWORD_START, NULL, 0);
6836         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6837
6838         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_ABSOLUTE_URI, &received, 0);
6839         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6840         ok(received == 0, "Error: Expected received=%d but instead received=%d.\n", 0, received);
6841     }
6842     if(uri) IUri_Release(uri);
6843
6844     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6845         uri_properties test = uri_tests[i];
6846         LPWSTR uriW;
6847         uri = NULL;
6848
6849         uriW = a2w(test.uri);
6850         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6851         if(test.create_todo) {
6852             todo_wine {
6853                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6854                         hr, test.create_expected, i);
6855             }
6856         } else {
6857             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6858                     hr, test.create_expected, i);
6859         }
6860
6861         if(SUCCEEDED(hr)) {
6862             DWORD j;
6863
6864             /* Checks all the DWORD properties of the uri. */
6865             for(j = 0; j < sizeof(test.dword_props)/sizeof(test.dword_props[0]); ++j) {
6866                 DWORD received;
6867                 uri_dword_property prop = test.dword_props[j];
6868
6869                 hr = IUri_GetPropertyDWORD(uri, j+Uri_PROPERTY_DWORD_START, &received, 0);
6870                 if(prop.todo) {
6871                     todo_wine {
6872                         ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
6873                                 hr, prop.expected, i, j);
6874                     }
6875                     todo_wine {
6876                         ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
6877                                 prop.value, received, i, j);
6878                     }
6879                 } else {
6880                     ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
6881                             hr, prop.expected, i, j);
6882                     ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
6883                             prop.value, received, i, j);
6884                 }
6885             }
6886         }
6887
6888         if(uri) IUri_Release(uri);
6889
6890         heap_free(uriW);
6891     }
6892 }
6893
6894 /* Tests all the 'Get*' property functions which deal with strings. */
6895 static void test_IUri_GetStrProperties(void) {
6896     IUri *uri = NULL;
6897     HRESULT hr;
6898     DWORD i;
6899
6900     /* Make sure all the 'Get*' string property functions handle invalid args correctly. */
6901     hr = pCreateUri(http_urlW, 0, 0, &uri);
6902     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6903     if(SUCCEEDED(hr)) {
6904         hr = IUri_GetAbsoluteUri(uri, NULL);
6905         ok(hr == E_POINTER, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6906
6907         hr = IUri_GetAuthority(uri, NULL);
6908         ok(hr == E_POINTER, "Error: GetAuthority returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6909
6910         hr = IUri_GetDisplayUri(uri, NULL);
6911         ok(hr == E_POINTER, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6912
6913         hr = IUri_GetDomain(uri, NULL);
6914         ok(hr == E_POINTER, "Error: GetDomain returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6915
6916         hr = IUri_GetExtension(uri, NULL);
6917         ok(hr == E_POINTER, "Error: GetExtension returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6918
6919         hr = IUri_GetFragment(uri, NULL);
6920         ok(hr == E_POINTER, "Error: GetFragment returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6921
6922         hr = IUri_GetHost(uri, NULL);
6923         ok(hr == E_POINTER, "Error: GetHost returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6924
6925         hr = IUri_GetPassword(uri, NULL);
6926         ok(hr == E_POINTER, "Error: GetPassword returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6927
6928         hr = IUri_GetPath(uri, NULL);
6929         ok(hr == E_POINTER, "Error: GetPath returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6930
6931         hr = IUri_GetPathAndQuery(uri, NULL);
6932         ok(hr == E_POINTER, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6933
6934         hr = IUri_GetQuery(uri, NULL);
6935         ok(hr == E_POINTER, "Error: GetQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6936
6937         hr = IUri_GetRawUri(uri, NULL);
6938         ok(hr == E_POINTER, "Error: GetRawUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6939
6940         hr = IUri_GetSchemeName(uri, NULL);
6941         ok(hr == E_POINTER, "Error: GetSchemeName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6942
6943         hr = IUri_GetUserInfo(uri, NULL);
6944         ok(hr == E_POINTER, "Error: GetUserInfo returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6945
6946         hr = IUri_GetUserName(uri, NULL);
6947         ok(hr == E_POINTER, "Error: GetUserName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6948     }
6949     if(uri) IUri_Release(uri);
6950
6951     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6952         uri_properties test = uri_tests[i];
6953         LPWSTR uriW;
6954         uri = NULL;
6955
6956         uriW = a2w(test.uri);
6957         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6958         if(test.create_todo) {
6959             todo_wine {
6960                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6961                         hr, test.create_expected, i);
6962             }
6963         } else {
6964             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6965                     hr, test.create_expected, i);
6966         }
6967
6968         if(SUCCEEDED(hr)) {
6969             uri_str_property prop;
6970             BSTR received = NULL;
6971
6972             /* GetAbsoluteUri() tests. */
6973             prop = test.str_props[Uri_PROPERTY_ABSOLUTE_URI];
6974             hr = IUri_GetAbsoluteUri(uri, &received);
6975             if(prop.todo) {
6976                 todo_wine {
6977                     ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6978                             hr, prop.expected, i);
6979                 }
6980                 todo_wine {
6981                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6982                             "Error: Expected %s but got %s on uri_tests[%d].\n",
6983                             prop.value, wine_dbgstr_w(received), i);
6984                 }
6985             } else {
6986                 ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6987                         hr, prop.expected, i);
6988                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6989                         "Error: Expected %s but got %s on uri_tests[%d].\n",
6990                         prop.value, wine_dbgstr_w(received), i);
6991             }
6992             SysFreeString(received);
6993             received = NULL;
6994
6995             /* GetAuthority() tests. */
6996             prop = test.str_props[Uri_PROPERTY_AUTHORITY];
6997             hr = IUri_GetAuthority(uri, &received);
6998             if(prop.todo) {
6999                 todo_wine {
7000                     ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7001                             hr, prop.expected, i);
7002                 }
7003                 todo_wine {
7004                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7005                             prop.value, wine_dbgstr_w(received), i);
7006                 }
7007             } else {
7008                 ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7009                         hr, prop.expected, i);
7010                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7011                         prop.value, wine_dbgstr_w(received), i);
7012             }
7013             SysFreeString(received);
7014             received = NULL;
7015
7016             /* GetDisplayUri() tests. */
7017             prop = test.str_props[Uri_PROPERTY_DISPLAY_URI];
7018             hr = IUri_GetDisplayUri(uri, &received);
7019             if(prop.todo) {
7020                 todo_wine {
7021                     ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7022                             hr, prop.expected, i);
7023                 }
7024                 todo_wine {
7025                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
7026                             "Error: Expected %s but got %s on uri_test[%d].\n",
7027                             prop.value, wine_dbgstr_w(received), i);
7028                 }
7029             } else {
7030                 ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7031                         hr, prop.expected, i);
7032                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
7033                         "Error: Expected %s but got %s on uri_tests[%d].\n",
7034                         prop.value, wine_dbgstr_w(received), i);
7035             }
7036             SysFreeString(received);
7037             received = NULL;
7038
7039             /* GetDomain() tests. */
7040             prop = test.str_props[Uri_PROPERTY_DOMAIN];
7041             hr = IUri_GetDomain(uri, &received);
7042             if(prop.todo) {
7043                 todo_wine {
7044                     ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7045                             hr, prop.expected, i);
7046                 }
7047                 todo_wine {
7048                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7049                             prop.value, wine_dbgstr_w(received), i);
7050                 }
7051             } else {
7052                 ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7053                         hr, prop.expected, i);
7054                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7055                         prop.value, wine_dbgstr_w(received), i);
7056             }
7057             SysFreeString(received);
7058             received = NULL;
7059
7060             /* GetExtension() tests. */
7061             prop = test.str_props[Uri_PROPERTY_EXTENSION];
7062             hr = IUri_GetExtension(uri, &received);
7063             if(prop.todo) {
7064                 todo_wine {
7065                     ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7066                             hr, prop.expected, i);
7067                 }
7068                 todo_wine {
7069                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7070                             prop.value, wine_dbgstr_w(received), i);
7071                 }
7072             } else {
7073                 ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7074                         hr, prop.expected, i);
7075                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7076                         prop.value, wine_dbgstr_w(received), i);
7077             }
7078             SysFreeString(received);
7079             received = NULL;
7080
7081             /* GetFragment() tests. */
7082             prop = test.str_props[Uri_PROPERTY_FRAGMENT];
7083             hr = IUri_GetFragment(uri, &received);
7084             if(prop.todo) {
7085                 todo_wine {
7086                     ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7087                             hr, prop.expected, i);
7088                 }
7089                 todo_wine {
7090                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7091                             prop.value, wine_dbgstr_w(received), i);
7092                 }
7093             } else {
7094                 ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7095                         hr, prop.expected, i);
7096                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7097                         prop.value, wine_dbgstr_w(received), i);
7098             }
7099             SysFreeString(received);
7100             received = NULL;
7101
7102             /* GetHost() tests. */
7103             prop = test.str_props[Uri_PROPERTY_HOST];
7104             hr = IUri_GetHost(uri, &received);
7105             if(prop.todo) {
7106                 todo_wine {
7107                     ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7108                             hr, prop.expected, i);
7109                 }
7110                 todo_wine {
7111                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7112                             prop.value, wine_dbgstr_w(received), i);
7113                 }
7114             } else {
7115                 ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7116                         hr, prop.expected, i);
7117                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7118                         prop.value, wine_dbgstr_w(received), i);
7119             }
7120             SysFreeString(received);
7121             received = NULL;
7122
7123             /* GetPassword() tests. */
7124             prop = test.str_props[Uri_PROPERTY_PASSWORD];
7125             hr = IUri_GetPassword(uri, &received);
7126             if(prop.todo) {
7127                 todo_wine {
7128                     ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7129                             hr, prop.expected, i);
7130                 }
7131                 todo_wine {
7132                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7133                             prop.value, wine_dbgstr_w(received), i);
7134                 }
7135             } else {
7136                 ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7137                         hr, prop.expected, i);
7138                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7139                         prop.value, wine_dbgstr_w(received), i);
7140             }
7141             SysFreeString(received);
7142             received = NULL;
7143
7144             /* GetPath() tests. */
7145             prop = test.str_props[Uri_PROPERTY_PATH];
7146             hr = IUri_GetPath(uri, &received);
7147             if(prop.todo) {
7148                 todo_wine {
7149                     ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7150                             hr, prop.expected, i);
7151                 }
7152                 todo_wine {
7153                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7154                             prop.value, wine_dbgstr_w(received), i);
7155                 }
7156             } else {
7157                 ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7158                         hr, prop.expected, i);
7159                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7160                         prop.value, wine_dbgstr_w(received), i);
7161             }
7162             SysFreeString(received);
7163             received = NULL;
7164
7165             /* GetPathAndQuery() tests. */
7166             prop = test.str_props[Uri_PROPERTY_PATH_AND_QUERY];
7167             hr = IUri_GetPathAndQuery(uri, &received);
7168             if(prop.todo) {
7169                 todo_wine {
7170                     ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7171                             hr, prop.expected, i);
7172                 }
7173                 todo_wine {
7174                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7175                             prop.value, wine_dbgstr_w(received), i);
7176                 }
7177             } else {
7178                 ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7179                         hr, prop.expected, i);
7180                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7181                         prop.value, wine_dbgstr_w(received), i);
7182             }
7183             SysFreeString(received);
7184             received = NULL;
7185
7186             /* GetQuery() tests. */
7187             prop = test.str_props[Uri_PROPERTY_QUERY];
7188             hr = IUri_GetQuery(uri, &received);
7189             if(prop.todo) {
7190                 todo_wine {
7191                     ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7192                             hr, prop.expected, i);
7193                 }
7194                 todo_wine {
7195                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7196                             prop.value, wine_dbgstr_w(received), i);
7197                 }
7198             } else {
7199                 ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7200                         hr, prop.expected, i);
7201                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7202                         prop.value, wine_dbgstr_w(received), i);
7203             }
7204             SysFreeString(received);
7205             received = NULL;
7206
7207             /* GetRawUri() tests. */
7208             prop = test.str_props[Uri_PROPERTY_RAW_URI];
7209             hr = IUri_GetRawUri(uri, &received);
7210             if(prop.todo) {
7211                 todo_wine {
7212                     ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7213                             hr, prop.expected, i);
7214                 }
7215                 todo_wine {
7216                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7217                             prop.value, wine_dbgstr_w(received), i);
7218                 }
7219             } else {
7220                 ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7221                         hr, prop.expected, i);
7222                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7223                         prop.value, wine_dbgstr_w(received), i);
7224             }
7225             SysFreeString(received);
7226             received = NULL;
7227
7228             /* GetSchemeName() tests. */
7229             prop = test.str_props[Uri_PROPERTY_SCHEME_NAME];
7230             hr = IUri_GetSchemeName(uri, &received);
7231             if(prop.todo) {
7232                 todo_wine {
7233                     ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7234                             hr, prop.expected, i);
7235                 }
7236                 todo_wine {
7237                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7238                             prop.value, wine_dbgstr_w(received), i);
7239                 }
7240             } else {
7241                 ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7242                         hr, prop.expected, i);
7243                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7244                         prop.value, wine_dbgstr_w(received), i);
7245             }
7246             SysFreeString(received);
7247             received = NULL;
7248
7249             /* GetUserInfo() tests. */
7250             prop = test.str_props[Uri_PROPERTY_USER_INFO];
7251             hr = IUri_GetUserInfo(uri, &received);
7252             if(prop.todo) {
7253                 todo_wine {
7254                     ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7255                             hr, prop.expected, i);
7256                 }
7257                 todo_wine {
7258                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7259                             prop.value, wine_dbgstr_w(received), i);
7260                 }
7261             } else {
7262                 ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7263                         hr, prop.expected, i);
7264                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7265                         prop.value, wine_dbgstr_w(received), i);
7266             }
7267             SysFreeString(received);
7268             received = NULL;
7269
7270             /* GetUserName() tests. */
7271             prop = test.str_props[Uri_PROPERTY_USER_NAME];
7272             hr = IUri_GetUserName(uri, &received);
7273             if(prop.todo) {
7274                 todo_wine {
7275                     ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7276                             hr, prop.expected, i);
7277                 }
7278                 todo_wine {
7279                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7280                             prop.value, wine_dbgstr_w(received), i);
7281                 }
7282             } else {
7283                 ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7284                         hr, prop.expected, i);
7285                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7286                         prop.value, wine_dbgstr_w(received), i);
7287             }
7288             SysFreeString(received);
7289         }
7290
7291         if(uri) IUri_Release(uri);
7292
7293         heap_free(uriW);
7294     }
7295 }
7296
7297 static void test_IUri_GetDwordProperties(void) {
7298     IUri *uri = NULL;
7299     HRESULT hr;
7300     DWORD i;
7301
7302     /* Make sure all the 'Get*' dword property functions handle invalid args correctly. */
7303     hr = pCreateUri(http_urlW, 0, 0, &uri);
7304     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7305     if(SUCCEEDED(hr)) {
7306         hr = IUri_GetHostType(uri, NULL);
7307         ok(hr == E_INVALIDARG, "Error: GetHostType returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7308
7309         hr = IUri_GetPort(uri, NULL);
7310         ok(hr == E_INVALIDARG, "Error: GetPort returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7311
7312         hr = IUri_GetScheme(uri, NULL);
7313         ok(hr == E_INVALIDARG, "Error: GetScheme returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7314
7315         hr = IUri_GetZone(uri, NULL);
7316         ok(hr == E_INVALIDARG, "Error: GetZone returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7317     }
7318     if(uri) IUri_Release(uri);
7319
7320     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7321         uri_properties test = uri_tests[i];
7322         LPWSTR uriW;
7323         uri = NULL;
7324
7325         uriW = a2w(test.uri);
7326         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7327         if(test.create_todo) {
7328             todo_wine {
7329                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7330                         hr, test.create_expected, i);
7331             }
7332         } else {
7333             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7334                     hr, test.create_expected, i);
7335         }
7336
7337         if(SUCCEEDED(hr)) {
7338             uri_dword_property prop;
7339             DWORD received;
7340
7341             /* Assign an insane value so tests don't accidentally pass when
7342              * they shouldn't!
7343              */
7344             received = -9999999;
7345
7346             /* GetHostType() tests. */
7347             prop = test.dword_props[Uri_PROPERTY_HOST_TYPE-Uri_PROPERTY_DWORD_START];
7348             hr = IUri_GetHostType(uri, &received);
7349             if(prop.todo) {
7350                 todo_wine {
7351                     ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7352                             hr, prop.expected, i);
7353                 }
7354                 todo_wine {
7355                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7356                 }
7357             } else {
7358                 ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7359                         hr, prop.expected, i);
7360                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7361             }
7362             received = -9999999;
7363
7364             /* GetPort() tests. */
7365             prop = test.dword_props[Uri_PROPERTY_PORT-Uri_PROPERTY_DWORD_START];
7366             hr = IUri_GetPort(uri, &received);
7367             if(prop.todo) {
7368                 todo_wine {
7369                     ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7370                             hr, prop.expected, i);
7371                 }
7372                 todo_wine {
7373                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7374                 }
7375             } else {
7376                 ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7377                         hr, prop.expected, i);
7378                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7379             }
7380             received = -9999999;
7381
7382             /* GetScheme() tests. */
7383             prop = test.dword_props[Uri_PROPERTY_SCHEME-Uri_PROPERTY_DWORD_START];
7384             hr = IUri_GetScheme(uri, &received);
7385             if(prop.todo) {
7386                 todo_wine {
7387                     ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7388                             hr, prop.expected, i);
7389                 }
7390                 todo_wine {
7391                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7392                 }
7393             } else {
7394                 ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7395                         hr, prop.expected, i);
7396                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7397             }
7398             received = -9999999;
7399
7400             /* GetZone() tests. */
7401             prop = test.dword_props[Uri_PROPERTY_ZONE-Uri_PROPERTY_DWORD_START];
7402             hr = IUri_GetZone(uri, &received);
7403             if(prop.todo) {
7404                 todo_wine {
7405                     ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7406                             hr, prop.expected, i);
7407                 }
7408                 todo_wine {
7409                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7410                 }
7411             } else {
7412                 ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7413                         hr, prop.expected, i);
7414                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7415             }
7416         }
7417
7418         if(uri) IUri_Release(uri);
7419
7420         heap_free(uriW);
7421     }
7422 }
7423
7424 static void test_IUri_GetPropertyLength(void) {
7425     IUri *uri = NULL;
7426     HRESULT hr;
7427     DWORD i;
7428
7429     /* Make sure it handles invalid args correctly. */
7430     hr = pCreateUri(http_urlW, 0, 0, &uri);
7431     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7432     if(SUCCEEDED(hr)) {
7433         DWORD received = 0xdeadbeef;
7434
7435         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_STRING_START, NULL, 0);
7436         ok(hr == E_INVALIDARG, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7437
7438         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_DWORD_START, &received, 0);
7439         ok(hr == E_INVALIDARG, "Error: GetPropertyLength return 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7440         ok(received == 0xdeadbeef, "Error: Expected 0xdeadbeef but got 0x%08x.\n", received);
7441     }
7442     if(uri) IUri_Release(uri);
7443
7444     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7445         uri_properties test = uri_tests[i];
7446         LPWSTR uriW;
7447         uri = NULL;
7448
7449         uriW = a2w(test.uri);
7450         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7451         if(test.create_todo) {
7452             todo_wine {
7453                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7454                         hr, test.create_expected, i);
7455             }
7456         } else {
7457             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_test[%d].\n",
7458                     hr, test.create_expected, i);
7459         }
7460
7461         if(SUCCEEDED(hr)) {
7462             DWORD j;
7463
7464             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
7465                 DWORD expectedLen, brokenLen, receivedLen;
7466                 uri_str_property prop = test.str_props[j];
7467
7468                 expectedLen = lstrlen(prop.value);
7469                 brokenLen = lstrlen(prop.broken_value);
7470
7471                 /* This won't be necessary once GetPropertyLength is implemented. */
7472                 receivedLen = -1;
7473
7474                 hr = IUri_GetPropertyLength(uri, j, &receivedLen, 0);
7475                 if(prop.todo) {
7476                     todo_wine {
7477                         ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
7478                                 hr, prop.expected, i, j);
7479                     }
7480                     todo_wine {
7481                         ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
7482                                 "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
7483                                 expectedLen, receivedLen, i, j);
7484                     }
7485                 } else {
7486                     ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
7487                             hr, prop.expected, i, j);
7488                     ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
7489                             "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
7490                             expectedLen, receivedLen, i, j);
7491                 }
7492             }
7493         }
7494
7495         if(uri) IUri_Release(uri);
7496
7497         heap_free(uriW);
7498     }
7499 }
7500
7501 static DWORD compute_expected_props(uri_properties *test)
7502 {
7503     DWORD ret = 0, i;
7504
7505     for(i=Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_STRING_LAST; i++) {
7506         if(test->str_props[i-Uri_PROPERTY_STRING_START].expected == S_OK)
7507             ret |= 1<<i;
7508     }
7509
7510     for(i=Uri_PROPERTY_DWORD_START; i <= Uri_PROPERTY_DWORD_LAST; i++) {
7511         if(test->dword_props[i-Uri_PROPERTY_DWORD_START].expected == S_OK)
7512             ret |= 1<<i;
7513     }
7514
7515     return ret;
7516 }
7517
7518 static void test_IUri_GetProperties(void) {
7519     IUri *uri = NULL;
7520     HRESULT hr;
7521     DWORD i;
7522
7523     hr = pCreateUri(http_urlW, 0, 0, &uri);
7524     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7525     if(SUCCEEDED(hr)) {
7526         hr = IUri_GetProperties(uri, NULL);
7527         ok(hr == E_INVALIDARG, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7528     }
7529     if(uri) IUri_Release(uri);
7530
7531     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7532         uri_properties test = uri_tests[i];
7533         LPWSTR uriW;
7534         uri = NULL;
7535
7536         uriW = a2w(test.uri);
7537         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7538         if(test.create_todo) {
7539             todo_wine {
7540                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7541             }
7542         } else {
7543             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7544         }
7545
7546         if(SUCCEEDED(hr)) {
7547             DWORD received = 0, expected_props;
7548             DWORD j;
7549
7550             hr = IUri_GetProperties(uri, &received);
7551             ok(hr == S_OK, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7552
7553             expected_props = compute_expected_props(&test);
7554
7555             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
7556                 /* (1 << j) converts a Uri_PROPERTY to its corresponding Uri_HAS_* flag mask. */
7557                 if(expected_props & (1 << j))
7558                     ok(received & (1 << j), "Error: Expected flag for property %d on uri_tests[%d].\n", j, i);
7559                 else
7560                     ok(!(received & (1 << j)), "Error: Received flag for property %d when not expected on uri_tests[%d].\n", j, i);
7561             }
7562         }
7563
7564         if(uri) IUri_Release(uri);
7565
7566         heap_free(uriW);
7567     }
7568 }
7569
7570 static void test_IUri_HasProperty(void) {
7571     IUri *uri = NULL;
7572     HRESULT hr;
7573     DWORD i;
7574
7575     hr = pCreateUri(http_urlW, 0, 0, &uri);
7576     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7577     if(SUCCEEDED(hr)) {
7578         hr = IUri_HasProperty(uri, Uri_PROPERTY_RAW_URI, NULL);
7579         ok(hr == E_INVALIDARG, "Error: HasProperty returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7580     }
7581     if(uri) IUri_Release(uri);
7582
7583     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7584         uri_properties test = uri_tests[i];
7585         LPWSTR uriW;
7586         uri = NULL;
7587
7588         uriW = a2w(test.uri);
7589
7590         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7591         if(test.create_todo) {
7592             todo_wine {
7593                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7594             }
7595         } else {
7596             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7597         }
7598
7599         if(SUCCEEDED(hr)) {
7600             DWORD expected_props, j;
7601
7602             expected_props = compute_expected_props(&test);
7603
7604             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
7605                 /* Assign -1, then explicitly test for TRUE or FALSE later. */
7606                 BOOL received = -1;
7607
7608                 hr = IUri_HasProperty(uri, j, &received);
7609                 ok(hr == S_OK, "Error: HasProperty returned 0x%08x, expected 0x%08x for property %d on uri_tests[%d].\n",
7610                         hr, S_OK, j, i);
7611
7612                 if(expected_props & (1 << j)) {
7613                     ok(received == TRUE, "Error: Expected to have property %d on uri_tests[%d].\n", j, i);
7614                 } else {
7615                     ok(received == FALSE, "Error: Wasn't expecting to have property %d on uri_tests[%d].\n", j, i);
7616                 }
7617             }
7618         }
7619
7620         if(uri) IUri_Release(uri);
7621
7622         heap_free(uriW);
7623     }
7624 }
7625
7626 static void test_IUri_IsEqual(void) {
7627     IUri *uriA, *uriB;
7628     HRESULT hrA, hrB;
7629     DWORD i;
7630
7631     uriA = uriB = NULL;
7632
7633     /* Make sure IsEqual handles invalid args correctly. */
7634     hrA = pCreateUri(http_urlW, 0, 0, &uriA);
7635     hrB = pCreateUri(http_urlW, 0, 0, &uriB);
7636     ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hrA, S_OK);
7637     ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hrB, S_OK);
7638     if(SUCCEEDED(hrA) && SUCCEEDED(hrB)) {
7639         BOOL equal = -1;
7640         hrA = IUri_IsEqual(uriA, NULL, &equal);
7641         ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hrA, S_OK);
7642         ok(equal == FALSE, "Error: Expected equal to be FALSE, but was %d instead.\n", equal);
7643
7644         hrA = IUri_IsEqual(uriA, uriB, NULL);
7645         ok(hrA == E_POINTER, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hrA, E_POINTER);
7646     }
7647     if(uriA) IUri_Release(uriA);
7648     if(uriB) IUri_Release(uriB);
7649
7650     for(i = 0; i < sizeof(equality_tests)/sizeof(equality_tests[0]); ++i) {
7651         uri_equality test = equality_tests[i];
7652         LPWSTR uriA_W, uriB_W;
7653
7654         uriA = uriB = NULL;
7655
7656         uriA_W = a2w(test.a);
7657         uriB_W = a2w(test.b);
7658
7659         hrA = pCreateUri(uriA_W, test.create_flags_a, 0, &uriA);
7660         if(test.create_todo_a) {
7661             todo_wine {
7662                 ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n",
7663                         hrA, S_OK, i);
7664             }
7665         } else {
7666             ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n",
7667                     hrA, S_OK, i);
7668         }
7669
7670         hrB = pCreateUri(uriB_W, test.create_flags_b, 0, &uriB);
7671         if(test.create_todo_b) {
7672             todo_wine {
7673                 ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n",
7674                         hrB, S_OK, i);
7675             }
7676         } else {
7677             ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n",
7678                     hrB, S_OK, i);
7679         }
7680
7681         if(SUCCEEDED(hrA) && SUCCEEDED(hrB)) {
7682             BOOL equal = -1;
7683
7684             hrA = IUri_IsEqual(uriA, uriB, &equal);
7685             if(test.todo) {
7686                 todo_wine {
7687                     ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n",
7688                             hrA, S_OK, i);
7689                 }
7690                 todo_wine {
7691                     ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7692                 }
7693             } else {
7694                 ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n", hrA, S_OK, i);
7695                 ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7696             }
7697         }
7698         if(uriA) IUri_Release(uriA);
7699         if(uriB) IUri_Release(uriB);
7700
7701         heap_free(uriA_W);
7702         heap_free(uriB_W);
7703     }
7704 }
7705
7706 static void test_CreateUriWithFragment_InvalidArgs(void) {
7707     HRESULT hr;
7708     IUri *uri = (void*) 0xdeadbeef;
7709     const WCHAR fragmentW[] = {'#','f','r','a','g','m','e','n','t',0};
7710
7711     hr = pCreateUriWithFragment(NULL, fragmentW, 0, 0, &uri);
7712     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7713     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7714
7715     hr = pCreateUriWithFragment(http_urlW, fragmentW, 0, 0, NULL);
7716     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7717
7718     /* Original URI can't already contain a fragment component. */
7719     uri = (void*) 0xdeadbeef;
7720     hr = pCreateUriWithFragment(http_url_fragW, fragmentW, 0, 0, &uri);
7721     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7722     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7723 }
7724
7725 /* CreateUriWithFragment has the same invalid flag combinations as CreateUri. */
7726 static void test_CreateUriWithFragment_InvalidFlags(void) {
7727     DWORD i;
7728
7729     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
7730         HRESULT hr;
7731         IUri *uri = (void*) 0xdeadbeef;
7732
7733         hr = pCreateUriWithFragment(http_urlW, NULL, invalid_flag_tests[i].flags, 0, &uri);
7734         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x. flags=0x%08x.\n",
7735             hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
7736         ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7737     }
7738 }
7739
7740 static void test_CreateUriWithFragment(void) {
7741     DWORD i;
7742
7743     for(i = 0; i < sizeof(uri_fragment_tests)/sizeof(uri_fragment_tests[0]); ++i) {
7744         HRESULT hr;
7745         IUri *uri = NULL;
7746         LPWSTR uriW, fragW;
7747         uri_with_fragment test = uri_fragment_tests[i];
7748
7749         uriW = a2w(test.uri);
7750         fragW = a2w(test.fragment);
7751
7752         hr = pCreateUriWithFragment(uriW, fragW, test.create_flags, 0, &uri);
7753         if(test.expected_todo) {
7754             todo_wine {
7755                 ok(hr == test.create_expected,
7756                     "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7757                     hr, test.create_expected, i);
7758             }
7759         } else
7760             ok(hr == test.create_expected,
7761                 "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7762                 hr, test.create_expected, i);
7763
7764         if(SUCCEEDED(hr)) {
7765             BSTR received = NULL;
7766
7767             hr = IUri_GetAbsoluteUri(uri, &received);
7768             if(test.expected_todo) {
7769                 todo_wine {
7770                     ok(hr == S_OK,
7771                         "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7772                         hr, S_OK, i);
7773                 }
7774                 todo_wine {
7775                     ok(!strcmp_aw(test.expected_uri, received),
7776                         "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7777                         test.expected_uri, wine_dbgstr_w(received), i);
7778                 }
7779             } else {
7780                 ok(hr == S_OK, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7781                     hr, S_OK, i);
7782                 ok(!strcmp_aw(test.expected_uri, received), "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7783                     test.expected_uri, wine_dbgstr_w(received), i);
7784             }
7785
7786             SysFreeString(received);
7787         }
7788
7789         if(uri) IUri_Release(uri);
7790         heap_free(uriW);
7791         heap_free(fragW);
7792     }
7793 }
7794
7795 static void test_CreateIUriBuilder(void) {
7796     HRESULT hr;
7797     IUriBuilder *builder = NULL;
7798     IUri *uri;
7799
7800     hr = pCreateIUriBuilder(NULL, 0, 0, NULL);
7801     ok(hr == E_POINTER, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x\n",
7802         hr, E_POINTER);
7803
7804     /* CreateIUriBuilder increases the ref count of the IUri it receives. */
7805     hr = pCreateUri(http_urlW, 0, 0, &uri);
7806     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7807     if(SUCCEEDED(hr)) {
7808         ULONG cur_count, orig_count;
7809
7810         orig_count = get_refcnt(uri);
7811         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
7812         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7813         ok(builder != NULL, "Error: Expecting builder not to be NULL\n");
7814
7815         cur_count = get_refcnt(uri);
7816         ok(cur_count == orig_count+1, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count+1, cur_count);
7817
7818         if(builder) IUriBuilder_Release(builder);
7819         cur_count = get_refcnt(uri);
7820         ok(cur_count == orig_count, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count, cur_count);
7821     }
7822     if(uri) IUri_Release(uri);
7823 }
7824
7825 static void test_IUriBuilder_CreateUri(IUriBuilder *builder, const uri_builder_test *test,
7826                                        DWORD test_index) {
7827     HRESULT hr;
7828     IUri *uri = NULL;
7829
7830     hr = IUriBuilder_CreateUri(builder, test->uri_flags, 0, 0, &uri);
7831     if(test->uri_todo) {
7832         todo_wine {
7833             ok(hr == test->uri_hres,
7834                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7835                 hr, test->uri_hres, test_index);
7836         }
7837     } else {
7838         ok(hr == test->uri_hres,
7839             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7840             hr, test->uri_hres, test_index);
7841     }
7842
7843     if(SUCCEEDED(hr)) {
7844         DWORD i;
7845
7846         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7847             uri_builder_str_property prop = test->expected_str_props[i];
7848             BSTR received = NULL;
7849
7850             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7851             if(prop.todo) {
7852                 todo_wine {
7853                     ok(hr == prop.result,
7854                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7855                         hr, prop.result, test_index, i);
7856                 }
7857             } else {
7858                 ok(hr == prop.result,
7859                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7860                     hr, prop.result, test_index, i);
7861             }
7862             if(SUCCEEDED(hr)) {
7863                 if(prop.todo) {
7864                     todo_wine {
7865                         ok(!strcmp_aw(prop.expected, received),
7866                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7867                             prop.expected, wine_dbgstr_w(received), test_index, i);
7868                     }
7869                 } else {
7870                     ok(!strcmp_aw(prop.expected, received),
7871                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7872                         prop.expected, wine_dbgstr_w(received), test_index, i);
7873                 }
7874             }
7875             SysFreeString(received);
7876         }
7877
7878         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7879             uri_builder_dword_property prop = test->expected_dword_props[i];
7880             DWORD received = -2;
7881
7882             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7883             if(prop.todo) {
7884                 todo_wine {
7885                     ok(hr == prop.result,
7886                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7887                         hr, prop.result, test_index, i);
7888                 }
7889             } else {
7890                 ok(hr == prop.result,
7891                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7892                     hr, prop.result, test_index, i);
7893             }
7894             if(SUCCEEDED(hr)) {
7895                 if(prop.todo) {
7896                     todo_wine {
7897                         ok(received == prop.expected,
7898                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7899                             prop.expected, received, test_index, i);
7900                     }
7901                 } else {
7902                     ok(received == prop.expected,
7903                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7904                         prop.expected, received, test_index, i);
7905                 }
7906             }
7907         }
7908     }
7909     if(uri) IUri_Release(uri);
7910 }
7911
7912 static void test_IUriBuilder_CreateUriSimple(IUriBuilder *builder, const uri_builder_test *test,
7913                                        DWORD test_index) {
7914     HRESULT hr;
7915     IUri *uri = NULL;
7916
7917     hr = IUriBuilder_CreateUriSimple(builder, test->uri_simple_encode_flags, 0, &uri);
7918     if(test->uri_simple_todo) {
7919         todo_wine {
7920             ok(hr == test->uri_simple_hres,
7921                 "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7922                 hr, test->uri_simple_hres, test_index);
7923         }
7924     } else {
7925         ok(hr == test->uri_simple_hres,
7926             "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7927             hr, test->uri_simple_hres, test_index);
7928     }
7929
7930     if(SUCCEEDED(hr)) {
7931         DWORD i;
7932
7933         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7934             uri_builder_str_property prop = test->expected_str_props[i];
7935             BSTR received = NULL;
7936
7937             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7938             if(prop.todo) {
7939                 todo_wine {
7940                     ok(hr == prop.result,
7941                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7942                         hr, prop.result, test_index, i);
7943                 }
7944             } else {
7945                 ok(hr == prop.result,
7946                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7947                     hr, prop.result, test_index, i);
7948             }
7949             if(SUCCEEDED(hr)) {
7950                 if(prop.todo) {
7951                     todo_wine {
7952                         ok(!strcmp_aw(prop.expected, received),
7953                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7954                             prop.expected, wine_dbgstr_w(received), test_index, i);
7955                     }
7956                 } else {
7957                     ok(!strcmp_aw(prop.expected, received),
7958                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7959                         prop.expected, wine_dbgstr_w(received), test_index, i);
7960                 }
7961             }
7962             SysFreeString(received);
7963         }
7964
7965         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7966             uri_builder_dword_property prop = test->expected_dword_props[i];
7967             DWORD received = -2;
7968
7969             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7970             if(prop.todo) {
7971                 todo_wine {
7972                     ok(hr == prop.result,
7973                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7974                         hr, prop.result, test_index, i);
7975                 }
7976             } else {
7977                 ok(hr == prop.result,
7978                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7979                     hr, prop.result, test_index, i);
7980             }
7981             if(SUCCEEDED(hr)) {
7982                 if(prop.todo) {
7983                     todo_wine {
7984                         ok(received == prop.expected,
7985                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7986                             prop.expected, received, test_index, i);
7987                     }
7988                 } else {
7989                     ok(received == prop.expected,
7990                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7991                         prop.expected, received, test_index, i);
7992                 }
7993             }
7994         }
7995     }
7996     if(uri) IUri_Release(uri);
7997 }
7998
7999 static void test_IUriBuilder_CreateUriWithFlags(IUriBuilder *builder, const uri_builder_test *test,
8000                                                 DWORD test_index) {
8001     HRESULT hr;
8002     IUri *uri = NULL;
8003
8004     hr = IUriBuilder_CreateUriWithFlags(builder, test->uri_with_flags, test->uri_with_builder_flags,
8005                                         test->uri_with_encode_flags, 0, &uri);
8006     if(test->uri_with_todo) {
8007         todo_wine {
8008             ok(hr == test->uri_with_hres,
8009                 "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8010                 hr, test->uri_with_hres, test_index);
8011         }
8012     } else {
8013         ok(hr == test->uri_with_hres,
8014             "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8015             hr, test->uri_with_hres, test_index);
8016     }
8017
8018     if(SUCCEEDED(hr)) {
8019         DWORD i;
8020
8021         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
8022             uri_builder_str_property prop = test->expected_str_props[i];
8023             BSTR received = NULL;
8024
8025             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
8026             if(prop.todo) {
8027                 todo_wine {
8028                     ok(hr == prop.result,
8029                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
8030                         hr, prop.result, test_index, i);
8031                 }
8032             } else {
8033                 ok(hr == prop.result,
8034                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
8035                     hr, prop.result, test_index, i);
8036             }
8037             if(SUCCEEDED(hr)) {
8038                 if(prop.todo) {
8039                     todo_wine {
8040                         ok(!strcmp_aw(prop.expected, received),
8041                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
8042                             prop.expected, wine_dbgstr_w(received), test_index, i);
8043                     }
8044                 } else {
8045                     ok(!strcmp_aw(prop.expected, received),
8046                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
8047                         prop.expected, wine_dbgstr_w(received), test_index, i);
8048                 }
8049             }
8050             SysFreeString(received);
8051         }
8052
8053         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
8054             uri_builder_dword_property prop = test->expected_dword_props[i];
8055             DWORD received = -2;
8056
8057             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
8058             if(prop.todo) {
8059                 todo_wine {
8060                     ok(hr == prop.result,
8061                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
8062                         hr, prop.result, test_index, i);
8063                 }
8064             } else {
8065                 ok(hr == prop.result,
8066                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
8067                     hr, prop.result, test_index, i);
8068             }
8069             if(SUCCEEDED(hr)) {
8070                 if(prop.todo) {
8071                     todo_wine {
8072                         ok(received == prop.expected,
8073                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
8074                             prop.expected, received, test_index, i);
8075                     }
8076                 } else {
8077                     ok(received == prop.expected,
8078                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
8079                         prop.expected, received, test_index, i);
8080                 }
8081             }
8082         }
8083     }
8084     if(uri) IUri_Release(uri);
8085 }
8086
8087 static void test_IUriBuilder_CreateInvalidArgs(void) {
8088     IUriBuilder *builder;
8089     HRESULT hr;
8090
8091     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8092     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8093     if(SUCCEEDED(hr)) {
8094         IUri *test = NULL, *uri = (void*) 0xdeadbeef;
8095
8096         /* Test what happens if the IUriBuilder doesn't have a IUri set. */
8097         hr = IUriBuilder_CreateUri(builder, 0, 0, 0, NULL);
8098         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
8099
8100         uri = (void*) 0xdeadbeef;
8101         hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
8102         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_NOTIMPL);
8103         ok(uri == NULL, "Error: expected uri to be NULL, but was %p instead.\n", uri);
8104
8105         hr = IUriBuilder_CreateUriSimple(builder, 0, 0, NULL);
8106         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8107             hr, E_POINTER);
8108
8109         uri = (void*) 0xdeadbeef;
8110         hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
8111         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8112             hr, E_NOTIMPL);
8113         ok(!uri, "Error: Expected uri to NULL, but was %p instead.\n", uri);
8114
8115         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, NULL);
8116         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8117             hr, E_POINTER);
8118
8119         uri = (void*) 0xdeadbeef;
8120         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
8121         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8122             hr, E_NOTIMPL);
8123         ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
8124
8125         hr = pCreateUri(http_urlW, 0, 0, &test);
8126         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8127         if(SUCCEEDED(hr)) {
8128             hr = IUriBuilder_SetIUri(builder, test);
8129             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8130
8131             /* No longer returns E_NOTIMPL, since a IUri has been set and hasn't been modified. */
8132             uri = NULL;
8133             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
8134             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8135             ok(uri != NULL, "Error: The uri was NULL.\n");
8136             if(uri) IUri_Release(uri);
8137
8138             uri = NULL;
8139             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
8140             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8141                 hr, S_OK);
8142             ok(uri != NULL, "Error: uri was NULL.\n");
8143             if(uri) IUri_Release(uri);
8144
8145             uri = NULL;
8146             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &uri);
8147             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8148                 hr, S_OK);
8149             ok(uri != NULL, "Error: uri was NULL.\n");
8150             if(uri) IUri_Release(uri);
8151
8152             hr = IUriBuilder_SetFragment(builder, NULL);
8153             ok(hr == S_OK, "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8154
8155             /* The IUriBuilder is changed, so it returns E_NOTIMPL again. */
8156             uri = (void*) 0xdeadbeef;
8157             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
8158             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8159             ok(!uri, "Error: Expected uri to be NULL but was %p instead.\n", uri);
8160
8161             uri = (void*) 0xdeadbeef;
8162             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
8163             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8164                 hr, S_OK);
8165             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
8166
8167             uri = (void*) 0xdeadbeef;
8168             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
8169             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8170                 hr, E_NOTIMPL);
8171             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
8172         }
8173         if(test) IUri_Release(test);
8174     }
8175     if(builder) IUriBuilder_Release(builder);
8176 }
8177
8178 /* Tests invalid args to the "Get*" functions. */
8179 static void test_IUriBuilder_GetInvalidArgs(void) {
8180     IUriBuilder *builder = NULL;
8181     HRESULT hr;
8182
8183     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8184     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8185     if(SUCCEEDED(hr)) {
8186         LPCWSTR received = (void*) 0xdeadbeef;
8187         DWORD len = -1, port = -1;
8188         BOOL set = -1;
8189
8190         hr = IUriBuilder_GetFragment(builder, NULL, NULL);
8191         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
8192             hr, E_POINTER);
8193         hr = IUriBuilder_GetFragment(builder, NULL, &received);
8194         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
8195             hr, E_POINTER);
8196         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8197         hr = IUriBuilder_GetFragment(builder, &len, NULL);
8198         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
8199             hr, E_POINTER);
8200         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8201
8202         hr = IUriBuilder_GetHost(builder, NULL, NULL);
8203         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
8204             hr, E_POINTER);
8205         received = (void*) 0xdeadbeef;
8206         hr = IUriBuilder_GetHost(builder, NULL, &received);
8207         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
8208             hr, E_POINTER);
8209         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8210         len = -1;
8211         hr = IUriBuilder_GetHost(builder, &len, NULL);
8212         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
8213             hr, E_POINTER);
8214         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8215
8216         hr = IUriBuilder_GetPassword(builder, NULL, NULL);
8217         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
8218             hr, E_POINTER);
8219         received = (void*) 0xdeadbeef;
8220         hr = IUriBuilder_GetPassword(builder, NULL, &received);
8221         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
8222             hr, E_POINTER);
8223         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8224         len = -1;
8225         hr = IUriBuilder_GetPassword(builder, &len, NULL);
8226         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
8227             hr, E_POINTER);
8228         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8229
8230         hr = IUriBuilder_GetPath(builder, NULL, NULL);
8231         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8232             hr, E_POINTER);
8233         received = (void*) 0xdeadbeef;
8234         hr = IUriBuilder_GetPath(builder, NULL, &received);
8235         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8236             hr, E_POINTER);
8237         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8238         len = -1;
8239         hr = IUriBuilder_GetPath(builder, &len, NULL);
8240         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8241             hr, E_POINTER);
8242         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8243
8244         hr = IUriBuilder_GetPort(builder, NULL, NULL);
8245         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8246             hr, E_POINTER);
8247         hr = IUriBuilder_GetPort(builder, NULL, &port);
8248         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8249             hr, E_POINTER);
8250         ok(!port, "Error: Expected port to be 0, but was %d instead.\n", port);
8251         hr = IUriBuilder_GetPort(builder, &set, NULL);
8252         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8253             hr, E_POINTER);
8254         ok(!set, "Error: Expected set to be FALSE, but was %d instead.\n", set);
8255
8256         hr = IUriBuilder_GetQuery(builder, NULL, NULL);
8257         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8258             hr, E_POINTER);
8259         received = (void*) 0xdeadbeef;
8260         hr = IUriBuilder_GetQuery(builder, NULL, &received);
8261         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8262             hr, E_POINTER);
8263         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8264         len = -1;
8265         hr = IUriBuilder_GetQuery(builder, &len, NULL);
8266         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8267             hr, E_POINTER);
8268         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8269
8270         hr = IUriBuilder_GetSchemeName(builder, NULL, NULL);
8271         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8272             hr, E_POINTER);
8273         received = (void*) 0xdeadbeef;
8274         hr = IUriBuilder_GetSchemeName(builder, NULL, &received);
8275         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8276             hr, E_POINTER);
8277         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8278         len = -1;
8279         hr = IUriBuilder_GetSchemeName(builder, &len, NULL);
8280         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8281             hr, E_POINTER);
8282         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8283
8284         hr = IUriBuilder_GetUserName(builder, NULL, NULL);
8285         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8286             hr, E_POINTER);
8287         received = (void*) 0xdeadbeef;
8288         hr = IUriBuilder_GetUserName(builder, NULL, &received);
8289         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8290             hr, E_POINTER);
8291         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8292         len = -1;
8293         hr = IUriBuilder_GetUserName(builder, &len, NULL);
8294         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8295             hr, E_POINTER);
8296         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8297     }
8298     if(builder) IUriBuilder_Release(builder);
8299 }
8300
8301 static void test_IUriBuilder_GetFragment(IUriBuilder *builder, const uri_builder_test *test,
8302                                          DWORD test_index) {
8303     HRESULT hr;
8304     DWORD i;
8305     LPCWSTR received = NULL;
8306     DWORD len = -1;
8307     const uri_builder_property *prop = NULL;
8308
8309     /* Check if the property was set earlier. */
8310     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8311         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_FRAGMENT)
8312             prop = &(test->properties[i]);
8313     }
8314
8315     if(prop) {
8316         /* Use expected_value unless it's NULL, then use value. */
8317         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8318         hr = IUriBuilder_GetFragment(builder, &len, &received);
8319         if(prop->todo) {
8320             todo_wine {
8321                 ok(hr == (expected ? S_OK : S_FALSE),
8322                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8323                     hr, (expected ? S_OK : S_FALSE), test_index);
8324             }
8325             if(SUCCEEDED(hr)) {
8326                 todo_wine {
8327                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8328                         expected, wine_dbgstr_w(received), test_index);
8329                 }
8330                 todo_wine {
8331                     ok(lstrlen(expected) == len,
8332                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8333                         lstrlen(expected), len, test_index);
8334                 }
8335             }
8336         } else {
8337             ok(hr == (expected ? S_OK : S_FALSE),
8338                 "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8339                 hr, (expected ? S_OK : S_FALSE), test_index);
8340             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8341                 expected, wine_dbgstr_w(received), test_index);
8342             ok(lstrlen(expected) == len,
8343                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8344                 lstrlen(expected), len, test_index);
8345         }
8346     } else {
8347         /* The property wasn't set earlier, so it should return whatever
8348          * the base IUri contains (if anything).
8349          */
8350         IUri *uri = NULL;
8351         hr = IUriBuilder_GetIUri(builder, &uri);
8352         ok(hr == S_OK,
8353             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8354             hr, S_OK, test_index);
8355         if(SUCCEEDED(hr)) {
8356             if(!uri) {
8357                 received = (void*) 0xdeadbeef;
8358                 len = -1;
8359
8360                 hr = IUriBuilder_GetFragment(builder, &len, &received);
8361                 ok(hr == S_FALSE,
8362                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8363                     hr, S_FALSE, test_index);
8364                 if(SUCCEEDED(hr)) {
8365                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8366                         len, test_index);
8367                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8368                         received, test_index);
8369                 }
8370             } else {
8371                 BOOL has_prop = FALSE;
8372                 BSTR expected = NULL;
8373
8374                 hr = IUri_GetFragment(uri, &expected);
8375                 ok(SUCCEEDED(hr),
8376                     "Error: Expected IUri_GetFragment to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8377                     hr, test_index);
8378                 has_prop = hr == S_OK;
8379
8380                 hr = IUriBuilder_GetFragment(builder, &len, &received);
8381                 if(has_prop) {
8382                     ok(hr == S_OK,
8383                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8384                         hr, S_OK, test_index);
8385                     if(SUCCEEDED(hr)) {
8386                         ok(!lstrcmpW(expected, received),
8387                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8388                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8389                         ok(lstrlenW(expected) == len,
8390                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8391                             lstrlenW(expected), len, test_index);
8392                     }
8393                 } else {
8394                     ok(hr == S_FALSE,
8395                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8396                         hr, S_FALSE, test_index);
8397                     if(SUCCEEDED(hr)) {
8398                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8399                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8400                             len, test_index);
8401                     }
8402                 }
8403                 SysFreeString(expected);
8404             }
8405         }
8406         if(uri) IUri_Release(uri);
8407     }
8408 }
8409
8410 static void test_IUriBuilder_GetHost(IUriBuilder *builder, const uri_builder_test *test,
8411                                      DWORD test_index) {
8412     HRESULT hr;
8413     DWORD i;
8414     LPCWSTR received = NULL;
8415     DWORD len = -1;
8416     const uri_builder_property *prop = NULL;
8417
8418     /* Check if the property was set earlier. */
8419     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8420         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_HOST)
8421             prop = &(test->properties[i]);
8422     }
8423
8424     if(prop) {
8425         /* Use expected_value unless it's NULL, then use value. */
8426         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8427         hr = IUriBuilder_GetHost(builder, &len, &received);
8428         if(prop->todo) {
8429             todo_wine {
8430                 ok(hr == (expected ? S_OK : S_FALSE),
8431                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8432                     hr, (expected ? S_OK : S_FALSE), test_index);
8433             }
8434             if(SUCCEEDED(hr)) {
8435                 todo_wine {
8436                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8437                         expected, wine_dbgstr_w(received), test_index);
8438                 }
8439                 todo_wine {
8440                     ok(lstrlen(expected) == len,
8441                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8442                         lstrlen(expected), len, test_index);
8443                 }
8444             }
8445         } else {
8446             ok(hr == (expected ? S_OK : S_FALSE),
8447                 "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8448                 hr, (expected ? S_OK : S_FALSE), test_index);
8449             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8450                 expected, wine_dbgstr_w(received), test_index);
8451             ok(lstrlen(expected) == len,
8452                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8453                 lstrlen(expected), len, test_index);
8454         }
8455     } else {
8456         /* The property wasn't set earlier, so it should return whatever
8457          * the base IUri contains (if anything).
8458          */
8459         IUri *uri = NULL;
8460         hr = IUriBuilder_GetIUri(builder, &uri);
8461         ok(hr == S_OK,
8462             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8463             hr, S_OK, test_index);
8464         if(SUCCEEDED(hr)) {
8465             if(!uri) {
8466                 received = (void*) 0xdeadbeef;
8467                 len = -1;
8468
8469                 hr = IUriBuilder_GetHost(builder, &len, &received);
8470                 ok(hr == S_FALSE,
8471                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8472                     hr, S_FALSE, test_index);
8473                 if(SUCCEEDED(hr)) {
8474                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8475                         len, test_index);
8476                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8477                         received, test_index);
8478                 }
8479             } else {
8480                 BOOL has_prop = FALSE;
8481                 BSTR expected = NULL;
8482
8483                 hr = IUri_GetHost(uri, &expected);
8484                 ok(SUCCEEDED(hr),
8485                     "Error: Expected IUri_GetHost to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8486                     hr, test_index);
8487                 has_prop = hr == S_OK;
8488
8489                 hr = IUriBuilder_GetHost(builder, &len, &received);
8490                 if(has_prop) {
8491                     ok(hr == S_OK,
8492                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8493                         hr, S_OK, test_index);
8494                     if(SUCCEEDED(hr)) {
8495                         ok(!lstrcmpW(expected, received),
8496                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8497                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8498                         ok(lstrlenW(expected) == len,
8499                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8500                             lstrlenW(expected), len, test_index);
8501                     }
8502                 } else {
8503                     ok(hr == S_FALSE,
8504                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8505                         hr, S_FALSE, test_index);
8506                     if(SUCCEEDED(hr)) {
8507                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8508                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8509                             len, test_index);
8510                     }
8511                 }
8512                 SysFreeString(expected);
8513             }
8514         }
8515         if(uri) IUri_Release(uri);
8516     }
8517 }
8518
8519 static void test_IUriBuilder_GetPassword(IUriBuilder *builder, const uri_builder_test *test,
8520                                          DWORD test_index) {
8521     HRESULT hr;
8522     DWORD i;
8523     LPCWSTR received = NULL;
8524     DWORD len = -1;
8525     const uri_builder_property *prop = NULL;
8526
8527     /* Check if the property was set earlier. */
8528     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8529         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PASSWORD)
8530             prop = &(test->properties[i]);
8531     }
8532
8533     if(prop) {
8534         /* Use expected_value unless it's NULL, then use value. */
8535         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8536         hr = IUriBuilder_GetPassword(builder, &len, &received);
8537         if(prop->todo) {
8538             todo_wine {
8539                 ok(hr == (expected ? S_OK : S_FALSE),
8540                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8541                     hr, (expected ? S_OK : S_FALSE), test_index);
8542             }
8543             if(SUCCEEDED(hr)) {
8544                 todo_wine {
8545                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8546                         expected, wine_dbgstr_w(received), test_index);
8547                 }
8548                 todo_wine {
8549                     ok(lstrlen(expected) == len,
8550                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8551                         lstrlen(expected), len, test_index);
8552                 }
8553             }
8554         } else {
8555             ok(hr == (expected ? S_OK : S_FALSE),
8556                 "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8557                 hr, (expected ? S_OK : S_FALSE), test_index);
8558             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8559                 expected, wine_dbgstr_w(received), test_index);
8560             ok(lstrlen(expected) == len,
8561                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8562                 lstrlen(expected), len, test_index);
8563         }
8564     } else {
8565         /* The property wasn't set earlier, so it should return whatever
8566          * the base IUri contains (if anything).
8567          */
8568         IUri *uri = NULL;
8569         hr = IUriBuilder_GetIUri(builder, &uri);
8570         ok(hr == S_OK,
8571             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8572             hr, S_OK, test_index);
8573         if(SUCCEEDED(hr)) {
8574             if(!uri) {
8575                 received = (void*) 0xdeadbeef;
8576                 len = -1;
8577
8578                 hr = IUriBuilder_GetPassword(builder, &len, &received);
8579                 ok(hr == S_FALSE,
8580                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8581                     hr, S_FALSE, test_index);
8582                 if(SUCCEEDED(hr)) {
8583                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8584                         len, test_index);
8585                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8586                         received, test_index);
8587                 }
8588             } else {
8589                 BOOL has_prop = FALSE;
8590                 BSTR expected = NULL;
8591
8592                 hr = IUri_GetPassword(uri, &expected);
8593                 ok(SUCCEEDED(hr),
8594                     "Error: Expected IUri_GetPassword to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8595                     hr, test_index);
8596                 has_prop = hr == S_OK;
8597
8598                 hr = IUriBuilder_GetPassword(builder, &len, &received);
8599                 if(has_prop) {
8600                     ok(hr == S_OK,
8601                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8602                         hr, S_OK, test_index);
8603                     if(SUCCEEDED(hr)) {
8604                         ok(!lstrcmpW(expected, received),
8605                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8606                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8607                         ok(lstrlenW(expected) == len,
8608                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8609                             lstrlenW(expected), len, test_index);
8610                     }
8611                 } else {
8612                     ok(hr == S_FALSE,
8613                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8614                         hr, S_FALSE, test_index);
8615                     if(SUCCEEDED(hr)) {
8616                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8617                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8618                             len, test_index);
8619                     }
8620                 }
8621                 SysFreeString(expected);
8622             }
8623         }
8624         if(uri) IUri_Release(uri);
8625     }
8626 }
8627
8628 static void test_IUriBuilder_GetPath(IUriBuilder *builder, const uri_builder_test *test,
8629                                      DWORD test_index) {
8630     HRESULT hr;
8631     DWORD i;
8632     LPCWSTR received = NULL;
8633     DWORD len = -1;
8634     const uri_builder_property *prop = NULL;
8635
8636     /* Check if the property was set earlier. */
8637     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8638         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PATH)
8639             prop = &(test->properties[i]);
8640     }
8641
8642     if(prop) {
8643         /* Use expected_value unless it's NULL, then use value. */
8644         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8645         hr = IUriBuilder_GetPath(builder, &len, &received);
8646         if(prop->todo) {
8647             todo_wine {
8648                 ok(hr == (expected ? S_OK : S_FALSE),
8649                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8650                     hr, (expected ? S_OK : S_FALSE), test_index);
8651             }
8652             if(SUCCEEDED(hr)) {
8653                 todo_wine {
8654                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8655                         expected, wine_dbgstr_w(received), test_index);
8656                 }
8657                 todo_wine {
8658                     ok(lstrlen(expected) == len,
8659                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8660                         lstrlen(expected), len, test_index);
8661                 }
8662             }
8663         } else {
8664             ok(hr == (expected ? S_OK : S_FALSE),
8665                 "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8666                 hr, (expected ? S_OK : S_FALSE), test_index);
8667             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8668                 expected, wine_dbgstr_w(received), test_index);
8669             ok(lstrlen(expected) == len,
8670                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8671                 lstrlen(expected), len, test_index);
8672         }
8673     } else {
8674         /* The property wasn't set earlier, so it should return whatever
8675          * the base IUri contains (if anything).
8676          */
8677         IUri *uri = NULL;
8678         hr = IUriBuilder_GetIUri(builder, &uri);
8679         ok(hr == S_OK,
8680             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8681             hr, S_OK, test_index);
8682         if(SUCCEEDED(hr)) {
8683             if(!uri) {
8684                 received = (void*) 0xdeadbeef;
8685                 len = -1;
8686
8687                 hr = IUriBuilder_GetPath(builder, &len, &received);
8688                 ok(hr == S_FALSE,
8689                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8690                     hr, S_FALSE, test_index);
8691                 if(SUCCEEDED(hr)) {
8692                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8693                         len, test_index);
8694                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8695                         received, test_index);
8696                 }
8697             } else {
8698                 BOOL has_prop = FALSE;
8699                 BSTR expected = NULL;
8700
8701                 hr = IUri_GetPath(uri, &expected);
8702                 ok(SUCCEEDED(hr),
8703                     "Error: Expected IUri_GetPath to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8704                     hr, test_index);
8705                 has_prop = hr == S_OK;
8706
8707                 hr = IUriBuilder_GetPath(builder, &len, &received);
8708                 if(has_prop) {
8709                     ok(hr == S_OK,
8710                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8711                         hr, S_OK, test_index);
8712                     if(SUCCEEDED(hr)) {
8713                         ok(!lstrcmpW(expected, received),
8714                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8715                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8716                         ok(lstrlenW(expected) == len,
8717                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8718                             lstrlenW(expected), len, test_index);
8719                     }
8720                 } else {
8721                     ok(hr == S_FALSE,
8722                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8723                         hr, S_FALSE, test_index);
8724                     if(SUCCEEDED(hr)) {
8725                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8726                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8727                             len, test_index);
8728                     }
8729                 }
8730                 SysFreeString(expected);
8731             }
8732         }
8733         if(uri) IUri_Release(uri);
8734     }
8735 }
8736
8737 static void test_IUriBuilder_GetPort(IUriBuilder *builder, const uri_builder_test *test,
8738                                      DWORD test_index) {
8739     HRESULT hr;
8740     BOOL has_port = FALSE;
8741     DWORD received = -1;
8742
8743     if(test->port_prop.change) {
8744         DWORD expected = test->port_prop.value;
8745
8746         hr = IUriBuilder_GetPort(builder, &has_port, &received);
8747         if(test->port_prop.todo) {
8748             todo_wine {
8749                 ok(hr == S_OK,
8750                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8751                     hr, S_OK, test_index);
8752             }
8753             if(SUCCEEDED(hr)) {
8754                 todo_wine {
8755                     ok(has_port == test->port_prop.set,
8756                         "Error: Expected has_port to be %d but was %d instead on uri_builder_tests[%d].\n",
8757                         test->port_prop.set, has_port, test_index);
8758                 }
8759                 todo_wine {
8760                     ok(received == expected,
8761                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8762                         expected, received, test_index);
8763                 }
8764             }
8765         } else {
8766             ok(hr == S_OK,
8767                 "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8768                 hr, S_OK, test_index);
8769             ok(has_port == test->port_prop.set,
8770                 "Error: Expected has_port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8771                 test->port_prop.set, has_port, test_index);
8772             ok(received == test->port_prop.value,
8773                 "Error: Expected port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8774                 test->port_prop.value, received, test_index);
8775         }
8776     } else {
8777         IUri *uri = NULL;
8778
8779         hr = IUriBuilder_GetIUri(builder, &uri);
8780         ok(hr == S_OK,
8781             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8782             hr, S_OK, test_index);
8783         if(SUCCEEDED(hr)) {
8784             if(!uri) {
8785                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8786                 ok(hr == S_OK,
8787                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8788                     hr, S_OK, test_index);
8789                 if(SUCCEEDED(hr)) {
8790                     ok(has_port == FALSE,
8791                         "Error: Expected has_port to be FALSE, but was %d instead on uri_builder_tests[%d].\n",
8792                         has_port, test_index);
8793                     ok(!received, "Error: Expected received to be 0, but was %d instead on uri_builder_tests[%d].\n",
8794                         received, test_index);
8795                 }
8796             } else {
8797                 DWORD expected;
8798
8799                 hr = IUri_GetPort(uri, &expected);
8800                 ok(SUCCEEDED(hr),
8801                     "Error: Expected IUri_Port to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8802                     hr, test_index);
8803
8804                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
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                 if(SUCCEEDED(hr)) {
8809                     ok(!has_port,
8810                         "Error: Expected has_port to be FALSE but was TRUE instead on uri_builder_tests[%d].\n",
8811                         test_index);
8812                     ok(received == expected,
8813                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8814                         expected, received, test_index);
8815                 }
8816             }
8817         }
8818         if(uri) IUri_Release(uri);
8819     }
8820 }
8821
8822 static void test_IUriBuilder_GetQuery(IUriBuilder *builder, const uri_builder_test *test,
8823                                       DWORD test_index) {
8824     HRESULT hr;
8825     DWORD i;
8826     LPCWSTR received = NULL;
8827     DWORD len = -1;
8828     const uri_builder_property *prop = NULL;
8829
8830     /* Check if the property was set earlier. */
8831     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8832         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_QUERY)
8833             prop = &(test->properties[i]);
8834     }
8835
8836     if(prop) {
8837         /* Use expected_value unless it's NULL, then use value. */
8838         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8839         hr = IUriBuilder_GetQuery(builder, &len, &received);
8840         if(prop->todo) {
8841             todo_wine {
8842                 ok(hr == (expected ? S_OK : S_FALSE),
8843                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8844                     hr, (expected ? S_OK : S_FALSE), test_index);
8845             }
8846             if(SUCCEEDED(hr)) {
8847                 todo_wine {
8848                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8849                         expected, wine_dbgstr_w(received), test_index);
8850                 }
8851                 todo_wine {
8852                     ok(lstrlen(expected) == len,
8853                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8854                         lstrlen(expected), len, test_index);
8855                 }
8856             }
8857         } else {
8858             ok(hr == (expected ? S_OK : S_FALSE),
8859                 "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8860                 hr, (expected ? S_OK : S_FALSE), test_index);
8861             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8862                 expected, wine_dbgstr_w(received), test_index);
8863             ok(lstrlen(expected) == len,
8864                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8865                 lstrlen(expected), len, test_index);
8866         }
8867     } else {
8868         /* The property wasn't set earlier, so it should return whatever
8869          * the base IUri contains (if anything).
8870          */
8871         IUri *uri = NULL;
8872         hr = IUriBuilder_GetIUri(builder, &uri);
8873         ok(hr == S_OK,
8874             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8875             hr, S_OK, test_index);
8876         if(SUCCEEDED(hr)) {
8877             if(!uri) {
8878                 received = (void*) 0xdeadbeef;
8879                 len = -1;
8880
8881                 hr = IUriBuilder_GetQuery(builder, &len, &received);
8882                 ok(hr == S_FALSE,
8883                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8884                     hr, S_FALSE, test_index);
8885                 if(SUCCEEDED(hr)) {
8886                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8887                         len, test_index);
8888                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8889                         received, test_index);
8890                 }
8891             } else {
8892                 BOOL has_prop = FALSE;
8893                 BSTR expected = NULL;
8894
8895                 hr = IUri_GetQuery(uri, &expected);
8896                 ok(SUCCEEDED(hr),
8897                     "Error: Expected IUri_GetQuery to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8898                     hr, test_index);
8899                 has_prop = hr == S_OK;
8900
8901                 hr = IUriBuilder_GetQuery(builder, &len, &received);
8902                 if(has_prop) {
8903                     ok(hr == S_OK,
8904                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8905                         hr, S_OK, test_index);
8906                     if(SUCCEEDED(hr)) {
8907                         ok(!lstrcmpW(expected, received),
8908                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8909                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8910                         ok(lstrlenW(expected) == len,
8911                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8912                             lstrlenW(expected), len, test_index);
8913                     }
8914                 } else {
8915                     ok(hr == S_FALSE,
8916                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8917                         hr, S_FALSE, test_index);
8918                     if(SUCCEEDED(hr)) {
8919                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8920                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8921                             len, test_index);
8922                     }
8923                 }
8924                 SysFreeString(expected);
8925             }
8926         }
8927         if(uri) IUri_Release(uri);
8928     }
8929 }
8930
8931 static void test_IUriBuilder_GetSchemeName(IUriBuilder *builder, const uri_builder_test *test,
8932                                            DWORD test_index) {
8933     HRESULT hr;
8934     DWORD i;
8935     LPCWSTR received = NULL;
8936     DWORD len = -1;
8937     const uri_builder_property *prop = NULL;
8938
8939     /* Check if the property was set earlier. */
8940     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8941         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_SCHEME_NAME)
8942             prop = &(test->properties[i]);
8943     }
8944
8945     if(prop) {
8946         /* Use expected_value unless it's NULL, then use value. */
8947         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8948         hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8949         if(prop->todo) {
8950             todo_wine {
8951                 ok(hr == (expected ? S_OK : S_FALSE),
8952                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8953                     hr, (expected ? S_OK : S_FALSE), test_index);
8954             }
8955             if(SUCCEEDED(hr)) {
8956                 todo_wine {
8957                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8958                         expected, wine_dbgstr_w(received), test_index);
8959                 }
8960                 todo_wine {
8961                     ok(lstrlen(expected) == len,
8962                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8963                         lstrlen(expected), len, test_index);
8964                 }
8965             }
8966         } else {
8967             ok(hr == (expected ? S_OK : S_FALSE),
8968                 "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8969                 hr, (expected ? S_OK : S_FALSE), test_index);
8970             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8971                 expected, wine_dbgstr_w(received), test_index);
8972             ok(lstrlen(expected) == len,
8973                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8974                 lstrlen(expected), len, test_index);
8975         }
8976     } else {
8977         /* The property wasn't set earlier, so it should return whatever
8978          * the base IUri contains (if anything).
8979          */
8980         IUri *uri = NULL;
8981         hr = IUriBuilder_GetIUri(builder, &uri);
8982         ok(hr == S_OK,
8983             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8984             hr, S_OK, test_index);
8985         if(SUCCEEDED(hr)) {
8986             if(!uri) {
8987                 received = (void*) 0xdeadbeef;
8988                 len = -1;
8989
8990                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8991                 ok(hr == S_FALSE,
8992                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8993                     hr, S_FALSE, test_index);
8994                 if(SUCCEEDED(hr)) {
8995                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8996                         len, test_index);
8997                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8998                         received, test_index);
8999                 }
9000             } else {
9001                 BOOL has_prop = FALSE;
9002                 BSTR expected = NULL;
9003
9004                 hr = IUri_GetSchemeName(uri, &expected);
9005                 ok(SUCCEEDED(hr),
9006                     "Error: Expected IUri_GetSchemeName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
9007                     hr, test_index);
9008                 has_prop = hr == S_OK;
9009
9010                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
9011                 if(has_prop) {
9012                     ok(hr == S_OK,
9013                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9014                         hr, S_OK, test_index);
9015                     if(SUCCEEDED(hr)) {
9016                         ok(!lstrcmpW(expected, received),
9017                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
9018                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
9019                         ok(lstrlenW(expected) == len,
9020                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9021                             lstrlenW(expected), len, test_index);
9022                     }
9023                 } else {
9024                     ok(hr == S_FALSE,
9025                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9026                         hr, S_FALSE, test_index);
9027                     if(SUCCEEDED(hr)) {
9028                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
9029                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
9030                             len, test_index);
9031                     }
9032                 }
9033                 SysFreeString(expected);
9034             }
9035         }
9036         if(uri) IUri_Release(uri);
9037     }
9038 }
9039
9040 static void test_IUriBuilder_GetUserName(IUriBuilder *builder, const uri_builder_test *test,
9041                                          DWORD test_index) {
9042     HRESULT hr;
9043     DWORD i;
9044     LPCWSTR received = NULL;
9045     DWORD len = -1;
9046     const uri_builder_property *prop = NULL;
9047
9048     /* Check if the property was set earlier. */
9049     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
9050         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_USER_NAME)
9051             prop = &(test->properties[i]);
9052     }
9053
9054     if(prop && prop->value && *prop->value) {
9055         /* Use expected_value unless it's NULL, then use value. */
9056         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
9057         hr = IUriBuilder_GetUserName(builder, &len, &received);
9058         if(prop->todo) {
9059             todo_wine {
9060                 ok(hr == (expected ? S_OK : S_FALSE),
9061                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9062                     hr, (expected ? S_OK : S_FALSE), test_index);
9063             }
9064             if(SUCCEEDED(hr)) {
9065                 todo_wine {
9066                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
9067                         expected, wine_dbgstr_w(received), test_index);
9068                 }
9069                 todo_wine {
9070                     ok(lstrlen(expected) == len,
9071                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9072                         lstrlen(expected), len, test_index);
9073                 }
9074             }
9075         } else {
9076             ok(hr == (expected ? S_OK : S_FALSE),
9077                 "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9078                 hr, (expected ? S_OK : S_FALSE), test_index);
9079             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
9080                 expected, wine_dbgstr_w(received), test_index);
9081             ok(lstrlen(expected) == len,
9082                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9083                 lstrlen(expected), len, test_index);
9084         }
9085     } else {
9086         /* The property wasn't set earlier, so it should return whatever
9087          * the base IUri contains (if anything).
9088          */
9089         IUri *uri = NULL;
9090         hr = IUriBuilder_GetIUri(builder, &uri);
9091         ok(hr == S_OK,
9092             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9093             hr, S_OK, test_index);
9094         if(SUCCEEDED(hr)) {
9095             if(!uri) {
9096                 received = (void*) 0xdeadbeef;
9097                 len = -1;
9098
9099                 hr = IUriBuilder_GetUserName(builder, &len, &received);
9100                 ok(hr == S_FALSE,
9101                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9102                     hr, S_FALSE, test_index);
9103                 if(SUCCEEDED(hr)) {
9104                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
9105                         len, test_index);
9106                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
9107                         received, test_index);
9108                 }
9109             } else {
9110                 BSTR expected = NULL;
9111                 BOOL has_prop = FALSE;
9112
9113                 hr = IUri_GetUserName(uri, &expected);
9114                 ok(SUCCEEDED(hr),
9115                     "Error: Expected IUri_GetUserName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
9116                     hr, test_index);
9117                 has_prop = hr == S_OK;
9118
9119                 hr = IUriBuilder_GetUserName(builder, &len, &received);
9120                 if(has_prop) {
9121                     ok(hr == S_OK,
9122                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9123                         hr, S_OK, test_index);
9124                     if(SUCCEEDED(hr)) {
9125                         ok(!lstrcmpW(expected, received),
9126                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
9127                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
9128                         ok(lstrlenW(expected) == len,
9129                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9130                             lstrlenW(expected), len, test_index);
9131                     }
9132                 } else {
9133                     ok(hr == S_FALSE,
9134                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9135                         hr, S_FALSE, test_index);
9136                     if(SUCCEEDED(hr)) {
9137                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
9138                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
9139                             len, test_index);
9140                     }
9141                 }
9142                 SysFreeString(expected);
9143             }
9144         }
9145         if(uri) IUri_Release(uri);
9146     }
9147 }
9148
9149 /* Tests IUriBuilder functions. */
9150 static void test_IUriBuilder(void) {
9151     HRESULT hr;
9152     IUriBuilder *builder;
9153     DWORD i;
9154
9155     for(i = 0; i < sizeof(uri_builder_tests)/sizeof(uri_builder_tests[0]); ++i) {
9156         IUri *uri = NULL;
9157         uri_builder_test test = uri_builder_tests[i];
9158         LPWSTR uriW = NULL;
9159
9160         if(test.uri) {
9161             uriW = a2w(test.uri);
9162             hr = pCreateUri(uriW, test.create_flags, 0, &uri);
9163             ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9164                 hr, S_OK, i);
9165             if(FAILED(hr)) continue;
9166         }
9167         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9168         if(test.create_builder_todo) {
9169             todo_wine {
9170                 ok(hr == test.create_builder_expected,
9171                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9172                     hr, test.create_builder_expected, i);
9173             }
9174         } else {
9175             ok(hr == test.create_builder_expected,
9176                 "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9177                 hr, test.create_builder_expected, i);
9178         }
9179         if(SUCCEEDED(hr)) {
9180             DWORD j;
9181             BOOL modified = FALSE, received = FALSE;
9182
9183             /* Perform all the string property changes. */
9184             for(j = 0; j < URI_BUILDER_STR_PROPERTY_COUNT; ++j) {
9185                 uri_builder_property prop = test.properties[j];
9186                 if(prop.change) {
9187                     change_property(builder, &prop, i);
9188                     if(prop.property != Uri_PROPERTY_SCHEME_NAME &&
9189                        prop.property != Uri_PROPERTY_HOST)
9190                         modified = TRUE;
9191                     else if(prop.value && *prop.value)
9192                         modified = TRUE;
9193                     else if(prop.value && !*prop.value && prop.property == Uri_PROPERTY_HOST)
9194                         /* Host name property can't be NULL, but it can be empty. */
9195                         modified = TRUE;
9196                 }
9197             }
9198
9199             if(test.port_prop.change) {
9200                 hr = IUriBuilder_SetPort(builder, test.port_prop.set, test.port_prop.value);
9201                 modified = TRUE;
9202                 if(test.port_prop.todo) {
9203                     todo_wine {
9204                         ok(hr == test.port_prop.expected,
9205                             "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9206                             hr, test.port_prop.expected, i);
9207                     }
9208                 } else {
9209                     ok(hr == test.port_prop.expected,
9210                         "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9211                         hr, test.port_prop.expected, i);
9212                 }
9213             }
9214
9215             hr = IUriBuilder_HasBeenModified(builder, &received);
9216             ok(hr == S_OK,
9217                 "Error IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9218                 hr, S_OK, i);
9219             if(SUCCEEDED(hr))
9220                 ok(received == modified,
9221                     "Error: Expected received to be %d but was %d instead on uri_builder_tests[%d].\n",
9222                     modified, received, i);
9223
9224             /* Test the "Get*" functions. */
9225             test_IUriBuilder_GetFragment(builder, &test, i);
9226             test_IUriBuilder_GetHost(builder, &test, i);
9227             test_IUriBuilder_GetPassword(builder, &test, i);
9228             test_IUriBuilder_GetPath(builder, &test, i);
9229             test_IUriBuilder_GetPort(builder, &test, i);
9230             test_IUriBuilder_GetQuery(builder, &test, i);
9231             test_IUriBuilder_GetSchemeName(builder, &test, i);
9232             test_IUriBuilder_GetUserName(builder, &test, i);
9233
9234             test_IUriBuilder_CreateUri(builder, &test, i);
9235             test_IUriBuilder_CreateUriSimple(builder, &test, i);
9236             test_IUriBuilder_CreateUriWithFlags(builder, &test, i);
9237         }
9238         if(builder) IUriBuilder_Release(builder);
9239         if(uri) IUri_Release(uri);
9240         heap_free(uriW);
9241     }
9242 }
9243
9244 static void test_IUriBuilder_HasBeenModified(void) {
9245     HRESULT hr;
9246     IUriBuilder *builder = NULL;
9247
9248     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9249     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9250     if(SUCCEEDED(hr)) {
9251         static const WCHAR hostW[] = {'g','o','o','g','l','e','.','c','o','m',0};
9252         IUri *uri = NULL;
9253         BOOL received;
9254
9255         hr = IUriBuilder_HasBeenModified(builder, NULL);
9256         ok(hr == E_POINTER, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9257             hr, E_POINTER);
9258
9259         hr = IUriBuilder_SetHost(builder, hostW);
9260         ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n",
9261             hr, S_OK);
9262
9263         hr = IUriBuilder_HasBeenModified(builder, &received);
9264         ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9265             hr, S_OK);
9266         if(SUCCEEDED(hr))
9267             ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9268
9269         hr = pCreateUri(http_urlW, 0, 0, &uri);
9270         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9271         if(SUCCEEDED(hr)) {
9272             LPCWSTR prop;
9273             DWORD len = -1;
9274
9275             hr = IUriBuilder_SetIUri(builder, uri);
9276             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n",
9277                 hr, S_OK);
9278
9279             hr = IUriBuilder_HasBeenModified(builder, &received);
9280             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9281                 hr, S_OK);
9282             if(SUCCEEDED(hr))
9283                 ok(received == FALSE, "Error: Expected received to be FALSE.\n");
9284
9285             /* Test what happens with you call SetIUri with the same IUri again. */
9286             hr = IUriBuilder_SetHost(builder, hostW);
9287             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9288
9289             hr = IUriBuilder_HasBeenModified(builder, &received);
9290             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9291                 hr, S_OK);
9292             if(SUCCEEDED(hr))
9293                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9294
9295             hr = IUriBuilder_SetIUri(builder, uri);
9296             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9297
9298             /* IUriBuilder already had 'uri' as it's IUri property and so Windows doesn't
9299              * reset any of the changes that were made to the IUriBuilder.
9300              */
9301             hr = IUriBuilder_HasBeenModified(builder, &received);
9302             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9303             if(SUCCEEDED(hr))
9304                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9305
9306             hr = IUriBuilder_GetHost(builder, &len, &prop);
9307             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9308             if(SUCCEEDED(hr)) {
9309                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
9310                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
9311                 ok(len == lstrlenW(hostW), "Error: Expected len to be %d, but was %d instead.\n",
9312                     lstrlenW(hostW), len);
9313             }
9314
9315             hr = IUriBuilder_SetIUri(builder, NULL);
9316             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9317
9318             hr = IUriBuilder_SetHost(builder, hostW);
9319             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9320             hr = IUriBuilder_HasBeenModified(builder, &received);
9321             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9322                 hr, S_OK);
9323             if(SUCCEEDED(hr))
9324                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9325
9326             hr = IUriBuilder_SetIUri(builder, NULL);
9327             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%09x.\n", hr, S_OK);
9328
9329             hr = IUriBuilder_HasBeenModified(builder, &received);
9330             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9331                 hr, S_OK);
9332             if(SUCCEEDED(hr))
9333                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9334
9335             hr = IUriBuilder_GetHost(builder, &len, &prop);
9336             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9337             if(SUCCEEDED(hr)) {
9338                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
9339                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
9340                 ok(len == lstrlenW(hostW), "Error: Expected len to %d, but was %d instead.\n",
9341                     lstrlenW(hostW), len);
9342             }
9343         }
9344         if(uri) IUri_Release(uri);
9345     }
9346     if(builder) IUriBuilder_Release(builder);
9347 }
9348
9349 /* Test IUriBuilder {Get,Set}IUri functions. */
9350 static void test_IUriBuilder_IUriProperty(void) {
9351     IUriBuilder *builder = NULL;
9352     HRESULT hr;
9353
9354     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9355     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9356     if(SUCCEEDED(hr)) {
9357         IUri *uri = NULL;
9358
9359         hr = IUriBuilder_GetIUri(builder, NULL);
9360         ok(hr == E_POINTER, "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x.\n",
9361             hr, E_POINTER);
9362
9363         hr = pCreateUri(http_urlW, 0, 0, &uri);
9364         if(SUCCEEDED(hr)) {
9365             IUri *test = NULL;
9366             ULONG cur_count, orig_count;
9367
9368             /* IUriBuilder doesn't clone the IUri, it use the same IUri. */
9369             orig_count = get_refcnt(uri);
9370             hr = IUriBuilder_SetIUri(builder, uri);
9371             cur_count = get_refcnt(uri);
9372             if(SUCCEEDED(hr))
9373                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9374                     orig_count+1, cur_count);
9375
9376             hr = IUriBuilder_SetIUri(builder, NULL);
9377             cur_count = get_refcnt(uri);
9378             if(SUCCEEDED(hr))
9379                 ok(cur_count == orig_count, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9380                     orig_count, cur_count);
9381
9382             /* CreateUri* functions will return back the same IUri if nothing has changed. */
9383             hr = IUriBuilder_SetIUri(builder, uri);
9384             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9385             orig_count = get_refcnt(uri);
9386
9387             hr = IUriBuilder_CreateUri(builder, 0, 0, 0, &test);
9388             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9389             if(SUCCEEDED(hr)) {
9390                 cur_count = get_refcnt(uri);
9391                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9392                     orig_count+1, cur_count);
9393                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n",
9394                     uri, test);
9395             }
9396             if(test) IUri_Release(test);
9397
9398             test = NULL;
9399             hr = IUriBuilder_CreateUri(builder, -1, 0, 0, &test);
9400             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9401             if(SUCCEEDED(hr)) {
9402                 cur_count = get_refcnt(uri);
9403                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9404                     orig_count+1, cur_count);
9405                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9406             }
9407             if(test) IUri_Release(test);
9408
9409             /* Doesn't return the same IUri, if the flag combination is different then the one that created
9410              * the base IUri.
9411              */
9412             test = NULL;
9413             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, &test);
9414             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9415             if(SUCCEEDED(hr))
9416                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
9417
9418             if(test) IUri_Release(test);
9419
9420             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
9421              * explicitly set (because it's a default flags).
9422              */
9423             test = NULL;
9424             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_CANONICALIZE, 0, 0, &test);
9425             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9426             if(SUCCEEDED(hr)) {
9427                 cur_count = get_refcnt(uri);
9428                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9429                     orig_count+1, cur_count);
9430                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
9431             }
9432             if(test) IUri_Release(test);
9433
9434             test = NULL;
9435             hr = IUriBuilder_CreateUriSimple(builder, 0, 0, &test);
9436             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9437             if(SUCCEEDED(hr)) {
9438                 cur_count = get_refcnt(uri);
9439                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9440                     orig_count+1, cur_count);
9441                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9442             }
9443             if(test) IUri_Release(test);
9444
9445             test = NULL;
9446             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &test);
9447             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
9448                 hr, S_OK);
9449             if(SUCCEEDED(hr)) {
9450                 cur_count = get_refcnt(uri);
9451                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9452                     orig_count+1, cur_count);
9453                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9454             }
9455             if(test) IUri_Release(test);
9456
9457             /* Doesn't return the same IUri, if the flag combination is different then the one that created
9458              * the base IUri.
9459              */
9460             test = NULL;
9461             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, 0, &test);
9462             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9463             if(SUCCEEDED(hr))
9464                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
9465
9466             if(test) IUri_Release(test);
9467
9468             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
9469              * explicitly set (because it's a default flags).
9470              */
9471             test = NULL;
9472             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_CANONICALIZE, 0, 0, 0, &test);
9473             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9474             if(SUCCEEDED(hr)) {
9475                 cur_count = get_refcnt(uri);
9476                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9477                     orig_count+1, cur_count);
9478                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
9479             }
9480             if(test) IUri_Release(test);
9481         }
9482         if(uri) IUri_Release(uri);
9483     }
9484     if(builder) IUriBuilder_Release(builder);
9485 }
9486
9487 static void test_IUriBuilder_RemoveProperties(void) {
9488     IUriBuilder *builder = NULL;
9489     HRESULT hr;
9490     DWORD i;
9491
9492     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9493     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9494     if(SUCCEEDED(hr)) {
9495         /* Properties that can't be removed. */
9496         const DWORD invalid = Uri_HAS_ABSOLUTE_URI|Uri_HAS_DISPLAY_URI|Uri_HAS_RAW_URI|Uri_HAS_HOST_TYPE|
9497                               Uri_HAS_SCHEME|Uri_HAS_ZONE;
9498
9499         for(i = Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_DWORD_LAST; ++i) {
9500             hr = IUriBuilder_RemoveProperties(builder, i << 1);
9501             if((i << 1) & invalid) {
9502                 ok(hr == E_INVALIDARG,
9503                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
9504                     hr, E_INVALIDARG, i);
9505             } else {
9506                 ok(hr == S_OK,
9507                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
9508                     hr, S_OK, i);
9509             }
9510         }
9511
9512         /* Also doesn't accept anything that's outside the range of the
9513          * Uri_HAS flags.
9514          */
9515         hr = IUriBuilder_RemoveProperties(builder, (Uri_PROPERTY_DWORD_LAST+1) << 1);
9516         ok(hr == E_INVALIDARG, "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x.\n",
9517             hr, E_INVALIDARG);
9518     }
9519     if(builder) IUriBuilder_Release(builder);
9520
9521     for(i = 0; i < sizeof(uri_builder_remove_tests)/sizeof(uri_builder_remove_tests[0]); ++i) {
9522         uri_builder_remove_test test = uri_builder_remove_tests[i];
9523         IUri *uri = NULL;
9524         LPWSTR uriW;
9525
9526         uriW = a2w(test.uri);
9527         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
9528         if(SUCCEEDED(hr)) {
9529             builder = NULL;
9530
9531             hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9532             if(test.create_builder_todo) {
9533                 todo_wine {
9534                     ok(hr == test.create_builder_expected,
9535                         "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9536                         hr, test.create_builder_expected, i);
9537                 }
9538             } else {
9539                 ok(hr == test.create_builder_expected,
9540                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9541                     hr, test.create_builder_expected, i);
9542             }
9543             if(SUCCEEDED(hr)) {
9544                 hr = IUriBuilder_RemoveProperties(builder, test.remove_properties);
9545                 if(test.remove_todo) {
9546                     todo_wine {
9547                         ok(hr == test.remove_expected,
9548                             "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x on test %d.\n",
9549                             hr, test.remove_expected, i);
9550                     }
9551                 } else {
9552                     ok(hr == test.remove_expected,
9553                         "Error: IUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9554                         hr, test.remove_expected, i);
9555                 }
9556                 if(SUCCEEDED(hr)) {
9557                     IUri *result = NULL;
9558
9559                     hr = IUriBuilder_CreateUri(builder, test.expected_flags, 0, 0, &result);
9560                     if(test.expected_todo) {
9561                         todo_wine {
9562                             ok(hr == test.expected_hres,
9563                                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
9564                                 hr, test.expected_hres, i);
9565                         }
9566                     } else {
9567                         ok(hr == test.expected_hres,
9568                             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
9569                             hr, test.expected_hres, i);
9570                     }
9571                     if(SUCCEEDED(hr)) {
9572                         BSTR received = NULL;
9573
9574                         hr = IUri_GetAbsoluteUri(result, &received);
9575                         ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
9576                         ok(!strcmp_aw(test.expected_uri, received),
9577                             "Error: Expected %s but got %s instead on test %d.\n",
9578                             test.expected_uri, wine_dbgstr_w(received), i);
9579                         SysFreeString(received);
9580                     }
9581                     if(result) IUri_Release(result);
9582                 }
9583             }
9584             if(builder) IUriBuilder_Release(builder);
9585         }
9586         if(uri) IUri_Release(uri);
9587         heap_free(uriW);
9588     }
9589 }
9590
9591 static void test_IUriBuilder_Misc(void) {
9592     HRESULT hr;
9593     IUri *uri;
9594
9595     hr = pCreateUri(http_urlW, 0, 0, &uri);
9596     if(SUCCEEDED(hr)) {
9597         IUriBuilder *builder;
9598
9599         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9600         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9601         if(SUCCEEDED(hr)) {
9602             BOOL has = -1;
9603             DWORD port = -1;
9604
9605             hr = IUriBuilder_GetPort(builder, &has, &port);
9606             ok(hr == S_OK, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9607             if(SUCCEEDED(hr)) {
9608                 /* 'has' will be set to FALSE, even though uri had a port. */
9609                 ok(has == FALSE, "Error: Expected 'has' to be FALSE, was %d instead.\n", has);
9610                 /* Still sets 'port' to 80. */
9611                 ok(port == 80, "Error: Expected the port to be 80, but, was %d instead.\n", port);
9612             }
9613         }
9614         if(builder) IUriBuilder_Release(builder);
9615     }
9616     if(uri) IUri_Release(uri);
9617 }
9618
9619 static void test_IUriBuilderFactory(void) {
9620     HRESULT hr;
9621     IUri *uri;
9622     IUriBuilderFactory *factory;
9623     IUriBuilder *builder;
9624
9625     hr = pCreateUri(http_urlW, 0, 0, &uri);
9626     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9627     if(SUCCEEDED(hr)) {
9628         factory = NULL;
9629         hr = IUri_QueryInterface(uri, &IID_IUriBuilderFactory, (void**)&factory);
9630         ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x.\n", hr);
9631         ok(factory != NULL, "Error: Expected 'factory' to not be NULL.\n");
9632
9633         if(SUCCEEDED(hr)) {
9634             builder = (void*) 0xdeadbeef;
9635             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 10, 0, &builder);
9636             ok(hr == E_INVALIDARG, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9637                 hr, E_INVALIDARG);
9638             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9639
9640             builder = (void*) 0xdeadbeef;
9641             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 10, &builder);
9642             ok(hr == E_INVALIDARG, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9643                 hr, E_INVALIDARG);
9644             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9645
9646             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 0, NULL);
9647             ok(hr == E_POINTER, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9648                 hr, E_POINTER);
9649
9650             builder = NULL;
9651             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 0, &builder);
9652             ok(hr == S_OK, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9653                 hr, S_OK);
9654             if(SUCCEEDED(hr)) {
9655                 IUri *tmp = (void*) 0xdeadbeef;
9656                 LPCWSTR result;
9657                 DWORD result_len;
9658
9659                 hr = IUriBuilder_GetIUri(builder, &tmp);
9660                 ok(hr == S_OK, "Error: GetIUri returned 0x%08x, expected 0x%08x.\n",
9661                     hr, S_OK);
9662                 ok(!tmp, "Error: Expected 'tmp' to be NULL, but was %p instead.\n", tmp);
9663
9664                 hr = IUriBuilder_GetHost(builder, &result_len, &result);
9665                 ok(hr == S_FALSE, "Error: GetHost returned 0x%08x, expected 0x%08x.\n",
9666                     hr, S_FALSE);
9667             }
9668             if(builder) IUriBuilder_Release(builder);
9669
9670             builder = (void*) 0xdeadbeef;
9671             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 10, 0, &builder);
9672             ok(hr == E_INVALIDARG, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9673                 hr, E_INVALIDARG);
9674             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9675
9676             builder = (void*) 0xdeadbeef;
9677             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 10, &builder);
9678             ok(hr == E_INVALIDARG, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9679                 hr, E_INVALIDARG);
9680             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9681
9682             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 0, NULL);
9683             ok(hr == E_POINTER, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9684                 hr, E_POINTER);
9685
9686             builder = NULL;
9687             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 0, &builder);
9688             ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9689                 hr, S_OK);
9690             if(SUCCEEDED(hr)) {
9691                 IUri *tmp = NULL;
9692
9693                 hr = IUriBuilder_GetIUri(builder, &tmp);
9694                 ok(hr == S_OK, "Error: GetIUri return 0x%08x, expected 0x%08x.\n",
9695                     hr, S_OK);
9696                 ok(tmp == uri, "Error: Expected tmp to be %p, but was %p.\n", uri, tmp);
9697                 if(uri) IUri_Release(uri);
9698             }
9699             if(builder) IUriBuilder_Release(builder);
9700         }
9701         if(factory) IUriBuilderFactory_Release(factory);
9702     }
9703     if(uri) IUri_Release(uri);
9704 }
9705
9706 static void test_CoInternetCombineIUri(void) {
9707     HRESULT hr;
9708     IUri *base, *relative, *result;
9709     DWORD i;
9710
9711     base = NULL;
9712     hr = pCreateUri(http_urlW, 0, 0, &base);
9713     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9714     if(SUCCEEDED(hr)) {
9715         result = (void*) 0xdeadbeef;
9716         hr = pCoInternetCombineIUri(base, NULL, 0, &result, 0);
9717         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9718         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9719     }
9720
9721     relative = NULL;
9722     hr = pCreateUri(http_urlW, 0, 0, &relative);
9723     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9724     if(SUCCEEDED(hr)) {
9725         result = (void*) 0xdeadbeef;
9726         hr = pCoInternetCombineIUri(NULL, relative, 0, &result, 0);
9727         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9728         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9729     }
9730
9731     hr = pCoInternetCombineIUri(base, relative, 0, NULL, 0);
9732     ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9733
9734     if(base) IUri_Release(base);
9735     if(relative) IUri_Release(relative);
9736
9737     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
9738         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
9739
9740         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
9741         ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9742         if(SUCCEEDED(hr)) {
9743             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
9744
9745             hr = pCreateUri(relativeW, uri_combine_tests[i].relative_create_flags, 0, &relative);
9746             ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9747             if(SUCCEEDED(hr)) {
9748                 result = NULL;
9749
9750                 hr = pCoInternetCombineIUri(base, relative, uri_combine_tests[i].combine_flags, &result, 0);
9751                 if(uri_combine_tests[i].todo) {
9752                     todo_wine {
9753                         ok(hr == uri_combine_tests[i].expected,
9754                             "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9755                             hr, uri_combine_tests[i].expected, i);
9756                     }
9757                 } else {
9758                     ok(hr == uri_combine_tests[i].expected,
9759                         "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9760                         hr, uri_combine_tests[i]. expected, i);
9761                 }
9762                 if(SUCCEEDED(hr)) {
9763                     DWORD j;
9764
9765                     for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
9766                         uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
9767                         BSTR received;
9768
9769                         hr = IUri_GetPropertyBSTR(result, j, &received, 0);
9770                         if(prop.todo) {
9771                             todo_wine {
9772                                 ok(hr == prop.expected,
9773                                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9774                                     hr, prop.expected, i, j);
9775                             }
9776                             todo_wine {
9777                                 ok(!strcmp_aw(prop.value, received) ||
9778                                    broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9779                                     "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9780                                     prop.value, wine_dbgstr_w(received), i, j);
9781                             }
9782                         } else {
9783                             ok(hr == prop.expected,
9784                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9785                                 hr, prop.expected, i, j);
9786                             ok(!strcmp_aw(prop.value, received) ||
9787                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9788                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9789                                 prop.value, wine_dbgstr_w(received), i, j);
9790                         }
9791                         SysFreeString(received);
9792                     }
9793
9794                     for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
9795                         uri_dword_property prop = uri_combine_tests[i].dword_props[j];
9796                         DWORD received;
9797
9798                         hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
9799                         if(prop.todo) {
9800                             todo_wine {
9801                                 ok(hr == prop.expected,
9802                                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9803                                     hr, prop.expected, i, j);
9804                             }
9805                             todo_wine {
9806                                 ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9807                                     prop.value, received, i, j);
9808                             }
9809                         } else {
9810                             ok(hr == prop.expected,
9811                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9812                                 hr, prop.expected, i, j);
9813                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9814                                 prop.value, received, i, j);
9815                         }
9816                     }
9817                 }
9818                 if(result) IUri_Release(result);
9819             }
9820             if(relative) IUri_Release(relative);
9821             heap_free(relativeW);
9822         }
9823         if(base) IUri_Release(base);
9824         heap_free(baseW);
9825     }
9826 }
9827
9828 static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface,
9829                                                           REFIID riid, void **ppv)
9830 {
9831     ok(0, "unexpected call\n");
9832     return E_NOINTERFACE;
9833 }
9834
9835 static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
9836 {
9837     return 2;
9838 }
9839
9840 static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
9841 {
9842     return 1;
9843 }
9844
9845 static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
9846         PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
9847         DWORD *pcchResult, DWORD dwReserved)
9848 {
9849     CHECK_EXPECT(ParseUrl);
9850     ok(!lstrcmpW(pwzUrl, parse_urlW), "Error: Expected %s, but got %s instead.\n",
9851         wine_dbgstr_w(parse_urlW), wine_dbgstr_w(pwzUrl));
9852     ok(ParseAction == parse_action, "Error: Expected %d, but got %d.\n", parse_action, ParseAction);
9853     ok(dwParseFlags == parse_flags, "Error: Expected 0x%08x, but got 0x%08x.\n", parse_flags, dwParseFlags);
9854     ok(cchResult == 200, "Error: Got %d.\n", cchResult);
9855
9856     memcpy(pwzResult, parse_resultW, sizeof(parse_resultW));
9857     *pcchResult = lstrlenW(parse_resultW);
9858
9859     return S_OK;
9860 }
9861
9862 static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
9863         LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags,
9864         LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
9865 {
9866     CHECK_EXPECT(CombineUrl);
9867     ok(!lstrcmpW(pwzBaseUrl, combine_baseW), "Error: Expected %s, but got %s instead.\n",
9868         wine_dbgstr_w(combine_baseW), wine_dbgstr_w(pwzBaseUrl));
9869     ok(!lstrcmpW(pwzRelativeUrl, combine_relativeW), "Error: Expected %s, but got %s instead.\n",
9870         wine_dbgstr_w(combine_relativeW), wine_dbgstr_w(pwzRelativeUrl));
9871     ok(dwCombineFlags == (URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO),
9872         "Error: Expected 0, but got 0x%08x.\n", dwCombineFlags);
9873     ok(cchResult == INTERNET_MAX_URL_LENGTH+1, "Error: Got %d.\n", cchResult);
9874
9875     memcpy(pwzResult, combine_resultW, sizeof(combine_resultW));
9876     *pcchResult = lstrlenW(combine_resultW);
9877
9878     return S_OK;
9879 }
9880
9881 static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface,
9882         LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
9883 {
9884     ok(0, "unexpected call\n");
9885     return E_NOTIMPL;
9886 }
9887
9888 static HRESULT WINAPI InternetProtocolInfo_QueryInfo(IInternetProtocolInfo *iface,
9889         LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer,
9890         DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
9891 {
9892     ok(0, "unexpected call\n");
9893     return E_NOTIMPL;
9894 }
9895
9896 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl = {
9897     InternetProtocolInfo_QueryInterface,
9898     InternetProtocolInfo_AddRef,
9899     InternetProtocolInfo_Release,
9900     InternetProtocolInfo_ParseUrl,
9901     InternetProtocolInfo_CombineUrl,
9902     InternetProtocolInfo_CompareUrl,
9903     InternetProtocolInfo_QueryInfo
9904 };
9905
9906 static IInternetProtocolInfo protocol_info = { &InternetProtocolInfoVtbl };
9907
9908 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
9909 {
9910     if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
9911         *ppv = &protocol_info;
9912         return S_OK;
9913     }
9914
9915     ok(0, "unexpected call\n");
9916     return E_NOINTERFACE;
9917 }
9918
9919 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
9920 {
9921     return 2;
9922 }
9923
9924 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
9925 {
9926     return 1;
9927 }
9928
9929 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
9930                                         REFIID riid, void **ppv)
9931 {
9932     ok(0, "unexpected call\n");
9933     return E_NOTIMPL;
9934 }
9935
9936 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
9937 {
9938     ok(0, "unexpected call\n");
9939     return S_OK;
9940 }
9941
9942 static const IClassFactoryVtbl ClassFactoryVtbl = {
9943     ClassFactory_QueryInterface,
9944     ClassFactory_AddRef,
9945     ClassFactory_Release,
9946     ClassFactory_CreateInstance,
9947     ClassFactory_LockServer
9948 };
9949
9950 static IClassFactory protocol_cf = { &ClassFactoryVtbl };
9951
9952 static void register_protocols(void)
9953 {
9954     IInternetSession *session;
9955     HRESULT hres;
9956
9957     hres = pCoInternetGetSession(0, &session, 0);
9958     ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
9959     if(FAILED(hres))
9960         return;
9961
9962     hres = IInternetSession_RegisterNameSpace(session, &protocol_cf, &IID_NULL,
9963             winetestW, 0, NULL, 0);
9964     ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
9965
9966     IInternetSession_Release(session);
9967 }
9968
9969 static void unregister_protocols(void) {
9970     IInternetSession *session;
9971     HRESULT hr;
9972
9973     hr = pCoInternetGetSession(0, &session, 0);
9974     ok(hr == S_OK, "CoInternetGetSession failed: 0x%08x\n", hr);
9975     if(FAILED(hr))
9976         return;
9977
9978     hr = IInternetSession_UnregisterNameSpace(session, &protocol_cf, winetestW);
9979     ok(hr == S_OK, "UnregisterNameSpace failed: 0x%08x\n", hr);
9980
9981     IInternetSession_Release(session);
9982 }
9983
9984 static void test_CoInternetCombineIUri_Pluggable(void) {
9985     HRESULT hr;
9986     IUri *base = NULL;
9987
9988     hr = pCreateUri(combine_baseW, 0, 0, &base);
9989     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9990     if(SUCCEEDED(hr)) {
9991         IUri *relative = NULL;
9992
9993         hr = pCreateUri(combine_relativeW, Uri_CREATE_ALLOW_RELATIVE, 0, &relative);
9994         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9995         if(SUCCEEDED(hr)) {
9996             IUri *result = NULL;
9997
9998             SET_EXPECT(CombineUrl);
9999
10000             hr = pCoInternetCombineIUri(base, relative, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
10001                                         &result, 0);
10002             ok(hr == S_OK, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
10003
10004             CHECK_CALLED(CombineUrl);
10005
10006             if(SUCCEEDED(hr)) {
10007                 BSTR received = NULL;
10008                 hr = IUri_GetAbsoluteUri(result, &received);
10009                 ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
10010                 if(SUCCEEDED(hr)) {
10011                     ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
10012                         wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
10013                 }
10014                 SysFreeString(received);
10015             }
10016             if(result) IUri_Release(result);
10017         }
10018         if(relative) IUri_Release(relative);
10019     }
10020     if(base) IUri_Release(base);
10021 }
10022
10023 static void test_CoInternetCombineUrlEx(void) {
10024     HRESULT hr;
10025     IUri *base, *result;
10026     DWORD i;
10027
10028     base = NULL;
10029     hr = pCreateUri(http_urlW, 0, 0, &base);
10030     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10031     if(SUCCEEDED(hr)) {
10032         result = (void*) 0xdeadbeef;
10033         hr = pCoInternetCombineUrlEx(base, NULL, 0, &result, 0);
10034         ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
10035             hr, E_UNEXPECTED);
10036         ok(!result, "Error: Expected 'result' to be NULL was %p instead.\n", result);
10037     }
10038
10039     result = (void*) 0xdeadbeef;
10040     hr = pCoInternetCombineUrlEx(NULL, http_urlW, 0, &result, 0);
10041     ok(hr == E_INVALIDARG, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
10042         hr, E_INVALIDARG);
10043     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
10044
10045     result = (void*) 0xdeadbeef;
10046     hr = pCoInternetCombineUrlEx(NULL, NULL, 0, &result, 0);
10047     ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
10048         hr, E_UNEXPECTED);
10049     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
10050
10051     hr = pCoInternetCombineUrlEx(base, http_urlW, 0, NULL, 0);
10052     ok(hr == E_POINTER, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
10053         hr, E_POINTER);
10054     if(base) IUri_Release(base);
10055
10056     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
10057         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
10058
10059         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
10060         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_combine_tests[%d].\n", hr, i);
10061         if(SUCCEEDED(hr)) {
10062             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
10063
10064             hr = pCoInternetCombineUrlEx(base, relativeW, uri_combine_tests[i].combine_flags,
10065                                          &result, 0);
10066             if(uri_combine_tests[i].todo) {
10067                 todo_wine {
10068                     ok(hr == uri_combine_tests[i].expected,
10069                         "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
10070                         hr, uri_combine_tests[i].expected, i);
10071                 }
10072             } else {
10073                 ok(hr == uri_combine_tests[i].expected,
10074                     "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
10075                     hr, uri_combine_tests[i]. expected, i);
10076             }
10077             if(SUCCEEDED(hr)) {
10078                 DWORD j;
10079
10080                 for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
10081                     uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
10082                     BSTR received;
10083                     LPCSTR value = (prop.value_ex) ? prop.value_ex : prop.value;
10084
10085                     hr = IUri_GetPropertyBSTR(result, j, &received, 0);
10086                     if(prop.todo) {
10087                         todo_wine {
10088                             ok(hr == prop.expected,
10089                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
10090                                 hr, prop.expected, i, j);
10091                         }
10092                         todo_wine {
10093                             ok(!strcmp_aw(value, received) ||
10094                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
10095                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
10096                                 value, wine_dbgstr_w(received), i, j);
10097                         }
10098                     } else {
10099                         ok(hr == prop.expected,
10100                             "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
10101                             hr, prop.expected, i, j);
10102                         ok(!strcmp_aw(value, received) ||
10103                            broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
10104                             "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
10105                             value, wine_dbgstr_w(received), i, j);
10106                     }
10107                     SysFreeString(received);
10108                 }
10109
10110                 for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
10111                     uri_dword_property prop = uri_combine_tests[i].dword_props[j];
10112                     DWORD received;
10113
10114                     hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
10115                     if(prop.todo) {
10116                         todo_wine {
10117                             ok(hr == prop.expected,
10118                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
10119                                 hr, prop.expected, i, j);
10120                         }
10121                         todo_wine {
10122                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
10123                                 prop.value, received, i, j);
10124                         }
10125                     } else {
10126                         ok(hr == prop.expected,
10127                             "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
10128                             hr, prop.expected, i, j);
10129                         ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
10130                             prop.value, received, i, j);
10131                     }
10132                 }
10133             }
10134             if(result) IUri_Release(result);
10135             heap_free(relativeW);
10136         }
10137         if(base) IUri_Release(base);
10138         heap_free(baseW);
10139     }
10140 }
10141
10142 static void test_CoInternetCombineUrlEx_Pluggable(void) {
10143     HRESULT hr;
10144     IUri *base = NULL;
10145
10146     hr = pCreateUri(combine_baseW, 0, 0, &base);
10147     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10148     if(SUCCEEDED(hr)) {
10149         IUri *result = NULL;
10150
10151         SET_EXPECT(CombineUrl);
10152
10153         hr = pCoInternetCombineUrlEx(base, combine_relativeW, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
10154                                      &result, 0);
10155         ok(hr == S_OK, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
10156
10157         CHECK_CALLED(CombineUrl);
10158
10159         if(SUCCEEDED(hr)) {
10160             BSTR received = NULL;
10161             hr = IUri_GetAbsoluteUri(result, &received);
10162             ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
10163             if(SUCCEEDED(hr)) {
10164                 ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
10165                     wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
10166             }
10167             SysFreeString(received);
10168         }
10169         if(result) IUri_Release(result);
10170     }
10171     if(base) IUri_Release(base);
10172 }
10173
10174 static void test_CoInternetParseIUri_InvalidArgs(void) {
10175     HRESULT hr;
10176     IUri *uri = NULL;
10177     WCHAR tmp[3];
10178     DWORD result = -1;
10179
10180     hr = pCoInternetParseIUri(NULL, PARSE_CANONICALIZE, 0, tmp, 3, &result, 0);
10181     ok(hr == E_INVALIDARG, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10182         hr, E_INVALIDARG);
10183     ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10184
10185     hr = pCreateUri(http_urlW, 0, 0, &uri);
10186     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10187     if(SUCCEEDED(hr)) {
10188         DWORD expected_len;
10189
10190         result = -1;
10191         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, NULL, 0, &result, 0);
10192         ok(hr == E_INVALIDARG, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10193             hr, E_INVALIDARG);
10194         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10195
10196         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, tmp, 3, NULL, 0);
10197         ok(hr == E_POINTER, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10198             hr, E_POINTER);
10199
10200         result = -1;
10201         hr = pCoInternetParseIUri(uri, PARSE_SECURITY_URL, 0, tmp, 3, &result, 0);
10202         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x expected 0x%08x.\n",
10203             hr, E_FAIL);
10204         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10205
10206         result = -1;
10207         hr = pCoInternetParseIUri(uri, PARSE_MIME, 0, tmp, 3, &result, 0);
10208         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10209             hr, E_FAIL);
10210         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10211
10212         result = -1;
10213         hr = pCoInternetParseIUri(uri, PARSE_SERVER, 0, tmp, 3, &result, 0);
10214         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10215             hr, E_FAIL);
10216         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10217
10218         result = -1;
10219         hr = pCoInternetParseIUri(uri, PARSE_SECURITY_DOMAIN, 0, tmp, 3, &result, 0);
10220         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10221             hr, E_FAIL);
10222         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10223
10224         expected_len = lstrlenW(http_urlW);
10225         result = -1;
10226         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, tmp, 3, &result, 0);
10227         ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER,
10228             "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10229             hr, STRSAFE_E_INSUFFICIENT_BUFFER);
10230         ok(result == expected_len, "Error: Expected 'result' to be %d, but was %d instead.\n",
10231             expected_len, result);
10232     }
10233     if(uri) IUri_Release(uri);
10234 }
10235
10236 static void test_CoInternetParseIUri(void) {
10237     DWORD i;
10238
10239     for(i = 0; i < sizeof(uri_parse_tests)/sizeof(uri_parse_tests[0]); ++i) {
10240         HRESULT hr;
10241         IUri *uri;
10242         LPWSTR uriW;
10243         uri_parse_test test = uri_parse_tests[i];
10244
10245         uriW = a2w(test.uri);
10246         hr = pCreateUri(uriW, test.uri_flags, 0, &uri);
10247         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_parse_tests[%d].\n", hr, i);
10248         if(SUCCEEDED(hr)) {
10249             WCHAR result[INTERNET_MAX_URL_LENGTH+1];
10250             DWORD result_len = -1;
10251
10252             hr = pCoInternetParseIUri(uri, test.action, test.flags, result, INTERNET_MAX_URL_LENGTH+1, &result_len, 0);
10253             if(test.todo) {
10254                 todo_wine {
10255                     ok(hr == test.expected,
10256                         "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x on uri_parse_tests[%d].\n",
10257                         hr, test.expected, i);
10258                 }
10259             } else {
10260                 ok(hr == test.expected,
10261                     "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x on uri_parse_tests[%d].\n",
10262                     hr, test.expected, i);
10263             }
10264             if(SUCCEEDED(hr)) {
10265                 DWORD len = lstrlenA(test.property);
10266                 ok(!strcmp_aw(test.property, result),
10267                     "Error: Expected %s but got %s instead on uri_parse_tests[%d].\n",
10268                     test.property, wine_dbgstr_w(result), i);
10269                 ok(len == result_len,
10270                     "Error: Expected %d, but got %d instead on uri_parse_tests[%d].\n",
10271                     len, result_len, i);
10272             } else {
10273                 ok(!result_len,
10274                     "Error: Expected 'result_len' to be 0, but was %d on uri_parse_tests[%d].\n",
10275                     result_len, i);
10276             }
10277         }
10278         if(uri) IUri_Release(uri);
10279         heap_free(uriW);
10280     }
10281 }
10282
10283 static void test_CoInternetParseIUri_Pluggable(void) {
10284     HRESULT hr;
10285     IUri *uri = NULL;
10286
10287     hr = pCreateUri(parse_urlW, 0, 0, &uri);
10288     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, but got 0x%08x.\n", hr);
10289     if(SUCCEEDED(hr)) {
10290         WCHAR result[200];
10291         DWORD result_len;
10292
10293         SET_EXPECT(ParseUrl);
10294
10295         parse_action = PARSE_CANONICALIZE;
10296         parse_flags = URL_UNESCAPE|URL_ESCAPE_UNSAFE;
10297
10298         hr = pCoInternetParseIUri(uri, parse_action, parse_flags, result, 200, &result_len, 0);
10299         ok(hr == S_OK, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
10300
10301         CHECK_CALLED(ParseUrl);
10302
10303         if(SUCCEEDED(hr)) {
10304             ok(result_len == lstrlenW(parse_resultW), "Error: Expected %d, but got %d.\n",
10305                 lstrlenW(parse_resultW), result_len);
10306             ok(!lstrcmpW(result, parse_resultW), "Error: Expected %s, but got %s.\n",
10307                 wine_dbgstr_w(parse_resultW), wine_dbgstr_w(result));
10308         }
10309     }
10310     if(uri) IUri_Release(uri);
10311 }
10312
10313 typedef struct {
10314     const char *url;
10315     DWORD uri_flags;
10316     const char *base_url;
10317     DWORD base_uri_flags;
10318     const char *legacy_url;
10319     const char *uniform_url;
10320     const char *no_canon_url;
10321     const char *uri_url;
10322 } create_urlmon_test_t;
10323
10324 static const create_urlmon_test_t create_urlmon_tests[] = {
10325     {
10326         "http://www.winehq.org",Uri_CREATE_NO_CANONICALIZE,
10327         NULL,0,
10328         "http://www.winehq.org/",
10329         "http://www.winehq.org/",
10330         "http://www.winehq.org",
10331         "http://www.winehq.org"
10332     },
10333     {
10334         "file://c:\\dir\\file.txt",Uri_CREATE_NO_CANONICALIZE,
10335         NULL,0,
10336         "file://c:\\dir\\file.txt",
10337         "file:///c:/dir/file.txt",
10338         "file:///c:/dir/file.txt",
10339         "file:///c:/dir/file.txt"
10340     },
10341     {
10342         "file://c:\\dir\\file.txt",Uri_CREATE_FILE_USE_DOS_PATH,
10343         NULL,0,
10344         "file://c:\\dir\\file.txt",
10345         "file:///c:/dir/file.txt",
10346         "file:///c:/dir/file.txt",
10347         "file://c:\\dir\\file.txt"
10348     },
10349     {
10350         "dat%61",Uri_CREATE_ALLOW_RELATIVE,
10351         "http://www.winehq.org",0,
10352         "http://www.winehq.org/data",
10353         "http://www.winehq.org/data",
10354         "http://www.winehq.org:80/data",
10355     },
10356     {
10357         "file.txt",Uri_CREATE_ALLOW_RELATIVE,
10358         "file://c:\\dir\\x.txt",Uri_CREATE_NO_CANONICALIZE,
10359         "file://c:\\dir\\file.txt",
10360         "file:///c:/dir/file.txt",
10361         "file:///c:/dir/file.txt",
10362     },
10363     {
10364         "",Uri_CREATE_ALLOW_RELATIVE,
10365         NULL,0,
10366         "",
10367         "",
10368         "",
10369         ""
10370     },
10371     {
10372         "test",Uri_CREATE_ALLOW_RELATIVE,
10373         NULL,0,
10374         "test",
10375         "test",
10376         "test",
10377         "test"
10378     },
10379     {
10380         "c:\\dir\\file.txt",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME,
10381         NULL,0,
10382         "file://c:\\dir\\file.txt",
10383         "file:///c:/dir/file.txt",
10384         "file:///c:/dir/file.txt",
10385         "file:///c:/dir/file.txt",
10386     }
10387 };
10388
10389 #define test_urlmon_display_name(a,b) _test_urlmon_display_name(__LINE__,a,b)
10390 static void _test_urlmon_display_name(unsigned line, IMoniker *mon, const char *exurl)
10391 {
10392     WCHAR *display_name;
10393     HRESULT hres;
10394
10395     hres = IMoniker_GetDisplayName(mon, NULL, NULL, &display_name);
10396     ok_(__FILE__,line)(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
10397     ok_(__FILE__,line)(!strcmp_aw(exurl, display_name), "unexpected display name: %s, expected %s\n",
10398             wine_dbgstr_w(display_name), exurl);
10399
10400     CoTaskMemFree(display_name);
10401 }
10402
10403 #define test_display_uri(a,b) _test_display_uri(__LINE__,a,b)
10404 static void _test_display_uri(unsigned line, IMoniker *mon, const char *exurl)
10405 {
10406     IUriContainer *uri_container;
10407     IUri *uri;
10408     BSTR display_uri;
10409     HRESULT hres;
10410
10411     hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container);
10412     ok(hres == S_OK, "Could not get IUriContainer iface: %08x\n", hres);
10413
10414     uri = NULL;
10415     hres = IUriContainer_GetIUri(uri_container, &uri);
10416     IUriContainer_Release(uri_container);
10417     ok(hres == S_OK, "GetIUri failed: %08x\n", hres);
10418     ok(uri != NULL, "uri == NULL\n");
10419
10420     hres = IUri_GetDisplayUri(uri, &display_uri);
10421     IUri_Release(uri);
10422     ok(hres == S_OK, "GetDisplayUri failed: %08x\n", hres);
10423     ok_(__FILE__,line)(!strcmp_aw(exurl, display_uri), "unexpected display uri: %s, expected %s\n",
10424             wine_dbgstr_w(display_uri), exurl);
10425     SysFreeString(display_uri);
10426 }
10427
10428 static void test_CreateURLMoniker(void)
10429 {
10430     const create_urlmon_test_t *test;
10431     IMoniker *mon, *base_mon;
10432     WCHAR *url, *base_url;
10433     IUri *uri, *base_uri;
10434     HRESULT hres;
10435
10436     for(test = create_urlmon_tests; test < create_urlmon_tests + sizeof(create_urlmon_tests)/sizeof(*create_urlmon_tests); test++) {
10437         url = a2w(test->url);
10438         base_url = a2w(test->base_url);
10439
10440         if(base_url) {
10441             hres = pCreateUri(base_url, test->base_uri_flags, 0, &base_uri);
10442             ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
10443
10444             hres = pCreateURLMonikerEx2(NULL, base_uri, &base_mon, URL_MK_NO_CANONICALIZE);
10445             ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10446         }else {
10447             base_uri = NULL;
10448             base_mon = NULL;
10449         }
10450
10451         hres = CreateURLMoniker(base_mon, url, &mon);
10452         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10453         test_urlmon_display_name(mon, test->legacy_url);
10454         test_display_uri(mon, test->legacy_url);
10455         IMoniker_Release(mon);
10456
10457         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_LEGACY);
10458         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10459         test_urlmon_display_name(mon, test->legacy_url);
10460         test_display_uri(mon, test->legacy_url);
10461         IMoniker_Release(mon);
10462
10463         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_UNIFORM);
10464         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10465         test_urlmon_display_name(mon, test->uniform_url);
10466         test_display_uri(mon, test->uniform_url);
10467         IMoniker_Release(mon);
10468
10469         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_NO_CANONICALIZE);
10470         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10471         test_urlmon_display_name(mon, test->no_canon_url);
10472         test_display_uri(mon, test->no_canon_url);
10473         IMoniker_Release(mon);
10474
10475         hres = pCreateUri(url, test->uri_flags, 0, &uri);
10476         ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
10477
10478         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_LEGACY);
10479         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10480         test_urlmon_display_name(mon, base_url ? test->legacy_url : test->uri_url);
10481         test_display_uri(mon, base_url ? test->legacy_url : test->uri_url);
10482         IMoniker_Release(mon);
10483
10484         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_UNIFORM);
10485         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10486         test_urlmon_display_name(mon, base_url ? test->uniform_url : test->uri_url);
10487         test_display_uri(mon, base_url ? test->uniform_url : test->uri_url);
10488         IMoniker_Release(mon);
10489
10490         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_NO_CANONICALIZE);
10491         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10492         test_urlmon_display_name(mon, base_url ? test->no_canon_url : test->uri_url);
10493         test_display_uri(mon, base_url ? test->no_canon_url : test->uri_url);
10494         IMoniker_Release(mon);
10495
10496         IUri_Release(uri);
10497         heap_free(url);
10498         heap_free(base_url);
10499         if(base_uri)
10500             IUri_Release(base_uri);
10501         if(base_mon)
10502             IMoniker_Release(base_mon);
10503     }
10504 }
10505
10506 START_TEST(uri) {
10507     HMODULE hurlmon;
10508
10509     hurlmon = GetModuleHandle("urlmon.dll");
10510     pCoInternetGetSession = (void*) GetProcAddress(hurlmon, "CoInternetGetSession");
10511     pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri");
10512     pCreateUriWithFragment = (void*) GetProcAddress(hurlmon, "CreateUriWithFragment");
10513     pCreateIUriBuilder = (void*) GetProcAddress(hurlmon, "CreateIUriBuilder");
10514     pCoInternetCombineIUri = (void*) GetProcAddress(hurlmon, "CoInternetCombineIUri");
10515     pCoInternetCombineUrlEx = (void*) GetProcAddress(hurlmon, "CoInternetCombineUrlEx");
10516     pCoInternetParseIUri = (void*) GetProcAddress(hurlmon, "CoInternetParseIUri");
10517     pCreateURLMonikerEx = (void*) GetProcAddress(hurlmon, "CreateURLMonikerEx");
10518     pCreateURLMonikerEx2 = (void*) GetProcAddress(hurlmon, "CreateURLMonikerEx2");
10519
10520     if(!pCreateUri) {
10521         win_skip("CreateUri is not present, skipping tests.\n");
10522         return;
10523     }
10524
10525     trace("test CreateUri invalid flags...\n");
10526     test_CreateUri_InvalidFlags();
10527
10528     trace("test CreateUri invalid args...\n");
10529     test_CreateUri_InvalidArgs();
10530
10531     trace("test CreateUri invalid URIs...\n");
10532     test_CreateUri_InvalidUri();
10533
10534     trace("test IUri_GetPropertyBSTR...\n");
10535     test_IUri_GetPropertyBSTR();
10536
10537     trace("test IUri_GetPropertyDWORD...\n");
10538     test_IUri_GetPropertyDWORD();
10539
10540     trace("test IUri_GetStrProperties...\n");
10541     test_IUri_GetStrProperties();
10542
10543     trace("test IUri_GetDwordProperties...\n");
10544     test_IUri_GetDwordProperties();
10545
10546     trace("test IUri_GetPropertyLength...\n");
10547     test_IUri_GetPropertyLength();
10548
10549     trace("test IUri_GetProperties...\n");
10550     test_IUri_GetProperties();
10551
10552     trace("test IUri_HasProperty...\n");
10553     test_IUri_HasProperty();
10554
10555     trace("test IUri_IsEqual...\n");
10556     test_IUri_IsEqual();
10557
10558     trace("test CreateUriWithFragment invalid args...\n");
10559     test_CreateUriWithFragment_InvalidArgs();
10560
10561     trace("test CreateUriWithFragment invalid flags...\n");
10562     test_CreateUriWithFragment_InvalidFlags();
10563
10564     trace("test CreateUriWithFragment...\n");
10565     test_CreateUriWithFragment();
10566
10567     trace("test CreateIUriBuilder...\n");
10568     test_CreateIUriBuilder();
10569
10570     trace("test IUriBuilder_CreateInvalidArgs...\n");
10571     test_IUriBuilder_CreateInvalidArgs();
10572
10573     trace("test IUriBuilder...\n");
10574     test_IUriBuilder();
10575
10576     trace("test IUriBuilder_GetInvalidArgs...\n");
10577     test_IUriBuilder_GetInvalidArgs();
10578
10579     trace("test IUriBuilder_HasBeenModified...\n");
10580     test_IUriBuilder_HasBeenModified();
10581
10582     trace("test IUriBuilder_IUriProperty...\n");
10583     test_IUriBuilder_IUriProperty();
10584
10585     trace("test IUriBuilder_RemoveProperties...\n");
10586     test_IUriBuilder_RemoveProperties();
10587
10588     trace("test IUriBuilder miscellaneous...\n");
10589     test_IUriBuilder_Misc();
10590
10591     trace("test IUriBuilderFactory...\n");
10592     test_IUriBuilderFactory();
10593
10594     trace("test CoInternetCombineIUri...\n");
10595     test_CoInternetCombineIUri();
10596
10597     trace("test CoInternetCombineUrlEx...\n");
10598     test_CoInternetCombineUrlEx();
10599
10600     trace("test CoInternetParseIUri Invalid Args...\n");
10601     test_CoInternetParseIUri_InvalidArgs();
10602
10603     trace("test CoInternetParseIUri...\n");
10604     test_CoInternetParseIUri();
10605
10606     register_protocols();
10607
10608     trace("test CoInternetCombineIUri pluggable...\n");
10609     test_CoInternetCombineIUri_Pluggable();
10610
10611     trace("test CoInternetCombineUrlEx Pluggable...\n");
10612     test_CoInternetCombineUrlEx_Pluggable();
10613
10614     trace("test CoInternetParseIUri pluggable...\n");
10615     test_CoInternetParseIUri_Pluggable();
10616
10617     trace("test CreateURLMoniker...\n");
10618     test_CreateURLMoniker();
10619
10620     unregister_protocols();
10621 }