winealsa: Fix AudioRenderClient Get/ReleaseBuffer protocol.
[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 #define WIN32_LEAN_AND_MEAN
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "urlmon.h"
32 #include "shlwapi.h"
33 #include "wininet.h"
34 #include "strsafe.h"
35
36 #define URI_STR_PROPERTY_COUNT Uri_PROPERTY_STRING_LAST+1
37 #define URI_DWORD_PROPERTY_COUNT (Uri_PROPERTY_DWORD_LAST - Uri_PROPERTY_DWORD_START)+1
38 #define URI_BUILDER_STR_PROPERTY_COUNT 7
39
40 #define DEFINE_EXPECT(func) \
41     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
42
43 #define SET_EXPECT(func) \
44     expect_ ## func = TRUE
45
46 #define CHECK_EXPECT(func) \
47     do { \
48         ok(expect_ ##func, "unexpected call " #func "\n"); \
49         expect_ ## func = FALSE; \
50         called_ ## func = TRUE; \
51     }while(0)
52
53 #define CHECK_EXPECT2(func) \
54     do { \
55         ok(expect_ ##func, "unexpected call " #func "\n"); \
56         called_ ## func = TRUE; \
57     }while(0)
58
59 #define CHECK_CALLED(func) \
60     do { \
61         ok(called_ ## func, "expected " #func "\n"); \
62         expect_ ## func = called_ ## func = FALSE; \
63     }while(0)
64
65 DEFINE_EXPECT(CombineUrl);
66 DEFINE_EXPECT(ParseUrl);
67
68 static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**);
69 static HRESULT (WINAPI *pCreateUriWithFragment)(LPCWSTR, LPCWSTR, DWORD, DWORD_PTR, IUri**);
70 static HRESULT (WINAPI *pCreateIUriBuilder)(IUri*, DWORD, DWORD_PTR, IUriBuilder**);
71 static HRESULT (WINAPI *pCoInternetCombineIUri)(IUri*,IUri*,DWORD,IUri**,DWORD_PTR);
72 static HRESULT (WINAPI *pCoInternetGetSession)(DWORD,IInternetSession**,DWORD);
73 static HRESULT (WINAPI *pCoInternetCombineUrlEx)(IUri*,LPCWSTR,DWORD,IUri**,DWORD_PTR);
74 static HRESULT (WINAPI *pCoInternetParseIUri)(IUri*,PARSEACTION,DWORD,LPWSTR,DWORD,DWORD*,DWORD_PTR);
75 static HRESULT (WINAPI *pCreateURLMonikerEx)(IMoniker*,LPCWSTR,IMoniker**,DWORD);
76 static HRESULT (WINAPI *pCreateURLMonikerEx2)(IMoniker*,IUri*,IMoniker**,DWORD);
77
78 static const WCHAR http_urlW[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
79         '.','o','r','g','/',0};
80 static const WCHAR http_url_fragW[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
81         '.','o','r','g','/','#','F','r','a','g',0};
82
83 static const WCHAR combine_baseW[] = {'w','i','n','e','t','e','s','t',':','?','t',
84         'e','s','t','i','n','g',0};
85 static const WCHAR combine_relativeW[] = {'?','t','e','s','t',0};
86 static const WCHAR combine_resultW[] = {'z','i','p',':','t','e','s','t',0};
87
88 static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0};
89
90 static const WCHAR parse_urlW[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t',0};
91 static const WCHAR parse_resultW[] = {'z','i','p',':','t','e','s','t',0};
92
93 static PARSEACTION parse_action;
94 static DWORD parse_flags;
95
96 typedef struct _uri_create_flag_test {
97     DWORD   flags;
98     HRESULT expected;
99 } uri_create_flag_test;
100
101 static const uri_create_flag_test invalid_flag_tests[] = {
102     /* Set of invalid flag combinations to test for. */
103     {Uri_CREATE_DECODE_EXTRA_INFO | Uri_CREATE_NO_DECODE_EXTRA_INFO, E_INVALIDARG},
104     {Uri_CREATE_CANONICALIZE | Uri_CREATE_NO_CANONICALIZE, E_INVALIDARG},
105     {Uri_CREATE_CRACK_UNKNOWN_SCHEMES | Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, E_INVALIDARG},
106     {Uri_CREATE_PRE_PROCESS_HTML_URI | Uri_CREATE_NO_PRE_PROCESS_HTML_URI, E_INVALIDARG},
107     {Uri_CREATE_IE_SETTINGS | Uri_CREATE_NO_IE_SETTINGS, E_INVALIDARG}
108 };
109
110 typedef struct _uri_str_property {
111     const char* value;
112     HRESULT     expected;
113     BOOL        todo;
114     const char* broken_value;
115 } uri_str_property;
116
117 typedef struct _uri_dword_property {
118     DWORD   value;
119     HRESULT expected;
120     BOOL    todo;
121 } uri_dword_property;
122
123 typedef struct _uri_properties {
124     const char*         uri;
125     DWORD               create_flags;
126     HRESULT             create_expected;
127     BOOL                create_todo;
128
129     uri_str_property    str_props[URI_STR_PROPERTY_COUNT];
130     uri_dword_property  dword_props[URI_DWORD_PROPERTY_COUNT];
131 } uri_properties;
132
133 static const uri_properties uri_tests[] = {
134     {   "http://www.winehq.org/tests/../tests/../..", 0, S_OK, FALSE,
135         {
136             {"http://www.winehq.org/",S_OK,FALSE},                      /* ABSOLUTE_URI */
137             {"www.winehq.org",S_OK,FALSE},                              /* AUTHORITY */
138             {"http://www.winehq.org/",S_OK,FALSE},                      /* DISPLAY_URI */
139             {"winehq.org",S_OK,FALSE},                                  /* DOMAIN */
140             {"",S_FALSE,FALSE},                                         /* EXTENSION */
141             {"",S_FALSE,FALSE},                                         /* FRAGMENT */
142             {"www.winehq.org",S_OK,FALSE},                              /* HOST */
143             {"",S_FALSE,FALSE},                                         /* PASSWORD */
144             {"/",S_OK,FALSE},                                           /* PATH */
145             {"/",S_OK,FALSE},                                           /* PATH_AND_QUERY */
146             {"",S_FALSE,FALSE},                                         /* QUERY */
147             {"http://www.winehq.org/tests/../tests/../..",S_OK,FALSE},  /* RAW_URI */
148             {"http",S_OK,FALSE},                                        /* SCHEME_NAME */
149             {"",S_FALSE,FALSE},                                         /* USER_INFO */
150             {"",S_FALSE,FALSE}                                          /* USER_NAME */
151         },
152         {
153             {Uri_HOST_DNS,S_OK,FALSE},                                  /* HOST_TYPE */
154             {80,S_OK,FALSE},                                            /* PORT */
155             {URL_SCHEME_HTTP,S_OK,FALSE},                               /* SCHEME */
156             {URLZONE_INVALID,E_NOTIMPL,FALSE}                           /* ZONE */
157         }
158     },
159     {   "http://winehq.org/tests/.././tests", 0, S_OK, FALSE,
160         {
161             {"http://winehq.org/tests",S_OK,FALSE},
162             {"winehq.org",S_OK,FALSE},
163             {"http://winehq.org/tests",S_OK,FALSE},
164             {"winehq.org",S_OK,FALSE},
165             {"",S_FALSE,FALSE},
166             {"",S_FALSE,FALSE},
167             {"winehq.org",S_OK,FALSE},
168             {"",S_FALSE,FALSE},
169             {"/tests",S_OK,FALSE},
170             {"/tests",S_OK,FALSE},
171             {"",S_FALSE,FALSE},
172             {"http://winehq.org/tests/.././tests",S_OK,FALSE},
173             {"http",S_OK,FALSE},
174             {"",S_FALSE,FALSE},
175             {"",S_FALSE,FALSE}
176         },
177         {
178             {Uri_HOST_DNS,S_OK,FALSE},
179             {80,S_OK,FALSE},
180             {URL_SCHEME_HTTP,S_OK,FALSE},
181             {URLZONE_INVALID,E_NOTIMPL,FALSE}
182         }
183     },
184     {   "HtTp://www.winehq.org/tests/..?query=x&return=y", 0, S_OK, FALSE,
185         {
186             {"http://www.winehq.org/?query=x&return=y",S_OK,FALSE},
187             {"www.winehq.org",S_OK,FALSE},
188             {"http://www.winehq.org/?query=x&return=y",S_OK,FALSE},
189             {"winehq.org",S_OK,FALSE},
190             {"",S_FALSE,FALSE},
191             {"",S_FALSE,FALSE},
192             {"www.winehq.org",S_OK,FALSE},
193             {"",S_FALSE,FALSE},
194             {"/",S_OK,FALSE},
195             {"/?query=x&return=y",S_OK,FALSE},
196             {"?query=x&return=y",S_OK,FALSE},
197             {"HtTp://www.winehq.org/tests/..?query=x&return=y",S_OK,FALSE},
198             {"http",S_OK,FALSE},
199             {"",S_FALSE,FALSE},
200             {"",S_FALSE,FALSE}
201         },
202         {
203             {Uri_HOST_DNS,S_OK,FALSE},
204             {80,S_OK,FALSE},
205             {URL_SCHEME_HTTP,S_OK,FALSE},
206             {URLZONE_INVALID,E_NOTIMPL,FALSE},
207         }
208     },
209     {   "hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters", 0, S_OK, FALSE,
210         {
211             {"http://usEr%3Ainfo@example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
212             {"usEr%3Ainfo@example.com",S_OK,FALSE},
213             {"http://example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
214             {"example.com",S_OK,FALSE},
215             {"",S_FALSE,FALSE},
216             {"",S_FALSE,FALSE},
217             {"example.com",S_OK,FALSE},
218             {"",S_FALSE,FALSE},
219             {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
220             {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
221             {"",S_FALSE,FALSE},
222             {"hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters",S_OK,FALSE},
223             {"http",S_OK,FALSE},
224             {"usEr%3Ainfo",S_OK,FALSE},
225             {"usEr%3Ainfo",S_OK,FALSE}
226         },
227         {
228             {Uri_HOST_DNS,S_OK,FALSE},
229             {80,S_OK,FALSE},
230             {URL_SCHEME_HTTP,S_OK,FALSE},
231             {URLZONE_INVALID,E_NOTIMPL,FALSE},
232         }
233     },
234     {   "ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt", 0, S_OK, FALSE,
235         {
236             {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK,FALSE},
237             {"winepass:wine@ftp.winehq.org:9999",S_OK,FALSE},
238             {"ftp://ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK,FALSE},
239             {"winehq.org",S_OK,FALSE},
240             {".txt",S_OK,FALSE},
241             {"",S_FALSE,FALSE},
242             {"ftp.winehq.org",S_OK,FALSE},
243             {"wine",S_OK,FALSE},
244             {"/dir/foo%20bar.txt",S_OK,FALSE},
245             {"/dir/foo%20bar.txt",S_OK,FALSE},
246             {"",S_FALSE,FALSE},
247             {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt",S_OK,FALSE},
248             {"ftp",S_OK,FALSE},
249             {"winepass:wine",S_OK,FALSE},
250             {"winepass",S_OK,FALSE}
251         },
252         {
253             {Uri_HOST_DNS,S_OK,FALSE},
254             {9999,S_OK,FALSE},
255             {URL_SCHEME_FTP,S_OK,FALSE},
256             {URLZONE_INVALID,E_NOTIMPL,FALSE}
257         }
258     },
259     {   "file://c:\\tests\\../tests/foo%20bar.mp3", 0, S_OK, FALSE,
260         {
261             {"file:///c:/tests/foo%2520bar.mp3",S_OK,FALSE},
262             {"",S_FALSE,FALSE},
263             {"file:///c:/tests/foo%2520bar.mp3",S_OK,FALSE},
264             {"",S_FALSE,FALSE},
265             {".mp3",S_OK,FALSE},
266             {"",S_FALSE,FALSE},
267             {"",S_FALSE,FALSE},
268             {"",S_FALSE,FALSE},
269             {"/c:/tests/foo%2520bar.mp3",S_OK,FALSE},
270             {"/c:/tests/foo%2520bar.mp3",S_OK,FALSE},
271             {"",S_FALSE,FALSE},
272             {"file://c:\\tests\\../tests/foo%20bar.mp3",S_OK,FALSE},
273             {"file",S_OK,FALSE},
274             {"",S_FALSE,FALSE},
275             {"",S_FALSE,FALSE}
276         },
277         {
278             {Uri_HOST_UNKNOWN,S_OK,FALSE},
279             {0,S_FALSE,FALSE},
280             {URL_SCHEME_FILE,S_OK,FALSE},
281             {URLZONE_INVALID,E_NOTIMPL,FALSE}
282         }
283     },
284     {   "file://c:\\tests\\../tests/foo%20bar.mp3", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
285         {
286             {"file:///c:/tests/../tests/foo%2520bar.mp3",S_OK,FALSE},
287             {"",S_FALSE,FALSE},
288             {"file:///c:/tests/../tests/foo%2520bar.mp3",S_OK,FALSE},
289             {"",S_FALSE,FALSE},
290             {".mp3",S_OK,FALSE},
291             {"",S_FALSE,FALSE},
292             {"",S_FALSE,FALSE},
293             {"",S_FALSE,FALSE},
294             {"/c:/tests/../tests/foo%2520bar.mp3",S_OK,FALSE},
295             {"/c:/tests/../tests/foo%2520bar.mp3",S_OK,FALSE},
296             {"",S_FALSE,FALSE},
297             {"file://c:\\tests\\../tests/foo%20bar.mp3",S_OK,FALSE},
298             {"file",S_OK,FALSE},
299             {"",S_FALSE,FALSE},
300             {"",S_FALSE,FALSE}
301         },
302         {
303             {Uri_HOST_UNKNOWN,S_OK,FALSE},
304             {0,S_FALSE,FALSE},
305             {URL_SCHEME_FILE,S_OK,FALSE},
306             {URLZONE_INVALID,E_NOTIMPL,FALSE}
307         }
308     },
309     {   "FILE://localhost/test dir\\../tests/test%20file.README.txt", 0, S_OK, FALSE,
310         {
311             {"file:///tests/test%20file.README.txt",S_OK,FALSE},
312             {"",S_FALSE,FALSE},
313             {"file:///tests/test%20file.README.txt",S_OK,FALSE},
314             {"",S_FALSE,FALSE},
315             {".txt",S_OK,FALSE},
316             {"",S_FALSE,FALSE},
317             {"",S_FALSE,FALSE},
318             {"",S_FALSE,FALSE},
319             {"/tests/test%20file.README.txt",S_OK,FALSE},
320             {"/tests/test%20file.README.txt",S_OK,FALSE},
321             {"",S_FALSE,FALSE},
322             {"FILE://localhost/test dir\\../tests/test%20file.README.txt",S_OK,FALSE},
323             {"file",S_OK,FALSE},
324             {"",S_FALSE,FALSE},
325             {"",S_FALSE,FALSE}
326         },
327         {
328             {Uri_HOST_UNKNOWN,S_OK,FALSE},
329             {0,S_FALSE,FALSE},
330             {URL_SCHEME_FILE,S_OK,FALSE},
331             {URLZONE_INVALID,E_NOTIMPL,FALSE}
332         }
333     },
334     {   "urn:nothing:should:happen here", 0, S_OK, FALSE,
335         {
336             {"urn:nothing:should:happen here",S_OK,FALSE},
337             {"",S_FALSE,FALSE},
338             {"urn:nothing:should:happen here",S_OK,FALSE},
339             {"",S_FALSE,FALSE},
340             {"",S_FALSE,FALSE},
341             {"",S_FALSE,FALSE},
342             {"",S_FALSE,FALSE},
343             {"",S_FALSE,FALSE},
344             {"nothing:should:happen here",S_OK,FALSE},
345             {"nothing:should:happen here",S_OK,FALSE},
346             {"",S_FALSE,FALSE},
347             {"urn:nothing:should:happen here",S_OK,FALSE},
348             {"urn",S_OK,FALSE},
349             {"",S_FALSE,FALSE},
350             {"",S_FALSE,FALSE}
351         },
352         {
353             {Uri_HOST_UNKNOWN,S_OK,FALSE},
354             {0,S_FALSE,FALSE},
355             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
356             {URLZONE_INVALID,E_NOTIMPL,FALSE}
357         }
358     },
359     {   "http://127.0.0.1/tests/../test dir/./test.txt", 0, S_OK, FALSE,
360         {
361             {"http://127.0.0.1/test%20dir/test.txt",S_OK,FALSE},
362             {"127.0.0.1",S_OK,FALSE},
363             {"http://127.0.0.1/test%20dir/test.txt",S_OK,FALSE},
364             {"",S_FALSE,FALSE},
365             {".txt",S_OK,FALSE},
366             {"",S_FALSE,FALSE},
367             {"127.0.0.1",S_OK,FALSE},
368             {"",S_FALSE,FALSE},
369             {"/test%20dir/test.txt",S_OK,FALSE},
370             {"/test%20dir/test.txt",S_OK,FALSE},
371             {"",S_FALSE,FALSE},
372             {"http://127.0.0.1/tests/../test dir/./test.txt",S_OK,FALSE},
373             {"http",S_OK,FALSE},
374             {"",S_FALSE,FALSE},
375             {"",S_FALSE,FALSE}
376         },
377         {
378             {Uri_HOST_IPV4,S_OK,FALSE},
379             {80,S_OK,FALSE},
380             {URL_SCHEME_HTTP,S_OK,FALSE},
381             {URLZONE_INVALID,E_NOTIMPL,FALSE}
382         }
383     },
384     {   "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", 0, S_OK, FALSE,
385         {
386             {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,FALSE},
387             {"[fedc:ba98:7654:3210:fedc:ba98:7654:3210]",S_OK,FALSE},
388             {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,FALSE},
389             {"",S_FALSE,FALSE},
390             {"",S_FALSE,FALSE},
391             {"",S_FALSE,FALSE},
392             {"fedc:ba98:7654:3210:fedc:ba98:7654:3210",S_OK,FALSE},
393             {"",S_FALSE,FALSE},
394             {"/",S_OK,FALSE},
395             {"/",S_OK,FALSE},
396             {"",S_FALSE,FALSE},
397             {"http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]",S_OK,FALSE},
398             {"http",S_OK,FALSE},
399             {"",S_FALSE,FALSE},
400             {"",S_FALSE,FALSE}
401         },
402         {
403             {Uri_HOST_IPV6,S_OK,FALSE},
404             {80,S_OK,FALSE},
405             {URL_SCHEME_HTTP,S_OK,FALSE},
406             {URLZONE_INVALID,E_NOTIMPL,FALSE}
407         }
408     },
409     {   "ftp://[::13.1.68.3]", 0, S_OK, FALSE,
410         {
411             {"ftp://[::13.1.68.3]/",S_OK,FALSE},
412             {"[::13.1.68.3]",S_OK,FALSE},
413             {"ftp://[::13.1.68.3]/",S_OK,FALSE},
414             {"",S_FALSE,FALSE},
415             {"",S_FALSE,FALSE},
416             {"",S_FALSE,FALSE},
417             {"::13.1.68.3",S_OK,FALSE},
418             {"",S_FALSE,FALSE},
419             {"/",S_OK,FALSE},
420             {"/",S_OK,FALSE},
421             {"",S_FALSE,FALSE},
422             {"ftp://[::13.1.68.3]",S_OK,FALSE},
423             {"ftp",S_OK,FALSE},
424             {"",S_FALSE,FALSE},
425             {"",S_FALSE,FALSE}
426         },
427         {
428             {Uri_HOST_IPV6,S_OK,FALSE},
429             {21,S_OK,FALSE},
430             {URL_SCHEME_FTP,S_OK,FALSE},
431             {URLZONE_INVALID,E_NOTIMPL,FALSE}
432         }
433     },
434     {   "http://[FEDC:BA98:0:0:0:0:0:3210]", 0, S_OK, FALSE,
435         {
436             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
437             {"[fedc:ba98::3210]",S_OK,FALSE},
438             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
439             {"",S_FALSE,FALSE},
440             {"",S_FALSE,FALSE},
441             {"",S_FALSE,FALSE},
442             {"fedc:ba98::3210",S_OK,FALSE},
443             {"",S_FALSE,FALSE},
444             {"/",S_OK,FALSE},
445             {"/",S_OK,FALSE},
446             {"",S_FALSE,FALSE},
447             {"http://[FEDC:BA98:0:0:0:0:0:3210]",S_OK,FALSE},
448             {"http",S_OK,FALSE},
449             {"",S_FALSE,FALSE},
450             {"",S_FALSE,FALSE},
451         },
452         {
453             {Uri_HOST_IPV6,S_OK,FALSE},
454             {80,S_OK,FALSE},
455             {URL_SCHEME_HTTP,S_OK,FALSE},
456             {URLZONE_INVALID,E_NOTIMPL,FALSE}
457         }
458     },
459     {   "1234://www.winehq.org", 0, S_OK, FALSE,
460         {
461             {"1234://www.winehq.org/",S_OK,FALSE},
462             {"www.winehq.org",S_OK,FALSE},
463             {"1234://www.winehq.org/",S_OK,FALSE},
464             {"winehq.org",S_OK,FALSE},
465             {"",S_FALSE,FALSE},
466             {"",S_FALSE,FALSE},
467             {"www.winehq.org",S_OK,FALSE},
468             {"",S_FALSE,FALSE},
469             {"/",S_OK,FALSE},
470             {"/",S_OK,FALSE},
471             {"",S_FALSE,FALSE},
472             {"1234://www.winehq.org",S_OK,FALSE},
473             {"1234",S_OK,FALSE},
474             {"",S_FALSE,FALSE},
475             {"",S_FALSE,FALSE}
476         },
477         {
478             {Uri_HOST_DNS,S_OK,FALSE},
479             {0,S_FALSE,FALSE},
480             {URL_SCHEME_UNKNOWN,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     {   "C:/test/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
486         {
487             {"file:///C:/test/test.mp3",S_OK,FALSE},
488             {"",S_FALSE,FALSE},
489             {"file:///C:/test/test.mp3",S_OK,FALSE},
490             {"",S_FALSE,FALSE},
491             {".mp3",S_OK,FALSE},
492             {"",S_FALSE,FALSE},
493             {"",S_FALSE,FALSE},
494             {"",S_FALSE,FALSE},
495             {"/C:/test/test.mp3",S_OK,FALSE},
496             {"/C:/test/test.mp3",S_OK,FALSE},
497             {"",S_FALSE,FALSE},
498             {"C:/test/test.mp3",S_OK,FALSE},
499             {"file",S_OK,FALSE},
500             {"",S_FALSE,FALSE},
501             {"",S_FALSE,FALSE}
502         },
503         {
504             {Uri_HOST_UNKNOWN,S_OK,FALSE},
505             {0,S_FALSE,FALSE},
506             {URL_SCHEME_FILE,S_OK,FALSE},
507             {URLZONE_INVALID,E_NOTIMPL,FALSE}
508         }
509     },
510     /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
511     {   "\\\\Server/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
512         {
513             {"file://server/test.mp3",S_OK,FALSE},
514             {"server",S_OK,FALSE},
515             {"file://server/test.mp3",S_OK,FALSE},
516             {"",S_FALSE,FALSE},
517             {".mp3",S_OK,FALSE},
518             {"",S_FALSE,FALSE},
519             {"server",S_OK,FALSE},
520             {"",S_FALSE,FALSE},
521             {"/test.mp3",S_OK,FALSE},
522             {"/test.mp3",S_OK,FALSE},
523             {"",S_FALSE,FALSE},
524             {"\\\\Server/test.mp3",S_OK,FALSE},
525             {"file",S_OK,FALSE},
526             {"",S_FALSE,FALSE},
527             {"",S_FALSE,FALSE}
528         },
529         {
530             {Uri_HOST_DNS,S_OK,FALSE},
531             {0,S_FALSE,FALSE},
532             {URL_SCHEME_FILE,S_OK,FALSE},
533             {URLZONE_INVALID,E_NOTIMPL,FALSE}
534         }
535     },
536     {   "www.winehq.org/test", Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, 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     /* Valid since the '*' is the only character in the scheme name. */
562     {   "*:www.winehq.org/test", 0, S_OK, FALSE,
563         {
564             {"*:www.winehq.org/test",S_OK,FALSE},
565             {"www.winehq.org",S_OK,FALSE},
566             {"*:www.winehq.org/test",S_OK,FALSE},
567             {"winehq.org",S_OK,FALSE},
568             {"",S_FALSE,FALSE},
569             {"",S_FALSE,FALSE},
570             {"www.winehq.org",S_OK,FALSE},
571             {"",S_FALSE,FALSE},
572             {"/test",S_OK,FALSE},
573             {"/test",S_OK,FALSE},
574             {"",S_FALSE,FALSE},
575             {"*:www.winehq.org/test",S_OK,FALSE},
576             {"*",S_OK,FALSE},
577             {"",S_FALSE,FALSE},
578             {"",S_FALSE,FALSE}
579         },
580         {
581             {Uri_HOST_DNS,S_OK,FALSE},
582             {0,S_FALSE,FALSE},
583             {URL_SCHEME_WILDCARD,S_OK,FALSE},
584             {URLZONE_INVALID,E_NOTIMPL,FALSE}
585         }
586     },
587     {   "/../some dir/test.ext", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
588         {
589             {"/../some dir/test.ext",S_OK,FALSE},
590             {"",S_FALSE,FALSE},
591             {"/../some dir/test.ext",S_OK,FALSE},
592             {"",S_FALSE,FALSE},
593             {".ext",S_OK,FALSE},
594             {"",S_FALSE,FALSE},
595             {"",S_FALSE,FALSE},
596             {"",S_FALSE,FALSE},
597             {"/../some dir/test.ext",S_OK,FALSE},
598             {"/../some dir/test.ext",S_OK,FALSE},
599             {"",S_FALSE,FALSE},
600             {"/../some dir/test.ext",S_OK,FALSE},
601             {"",S_FALSE,FALSE},
602             {"",S_FALSE,FALSE},
603             {"",S_FALSE,FALSE}
604         },
605         {
606             {Uri_HOST_UNKNOWN,S_OK,FALSE},
607             {0,S_FALSE,FALSE},
608             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
609             {URLZONE_INVALID,E_NOTIMPL,FALSE}
610         }
611     },
612     {   "//implicit/wildcard/uri scheme", Uri_CREATE_ALLOW_RELATIVE|Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
613         {
614             {"*://implicit/wildcard/uri%20scheme",S_OK,FALSE},
615             {"",S_OK,FALSE},
616             {"*://implicit/wildcard/uri%20scheme",S_OK,FALSE},
617             {"",S_FALSE,FALSE},
618             {"",S_FALSE,FALSE},
619             {"",S_FALSE,FALSE},
620             {"",S_OK,FALSE},
621             {"",S_FALSE,FALSE},
622             {"//implicit/wildcard/uri%20scheme",S_OK,FALSE},
623             {"//implicit/wildcard/uri%20scheme",S_OK,FALSE},
624             {"",S_FALSE,FALSE},
625             {"//implicit/wildcard/uri scheme",S_OK,FALSE},
626             {"*",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_WILDCARD,S_OK,FALSE},
634             {URLZONE_INVALID,E_NOTIMPL,FALSE}
635         }
636     },
637     /* URI is considered opaque since CREATE_NO_CRACK_UNKNOWN_SCHEMES is set and its an unknown scheme. */
638     {   "zip://google.com", Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, S_OK, FALSE,
639         {
640             {"zip:/.//google.com",S_OK,FALSE},
641             {"",S_FALSE,FALSE},
642             {"zip:/.//google.com",S_OK,FALSE},
643             {"",S_FALSE,FALSE},
644             {".com",S_OK,FALSE},
645             {"",S_FALSE,FALSE},
646             {"",S_FALSE,FALSE},
647             {"",S_FALSE,FALSE},
648             {"/.//google.com",S_OK,FALSE},
649             {"/.//google.com",S_OK,FALSE},
650             {"",S_FALSE,FALSE},
651             {"zip://google.com",S_OK,FALSE},
652             {"zip",S_OK,FALSE},
653             {"",S_FALSE,FALSE},
654             {"",S_FALSE,FALSE}
655         },
656         {
657             {Uri_HOST_UNKNOWN,S_OK,FALSE},
658             {0,S_FALSE,FALSE},
659             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
660             {URLZONE_INVALID,E_NOTIMPL,FALSE}
661         }
662     },
663     /* Windows uses the first occurrence of ':' to delimit the userinfo. */
664     {   "ftp://user:pass:word@winehq.org/", 0, S_OK, FALSE,
665         {
666             {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
667             {"user:pass:word@winehq.org",S_OK,FALSE},
668             {"ftp://winehq.org/",S_OK,FALSE},
669             {"winehq.org",S_OK,FALSE},
670             {"",S_FALSE,FALSE},
671             {"",S_FALSE,FALSE},
672             {"winehq.org",S_OK,FALSE},
673             {"pass:word",S_OK,FALSE},
674             {"/",S_OK,FALSE},
675             {"/",S_OK,FALSE},
676             {"",S_FALSE,FALSE},
677             {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
678             {"ftp",S_OK,FALSE},
679             {"user:pass:word",S_OK,FALSE},
680             {"user",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 unreserved characters are decoded. */
690     {   "ftp://w%49%4Ee:PA%53%53@ftp.google.com/", 0, S_OK, FALSE,
691         {
692             {"ftp://wINe:PASS@ftp.google.com/",S_OK,FALSE},
693             {"wINe:PASS@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             {"PASS",S_OK,FALSE},
700             {"/",S_OK,FALSE},
701             {"/",S_OK,FALSE},
702             {"",S_FALSE,FALSE},
703             {"ftp://w%49%4Ee:PA%53%53@ftp.google.com/",S_OK,FALSE},
704             {"ftp",S_OK,FALSE},
705             {"wINe:PASS",S_OK,FALSE},
706             {"wINe",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     /* Make sure % encoded characters which are NOT unreserved are NOT decoded. */
716     {   "ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/", 0, S_OK, FALSE,
717         {
718             {"ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/",S_OK,FALSE},
719             {"w%5D%5Be:PA%7B%7D@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             {"PA%7B%7D",S_OK,FALSE},
726             {"/",S_OK,FALSE},
727             {"/",S_OK,FALSE},
728             {"",S_FALSE,FALSE},
729             {"ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/",S_OK,FALSE},
730             {"ftp",S_OK,FALSE},
731             {"w%5D%5Be:PA%7B%7D",S_OK,FALSE},
732             {"w%5D%5Be",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     /* You're allowed to have an empty password portion in the userinfo section. */
742     {   "ftp://empty:@ftp.google.com/", 0, S_OK, FALSE,
743         {
744             {"ftp://empty:@ftp.google.com/",S_OK,FALSE},
745             {"empty:@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_OK,FALSE},
752             {"/",S_OK,FALSE},
753             {"/",S_OK,FALSE},
754             {"",S_FALSE,FALSE},
755             {"ftp://empty:@ftp.google.com/",S_OK,FALSE},
756             {"ftp",S_OK,FALSE},
757             {"empty:",S_OK,FALSE},
758             {"empty",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 forbidden characters in "userinfo" get encoded. */
768     {   "ftp://\" \"weird@ftp.google.com/", 0, S_OK, FALSE,
769         {
770             {"ftp://%22%20%22weird@ftp.google.com/",S_OK,FALSE},
771             {"%22%20%22weird@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             {"%22%20%22weird",S_OK,FALSE},
784             {"%22%20%22weird",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 the forbidden characters don't get percent encoded. */
794     {   "ftp://\" \"weird@ftp.google.com/", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
795         {
796             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
797             {"\" \"weird@ftp.google.com",S_OK,FALSE},
798             {"ftp://ftp.google.com/",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             {"/",S_OK,FALSE},
805             {"/",S_OK,FALSE},
806             {"",S_FALSE,FALSE},
807             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
808             {"ftp",S_OK,FALSE},
809             {"\" \"weird",S_OK,FALSE},
810             {"\" \"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     /* Make sure already percent encoded characters don't get unencoded. */
820     {   "ftp://\"%20\"weird@ftp.google.com/\"%20\"weird", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
821         {
822             {"ftp://\"%20\"weird@ftp.google.com/\"%20\"weird",S_OK,FALSE},
823             {"\"%20\"weird@ftp.google.com",S_OK,FALSE},
824             {"ftp://ftp.google.com/\"%20\"weird",S_OK,FALSE},
825             {"google.com",S_OK,FALSE},
826             {"",S_FALSE,FALSE},
827             {"",S_FALSE,FALSE},
828             {"ftp.google.com",S_OK,FALSE},
829             {"",S_FALSE,FALSE},
830             {"/\"%20\"weird",S_OK,FALSE},
831             {"/\"%20\"weird",S_OK,FALSE},
832             {"",S_FALSE,FALSE},
833             {"ftp://\"%20\"weird@ftp.google.com/\"%20\"weird",S_OK,FALSE},
834             {"ftp",S_OK,FALSE},
835             {"\"%20\"weird",S_OK,FALSE},
836             {"\"%20\"weird",S_OK,FALSE}
837         },
838         {
839             {Uri_HOST_DNS,S_OK,FALSE},
840             {21,S_OK,FALSE},
841             {URL_SCHEME_FTP,S_OK,FALSE},
842             {URLZONE_INVALID,E_NOTIMPL,FALSE}
843         }
844     },
845     /* Allowed to have invalid % encoded because its an unknown scheme type. */
846     {   "zip://%xy:word@winehq.org/", 0, S_OK, FALSE,
847         {
848             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
849             {"%xy:word@winehq.org",S_OK,FALSE},
850             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
851             {"winehq.org",S_OK,FALSE},
852             {"",S_FALSE,FALSE},
853             {"",S_FALSE,FALSE},
854             {"winehq.org",S_OK,FALSE},
855             {"word",S_OK,FALSE},
856             {"/",S_OK,FALSE},
857             {"/",S_OK,FALSE},
858             {"",S_FALSE,FALSE},
859             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
860             {"zip",S_OK,FALSE},
861             {"%xy:word",S_OK,FALSE},
862             {"%xy",S_OK,FALSE}
863         },
864         {
865             {Uri_HOST_DNS,S_OK,FALSE},
866             {0,S_FALSE,FALSE},
867             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
868             {URLZONE_INVALID,E_NOTIMPL,FALSE}
869         }
870     },
871     /* Unreserved, percent encoded characters aren't decoded in the userinfo because the scheme
872      * isn't known.
873      */
874     {   "zip://%2E:%52%53ord@winehq.org/", 0, S_OK, FALSE,
875         {
876             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
877             {"%2E:%52%53ord@winehq.org",S_OK,FALSE},
878             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
879             {"winehq.org",S_OK,FALSE},
880             {"",S_FALSE,FALSE},
881             {"",S_FALSE,FALSE},
882             {"winehq.org",S_OK,FALSE},
883             {"%52%53ord",S_OK,FALSE},
884             {"/",S_OK,FALSE},
885             {"/",S_OK,FALSE},
886             {"",S_FALSE,FALSE},
887             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
888             {"zip",S_OK,FALSE},
889             {"%2E:%52%53ord",S_OK,FALSE},
890             {"%2E",S_OK,FALSE}
891         },
892         {
893             {Uri_HOST_DNS,S_OK,FALSE},
894             {0,S_FALSE,FALSE},
895             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
896             {URLZONE_INVALID,E_NOTIMPL,FALSE}
897         }
898     },
899     {   "ftp://[](),'test':word@winehq.org/", 0, S_OK, FALSE,
900         {
901             {"ftp://[](),'test':word@winehq.org/",S_OK,FALSE},
902             {"[](),'test':word@winehq.org",S_OK,FALSE},
903             {"ftp://winehq.org/",S_OK,FALSE},
904             {"winehq.org",S_OK,FALSE},
905             {"",S_FALSE,FALSE},
906             {"",S_FALSE,FALSE},
907             {"winehq.org",S_OK,FALSE},
908             {"word",S_OK,FALSE},
909             {"/",S_OK,FALSE},
910             {"/",S_OK,FALSE},
911             {"",S_FALSE,FALSE},
912             {"ftp://[](),'test':word@winehq.org/",S_OK,FALSE},
913             {"ftp",S_OK,FALSE},
914             {"[](),'test':word",S_OK,FALSE},
915             {"[](),'test'",S_OK,FALSE}
916         },
917         {
918             {Uri_HOST_DNS,S_OK,FALSE},
919             {21,S_OK,FALSE},
920             {URL_SCHEME_FTP,S_OK,FALSE},
921             {URLZONE_INVALID,E_NOTIMPL,FALSE}
922         }
923     },
924     {   "ftp://test?:word@winehq.org/", 0, S_OK, FALSE,
925         {
926             {"ftp://test/?:word@winehq.org/",S_OK,FALSE},
927             {"test",S_OK,FALSE},
928             {"ftp://test/?:word@winehq.org/",S_OK,FALSE},
929             {"",S_FALSE,FALSE},
930             {"",S_FALSE,FALSE},
931             {"",S_FALSE,FALSE},
932             {"test",S_OK,FALSE},
933             {"",S_FALSE,FALSE},
934             {"/",S_OK,FALSE},
935             {"/?:word@winehq.org/",S_OK,FALSE},
936             {"?:word@winehq.org/",S_OK,FALSE},
937             {"ftp://test?:word@winehq.org/",S_OK,FALSE},
938             {"ftp",S_OK,FALSE},
939             {"",S_FALSE,FALSE},
940             {"",S_FALSE,FALSE}
941         },
942         {
943             {Uri_HOST_DNS,S_OK,FALSE},
944             {21,S_OK,FALSE},
945             {URL_SCHEME_FTP,S_OK,FALSE},
946             {URLZONE_INVALID,E_NOTIMPL,FALSE}
947         }
948     },
949     {   "ftp://test#:word@winehq.org/", 0, S_OK, FALSE,
950         {
951             {"ftp://test/#:word@winehq.org/",S_OK,FALSE},
952             {"test",S_OK,FALSE},
953             {"ftp://test/#:word@winehq.org/",S_OK,FALSE},
954             {"",S_FALSE,FALSE},
955             {"",S_FALSE,FALSE},
956             {"#:word@winehq.org/",S_OK,FALSE},
957             {"test",S_OK,FALSE},
958             {"",S_FALSE,FALSE},
959             {"/",S_OK,FALSE},
960             {"/",S_OK,FALSE},
961             {"",S_FALSE,FALSE},
962             {"ftp://test#:word@winehq.org/",S_OK,FALSE},
963             {"ftp",S_OK,FALSE},
964             {"",S_FALSE,FALSE},
965             {"",S_FALSE,FALSE}
966         },
967         {
968             {Uri_HOST_DNS,S_OK,FALSE},
969             {21,S_OK,FALSE},
970             {URL_SCHEME_FTP,S_OK,FALSE},
971             {URLZONE_INVALID,E_NOTIMPL,FALSE}
972         }
973     },
974     /* Allowed to have a backslash in the userinfo since it's an unknown scheme. */
975     {   "zip://test\\:word@winehq.org/", 0, S_OK, FALSE,
976         {
977             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
978             {"test\\:word@winehq.org",S_OK,FALSE},
979             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
980             {"winehq.org",S_OK,FALSE},
981             {"",S_FALSE,FALSE},
982             {"",S_FALSE,FALSE},
983             {"winehq.org",S_OK,FALSE},
984             {"word",S_OK,FALSE},
985             {"/",S_OK,FALSE},
986             {"/",S_OK,FALSE},
987             {"",S_FALSE,FALSE},
988             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
989             {"zip",S_OK,FALSE},
990             {"test\\:word",S_OK,FALSE},
991             {"test\\",S_OK,FALSE}
992         },
993         {
994             {Uri_HOST_DNS,S_OK,FALSE},
995             {0,S_FALSE,FALSE},
996             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
997             {URLZONE_INVALID,E_NOTIMPL,FALSE}
998         }
999     },
1000     /* It normalizes IPv4 addresses correctly. */
1001     {   "http://127.000.000.100/", 0, S_OK, FALSE,
1002         {
1003             {"http://127.0.0.100/",S_OK,FALSE},
1004             {"127.0.0.100",S_OK,FALSE},
1005             {"http://127.0.0.100/",S_OK,FALSE},
1006             {"",S_FALSE,FALSE},
1007             {"",S_FALSE,FALSE},
1008             {"",S_FALSE,FALSE},
1009             {"127.0.0.100",S_OK,FALSE},
1010             {"",S_FALSE,FALSE},
1011             {"/",S_OK,FALSE},
1012             {"/",S_OK,FALSE},
1013             {"",S_FALSE,FALSE},
1014             {"http://127.000.000.100/",S_OK,FALSE},
1015             {"http",S_OK,FALSE},
1016             {"",S_FALSE,FALSE},
1017             {"",S_FALSE,FALSE}
1018         },
1019         {
1020             {Uri_HOST_IPV4,S_OK,FALSE},
1021             {80,S_OK,FALSE},
1022             {URL_SCHEME_HTTP,S_OK,FALSE},
1023             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1024         }
1025     },
1026     {   "http://127.0.0.1:8000", 0, S_OK, FALSE,
1027         {
1028             {"http://127.0.0.1:8000/",S_OK},
1029             {"127.0.0.1:8000",S_OK},
1030             {"http://127.0.0.1:8000/",S_OK},
1031             {"",S_FALSE},
1032             {"",S_FALSE},
1033             {"",S_FALSE},
1034             {"127.0.0.1",S_OK},
1035             {"",S_FALSE},
1036             {"/",S_OK},
1037             {"/",S_OK},
1038             {"",S_FALSE},
1039             {"http://127.0.0.1:8000",S_OK},
1040             {"http",S_OK},
1041             {"",S_FALSE},
1042             {"",S_FALSE}
1043         },
1044         {
1045             {Uri_HOST_IPV4,S_OK,FALSE},
1046             {8000,S_OK,FALSE},
1047             {URL_SCHEME_HTTP,S_OK,FALSE},
1048             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1049         }
1050     },
1051     /* Make sure it normalizes partial IPv4 addresses correctly. */
1052     {   "http://127.0/", 0, S_OK, FALSE,
1053         {
1054             {"http://127.0.0.0/",S_OK,FALSE},
1055             {"127.0.0.0",S_OK,FALSE},
1056             {"http://127.0.0.0/",S_OK,FALSE},
1057             {"",S_FALSE,FALSE},
1058             {"",S_FALSE,FALSE},
1059             {"",S_FALSE,FALSE},
1060             {"127.0.0.0",S_OK,FALSE},
1061             {"",S_FALSE,FALSE},
1062             {"/",S_OK,FALSE},
1063             {"/",S_OK,FALSE},
1064             {"",S_FALSE,FALSE},
1065             {"http://127.0/",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     /* Make sure it converts implicit IPv4's correctly. */
1078     {   "http://123456/", 0, S_OK, FALSE,
1079         {
1080             {"http://0.1.226.64/",S_OK,FALSE},
1081             {"0.1.226.64",S_OK,FALSE},
1082             {"http://0.1.226.64/",S_OK,FALSE},
1083             {"",S_FALSE,FALSE},
1084             {"",S_FALSE,FALSE},
1085             {"",S_FALSE,FALSE},
1086             {"0.1.226.64",S_OK,FALSE},
1087             {"",S_FALSE,FALSE},
1088             {"/",S_OK,FALSE},
1089             {"/",S_OK,FALSE},
1090             {"",S_FALSE,FALSE},
1091             {"http://123456/",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 */
1104     {   "http://4294967295/", 0, S_OK, FALSE,
1105         {
1106             {"http://255.255.255.255/",S_OK,FALSE},
1107             {"255.255.255.255",S_OK,FALSE},
1108             {"http://255.255.255.255/",S_OK,FALSE},
1109             {"",S_FALSE,FALSE},
1110             {"",S_FALSE,FALSE},
1111             {"",S_FALSE,FALSE},
1112             {"255.255.255.255",S_OK,FALSE},
1113             {"",S_FALSE,FALSE},
1114             {"/",S_OK,FALSE},
1115             {"/",S_OK,FALSE},
1116             {"",S_FALSE,FALSE},
1117             {"http://4294967295/",S_OK,FALSE},
1118             {"http",S_OK,FALSE},
1119             {"",S_FALSE,FALSE},
1120             {"",S_FALSE,FALSE}
1121         },
1122         {
1123             {Uri_HOST_IPV4,S_OK,FALSE},
1124             {80,S_OK,FALSE},
1125             {URL_SCHEME_HTTP,S_OK,FALSE},
1126             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1127         }
1128     },
1129     /* UINT_MAX+1 */
1130     {   "http://4294967296/", 0, S_OK, FALSE,
1131         {
1132             {"http://4294967296/",S_OK,FALSE},
1133             {"4294967296",S_OK,FALSE},
1134             {"http://4294967296/",S_OK,FALSE},
1135             {"",S_FALSE,FALSE},
1136             {"",S_FALSE,FALSE},
1137             {"",S_FALSE,FALSE},
1138             {"4294967296",S_OK,FALSE},
1139             {"",S_FALSE,FALSE},
1140             {"/",S_OK,FALSE},
1141             {"/",S_OK,FALSE},
1142             {"",S_FALSE,FALSE},
1143             {"http://4294967296/",S_OK,FALSE},
1144             {"http",S_OK,FALSE},
1145             {"",S_FALSE,FALSE},
1146             {"",S_FALSE,FALSE}
1147         },
1148         {
1149             {Uri_HOST_DNS,S_OK,FALSE},
1150             {80,S_OK,FALSE},
1151             {URL_SCHEME_HTTP,S_OK,FALSE},
1152             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1153         }
1154     },
1155     /* Window's doesn't normalize IP address for unknown schemes. */
1156     {   "1234://4294967295/", 0, S_OK, FALSE,
1157         {
1158             {"1234://4294967295/",S_OK,FALSE},
1159             {"4294967295",S_OK,FALSE},
1160             {"1234://4294967295/",S_OK,FALSE},
1161             {"",S_FALSE,FALSE},
1162             {"",S_FALSE,FALSE},
1163             {"",S_FALSE,FALSE},
1164             {"4294967295",S_OK,FALSE},
1165             {"",S_FALSE,FALSE},
1166             {"/",S_OK,FALSE},
1167             {"/",S_OK,FALSE},
1168             {"",S_FALSE,FALSE},
1169             {"1234://4294967295/",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     /* Window's doesn't normalize IP address for unknown schemes. */
1182     {   "1234://127.001/", 0, S_OK, FALSE,
1183         {
1184             {"1234://127.001/",S_OK,FALSE},
1185             {"127.001",S_OK,FALSE},
1186             {"1234://127.001/",S_OK,FALSE},
1187             {"",S_FALSE,FALSE},
1188             {"",S_FALSE,FALSE},
1189             {"",S_FALSE,FALSE},
1190             {"127.001",S_OK,FALSE},
1191             {"",S_FALSE,FALSE},
1192             {"/",S_OK,FALSE},
1193             {"/",S_OK,FALSE},
1194             {"",S_FALSE,FALSE},
1195             {"1234://127.001/",S_OK,FALSE},
1196             {"1234",S_OK,FALSE},
1197             {"",S_FALSE,FALSE},
1198             {"",S_FALSE,FALSE}
1199         },
1200         {
1201             {Uri_HOST_IPV4,S_OK,FALSE},
1202             {0,S_FALSE,FALSE},
1203             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1204             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1205         }
1206     },
1207     {   "http://[FEDC:BA98::3210]", 0, S_OK, FALSE,
1208         {
1209             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
1210             {"[fedc:ba98::3210]",S_OK,FALSE},
1211             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
1212             {"",S_FALSE,FALSE},
1213             {"",S_FALSE,FALSE},
1214             {"",S_FALSE,FALSE},
1215             {"fedc:ba98::3210",S_OK,FALSE},
1216             {"",S_FALSE,FALSE},
1217             {"/",S_OK,FALSE},
1218             {"/",S_OK,FALSE},
1219             {"",S_FALSE,FALSE},
1220             {"http://[FEDC:BA98::3210]",S_OK,FALSE},
1221             {"http",S_OK,FALSE},
1222             {"",S_FALSE,FALSE},
1223             {"",S_FALSE,FALSE},
1224         },
1225         {
1226             {Uri_HOST_IPV6,S_OK,FALSE},
1227             {80,S_OK,FALSE},
1228             {URL_SCHEME_HTTP,S_OK,FALSE},
1229             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1230         }
1231     },
1232     {   "http://[::]", 0, S_OK, FALSE,
1233         {
1234             {"http://[::]/",S_OK,FALSE},
1235             {"[::]",S_OK,FALSE},
1236             {"http://[::]/",S_OK,FALSE},
1237             {"",S_FALSE,FALSE},
1238             {"",S_FALSE,FALSE},
1239             {"",S_FALSE,FALSE},
1240             {"::",S_OK,FALSE},
1241             {"",S_FALSE,FALSE},
1242             {"/",S_OK,FALSE},
1243             {"/",S_OK,FALSE},
1244             {"",S_FALSE,FALSE},
1245             {"http://[::]",S_OK,FALSE},
1246             {"http",S_OK,FALSE},
1247             {"",S_FALSE,FALSE},
1248             {"",S_FALSE,FALSE},
1249         },
1250         {
1251             {Uri_HOST_IPV6,S_OK,FALSE},
1252             {80,S_OK,FALSE},
1253             {URL_SCHEME_HTTP,S_OK,FALSE},
1254             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1255         }
1256     },
1257     {   "http://[FEDC:BA98::]", 0, S_OK, FALSE,
1258         {
1259             {"http://[fedc:ba98::]/",S_OK,FALSE},
1260             {"[fedc:ba98::]",S_OK,FALSE},
1261             {"http://[fedc:ba98::]/",S_OK,FALSE},
1262             {"",S_FALSE,FALSE},
1263             {"",S_FALSE,FALSE},
1264             {"",S_FALSE,FALSE},
1265             {"fedc:ba98::",S_OK,FALSE},
1266             {"",S_FALSE,FALSE},
1267             {"/",S_OK,FALSE},
1268             {"/",S_OK,FALSE},
1269             {"",S_FALSE,FALSE},
1270             {"http://[FEDC:BA98::]",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     /* Valid even with 2 byte elision because it doesn't appear the beginning or end. */
1283     {   "http://[1::3:4:5:6:7:8]", 0, S_OK, FALSE,
1284         {
1285             {"http://[1:0:3:4:5:6:7:8]/",S_OK,FALSE},
1286             {"[1:0:3:4:5:6:7:8]",S_OK,FALSE},
1287             {"http://[1:0:3:4:5:6:7:8]/",S_OK,FALSE},
1288             {"",S_FALSE,FALSE},
1289             {"",S_FALSE,FALSE},
1290             {"",S_FALSE,FALSE},
1291             {"1:0:3:4:5:6:7:8",S_OK,FALSE},
1292             {"",S_FALSE,FALSE},
1293             {"/",S_OK,FALSE},
1294             {"/",S_OK,FALSE},
1295             {"",S_FALSE,FALSE},
1296             {"http://[1::3:4:5:6:7:8]",S_OK,FALSE},
1297             {"http",S_OK,FALSE},
1298             {"",S_FALSE,FALSE},
1299             {"",S_FALSE,FALSE},
1300         },
1301         {
1302             {Uri_HOST_IPV6,S_OK,FALSE},
1303             {80,S_OK,FALSE},
1304             {URL_SCHEME_HTTP,S_OK,FALSE},
1305             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1306         }
1307     },
1308     {   "http://[v2.34]/", 0, S_OK, FALSE,
1309         {
1310             {"http://[v2.34]/",S_OK,FALSE},
1311             {"[v2.34]",S_OK,FALSE},
1312             {"http://[v2.34]/",S_OK,FALSE},
1313             {"",S_FALSE,FALSE},
1314             {"",S_FALSE,FALSE},
1315             {"",S_FALSE,FALSE},
1316             {"[v2.34]",S_OK,FALSE},
1317             {"",S_FALSE,FALSE},
1318             {"/",S_OK,FALSE},
1319             {"/",S_OK,FALSE},
1320             {"",S_FALSE,FALSE},
1321             {"http://[v2.34]/",S_OK,FALSE},
1322             {"http",S_OK,FALSE},
1323             {"",S_FALSE,FALSE},
1324             {"",S_FALSE,FALSE}
1325         },
1326         {
1327             {Uri_HOST_UNKNOWN,S_OK,FALSE},
1328             {80,S_OK,FALSE},
1329             {URL_SCHEME_HTTP,S_OK,FALSE},
1330             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1331         }
1332     },
1333     /* Windows ignores ':' if they appear after a '[' on a non-IPLiteral host. */
1334     {   "http://[xyz:12345.com/test", 0, S_OK, FALSE,
1335         {
1336             {"http://[xyz:12345.com/test",S_OK,FALSE},
1337             {"[xyz:12345.com",S_OK,FALSE},
1338             {"http://[xyz:12345.com/test",S_OK,FALSE},
1339             {"[xyz:12345.com",S_OK,FALSE},
1340             {"",S_FALSE,FALSE},
1341             {"",S_FALSE,FALSE},
1342             {"[xyz:12345.com",S_OK,FALSE},
1343             {"",S_FALSE,FALSE},
1344             {"/test",S_OK,FALSE},
1345             {"/test",S_OK,FALSE},
1346             {"",S_FALSE,FALSE},
1347             {"http://[xyz:12345.com/test",S_OK,FALSE},
1348             {"http",S_OK,FALSE},
1349             {"",S_FALSE,FALSE},
1350             {"",S_FALSE,FALSE}
1351         },
1352         {
1353             {Uri_HOST_DNS,S_OK,FALSE},
1354             {80,S_OK,FALSE},
1355             {URL_SCHEME_HTTP,S_OK,FALSE},
1356             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1357         }
1358     },
1359     /* Valid URI since the '[' and ']' don't appear at the beginning and end
1360      * of the host name (respectively).
1361      */
1362     {   "ftp://www.[works].com/", 0, S_OK, FALSE,
1363         {
1364             {"ftp://www.[works].com/",S_OK,FALSE},
1365             {"www.[works].com",S_OK,FALSE},
1366             {"ftp://www.[works].com/",S_OK,FALSE},
1367             {"[works].com",S_OK,FALSE},
1368             {"",S_FALSE,FALSE},
1369             {"",S_FALSE,FALSE},
1370             {"www.[works].com",S_OK,FALSE},
1371             {"",S_FALSE,FALSE},
1372             {"/",S_OK,FALSE},
1373             {"/",S_OK,FALSE},
1374             {"",S_FALSE,FALSE},
1375             {"ftp://www.[works].com/",S_OK,FALSE},
1376             {"ftp",S_OK,FALSE},
1377             {"",S_FALSE,FALSE},
1378             {"",S_FALSE,FALSE}
1379         },
1380         {
1381             {Uri_HOST_DNS,S_OK,FALSE},
1382             {21,S_OK,FALSE},
1383             {URL_SCHEME_FTP,S_OK,FALSE},
1384             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1385         }
1386     },
1387     /* Considers ':' a delimiter since it appears after the ']'. */
1388     {   "http://www.google.com]:12345/", 0, S_OK, FALSE,
1389         {
1390             {"http://www.google.com]:12345/",S_OK,FALSE},
1391             {"www.google.com]:12345",S_OK,FALSE},
1392             {"http://www.google.com]:12345/",S_OK,FALSE},
1393             {"google.com]",S_OK,FALSE},
1394             {"",S_FALSE,FALSE},
1395             {"",S_FALSE,FALSE},
1396             {"www.google.com]",S_OK,FALSE},
1397             {"",S_FALSE,FALSE},
1398             {"/",S_OK,FALSE},
1399             {"/",S_OK,FALSE},
1400             {"",S_FALSE,FALSE},
1401             {"http://www.google.com]:12345/",S_OK,FALSE},
1402             {"http",S_OK,FALSE},
1403             {"",S_FALSE,FALSE},
1404             {"",S_FALSE,FALSE}
1405         },
1406         {
1407             {Uri_HOST_DNS,S_OK,FALSE},
1408             {12345,S_OK,FALSE},
1409             {URL_SCHEME_HTTP,S_OK,FALSE},
1410             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1411         }
1412     },
1413     /* Unknown scheme types can have invalid % encoded data in the hostname. */
1414     {   "zip://w%XXw%GEw.google.com/", 0, S_OK, FALSE,
1415         {
1416             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1417             {"w%XXw%GEw.google.com",S_OK,FALSE},
1418             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1419             {"google.com",S_OK,FALSE},
1420             {"",S_FALSE,FALSE},
1421             {"",S_FALSE,FALSE},
1422             {"w%XXw%GEw.google.com",S_OK,FALSE},
1423             {"",S_FALSE,FALSE},
1424             {"/",S_OK,FALSE},
1425             {"/",S_OK,FALSE},
1426             {"",S_FALSE,FALSE},
1427             {"zip://w%XXw%GEw.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     /* Unknown scheme types hostname doesn't get lower cased. */
1440     {   "zip://GOOGLE.com/", 0, S_OK, FALSE,
1441         {
1442             {"zip://GOOGLE.com/",S_OK,FALSE},
1443             {"GOOGLE.com",S_OK,FALSE},
1444             {"zip://GOOGLE.com/",S_OK,FALSE},
1445             {"GOOGLE.com",S_OK,FALSE},
1446             {"",S_FALSE,FALSE},
1447             {"",S_FALSE,FALSE},
1448             {"GOOGLE.com",S_OK,FALSE},
1449             {"",S_FALSE,FALSE},
1450             {"/",S_OK,FALSE},
1451             {"/",S_OK,FALSE},
1452             {"",S_FALSE,FALSE},
1453             {"zip://GOOGLE.com/",S_OK,FALSE},
1454             {"zip",S_OK,FALSE},
1455             {"",S_FALSE,FALSE},
1456             {"",S_FALSE,FALSE}
1457         },
1458         {
1459             {Uri_HOST_DNS,S_OK,FALSE},
1460             {0,S_FALSE,FALSE},
1461             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1462             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1463         }
1464     },
1465     /* Hostname gets lower-cased for known scheme types. */
1466     {   "http://WWW.GOOGLE.com/", 0, S_OK, FALSE,
1467         {
1468             {"http://www.google.com/",S_OK,FALSE},
1469             {"www.google.com",S_OK,FALSE},
1470             {"http://www.google.com/",S_OK,FALSE},
1471             {"google.com",S_OK,FALSE},
1472             {"",S_FALSE,FALSE},
1473             {"",S_FALSE,FALSE},
1474             {"www.google.com",S_OK,FALSE},
1475             {"",S_FALSE,FALSE},
1476             {"/",S_OK,FALSE},
1477             {"/",S_OK,FALSE},
1478             {"",S_FALSE,FALSE},
1479             {"http://WWW.GOOGLE.com/",S_OK,FALSE},
1480             {"http",S_OK,FALSE},
1481             {"",S_FALSE,FALSE},
1482             {"",S_FALSE,FALSE}
1483         },
1484         {
1485             {Uri_HOST_DNS,S_OK,FALSE},
1486             {80,S_OK,FALSE},
1487             {URL_SCHEME_HTTP,S_OK,FALSE},
1488             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1489         }
1490     },
1491     /* Characters that get % encoded in the hostname also have their percent
1492      * encoded forms lower cased.
1493      */
1494     {   "http://www.%7Cgoogle|.com/", 0, S_OK, FALSE,
1495         {
1496             {"http://www.%7cgoogle%7c.com/",S_OK,FALSE},
1497             {"www.%7cgoogle%7c.com",S_OK,FALSE},
1498             {"http://www.%7cgoogle%7c.com/",S_OK,FALSE},
1499             {"%7cgoogle%7c.com",S_OK,FALSE},
1500             {"",S_FALSE,FALSE},
1501             {"",S_FALSE,FALSE},
1502             {"www.%7cgoogle%7c.com",S_OK,FALSE},
1503             {"",S_FALSE,FALSE},
1504             {"/",S_OK,FALSE},
1505             {"/",S_OK,FALSE},
1506             {"",S_FALSE,FALSE},
1507             {"http://www.%7Cgoogle|.com/",S_OK,FALSE},
1508             {"http",S_OK,FALSE},
1509             {"",S_FALSE,FALSE},
1510             {"",S_FALSE,FALSE}
1511         },
1512         {
1513             {Uri_HOST_DNS,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 attached to IPv6 can be included in elisions. */
1520     {   "http://[1:2:3:4:5:6:0.0.0.0]", 0, S_OK, FALSE,
1521         {
1522             {"http://[1:2:3:4:5:6::]/",S_OK,FALSE},
1523             {"[1:2:3:4:5:6::]",S_OK,FALSE},
1524             {"http://[1:2:3:4:5:6::]/",S_OK,FALSE},
1525             {"",S_FALSE,FALSE},
1526             {"",S_FALSE,FALSE},
1527             {"",S_FALSE,FALSE},
1528             {"1:2:3:4:5:6::",S_OK,FALSE},
1529             {"",S_FALSE,FALSE},
1530             {"/",S_OK,FALSE},
1531             {"/",S_OK,FALSE},
1532             {"",S_FALSE,FALSE},
1533             {"http://[1:2:3:4:5:6:0.0.0.0]",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     /* IPv4 addresses get normalized. */
1546     {   "http://[::001.002.003.000]", 0, S_OK, FALSE,
1547         {
1548             {"http://[::1.2.3.0]/",S_OK,FALSE},
1549             {"[::1.2.3.0]",S_OK,FALSE},
1550             {"http://[::1.2.3.0]/",S_OK,FALSE},
1551             {"",S_FALSE,FALSE},
1552             {"",S_FALSE,FALSE},
1553             {"",S_FALSE,FALSE},
1554             {"::1.2.3.0",S_OK,FALSE},
1555             {"",S_FALSE,FALSE},
1556             {"/",S_OK,FALSE},
1557             {"/",S_OK,FALSE},
1558             {"",S_FALSE,FALSE},
1559             {"http://[::001.002.003.000]",S_OK,FALSE},
1560             {"http",S_OK,FALSE},
1561             {"",S_FALSE,FALSE},
1562             {"",S_FALSE,FALSE},
1563         },
1564         {
1565             {Uri_HOST_IPV6,S_OK,FALSE},
1566             {80,S_OK,FALSE},
1567             {URL_SCHEME_HTTP,S_OK,FALSE},
1568             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1569         }
1570     },
1571     /* Windows doesn't do anything to IPv6's in unknown schemes. */
1572     {   "zip://[0001:0:000:0004:0005:0006:001.002.003.000]", 0, S_OK, FALSE,
1573         {
1574             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]/",S_OK,FALSE},
1575             {"[0001:0:000:0004:0005:0006:001.002.003.000]",S_OK,FALSE},
1576             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]/",S_OK,FALSE},
1577             {"",S_FALSE,FALSE},
1578             {"",S_FALSE,FALSE},
1579             {"",S_FALSE,FALSE},
1580             {"0001:0:000:0004:0005:0006:001.002.003.000",S_OK,FALSE},
1581             {"",S_FALSE,FALSE},
1582             {"/",S_OK,FALSE},
1583             {"/",S_OK,FALSE},
1584             {"",S_FALSE,FALSE},
1585             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]",S_OK,FALSE},
1586             {"zip",S_OK,FALSE},
1587             {"",S_FALSE,FALSE},
1588             {"",S_FALSE,FALSE},
1589         },
1590         {
1591             {Uri_HOST_IPV6,S_OK,FALSE},
1592             {0,S_FALSE,FALSE},
1593             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1594             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1595         }
1596     },
1597     /* IPv4 address is converted into 2 h16 components. */
1598     {   "http://[ffff::192.222.111.32]", 0, S_OK, FALSE,
1599         {
1600             {"http://[ffff::c0de:6f20]/",S_OK,FALSE},
1601             {"[ffff::c0de:6f20]",S_OK,FALSE},
1602             {"http://[ffff::c0de:6f20]/",S_OK,FALSE},
1603             {"",S_FALSE,FALSE},
1604             {"",S_FALSE,FALSE},
1605             {"",S_FALSE,FALSE},
1606             {"ffff::c0de:6f20",S_OK,FALSE},
1607             {"",S_FALSE,FALSE},
1608             {"/",S_OK,FALSE},
1609             {"/",S_OK,FALSE},
1610             {"",S_FALSE,FALSE},
1611             {"http://[ffff::192.222.111.32]",S_OK,FALSE},
1612             {"http",S_OK,FALSE},
1613             {"",S_FALSE,FALSE},
1614             {"",S_FALSE,FALSE},
1615         },
1616         {
1617             {Uri_HOST_IPV6,S_OK,FALSE},
1618             {80,S_OK,FALSE},
1619             {URL_SCHEME_HTTP,S_OK,FALSE},
1620             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1621         }
1622     },
1623     /* Max value for a port. */
1624     {   "http://google.com:65535", 0, S_OK, FALSE,
1625         {
1626             {"http://google.com:65535/",S_OK,FALSE},
1627             {"google.com:65535",S_OK,FALSE},
1628             {"http://google.com:65535/",S_OK,FALSE},
1629             {"google.com",S_OK,FALSE},
1630             {"",S_FALSE,FALSE},
1631             {"",S_FALSE,FALSE},
1632             {"google.com",S_OK,FALSE},
1633             {"",S_FALSE,FALSE},
1634             {"/",S_OK,FALSE},
1635             {"/",S_OK,FALSE},
1636             {"",S_FALSE,FALSE},
1637             {"http://google.com:65535",S_OK,FALSE},
1638             {"http",S_OK,FALSE},
1639             {"",S_FALSE,FALSE},
1640             {"",S_FALSE,FALSE}
1641         },
1642         {
1643             {Uri_HOST_DNS,S_OK,FALSE},
1644             {65535,S_OK,FALSE},
1645             {URL_SCHEME_HTTP,S_OK,FALSE},
1646             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1647         }
1648     },
1649     {   "zip://google.com:65536", 0, S_OK, FALSE,
1650         {
1651             {"zip://google.com:65536/",S_OK,FALSE},
1652             {"google.com:65536",S_OK,FALSE},
1653             {"zip://google.com:65536/",S_OK,FALSE},
1654             {"google.com:65536",S_OK,FALSE},
1655             {"",S_FALSE,FALSE},
1656             {"",S_FALSE,FALSE},
1657             {"google.com:65536",S_OK,FALSE},
1658             {"",S_FALSE,FALSE},
1659             {"/",S_OK,FALSE},
1660             {"/",S_OK,FALSE},
1661             {"",S_FALSE,FALSE},
1662             {"zip://google.com:65536",S_OK,FALSE},
1663             {"zip",S_OK,FALSE},
1664             {"",S_FALSE,FALSE},
1665             {"",S_FALSE,FALSE}
1666         },
1667         {
1668             {Uri_HOST_DNS,S_OK,FALSE},
1669             {0,S_FALSE,FALSE},
1670             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1671             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1672         }
1673     },
1674     {   "zip://google.com:65536:25", 0, S_OK, FALSE,
1675         {
1676             {"zip://google.com:65536:25/",S_OK,FALSE},
1677             {"google.com:65536:25",S_OK,FALSE},
1678             {"zip://google.com:65536:25/",S_OK,FALSE},
1679             {"google.com:65536:25",S_OK,FALSE},
1680             {"",S_FALSE,FALSE},
1681             {"",S_FALSE,FALSE},
1682             {"google.com:65536:25",S_OK,FALSE},
1683             {"",S_FALSE,FALSE},
1684             {"/",S_OK,FALSE},
1685             {"/",S_OK,FALSE},
1686             {"",S_FALSE,FALSE},
1687             {"zip://google.com:65536:25",S_OK,FALSE},
1688             {"zip",S_OK,FALSE},
1689             {"",S_FALSE,FALSE},
1690             {"",S_FALSE,FALSE}
1691         },
1692         {
1693             {Uri_HOST_DNS,S_OK,FALSE},
1694             {0,S_FALSE,FALSE},
1695             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1696             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1697         }
1698     },
1699     {   "zip://[::ffff]:abcd", 0, S_OK, FALSE,
1700         {
1701             {"zip://[::ffff]:abcd/",S_OK,FALSE},
1702             {"[::ffff]:abcd",S_OK,FALSE},
1703             {"zip://[::ffff]:abcd/",S_OK,FALSE},
1704             {"",S_FALSE,FALSE},
1705             {"",S_FALSE,FALSE},
1706             {"",S_FALSE,FALSE},
1707             {"[::ffff]:abcd",S_OK,FALSE},
1708             {"",S_FALSE,FALSE},
1709             {"/",S_OK,FALSE},
1710             {"/",S_OK,FALSE},
1711             {"",S_FALSE,FALSE},
1712             {"zip://[::ffff]:abcd",S_OK,FALSE},
1713             {"zip",S_OK,FALSE},
1714             {"",S_FALSE,FALSE},
1715             {"",S_FALSE,FALSE}
1716         },
1717         {
1718             {Uri_HOST_DNS,S_OK,FALSE},
1719             {0,S_FALSE,FALSE},
1720             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1721             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1722         }
1723     },
1724     {   "zip://127.0.0.1:abcd", 0, S_OK, FALSE,
1725         {
1726             {"zip://127.0.0.1:abcd/",S_OK,FALSE},
1727             {"127.0.0.1:abcd",S_OK,FALSE},
1728             {"zip://127.0.0.1:abcd/",S_OK,FALSE},
1729             {"0.1:abcd",S_OK,FALSE},
1730             {"",S_FALSE,FALSE},
1731             {"",S_FALSE,FALSE},
1732             {"127.0.0.1:abcd",S_OK,FALSE},
1733             {"",S_FALSE,FALSE},
1734             {"/",S_OK,FALSE},
1735             {"/",S_OK,FALSE},
1736             {"",S_FALSE,FALSE},
1737             {"zip://127.0.0.1:abcd",S_OK,FALSE},
1738             {"zip",S_OK,FALSE},
1739             {"",S_FALSE,FALSE},
1740             {"",S_FALSE,FALSE}
1741         },
1742         {
1743             {Uri_HOST_DNS,S_OK,FALSE},
1744             {0,S_FALSE,FALSE},
1745             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1746             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1747         }
1748     },
1749     /* Port is just copied over. */
1750     {   "http://google.com:00035", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1751         {
1752             {"http://google.com:00035",S_OK,FALSE},
1753             {"google.com:00035",S_OK,FALSE},
1754             {"http://google.com:00035",S_OK,FALSE,"http://google.com:35"},
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:00035",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             {35,S_OK,FALSE},
1771             {URL_SCHEME_HTTP,S_OK,FALSE},
1772             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1773         }
1774     },
1775     /* Default port is copied over. */
1776     {   "http://google.com:80", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1777         {
1778             {"http://google.com:80",S_OK,FALSE},
1779             {"google.com:80",S_OK,FALSE},
1780             {"http://google.com:80",S_OK,FALSE},
1781             {"google.com",S_OK,FALSE},
1782             {"",S_FALSE,FALSE},
1783             {"",S_FALSE,FALSE},
1784             {"google.com",S_OK,FALSE},
1785             {"",S_FALSE,FALSE},
1786             {"",S_FALSE,FALSE},
1787             {"",S_FALSE,FALSE},
1788             {"",S_FALSE,FALSE},
1789             {"http://google.com:80",S_OK,FALSE},
1790             {"http",S_OK,FALSE},
1791             {"",S_FALSE,FALSE},
1792             {"",S_FALSE,FALSE}
1793         },
1794         {
1795             {Uri_HOST_DNS,S_OK,FALSE},
1796             {80,S_OK,FALSE},
1797             {URL_SCHEME_HTTP,S_OK,FALSE},
1798             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1799         }
1800     },
1801     {   "http://google.com.uk", 0, S_OK, FALSE,
1802         {
1803             {"http://google.com.uk/",S_OK,FALSE},
1804             {"google.com.uk",S_OK,FALSE},
1805             {"http://google.com.uk/",S_OK,FALSE},
1806             {"google.com.uk",S_OK,FALSE},
1807             {"",S_FALSE,FALSE},
1808             {"",S_FALSE,FALSE},
1809             {"google.com.uk",S_OK,FALSE},
1810             {"",S_FALSE,FALSE},
1811             {"/",S_OK,FALSE},
1812             {"/",S_OK,FALSE},
1813             {"",S_FALSE,FALSE},
1814             {"http://google.com.uk",S_OK,FALSE},
1815             {"http",S_OK,FALSE},
1816             {"",S_FALSE,FALSE},
1817             {"",S_FALSE,FALSE}
1818         },
1819         {
1820             {Uri_HOST_DNS,S_OK,FALSE},
1821             {80,S_OK,FALSE},
1822             {URL_SCHEME_HTTP,S_OK,FALSE},
1823             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1824         }
1825     },
1826     {   "http://google.com.com", 0, S_OK, FALSE,
1827         {
1828             {"http://google.com.com/",S_OK,FALSE},
1829             {"google.com.com",S_OK,FALSE},
1830             {"http://google.com.com/",S_OK,FALSE},
1831             {"com.com",S_OK,FALSE},
1832             {"",S_FALSE,FALSE},
1833             {"",S_FALSE,FALSE},
1834             {"google.com.com",S_OK,FALSE},
1835             {"",S_FALSE,FALSE},
1836             {"/",S_OK,FALSE},
1837             {"/",S_OK,FALSE},
1838             {"",S_FALSE,FALSE},
1839             {"http://google.com.com",S_OK,FALSE},
1840             {"http",S_OK,FALSE},
1841             {"",S_FALSE,FALSE},
1842             {"",S_FALSE,FALSE}
1843         },
1844         {
1845             {Uri_HOST_DNS,S_OK,FALSE},
1846             {80,S_OK,FALSE},
1847             {URL_SCHEME_HTTP,S_OK,FALSE},
1848             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1849         }
1850     },
1851     {   "http://google.uk.1", 0, S_OK, FALSE,
1852         {
1853             {"http://google.uk.1/",S_OK,FALSE},
1854             {"google.uk.1",S_OK,FALSE},
1855             {"http://google.uk.1/",S_OK,FALSE},
1856             {"google.uk.1",S_OK,FALSE},
1857             {"",S_FALSE,FALSE},
1858             {"",S_FALSE,FALSE},
1859             {"google.uk.1",S_OK,FALSE},
1860             {"",S_FALSE,FALSE},
1861             {"/",S_OK,FALSE},
1862             {"/",S_OK,FALSE},
1863             {"",S_FALSE,FALSE},
1864             {"http://google.uk.1",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     /* Since foo isn't a recognized 3 character TLD its considered the domain name. */
1877     {   "http://google.foo.uk", 0, S_OK, FALSE,
1878         {
1879             {"http://google.foo.uk/",S_OK,FALSE},
1880             {"google.foo.uk",S_OK,FALSE},
1881             {"http://google.foo.uk/",S_OK,FALSE},
1882             {"foo.uk",S_OK,FALSE},
1883             {"",S_FALSE,FALSE},
1884             {"",S_FALSE,FALSE},
1885             {"google.foo.uk",S_OK,FALSE},
1886             {"",S_FALSE,FALSE},
1887             {"/",S_OK,FALSE},
1888             {"/",S_OK,FALSE},
1889             {"",S_FALSE,FALSE},
1890             {"http://google.foo.uk",S_OK,FALSE},
1891             {"http",S_OK,FALSE},
1892             {"",S_FALSE,FALSE},
1893             {"",S_FALSE,FALSE}
1894         },
1895         {
1896             {Uri_HOST_DNS,S_OK,FALSE},
1897             {80,S_OK,FALSE},
1898             {URL_SCHEME_HTTP,S_OK,FALSE},
1899             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1900         }
1901     },
1902     {   "http://.com", 0, S_OK, FALSE,
1903         {
1904             {"http://.com/",S_OK,FALSE},
1905             {".com",S_OK,FALSE},
1906             {"http://.com/",S_OK,FALSE},
1907             {".com",S_OK,FALSE},
1908             {"",S_FALSE,FALSE},
1909             {"",S_FALSE,FALSE},
1910             {".com",S_OK,FALSE},
1911             {"",S_FALSE,FALSE},
1912             {"/",S_OK,FALSE},
1913             {"/",S_OK,FALSE},
1914             {"",S_FALSE,FALSE},
1915             {"http://.com",S_OK,FALSE},
1916             {"http",S_OK,FALSE},
1917             {"",S_FALSE,FALSE},
1918             {"",S_FALSE,FALSE}
1919         },
1920         {
1921             {Uri_HOST_DNS,S_OK,FALSE},
1922             {80,S_OK,FALSE},
1923             {URL_SCHEME_HTTP,S_OK,FALSE},
1924             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1925         }
1926     },
1927     {   "http://.uk", 0, S_OK, FALSE,
1928         {
1929             {"http://.uk/",S_OK,FALSE},
1930             {".uk",S_OK,FALSE},
1931             {"http://.uk/",S_OK,FALSE},
1932             {"",S_FALSE,FALSE},
1933             {"",S_FALSE,FALSE},
1934             {"",S_FALSE,FALSE},
1935             {".uk",S_OK,FALSE},
1936             {"",S_FALSE,FALSE},
1937             {"/",S_OK,FALSE},
1938             {"/",S_OK,FALSE},
1939             {"",S_FALSE,FALSE},
1940             {"http://.uk",S_OK,FALSE},
1941             {"http",S_OK,FALSE},
1942             {"",S_FALSE,FALSE},
1943             {"",S_FALSE,FALSE}
1944         },
1945         {
1946             {Uri_HOST_DNS,S_OK,FALSE},
1947             {80,S_OK,FALSE},
1948             {URL_SCHEME_HTTP,S_OK,FALSE},
1949             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1950         }
1951     },
1952     {   "http://www.co.google.com.[]", 0, S_OK, FALSE,
1953         {
1954             {"http://www.co.google.com.[]/",S_OK,FALSE},
1955             {"www.co.google.com.[]",S_OK,FALSE},
1956             {"http://www.co.google.com.[]/",S_OK,FALSE},
1957             {"google.com.[]",S_OK,FALSE},
1958             {"",S_FALSE,FALSE},
1959             {"",S_FALSE,FALSE},
1960             {"www.co.google.com.[]",S_OK,FALSE},
1961             {"",S_FALSE,FALSE},
1962             {"/",S_OK,FALSE},
1963             {"/",S_OK,FALSE},
1964             {"",S_FALSE,FALSE},
1965             {"http://www.co.google.com.[]",S_OK,FALSE},
1966             {"http",S_OK,FALSE},
1967             {"",S_FALSE,FALSE},
1968             {"",S_FALSE,FALSE}
1969         },
1970         {
1971             {Uri_HOST_DNS,S_OK,FALSE},
1972             {80,S_OK,FALSE},
1973             {URL_SCHEME_HTTP,S_OK,FALSE},
1974             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1975         }
1976     },
1977     {   "http://co.uk", 0, S_OK, FALSE,
1978         {
1979             {"http://co.uk/",S_OK,FALSE},
1980             {"co.uk",S_OK,FALSE},
1981             {"http://co.uk/",S_OK,FALSE},
1982             {"",S_FALSE,FALSE},
1983             {"",S_FALSE,FALSE},
1984             {"",S_FALSE,FALSE},
1985             {"co.uk",S_OK,FALSE},
1986             {"",S_FALSE,FALSE},
1987             {"/",S_OK,FALSE},
1988             {"/",S_OK,FALSE},
1989             {"",S_FALSE,FALSE},
1990             {"http://co.uk",S_OK,FALSE},
1991             {"http",S_OK,FALSE},
1992             {"",S_FALSE,FALSE},
1993             {"",S_FALSE,FALSE}
1994         },
1995         {
1996             {Uri_HOST_DNS,S_OK,FALSE},
1997             {80,S_OK,FALSE},
1998             {URL_SCHEME_HTTP,S_OK,FALSE},
1999             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2000         }
2001     },
2002     {   "http://www.co.google.us.test", 0, S_OK, FALSE,
2003         {
2004             {"http://www.co.google.us.test/",S_OK,FALSE},
2005             {"www.co.google.us.test",S_OK,FALSE},
2006             {"http://www.co.google.us.test/",S_OK,FALSE},
2007             {"us.test",S_OK,FALSE},
2008             {"",S_FALSE,FALSE},
2009             {"",S_FALSE,FALSE},
2010             {"www.co.google.us.test",S_OK,FALSE},
2011             {"",S_FALSE,FALSE},
2012             {"/",S_OK,FALSE},
2013             {"/",S_OK,FALSE},
2014             {"",S_FALSE,FALSE},
2015             {"http://www.co.google.us.test",S_OK,FALSE},
2016             {"http",S_OK,FALSE},
2017             {"",S_FALSE,FALSE},
2018             {"",S_FALSE,FALSE}
2019         },
2020         {
2021             {Uri_HOST_DNS,S_OK,FALSE},
2022             {80,S_OK,FALSE},
2023             {URL_SCHEME_HTTP,S_OK,FALSE},
2024             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2025         }
2026     },
2027     {   "http://gov.uk", 0, S_OK, FALSE,
2028         {
2029             {"http://gov.uk/",S_OK,FALSE},
2030             {"gov.uk",S_OK,FALSE},
2031             {"http://gov.uk/",S_OK,FALSE},
2032             {"",S_FALSE,FALSE},
2033             {"",S_FALSE,FALSE},
2034             {"",S_FALSE,FALSE},
2035             {"gov.uk",S_OK,FALSE},
2036             {"",S_FALSE,FALSE},
2037             {"/",S_OK,FALSE},
2038             {"/",S_OK,FALSE},
2039             {"",S_FALSE,FALSE},
2040             {"http://gov.uk",S_OK,FALSE},
2041             {"http",S_OK,FALSE},
2042             {"",S_FALSE,FALSE},
2043             {"",S_FALSE,FALSE}
2044         },
2045         {
2046             {Uri_HOST_DNS,S_OK,FALSE},
2047             {80,S_OK,FALSE},
2048             {URL_SCHEME_HTTP,S_OK,FALSE},
2049             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2050         }
2051     },
2052     {   "zip://www.google.com\\test", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2053         {
2054             {"zip://www.google.com\\test",S_OK,FALSE},
2055             {"www.google.com\\test",S_OK,FALSE},
2056             {"zip://www.google.com\\test",S_OK,FALSE},
2057             {"google.com\\test",S_OK,FALSE},
2058             {"",S_FALSE,FALSE},
2059             {"",S_FALSE,FALSE},
2060             {"www.google.com\\test",S_OK,FALSE},
2061             {"",S_FALSE,FALSE},
2062             {"",S_FALSE,FALSE},
2063             {"",S_FALSE,FALSE},
2064             {"",S_FALSE,FALSE},
2065             {"zip://www.google.com\\test",S_OK,FALSE},
2066             {"zip",S_OK,FALSE},
2067             {"",S_FALSE,FALSE},
2068             {"",S_FALSE,FALSE}
2069         },
2070         {
2071             {Uri_HOST_DNS,S_OK,FALSE},
2072             {0,S_FALSE,FALSE},
2073             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2074             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2075         }
2076     },
2077     {   "urn:excepts:bad:%XY:encoded", 0, S_OK, FALSE,
2078         {
2079             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2080             {"",S_FALSE,FALSE},
2081             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2082             {"",S_FALSE,FALSE},
2083             {"",S_FALSE,FALSE},
2084             {"",S_FALSE,FALSE},
2085             {"",S_FALSE,FALSE},
2086             {"",S_FALSE,FALSE},
2087             {"excepts:bad:%XY:encoded",S_OK,FALSE},
2088             {"excepts:bad:%XY:encoded",S_OK,FALSE},
2089             {"",S_FALSE,FALSE},
2090             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2091             {"urn",S_OK,FALSE},
2092             {"",S_FALSE,FALSE},
2093             {"",S_FALSE,FALSE}
2094         },
2095         {
2096             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2097             {0,S_FALSE,FALSE},
2098             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2099             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2100         }
2101     },
2102     /* Since the original URI doesn't contain an extra '/' before the path no % encoded values
2103      * are decoded and all '%' are encoded.
2104      */
2105     {   "file://C:/te%3Es%2Et/tes%t.mp3", 0, S_OK, FALSE,
2106         {
2107             {"file:///C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2108             {"",S_FALSE,FALSE},
2109             {"file:///C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2110             {"",S_FALSE,FALSE},
2111             {".mp3",S_OK,FALSE},
2112             {"",S_FALSE,FALSE},
2113             {"",S_FALSE,FALSE},
2114             {"",S_FALSE,FALSE},
2115             {"/C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2116             {"/C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2117             {"",S_FALSE,FALSE},
2118             {"file://C:/te%3Es%2Et/tes%t.mp3",S_OK,FALSE},
2119             {"file",S_OK,FALSE},
2120             {"",S_FALSE,FALSE},
2121             {"",S_FALSE,FALSE}
2122         },
2123         {
2124             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2125             {0,S_FALSE,FALSE},
2126             {URL_SCHEME_FILE,S_OK,FALSE},
2127             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2128         }
2129     },
2130     /* Since there's a '/' in front of the drive letter, any percent encoded, non-forbidden character
2131      * is decoded and only %'s in front of invalid hex digits are encoded.
2132      */
2133     {   "file:///C:/te%3Es%2Et/t%23es%t.mp3", 0, S_OK, FALSE,
2134         {
2135             {"file:///C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2136             {"",S_FALSE,FALSE},
2137             {"file:///C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2138             {"",S_FALSE,FALSE},
2139             {".mp3",S_OK,FALSE},
2140             {"",S_FALSE,FALSE},
2141             {"",S_FALSE,FALSE},
2142             {"",S_FALSE,FALSE},
2143             {"/C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2144             {"/C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2145             {"",S_FALSE,FALSE},
2146             {"file:///C:/te%3Es%2Et/t%23es%t.mp3",S_OK,FALSE},
2147             {"file",S_OK,FALSE},
2148             {"",S_FALSE,FALSE},
2149             {"",S_FALSE,FALSE}
2150         },
2151         {
2152             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2153             {0,S_FALSE,FALSE},
2154             {URL_SCHEME_FILE,S_OK,FALSE},
2155             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2156         }
2157     },
2158     /* Only unreserved percent encoded characters are decoded for known schemes that aren't file. */
2159     {   "http://[::001.002.003.000]/%3F%23%2E%54/test", 0, S_OK, FALSE,
2160         {
2161             {"http://[::1.2.3.0]/%3F%23.T/test",S_OK,FALSE},
2162             {"[::1.2.3.0]",S_OK,FALSE},
2163             {"http://[::1.2.3.0]/%3F%23.T/test",S_OK,FALSE},
2164             {"",S_FALSE,FALSE},
2165             {"",S_FALSE,FALSE},
2166             {"",S_FALSE,FALSE},
2167             {"::1.2.3.0",S_OK,FALSE},
2168             {"",S_FALSE,FALSE},
2169             {"/%3F%23.T/test",S_OK,FALSE},
2170             {"/%3F%23.T/test",S_OK,FALSE},
2171             {"",S_FALSE,FALSE},
2172             {"http://[::001.002.003.000]/%3F%23%2E%54/test",S_OK,FALSE},
2173             {"http",S_OK,FALSE},
2174             {"",S_FALSE,FALSE},
2175             {"",S_FALSE,FALSE},
2176         },
2177         {
2178             {Uri_HOST_IPV6,S_OK,FALSE},
2179             {80,S_OK,FALSE},
2180             {URL_SCHEME_HTTP,S_OK,FALSE},
2181             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2182         }
2183     },
2184     /* Forbidden characters are always encoded for file URIs. */
2185     {   "file:///C:/\"test\"/test.mp3", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2186         {
2187             {"file:///C:/%22test%22/test.mp3",S_OK,FALSE},
2188             {"",S_FALSE,FALSE},
2189             {"file:///C:/%22test%22/test.mp3",S_OK,FALSE},
2190             {"",S_FALSE,FALSE},
2191             {".mp3",S_OK,FALSE},
2192             {"",S_FALSE,FALSE},
2193             {"",S_FALSE,FALSE},
2194             {"",S_FALSE,FALSE},
2195             {"/C:/%22test%22/test.mp3",S_OK,FALSE},
2196             {"/C:/%22test%22/test.mp3",S_OK,FALSE},
2197             {"",S_FALSE,FALSE},
2198             {"file:///C:/\"test\"/test.mp3",S_OK,FALSE},
2199             {"file",S_OK,FALSE},
2200             {"",S_FALSE,FALSE},
2201             {"",S_FALSE,FALSE}
2202         },
2203         {
2204             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2205             {0,S_FALSE,FALSE},
2206             {URL_SCHEME_FILE,S_OK,FALSE},
2207             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2208         }
2209     },
2210     /* Forbidden characters are never encoded for unknown scheme types. */
2211     {   "1234://4294967295/<|>\" test<|>", 0, S_OK, FALSE,
2212         {
2213             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2214             {"4294967295",S_OK,FALSE},
2215             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2216             {"",S_FALSE,FALSE},
2217             {"",S_FALSE,FALSE},
2218             {"",S_FALSE,FALSE},
2219             {"4294967295",S_OK,FALSE},
2220             {"",S_FALSE,FALSE},
2221             {"/<|>\" test<|>",S_OK,FALSE},
2222             {"/<|>\" test<|>",S_OK,FALSE},
2223             {"",S_FALSE,FALSE},
2224             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2225             {"1234",S_OK,FALSE},
2226             {"",S_FALSE,FALSE},
2227             {"",S_FALSE,FALSE}
2228         },
2229         {
2230             {Uri_HOST_IPV4,S_OK,FALSE},
2231             {0,S_FALSE,FALSE},
2232             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2233             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2234         }
2235     },
2236     /* Make sure forbidden characters are percent encoded. */
2237     {   "http://gov.uk/<|> test<|>", 0, S_OK, FALSE,
2238         {
2239             {"http://gov.uk/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2240             {"gov.uk",S_OK,FALSE},
2241             {"http://gov.uk/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2242             {"",S_FALSE,FALSE},
2243             {"",S_FALSE,FALSE},
2244             {"",S_FALSE,FALSE},
2245             {"gov.uk",S_OK,FALSE},
2246             {"",S_FALSE,FALSE},
2247             {"/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2248             {"/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2249             {"",S_FALSE,FALSE},
2250             {"http://gov.uk/<|> test<|>",S_OK,FALSE},
2251             {"http",S_OK,FALSE},
2252             {"",S_FALSE,FALSE},
2253             {"",S_FALSE,FALSE}
2254         },
2255         {
2256             {Uri_HOST_DNS,S_OK,FALSE},
2257             {80,S_OK,FALSE},
2258             {URL_SCHEME_HTTP,S_OK,FALSE},
2259             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2260         }
2261     },
2262     {   "http://gov.uk/test/../test2/././../test3/.././././", 0, S_OK, FALSE,
2263         {
2264             {"http://gov.uk/",S_OK,FALSE},
2265             {"gov.uk",S_OK,FALSE},
2266             {"http://gov.uk/",S_OK,FALSE},
2267             {"",S_FALSE,FALSE},
2268             {"",S_FALSE,FALSE},
2269             {"",S_FALSE,FALSE},
2270             {"gov.uk",S_OK,FALSE},
2271             {"",S_FALSE,FALSE},
2272             {"/",S_OK,FALSE},
2273             {"/",S_OK,FALSE},
2274             {"",S_FALSE,FALSE},
2275             {"http://gov.uk/test/../test2/././../test3/.././././",S_OK,FALSE},
2276             {"http",S_OK,FALSE},
2277             {"",S_FALSE,FALSE},
2278             {"",S_FALSE,FALSE}
2279         },
2280         {
2281             {Uri_HOST_DNS,S_OK,FALSE},
2282             {80,S_OK,FALSE},
2283             {URL_SCHEME_HTTP,S_OK,FALSE},
2284             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2285         }
2286     },
2287     {   "http://gov.uk/test/test2/../../..", 0, S_OK, FALSE,
2288         {
2289             {"http://gov.uk/",S_OK,FALSE},
2290             {"gov.uk",S_OK,FALSE},
2291             {"http://gov.uk/",S_OK,FALSE},
2292             {"",S_FALSE,FALSE},
2293             {"",S_FALSE,FALSE},
2294             {"",S_FALSE,FALSE},
2295             {"gov.uk",S_OK,FALSE},
2296             {"",S_FALSE,FALSE},
2297             {"/",S_OK,FALSE},
2298             {"/",S_OK,FALSE},
2299             {"",S_FALSE,FALSE},
2300             {"http://gov.uk/test/test2/../../..",S_OK,FALSE},
2301             {"http",S_OK,FALSE},
2302             {"",S_FALSE,FALSE},
2303             {"",S_FALSE,FALSE}
2304         },
2305         {
2306             {Uri_HOST_DNS,S_OK,FALSE},
2307             {80,S_OK,FALSE},
2308             {URL_SCHEME_HTTP,S_OK,FALSE},
2309             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2310         }
2311     },
2312     {   "http://gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2313         {
2314             {"http://gov.uk/",S_OK,FALSE},
2315             {"gov.uk",S_OK,FALSE},
2316             {"http://gov.uk/",S_OK,FALSE},
2317             {"",S_FALSE,FALSE},
2318             {"",S_FALSE,FALSE},
2319             {"",S_FALSE,FALSE},
2320             {"gov.uk",S_OK,FALSE},
2321             {"",S_FALSE,FALSE},
2322             {"/",S_OK,FALSE},
2323             {"/",S_OK,FALSE},
2324             {"",S_FALSE,FALSE},
2325             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2326             {"http",S_OK,FALSE},
2327             {"",S_FALSE,FALSE},
2328             {"",S_FALSE,FALSE}
2329         },
2330         {
2331             {Uri_HOST_DNS,S_OK,FALSE},
2332             {80,S_OK,FALSE},
2333             {URL_SCHEME_HTTP,S_OK,FALSE},
2334             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2335         }
2336     },
2337     {   "file://c:\\tests\\../tests\\./.\\..\\foo%20bar.mp3", 0, S_OK, FALSE,
2338         {
2339             {"file:///c:/foo%2520bar.mp3",S_OK,FALSE},
2340             {"",S_FALSE,FALSE},
2341             {"file:///c:/foo%2520bar.mp3",S_OK,FALSE},
2342             {"",S_FALSE,FALSE},
2343             {".mp3",S_OK,FALSE},
2344             {"",S_FALSE,FALSE},
2345             {"",S_FALSE,FALSE},
2346             {"",S_FALSE,FALSE},
2347             {"/c:/foo%2520bar.mp3",S_OK,FALSE},
2348             {"/c:/foo%2520bar.mp3",S_OK,FALSE},
2349             {"",S_FALSE,FALSE},
2350             {"file://c:\\tests\\../tests\\./.\\..\\foo%20bar.mp3",S_OK,FALSE},
2351             {"file",S_OK,FALSE},
2352             {"",S_FALSE,FALSE},
2353             {"",S_FALSE,FALSE}
2354         },
2355         {
2356             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2357             {0,S_FALSE,FALSE},
2358             {URL_SCHEME_FILE,S_OK,FALSE},
2359             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2360         }
2361     },
2362     /* Dot removal happens for unknown scheme types. */
2363     {   "zip://gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2364         {
2365             {"zip://gov.uk/",S_OK,FALSE},
2366             {"gov.uk",S_OK,FALSE},
2367             {"zip://gov.uk/",S_OK,FALSE},
2368             {"",S_FALSE,FALSE},
2369             {"",S_FALSE,FALSE},
2370             {"",S_FALSE,FALSE},
2371             {"gov.uk",S_OK,FALSE},
2372             {"",S_FALSE,FALSE},
2373             {"/",S_OK,FALSE},
2374             {"/",S_OK,FALSE},
2375             {"",S_FALSE,FALSE},
2376             {"zip://gov.uk/test/test2/../../.",S_OK,FALSE},
2377             {"zip",S_OK,FALSE},
2378             {"",S_FALSE,FALSE},
2379             {"",S_FALSE,FALSE}
2380         },
2381         {
2382             {Uri_HOST_DNS,S_OK,FALSE},
2383             {0,S_FALSE,FALSE},
2384             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2385             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2386         }
2387     },
2388     /* Dot removal doesn't happen if NO_CANONICALIZE is set. */
2389     {   "http://gov.uk/test/test2/../../.", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2390         {
2391             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2392             {"gov.uk",S_OK,FALSE},
2393             {"http://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             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2403             {"http",S_OK,FALSE},
2404             {"",S_FALSE,FALSE},
2405             {"",S_FALSE,FALSE}
2406         },
2407         {
2408             {Uri_HOST_DNS,S_OK,FALSE},
2409             {80,S_OK,FALSE},
2410             {URL_SCHEME_HTTP,S_OK,FALSE},
2411             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2412         }
2413     },
2414     /* Dot removal doesn't happen for wildcard scheme types. */
2415     {   "*:gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2416         {
2417             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2418             {"gov.uk",S_OK,FALSE},
2419             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2420             {"",S_FALSE,FALSE},
2421             {".",S_OK,FALSE},
2422             {"",S_FALSE,FALSE},
2423             {"gov.uk",S_OK,FALSE},
2424             {"",S_FALSE,FALSE},
2425             {"/test/test2/../../.",S_OK,FALSE},
2426             {"/test/test2/../../.",S_OK,FALSE},
2427             {"",S_FALSE,FALSE},
2428             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2429             {"*",S_OK,FALSE},
2430             {"",S_FALSE,FALSE},
2431             {"",S_FALSE,FALSE}
2432         },
2433         {
2434             {Uri_HOST_DNS,S_OK,FALSE},
2435             {0,S_FALSE,FALSE},
2436             {URL_SCHEME_WILDCARD,S_OK,FALSE},
2437             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2438         }
2439     },
2440     /* Forbidden characters are encoded for opaque known scheme types. */
2441     {   "mailto:\"acco<|>unt@example.com\"", 0, S_OK, FALSE,
2442         {
2443             {"mailto:%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2444             {"",S_FALSE,FALSE},
2445             {"mailto:%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2446             {"",S_FALSE,FALSE},
2447             {".com%22",S_OK,FALSE},
2448             {"",S_FALSE,FALSE},
2449             {"",S_FALSE,FALSE},
2450             {"",S_FALSE,FALSE},
2451             {"%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2452             {"%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2453             {"",S_FALSE,FALSE},
2454             {"mailto:\"acco<|>unt@example.com\"",S_OK,FALSE},
2455             {"mailto",S_OK,FALSE},
2456             {"",S_FALSE,FALSE},
2457             {"",S_FALSE,FALSE}
2458         },
2459         {
2460             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2461             {0,S_FALSE,FALSE},
2462             {URL_SCHEME_MAILTO,S_OK,FALSE},
2463             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2464         }
2465     },
2466     {   "news:test.tes<|>t.com", 0, S_OK, FALSE,
2467         {
2468             {"news:test.tes%3C%7C%3Et.com",S_OK,FALSE},
2469             {"",S_FALSE,FALSE},
2470             {"news:test.tes%3C%7C%3Et.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%3C%7C%3Et.com",S_OK,FALSE},
2477             {"test.tes%3C%7C%3Et.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     /* Don't encode forbidden characters. */
2492     {   "news:test.tes<|>t.com", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2493         {
2494             {"news:test.tes<|>t.com",S_OK,FALSE},
2495             {"",S_FALSE,FALSE},
2496             {"news: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             {"news:test.tes<|>t.com",S_OK,FALSE},
2506             {"news",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_NEWS,S_OK,FALSE},
2514             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2515         }
2516     },
2517     /* Forbidden characters aren't encoded for unknown, opaque URIs. */
2518     {   "urn:test.tes<|>t.com", 0, S_OK, FALSE,
2519         {
2520             {"urn:test.tes<|>t.com",S_OK,FALSE},
2521             {"",S_FALSE,FALSE},
2522             {"urn:test.tes<|>t.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.tes<|>t.com",S_OK,FALSE},
2529             {"test.tes<|>t.com",S_OK,FALSE},
2530             {"",S_FALSE,FALSE},
2531             {"urn:test.tes<|>t.com",S_OK,FALSE},
2532             {"urn",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_UNKNOWN,S_OK,FALSE},
2540             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2541         }
2542     },
2543     /* Percent encoded unreserved characters are decoded for known opaque URIs. */
2544     {   "news:test.%74%65%73%74.com", 0, 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 are still decoded for known scheme types. */
2570     {   "news:test.%74%65%73%74.com", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2571         {
2572             {"news:test.test.com",S_OK,FALSE},
2573             {"",S_FALSE,FALSE},
2574             {"news:test.test.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.test.com",S_OK,FALSE},
2581             {"test.test.com",S_OK,FALSE},
2582             {"",S_FALSE,FALSE},
2583             {"news:test.%74%65%73%74.com",S_OK,FALSE},
2584             {"news",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_NEWS,S_OK,FALSE},
2592             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2593         }
2594     },
2595     /* Percent encoded characters aren't decoded for unknown scheme types. */
2596     {   "urn:test.%74%65%73%74.com", 0, S_OK, FALSE,
2597         {
2598             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2599             {"",S_FALSE,FALSE},
2600             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2601             {"",S_FALSE,FALSE},
2602             {".com",S_OK,FALSE},
2603             {"",S_FALSE,FALSE},
2604             {"",S_FALSE,FALSE},
2605             {"",S_FALSE,FALSE},
2606             {"test.%74%65%73%74.com",S_OK,FALSE},
2607             {"test.%74%65%73%74.com",S_OK,FALSE},
2608             {"",S_FALSE,FALSE},
2609             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2610             {"urn",S_OK,FALSE},
2611             {"",S_FALSE,FALSE},
2612             {"",S_FALSE,FALSE}
2613         },
2614         {
2615             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2616             {0,S_FALSE,FALSE},
2617             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2618             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2619         }
2620     },
2621     /* Unknown scheme types can have invalid % encoded data in query string. */
2622     {   "zip://www.winehq.org/tests/..?query=%xx&return=y", 0, S_OK, FALSE,
2623         {
2624             {"zip://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2625             {"www.winehq.org",S_OK,FALSE},
2626             {"zip://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             {"zip://www.winehq.org/tests/..?query=%xx&return=y",S_OK,FALSE},
2636             {"zip",S_OK,FALSE},
2637             {"",S_FALSE,FALSE},
2638             {"",S_FALSE,FALSE}
2639         },
2640         {
2641             {Uri_HOST_DNS,S_OK,FALSE},
2642             {0,S_FALSE,FALSE},
2643             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2644             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2645         }
2646     },
2647     /* Known scheme types can have invalid % encoded data with the right flags. */
2648     {   "http://www.winehq.org/tests/..?query=%xx&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2649         {
2650             {"http://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2651             {"www.winehq.org",S_OK,FALSE},
2652             {"http://www.winehq.org/?query=%xx&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=%xx&return=y",S_OK,FALSE},
2660             {"?query=%xx&return=y",S_OK,FALSE},
2661             {"http://www.winehq.org/tests/..?query=%xx&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_DECODE_EXTRA_INFO, 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 in query aren't percent encoded for known scheme types with this flag. */
2700     {   "http://www.winehq.org/tests/..?query=<|>&return=y", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2701         {
2702             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2703             {"www.winehq.org",S_OK,FALSE},
2704             {"http://www.winehq.org/?query=<|>&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=<|>&return=y",S_OK,FALSE},
2712             {"?query=<|>&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 encoded for known scheme types. */
2726     {   "http://www.winehq.org/tests/..?query=<|>&return=y", 0, S_OK, FALSE,
2727         {
2728             {"http://www.winehq.org/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2729             {"www.winehq.org",S_OK,FALSE},
2730             {"http://www.winehq.org/?query=%3C%7C%3E&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=%3C%7C%3E&return=y",S_OK,FALSE},
2738             {"?query=%3C%7C%3E&return=y",S_OK,FALSE},
2739             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2740             {"http",S_OK,FALSE},
2741             {"",S_FALSE,FALSE},
2742             {"",S_FALSE,FALSE}
2743         },
2744         {
2745             {Uri_HOST_DNS,S_OK,FALSE},
2746             {80,S_OK,FALSE},
2747             {URL_SCHEME_HTTP,S_OK,FALSE},
2748             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2749         }
2750     },
2751     /* Forbidden characters are not encoded for unknown scheme types. */
2752     {   "zip://www.winehq.org/tests/..?query=<|>&return=y", 0, S_OK, FALSE,
2753         {
2754             {"zip://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2755             {"www.winehq.org",S_OK,FALSE},
2756             {"zip://www.winehq.org/?query=<|>&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=<|>&return=y",S_OK,FALSE},
2764             {"?query=<|>&return=y",S_OK,FALSE},
2765             {"zip://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2766             {"zip",S_OK,FALSE},
2767             {"",S_FALSE,FALSE},
2768             {"",S_FALSE,FALSE}
2769         },
2770         {
2771             {Uri_HOST_DNS,S_OK,FALSE},
2772             {0,S_FALSE,FALSE},
2773             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2774             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2775         }
2776     },
2777     /* Percent encoded, unreserved characters are decoded for known scheme types. */
2778     {   "http://www.winehq.org/tests/..?query=%30%31&return=y", 0, S_OK, FALSE,
2779         {
2780             {"http://www.winehq.org/?query=01&return=y",S_OK,FALSE},
2781             {"www.winehq.org",S_OK,FALSE},
2782             {"http://www.winehq.org/?query=01&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=01&return=y",S_OK,FALSE},
2790             {"?query=01&return=y",S_OK,FALSE},
2791             {"http://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2792             {"http",S_OK,FALSE},
2793             {"",S_FALSE,FALSE},
2794             {"",S_FALSE,FALSE}
2795         },
2796         {
2797             {Uri_HOST_DNS,S_OK,FALSE},
2798             {80,S_OK,FALSE},
2799             {URL_SCHEME_HTTP,S_OK,FALSE},
2800             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2801         }
2802     },
2803     /* Percent encoded, unreserved characters aren't decoded for unknown scheme types. */
2804     {   "zip://www.winehq.org/tests/..?query=%30%31&return=y", 0, S_OK, FALSE,
2805         {
2806             {"zip://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2807             {"www.winehq.org",S_OK,FALSE},
2808             {"zip://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             {"zip://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2818             {"zip",S_OK,FALSE},
2819             {"",S_FALSE,FALSE},
2820             {"",S_FALSE,FALSE}
2821         },
2822         {
2823             {Uri_HOST_DNS,S_OK,FALSE},
2824             {0,S_FALSE,FALSE},
2825             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2826             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2827         }
2828     },
2829     /* Percent encoded characters aren't decoded when NO_DECODE_EXTRA_INFO is set. */
2830     {   "http://www.winehq.org/tests/..?query=%30%31&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2831         {
2832             {"http://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2833             {"www.winehq.org",S_OK,FALSE},
2834             {"http://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2835             {"winehq.org",S_OK,FALSE},
2836             {"",S_FALSE,FALSE},
2837             {"",S_FALSE,FALSE},
2838             {"www.winehq.org",S_OK,FALSE},
2839             {"",S_FALSE,FALSE},
2840             {"/",S_OK,FALSE},
2841             {"/?query=%30%31&return=y",S_OK,FALSE},
2842             {"?query=%30%31&return=y",S_OK,FALSE},
2843             {"http://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2844             {"http",S_OK,FALSE},
2845             {"",S_FALSE,FALSE},
2846             {"",S_FALSE,FALSE}
2847         },
2848         {
2849             {Uri_HOST_DNS,S_OK,FALSE},
2850             {80,S_OK,FALSE},
2851             {URL_SCHEME_HTTP,S_OK,FALSE},
2852             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2853         }
2854     },
2855     {   "http://www.winehq.org?query=12&return=y", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2856         {
2857             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2858             {"www.winehq.org",S_OK,FALSE},
2859             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2860             {"winehq.org",S_OK,FALSE},
2861             {"",S_FALSE,FALSE},
2862             {"",S_FALSE,FALSE},
2863             {"www.winehq.org",S_OK,FALSE},
2864             {"",S_FALSE,FALSE},
2865             {"",S_FALSE,FALSE},
2866             {"?query=12&return=y",S_OK,FALSE},
2867             {"?query=12&return=y",S_OK,FALSE},
2868             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2869             {"http",S_OK,FALSE},
2870             {"",S_FALSE,FALSE},
2871             {"",S_FALSE,FALSE}
2872         },
2873         {
2874             {Uri_HOST_DNS,S_OK,FALSE},
2875             {80,S_OK,FALSE},
2876             {URL_SCHEME_HTTP,S_OK,FALSE},
2877             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2878         }
2879     },
2880     /* Unknown scheme types can have invalid % encoded data in fragments. */
2881     {   "zip://www.winehq.org/tests/#Te%xx", 0, S_OK, FALSE,
2882         {
2883             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2884             {"www.winehq.org",S_OK,FALSE},
2885             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2886             {"winehq.org",S_OK,FALSE},
2887             {"",S_FALSE,FALSE},
2888             {"#Te%xx",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%xx",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 fragment aren't encoded for unknown schemes. */
2907     {   "zip://www.winehq.org/tests/#Te<|>", 0, S_OK, FALSE,
2908         {
2909             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2910             {"www.winehq.org",S_OK,FALSE},
2911             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2912             {"winehq.org",S_OK,FALSE},
2913             {"",S_FALSE,FALSE},
2914             {"#Te<|>",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             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2921             {"zip",S_OK,FALSE},
2922             {"",S_FALSE,FALSE},
2923             {"",S_FALSE,FALSE}
2924         },
2925         {
2926             {Uri_HOST_DNS,S_OK,FALSE},
2927             {0,S_FALSE,FALSE},
2928             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2929             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2930         }
2931     },
2932     /* Forbidden characters in the fragment are percent encoded for known schemes. */
2933     {   "http://www.winehq.org/tests/#Te<|>", 0, S_OK, FALSE,
2934         {
2935             {"http://www.winehq.org/tests/#Te%3C%7C%3E",S_OK,FALSE},
2936             {"www.winehq.org",S_OK,FALSE},
2937             {"http://www.winehq.org/tests/#Te%3C%7C%3E",S_OK,FALSE},
2938             {"winehq.org",S_OK,FALSE},
2939             {"",S_FALSE,FALSE},
2940             {"#Te%3C%7C%3E",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_DECODE_EXTRA_INFO, 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     /* Forbidden characters aren't encoded in the fragment with this flag. */
2985     {   "http://www.winehq.org/tests/#Te<|>", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2986         {
2987             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2988             {"www.winehq.org",S_OK,FALSE},
2989             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2990             {"winehq.org",S_OK,FALSE},
2991             {"",S_FALSE,FALSE},
2992             {"#Te<|>",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             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2999             {"http",S_OK,FALSE},
3000             {"",S_FALSE,FALSE},
3001             {"",S_FALSE,FALSE}
3002         },
3003         {
3004             {Uri_HOST_DNS,S_OK,FALSE},
3005             {80,S_OK,FALSE},
3006             {URL_SCHEME_HTTP,S_OK,FALSE},
3007             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3008         }
3009     },
3010     /* Percent encoded, unreserved characters aren't decoded for known scheme types. */
3011     {   "zip://www.winehq.org/tests/#Te%30%31%32", 0, S_OK, FALSE,
3012         {
3013             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3014             {"www.winehq.org",S_OK,FALSE},
3015             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3016             {"winehq.org",S_OK,FALSE},
3017             {"",S_FALSE,FALSE},
3018             {"#Te%30%31%32",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             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3025             {"zip",S_OK,FALSE},
3026             {"",S_FALSE,FALSE},
3027             {"",S_FALSE,FALSE}
3028         },
3029         {
3030             {Uri_HOST_DNS,S_OK,FALSE},
3031             {0,S_FALSE,FALSE},
3032             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3033             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3034         }
3035     },
3036     /* Percent encoded, unreserved characters are decoded for known schemes. */
3037     {   "http://www.winehq.org/tests/#Te%30%31%32", 0, 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 are decoded even if NO_CANONICALIZE is set. */
3063     {   "http://www.winehq.org/tests/#Te%30%31%32", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
3064         {
3065             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
3066             {"www.winehq.org",S_OK,FALSE},
3067             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
3068             {"winehq.org",S_OK,FALSE},
3069             {"",S_FALSE,FALSE},
3070             {"#Te012",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     /* Percent encoded, unreserved characters aren't decoded when NO_DECODE_EXTRA is set. */
3089     {   "http://www.winehq.org/tests/#Te%30%31%32", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
3090         {
3091             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3092             {"www.winehq.org",S_OK,FALSE},
3093             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3094             {"winehq.org",S_OK,FALSE},
3095             {"",S_FALSE,FALSE},
3096             {"#Te%30%31%32",S_OK,FALSE},
3097             {"www.winehq.org",S_OK,FALSE},
3098             {"",S_FALSE,FALSE},
3099             {"/tests/",S_OK,FALSE},
3100             {"/tests/",S_OK,FALSE},
3101             {"",S_FALSE,FALSE},
3102             {"http://www.winehq.org/tests/#Te%30%31%32",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     /* Leading/Trailing whitespace is removed. */
3115     {   "    http://google.com/     ", 0, S_OK, FALSE,
3116         {
3117             {"http://google.com/",S_OK,FALSE},
3118             {"google.com",S_OK,FALSE},
3119             {"http://google.com/",S_OK,FALSE},
3120             {"google.com",S_OK,FALSE},
3121             {"",S_FALSE,FALSE},
3122             {"",S_FALSE,FALSE},
3123             {"google.com",S_OK,FALSE},
3124             {"",S_FALSE,FALSE},
3125             {"/",S_OK,FALSE},
3126             {"/",S_OK,FALSE},
3127             {"",S_FALSE,FALSE},
3128             {"http://google.com/",S_OK,FALSE},
3129             {"http",S_OK,FALSE},
3130             {"",S_FALSE,FALSE},
3131             {"",S_FALSE,FALSE}
3132         },
3133         {
3134             {Uri_HOST_DNS,S_OK,FALSE},
3135             {80,S_OK,FALSE},
3136             {URL_SCHEME_HTTP,S_OK,FALSE},
3137             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3138         }
3139     },
3140     {   "\t\t\r\nhttp\n://g\noogle.co\rm/\n\n\n", 0, S_OK, FALSE,
3141         {
3142             {"http://google.com/",S_OK,FALSE},
3143             {"google.com",S_OK,FALSE},
3144             {"http://google.com/",S_OK,FALSE},
3145             {"google.com",S_OK,FALSE},
3146             {"",S_FALSE,FALSE},
3147             {"",S_FALSE,FALSE},
3148             {"google.com",S_OK,FALSE},
3149             {"",S_FALSE,FALSE},
3150             {"/",S_OK,FALSE},
3151             {"/",S_OK,FALSE},
3152             {"",S_FALSE,FALSE},
3153             {"http://google.com/",S_OK,FALSE},
3154             {"http",S_OK,FALSE},
3155             {"",S_FALSE,FALSE},
3156             {"",S_FALSE,FALSE}
3157         },
3158         {
3159             {Uri_HOST_DNS,S_OK,FALSE},
3160             {80,S_OK,FALSE},
3161             {URL_SCHEME_HTTP,S_OK,FALSE},
3162             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3163         }
3164     },
3165     {   "http://g\noogle.co\rm/\n\n\n", Uri_CREATE_NO_PRE_PROCESS_HTML_URI, S_OK, FALSE,
3166         {
3167             {"http://g%0aoogle.co%0dm/%0A%0A%0A",S_OK,FALSE},
3168             {"g%0aoogle.co%0dm",S_OK,FALSE},
3169             {"http://g%0aoogle.co%0dm/%0A%0A%0A",S_OK,FALSE},
3170             {"g%0aoogle.co%0dm",S_OK,FALSE},
3171             {"",S_FALSE,FALSE},
3172             {"",S_FALSE,FALSE},
3173             {"g%0aoogle.co%0dm",S_OK,FALSE},
3174             {"",S_FALSE,FALSE},
3175             {"/%0A%0A%0A",S_OK,FALSE},
3176             {"/%0A%0A%0A",S_OK,FALSE},
3177             {"",S_FALSE,FALSE},
3178             {"http://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3179             {"http",S_OK,FALSE},
3180             {"",S_FALSE,FALSE},
3181             {"",S_FALSE,FALSE}
3182         },
3183         {
3184             {Uri_HOST_DNS,S_OK,FALSE},
3185             {80,S_OK,FALSE},
3186             {URL_SCHEME_HTTP,S_OK,FALSE},
3187             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3188         }
3189     },
3190     {   "zip://g\noogle.co\rm/\n\n\n", Uri_CREATE_NO_PRE_PROCESS_HTML_URI, S_OK, FALSE,
3191         {
3192             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3193             {"g\noogle.co\rm",S_OK,FALSE},
3194             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3195             {"g\noogle.co\rm",S_OK,FALSE},
3196             {"",S_FALSE,FALSE},
3197             {"",S_FALSE,FALSE},
3198             {"g\noogle.co\rm",S_OK,FALSE},
3199             {"",S_FALSE,FALSE},
3200             {"/\n\n\n",S_OK,FALSE},
3201             {"/\n\n\n",S_OK,FALSE},
3202             {"",S_FALSE,FALSE},
3203             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3204             {"zip",S_OK,FALSE},
3205             {"",S_FALSE,FALSE},
3206             {"",S_FALSE,FALSE}
3207         },
3208         {
3209             {Uri_HOST_DNS,S_OK,FALSE},
3210             {0,S_FALSE,FALSE},
3211             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3212             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3213         }
3214     },
3215     /* Since file URLs are usually hierarchical, it returns an empty string
3216      * for the absolute URI property since it was declared as an opaque URI.
3217      */
3218     {   "file:index.html", 0, S_OK, FALSE,
3219         {
3220             {"",S_FALSE,FALSE},
3221             {"",S_FALSE,FALSE},
3222             {"file: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             {"index.html",S_OK,FALSE},
3229             {"index.html",S_OK,FALSE},
3230             {"",S_FALSE,FALSE},
3231             {"file:index.html",S_OK,FALSE},
3232             {"file",S_OK,FALSE},
3233             {"",S_FALSE,FALSE},
3234             {"",S_FALSE,FALSE}
3235         },
3236         {
3237             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3238             {0,S_FALSE,FALSE},
3239             {URL_SCHEME_FILE,S_OK,FALSE},
3240             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3241         }
3242     },
3243     /* Doesn't have an absolute since it's opaque, but gets it port set. */
3244     {   "http:test.com/index.html", 0, S_OK, FALSE,
3245         {
3246             {"",S_FALSE,FALSE},
3247             {"",S_FALSE,FALSE},
3248             {"http:test.com/index.html",S_OK,FALSE},
3249             {"",S_FALSE,FALSE},
3250             {".html",S_OK,FALSE},
3251             {"",S_FALSE,FALSE},
3252             {"",S_FALSE,FALSE},
3253             {"",S_FALSE,FALSE},
3254             {"test.com/index.html",S_OK,FALSE},
3255             {"test.com/index.html",S_OK,FALSE},
3256             {"",S_FALSE,FALSE},
3257             {"http:test.com/index.html",S_OK,FALSE},
3258             {"http",S_OK,FALSE},
3259             {"",S_FALSE,FALSE},
3260             {"",S_FALSE,FALSE}
3261         },
3262         {
3263             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3264             {80,S_OK,FALSE},
3265             {URL_SCHEME_HTTP,S_OK,FALSE},
3266             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3267         }
3268     },
3269     {   "ftp:test.com/index.html", 0, S_OK, FALSE,
3270         {
3271             {"",S_FALSE,FALSE},
3272             {"",S_FALSE,FALSE},
3273             {"ftp:test.com/index.html",S_OK,FALSE},
3274             {"",S_FALSE,FALSE},
3275             {".html",S_OK,FALSE},
3276             {"",S_FALSE,FALSE},
3277             {"",S_FALSE,FALSE},
3278             {"",S_FALSE,FALSE},
3279             {"test.com/index.html",S_OK,FALSE},
3280             {"test.com/index.html",S_OK,FALSE},
3281             {"",S_FALSE,FALSE},
3282             {"ftp:test.com/index.html",S_OK,FALSE},
3283             {"ftp",S_OK,FALSE},
3284             {"",S_FALSE,FALSE},
3285             {"",S_FALSE,FALSE}
3286         },
3287         {
3288             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3289             {21,S_OK,FALSE},
3290             {URL_SCHEME_FTP,S_OK,FALSE},
3291             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3292         }
3293     },
3294     {   "file://C|/test.mp3", 0, S_OK, FALSE,
3295         {
3296             {"file:///C:/test.mp3",S_OK,FALSE},
3297             {"",S_FALSE,FALSE},
3298             {"file:///C:/test.mp3",S_OK,FALSE},
3299             {"",S_FALSE,FALSE},
3300             {".mp3",S_OK,FALSE},
3301             {"",S_FALSE,FALSE},
3302             {"",S_FALSE,FALSE},
3303             {"",S_FALSE,FALSE},
3304             {"/C:/test.mp3",S_OK,FALSE},
3305             {"/C:/test.mp3",S_OK,FALSE},
3306             {"",S_FALSE,FALSE},
3307             {"file://C|/test.mp3",S_OK,FALSE},
3308             {"file",S_OK,FALSE},
3309             {"",S_FALSE,FALSE},
3310             {"",S_FALSE,FALSE}
3311         },
3312         {
3313             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3314             {0,S_FALSE,FALSE},
3315             {URL_SCHEME_FILE,S_OK,FALSE},
3316             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3317         }
3318     },
3319     {   "file:///C|/test.mp3", 0, S_OK, FALSE,
3320         {
3321             {"file:///C:/test.mp3",S_OK,FALSE},
3322             {"",S_FALSE,FALSE},
3323             {"file:///C:/test.mp3",S_OK,FALSE},
3324             {"",S_FALSE,FALSE},
3325             {".mp3",S_OK,FALSE},
3326             {"",S_FALSE,FALSE},
3327             {"",S_FALSE,FALSE},
3328             {"",S_FALSE,FALSE},
3329             {"/C:/test.mp3",S_OK,FALSE},
3330             {"/C:/test.mp3",S_OK,FALSE},
3331             {"",S_FALSE,FALSE},
3332             {"file:///C|/test.mp3",S_OK,FALSE},
3333             {"file",S_OK,FALSE},
3334             {"",S_FALSE,FALSE},
3335             {"",S_FALSE,FALSE}
3336         },
3337         {
3338             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3339             {0,S_FALSE,FALSE},
3340             {URL_SCHEME_FILE,S_OK,FALSE},
3341             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3342         }
3343     },
3344     /* Extra '/' isn't added before "c:" since USE_DOS_PATH is set and '/' are converted
3345      * to '\\'.
3346      */
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     /* Extra '/' after "file://" is removed. */
3373     {   "file:///c:/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3374         {
3375             {"file://c:\\dir\\index.html",S_OK,FALSE},
3376             {"",S_FALSE,FALSE},
3377             {"file://c:\\dir\\index.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\\index.html",S_OK,FALSE},
3384             {"c:\\dir\\index.html",S_OK,FALSE},
3385             {"",S_FALSE,FALSE},
3386             {"file:///c:/dir/index.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     /* Allow more characters when Uri_CREATE_FILE_USE_DOS_PATH is specified */
3399     {   "file:///c:/dir\\%%61%20%5Fname/file%2A.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3400         {
3401             {"file://c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3402             {"",S_FALSE,FALSE},
3403             {"file://c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3404             {"",S_FALSE,FALSE},
3405             {".html",S_OK,FALSE},
3406             {"",S_FALSE,FALSE},
3407             {"",S_FALSE,FALSE},
3408             {"",S_FALSE,FALSE},
3409             {"c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3410             {"c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3411             {"",S_FALSE,FALSE},
3412             {"file:///c:/dir\\%%61%20%5Fname/file%2A.html",S_OK,FALSE},
3413             {"file",S_OK,FALSE},
3414             {"",S_FALSE,FALSE},
3415             {"",S_FALSE,FALSE}
3416         },
3417         {
3418             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3419             {0,S_FALSE,FALSE},
3420             {URL_SCHEME_FILE,S_OK,FALSE},
3421             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3422         }
3423     },
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     /* The backslashes after the scheme name are converted to forward slashes. */
3450     {   "file:\\\\c:\\dir\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3451         {
3452             {"file://c:\\dir\\index.html",S_OK,FALSE},
3453             {"",S_FALSE,FALSE},
3454             {"file://c:\\dir\\index.html",S_OK,FALSE},
3455             {"",S_FALSE,FALSE},
3456             {".html",S_OK,FALSE},
3457             {"",S_FALSE,FALSE},
3458             {"",S_FALSE,FALSE},
3459             {"",S_FALSE,FALSE},
3460             {"c:\\dir\\index.html",S_OK,FALSE},
3461             {"c:\\dir\\index.html",S_OK,FALSE},
3462             {"",S_FALSE,FALSE},
3463             {"file:\\\\c:\\dir\\index.html",S_OK,FALSE},
3464             {"file",S_OK,FALSE},
3465             {"",S_FALSE,FALSE},
3466             {"",S_FALSE,FALSE}
3467         },
3468         {
3469             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3470             {0,S_FALSE,FALSE},
3471             {URL_SCHEME_FILE,S_OK,FALSE},
3472             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3473         }
3474     },
3475     {   "file:\\\\c:/dir/index.html", 0, S_OK, FALSE,
3476         {
3477             {"file:///c:/dir/index.html",S_OK,FALSE},
3478             {"",S_FALSE,FALSE},
3479             {"file:///c:/dir/index.html",S_OK,FALSE},
3480             {"",S_FALSE,FALSE},
3481             {".html",S_OK,FALSE},
3482             {"",S_FALSE,FALSE},
3483             {"",S_FALSE,FALSE},
3484             {"",S_FALSE,FALSE},
3485             {"/c:/dir/index.html",S_OK,FALSE},
3486             {"/c:/dir/index.html",S_OK,FALSE},
3487             {"",S_FALSE,FALSE},
3488             {"file:\\\\c:/dir/index.html",S_OK,FALSE},
3489             {"file",S_OK,FALSE},
3490             {"",S_FALSE,FALSE},
3491             {"",S_FALSE,FALSE}
3492         },
3493         {
3494             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3495             {0,S_FALSE,FALSE},
3496             {URL_SCHEME_FILE,S_OK,FALSE},
3497             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3498         }
3499     },
3500     {   "http:\\\\google.com", 0, S_OK, FALSE,
3501         {
3502             {"http://google.com/",S_OK,FALSE},
3503             {"google.com",S_OK,FALSE},
3504             {"http://google.com/",S_OK,FALSE},
3505             {"google.com",S_OK,FALSE},
3506             {"",S_FALSE,FALSE},
3507             {"",S_FALSE,FALSE},
3508             {"google.com",S_OK,FALSE},
3509             {"",S_FALSE,FALSE},
3510             {"/",S_OK,FALSE},
3511             {"/",S_OK,FALSE},
3512             {"",S_FALSE,FALSE},
3513             {"http:\\\\google.com",S_OK,FALSE},
3514             {"http",S_OK,FALSE},
3515             {"",S_FALSE,FALSE},
3516             {"",S_FALSE,FALSE}
3517         },
3518         {
3519             {Uri_HOST_DNS,S_OK,FALSE},
3520             {80,S_OK,FALSE},
3521             {URL_SCHEME_HTTP,S_OK,FALSE},
3522             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3523         }
3524     },
3525     /* the "\\\\" aren't converted to "//" for unknown scheme types and it's considered opaque. */
3526     {   "zip:\\\\google.com", 0, S_OK, FALSE,
3527         {
3528             {"zip:\\\\google.com",S_OK,FALSE},
3529             {"",S_FALSE,FALSE},
3530             {"zip:\\\\google.com",S_OK,FALSE},
3531             {"",S_FALSE,FALSE},
3532             {".com",S_OK,FALSE},
3533             {"",S_FALSE,FALSE},
3534             {"",S_FALSE,FALSE},
3535             {"",S_FALSE,FALSE},
3536             {"\\\\google.com",S_OK,FALSE},
3537             {"\\\\google.com",S_OK,FALSE},
3538             {"",S_FALSE,FALSE},
3539             {"zip:\\\\google.com",S_OK,FALSE},
3540             {"zip",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_UNKNOWN,S_OK,FALSE},
3548             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3549         }
3550     },
3551     /* Dot segments aren't removed. */
3552     {   "file://c:\\dir\\../..\\./index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3553         {
3554             {"file://c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3555             {"",S_FALSE,FALSE},
3556             {"file://c:\\dir\\..\\..\\.\\index.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\\..\\..\\.\\index.html",S_OK,FALSE},
3563             {"c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3564             {"",S_FALSE,FALSE},
3565             {"file://c:\\dir\\../..\\./index.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     /* Forbidden characters aren't percent encoded. */
3578     {   "file://c:\\dir\\i^|ndex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3579         {
3580             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3581             {"",S_FALSE,FALSE},
3582             {"file://c:\\dir\\i^|ndex.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\\i^|ndex.html",S_OK,FALSE},
3589             {"c:\\dir\\i^|ndex.html",S_OK,FALSE},
3590             {"",S_FALSE,FALSE},
3591             {"file://c:\\dir\\i^|ndex.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     /* The '\' are still converted to '/' even though it's an opaque file URI. */
3604     {   "file:c:\\dir\\../..\\index.html", 0, 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     /* '/' are still converted to '\' even though it's an opaque URI. */
3630     {   "file:c:/dir\\../..\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3631         {
3632             {"",S_FALSE,FALSE},
3633             {"",S_FALSE,FALSE},
3634             {"file:c:\\dir\\..\\..\\index.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:\\dir\\..\\..\\index.html",S_OK,FALSE},
3641             {"c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3642             {"",S_FALSE,FALSE},
3643             {"file:c:/dir\\../..\\index.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     /* Forbidden characters aren't percent encoded. */
3656     {   "file:c:\\in^|dex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3657         {
3658             {"",S_FALSE,FALSE},
3659             {"",S_FALSE,FALSE},
3660             {"file:c:\\in^|dex.html",S_OK,FALSE},
3661             {"",S_FALSE,FALSE},
3662             {".html",S_OK,FALSE},
3663             {"",S_FALSE,FALSE},
3664             {"",S_FALSE,FALSE},
3665             {"",S_FALSE,FALSE},
3666             {"c:\\in^|dex.html",S_OK,FALSE},
3667             {"c:\\in^|dex.html",S_OK,FALSE},
3668             {"",S_FALSE,FALSE},
3669             {"file:c:\\in^|dex.html",S_OK,FALSE},
3670             {"file",S_OK,FALSE},
3671             {"",S_FALSE,FALSE},
3672             {"",S_FALSE,FALSE}
3673         },
3674         {
3675             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3676             {0,S_FALSE,FALSE},
3677             {URL_SCHEME_FILE,S_OK,FALSE},
3678             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3679         }
3680     },
3681     /* Doesn't have a UserName since the ':' appears at the beginning of the
3682      * userinfo section.
3683      */
3684     {   "http://:password@gov.uk", 0, S_OK, FALSE,
3685         {
3686             {"http://:password@gov.uk/",S_OK,FALSE},
3687             {":password@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             {"password",S_OK,FALSE},
3694             {"/",S_OK,FALSE},
3695             {"/",S_OK,FALSE},
3696             {"",S_FALSE,FALSE},
3697             {"http://:password@gov.uk",S_OK,FALSE},
3698             {"http",S_OK,FALSE},
3699             {":password",S_OK,FALSE},
3700             {"",S_FALSE,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     /* Has a UserName since the userinfo section doesn't contain a password. */
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_FALSE,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_OK,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     /* ":@" not included in the absolute URI. */
3736     {   "http://:@gov.uk", 0, S_OK, FALSE,
3737         {
3738             {"http://gov.uk/",S_OK,FALSE,"http://:@gov.uk/"},
3739             {":@gov.uk",S_OK,FALSE},
3740             {"http://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_OK,FALSE},
3746             {"/",S_OK,FALSE},
3747             {"/",S_OK,FALSE},
3748             {"",S_FALSE,FALSE},
3749             {"http://:@gov.uk",S_OK,FALSE},
3750             {"http",S_OK,FALSE},
3751             {":",S_OK,FALSE},
3752             {"",S_FALSE,FALSE}
3753         },
3754         {
3755             {Uri_HOST_DNS,S_OK,FALSE},
3756             {80,S_OK,FALSE},
3757             {URL_SCHEME_HTTP,S_OK,FALSE},
3758             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3759         }
3760     },
3761     /* '@' is 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_FALSE,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_OK,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     /* ":@" are included because it's an unknown scheme type. */
3788     {   "zip://:@gov.uk", 0, S_OK, FALSE,
3789         {
3790             {"zip://:@gov.uk/",S_OK,FALSE},
3791             {":@gov.uk",S_OK,FALSE},
3792             {"zip://:@gov.uk/",S_OK,FALSE},
3793             {"",S_FALSE,FALSE},
3794             {"",S_FALSE,FALSE},
3795             {"",S_FALSE,FALSE},
3796             {"gov.uk",S_OK,FALSE},
3797             {"",S_OK,FALSE},
3798             {"/",S_OK,FALSE},
3799             {"/",S_OK,FALSE},
3800             {"",S_FALSE,FALSE},
3801             {"zip://:@gov.uk",S_OK,FALSE},
3802             {"zip",S_OK,FALSE},
3803             {":",S_OK,FALSE},
3804             {"",S_FALSE,FALSE}
3805         },
3806         {
3807             {Uri_HOST_DNS,S_OK,FALSE},
3808             {0,S_FALSE,FALSE},
3809             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3810             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3811         }
3812     },
3813     {   "about:blank", 0, S_OK, FALSE,
3814         {
3815             {"about:blank",S_OK,FALSE},
3816             {"",S_FALSE,FALSE},
3817             {"about:blank",S_OK,FALSE},
3818             {"",S_FALSE,FALSE},
3819             {"",S_FALSE,FALSE},
3820             {"",S_FALSE,FALSE},
3821             {"",S_FALSE,FALSE},
3822             {"",S_FALSE,FALSE},
3823             {"blank",S_OK,FALSE},
3824             {"blank",S_OK,FALSE},
3825             {"",S_FALSE,FALSE},
3826             {"about:blank",S_OK,FALSE},
3827             {"about",S_OK,FALSE},
3828             {"",S_FALSE,FALSE},
3829             {"",S_FALSE,FALSE}
3830         },
3831         {
3832             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3833             {0,S_FALSE,FALSE},
3834             {URL_SCHEME_ABOUT,S_OK,FALSE},
3835             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3836         }
3837     },
3838     {   "mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",0,S_OK,FALSE,
3839         {
3840             {"mk:@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3841             {"",S_FALSE,FALSE},
3842             {"mk:@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3843             {"",S_FALSE,FALSE},
3844             {".htm",S_OK,FALSE},
3845             {"",S_FALSE,FALSE},
3846             {"",S_FALSE,FALSE},
3847             {"",S_FALSE,FALSE},
3848             {"@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3849             {"@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3850             {"",S_FALSE,FALSE},
3851             {"mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3852             {"mk",S_OK,FALSE},
3853             {"",S_FALSE,FALSE},
3854             {"",S_FALSE,FALSE}
3855         },
3856         {
3857             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3858             {0,S_FALSE,FALSE},
3859             {URL_SCHEME_MK,S_OK,FALSE},
3860             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3861         }
3862     },
3863     {   "mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",0,S_OK,FALSE,
3864         {
3865             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3866             {"",S_FALSE,FALSE},
3867             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3868             {"",S_FALSE,FALSE},
3869             {".htm",S_OK,FALSE},
3870             {"",S_FALSE,FALSE},
3871             {"",S_FALSE,FALSE},
3872             {"",S_FALSE,FALSE},
3873             {"@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3874             {"@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3875             {"",S_FALSE,FALSE},
3876             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3877             {"mk",S_OK,FALSE},
3878             {"",S_FALSE,FALSE},
3879             {"",S_FALSE,FALSE}
3880         },
3881         {
3882             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3883             {0,S_FALSE,FALSE},
3884             {URL_SCHEME_MK,S_OK,FALSE},
3885             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3886         }
3887     },
3888     /* Two '\' are added to the URI when USE_DOS_PATH is set, and it's a UNC path. */
3889     {   "file://server/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3890         {
3891             {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
3892             {"server",S_OK,FALSE},
3893             {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
3894             {"",S_FALSE,FALSE},
3895             {".html",S_OK,FALSE},
3896             {"",S_FALSE,FALSE},
3897             {"server",S_OK,FALSE},
3898             {"",S_FALSE,FALSE},
3899             {"\\dir\\index.html",S_OK,FALSE},
3900             {"\\dir\\index.html",S_OK,FALSE},
3901             {"",S_FALSE,FALSE},
3902             {"file://server/dir/index.html",S_OK,FALSE},
3903             {"file",S_OK,FALSE},
3904             {"",S_FALSE,FALSE},
3905             {"",S_FALSE,FALSE}
3906         },
3907         {
3908             {Uri_HOST_DNS,S_OK,FALSE},
3909             {0,S_FALSE,FALSE},
3910             {URL_SCHEME_FILE,S_OK,FALSE},
3911             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3912         }
3913     },
3914     /* When CreateUri generates an IUri, it still displays the default port in the
3915      * authority.
3916      */
3917     {   "http://google.com:80/", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
3918         {
3919             {"http://google.com:80/",S_OK,FALSE},
3920             {"google.com:80",S_OK,FALSE},
3921             {"http://google.com:80/",S_OK,FALSE},
3922             {"google.com",S_OK,FALSE},
3923             {"",S_FALSE,FALSE},
3924             {"",S_FALSE,FALSE},
3925             {"google.com",S_OK,FALSE},
3926             {"",S_FALSE,FALSE},
3927             {"/",S_OK,FALSE},
3928             {"/",S_OK,FALSE},
3929             {"",S_FALSE,FALSE},
3930             {"http://google.com:80/",S_OK,FALSE},
3931             {"http",S_OK,FALSE},
3932             {"",S_FALSE,FALSE},
3933             {"",S_FALSE,FALSE}
3934         },
3935         {
3936             {Uri_HOST_DNS,S_OK,FALSE},
3937             {80,S_OK,FALSE},
3938             {URL_SCHEME_HTTP,S_OK,FALSE},
3939             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3940         }
3941     },
3942     /* For res URIs the host is everything up until the first '/'. */
3943     {   "res://C:\\dir\\file.exe/DATA/test.html", 0, S_OK, FALSE,
3944         {
3945             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3946             {"C:\\dir\\file.exe",S_OK,FALSE},
3947             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3948             {"",S_FALSE,FALSE},
3949             {".html",S_OK,FALSE},
3950             {"",S_FALSE,FALSE},
3951             {"C:\\dir\\file.exe",S_OK,FALSE},
3952             {"",S_FALSE,FALSE},
3953             {"/DATA/test.html",S_OK,FALSE},
3954             {"/DATA/test.html",S_OK,FALSE},
3955             {"",S_FALSE,FALSE},
3956             {"res://C:\\dir\\file.exe/DATA/test.html",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 URI can contain a '|' in the host name. */
3969     {   "res://c:\\di|r\\file.exe/test", 0, S_OK, FALSE,
3970         {
3971             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3972             {"c:\\di|r\\file.exe",S_OK,FALSE},
3973             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3974             {"",S_FALSE,FALSE},
3975             {"",S_FALSE,FALSE},
3976             {"",S_FALSE,FALSE},
3977             {"c:\\di|r\\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:\\di|r\\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 URIs can have invalid percent encoded values. */
3995     {   "res://c:\\dir%xx\\file.exe/test", 0, S_OK, FALSE,
3996         {
3997             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3998             {"c:\\dir%xx\\file.exe",S_OK,FALSE},
3999             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
4000             {"",S_FALSE,FALSE},
4001             {"",S_FALSE,FALSE},
4002             {"",S_FALSE,FALSE},
4003             {"c:\\dir%xx\\file.exe",S_OK,FALSE},
4004             {"",S_FALSE,FALSE},
4005             {"/test",S_OK,FALSE},
4006             {"/test",S_OK,FALSE},
4007             {"",S_FALSE,FALSE},
4008             {"res://c:\\dir%xx\\file.exe/test",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     /* Res doesn't get forbidden characters percent encoded in it's path. */
4021     {   "res://c:\\test/tes<|>t", 0, S_OK, FALSE,
4022         {
4023             {"res://c:\\test/tes<|>t",S_OK,FALSE},
4024             {"c:\\test",S_OK,FALSE},
4025             {"res://c:\\test/tes<|>t",S_OK,FALSE},
4026             {"",S_FALSE,FALSE},
4027             {"",S_FALSE,FALSE},
4028             {"",S_FALSE,FALSE},
4029             {"c:\\test",S_OK,FALSE},
4030             {"",S_FALSE,FALSE},
4031             {"/tes<|>t",S_OK,FALSE},
4032             {"/tes<|>t",S_OK,FALSE},
4033             {"",S_FALSE,FALSE},
4034             {"res://c:\\test/tes<|>t",S_OK,FALSE},
4035             {"res",S_OK,FALSE},
4036             {"",S_FALSE,FALSE},
4037             {"",S_FALSE,FALSE}
4038         },
4039         {
4040             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4041             {0,S_FALSE,FALSE},
4042             {URL_SCHEME_RES,S_OK,FALSE},
4043             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4044         }
4045     },
4046     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg", 0, S_OK, FALSE,
4047         {
4048             {"mk:@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4049             {"",S_FALSE,FALSE},
4050             {"mk:@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4051             {"",S_FALSE,FALSE},
4052             {".jpg",S_OK,FALSE},
4053             {"",S_FALSE,FALSE},
4054             {"",S_FALSE,FALSE},
4055             {"",S_FALSE,FALSE},
4056             {"@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4057             {"@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4058             {"",S_FALSE,FALSE},
4059             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4060             {"mk",S_OK,FALSE},
4061             {"",S_FALSE,FALSE},
4062             {"",S_FALSE,FALSE}
4063         },
4064         {
4065             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4066             {0,S_FALSE,FALSE},
4067             {URL_SCHEME_MK,S_OK,FALSE},
4068             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4069         }
4070     },
4071     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
4072         {
4073             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4074             {"",S_FALSE,FALSE},
4075             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4076             {"",S_FALSE,FALSE},
4077             {".jpg",S_OK,FALSE},
4078             {"",S_FALSE,FALSE},
4079             {"",S_FALSE,FALSE},
4080             {"",S_FALSE,FALSE},
4081             {"@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4082             {"@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4083             {"",S_FALSE,FALSE},
4084             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4085             {"mk",S_OK,FALSE},
4086             {"",S_FALSE,FALSE},
4087             {"",S_FALSE,FALSE}
4088         },
4089         {
4090             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4091             {0,S_FALSE,FALSE},
4092             {URL_SCHEME_MK,S_OK,FALSE},
4093             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4094         }
4095     },
4096     {   "xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg", 0, S_OK, FALSE,
4097         {
4098             {"xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4099             {"",S_FALSE,FALSE},
4100             {"xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4101             {"",S_FALSE,FALSE},
4102             {".jpg",S_OK,FALSE},
4103             {"",S_FALSE,FALSE},
4104             {"",S_FALSE,FALSE},
4105             {"",S_FALSE,FALSE},
4106             {"@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4107             {"@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4108             {"",S_FALSE,FALSE},
4109             {"xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4110             {"xx",S_OK,FALSE},
4111             {"",S_FALSE,FALSE},
4112             {"",S_FALSE,FALSE}
4113         },
4114         {
4115             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4116             {0,S_FALSE,FALSE},
4117             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
4118             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4119         }
4120     },
4121     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../../images/xxx.jpg", 0, S_OK, FALSE,
4122         {
4123             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4124             {"",S_FALSE,FALSE},
4125             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4126             {"",S_FALSE,FALSE},
4127             {".jpg",S_OK,FALSE},
4128             {"",S_FALSE,FALSE},
4129             {"",S_FALSE,FALSE},
4130             {"",S_FALSE,FALSE},
4131             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4132             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4133             {"",S_FALSE,FALSE},
4134             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../../images/xxx.jpg",S_OK,FALSE},
4135             {"mk",S_OK,FALSE},
4136             {"",S_FALSE,FALSE},
4137             {"",S_FALSE,FALSE}
4138         },
4139         {
4140             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4141             {0,S_FALSE,FALSE},
4142             {URL_SCHEME_MK,S_OK,FALSE},
4143             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4144         }
4145     },
4146     {   "mk:@MSITStore:Z:\\dir\\dir2\\..\\test.chm::/html/../../images/xxx.jpg", 0, S_OK, FALSE,
4147         {
4148             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4149             {"",S_FALSE,FALSE},
4150             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4151             {"",S_FALSE,FALSE},
4152             {".jpg",S_OK,FALSE},
4153             {"",S_FALSE,FALSE},
4154             {"",S_FALSE,FALSE},
4155             {"",S_FALSE,FALSE},
4156             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4157             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4158             {"",S_FALSE,FALSE},
4159             {"mk:@MSITStore:Z:\\dir\\dir2\\..\\test.chm::/html/../../images/xxx.jpg",S_OK,FALSE},
4160             {"mk",S_OK,FALSE},
4161             {"",S_FALSE,FALSE},
4162             {"",S_FALSE,FALSE}
4163         },
4164         {
4165             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4166             {0,S_FALSE,FALSE},
4167             {URL_SCHEME_MK,S_OK,FALSE},
4168             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4169         }
4170     },
4171     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../../../../images/xxx.jpg", 0, S_OK, FALSE,
4172         {
4173             {"mk:images/xxx.jpg",S_OK,FALSE},
4174             {"",S_FALSE,FALSE},
4175             {"mk:images/xxx.jpg",S_OK,FALSE},
4176             {"",S_FALSE,FALSE},
4177             {".jpg",S_OK,FALSE},
4178             {"",S_FALSE,FALSE},
4179             {"",S_FALSE,FALSE},
4180             {"",S_FALSE,FALSE},
4181             {"images/xxx.jpg",S_OK,FALSE},
4182             {"images/xxx.jpg",S_OK,FALSE},
4183             {"",S_FALSE,FALSE},
4184             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../../../../images/xxx.jpg",S_OK,FALSE},
4185             {"mk",S_OK,FALSE},
4186             {"",S_FALSE,FALSE},
4187             {"",S_FALSE,FALSE}
4188         },
4189         {
4190             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4191             {0,S_FALSE,FALSE},
4192             {URL_SCHEME_MK,S_OK,FALSE},
4193             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4194         }
4195     },
4196     {   "", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
4197         {
4198             {"",S_OK,FALSE},
4199             {"",S_FALSE,FALSE},
4200             {"",S_OK,FALSE},
4201             {"",S_FALSE,FALSE},
4202             {"",S_FALSE,FALSE},
4203             {"",S_FALSE,FALSE},
4204             {"",S_FALSE,FALSE},
4205             {"",S_FALSE,FALSE},
4206             {"",S_OK,FALSE},
4207             {"",S_OK,FALSE},
4208             {"",S_FALSE,FALSE},
4209             {"",S_OK,FALSE},
4210             {"",S_FALSE,FALSE},
4211             {"",S_FALSE,FALSE},
4212             {"",S_FALSE,FALSE}
4213         },
4214         {
4215             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4216             {0,S_FALSE,FALSE},
4217             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
4218             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4219         }
4220     },
4221     {   " \t ", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
4222         {
4223             {"",S_OK,FALSE},
4224             {"",S_FALSE,FALSE},
4225             {"",S_OK,FALSE},
4226             {"",S_FALSE,FALSE},
4227             {"",S_FALSE,FALSE},
4228             {"",S_FALSE,FALSE},
4229             {"",S_FALSE,FALSE},
4230             {"",S_FALSE,FALSE},
4231             {"",S_OK,FALSE},
4232             {"",S_OK,FALSE},
4233             {"",S_FALSE,FALSE},
4234             {"",S_OK,FALSE},
4235             {"",S_FALSE,FALSE},
4236             {"",S_FALSE,FALSE},
4237             {"",S_FALSE,FALSE}
4238         },
4239         {
4240             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4241             {0,S_FALSE,FALSE},
4242             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
4243             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4244         }
4245     },
4246     {   "javascript:void", 0, S_OK, FALSE,
4247         {
4248             {"javascript:void",S_OK},
4249             {"",S_FALSE},
4250             {"javascript:void",S_OK},
4251             {"",S_FALSE},
4252             {"",S_FALSE},
4253             {"",S_FALSE},
4254             {"",S_FALSE},
4255             {"",S_FALSE},
4256             {"void",S_OK},
4257             {"void",S_OK},
4258             {"",S_FALSE},
4259             {"javascript:void",S_OK},
4260             {"javascript",S_OK},
4261             {"",S_FALSE},
4262             {"",S_FALSE}
4263         },
4264         {
4265             {Uri_HOST_UNKNOWN,S_OK},
4266             {0,S_FALSE},
4267             {URL_SCHEME_JAVASCRIPT,S_OK},
4268             {URLZONE_INVALID,E_NOTIMPL}
4269         }
4270     },
4271     {   "javascript://undefined", 0, S_OK, FALSE,
4272         {
4273             {"javascript://undefined",S_OK},
4274             {"",S_FALSE},
4275             {"javascript://undefined",S_OK},
4276             {"",S_FALSE},
4277             {"",S_FALSE},
4278             {"",S_FALSE},
4279             {"",S_FALSE},
4280             {"",S_FALSE},
4281             {"//undefined",S_OK},
4282             {"//undefined",S_OK},
4283             {"",S_FALSE},
4284             {"javascript://undefined",S_OK},
4285             {"javascript",S_OK},
4286             {"",S_FALSE},
4287             {"",S_FALSE}
4288         },
4289         {
4290             {Uri_HOST_UNKNOWN,S_OK},
4291             {0,S_FALSE},
4292             {URL_SCHEME_JAVASCRIPT,S_OK},
4293             {URLZONE_INVALID,E_NOTIMPL}
4294         }
4295     },
4296     {   "JavaSCript:escape('/\\?#?')", 0, S_OK, FALSE,
4297         {
4298             {"javascript:escape('/\\?#?')",S_OK},
4299             {"",S_FALSE},
4300             {"javascript:escape('/\\?#?')",S_OK},
4301             {"",S_FALSE},
4302             {"",S_FALSE},
4303             {"",S_FALSE},
4304             {"",S_FALSE},
4305             {"",S_FALSE},
4306             {"escape('/\\?#?')",S_OK},
4307             {"escape('/\\?#?')",S_OK},
4308             {"",S_FALSE},
4309             {"JavaSCript:escape('/\\?#?')",S_OK},
4310             {"javascript",S_OK},
4311             {"",S_FALSE},
4312             {"",S_FALSE}
4313         },
4314         {
4315             {Uri_HOST_UNKNOWN,S_OK},
4316             {0,S_FALSE},
4317             {URL_SCHEME_JAVASCRIPT,S_OK},
4318             {URLZONE_INVALID,E_NOTIMPL}
4319         }
4320     },
4321     {   "*://google.com", 0, S_OK, FALSE,
4322         {
4323             {"*:google.com/",S_OK,FALSE},
4324             {"google.com",S_OK},
4325             {"*:google.com/",S_OK,FALSE},
4326             {"google.com",S_OK,FALSE},
4327             {"",S_FALSE,FALSE},
4328             {"",S_FALSE,FALSE},
4329             {"google.com",S_OK,FALSE},
4330             {"",S_FALSE,FALSE},
4331             {"/",S_OK,FALSE},
4332             {"/",S_OK,FALSE},
4333             {"",S_FALSE,FALSE},
4334             {"*://google.com",S_OK,FALSE},
4335             {"*",S_OK,FALSE},
4336             {"",S_FALSE,FALSE},
4337             {"",S_FALSE,FALSE}
4338         },
4339         {
4340             {Uri_HOST_DNS,S_OK,FALSE},
4341             {0,S_FALSE,FALSE},
4342             {URL_SCHEME_WILDCARD,S_OK,FALSE},
4343             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4344         }
4345     },
4346     {   "mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",0,S_OK,FALSE,
4347         {
4348             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",S_OK},
4349             {"",S_FALSE},
4350             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",S_OK},
4351             {"",S_FALSE},
4352             {".txt",S_OK},
4353             {"",S_FALSE},
4354             {"",S_FALSE},
4355             {"",S_FALSE},
4356             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",S_OK},
4357             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",S_OK},
4358             {"",S_FALSE},
4359             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/file.txt",S_OK},
4360             {"mk",S_OK},
4361             {"",S_FALSE},
4362             {"",S_FALSE}
4363         },
4364         {
4365             {Uri_HOST_UNKNOWN,S_OK},
4366             {0,S_FALSE},
4367             {URL_SCHEME_MK,S_OK},
4368             {URLZONE_INVALID,E_NOTIMPL}
4369         }
4370     },
4371 };
4372
4373 typedef struct _invalid_uri {
4374     const char* uri;
4375     DWORD       flags;
4376     BOOL        todo;
4377 } invalid_uri;
4378
4379 static const invalid_uri invalid_uri_tests[] = {
4380     /* Has to have a scheme name. */
4381     {"://www.winehq.org",0,FALSE},
4382     /* Window's doesn't like URI's which are implicitly file paths without the
4383      * ALLOW_IMPLICIT_FILE_SCHEME flag set.
4384      */
4385     {"C:/test/test.mp3",0,FALSE},
4386     {"\\\\Server/test/test.mp3",0,FALSE},
4387     {"C:/test/test.mp3",Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME,FALSE},
4388     {"\\\\Server/test/test.mp3",Uri_CREATE_ALLOW_RELATIVE,FALSE},
4389     /* Invalid schemes. */
4390     {"*abcd://not.valid.com",0,FALSE},
4391     {"*a*b*c*d://not.valid.com",0,FALSE},
4392     /* Not allowed to have invalid % encoded data. */
4393     {"ftp://google.co%XX/",0,FALSE},
4394     /* To many h16 components. */
4395     {"http://[1:2:3:4:5:6:7:8:9]",0,FALSE},
4396     /* Not enough room for IPv4 address. */
4397     {"http://[1:2:3:4:5:6:7:192.0.1.0]",0,FALSE},
4398     /* Not enough h16 components. */
4399     {"http://[1:2:3:4]",0,FALSE},
4400     /* Not enough components including IPv4. */
4401     {"http://[1:192.0.1.0]",0,FALSE},
4402     /* Not allowed to have partial IPv4 in IPv6. */
4403     {"http://[::192.0]",0,FALSE},
4404     /* Can't have elision of 1 h16 at beginning of address. */
4405     {"http://[::2:3:4:5:6:7:8]",0,FALSE},
4406     /* Can't have elision of 1 h16 at end of address. */
4407     {"http://[1:2:3:4:5:6:7::]",0,FALSE},
4408     /* Expects a valid IP Literal. */
4409     {"ftp://[not.valid.uri]/",0,FALSE},
4410     /* Expects valid port for a known scheme type. */
4411     {"ftp://www.winehq.org:123fgh",0,FALSE},
4412     /* Port exceeds USHORT_MAX for known scheme type. */
4413     {"ftp://www.winehq.org:65536",0,FALSE},
4414     /* Invalid port with IPv4 address. */
4415     {"http://www.winehq.org:1abcd",0,FALSE},
4416     /* Invalid port with IPv6 address. */
4417     {"http://[::ffff]:32xy",0,FALSE},
4418     /* Not allowed to have backslashes with NO_CANONICALIZE. */
4419     {"gopher://www.google.com\\test",Uri_CREATE_NO_CANONICALIZE,FALSE},
4420     /* Not allowed to have invalid % encoded data in opaque URI path. */
4421     {"news:test%XX",0,FALSE},
4422     {"mailto:wine@winehq%G8.com",0,FALSE},
4423     /* Known scheme types can't have invalid % encoded data in query string. */
4424     {"http://google.com/?query=te%xx",0,FALSE},
4425     /* Invalid % encoded data in fragment of know scheme type. */
4426     {"ftp://google.com/#Test%xx",0,FALSE},
4427     {"  http://google.com/",Uri_CREATE_NO_PRE_PROCESS_HTML_URI,FALSE},
4428     {"\n\nhttp://google.com/",Uri_CREATE_NO_PRE_PROCESS_HTML_URI,FALSE},
4429     {"file://c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4430     {"file://c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4431     {"file://c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4432     {"file:c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4433     {"file:c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4434     {"file:c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4435     /* res URIs aren't allowed to have forbidden dos path characters in the
4436      * hostname.
4437      */
4438     {"res://c:\\te<st\\test/test",0,FALSE},
4439     {"res://c:\\te>st\\test/test",0,FALSE},
4440     {"res://c:\\te\"st\\test/test",0,FALSE},
4441     {"res://c:\\test/te%xxst",0,FALSE}
4442 };
4443
4444 typedef struct _uri_equality {
4445     const char* a;
4446     DWORD       create_flags_a;
4447     const char* b;
4448     DWORD       create_flags_b;
4449     BOOL        equal;
4450     BOOL        todo;
4451 } uri_equality;
4452
4453 static const uri_equality equality_tests[] = {
4454     {
4455         "HTTP://www.winehq.org/test dir/./",0,
4456         "http://www.winehq.org/test dir/../test dir/",0,
4457         TRUE
4458     },
4459     {
4460         /* http://www.winehq.org/test%20dir */
4461         "http://%77%77%77%2E%77%69%6E%65%68%71%2E%6F%72%67/%74%65%73%74%20%64%69%72",0,
4462         "http://www.winehq.org/test dir",0,
4463         TRUE
4464     },
4465     {
4466         "c:\\test.mp3",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME,
4467         "file:///c:/test.mp3",0,
4468         TRUE
4469     },
4470     {
4471         "ftp://ftp.winehq.org/",0,
4472         "ftp://ftp.winehq.org",0,
4473         TRUE
4474     },
4475     {
4476         "ftp://ftp.winehq.org/test/test2/../../testB/",0,
4477         "ftp://ftp.winehq.org/t%45stB/",0,
4478         FALSE
4479     },
4480     {
4481         "http://google.com/TEST",0,
4482         "http://google.com/test",0,
4483         FALSE
4484     },
4485     {
4486         "http://GOOGLE.com/",0,
4487         "http://google.com/",0,
4488         TRUE
4489     },
4490     /* Performs case insensitive compare of host names (for known scheme types). */
4491     {
4492         "ftp://GOOGLE.com/",Uri_CREATE_NO_CANONICALIZE,
4493         "ftp://google.com/",0,
4494         TRUE
4495     },
4496     {
4497         "zip://GOOGLE.com/",0,
4498         "zip://google.com/",0,
4499         FALSE
4500     },
4501     {
4502         "file:///c:/TEST/TeST/",0,
4503         "file:///c:/test/test/",0,
4504         TRUE
4505     },
4506     {
4507         "file:///server/TEST",0,
4508         "file:///SERVER/TEST",0,
4509         TRUE
4510     },
4511     {
4512         "http://google.com",Uri_CREATE_NO_CANONICALIZE,
4513         "http://google.com/",0,
4514         TRUE
4515     },
4516     {
4517         "ftp://google.com:21/",0,
4518         "ftp://google.com/",0,
4519         TRUE
4520     },
4521     {
4522         "http://google.com:80/",Uri_CREATE_NO_CANONICALIZE,
4523         "http://google.com/",0,
4524         TRUE
4525     },
4526     {
4527         "http://google.com:70/",0,
4528         "http://google.com:71/",0,
4529         FALSE
4530     },
4531     {
4532         "file:///c:/dir/file.txt", 0,
4533         "file:///c:/dir/file.txt", Uri_CREATE_FILE_USE_DOS_PATH,
4534         TRUE
4535     },
4536     {
4537         "file:///c:/dir/file.txt", 0,
4538         "file:///c:\\dir\\file.txt", Uri_CREATE_NO_CANONICALIZE,
4539         TRUE
4540     },
4541     {
4542         "file:///c:/dir/file.txt", 0,
4543         "file:///c:\\dir2\\..\\dir\\file.txt", Uri_CREATE_NO_CANONICALIZE,
4544         TRUE
4545     },
4546     {
4547         "file:///c:\\dir2\\..\\ dir\\file.txt", Uri_CREATE_NO_CANONICALIZE,
4548         "file:///c:/%20dir/file.txt", 0,
4549         TRUE
4550     },
4551     {
4552         "file:///c:/Dir/file.txt", 0,
4553         "file:///C:/dir/file.TXT", Uri_CREATE_FILE_USE_DOS_PATH,
4554         TRUE
4555     },
4556     {
4557         "file:///c:/dir/file.txt", 0,
4558         "file:///c:\\dir\\file.txt", Uri_CREATE_FILE_USE_DOS_PATH,
4559         TRUE
4560     },
4561     {
4562         "file:///c:/dir/file.txt#a", 0,
4563         "file:///c:\\dir\\file.txt#b", Uri_CREATE_FILE_USE_DOS_PATH,
4564         FALSE
4565     }
4566 };
4567
4568 typedef struct _uri_with_fragment {
4569     const char* uri;
4570     const char* fragment;
4571     DWORD       create_flags;
4572     HRESULT     create_expected;
4573     BOOL        create_todo;
4574
4575     const char* expected_uri;
4576     BOOL        expected_todo;
4577 } uri_with_fragment;
4578
4579 static const uri_with_fragment uri_fragment_tests[] = {
4580     {
4581         "http://google.com/","#fragment",0,S_OK,FALSE,
4582         "http://google.com/#fragment",FALSE
4583     },
4584     {
4585         "http://google.com/","fragment",0,S_OK,FALSE,
4586         "http://google.com/#fragment",FALSE
4587     },
4588     {
4589         "zip://test.com/","?test",0,S_OK,FALSE,
4590         "zip://test.com/#?test",FALSE
4591     },
4592     /* The fragment can be empty. */
4593     {
4594         "ftp://ftp.google.com/","",0,S_OK,FALSE,
4595         "ftp://ftp.google.com/#",FALSE
4596     }
4597 };
4598
4599 typedef struct _uri_builder_property {
4600     BOOL            change;
4601     const char      *value;
4602     const char      *expected_value;
4603     Uri_PROPERTY    property;
4604     HRESULT         expected;
4605     BOOL            todo;
4606 } uri_builder_property;
4607
4608 typedef struct _uri_builder_port {
4609     BOOL    change;
4610     BOOL    set;
4611     DWORD   value;
4612     HRESULT expected;
4613     BOOL    todo;
4614 } uri_builder_port;
4615
4616 typedef struct _uri_builder_str_property {
4617     const char* expected;
4618     HRESULT     result;
4619     BOOL        todo;
4620 } uri_builder_str_property;
4621
4622 typedef struct _uri_builder_dword_property {
4623     DWORD   expected;
4624     HRESULT result;
4625     BOOL    todo;
4626 } uri_builder_dword_property;
4627
4628 typedef struct _uri_builder_test {
4629     const char                  *uri;
4630     DWORD                       create_flags;
4631     HRESULT                     create_builder_expected;
4632     BOOL                        create_builder_todo;
4633
4634     uri_builder_property        properties[URI_BUILDER_STR_PROPERTY_COUNT];
4635
4636     uri_builder_port            port_prop;
4637
4638     DWORD                       uri_flags;
4639     HRESULT                     uri_hres;
4640     BOOL                        uri_todo;
4641
4642     DWORD                       uri_simple_encode_flags;
4643     HRESULT                     uri_simple_hres;
4644     BOOL                        uri_simple_todo;
4645
4646     DWORD                       uri_with_flags;
4647     DWORD                       uri_with_builder_flags;
4648     DWORD                       uri_with_encode_flags;
4649     HRESULT                     uri_with_hres;
4650     BOOL                        uri_with_todo;
4651
4652     uri_builder_str_property    expected_str_props[URI_STR_PROPERTY_COUNT];
4653     uri_builder_dword_property  expected_dword_props[URI_DWORD_PROPERTY_COUNT];
4654 } uri_builder_test;
4655
4656 static const uri_builder_test uri_builder_tests[] = {
4657     {   "http://google.com/",0,S_OK,FALSE,
4658         {
4659             {TRUE,"#fragment",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4660             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE},
4661             {TRUE,"?query=x",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE},
4662             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4663         },
4664         {FALSE},
4665         0,S_OK,FALSE,
4666         0,S_OK,FALSE,
4667         0,0,0,S_OK,FALSE,
4668         {
4669             {"http://username:password@google.com/?query=x#fragment",S_OK},
4670             {"username:password@google.com",S_OK},
4671             {"http://google.com/?query=x#fragment",S_OK},
4672             {"google.com",S_OK},
4673             {"",S_FALSE},
4674             {"#fragment",S_OK},
4675             {"google.com",S_OK},
4676             {"password",S_OK},
4677             {"/",S_OK},
4678             {"/?query=x",S_OK},
4679             {"?query=x",S_OK},
4680             {"http://username:password@google.com/?query=x#fragment",S_OK},
4681             {"http",S_OK},
4682             {"username:password",S_OK},
4683             {"username",S_OK}
4684         },
4685         {
4686             {Uri_HOST_DNS,S_OK},
4687             {80,S_OK},
4688             {URL_SCHEME_HTTP,S_OK},
4689             {URLZONE_INVALID,E_NOTIMPL}
4690         }
4691     },
4692     {   "http://google.com/",0,S_OK,FALSE,
4693         {
4694             {TRUE,"test",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
4695         },
4696         {TRUE,TRUE,120,S_OK,FALSE},
4697         0,S_OK,FALSE,
4698         0,S_OK,FALSE,
4699         0,0,0,S_OK,FALSE,
4700         {
4701             {"test://google.com:120/",S_OK},
4702             {"google.com:120",S_OK},
4703             {"test://google.com:120/",S_OK},
4704             {"google.com",S_OK},
4705             {"",S_FALSE},
4706             {"",S_FALSE},
4707             {"google.com",S_OK},
4708             {"",S_FALSE},
4709             {"/",S_OK},
4710             {"/",S_OK},
4711             {"",S_FALSE},
4712             {"test://google.com:120/",S_OK},
4713             {"test",S_OK},
4714             {"",S_FALSE},
4715             {"",S_FALSE}
4716         },
4717         {
4718             {Uri_HOST_DNS,S_OK},
4719             {120,S_OK},
4720             {URL_SCHEME_UNKNOWN,S_OK},
4721             {URLZONE_INVALID,E_NOTIMPL}
4722         }
4723     },
4724     {   "/Test/test dir",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4725         {
4726             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
4727             {TRUE,"::192.2.3.4",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
4728             {TRUE,NULL,NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
4729         },
4730         {FALSE},
4731         0,S_OK,FALSE,
4732         0,S_OK,FALSE,
4733         0,0,0,S_OK,FALSE,
4734         {
4735             {"http://[::192.2.3.4]/",S_OK},
4736             {"[::192.2.3.4]",S_OK},
4737             {"http://[::192.2.3.4]/",S_OK},
4738             {"",S_FALSE},
4739             {"",S_FALSE},
4740             {"",S_FALSE},
4741             {"::192.2.3.4",S_OK},
4742             {"",S_FALSE},
4743             {"/",S_OK},
4744             {"/",S_OK},
4745             {"",S_FALSE},
4746             {"http://[::192.2.3.4]/",S_OK},
4747             {"http",S_OK},
4748             {"",S_FALSE},
4749             {"",S_FALSE}
4750         },
4751         {
4752             {Uri_HOST_IPV6,S_OK},
4753             {80,S_OK},
4754             {URL_SCHEME_HTTP,S_OK},
4755             {URLZONE_INVALID,E_NOTIMPL}
4756         }
4757     },
4758     {   "http://google.com/",0,S_OK,FALSE,
4759         {
4760             {TRUE,"Frag","#Frag",Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4761         },
4762         {FALSE},
4763         0,S_OK,FALSE,
4764         0,S_OK,FALSE,
4765         0,0,0,S_OK,FALSE,
4766         {
4767             {"http://google.com/#Frag",S_OK},
4768             {"google.com",S_OK},
4769             {"http://google.com/#Frag",S_OK},
4770             {"google.com",S_OK},
4771             {"",S_FALSE},
4772             {"#Frag",S_OK},
4773             {"google.com",S_OK},
4774             {"",S_FALSE},
4775             {"/",S_OK},
4776             {"/",S_OK},
4777             {"",S_FALSE},
4778             {"http://google.com/#Frag",S_OK},
4779             {"http",S_OK},
4780             {"",S_FALSE},
4781             {"",S_FALSE}
4782         },
4783         {
4784             {Uri_HOST_DNS,S_OK},
4785             {80,S_OK},
4786             {URL_SCHEME_HTTP,S_OK},
4787             {URLZONE_INVALID,E_NOTIMPL}
4788         }
4789     },
4790     {   "http://google.com/",0,S_OK,FALSE,
4791         {
4792             {TRUE,"","#",Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4793         },
4794         {FALSE},
4795         0,S_OK,FALSE,
4796         0,S_OK,FALSE,
4797         0,0,0,S_OK,FALSE,
4798         {
4799             {"http://google.com/#",S_OK},
4800             {"google.com",S_OK},
4801             {"http://google.com/#",S_OK},
4802             {"google.com",S_OK},
4803             {"",S_FALSE},
4804             {"#",S_OK},
4805             {"google.com",S_OK},
4806             {"",S_FALSE},
4807             {"/",S_OK},
4808             {"/",S_OK},
4809             {"",S_FALSE},
4810             {"http://google.com/#",S_OK},
4811             {"http",S_OK},
4812             {"",S_FALSE},
4813             {"",S_FALSE}
4814         },
4815         {
4816             {Uri_HOST_DNS,S_OK},
4817             {80,S_OK},
4818             {URL_SCHEME_HTTP,S_OK},
4819             {URLZONE_INVALID,E_NOTIMPL}
4820         }
4821     },
4822     {   "http://google.com/",0,S_OK,FALSE,
4823         {
4824             {TRUE,":password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4825         },
4826         {FALSE},
4827         0,S_OK,FALSE,
4828         0,S_OK,FALSE,
4829         0,0,0,S_OK,FALSE,
4830         {
4831             {"http://::password@google.com/",S_OK},
4832             {"::password@google.com",S_OK},
4833             {"http://google.com/",S_OK},
4834             {"google.com",S_OK},
4835             {"",S_FALSE},
4836             {"",S_FALSE},
4837             {"google.com",S_OK},
4838             {":password",S_OK},
4839             {"/",S_OK},
4840             {"/",S_OK},
4841             {"",S_FALSE},
4842             {"http://::password@google.com/",S_OK},
4843             {"http",S_OK},
4844             {"::password",S_OK},
4845             {"",S_FALSE}
4846         },
4847         {
4848             {Uri_HOST_DNS,S_OK},
4849             {80,S_OK},
4850             {URL_SCHEME_HTTP,S_OK},
4851             {URLZONE_INVALID,E_NOTIMPL}
4852         }
4853     },
4854     {   "test/test",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4855         {
4856             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4857         },
4858         {FALSE},
4859         Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4860         0,S_OK,FALSE,
4861         Uri_CREATE_ALLOW_RELATIVE,0,0,S_OK,FALSE,
4862         {
4863             {":password@test/test",S_OK},
4864             {":password@",S_OK},
4865             {":password@test/test",S_OK},
4866             {"",S_FALSE},
4867             {"",S_FALSE},
4868             {"",S_FALSE},
4869             {"",S_FALSE},
4870             {"password",S_OK},
4871             {"test/test",S_OK},
4872             {"test/test",S_OK},
4873             {"",S_FALSE},
4874             {":password@test/test",S_OK},
4875             {"",S_FALSE},
4876             {":password",S_OK},
4877             {"",S_FALSE}
4878         },
4879         {
4880             {Uri_HOST_UNKNOWN,S_OK},
4881             {0,S_FALSE},
4882             {URL_SCHEME_UNKNOWN,S_OK},
4883             {URLZONE_INVALID,E_NOTIMPL}
4884         }
4885     },
4886     {   "http://google.com/",0,S_OK,FALSE,
4887         {
4888             {TRUE,"test/test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4889         },
4890         {FALSE},
4891         0,S_OK,FALSE,
4892         0,S_OK,FALSE,
4893         0,0,0,S_OK,FALSE,
4894         {
4895             {"http://google.com/test/test",S_OK},
4896             {"google.com",S_OK},
4897             {"http://google.com/test/test",S_OK},
4898             {"google.com",S_OK},
4899             {"",S_FALSE},
4900             {"",S_FALSE},
4901             {"google.com",S_OK},
4902             {"",S_FALSE},
4903             {"/test/test",S_OK},
4904             {"/test/test",S_OK},
4905             {"",S_FALSE},
4906             {"http://google.com/test/test",S_OK},
4907             {"http",S_OK},
4908             {"",S_FALSE},
4909             {"",S_FALSE}
4910         },
4911         {
4912             {Uri_HOST_DNS,S_OK},
4913             {80,S_OK},
4914             {URL_SCHEME_HTTP,S_OK},
4915             {URLZONE_INVALID,E_NOTIMPL}
4916         }
4917     },
4918     {   "zip:testing/test",0,S_OK,FALSE,
4919         {
4920             {TRUE,"test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4921         },
4922         {FALSE},
4923         0,S_OK,FALSE,
4924         0,S_OK,FALSE,
4925         0,0,0,S_OK,FALSE,
4926         {
4927             {"zip:test",S_OK},
4928             {"",S_FALSE},
4929             {"zip:test",S_OK},
4930             {"",S_FALSE},
4931             {"",S_FALSE},
4932             {"",S_FALSE},
4933             {"",S_FALSE},
4934             {"",S_FALSE},
4935             {"test",S_OK},
4936             {"test",S_OK},
4937             {"",S_FALSE},
4938             {"zip:test",S_OK},
4939             {"zip",S_OK},
4940             {"",S_FALSE},
4941             {"",S_FALSE}
4942         },
4943         {
4944             {Uri_HOST_UNKNOWN,S_OK},
4945             {0,S_FALSE},
4946             {URL_SCHEME_UNKNOWN,S_OK},
4947             {URLZONE_INVALID,E_NOTIMPL}
4948         }
4949     },
4950     {   "http://google.com/",0,S_OK,FALSE,
4951         {
4952             {FALSE},
4953         },
4954         /* 555 will be returned from GetPort even though FALSE was passed as the hasPort parameter. */
4955         {TRUE,FALSE,555,S_OK,FALSE},
4956         0,S_OK,FALSE,
4957         0,S_OK,FALSE,
4958         0,0,0,S_OK,FALSE,
4959         {
4960             {"http://google.com/",S_OK},
4961             {"google.com",S_OK},
4962             {"http://google.com/",S_OK},
4963             {"google.com",S_OK},
4964             {"",S_FALSE},
4965             {"",S_FALSE},
4966             {"google.com",S_OK},
4967             {"",S_FALSE},
4968             {"/",S_OK},
4969             {"/",S_OK},
4970             {"",S_FALSE},
4971             {"http://google.com/",S_OK},
4972             {"http",S_OK},
4973             {"",S_FALSE},
4974             {"",S_FALSE}
4975         },
4976         {
4977             {Uri_HOST_DNS,S_OK},
4978             /* Still returns 80, even though earlier the port was disabled. */
4979             {80,S_OK},
4980             {URL_SCHEME_HTTP,S_OK},
4981             {URLZONE_INVALID,E_NOTIMPL}
4982         }
4983     },
4984     {   "http://google.com/",0,S_OK,FALSE,
4985         {
4986             {FALSE},
4987         },
4988         /* Instead of getting "TRUE" back as the "hasPort" parameter in GetPort,
4989          * you'll get 122345 instead.
4990          */
4991         {TRUE,122345,222,S_OK,FALSE},
4992         0,S_OK,FALSE,
4993         0,S_OK,FALSE,
4994         0,0,0,S_OK,FALSE,
4995         {
4996             {"http://google.com:222/",S_OK},
4997             {"google.com:222",S_OK},
4998             {"http://google.com:222/",S_OK},
4999             {"google.com",S_OK},
5000             {"",S_FALSE},
5001             {"",S_FALSE},
5002             {"google.com",S_OK},
5003             {"",S_FALSE},
5004             {"/",S_OK},
5005             {"/",S_OK},
5006             {"",S_FALSE},
5007             {"http://google.com:222/",S_OK},
5008             {"http",S_OK},
5009             {"",S_FALSE},
5010             {"",S_FALSE}
5011         },
5012         {
5013             {Uri_HOST_DNS,S_OK},
5014             {222,S_OK},
5015             {URL_SCHEME_HTTP,S_OK},
5016             {URLZONE_INVALID,E_NOTIMPL}
5017         }
5018     },
5019     /* IUri's created with the IUriBuilder can have ports that exceed USHORT_MAX. */
5020     {   "http://google.com/",0,S_OK,FALSE,
5021         {
5022             {FALSE},
5023         },
5024         {TRUE,TRUE,999999,S_OK,FALSE},
5025         0,S_OK,FALSE,
5026         0,S_OK,FALSE,
5027         0,0,0,S_OK,FALSE,
5028         {
5029             {"http://google.com:999999/",S_OK},
5030             {"google.com:999999",S_OK},
5031             {"http://google.com:999999/",S_OK},
5032             {"google.com",S_OK},
5033             {"",S_FALSE},
5034             {"",S_FALSE},
5035             {"google.com",S_OK},
5036             {"",S_FALSE},
5037             {"/",S_OK},
5038             {"/",S_OK},
5039             {"",S_FALSE},
5040             {"http://google.com:999999/",S_OK},
5041             {"http",S_OK},
5042             {"",S_FALSE},
5043             {"",S_FALSE}
5044         },
5045         {
5046             {Uri_HOST_DNS,S_OK},
5047             {999999,S_OK},
5048             {URL_SCHEME_HTTP,S_OK},
5049             {URLZONE_INVALID,E_NOTIMPL}
5050         }
5051     },
5052     {   "http://google.com/",0,S_OK,FALSE,
5053         {
5054             {TRUE,"test","?test",Uri_PROPERTY_QUERY,S_OK,FALSE},
5055         },
5056
5057         {FALSE},
5058         0,S_OK,FALSE,
5059         0,S_OK,FALSE,
5060         0,0,0,S_OK,FALSE,
5061         {
5062             {"http://google.com/?test",S_OK},
5063             {"google.com",S_OK},
5064             {"http://google.com/?test",S_OK},
5065             {"google.com",S_OK},
5066             {"",S_FALSE},
5067             {"",S_FALSE},
5068             {"google.com",S_OK},
5069             {"",S_FALSE},
5070             {"/",S_OK},
5071             {"/?test",S_OK},
5072             {"?test",S_OK},
5073             {"http://google.com/?test",S_OK},
5074             {"http",S_OK},
5075             {"",S_FALSE},
5076             {"",S_FALSE}
5077         },
5078         {
5079             {Uri_HOST_DNS,S_OK},
5080             {80,S_OK},
5081             {URL_SCHEME_HTTP,S_OK},
5082             {URLZONE_INVALID,E_NOTIMPL}
5083         }
5084     },
5085     {   "http://:password@google.com/",0,S_OK,FALSE,
5086         {
5087             {FALSE},
5088         },
5089         {FALSE},
5090         0,S_OK,FALSE,
5091         0,S_OK,FALSE,
5092         0,0,0,S_OK,FALSE,
5093         {
5094             {"http://:password@google.com/",S_OK},
5095             {":password@google.com",S_OK},
5096             {"http://google.com/",S_OK},
5097             {"google.com",S_OK},
5098             {"",S_FALSE},
5099             {"",S_FALSE},
5100             {"google.com",S_OK},
5101             {"password",S_OK},
5102             {"/",S_OK},
5103             {"/",S_OK},
5104             {"",S_FALSE},
5105             {"http://:password@google.com/",S_OK},
5106             {"http",S_OK},
5107             {":password",S_OK},
5108             {"",S_FALSE}
5109         },
5110         {
5111             {Uri_HOST_DNS,S_OK},
5112             {80,S_OK},
5113             {URL_SCHEME_HTTP,S_OK},
5114             {URLZONE_INVALID,E_NOTIMPL}
5115         }
5116     },
5117     /* IUriBuilder doesn't need a base IUri to build a IUri. */
5118     {   NULL,0,S_OK,FALSE,
5119         {
5120             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
5121             {TRUE,"google.com",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5122         },
5123         {FALSE},
5124         0,S_OK,FALSE,
5125         0,S_OK,FALSE,
5126         0,0,0,S_OK,FALSE,
5127         {
5128             {"http://google.com/",S_OK},
5129             {"google.com",S_OK},
5130             {"http://google.com/",S_OK},
5131             {"google.com",S_OK},
5132             {"",S_FALSE},
5133             {"",S_FALSE},
5134             {"google.com",S_OK},
5135             {"",S_FALSE},
5136             {"/",S_OK},
5137             {"/",S_OK},
5138             {"",S_FALSE},
5139             {"http://google.com/",S_OK},
5140             {"http",S_OK},
5141             {"",S_FALSE},
5142             {"",S_FALSE}
5143         },
5144         {
5145             {Uri_HOST_DNS,S_OK},
5146             {80,S_OK},
5147             {URL_SCHEME_HTTP,S_OK},
5148             {URLZONE_INVALID,E_NOTIMPL}
5149         }
5150     },
5151     /* Can't set the scheme name to NULL. */
5152     {   "zip://google.com/",0,S_OK,FALSE,
5153         {
5154             {TRUE,NULL,"zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
5155         },
5156         {FALSE},
5157         0,S_OK,FALSE,
5158         0,S_OK,FALSE,
5159         0,0,0,S_OK,FALSE,
5160         {
5161             {"zip://google.com/",S_OK},
5162             {"google.com",S_OK},
5163             {"zip://google.com/",S_OK},
5164             {"google.com",S_OK},
5165             {"",S_FALSE},
5166             {"",S_FALSE},
5167             {"google.com",S_OK},
5168             {"",S_FALSE},
5169             {"/",S_OK},
5170             {"/",S_OK},
5171             {"",S_FALSE},
5172             {"zip://google.com/",S_OK},
5173             {"zip",S_OK},
5174             {"",S_FALSE},
5175             {"",S_FALSE}
5176         },
5177         {
5178             {Uri_HOST_DNS,S_OK},
5179             {0,S_FALSE},
5180             {URL_SCHEME_UNKNOWN,S_OK},
5181             {URLZONE_INVALID,E_NOTIMPL}
5182         }
5183     },
5184     /* Can't set the scheme name to an empty string. */
5185     {   "zip://google.com/",0,S_OK,FALSE,
5186         {
5187             {TRUE,"","zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
5188         },
5189         {FALSE},
5190         0,S_OK,FALSE,
5191         0,S_OK,FALSE,
5192         0,0,0,S_OK,FALSE,
5193         {
5194             {"zip://google.com/",S_OK},
5195             {"google.com",S_OK},
5196             {"zip://google.com/",S_OK},
5197             {"google.com",S_OK},
5198             {"",S_FALSE},
5199             {"",S_FALSE},
5200             {"google.com",S_OK},
5201             {"",S_FALSE},
5202             {"/",S_OK},
5203             {"/",S_OK},
5204             {"",S_FALSE},
5205             {"zip://google.com/",S_OK},
5206             {"zip",S_OK},
5207             {"",S_FALSE},
5208             {"",S_FALSE}
5209         },
5210         {
5211             {Uri_HOST_DNS,S_OK},
5212             {0,S_FALSE},
5213             {URL_SCHEME_UNKNOWN,S_OK},
5214             {URLZONE_INVALID,E_NOTIMPL}
5215         }
5216     },
5217     /* -1 to CreateUri makes it use the same flags as the base IUri was created with.
5218      * CreateUriSimple always uses the flags the base IUri was created with (if any).
5219      */
5220     {   "http://google.com/../../",Uri_CREATE_NO_CANONICALIZE,S_OK,FALSE,
5221         {{FALSE}},
5222         {FALSE},
5223         -1,S_OK,FALSE,
5224         0,S_OK,FALSE,
5225         0,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5226         {
5227             {"http://google.com/../../",S_OK},
5228             {"google.com",S_OK},
5229             {"http://google.com/../../",S_OK},
5230             {"google.com",S_OK},
5231             {"",S_FALSE},
5232             {"",S_FALSE},
5233             {"google.com",S_OK},
5234             {"",S_FALSE},
5235             {"/../../",S_OK},
5236             {"/../../",S_OK},
5237             {"",S_FALSE},
5238             {"http://google.com/../../",S_OK},
5239             {"http",S_OK},
5240             {"",S_FALSE},
5241             {"",S_FALSE}
5242         },
5243         {
5244             {Uri_HOST_DNS,S_OK},
5245             {80,S_OK},
5246             {URL_SCHEME_HTTP,S_OK},
5247             {URLZONE_INVALID,E_NOTIMPL}
5248         }
5249     },
5250     {   "http://google.com/",0,S_OK,FALSE,
5251         {
5252             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5253         },
5254         {FALSE},
5255         -1,S_OK,FALSE,
5256         0,S_OK,FALSE,
5257         Uri_CREATE_NO_DECODE_EXTRA_INFO,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5258         {
5259             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5260             {"google.com",S_OK},
5261             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5262             {"google.com",S_OK},
5263             {"",S_FALSE},
5264             {"#Fr%3C%7C%3Eg",S_OK},
5265             {"google.com",S_OK},
5266             {"",S_FALSE},
5267             {"/",S_OK},
5268             {"/",S_OK},
5269             {"",S_FALSE},
5270             {"http://google.com/#Fr<|>g",S_OK},
5271             {"http",S_OK},
5272             {"",S_FALSE},
5273             {"",S_FALSE}
5274         },
5275         {
5276             {Uri_HOST_DNS,S_OK},
5277             {80,S_OK},
5278             {URL_SCHEME_HTTP,S_OK},
5279             {URLZONE_INVALID,E_NOTIMPL}
5280         }
5281     },
5282     {   "http://google.com/",0,S_OK,FALSE,
5283         {
5284             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5285         },
5286         {FALSE},
5287         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,E_INVALIDARG,FALSE,
5288         0,S_OK,FALSE,
5289         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5290         {
5291             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5292             {"google.com",S_OK},
5293             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5294             {"google.com",S_OK},
5295             {"",S_FALSE},
5296             {"#Fr%3C%7C%3Eg",S_OK},
5297             {"google.com",S_OK},
5298             {"",S_FALSE},
5299             {"/",S_OK},
5300             {"/",S_OK},
5301             {"",S_FALSE},
5302             {"http://google.com/#Fr<|>g",S_OK},
5303             {"http",S_OK},
5304             {"",S_FALSE},
5305             {"",S_FALSE}
5306         },
5307         {
5308             {Uri_HOST_DNS,S_OK},
5309             {80,S_OK},
5310             {URL_SCHEME_HTTP,S_OK},
5311             {URLZONE_INVALID,E_NOTIMPL}
5312         }
5313     },
5314     {   NULL,0,S_OK,FALSE,
5315         {
5316             {TRUE,"/test/test/",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
5317             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,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,"ht%xxtp",NULL,Uri_PROPERTY_SCHEME_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     /* File scheme's can't have a username set. */
5334     {   "file://google.com/",0,S_OK,FALSE,
5335         {
5336             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5337         },
5338         {FALSE},
5339         0,INET_E_INVALID_URL,FALSE,
5340         0,INET_E_INVALID_URL,FALSE,
5341         0,0,0,INET_E_INVALID_URL,FALSE
5342     },
5343     /* File schemes can't have a password set. */
5344     {   "file://google.com/",0,S_OK,FALSE,
5345         {
5346             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5347         },
5348         {FALSE},
5349         0,INET_E_INVALID_URL,FALSE,
5350         0,INET_E_INVALID_URL,FALSE,
5351         0,0,0,INET_E_INVALID_URL,FALSE
5352     },
5353     /* UserName can't contain any character that is a delimeter for another
5354      * component that appears after it in a normal URI.
5355      */
5356     {   "http://google.com/",0,S_OK,FALSE,
5357         {
5358             {TRUE,"user:pass",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5359         },
5360         {FALSE},
5361         0,INET_E_INVALID_URL,FALSE,
5362         0,INET_E_INVALID_URL,FALSE,
5363         0,0,0,INET_E_INVALID_URL,FALSE
5364     },
5365     {   "http://google.com/",0,S_OK,FALSE,
5366         {
5367             {TRUE,"user@google.com",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5368         },
5369         {FALSE},
5370         0,INET_E_INVALID_URL,FALSE,
5371         0,INET_E_INVALID_URL,FALSE,
5372         0,0,0,INET_E_INVALID_URL,FALSE
5373     },
5374     {   "http://google.com/",0,S_OK,FALSE,
5375         {
5376             {TRUE,"user/path",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5377         },
5378         {FALSE},
5379         0,INET_E_INVALID_URL,FALSE,
5380         0,INET_E_INVALID_URL,FALSE,
5381         0,0,0,INET_E_INVALID_URL,FALSE
5382     },
5383     {   "http://google.com/",0,S_OK,FALSE,
5384         {
5385             {TRUE,"user?Query",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5386         },
5387         {FALSE},
5388         0,INET_E_INVALID_URL,FALSE,
5389         0,INET_E_INVALID_URL,FALSE,
5390         0,0,0,INET_E_INVALID_URL,FALSE
5391     },
5392     {   "http://google.com/",0,S_OK,FALSE,
5393         {
5394             {TRUE,"user#Frag",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5395         },
5396         {FALSE},
5397         0,INET_E_INVALID_URL,FALSE,
5398         0,INET_E_INVALID_URL,FALSE,
5399         0,0,0,INET_E_INVALID_URL,FALSE
5400     },
5401     {   "http://google.com/",0,S_OK,FALSE,
5402         {
5403             {TRUE,"pass@google.com",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5404         },
5405         {FALSE},
5406         0,INET_E_INVALID_URL,FALSE,
5407         0,INET_E_INVALID_URL,FALSE,
5408         0,0,0,INET_E_INVALID_URL,FALSE
5409     },
5410     {   "http://google.com/",0,S_OK,FALSE,
5411         {
5412             {TRUE,"pass/path",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5413         },
5414         {FALSE},
5415         0,INET_E_INVALID_URL,FALSE,
5416         0,INET_E_INVALID_URL,FALSE,
5417         0,0,0,INET_E_INVALID_URL,FALSE
5418     },
5419     {   "http://google.com/",0,S_OK,FALSE,
5420         {
5421             {TRUE,"pass?query",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5422         },
5423         {FALSE},
5424         0,INET_E_INVALID_URL,FALSE,
5425         0,INET_E_INVALID_URL,FALSE,
5426        0,0,0,INET_E_INVALID_URL,FALSE
5427     },
5428     {   "http://google.com/",0,S_OK,FALSE,
5429         {
5430             {TRUE,"pass#frag",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5431         },
5432         {FALSE},
5433         0,INET_E_INVALID_URL,FALSE,
5434         0,INET_E_INVALID_URL,FALSE,
5435         0,0,0,INET_E_INVALID_URL,FALSE
5436     },
5437     {   "http://google.com/",0,S_OK,FALSE,
5438         {
5439             {TRUE,"winehq.org/test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5440         },
5441         {FALSE},
5442         0,INET_E_INVALID_URL,FALSE,
5443         0,INET_E_INVALID_URL,FALSE,
5444         0,0,0,INET_E_INVALID_URL,FALSE
5445     },
5446     {   "http://google.com/",0,S_OK,FALSE,
5447         {
5448             {TRUE,"winehq.org?test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5449         },
5450         {FALSE},
5451         0,INET_E_INVALID_URL,FALSE,
5452         0,INET_E_INVALID_URL,FALSE,
5453         0,0,0,INET_E_INVALID_URL,FALSE
5454     },
5455     {   "http://google.com/",0,S_OK,FALSE,
5456         {
5457             {TRUE,"winehq.org#test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5458         },
5459         {FALSE},
5460         0,INET_E_INVALID_URL,FALSE,
5461         0,INET_E_INVALID_URL,FALSE,
5462         0,0,0,INET_E_INVALID_URL,FALSE
5463     },
5464     /* Hostname is allowed to contain a ':' (even for known scheme types). */
5465     {   "http://google.com/",0,S_OK,FALSE,
5466         {
5467             {TRUE,"winehq.org:test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
5468         },
5469         {FALSE},
5470         0,S_OK,FALSE,
5471         0,S_OK,FALSE,
5472         0,0,0,S_OK,FALSE,
5473         {
5474             {"http://winehq.org:test/",S_OK},
5475             {"winehq.org:test",S_OK},
5476             {"http://winehq.org:test/",S_OK},
5477             {"winehq.org:test",S_OK},
5478             {"",S_FALSE},
5479             {"",S_FALSE},
5480             {"winehq.org:test",S_OK},
5481             {"",S_FALSE},
5482             {"/",S_OK},
5483             {"/",S_OK},
5484             {"",S_FALSE},
5485             {"http://winehq.org:test/",S_OK},
5486             {"http",S_OK},
5487             {"",S_FALSE},
5488             {"",S_FALSE}
5489         },
5490         {
5491             {Uri_HOST_DNS,S_OK},
5492             {80,S_OK},
5493             {URL_SCHEME_HTTP,S_OK},
5494             {URLZONE_INVALID,E_NOTIMPL}
5495         }
5496     },
5497     /* Can't set the host name to NULL. */
5498     {   "http://google.com/",0,S_OK,FALSE,
5499         {
5500             {TRUE,NULL,"google.com",Uri_PROPERTY_HOST,E_INVALIDARG,FALSE}
5501         },
5502         {FALSE},
5503         0,S_OK,FALSE,
5504         0,S_OK,FALSE,
5505         0,0,0,S_OK,FALSE,
5506         {
5507             {"http://google.com/",S_OK},
5508             {"google.com",S_OK},
5509             {"http://google.com/",S_OK},
5510             {"google.com",S_OK},
5511             {"",S_FALSE},
5512             {"",S_FALSE},
5513             {"google.com",S_OK},
5514             {"",S_FALSE},
5515             {"/",S_OK},
5516             {"/",S_OK},
5517             {"",S_FALSE},
5518             {"http://google.com/",S_OK},
5519             {"http",S_OK},
5520             {"",S_FALSE},
5521             {"",S_FALSE}
5522         },
5523         {
5524             {Uri_HOST_DNS,S_OK},
5525             {80,S_OK},
5526             {URL_SCHEME_HTTP,S_OK},
5527             {URLZONE_INVALID,E_NOTIMPL}
5528         }
5529     },
5530     /* Can set the host name to an empty string. */
5531     {   "http://google.com/",0,S_OK,FALSE,
5532         {
5533             {TRUE,"",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5534         },
5535         {FALSE},
5536         0,S_OK,FALSE,
5537         0,S_OK,FALSE,
5538         0,0,0,S_OK,FALSE,
5539         {
5540             {"http:///",S_OK},
5541             {"",S_OK},
5542             {"http:///",S_OK},
5543             {"",S_FALSE},
5544             {"",S_FALSE},
5545             {"",S_FALSE},
5546             {"",S_OK},
5547             {"",S_FALSE},
5548             {"/",S_OK},
5549             {"/",S_OK},
5550             {"",S_FALSE},
5551             {"http:///",S_OK},
5552             {"http",S_OK},
5553             {"",S_FALSE},
5554             {"",S_FALSE}
5555         },
5556         {
5557             {Uri_HOST_UNKNOWN,S_OK},
5558             {80,S_OK},
5559             {URL_SCHEME_HTTP,S_OK},
5560             {URLZONE_INVALID,E_NOTIMPL}
5561         }
5562     },
5563     {   "http://google.com/",0,S_OK,FALSE,
5564         {
5565             {TRUE,"/path?query",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5566         },
5567         {FALSE},
5568         0,INET_E_INVALID_URL,FALSE,
5569         0,INET_E_INVALID_URL,FALSE,
5570         0,0,0,INET_E_INVALID_URL,FALSE
5571     },
5572     {   "http://google.com/",0,S_OK,FALSE,
5573         {
5574             {TRUE,"/path#test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5575         },
5576         {FALSE},
5577         0,INET_E_INVALID_URL,FALSE,
5578         0,INET_E_INVALID_URL,FALSE,
5579         0,0,0,INET_E_INVALID_URL,FALSE
5580     },
5581     {   "http://google.com/",0,S_OK,FALSE,
5582         {
5583             {TRUE,"?path#test",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE}
5584         },
5585         {FALSE},
5586         0,INET_E_INVALID_URL,FALSE,
5587         0,INET_E_INVALID_URL,FALSE,
5588         0,0,0,INET_E_INVALID_URL,FALSE
5589     },
5590     {   "file:///c:/dir/file.html",0,S_OK,FALSE,
5591         {
5592             {TRUE,NULL,NULL,Uri_PROPERTY_FRAGMENT,S_OK},
5593         },
5594         {FALSE},
5595         0,S_OK,FALSE,
5596         0,S_OK,FALSE,
5597         0,0,0,S_OK,FALSE,
5598         {
5599             {"file:///c:/dir/file.html",S_OK},
5600             {"",S_FALSE},
5601             {"file:///c:/dir/file.html",S_OK},
5602             {"",S_FALSE},
5603             {".html",S_OK},
5604             {"",S_FALSE},
5605             {"",S_FALSE},
5606             {"",S_FALSE},
5607             {"/c:/dir/file.html",S_OK},
5608             {"/c:/dir/file.html",S_OK},
5609             {"",S_FALSE},
5610             {"file:///c:/dir/file.html",S_OK},
5611             {"file",S_OK},
5612             {"",S_FALSE},
5613             {"",S_FALSE}
5614         },
5615         {
5616             {Uri_HOST_UNKNOWN,S_OK},
5617             {0,S_FALSE},
5618             {URL_SCHEME_FILE,S_OK},
5619             {URLZONE_INVALID,E_NOTIMPL}
5620         }
5621     },
5622     {   "file:///c:/dir/file.html",0,S_OK,FALSE,
5623         {
5624             {TRUE,"#",NULL,Uri_PROPERTY_FRAGMENT,S_OK},
5625         },
5626         {FALSE},
5627         0,S_OK,FALSE,
5628         0,S_OK,FALSE,
5629         0,0,0,S_OK,FALSE,
5630         {
5631             {"file:///c:/dir/file.html#",S_OK},
5632             {"",S_FALSE},
5633             {"file:///c:/dir/file.html#",S_OK},
5634             {"",S_FALSE},
5635             {".html",S_OK},
5636             {"#",S_OK},
5637             {"",S_FALSE},
5638             {"",S_FALSE},
5639             {"/c:/dir/file.html",S_OK},
5640             {"/c:/dir/file.html",S_OK},
5641             {"",S_FALSE},
5642             {"file:///c:/dir/file.html#",S_OK},
5643             {"file",S_OK},
5644             {"",S_FALSE},
5645             {"",S_FALSE}
5646         },
5647         {
5648             {Uri_HOST_UNKNOWN,S_OK},
5649             {0,S_FALSE},
5650             {URL_SCHEME_FILE,S_OK},
5651             {URLZONE_INVALID,E_NOTIMPL}
5652         }
5653     }
5654 };
5655
5656 typedef struct _uri_builder_remove_test {
5657     const char  *uri;
5658     DWORD       create_flags;
5659     HRESULT     create_builder_expected;
5660     BOOL        create_builder_todo;
5661
5662     DWORD       remove_properties;
5663     HRESULT     remove_expected;
5664     BOOL        remove_todo;
5665
5666     const char  *expected_uri;
5667     DWORD       expected_flags;
5668     HRESULT     expected_hres;
5669     BOOL        expected_todo;
5670 } uri_builder_remove_test;
5671
5672 static const uri_builder_remove_test uri_builder_remove_tests[] = {
5673     {   "http://google.com/test?test=y#Frag",0,S_OK,FALSE,
5674         Uri_HAS_FRAGMENT|Uri_HAS_PATH|Uri_HAS_QUERY,S_OK,FALSE,
5675         "http://google.com/",0,S_OK,FALSE
5676     },
5677     {   "http://user:pass@winehq.org/",0,S_OK,FALSE,
5678         Uri_HAS_USER_NAME|Uri_HAS_PASSWORD,S_OK,FALSE,
5679         "http://winehq.org/",0,S_OK,FALSE
5680     },
5681     {   "zip://google.com?Test=x",0,S_OK,FALSE,
5682         Uri_HAS_HOST,S_OK,FALSE,
5683         "zip:/?Test=x",0,S_OK,FALSE
5684     },
5685     /* Doesn't remove the whole userinfo component. */
5686     {   "http://username:pass@google.com/",0,S_OK,FALSE,
5687         Uri_HAS_USER_INFO,S_OK,FALSE,
5688         "http://username:pass@google.com/",0,S_OK,FALSE
5689     },
5690     /* Doesn't remove the domain. */
5691     {   "http://google.com/",0,S_OK,FALSE,
5692         Uri_HAS_DOMAIN,S_OK,FALSE,
5693         "http://google.com/",0,S_OK,FALSE
5694     },
5695     {   "http://google.com:120/",0,S_OK,FALSE,
5696         Uri_HAS_AUTHORITY,S_OK,FALSE,
5697         "http://google.com:120/",0,S_OK,FALSE
5698     },
5699     {   "http://google.com/test.com/",0,S_OK,FALSE,
5700         Uri_HAS_EXTENSION,S_OK,FALSE,
5701         "http://google.com/test.com/",0,S_OK,FALSE
5702     },
5703     {   "http://google.com/?test=x",0,S_OK,FALSE,
5704         Uri_HAS_PATH_AND_QUERY,S_OK,FALSE,
5705         "http://google.com/?test=x",0,S_OK,FALSE
5706     },
5707     /* Can't remove the scheme name. */
5708     {   "http://google.com/?test=x",0,S_OK,FALSE,
5709         Uri_HAS_SCHEME_NAME|Uri_HAS_QUERY,E_INVALIDARG,FALSE,
5710         "http://google.com/?test=x",0,S_OK,FALSE
5711     }
5712 };
5713
5714 typedef struct _uri_combine_str_property {
5715     const char  *value;
5716     HRESULT     expected;
5717     BOOL        todo;
5718     const char  *broken_value;
5719     const char  *value_ex;
5720 } uri_combine_str_property;
5721
5722 typedef struct _uri_combine_test {
5723     const char  *base_uri;
5724     DWORD       base_create_flags;
5725     const char  *relative_uri;
5726     DWORD       relative_create_flags;
5727     DWORD       combine_flags;
5728     HRESULT     expected;
5729     BOOL        todo;
5730
5731     uri_combine_str_property    str_props[URI_STR_PROPERTY_COUNT];
5732     uri_dword_property          dword_props[URI_DWORD_PROPERTY_COUNT];
5733 } uri_combine_test;
5734
5735 static const uri_combine_test uri_combine_tests[] = {
5736     {   "http://google.com/fun/stuff",0,
5737         "../not/fun/stuff",Uri_CREATE_ALLOW_RELATIVE,
5738         0,S_OK,FALSE,
5739         {
5740             {"http://google.com/not/fun/stuff",S_OK},
5741             {"google.com",S_OK},
5742             {"http://google.com/not/fun/stuff",S_OK},
5743             {"google.com",S_OK},
5744             {"",S_FALSE},
5745             {"",S_FALSE},
5746             {"google.com",S_OK},
5747             {"",S_FALSE},
5748             {"/not/fun/stuff",S_OK},
5749             {"/not/fun/stuff",S_OK},
5750             {"",S_FALSE},
5751             {"http://google.com/not/fun/stuff",S_OK},
5752             {"http",S_OK},
5753             {"",S_FALSE},
5754             {"",S_FALSE}
5755         },
5756         {
5757             {Uri_HOST_DNS,S_OK},
5758             {80,S_OK},
5759             {URL_SCHEME_HTTP,S_OK},
5760             {URLZONE_INVALID,E_NOTIMPL}
5761         }
5762     },
5763     {   "http://google.com/test",0,
5764         "zip://test.com/cool",0,
5765         0,S_OK,FALSE,
5766         {
5767             {"zip://test.com/cool",S_OK},
5768             {"test.com",S_OK},
5769             {"zip://test.com/cool",S_OK},
5770             {"test.com",S_OK},
5771             {"",S_FALSE},
5772             {"",S_FALSE},
5773             {"test.com",S_OK},
5774             {"",S_FALSE},
5775             {"/cool",S_OK},
5776             {"/cool",S_OK},
5777             {"",S_FALSE},
5778             {"zip://test.com/cool",S_OK},
5779             {"zip",S_OK},
5780             {"",S_FALSE},
5781             {"",S_FALSE}
5782         },
5783         {
5784             {Uri_HOST_DNS,S_OK},
5785             {0,S_FALSE},
5786             {URL_SCHEME_UNKNOWN,S_OK},
5787             {URLZONE_INVALID,E_NOTIMPL}
5788         }
5789     },
5790     {   "http://google.com/use/base/path",0,
5791         "?relative",Uri_CREATE_ALLOW_RELATIVE,
5792         0,S_OK,FALSE,
5793         {
5794             {"http://google.com/use/base/path?relative",S_OK},
5795             {"google.com",S_OK},
5796             {"http://google.com/use/base/path?relative",S_OK},
5797             {"google.com",S_OK},
5798             {"",S_FALSE},
5799             {"",S_FALSE},
5800             {"google.com",S_OK},
5801             {"",S_FALSE},
5802             {"/use/base/path",S_OK},
5803             {"/use/base/path?relative",S_OK},
5804             {"?relative",S_OK},
5805             {"http://google.com/use/base/path?relative",S_OK},
5806             {"http",S_OK},
5807             {"",S_FALSE},
5808             {"",S_FALSE}
5809         },
5810         {
5811             {Uri_HOST_DNS,S_OK},
5812             {80,S_OK},
5813             {URL_SCHEME_HTTP,S_OK},
5814             {URLZONE_INVALID,E_NOTIMPL}
5815         }
5816     },
5817     {   "http://google.com/path",0,
5818         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5819         0,S_OK,FALSE,
5820         {
5821             {"http://google.com/testing",S_OK},
5822             {"google.com",S_OK},
5823             {"http://google.com/testing",S_OK},
5824             {"google.com",S_OK},
5825             {"",S_FALSE},
5826             {"",S_FALSE},
5827             {"google.com",S_OK},
5828             {"",S_FALSE},
5829             {"/testing",S_OK},
5830             {"/testing",S_OK},
5831             {"",S_FALSE},
5832             {"http://google.com/testing",S_OK},
5833             {"http",S_OK},
5834             {"",S_FALSE},
5835             {"",S_FALSE}
5836         },
5837         {
5838             {Uri_HOST_DNS,S_OK},
5839             {80,S_OK},
5840             {URL_SCHEME_HTTP,S_OK},
5841             {URLZONE_INVALID,E_NOTIMPL}
5842         }
5843     },
5844     {   "http://google.com/path",0,
5845         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5846         URL_DONT_SIMPLIFY,S_OK,FALSE,
5847         {
5848             {"http://google.com:80/test/../test/.././testing",S_OK},
5849             {"google.com",S_OK},
5850             {"http://google.com:80/test/../test/.././testing",S_OK},
5851             {"google.com",S_OK},
5852             {"",S_FALSE},
5853             {"",S_FALSE},
5854             {"google.com",S_OK},
5855             {"",S_FALSE},
5856             {"/test/../test/.././testing",S_OK},
5857             {"/test/../test/.././testing",S_OK},
5858             {"",S_FALSE},
5859             {"http://google.com:80/test/../test/.././testing",S_OK},
5860             {"http",S_OK},
5861             {"",S_FALSE},
5862             {"",S_FALSE}
5863         },
5864         {
5865             {Uri_HOST_DNS,S_OK},
5866             {80,S_OK},
5867             {URL_SCHEME_HTTP,S_OK},
5868             {URLZONE_INVALID,E_NOTIMPL}
5869         }
5870     },
5871     {   "http://winehq.org/test/abc",0,
5872         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5873         0,S_OK,FALSE,
5874         {
5875             {"http://winehq.org/test/testing/test",S_OK},
5876             {"winehq.org",S_OK},
5877             {"http://winehq.org/test/testing/test",S_OK},
5878             {"winehq.org",S_OK},
5879             {"",S_FALSE},
5880             {"",S_FALSE},
5881             {"winehq.org",S_OK},
5882             {"",S_FALSE},
5883             {"/test/testing/test",S_OK},
5884             {"/test/testing/test",S_OK},
5885             {"",S_FALSE},
5886             {"http://winehq.org/test/testing/test",S_OK},
5887             {"http",S_OK},
5888             {"",S_FALSE},
5889             {"",S_FALSE}
5890         },
5891         {
5892             {Uri_HOST_DNS,S_OK},
5893             {80,S_OK},
5894             {URL_SCHEME_HTTP,S_OK},
5895             {URLZONE_INVALID,E_NOTIMPL}
5896         }
5897     },
5898     {   "http://winehq.org/test/abc",0,
5899         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5900         URL_DONT_SIMPLIFY,S_OK,FALSE,
5901         {
5902             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5903             /* Default port is hidden in the authority. */
5904             {"winehq.org",S_OK},
5905             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5906             {"winehq.org",S_OK},
5907             {"",S_FALSE},
5908             {"",S_FALSE},
5909             {"winehq.org",S_OK},
5910             {"",S_FALSE},
5911             {"/test/testing/abc/../test",S_OK},
5912             {"/test/testing/abc/../test",S_OK},
5913             {"",S_FALSE},
5914             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5915             {"http",S_OK},
5916             {"",S_FALSE},
5917             {"",S_FALSE}
5918         },
5919         {
5920             {Uri_HOST_DNS,S_OK},
5921             {80,S_OK},
5922             {URL_SCHEME_HTTP,S_OK},
5923             {URLZONE_INVALID,E_NOTIMPL}
5924         }
5925     },
5926     {   "http://winehq.org/test?query",0,
5927         "testing",Uri_CREATE_ALLOW_RELATIVE,
5928         0,S_OK,FALSE,
5929         {
5930             {"http://winehq.org/testing",S_OK},
5931             {"winehq.org",S_OK},
5932             {"http://winehq.org/testing",S_OK},
5933             {"winehq.org",S_OK},
5934             {"",S_FALSE},
5935             {"",S_FALSE},
5936             {"winehq.org",S_OK},
5937             {"",S_FALSE},
5938             {"/testing",S_OK},
5939             {"/testing",S_OK},
5940             {"",S_FALSE},
5941             {"http://winehq.org/testing",S_OK},
5942             {"http",S_OK},
5943             {"",S_FALSE},
5944             {"",S_FALSE}
5945         },
5946         {
5947             {Uri_HOST_DNS,S_OK},
5948             {80,S_OK},
5949             {URL_SCHEME_HTTP,S_OK},
5950             {URLZONE_INVALID,E_NOTIMPL}
5951         }
5952     },
5953     {   "http://winehq.org/test#frag",0,
5954         "testing",Uri_CREATE_ALLOW_RELATIVE,
5955         0,S_OK,FALSE,
5956         {
5957             {"http://winehq.org/testing",S_OK},
5958             {"winehq.org",S_OK},
5959             {"http://winehq.org/testing",S_OK},
5960             {"winehq.org",S_OK},
5961             {"",S_FALSE},
5962             {"",S_FALSE},
5963             {"winehq.org",S_OK},
5964             {"",S_FALSE},
5965             {"/testing",S_OK},
5966             {"/testing",S_OK},
5967             {"",S_FALSE},
5968             {"http://winehq.org/testing",S_OK},
5969             {"http",S_OK},
5970             {"",S_FALSE},
5971             {"",S_FALSE}
5972         },
5973         {
5974             {Uri_HOST_DNS,S_OK},
5975             {80,S_OK},
5976             {URL_SCHEME_HTTP,S_OK},
5977             {URLZONE_INVALID,E_NOTIMPL}
5978         }
5979     },
5980     {   "testing?query#frag",Uri_CREATE_ALLOW_RELATIVE,
5981         "test",Uri_CREATE_ALLOW_RELATIVE,
5982         0,S_OK,FALSE,
5983         {
5984             {"test",S_OK},
5985             {"",S_FALSE},
5986             {"test",S_OK},
5987             {"",S_FALSE},
5988             {"",S_FALSE},
5989             {"",S_FALSE},
5990             {"",S_FALSE},
5991             {"",S_FALSE},
5992             {"test",S_OK},
5993             {"test",S_OK},
5994             {"",S_FALSE},
5995             {"test",S_OK},
5996             {"",S_FALSE},
5997             {"",S_FALSE},
5998             {"",S_FALSE}
5999         },
6000         {
6001             {Uri_HOST_UNKNOWN,S_OK},
6002             {0,S_FALSE},
6003             {URL_SCHEME_UNKNOWN,S_OK},
6004             {URLZONE_INVALID,E_NOTIMPL}
6005         }
6006     },
6007     {   "file:///c:/test/test",0,
6008         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
6009         URL_FILE_USE_PATHURL,S_OK,FALSE,
6010         {
6011             {"file://c:\\testing.mp3",S_OK},
6012             {"",S_FALSE},
6013             {"file://c:\\testing.mp3",S_OK},
6014             {"",S_FALSE},
6015             {".mp3",S_OK},
6016             {"",S_FALSE},
6017             {"",S_FALSE},
6018             {"",S_FALSE},
6019             {"c:\\testing.mp3",S_OK},
6020             {"c:\\testing.mp3",S_OK},
6021             {"",S_FALSE},
6022             {"file://c:\\testing.mp3",S_OK},
6023             {"file",S_OK},
6024             {"",S_FALSE},
6025             {"",S_FALSE}
6026         },
6027         {
6028             {Uri_HOST_UNKNOWN,S_OK},
6029             {0,S_FALSE},
6030             {URL_SCHEME_FILE,S_OK},
6031             {URLZONE_INVALID,E_NOTIMPL}
6032         }
6033     },
6034     {   "file:///c:/test/test",0,
6035         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
6036         0,S_OK,FALSE,
6037         {
6038             {"file:///c:/testing.mp3",S_OK},
6039             {"",S_FALSE},
6040             {"file:///c:/testing.mp3",S_OK},
6041             {"",S_FALSE},
6042             {".mp3",S_OK},
6043             {"",S_FALSE},
6044             {"",S_FALSE},
6045             {"",S_FALSE},
6046             {"/c:/testing.mp3",S_OK},
6047             {"/c:/testing.mp3",S_OK},
6048             {"",S_FALSE},
6049             {"file:///c:/testing.mp3",S_OK},
6050             {"file",S_OK},
6051             {"",S_FALSE},
6052             {"",S_FALSE}
6053         },
6054         {
6055             {Uri_HOST_UNKNOWN,S_OK},
6056             {0,S_FALSE},
6057             {URL_SCHEME_FILE,S_OK},
6058             {URLZONE_INVALID,E_NOTIMPL}
6059         }
6060     },
6061     {   "file://test.com/test/test",0,
6062         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
6063         URL_FILE_USE_PATHURL,S_OK,FALSE,
6064         {
6065             {"file://\\\\test.com\\testing.mp3",S_OK},
6066             {"test.com",S_OK},
6067             {"file://\\\\test.com\\testing.mp3",S_OK},
6068             {"test.com",S_OK},
6069             {".mp3",S_OK},
6070             {"",S_FALSE},
6071             {"test.com",S_OK},
6072             {"",S_FALSE},
6073             {"\\testing.mp3",S_OK},
6074             {"\\testing.mp3",S_OK},
6075             {"",S_FALSE},
6076             {"file://\\\\test.com\\testing.mp3",S_OK},
6077             {"file",S_OK},
6078             {"",S_FALSE},
6079             {"",S_FALSE}
6080         },
6081         {
6082             {Uri_HOST_DNS,S_OK},
6083             {0,S_FALSE},
6084             {URL_SCHEME_FILE,S_OK},
6085             {URLZONE_INVALID,E_NOTIMPL}
6086         }
6087     },
6088     /* URL_DONT_SIMPLIFY has no effect. */
6089     {   "http://google.com/test",0,
6090         "zip://test.com/cool/../cool/test",0,
6091         URL_DONT_SIMPLIFY,S_OK,FALSE,
6092         {
6093             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
6094             {"test.com",S_OK},
6095             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
6096             {"test.com",S_OK},
6097             {"",S_FALSE},
6098             {"",S_FALSE},
6099             {"test.com",S_OK},
6100             {"",S_FALSE},
6101             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
6102             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
6103             {"",S_FALSE},
6104             /* The resulting IUri has the same Raw URI as the relative URI (only IE 8).
6105              * On IE 7 it reduces the path in the Raw URI.
6106              */
6107             {"zip://test.com/cool/../cool/test",S_OK,FALSE,"zip://test.com/cool/test"},
6108             {"zip",S_OK},
6109             {"",S_FALSE},
6110             {"",S_FALSE}
6111         },
6112         {
6113             {Uri_HOST_DNS,S_OK},
6114             {0,S_FALSE},
6115             {URL_SCHEME_UNKNOWN,S_OK},
6116             {URLZONE_INVALID,E_NOTIMPL}
6117         }
6118     },
6119     /* FILE_USE_PATHURL has no effect in IE 8, in IE 7 the
6120      * resulting URI is converted into a dos path.
6121      */
6122     {   "http://google.com/test",0,
6123         "file:///c:/test/",0,
6124         URL_FILE_USE_PATHURL,S_OK,FALSE,
6125         {
6126             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
6127             {"",S_FALSE},
6128             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
6129             {"",S_FALSE},
6130             {"",S_FALSE},
6131             {"",S_FALSE},
6132             {"",S_FALSE},
6133             {"",S_FALSE},
6134             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
6135             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
6136             {"",S_FALSE},
6137             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
6138             {"file",S_OK},
6139             {"",S_FALSE},
6140             {"",S_FALSE}
6141         },
6142         {
6143             {Uri_HOST_UNKNOWN,S_OK},
6144             {0,S_FALSE},
6145             {URL_SCHEME_FILE,S_OK},
6146             {URLZONE_INVALID,E_NOTIMPL}
6147         }
6148     },
6149     {   "http://google.com/test",0,
6150         "http://test.com/test#%30test",0,
6151         URL_DONT_UNESCAPE_EXTRA_INFO,S_OK,FALSE,
6152         {
6153             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
6154             {"test.com",S_OK},
6155             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
6156             {"test.com",S_OK},
6157             {"",S_FALSE},
6158             {"#0test",S_OK,FALSE,NULL,"#%30test"},
6159             {"test.com",S_OK},
6160             {"",S_FALSE},
6161             {"/test",S_OK},
6162             {"/test",S_OK},
6163             {"",S_FALSE},
6164             /* IE 7 decodes the %30 to a 0 in the Raw URI. */
6165             {"http://test.com/test#%30test",S_OK,FALSE,"http://test.com/test#0test"},
6166             {"http",S_OK},
6167             {"",S_FALSE},
6168             {"",S_FALSE}
6169         },
6170         {
6171             {Uri_HOST_DNS,S_OK},
6172             {80,S_OK},
6173             {URL_SCHEME_HTTP,S_OK},
6174             {URLZONE_INVALID,E_NOTIMPL}
6175         }
6176     },
6177     /* Windows validates the path component from the relative Uri. */
6178     {   "http://google.com/test",0,
6179         "/Te%XXst",Uri_CREATE_ALLOW_RELATIVE,
6180         0,E_INVALIDARG,FALSE
6181     },
6182     /* Windows doesn't validate the query from the relative Uri. */
6183     {   "http://google.com/test",0,
6184         "?Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
6185         0,S_OK,FALSE,
6186         {
6187             {"http://google.com/test?Tes%XXt",S_OK},
6188             {"google.com",S_OK},
6189             {"http://google.com/test?Tes%XXt",S_OK},
6190             {"google.com",S_OK},
6191             {"",S_FALSE},
6192             {"",S_FALSE},
6193             {"google.com",S_OK},
6194             {"",S_FALSE},
6195             {"/test",S_OK},
6196             {"/test?Tes%XXt",S_OK},
6197             {"?Tes%XXt",S_OK},
6198             {"http://google.com/test?Tes%XXt",S_OK},
6199             {"http",S_OK},
6200             {"",S_FALSE},
6201             {"",S_FALSE}
6202         },
6203         {
6204             {Uri_HOST_DNS,S_OK},
6205             {80,S_OK},
6206             {URL_SCHEME_HTTP,S_OK},
6207             {URLZONE_INVALID,E_NOTIMPL}
6208         }
6209     },
6210     /* Windows doesn't validate the fragment from the relative Uri. */
6211     {   "http://google.com/test",0,
6212         "#Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
6213         0,S_OK,FALSE,
6214         {
6215             {"http://google.com/test#Tes%XXt",S_OK},
6216             {"google.com",S_OK},
6217             {"http://google.com/test#Tes%XXt",S_OK},
6218             {"google.com",S_OK},
6219             {"",S_FALSE},
6220             {"#Tes%XXt",S_OK},
6221             {"google.com",S_OK},
6222             {"",S_FALSE},
6223             {"/test",S_OK},
6224             {"/test",S_OK},
6225             {"",S_FALSE},
6226             {"http://google.com/test#Tes%XXt",S_OK},
6227             {"http",S_OK},
6228             {"",S_FALSE},
6229             {"",S_FALSE}
6230         },
6231         {
6232             {Uri_HOST_DNS,S_OK},
6233             {80,S_OK},
6234             {URL_SCHEME_HTTP,S_OK},
6235             {URLZONE_INVALID,E_NOTIMPL}
6236         }
6237     },
6238     /* Creates an IUri which contains an invalid dos path char. */
6239     {   "file:///c:/test",0,
6240         "/test<ing",Uri_CREATE_ALLOW_RELATIVE,
6241         URL_FILE_USE_PATHURL,S_OK,FALSE,
6242         {
6243             {"file://c:\\test<ing",S_OK},
6244             {"",S_FALSE},
6245             {"file://c:\\test<ing",S_OK},
6246             {"",S_FALSE},
6247             {"",S_FALSE},
6248             {"",S_FALSE},
6249             {"",S_FALSE},
6250             {"",S_FALSE},
6251             {"c:\\test<ing",S_OK},
6252             {"c:\\test<ing",S_OK},
6253             {"",S_FALSE},
6254             {"file://c:\\test<ing",S_OK},
6255             {"file",S_OK},
6256             {"",S_FALSE},
6257             {"",S_FALSE}
6258         },
6259         {
6260             {Uri_HOST_UNKNOWN,S_OK},
6261             {0,S_FALSE},
6262             {URL_SCHEME_FILE,S_OK},
6263             {URLZONE_INVALID,E_NOTIMPL}
6264         }
6265     },
6266     /* Appends the path after the drive letter (if any). */
6267     {   "file:///c:/test",0,
6268         "/c:/testing",Uri_CREATE_ALLOW_RELATIVE,
6269         0,S_OK,FALSE,
6270         {
6271             {"file:///c:/c:/testing",S_OK},
6272             {"",S_FALSE},
6273             {"file:///c:/c:/testing",S_OK},
6274             {"",S_FALSE},
6275             {"",S_FALSE},
6276             {"",S_FALSE},
6277             {"",S_FALSE},
6278             {"",S_FALSE},
6279             {"/c:/c:/testing",S_OK},
6280             {"/c:/c:/testing",S_OK},
6281             {"",S_FALSE},
6282             {"file:///c:/c:/testing",S_OK},
6283             {"file",S_OK},
6284             {"",S_FALSE},
6285             {"",S_FALSE}
6286         },
6287         {
6288             {Uri_HOST_UNKNOWN,S_OK},
6289             {0,S_FALSE},
6290             {URL_SCHEME_FILE,S_OK},
6291             {URLZONE_INVALID,E_NOTIMPL}
6292         }
6293     },
6294     /* A '/' is added if the base URI doesn't have a path and the
6295      * relative URI doesn't contain a path (since the base URI is
6296      * hierarchical.
6297      */
6298     {   "http://google.com",Uri_CREATE_NO_CANONICALIZE,
6299         "?test",Uri_CREATE_ALLOW_RELATIVE,
6300         0,S_OK,FALSE,
6301         {
6302             {"http://google.com/?test",S_OK},
6303             {"google.com",S_OK},
6304             {"http://google.com/?test",S_OK},
6305             {"google.com",S_OK},
6306             {"",S_FALSE},
6307             {"",S_FALSE},
6308             {"google.com",S_OK},
6309             {"",S_FALSE},
6310             {"/",S_OK},
6311             {"/?test",S_OK},
6312             {"?test",S_OK},
6313             {"http://google.com/?test",S_OK},
6314             {"http",S_OK},
6315             {"",S_FALSE},
6316             {"",S_FALSE}
6317         },
6318         {
6319             {Uri_HOST_DNS,S_OK},
6320             {80,S_OK},
6321             {URL_SCHEME_HTTP,S_OK},
6322             {URLZONE_INVALID,E_NOTIMPL}
6323         }
6324     },
6325     {   "zip://google.com",Uri_CREATE_NO_CANONICALIZE,
6326         "?test",Uri_CREATE_ALLOW_RELATIVE,
6327         0,S_OK,FALSE,
6328         {
6329             {"zip://google.com/?test",S_OK},
6330             {"google.com",S_OK},
6331             {"zip://google.com/?test",S_OK},
6332             {"google.com",S_OK},
6333             {"",S_FALSE},
6334             {"",S_FALSE},
6335             {"google.com",S_OK},
6336             {"",S_FALSE},
6337             {"/",S_OK},
6338             {"/?test",S_OK},
6339             {"?test",S_OK},
6340             {"zip://google.com/?test",S_OK},
6341             {"zip",S_OK},
6342             {"",S_FALSE},
6343             {"",S_FALSE}
6344         },
6345         {
6346             {Uri_HOST_DNS,S_OK},
6347             {0,S_FALSE},
6348             {URL_SCHEME_UNKNOWN,S_OK},
6349             {URLZONE_INVALID,E_NOTIMPL}
6350         }
6351     },
6352     /* No path is appended since the base URI is opaque. */
6353     {   "zip:?testing",0,
6354         "?test",Uri_CREATE_ALLOW_RELATIVE,
6355         0,S_OK,FALSE,
6356         {
6357             {"zip:?test",S_OK},
6358             {"",S_FALSE},
6359             {"zip:?test",S_OK},
6360             {"",S_FALSE},
6361             {"",S_FALSE},
6362             {"",S_FALSE},
6363             {"",S_FALSE},
6364             {"",S_FALSE},
6365             {"",S_OK},
6366             {"?test",S_OK},
6367             {"?test",S_OK},
6368             {"zip:?test",S_OK},
6369             {"zip",S_OK},
6370             {"",S_FALSE},
6371             {"",S_FALSE}
6372         },
6373         {
6374             {Uri_HOST_UNKNOWN,S_OK},
6375             {0,S_FALSE},
6376             {URL_SCHEME_UNKNOWN,S_OK},
6377             {URLZONE_INVALID,E_NOTIMPL}
6378         }
6379     },
6380     {   "file:///c:/",0,
6381         "../testing/test",Uri_CREATE_ALLOW_RELATIVE,
6382         0,S_OK,FALSE,
6383         {
6384             {"file:///c:/testing/test",S_OK},
6385             {"",S_FALSE},
6386             {"file:///c:/testing/test",S_OK},
6387             {"",S_FALSE},
6388             {"",S_FALSE},
6389             {"",S_FALSE},
6390             {"",S_FALSE},
6391             {"",S_FALSE},
6392             {"/c:/testing/test",S_OK},
6393             {"/c:/testing/test",S_OK},
6394             {"",S_FALSE},
6395             {"file:///c:/testing/test",S_OK},
6396             {"file",S_OK},
6397             {"",S_FALSE},
6398             {"",S_FALSE}
6399         },
6400         {
6401             {Uri_HOST_UNKNOWN,S_OK},
6402             {0,S_FALSE},
6403             {URL_SCHEME_FILE,S_OK},
6404             {URLZONE_INVALID,E_NOTIMPL}
6405         }
6406     },
6407     {   "http://winehq.org/dir/testfile",0,
6408         "test?querystring",Uri_CREATE_ALLOW_RELATIVE,
6409         0,S_OK,FALSE,
6410         {
6411             {"http://winehq.org/dir/test?querystring",S_OK},
6412             {"winehq.org",S_OK},
6413             {"http://winehq.org/dir/test?querystring",S_OK},
6414             {"winehq.org",S_OK},
6415             {"",S_FALSE},
6416             {"",S_FALSE},
6417             {"winehq.org",S_OK},
6418             {"",S_FALSE},
6419             {"/dir/test",S_OK},
6420             {"/dir/test?querystring",S_OK},
6421             {"?querystring",S_OK},
6422             {"http://winehq.org/dir/test?querystring",S_OK},
6423             {"http",S_OK},
6424             {"",S_FALSE},
6425             {"",S_FALSE}
6426         },
6427         {
6428             {Uri_HOST_DNS,S_OK},
6429             {80,S_OK},
6430             {URL_SCHEME_HTTP,S_OK},
6431             {URLZONE_INVALID,E_NOTIMPL}
6432         }
6433     },
6434     {   "http://winehq.org/dir/test",0,
6435         "test?querystring",Uri_CREATE_ALLOW_RELATIVE,
6436         0,S_OK,FALSE,
6437         {
6438             {"http://winehq.org/dir/test?querystring",S_OK},
6439             {"winehq.org",S_OK},
6440             {"http://winehq.org/dir/test?querystring",S_OK},
6441             {"winehq.org",S_OK},
6442             {"",S_FALSE},
6443             {"",S_FALSE},
6444             {"winehq.org",S_OK},
6445             {"",S_FALSE},
6446             {"/dir/test",S_OK},
6447             {"/dir/test?querystring",S_OK},
6448             {"?querystring",S_OK},
6449             {"http://winehq.org/dir/test?querystring",S_OK},
6450             {"http",S_OK},
6451             {"",S_FALSE},
6452             {"",S_FALSE}
6453         },
6454         {
6455             {Uri_HOST_DNS,S_OK},
6456             {80,S_OK},
6457             {URL_SCHEME_HTTP,S_OK},
6458             {URLZONE_INVALID,E_NOTIMPL}
6459         }
6460     },
6461     {   "http://winehq.org/dir/test?querystring",0,
6462         "#hash",Uri_CREATE_ALLOW_RELATIVE,
6463         0,S_OK,FALSE,
6464         {
6465             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6466             {"winehq.org",S_OK},
6467             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6468             {"winehq.org",S_OK},
6469             {"",S_FALSE},
6470             {"#hash",S_OK},
6471             {"winehq.org",S_OK},
6472             {"",S_FALSE},
6473             {"/dir/test",S_OK},
6474             {"/dir/test?querystring",S_OK},
6475             {"?querystring",S_OK},
6476             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6477             {"http",S_OK},
6478             {"",S_FALSE},
6479             {"",S_FALSE}
6480         },
6481         {
6482             {Uri_HOST_DNS,S_OK},
6483             {80,S_OK},
6484             {URL_SCHEME_HTTP,S_OK},
6485             {URLZONE_INVALID,E_NOTIMPL}
6486         }
6487     },
6488     {   "mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir\\file.txt",0,
6489         "relative/path.txt",Uri_CREATE_ALLOW_RELATIVE,
6490         0,S_OK,FALSE,
6491         {
6492             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6493             {"",S_FALSE},
6494             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6495             {"",S_FALSE},
6496             {".txt",S_OK},
6497             {"",S_FALSE},
6498             {"",S_FALSE},
6499             {"",S_FALSE},
6500             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6501             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6502             {"",S_FALSE},
6503             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6504             {"mk",S_OK},
6505             {"",S_FALSE},
6506             {"",S_FALSE}
6507         },
6508         {
6509             {Uri_HOST_UNKNOWN,S_OK},
6510             {0,S_FALSE},
6511             {URL_SCHEME_MK,S_OK},
6512             {URLZONE_INVALID,E_NOTIMPL}
6513         }
6514     },
6515     {   "mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::\\subdir\\file.txt",0,
6516         "relative/path.txt",Uri_CREATE_ALLOW_RELATIVE,
6517         0,S_OK,FALSE,
6518         {
6519             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6520             {"",S_FALSE},
6521             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6522             {"",S_FALSE},
6523             {".txt",S_OK},
6524             {"",S_FALSE},
6525             {"",S_FALSE},
6526             {"",S_FALSE},
6527             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6528             {"@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6529             {"",S_FALSE},
6530             {"mk:@MSITSTORE:C:\\Some\\Bogus\\Path.chm::/subdir/relative/path.txt",S_OK},
6531             {"mk",S_OK},
6532             {"",S_FALSE},
6533             {"",S_FALSE}
6534         },
6535         {
6536             {Uri_HOST_UNKNOWN,S_OK},
6537             {0,S_FALSE},
6538             {URL_SCHEME_MK,S_OK},
6539             {URLZONE_INVALID,E_NOTIMPL}
6540         }
6541     },
6542     {   "mk:@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir\\file.txt",0,
6543         "relative\\path.txt",Uri_CREATE_ALLOW_RELATIVE,
6544         0,S_OK,FALSE,
6545         {
6546             {"mk:@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6547             {"",S_FALSE},
6548             {"mk:@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6549             {"",S_FALSE},
6550             {".txt",S_OK},
6551             {"",S_FALSE},
6552             {"",S_FALSE},
6553             {"",S_FALSE},
6554             {"@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6555             {"@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6556             {"",S_FALSE},
6557             {"mk:@MSITSTORE:C:/Some\\Bogus/Path.chm::/subdir/relative/path.txt",S_OK},
6558             {"mk",S_OK},
6559             {"",S_FALSE},
6560             {"",S_FALSE}
6561         },
6562         {
6563             {Uri_HOST_UNKNOWN,S_OK},
6564             {0,S_FALSE},
6565             {URL_SCHEME_MK,S_OK},
6566             {URLZONE_INVALID,E_NOTIMPL}
6567         }
6568     }
6569 };
6570
6571 typedef struct _uri_parse_test {
6572     const char  *uri;
6573     DWORD       uri_flags;
6574     PARSEACTION action;
6575     DWORD       flags;
6576     const char  *property;
6577     HRESULT     expected;
6578     BOOL        todo;
6579 } uri_parse_test;
6580
6581 static const uri_parse_test uri_parse_tests[] = {
6582     /* PARSE_CANONICALIZE tests. */
6583     {"zip://google.com/test<|>",0,PARSE_CANONICALIZE,0,"zip://google.com/test<|>",S_OK,FALSE},
6584     {"http://google.com/test<|>",0,PARSE_CANONICALIZE,0,"http://google.com/test%3C%7C%3E",S_OK,FALSE},
6585     {"http://google.com/%30%23%3F",0,PARSE_CANONICALIZE,URL_UNESCAPE,"http://google.com/0#?",S_OK,FALSE},
6586     {"test <|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_ESCAPE_UNSAFE,"test %3C%7C%3E",S_OK,FALSE},
6587     {"test <|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_ESCAPE_SPACES_ONLY,"test%20<|>",S_OK,FALSE},
6588     {"test%20<|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_UNESCAPE|URL_ESCAPE_UNSAFE,"test%20%3C%7C%3E",S_OK,FALSE},
6589     {"http://google.com/%20",0,PARSE_CANONICALIZE,URL_ESCAPE_PERCENT,"http://google.com/%2520",S_OK,FALSE},
6590     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_DONT_SIMPLIFY,"http://google.com/test/../",S_OK,FALSE},
6591     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_NO_META,"http://google.com/test/../",S_OK,FALSE},
6592     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,0,"http://google.com/",S_OK,FALSE},
6593     {"zip://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,0,"zip://google.com/",S_OK,FALSE},
6594     {"file:///c:/test/../test",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_DONT_SIMPLIFY,"file:///c:/test/../test",S_OK,FALSE},
6595
6596     /* PARSE_FRIENDLY tests. */
6597     {"http://test@google.com/test#test",0,PARSE_FRIENDLY,0,"http://google.com/test#test",S_OK,FALSE},
6598     {"zip://test@google.com/test",0,PARSE_FRIENDLY,0,"zip://test@google.com/test",S_OK,FALSE},
6599
6600     /* PARSE_ROOTDOCUMENT tests. */
6601     {"http://google.com:200/test/test",0,PARSE_ROOTDOCUMENT,0,"http://google.com:200/",S_OK,FALSE},
6602     {"http://google.com",Uri_CREATE_NO_CANONICALIZE,PARSE_ROOTDOCUMENT,0,"http://google.com/",S_OK,FALSE},
6603     {"zip://google.com/",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6604     {"file:///c:/testing/",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6605     {"file://server/test",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6606     {"zip:test/test",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6607
6608     /* PARSE_DOCUMENT tests. */
6609     {"http://test@google.com/test?query#frag",0,PARSE_DOCUMENT,0,"http://test@google.com/test?query",S_OK,FALSE},
6610     {"http:testing#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6611     {"file:///c:/test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6612     {"zip://google.com/#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6613     {"zip:test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6614     {"testing#frag",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6615
6616     /* PARSE_PATH_FROM_URL tests. */
6617     {"file:///c:/test.mp3",0,PARSE_PATH_FROM_URL,0,"c:\\test.mp3",S_OK,FALSE},
6618     {"file:///c:/t<|>est.mp3",0,PARSE_PATH_FROM_URL,0,"c:\\t<|>est.mp3",S_OK,FALSE},
6619     {"file:///c:/te%XX t/",0,PARSE_PATH_FROM_URL,0,"c:\\te%XX t\\",S_OK,FALSE},
6620     {"file://server/test",0,PARSE_PATH_FROM_URL,0,"\\\\server\\test",S_OK,FALSE},
6621     {"http://google.com/",0,PARSE_PATH_FROM_URL,0,"",E_INVALIDARG,FALSE},
6622
6623     /* PARSE_URL_FROM_PATH tests. */
6624     /* This function almost seems to useless (just returns the absolute uri). */
6625     {"test.com",Uri_CREATE_ALLOW_RELATIVE,PARSE_URL_FROM_PATH,0,"test.com",S_OK,FALSE},
6626     {"/test/test",Uri_CREATE_ALLOW_RELATIVE,PARSE_URL_FROM_PATH,0,"/test/test",S_OK,FALSE},
6627     {"file://c:\\test\\test",Uri_CREATE_FILE_USE_DOS_PATH,PARSE_URL_FROM_PATH,0,"file://c:\\test\\test",S_OK,FALSE},
6628     {"file:c:/test",0,PARSE_URL_FROM_PATH,0,"",S_OK,FALSE},
6629     {"http:google.com/",0,PARSE_URL_FROM_PATH,0,"",S_OK,FALSE},
6630
6631     /* PARSE_SCHEMA tests. */
6632     {"http://google.com/test",0,PARSE_SCHEMA,0,"http",S_OK,FALSE},
6633     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_SCHEMA,0,"",S_OK,FALSE},
6634
6635     /* PARSE_SITE tests. */
6636     {"http://google.uk.com/",0,PARSE_SITE,0,"google.uk.com",S_OK,FALSE},
6637     {"http://google.com.com/",0,PARSE_SITE,0,"google.com.com",S_OK,FALSE},
6638     {"google.com",Uri_CREATE_ALLOW_RELATIVE,PARSE_SITE,0,"",S_OK,FALSE},
6639     {"file://server/test",0,PARSE_SITE,0,"server",S_OK,FALSE},
6640
6641     /* PARSE_DOMAIN tests. */
6642     {"http://google.com.uk/",0,PARSE_DOMAIN,0,"google.com.uk",S_OK,FALSE},
6643     {"http://google.com.com/",0,PARSE_DOMAIN,0,"com.com",S_OK,FALSE},
6644     {"test/test",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOMAIN,0,"",S_OK,FALSE},
6645     {"file://server/test",0,PARSE_DOMAIN,0,"",S_OK,FALSE},
6646
6647     /* PARSE_LOCATION and PARSE_ANCHOR tests. */
6648     {"http://google.com/test#Test",0,PARSE_ANCHOR,0,"#Test",S_OK,FALSE},
6649     {"http://google.com/test#Test",0,PARSE_LOCATION,0,"#Test",S_OK,FALSE},
6650     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_ANCHOR,0,"",S_OK,FALSE},
6651     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_LOCATION,0,"",S_OK,FALSE}
6652 };
6653
6654 static inline LPWSTR a2w(LPCSTR str) {
6655     LPWSTR ret = NULL;
6656
6657     if(str) {
6658         DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
6659         ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
6660         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
6661     }
6662
6663     return ret;
6664 }
6665
6666 static inline BOOL heap_free(void* mem) {
6667     return HeapFree(GetProcessHeap(), 0, mem);
6668 }
6669
6670 static inline DWORD strcmp_aw(LPCSTR strA, LPCWSTR strB) {
6671     LPWSTR strAW = a2w(strA);
6672     DWORD ret = lstrcmpW(strAW, strB);
6673     heap_free(strAW);
6674     return ret;
6675 }
6676
6677 static inline ULONG get_refcnt(IUri *uri) {
6678     IUri_AddRef(uri);
6679     return IUri_Release(uri);
6680 }
6681
6682 static void change_property(IUriBuilder *builder, const uri_builder_property *prop,
6683                             DWORD test_index) {
6684     HRESULT hr;
6685     LPWSTR valueW;
6686
6687     valueW = a2w(prop->value);
6688     switch(prop->property) {
6689     case Uri_PROPERTY_FRAGMENT:
6690         hr = IUriBuilder_SetFragment(builder, valueW);
6691         if(prop->todo) {
6692             todo_wine {
6693                 ok(hr == prop->expected,
6694                     "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6695                     hr, prop->expected, test_index);
6696             }
6697         } else {
6698             ok(hr == prop->expected,
6699                 "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6700                 hr, prop->expected, test_index);
6701         }
6702         break;
6703     case Uri_PROPERTY_HOST:
6704         hr = IUriBuilder_SetHost(builder, valueW);
6705         if(prop->todo) {
6706             todo_wine {
6707                 ok(hr == prop->expected,
6708                     "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6709                     hr, prop->expected, test_index);
6710             }
6711         } else {
6712             ok(hr == prop->expected,
6713                 "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6714                 hr, prop->expected, test_index);
6715         }
6716         break;
6717     case Uri_PROPERTY_PASSWORD:
6718         hr = IUriBuilder_SetPassword(builder, valueW);
6719         if(prop->todo) {
6720             todo_wine {
6721                 ok(hr == prop->expected,
6722                     "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6723                     hr, prop->expected, test_index);
6724             }
6725         } else {
6726             ok(hr == prop->expected,
6727                 "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6728                 hr, prop->expected, test_index);
6729         }
6730         break;
6731     case Uri_PROPERTY_PATH:
6732         hr = IUriBuilder_SetPath(builder, valueW);
6733         if(prop->todo) {
6734             todo_wine {
6735                 ok(hr == prop->expected,
6736                     "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6737                     hr, prop->expected, test_index);
6738             }
6739         } else {
6740             ok(hr == prop->expected,
6741                 "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6742                 hr, prop->expected, test_index);
6743         }
6744         break;
6745     case Uri_PROPERTY_QUERY:
6746         hr = IUriBuilder_SetQuery(builder, valueW);
6747         if(prop->todo) {
6748             todo_wine {
6749                 ok(hr == prop->expected,
6750                     "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6751                     hr, prop->expected, test_index);
6752             }
6753         } else {
6754             ok(hr == prop->expected,
6755                 "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6756                 hr, prop->expected, test_index);
6757         }
6758         break;
6759     case Uri_PROPERTY_SCHEME_NAME:
6760         hr = IUriBuilder_SetSchemeName(builder, valueW);
6761         if(prop->todo) {
6762             todo_wine {
6763                 ok(hr == prop->expected,
6764                     "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6765                     hr, prop->expected, test_index);
6766             }
6767         } else {
6768             ok(hr == prop->expected,
6769                 "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6770                 hr, prop->expected, test_index);
6771         }
6772         break;
6773     case Uri_PROPERTY_USER_NAME:
6774         hr = IUriBuilder_SetUserName(builder, valueW);
6775         if(prop->todo) {
6776             todo_wine {
6777                 ok(hr == prop->expected,
6778                     "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6779                     hr, prop->expected, test_index);
6780             }
6781         } else {
6782             ok(hr == prop->expected,
6783                 "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6784                 hr, prop->expected, test_index);
6785         }
6786         break;
6787     default:
6788         trace("Unsupported operation for %d on uri_builder_tests[%d].\n", prop->property, test_index);
6789     }
6790
6791     heap_free(valueW);
6792 }
6793
6794 /*
6795  * Simple tests to make sure the CreateUri function handles invalid flag combinations
6796  * correctly.
6797  */
6798 static void test_CreateUri_InvalidFlags(void) {
6799     DWORD i;
6800
6801     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
6802         HRESULT hr;
6803         IUri *uri = (void*) 0xdeadbeef;
6804
6805         hr = pCreateUri(http_urlW, invalid_flag_tests[i].flags, 0, &uri);
6806         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUri returned 0x%08x, expected 0x%08x, flags=0x%08x\n",
6807                 hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
6808         ok(uri == NULL, "Error: expected the IUri to be NULL, but it was %p instead\n", uri);
6809     }
6810 }
6811
6812 static void test_CreateUri_InvalidArgs(void) {
6813     HRESULT hr;
6814     IUri *uri = (void*) 0xdeadbeef;
6815
6816     const WCHAR invalidW[] = {'i','n','v','a','l','i','d',0};
6817     static const WCHAR emptyW[] = {0};
6818
6819     hr = pCreateUri(http_urlW, 0, 0, NULL);
6820     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6821
6822     hr = pCreateUri(NULL, 0, 0, &uri);
6823     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6824     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6825
6826     uri = (void*) 0xdeadbeef;
6827     hr = pCreateUri(invalidW, 0, 0, &uri);
6828     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6829     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6830
6831     uri = (void*) 0xdeadbeef;
6832     hr = pCreateUri(emptyW, 0, 0, &uri);
6833     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6834     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6835 }
6836
6837 static void test_CreateUri_InvalidUri(void) {
6838     DWORD i;
6839
6840     for(i = 0; i < sizeof(invalid_uri_tests)/sizeof(invalid_uri_tests[0]); ++i) {
6841         invalid_uri test = invalid_uri_tests[i];
6842         IUri *uri = NULL;
6843         LPWSTR uriW;
6844         HRESULT hr;
6845
6846         uriW = a2w(test.uri);
6847         hr = pCreateUri(uriW, test.flags, 0, &uri);
6848         if(test.todo) {
6849             todo_wine {
6850                 ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6851                     hr, E_INVALIDARG, i);
6852             }
6853         } else {
6854             ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6855                 hr, E_INVALIDARG, i);
6856         }
6857         if(uri) IUri_Release(uri);
6858
6859         heap_free(uriW);
6860     }
6861 }
6862
6863 static void test_IUri_GetPropertyBSTR(void) {
6864     IUri *uri = NULL;
6865     HRESULT hr;
6866     DWORD i;
6867
6868     /* Make sure GetPropertyBSTR handles invalid args correctly. */
6869     hr = pCreateUri(http_urlW, 0, 0, &uri);
6870     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6871     if(SUCCEEDED(hr)) {
6872         BSTR received = NULL;
6873
6874         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_RAW_URI, NULL, 0);
6875         ok(hr == E_POINTER, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6876
6877         /* Make sure it handles a invalid Uri_PROPERTY's correctly. */
6878         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_PORT, &received, 0);
6879         ok(hr == S_OK, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6880         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6881         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6882         SysFreeString(received);
6883
6884         /* Make sure it handles the ZONE property correctly. */
6885         received = NULL;
6886         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_ZONE, &received, 0);
6887         ok(hr == S_FALSE, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_FALSE);
6888         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6889         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6890         SysFreeString(received);
6891     }
6892     if(uri) IUri_Release(uri);
6893
6894     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6895         uri_properties test = uri_tests[i];
6896         LPWSTR uriW;
6897         uri = NULL;
6898
6899         uriW = a2w(test.uri);
6900         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6901         if(test.create_todo) {
6902             todo_wine {
6903                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6904                         hr, test.create_expected, i);
6905             }
6906         } else {
6907             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6908                     hr, test.create_expected, i);
6909         }
6910
6911         if(SUCCEEDED(hr)) {
6912             DWORD j;
6913
6914             /* Checks all the string properties of the uri. */
6915             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
6916                 BSTR received = NULL;
6917                 uri_str_property prop = test.str_props[j];
6918
6919                 hr = IUri_GetPropertyBSTR(uri, j, &received, 0);
6920                 if(prop.todo) {
6921                     todo_wine {
6922                         ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6923                                 hr, prop.expected, i, j);
6924                     }
6925                     todo_wine {
6926                         ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6927                                 "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6928                                 prop.value, wine_dbgstr_w(received), i, j);
6929                     }
6930                 } else {
6931                     ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6932                             hr, prop.expected, i, j);
6933                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6934                             "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6935                             prop.value, wine_dbgstr_w(received), i, j);
6936                 }
6937
6938                 SysFreeString(received);
6939             }
6940         }
6941
6942         if(uri) IUri_Release(uri);
6943
6944         heap_free(uriW);
6945     }
6946 }
6947
6948 static void test_IUri_GetPropertyDWORD(void) {
6949     IUri *uri = NULL;
6950     HRESULT hr;
6951     DWORD i;
6952
6953     hr = pCreateUri(http_urlW, 0, 0, &uri);
6954     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6955     if(SUCCEEDED(hr)) {
6956         DWORD received = 0xdeadbeef;
6957
6958         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_DWORD_START, NULL, 0);
6959         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6960
6961         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_ABSOLUTE_URI, &received, 0);
6962         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6963         ok(received == 0, "Error: Expected received=%d but instead received=%d.\n", 0, received);
6964     }
6965     if(uri) IUri_Release(uri);
6966
6967     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6968         uri_properties test = uri_tests[i];
6969         LPWSTR uriW;
6970         uri = NULL;
6971
6972         uriW = a2w(test.uri);
6973         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6974         if(test.create_todo) {
6975             todo_wine {
6976                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6977                         hr, test.create_expected, i);
6978             }
6979         } else {
6980             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6981                     hr, test.create_expected, i);
6982         }
6983
6984         if(SUCCEEDED(hr)) {
6985             DWORD j;
6986
6987             /* Checks all the DWORD properties of the uri. */
6988             for(j = 0; j < sizeof(test.dword_props)/sizeof(test.dword_props[0]); ++j) {
6989                 DWORD received;
6990                 uri_dword_property prop = test.dword_props[j];
6991
6992                 hr = IUri_GetPropertyDWORD(uri, j+Uri_PROPERTY_DWORD_START, &received, 0);
6993                 if(prop.todo) {
6994                     todo_wine {
6995                         ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
6996                                 hr, prop.expected, i, j);
6997                     }
6998                     todo_wine {
6999                         ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
7000                                 prop.value, received, i, j);
7001                     }
7002                 } else {
7003                     ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
7004                             hr, prop.expected, i, j);
7005                     ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
7006                             prop.value, received, i, j);
7007                 }
7008             }
7009         }
7010
7011         if(uri) IUri_Release(uri);
7012
7013         heap_free(uriW);
7014     }
7015 }
7016
7017 /* Tests all the 'Get*' property functions which deal with strings. */
7018 static void test_IUri_GetStrProperties(void) {
7019     IUri *uri = NULL;
7020     HRESULT hr;
7021     DWORD i;
7022
7023     /* Make sure all the 'Get*' string property functions handle invalid args correctly. */
7024     hr = pCreateUri(http_urlW, 0, 0, &uri);
7025     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7026     if(SUCCEEDED(hr)) {
7027         hr = IUri_GetAbsoluteUri(uri, NULL);
7028         ok(hr == E_POINTER, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7029
7030         hr = IUri_GetAuthority(uri, NULL);
7031         ok(hr == E_POINTER, "Error: GetAuthority returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7032
7033         hr = IUri_GetDisplayUri(uri, NULL);
7034         ok(hr == E_POINTER, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7035
7036         hr = IUri_GetDomain(uri, NULL);
7037         ok(hr == E_POINTER, "Error: GetDomain returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7038
7039         hr = IUri_GetExtension(uri, NULL);
7040         ok(hr == E_POINTER, "Error: GetExtension returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7041
7042         hr = IUri_GetFragment(uri, NULL);
7043         ok(hr == E_POINTER, "Error: GetFragment returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7044
7045         hr = IUri_GetHost(uri, NULL);
7046         ok(hr == E_POINTER, "Error: GetHost returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7047
7048         hr = IUri_GetPassword(uri, NULL);
7049         ok(hr == E_POINTER, "Error: GetPassword returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7050
7051         hr = IUri_GetPath(uri, NULL);
7052         ok(hr == E_POINTER, "Error: GetPath returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7053
7054         hr = IUri_GetPathAndQuery(uri, NULL);
7055         ok(hr == E_POINTER, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7056
7057         hr = IUri_GetQuery(uri, NULL);
7058         ok(hr == E_POINTER, "Error: GetQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7059
7060         hr = IUri_GetRawUri(uri, NULL);
7061         ok(hr == E_POINTER, "Error: GetRawUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7062
7063         hr = IUri_GetSchemeName(uri, NULL);
7064         ok(hr == E_POINTER, "Error: GetSchemeName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7065
7066         hr = IUri_GetUserInfo(uri, NULL);
7067         ok(hr == E_POINTER, "Error: GetUserInfo returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7068
7069         hr = IUri_GetUserName(uri, NULL);
7070         ok(hr == E_POINTER, "Error: GetUserName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7071     }
7072     if(uri) IUri_Release(uri);
7073
7074     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7075         uri_properties test = uri_tests[i];
7076         LPWSTR uriW;
7077         uri = NULL;
7078
7079         uriW = a2w(test.uri);
7080         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7081         if(test.create_todo) {
7082             todo_wine {
7083                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7084                         hr, test.create_expected, i);
7085             }
7086         } else {
7087             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7088                     hr, test.create_expected, i);
7089         }
7090
7091         if(SUCCEEDED(hr)) {
7092             uri_str_property prop;
7093             BSTR received = NULL;
7094
7095             /* GetAbsoluteUri() tests. */
7096             prop = test.str_props[Uri_PROPERTY_ABSOLUTE_URI];
7097             hr = IUri_GetAbsoluteUri(uri, &received);
7098             if(prop.todo) {
7099                 todo_wine {
7100                     ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7101                             hr, prop.expected, i);
7102                 }
7103                 todo_wine {
7104                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
7105                             "Error: Expected %s but got %s on uri_tests[%d].\n",
7106                             prop.value, wine_dbgstr_w(received), i);
7107                 }
7108             } else {
7109                 ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7110                         hr, prop.expected, i);
7111                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
7112                         "Error: Expected %s but got %s on uri_tests[%d].\n",
7113                         prop.value, wine_dbgstr_w(received), i);
7114             }
7115             SysFreeString(received);
7116             received = NULL;
7117
7118             /* GetAuthority() tests. */
7119             prop = test.str_props[Uri_PROPERTY_AUTHORITY];
7120             hr = IUri_GetAuthority(uri, &received);
7121             if(prop.todo) {
7122                 todo_wine {
7123                     ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7124                             hr, prop.expected, i);
7125                 }
7126                 todo_wine {
7127                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7128                             prop.value, wine_dbgstr_w(received), i);
7129                 }
7130             } else {
7131                 ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7132                         hr, prop.expected, i);
7133                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7134                         prop.value, wine_dbgstr_w(received), i);
7135             }
7136             SysFreeString(received);
7137             received = NULL;
7138
7139             /* GetDisplayUri() tests. */
7140             prop = test.str_props[Uri_PROPERTY_DISPLAY_URI];
7141             hr = IUri_GetDisplayUri(uri, &received);
7142             if(prop.todo) {
7143                 todo_wine {
7144                     ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7145                             hr, prop.expected, i);
7146                 }
7147                 todo_wine {
7148                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
7149                             "Error: Expected %s but got %s on uri_test[%d].\n",
7150                             prop.value, wine_dbgstr_w(received), i);
7151                 }
7152             } else {
7153                 ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7154                         hr, prop.expected, i);
7155                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
7156                         "Error: Expected %s but got %s on uri_tests[%d].\n",
7157                         prop.value, wine_dbgstr_w(received), i);
7158             }
7159             SysFreeString(received);
7160             received = NULL;
7161
7162             /* GetDomain() tests. */
7163             prop = test.str_props[Uri_PROPERTY_DOMAIN];
7164             hr = IUri_GetDomain(uri, &received);
7165             if(prop.todo) {
7166                 todo_wine {
7167                     ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7168                             hr, prop.expected, i);
7169                 }
7170                 todo_wine {
7171                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7172                             prop.value, wine_dbgstr_w(received), i);
7173                 }
7174             } else {
7175                 ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7176                         hr, prop.expected, i);
7177                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7178                         prop.value, wine_dbgstr_w(received), i);
7179             }
7180             SysFreeString(received);
7181             received = NULL;
7182
7183             /* GetExtension() tests. */
7184             prop = test.str_props[Uri_PROPERTY_EXTENSION];
7185             hr = IUri_GetExtension(uri, &received);
7186             if(prop.todo) {
7187                 todo_wine {
7188                     ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7189                             hr, prop.expected, i);
7190                 }
7191                 todo_wine {
7192                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7193                             prop.value, wine_dbgstr_w(received), i);
7194                 }
7195             } else {
7196                 ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7197                         hr, prop.expected, i);
7198                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7199                         prop.value, wine_dbgstr_w(received), i);
7200             }
7201             SysFreeString(received);
7202             received = NULL;
7203
7204             /* GetFragment() tests. */
7205             prop = test.str_props[Uri_PROPERTY_FRAGMENT];
7206             hr = IUri_GetFragment(uri, &received);
7207             if(prop.todo) {
7208                 todo_wine {
7209                     ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7210                             hr, prop.expected, i);
7211                 }
7212                 todo_wine {
7213                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7214                             prop.value, wine_dbgstr_w(received), i);
7215                 }
7216             } else {
7217                 ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7218                         hr, prop.expected, i);
7219                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7220                         prop.value, wine_dbgstr_w(received), i);
7221             }
7222             SysFreeString(received);
7223             received = NULL;
7224
7225             /* GetHost() tests. */
7226             prop = test.str_props[Uri_PROPERTY_HOST];
7227             hr = IUri_GetHost(uri, &received);
7228             if(prop.todo) {
7229                 todo_wine {
7230                     ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7231                             hr, prop.expected, i);
7232                 }
7233                 todo_wine {
7234                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7235                             prop.value, wine_dbgstr_w(received), i);
7236                 }
7237             } else {
7238                 ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7239                         hr, prop.expected, i);
7240                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7241                         prop.value, wine_dbgstr_w(received), i);
7242             }
7243             SysFreeString(received);
7244             received = NULL;
7245
7246             /* GetPassword() tests. */
7247             prop = test.str_props[Uri_PROPERTY_PASSWORD];
7248             hr = IUri_GetPassword(uri, &received);
7249             if(prop.todo) {
7250                 todo_wine {
7251                     ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7252                             hr, prop.expected, i);
7253                 }
7254                 todo_wine {
7255                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7256                             prop.value, wine_dbgstr_w(received), i);
7257                 }
7258             } else {
7259                 ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7260                         hr, prop.expected, i);
7261                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7262                         prop.value, wine_dbgstr_w(received), i);
7263             }
7264             SysFreeString(received);
7265             received = NULL;
7266
7267             /* GetPath() tests. */
7268             prop = test.str_props[Uri_PROPERTY_PATH];
7269             hr = IUri_GetPath(uri, &received);
7270             if(prop.todo) {
7271                 todo_wine {
7272                     ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7273                             hr, prop.expected, i);
7274                 }
7275                 todo_wine {
7276                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7277                             prop.value, wine_dbgstr_w(received), i);
7278                 }
7279             } else {
7280                 ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7281                         hr, prop.expected, i);
7282                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7283                         prop.value, wine_dbgstr_w(received), i);
7284             }
7285             SysFreeString(received);
7286             received = NULL;
7287
7288             /* GetPathAndQuery() tests. */
7289             prop = test.str_props[Uri_PROPERTY_PATH_AND_QUERY];
7290             hr = IUri_GetPathAndQuery(uri, &received);
7291             if(prop.todo) {
7292                 todo_wine {
7293                     ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7294                             hr, prop.expected, i);
7295                 }
7296                 todo_wine {
7297                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7298                             prop.value, wine_dbgstr_w(received), i);
7299                 }
7300             } else {
7301                 ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7302                         hr, prop.expected, i);
7303                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7304                         prop.value, wine_dbgstr_w(received), i);
7305             }
7306             SysFreeString(received);
7307             received = NULL;
7308
7309             /* GetQuery() tests. */
7310             prop = test.str_props[Uri_PROPERTY_QUERY];
7311             hr = IUri_GetQuery(uri, &received);
7312             if(prop.todo) {
7313                 todo_wine {
7314                     ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7315                             hr, prop.expected, i);
7316                 }
7317                 todo_wine {
7318                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7319                             prop.value, wine_dbgstr_w(received), i);
7320                 }
7321             } else {
7322                 ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7323                         hr, prop.expected, i);
7324                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7325                         prop.value, wine_dbgstr_w(received), i);
7326             }
7327             SysFreeString(received);
7328             received = NULL;
7329
7330             /* GetRawUri() tests. */
7331             prop = test.str_props[Uri_PROPERTY_RAW_URI];
7332             hr = IUri_GetRawUri(uri, &received);
7333             if(prop.todo) {
7334                 todo_wine {
7335                     ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7336                             hr, prop.expected, i);
7337                 }
7338                 todo_wine {
7339                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7340                             prop.value, wine_dbgstr_w(received), i);
7341                 }
7342             } else {
7343                 ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7344                         hr, prop.expected, i);
7345                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7346                         prop.value, wine_dbgstr_w(received), i);
7347             }
7348             SysFreeString(received);
7349             received = NULL;
7350
7351             /* GetSchemeName() tests. */
7352             prop = test.str_props[Uri_PROPERTY_SCHEME_NAME];
7353             hr = IUri_GetSchemeName(uri, &received);
7354             if(prop.todo) {
7355                 todo_wine {
7356                     ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7357                             hr, prop.expected, i);
7358                 }
7359                 todo_wine {
7360                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7361                             prop.value, wine_dbgstr_w(received), i);
7362                 }
7363             } else {
7364                 ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7365                         hr, prop.expected, i);
7366                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7367                         prop.value, wine_dbgstr_w(received), i);
7368             }
7369             SysFreeString(received);
7370             received = NULL;
7371
7372             /* GetUserInfo() tests. */
7373             prop = test.str_props[Uri_PROPERTY_USER_INFO];
7374             hr = IUri_GetUserInfo(uri, &received);
7375             if(prop.todo) {
7376                 todo_wine {
7377                     ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7378                             hr, prop.expected, i);
7379                 }
7380                 todo_wine {
7381                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7382                             prop.value, wine_dbgstr_w(received), i);
7383                 }
7384             } else {
7385                 ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7386                         hr, prop.expected, i);
7387                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7388                         prop.value, wine_dbgstr_w(received), i);
7389             }
7390             SysFreeString(received);
7391             received = NULL;
7392
7393             /* GetUserName() tests. */
7394             prop = test.str_props[Uri_PROPERTY_USER_NAME];
7395             hr = IUri_GetUserName(uri, &received);
7396             if(prop.todo) {
7397                 todo_wine {
7398                     ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7399                             hr, prop.expected, i);
7400                 }
7401                 todo_wine {
7402                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7403                             prop.value, wine_dbgstr_w(received), i);
7404                 }
7405             } else {
7406                 ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7407                         hr, prop.expected, i);
7408                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7409                         prop.value, wine_dbgstr_w(received), i);
7410             }
7411             SysFreeString(received);
7412         }
7413
7414         if(uri) IUri_Release(uri);
7415
7416         heap_free(uriW);
7417     }
7418 }
7419
7420 static void test_IUri_GetDwordProperties(void) {
7421     IUri *uri = NULL;
7422     HRESULT hr;
7423     DWORD i;
7424
7425     /* Make sure all the 'Get*' dword property functions handle invalid args correctly. */
7426     hr = pCreateUri(http_urlW, 0, 0, &uri);
7427     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7428     if(SUCCEEDED(hr)) {
7429         hr = IUri_GetHostType(uri, NULL);
7430         ok(hr == E_INVALIDARG, "Error: GetHostType returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7431
7432         hr = IUri_GetPort(uri, NULL);
7433         ok(hr == E_INVALIDARG, "Error: GetPort returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7434
7435         hr = IUri_GetScheme(uri, NULL);
7436         ok(hr == E_INVALIDARG, "Error: GetScheme returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7437
7438         hr = IUri_GetZone(uri, NULL);
7439         ok(hr == E_INVALIDARG, "Error: GetZone returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7440     }
7441     if(uri) IUri_Release(uri);
7442
7443     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7444         uri_properties test = uri_tests[i];
7445         LPWSTR uriW;
7446         uri = NULL;
7447
7448         uriW = a2w(test.uri);
7449         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7450         if(test.create_todo) {
7451             todo_wine {
7452                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7453                         hr, test.create_expected, i);
7454             }
7455         } else {
7456             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7457                     hr, test.create_expected, i);
7458         }
7459
7460         if(SUCCEEDED(hr)) {
7461             uri_dword_property prop;
7462             DWORD received;
7463
7464             /* Assign an insane value so tests don't accidentally pass when
7465              * they shouldn't!
7466              */
7467             received = -9999999;
7468
7469             /* GetHostType() tests. */
7470             prop = test.dword_props[Uri_PROPERTY_HOST_TYPE-Uri_PROPERTY_DWORD_START];
7471             hr = IUri_GetHostType(uri, &received);
7472             if(prop.todo) {
7473                 todo_wine {
7474                     ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7475                             hr, prop.expected, i);
7476                 }
7477                 todo_wine {
7478                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7479                 }
7480             } else {
7481                 ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7482                         hr, prop.expected, i);
7483                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7484             }
7485             received = -9999999;
7486
7487             /* GetPort() tests. */
7488             prop = test.dword_props[Uri_PROPERTY_PORT-Uri_PROPERTY_DWORD_START];
7489             hr = IUri_GetPort(uri, &received);
7490             if(prop.todo) {
7491                 todo_wine {
7492                     ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7493                             hr, prop.expected, i);
7494                 }
7495                 todo_wine {
7496                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7497                 }
7498             } else {
7499                 ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7500                         hr, prop.expected, i);
7501                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7502             }
7503             received = -9999999;
7504
7505             /* GetScheme() tests. */
7506             prop = test.dword_props[Uri_PROPERTY_SCHEME-Uri_PROPERTY_DWORD_START];
7507             hr = IUri_GetScheme(uri, &received);
7508             if(prop.todo) {
7509                 todo_wine {
7510                     ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7511                             hr, prop.expected, i);
7512                 }
7513                 todo_wine {
7514                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7515                 }
7516             } else {
7517                 ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7518                         hr, prop.expected, i);
7519                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7520             }
7521             received = -9999999;
7522
7523             /* GetZone() tests. */
7524             prop = test.dword_props[Uri_PROPERTY_ZONE-Uri_PROPERTY_DWORD_START];
7525             hr = IUri_GetZone(uri, &received);
7526             if(prop.todo) {
7527                 todo_wine {
7528                     ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7529                             hr, prop.expected, i);
7530                 }
7531                 todo_wine {
7532                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7533                 }
7534             } else {
7535                 ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7536                         hr, prop.expected, i);
7537                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7538             }
7539         }
7540
7541         if(uri) IUri_Release(uri);
7542
7543         heap_free(uriW);
7544     }
7545 }
7546
7547 static void test_IUri_GetPropertyLength(void) {
7548     IUri *uri = NULL;
7549     HRESULT hr;
7550     DWORD i;
7551
7552     /* Make sure it handles invalid args correctly. */
7553     hr = pCreateUri(http_urlW, 0, 0, &uri);
7554     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7555     if(SUCCEEDED(hr)) {
7556         DWORD received = 0xdeadbeef;
7557
7558         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_STRING_START, NULL, 0);
7559         ok(hr == E_INVALIDARG, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7560
7561         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_DWORD_START, &received, 0);
7562         ok(hr == E_INVALIDARG, "Error: GetPropertyLength return 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7563         ok(received == 0xdeadbeef, "Error: Expected 0xdeadbeef but got 0x%08x.\n", received);
7564     }
7565     if(uri) IUri_Release(uri);
7566
7567     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7568         uri_properties test = uri_tests[i];
7569         LPWSTR uriW;
7570         uri = NULL;
7571
7572         uriW = a2w(test.uri);
7573         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7574         if(test.create_todo) {
7575             todo_wine {
7576                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7577                         hr, test.create_expected, i);
7578             }
7579         } else {
7580             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_test[%d].\n",
7581                     hr, test.create_expected, i);
7582         }
7583
7584         if(SUCCEEDED(hr)) {
7585             DWORD j;
7586
7587             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
7588                 DWORD expectedLen, brokenLen, receivedLen;
7589                 uri_str_property prop = test.str_props[j];
7590
7591                 expectedLen = lstrlen(prop.value);
7592                 brokenLen = lstrlen(prop.broken_value);
7593
7594                 /* This won't be necessary once GetPropertyLength is implemented. */
7595                 receivedLen = -1;
7596
7597                 hr = IUri_GetPropertyLength(uri, j, &receivedLen, 0);
7598                 if(prop.todo) {
7599                     todo_wine {
7600                         ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
7601                                 hr, prop.expected, i, j);
7602                     }
7603                     todo_wine {
7604                         ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
7605                                 "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
7606                                 expectedLen, receivedLen, i, j);
7607                     }
7608                 } else {
7609                     ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
7610                             hr, prop.expected, i, j);
7611                     ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
7612                             "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
7613                             expectedLen, receivedLen, i, j);
7614                 }
7615             }
7616         }
7617
7618         if(uri) IUri_Release(uri);
7619
7620         heap_free(uriW);
7621     }
7622 }
7623
7624 static DWORD compute_expected_props(uri_properties *test)
7625 {
7626     DWORD ret = 0, i;
7627
7628     for(i=Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_STRING_LAST; i++) {
7629         if(test->str_props[i-Uri_PROPERTY_STRING_START].expected == S_OK)
7630             ret |= 1<<i;
7631     }
7632
7633     for(i=Uri_PROPERTY_DWORD_START; i <= Uri_PROPERTY_DWORD_LAST; i++) {
7634         if(test->dword_props[i-Uri_PROPERTY_DWORD_START].expected == S_OK)
7635             ret |= 1<<i;
7636     }
7637
7638     return ret;
7639 }
7640
7641 static void test_IUri_GetProperties(void) {
7642     IUri *uri = NULL;
7643     HRESULT hr;
7644     DWORD i;
7645
7646     hr = pCreateUri(http_urlW, 0, 0, &uri);
7647     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7648     if(SUCCEEDED(hr)) {
7649         hr = IUri_GetProperties(uri, NULL);
7650         ok(hr == E_INVALIDARG, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7651     }
7652     if(uri) IUri_Release(uri);
7653
7654     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7655         uri_properties test = uri_tests[i];
7656         LPWSTR uriW;
7657         uri = NULL;
7658
7659         uriW = a2w(test.uri);
7660         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7661         if(test.create_todo) {
7662             todo_wine {
7663                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7664             }
7665         } else {
7666             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7667         }
7668
7669         if(SUCCEEDED(hr)) {
7670             DWORD received = 0, expected_props;
7671             DWORD j;
7672
7673             hr = IUri_GetProperties(uri, &received);
7674             ok(hr == S_OK, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7675
7676             expected_props = compute_expected_props(&test);
7677
7678             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
7679                 /* (1 << j) converts a Uri_PROPERTY to its corresponding Uri_HAS_* flag mask. */
7680                 if(expected_props & (1 << j))
7681                     ok(received & (1 << j), "Error: Expected flag for property %d on uri_tests[%d].\n", j, i);
7682                 else
7683                     ok(!(received & (1 << j)), "Error: Received flag for property %d when not expected on uri_tests[%d].\n", j, i);
7684             }
7685         }
7686
7687         if(uri) IUri_Release(uri);
7688
7689         heap_free(uriW);
7690     }
7691 }
7692
7693 static void test_IUri_HasProperty(void) {
7694     IUri *uri = NULL;
7695     HRESULT hr;
7696     DWORD i;
7697
7698     hr = pCreateUri(http_urlW, 0, 0, &uri);
7699     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7700     if(SUCCEEDED(hr)) {
7701         hr = IUri_HasProperty(uri, Uri_PROPERTY_RAW_URI, NULL);
7702         ok(hr == E_INVALIDARG, "Error: HasProperty returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7703     }
7704     if(uri) IUri_Release(uri);
7705
7706     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7707         uri_properties test = uri_tests[i];
7708         LPWSTR uriW;
7709         uri = NULL;
7710
7711         uriW = a2w(test.uri);
7712
7713         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7714         if(test.create_todo) {
7715             todo_wine {
7716                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7717             }
7718         } else {
7719             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7720         }
7721
7722         if(SUCCEEDED(hr)) {
7723             DWORD expected_props, j;
7724
7725             expected_props = compute_expected_props(&test);
7726
7727             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
7728                 /* Assign -1, then explicitly test for TRUE or FALSE later. */
7729                 BOOL received = -1;
7730
7731                 hr = IUri_HasProperty(uri, j, &received);
7732                 ok(hr == S_OK, "Error: HasProperty returned 0x%08x, expected 0x%08x for property %d on uri_tests[%d].\n",
7733                         hr, S_OK, j, i);
7734
7735                 if(expected_props & (1 << j)) {
7736                     ok(received == TRUE, "Error: Expected to have property %d on uri_tests[%d].\n", j, i);
7737                 } else {
7738                     ok(received == FALSE, "Error: Wasn't expecting to have property %d on uri_tests[%d].\n", j, i);
7739                 }
7740             }
7741         }
7742
7743         if(uri) IUri_Release(uri);
7744
7745         heap_free(uriW);
7746     }
7747 }
7748
7749 static void test_IUri_IsEqual(void) {
7750     IUri *uriA, *uriB;
7751     BOOL equal;
7752     HRESULT hres;
7753     DWORD i;
7754
7755     uriA = uriB = NULL;
7756
7757     /* Make sure IsEqual handles invalid args correctly. */
7758     hres = pCreateUri(http_urlW, 0, 0, &uriA);
7759     ok(hres == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hres, S_OK);
7760     hres = pCreateUri(http_urlW, 0, 0, &uriB);
7761     ok(hres == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hres, S_OK);
7762
7763     equal = -1;
7764     hres = IUri_IsEqual(uriA, NULL, &equal);
7765     ok(hres == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hres, S_OK);
7766     ok(!equal, "Error: Expected equal to be FALSE, but was %d instead.\n", equal);
7767
7768     hres = IUri_IsEqual(uriA, uriB, NULL);
7769     ok(hres == E_POINTER, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hres, E_POINTER);
7770
7771     IUri_Release(uriA);
7772     IUri_Release(uriB);
7773
7774     for(i = 0; i < sizeof(equality_tests)/sizeof(equality_tests[0]); ++i) {
7775         uri_equality test = equality_tests[i];
7776         LPWSTR uriA_W, uriB_W;
7777
7778         uriA = uriB = NULL;
7779
7780         uriA_W = a2w(test.a);
7781         uriB_W = a2w(test.b);
7782
7783         hres = pCreateUri(uriA_W, test.create_flags_a, 0, &uriA);
7784         ok(hres == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n", hres, S_OK, i);
7785
7786         hres = pCreateUri(uriB_W, test.create_flags_b, 0, &uriB);
7787         ok(hres == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n", hres, S_OK, i);
7788
7789         equal = -1;
7790         hres = IUri_IsEqual(uriA, uriB, &equal);
7791         if(test.todo) todo_wine {
7792             ok(hres == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n", hres, S_OK, i);
7793             ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7794         } else {
7795             ok(hres == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n", hres, S_OK, i);
7796             ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7797         }
7798         if(uriA) IUri_Release(uriA);
7799         if(uriB) IUri_Release(uriB);
7800
7801         heap_free(uriA_W);
7802         heap_free(uriB_W);
7803     }
7804 }
7805
7806 static void test_CreateUriWithFragment_InvalidArgs(void) {
7807     HRESULT hr;
7808     IUri *uri = (void*) 0xdeadbeef;
7809     const WCHAR fragmentW[] = {'#','f','r','a','g','m','e','n','t',0};
7810
7811     hr = pCreateUriWithFragment(NULL, fragmentW, 0, 0, &uri);
7812     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7813     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7814
7815     hr = pCreateUriWithFragment(http_urlW, fragmentW, 0, 0, NULL);
7816     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7817
7818     /* Original URI can't already contain a fragment component. */
7819     uri = (void*) 0xdeadbeef;
7820     hr = pCreateUriWithFragment(http_url_fragW, fragmentW, 0, 0, &uri);
7821     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7822     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7823 }
7824
7825 /* CreateUriWithFragment has the same invalid flag combinations as CreateUri. */
7826 static void test_CreateUriWithFragment_InvalidFlags(void) {
7827     DWORD i;
7828
7829     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
7830         HRESULT hr;
7831         IUri *uri = (void*) 0xdeadbeef;
7832
7833         hr = pCreateUriWithFragment(http_urlW, NULL, invalid_flag_tests[i].flags, 0, &uri);
7834         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x. flags=0x%08x.\n",
7835             hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
7836         ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7837     }
7838 }
7839
7840 static void test_CreateUriWithFragment(void) {
7841     DWORD i;
7842
7843     for(i = 0; i < sizeof(uri_fragment_tests)/sizeof(uri_fragment_tests[0]); ++i) {
7844         HRESULT hr;
7845         IUri *uri = NULL;
7846         LPWSTR uriW, fragW;
7847         uri_with_fragment test = uri_fragment_tests[i];
7848
7849         uriW = a2w(test.uri);
7850         fragW = a2w(test.fragment);
7851
7852         hr = pCreateUriWithFragment(uriW, fragW, test.create_flags, 0, &uri);
7853         if(test.expected_todo) {
7854             todo_wine {
7855                 ok(hr == test.create_expected,
7856                     "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7857                     hr, test.create_expected, i);
7858             }
7859         } else
7860             ok(hr == test.create_expected,
7861                 "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7862                 hr, test.create_expected, i);
7863
7864         if(SUCCEEDED(hr)) {
7865             BSTR received = NULL;
7866
7867             hr = IUri_GetAbsoluteUri(uri, &received);
7868             if(test.expected_todo) {
7869                 todo_wine {
7870                     ok(hr == S_OK,
7871                         "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7872                         hr, S_OK, i);
7873                 }
7874                 todo_wine {
7875                     ok(!strcmp_aw(test.expected_uri, received),
7876                         "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7877                         test.expected_uri, wine_dbgstr_w(received), i);
7878                 }
7879             } else {
7880                 ok(hr == S_OK, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7881                     hr, S_OK, i);
7882                 ok(!strcmp_aw(test.expected_uri, received), "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7883                     test.expected_uri, wine_dbgstr_w(received), i);
7884             }
7885
7886             SysFreeString(received);
7887         }
7888
7889         if(uri) IUri_Release(uri);
7890         heap_free(uriW);
7891         heap_free(fragW);
7892     }
7893 }
7894
7895 static void test_CreateIUriBuilder(void) {
7896     HRESULT hr;
7897     IUriBuilder *builder = NULL;
7898     IUri *uri;
7899
7900     hr = pCreateIUriBuilder(NULL, 0, 0, NULL);
7901     ok(hr == E_POINTER, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x\n",
7902         hr, E_POINTER);
7903
7904     /* CreateIUriBuilder increases the ref count of the IUri it receives. */
7905     hr = pCreateUri(http_urlW, 0, 0, &uri);
7906     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7907     if(SUCCEEDED(hr)) {
7908         ULONG cur_count, orig_count;
7909
7910         orig_count = get_refcnt(uri);
7911         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
7912         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7913         ok(builder != NULL, "Error: Expecting builder not to be NULL\n");
7914
7915         cur_count = get_refcnt(uri);
7916         ok(cur_count == orig_count+1, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count+1, cur_count);
7917
7918         if(builder) IUriBuilder_Release(builder);
7919         cur_count = get_refcnt(uri);
7920         ok(cur_count == orig_count, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count, cur_count);
7921     }
7922     if(uri) IUri_Release(uri);
7923 }
7924
7925 static void test_IUriBuilder_CreateUri(IUriBuilder *builder, const uri_builder_test *test,
7926                                        DWORD test_index) {
7927     HRESULT hr;
7928     IUri *uri = NULL;
7929
7930     hr = IUriBuilder_CreateUri(builder, test->uri_flags, 0, 0, &uri);
7931     if(test->uri_todo) {
7932         todo_wine {
7933             ok(hr == test->uri_hres,
7934                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7935                 hr, test->uri_hres, test_index);
7936         }
7937     } else {
7938         ok(hr == test->uri_hres,
7939             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7940             hr, test->uri_hres, test_index);
7941     }
7942
7943     if(SUCCEEDED(hr)) {
7944         DWORD i;
7945
7946         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7947             uri_builder_str_property prop = test->expected_str_props[i];
7948             BSTR received = NULL;
7949
7950             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7951             if(prop.todo) {
7952                 todo_wine {
7953                     ok(hr == prop.result,
7954                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7955                         hr, prop.result, test_index, i);
7956                 }
7957             } else {
7958                 ok(hr == prop.result,
7959                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7960                     hr, prop.result, test_index, i);
7961             }
7962             if(SUCCEEDED(hr)) {
7963                 if(prop.todo) {
7964                     todo_wine {
7965                         ok(!strcmp_aw(prop.expected, received),
7966                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7967                             prop.expected, wine_dbgstr_w(received), test_index, i);
7968                     }
7969                 } else {
7970                     ok(!strcmp_aw(prop.expected, received),
7971                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7972                         prop.expected, wine_dbgstr_w(received), test_index, i);
7973                 }
7974             }
7975             SysFreeString(received);
7976         }
7977
7978         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7979             uri_builder_dword_property prop = test->expected_dword_props[i];
7980             DWORD received = -2;
7981
7982             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7983             if(prop.todo) {
7984                 todo_wine {
7985                     ok(hr == prop.result,
7986                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7987                         hr, prop.result, test_index, i);
7988                 }
7989             } else {
7990                 ok(hr == prop.result,
7991                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7992                     hr, prop.result, test_index, i);
7993             }
7994             if(SUCCEEDED(hr)) {
7995                 if(prop.todo) {
7996                     todo_wine {
7997                         ok(received == prop.expected,
7998                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7999                             prop.expected, received, test_index, i);
8000                     }
8001                 } else {
8002                     ok(received == prop.expected,
8003                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
8004                         prop.expected, received, test_index, i);
8005                 }
8006             }
8007         }
8008     }
8009     if(uri) IUri_Release(uri);
8010 }
8011
8012 static void test_IUriBuilder_CreateUriSimple(IUriBuilder *builder, const uri_builder_test *test,
8013                                        DWORD test_index) {
8014     HRESULT hr;
8015     IUri *uri = NULL;
8016
8017     hr = IUriBuilder_CreateUriSimple(builder, test->uri_simple_encode_flags, 0, &uri);
8018     if(test->uri_simple_todo) {
8019         todo_wine {
8020             ok(hr == test->uri_simple_hres,
8021                 "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8022                 hr, test->uri_simple_hres, test_index);
8023         }
8024     } else {
8025         ok(hr == test->uri_simple_hres,
8026             "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8027             hr, test->uri_simple_hres, test_index);
8028     }
8029
8030     if(SUCCEEDED(hr)) {
8031         DWORD i;
8032
8033         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
8034             uri_builder_str_property prop = test->expected_str_props[i];
8035             BSTR received = NULL;
8036
8037             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
8038             if(prop.todo) {
8039                 todo_wine {
8040                     ok(hr == prop.result,
8041                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
8042                         hr, prop.result, test_index, i);
8043                 }
8044             } else {
8045                 ok(hr == prop.result,
8046                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
8047                     hr, prop.result, test_index, i);
8048             }
8049             if(SUCCEEDED(hr)) {
8050                 if(prop.todo) {
8051                     todo_wine {
8052                         ok(!strcmp_aw(prop.expected, received),
8053                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
8054                             prop.expected, wine_dbgstr_w(received), test_index, i);
8055                     }
8056                 } else {
8057                     ok(!strcmp_aw(prop.expected, received),
8058                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
8059                         prop.expected, wine_dbgstr_w(received), test_index, i);
8060                 }
8061             }
8062             SysFreeString(received);
8063         }
8064
8065         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
8066             uri_builder_dword_property prop = test->expected_dword_props[i];
8067             DWORD received = -2;
8068
8069             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
8070             if(prop.todo) {
8071                 todo_wine {
8072                     ok(hr == prop.result,
8073                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
8074                         hr, prop.result, test_index, i);
8075                 }
8076             } else {
8077                 ok(hr == prop.result,
8078                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
8079                     hr, prop.result, test_index, i);
8080             }
8081             if(SUCCEEDED(hr)) {
8082                 if(prop.todo) {
8083                     todo_wine {
8084                         ok(received == prop.expected,
8085                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
8086                             prop.expected, received, test_index, i);
8087                     }
8088                 } else {
8089                     ok(received == prop.expected,
8090                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
8091                         prop.expected, received, test_index, i);
8092                 }
8093             }
8094         }
8095     }
8096     if(uri) IUri_Release(uri);
8097 }
8098
8099 static void test_IUriBuilder_CreateUriWithFlags(IUriBuilder *builder, const uri_builder_test *test,
8100                                                 DWORD test_index) {
8101     HRESULT hr;
8102     IUri *uri = NULL;
8103
8104     hr = IUriBuilder_CreateUriWithFlags(builder, test->uri_with_flags, test->uri_with_builder_flags,
8105                                         test->uri_with_encode_flags, 0, &uri);
8106     if(test->uri_with_todo) {
8107         todo_wine {
8108             ok(hr == test->uri_with_hres,
8109                 "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8110                 hr, test->uri_with_hres, test_index);
8111         }
8112     } else {
8113         ok(hr == test->uri_with_hres,
8114             "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8115             hr, test->uri_with_hres, test_index);
8116     }
8117
8118     if(SUCCEEDED(hr)) {
8119         DWORD i;
8120
8121         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
8122             uri_builder_str_property prop = test->expected_str_props[i];
8123             BSTR received = NULL;
8124
8125             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
8126             if(prop.todo) {
8127                 todo_wine {
8128                     ok(hr == prop.result,
8129                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
8130                         hr, prop.result, test_index, i);
8131                 }
8132             } else {
8133                 ok(hr == prop.result,
8134                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
8135                     hr, prop.result, test_index, i);
8136             }
8137             if(SUCCEEDED(hr)) {
8138                 if(prop.todo) {
8139                     todo_wine {
8140                         ok(!strcmp_aw(prop.expected, received),
8141                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
8142                             prop.expected, wine_dbgstr_w(received), test_index, i);
8143                     }
8144                 } else {
8145                     ok(!strcmp_aw(prop.expected, received),
8146                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
8147                         prop.expected, wine_dbgstr_w(received), test_index, i);
8148                 }
8149             }
8150             SysFreeString(received);
8151         }
8152
8153         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
8154             uri_builder_dword_property prop = test->expected_dword_props[i];
8155             DWORD received = -2;
8156
8157             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
8158             if(prop.todo) {
8159                 todo_wine {
8160                     ok(hr == prop.result,
8161                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
8162                         hr, prop.result, test_index, i);
8163                 }
8164             } else {
8165                 ok(hr == prop.result,
8166                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
8167                     hr, prop.result, test_index, i);
8168             }
8169             if(SUCCEEDED(hr)) {
8170                 if(prop.todo) {
8171                     todo_wine {
8172                         ok(received == prop.expected,
8173                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
8174                             prop.expected, received, test_index, i);
8175                     }
8176                 } else {
8177                     ok(received == prop.expected,
8178                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
8179                         prop.expected, received, test_index, i);
8180                 }
8181             }
8182         }
8183     }
8184     if(uri) IUri_Release(uri);
8185 }
8186
8187 static void test_IUriBuilder_CreateInvalidArgs(void) {
8188     IUriBuilder *builder;
8189     HRESULT hr;
8190
8191     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8192     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8193     if(SUCCEEDED(hr)) {
8194         IUri *test = NULL, *uri = (void*) 0xdeadbeef;
8195
8196         /* Test what happens if the IUriBuilder doesn't have a IUri set. */
8197         hr = IUriBuilder_CreateUri(builder, 0, 0, 0, NULL);
8198         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
8199
8200         uri = (void*) 0xdeadbeef;
8201         hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
8202         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_NOTIMPL);
8203         ok(uri == NULL, "Error: expected uri to be NULL, but was %p instead.\n", uri);
8204
8205         hr = IUriBuilder_CreateUriSimple(builder, 0, 0, NULL);
8206         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8207             hr, E_POINTER);
8208
8209         uri = (void*) 0xdeadbeef;
8210         hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
8211         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8212             hr, E_NOTIMPL);
8213         ok(!uri, "Error: Expected uri to NULL, but was %p instead.\n", uri);
8214
8215         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, NULL);
8216         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8217             hr, E_POINTER);
8218
8219         uri = (void*) 0xdeadbeef;
8220         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
8221         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8222             hr, E_NOTIMPL);
8223         ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
8224
8225         hr = pCreateUri(http_urlW, 0, 0, &test);
8226         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8227         if(SUCCEEDED(hr)) {
8228             hr = IUriBuilder_SetIUri(builder, test);
8229             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8230
8231             /* No longer returns E_NOTIMPL, since a IUri has been set and hasn't been modified. */
8232             uri = NULL;
8233             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
8234             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8235             ok(uri != NULL, "Error: The uri was NULL.\n");
8236             if(uri) IUri_Release(uri);
8237
8238             uri = NULL;
8239             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
8240             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8241                 hr, S_OK);
8242             ok(uri != NULL, "Error: uri was NULL.\n");
8243             if(uri) IUri_Release(uri);
8244
8245             uri = NULL;
8246             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &uri);
8247             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8248                 hr, S_OK);
8249             ok(uri != NULL, "Error: uri was NULL.\n");
8250             if(uri) IUri_Release(uri);
8251
8252             hr = IUriBuilder_SetFragment(builder, NULL);
8253             ok(hr == S_OK, "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8254
8255             /* The IUriBuilder is changed, so it returns E_NOTIMPL again. */
8256             uri = (void*) 0xdeadbeef;
8257             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
8258             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8259             ok(!uri, "Error: Expected uri to be NULL but was %p instead.\n", uri);
8260
8261             uri = (void*) 0xdeadbeef;
8262             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
8263             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8264                 hr, S_OK);
8265             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
8266
8267             uri = (void*) 0xdeadbeef;
8268             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
8269             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8270                 hr, E_NOTIMPL);
8271             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
8272         }
8273         if(test) IUri_Release(test);
8274     }
8275     if(builder) IUriBuilder_Release(builder);
8276 }
8277
8278 /* Tests invalid args to the "Get*" functions. */
8279 static void test_IUriBuilder_GetInvalidArgs(void) {
8280     IUriBuilder *builder = NULL;
8281     HRESULT hr;
8282
8283     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8284     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8285     if(SUCCEEDED(hr)) {
8286         LPCWSTR received = (void*) 0xdeadbeef;
8287         DWORD len = -1, port = -1;
8288         BOOL set = -1;
8289
8290         hr = IUriBuilder_GetFragment(builder, NULL, NULL);
8291         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
8292             hr, E_POINTER);
8293         hr = IUriBuilder_GetFragment(builder, NULL, &received);
8294         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
8295             hr, E_POINTER);
8296         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8297         hr = IUriBuilder_GetFragment(builder, &len, NULL);
8298         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
8299             hr, E_POINTER);
8300         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8301
8302         hr = IUriBuilder_GetHost(builder, NULL, NULL);
8303         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
8304             hr, E_POINTER);
8305         received = (void*) 0xdeadbeef;
8306         hr = IUriBuilder_GetHost(builder, NULL, &received);
8307         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
8308             hr, E_POINTER);
8309         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8310         len = -1;
8311         hr = IUriBuilder_GetHost(builder, &len, NULL);
8312         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
8313             hr, E_POINTER);
8314         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8315
8316         hr = IUriBuilder_GetPassword(builder, NULL, NULL);
8317         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
8318             hr, E_POINTER);
8319         received = (void*) 0xdeadbeef;
8320         hr = IUriBuilder_GetPassword(builder, NULL, &received);
8321         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
8322             hr, E_POINTER);
8323         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8324         len = -1;
8325         hr = IUriBuilder_GetPassword(builder, &len, NULL);
8326         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
8327             hr, E_POINTER);
8328         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8329
8330         hr = IUriBuilder_GetPath(builder, NULL, NULL);
8331         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8332             hr, E_POINTER);
8333         received = (void*) 0xdeadbeef;
8334         hr = IUriBuilder_GetPath(builder, NULL, &received);
8335         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8336             hr, E_POINTER);
8337         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8338         len = -1;
8339         hr = IUriBuilder_GetPath(builder, &len, NULL);
8340         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8341             hr, E_POINTER);
8342         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8343
8344         hr = IUriBuilder_GetPort(builder, NULL, NULL);
8345         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8346             hr, E_POINTER);
8347         hr = IUriBuilder_GetPort(builder, NULL, &port);
8348         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8349             hr, E_POINTER);
8350         ok(!port, "Error: Expected port to be 0, but was %d instead.\n", port);
8351         hr = IUriBuilder_GetPort(builder, &set, NULL);
8352         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8353             hr, E_POINTER);
8354         ok(!set, "Error: Expected set to be FALSE, but was %d instead.\n", set);
8355
8356         hr = IUriBuilder_GetQuery(builder, NULL, NULL);
8357         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8358             hr, E_POINTER);
8359         received = (void*) 0xdeadbeef;
8360         hr = IUriBuilder_GetQuery(builder, NULL, &received);
8361         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8362             hr, E_POINTER);
8363         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8364         len = -1;
8365         hr = IUriBuilder_GetQuery(builder, &len, NULL);
8366         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8367             hr, E_POINTER);
8368         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8369
8370         hr = IUriBuilder_GetSchemeName(builder, NULL, NULL);
8371         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8372             hr, E_POINTER);
8373         received = (void*) 0xdeadbeef;
8374         hr = IUriBuilder_GetSchemeName(builder, NULL, &received);
8375         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8376             hr, E_POINTER);
8377         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8378         len = -1;
8379         hr = IUriBuilder_GetSchemeName(builder, &len, NULL);
8380         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8381             hr, E_POINTER);
8382         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8383
8384         hr = IUriBuilder_GetUserName(builder, NULL, NULL);
8385         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8386             hr, E_POINTER);
8387         received = (void*) 0xdeadbeef;
8388         hr = IUriBuilder_GetUserName(builder, NULL, &received);
8389         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8390             hr, E_POINTER);
8391         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8392         len = -1;
8393         hr = IUriBuilder_GetUserName(builder, &len, NULL);
8394         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8395             hr, E_POINTER);
8396         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8397     }
8398     if(builder) IUriBuilder_Release(builder);
8399 }
8400
8401 static void test_IUriBuilder_GetFragment(IUriBuilder *builder, const uri_builder_test *test,
8402                                          DWORD test_index) {
8403     HRESULT hr;
8404     DWORD i;
8405     LPCWSTR received = NULL;
8406     DWORD len = -1;
8407     const uri_builder_property *prop = NULL;
8408
8409     /* Check if the property was set earlier. */
8410     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8411         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_FRAGMENT)
8412             prop = &(test->properties[i]);
8413     }
8414
8415     if(prop) {
8416         /* Use expected_value unless it's NULL, then use value. */
8417         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8418         hr = IUriBuilder_GetFragment(builder, &len, &received);
8419         if(prop->todo) {
8420             todo_wine {
8421                 ok(hr == (expected ? S_OK : S_FALSE),
8422                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8423                     hr, (expected ? S_OK : S_FALSE), test_index);
8424             }
8425             if(SUCCEEDED(hr)) {
8426                 todo_wine {
8427                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8428                         expected, wine_dbgstr_w(received), test_index);
8429                 }
8430                 todo_wine {
8431                     ok(lstrlen(expected) == len,
8432                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8433                         lstrlen(expected), len, test_index);
8434                 }
8435             }
8436         } else {
8437             ok(hr == (expected ? S_OK : S_FALSE),
8438                 "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8439                 hr, (expected ? S_OK : S_FALSE), test_index);
8440             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8441                 expected, wine_dbgstr_w(received), test_index);
8442             ok(lstrlen(expected) == len,
8443                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8444                 lstrlen(expected), len, test_index);
8445         }
8446     } else {
8447         /* The property wasn't set earlier, so it should return whatever
8448          * the base IUri contains (if anything).
8449          */
8450         IUri *uri = NULL;
8451         hr = IUriBuilder_GetIUri(builder, &uri);
8452         ok(hr == S_OK,
8453             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8454             hr, S_OK, test_index);
8455         if(SUCCEEDED(hr)) {
8456             if(!uri) {
8457                 received = (void*) 0xdeadbeef;
8458                 len = -1;
8459
8460                 hr = IUriBuilder_GetFragment(builder, &len, &received);
8461                 ok(hr == S_FALSE,
8462                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8463                     hr, S_FALSE, test_index);
8464                 if(SUCCEEDED(hr)) {
8465                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8466                         len, test_index);
8467                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8468                         received, test_index);
8469                 }
8470             } else {
8471                 BOOL has_prop = FALSE;
8472                 BSTR expected = NULL;
8473
8474                 hr = IUri_GetFragment(uri, &expected);
8475                 ok(SUCCEEDED(hr),
8476                     "Error: Expected IUri_GetFragment to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8477                     hr, test_index);
8478                 has_prop = hr == S_OK;
8479
8480                 hr = IUriBuilder_GetFragment(builder, &len, &received);
8481                 if(has_prop) {
8482                     ok(hr == S_OK,
8483                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8484                         hr, S_OK, test_index);
8485                     if(SUCCEEDED(hr)) {
8486                         ok(!lstrcmpW(expected, received),
8487                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8488                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8489                         ok(lstrlenW(expected) == len,
8490                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8491                             lstrlenW(expected), len, test_index);
8492                     }
8493                 } else {
8494                     ok(hr == S_FALSE,
8495                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8496                         hr, S_FALSE, test_index);
8497                     if(SUCCEEDED(hr)) {
8498                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8499                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8500                             len, test_index);
8501                     }
8502                 }
8503                 SysFreeString(expected);
8504             }
8505         }
8506         if(uri) IUri_Release(uri);
8507     }
8508 }
8509
8510 static void test_IUriBuilder_GetHost(IUriBuilder *builder, const uri_builder_test *test,
8511                                      DWORD test_index) {
8512     HRESULT hr;
8513     DWORD i;
8514     LPCWSTR received = NULL;
8515     DWORD len = -1;
8516     const uri_builder_property *prop = NULL;
8517
8518     /* Check if the property was set earlier. */
8519     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8520         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_HOST)
8521             prop = &(test->properties[i]);
8522     }
8523
8524     if(prop) {
8525         /* Use expected_value unless it's NULL, then use value. */
8526         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8527         hr = IUriBuilder_GetHost(builder, &len, &received);
8528         if(prop->todo) {
8529             todo_wine {
8530                 ok(hr == (expected ? S_OK : S_FALSE),
8531                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8532                     hr, (expected ? S_OK : S_FALSE), test_index);
8533             }
8534             if(SUCCEEDED(hr)) {
8535                 todo_wine {
8536                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8537                         expected, wine_dbgstr_w(received), test_index);
8538                 }
8539                 todo_wine {
8540                     ok(lstrlen(expected) == len,
8541                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8542                         lstrlen(expected), len, test_index);
8543                 }
8544             }
8545         } else {
8546             ok(hr == (expected ? S_OK : S_FALSE),
8547                 "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8548                 hr, (expected ? S_OK : S_FALSE), test_index);
8549             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8550                 expected, wine_dbgstr_w(received), test_index);
8551             ok(lstrlen(expected) == len,
8552                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8553                 lstrlen(expected), len, test_index);
8554         }
8555     } else {
8556         /* The property wasn't set earlier, so it should return whatever
8557          * the base IUri contains (if anything).
8558          */
8559         IUri *uri = NULL;
8560         hr = IUriBuilder_GetIUri(builder, &uri);
8561         ok(hr == S_OK,
8562             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8563             hr, S_OK, test_index);
8564         if(SUCCEEDED(hr)) {
8565             if(!uri) {
8566                 received = (void*) 0xdeadbeef;
8567                 len = -1;
8568
8569                 hr = IUriBuilder_GetHost(builder, &len, &received);
8570                 ok(hr == S_FALSE,
8571                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8572                     hr, S_FALSE, test_index);
8573                 if(SUCCEEDED(hr)) {
8574                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8575                         len, test_index);
8576                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8577                         received, test_index);
8578                 }
8579             } else {
8580                 BOOL has_prop = FALSE;
8581                 BSTR expected = NULL;
8582
8583                 hr = IUri_GetHost(uri, &expected);
8584                 ok(SUCCEEDED(hr),
8585                     "Error: Expected IUri_GetHost to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8586                     hr, test_index);
8587                 has_prop = hr == S_OK;
8588
8589                 hr = IUriBuilder_GetHost(builder, &len, &received);
8590                 if(has_prop) {
8591                     ok(hr == S_OK,
8592                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8593                         hr, S_OK, test_index);
8594                     if(SUCCEEDED(hr)) {
8595                         ok(!lstrcmpW(expected, received),
8596                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8597                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8598                         ok(lstrlenW(expected) == len,
8599                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8600                             lstrlenW(expected), len, test_index);
8601                     }
8602                 } else {
8603                     ok(hr == S_FALSE,
8604                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8605                         hr, S_FALSE, test_index);
8606                     if(SUCCEEDED(hr)) {
8607                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8608                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8609                             len, test_index);
8610                     }
8611                 }
8612                 SysFreeString(expected);
8613             }
8614         }
8615         if(uri) IUri_Release(uri);
8616     }
8617 }
8618
8619 static void test_IUriBuilder_GetPassword(IUriBuilder *builder, const uri_builder_test *test,
8620                                          DWORD test_index) {
8621     HRESULT hr;
8622     DWORD i;
8623     LPCWSTR received = NULL;
8624     DWORD len = -1;
8625     const uri_builder_property *prop = NULL;
8626
8627     /* Check if the property was set earlier. */
8628     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8629         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PASSWORD)
8630             prop = &(test->properties[i]);
8631     }
8632
8633     if(prop) {
8634         /* Use expected_value unless it's NULL, then use value. */
8635         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8636         hr = IUriBuilder_GetPassword(builder, &len, &received);
8637         if(prop->todo) {
8638             todo_wine {
8639                 ok(hr == (expected ? S_OK : S_FALSE),
8640                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8641                     hr, (expected ? S_OK : S_FALSE), test_index);
8642             }
8643             if(SUCCEEDED(hr)) {
8644                 todo_wine {
8645                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8646                         expected, wine_dbgstr_w(received), test_index);
8647                 }
8648                 todo_wine {
8649                     ok(lstrlen(expected) == len,
8650                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8651                         lstrlen(expected), len, test_index);
8652                 }
8653             }
8654         } else {
8655             ok(hr == (expected ? S_OK : S_FALSE),
8656                 "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8657                 hr, (expected ? S_OK : S_FALSE), test_index);
8658             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8659                 expected, wine_dbgstr_w(received), test_index);
8660             ok(lstrlen(expected) == len,
8661                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8662                 lstrlen(expected), len, test_index);
8663         }
8664     } else {
8665         /* The property wasn't set earlier, so it should return whatever
8666          * the base IUri contains (if anything).
8667          */
8668         IUri *uri = NULL;
8669         hr = IUriBuilder_GetIUri(builder, &uri);
8670         ok(hr == S_OK,
8671             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8672             hr, S_OK, test_index);
8673         if(SUCCEEDED(hr)) {
8674             if(!uri) {
8675                 received = (void*) 0xdeadbeef;
8676                 len = -1;
8677
8678                 hr = IUriBuilder_GetPassword(builder, &len, &received);
8679                 ok(hr == S_FALSE,
8680                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8681                     hr, S_FALSE, test_index);
8682                 if(SUCCEEDED(hr)) {
8683                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8684                         len, test_index);
8685                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8686                         received, test_index);
8687                 }
8688             } else {
8689                 BOOL has_prop = FALSE;
8690                 BSTR expected = NULL;
8691
8692                 hr = IUri_GetPassword(uri, &expected);
8693                 ok(SUCCEEDED(hr),
8694                     "Error: Expected IUri_GetPassword to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8695                     hr, test_index);
8696                 has_prop = hr == S_OK;
8697
8698                 hr = IUriBuilder_GetPassword(builder, &len, &received);
8699                 if(has_prop) {
8700                     ok(hr == S_OK,
8701                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8702                         hr, S_OK, test_index);
8703                     if(SUCCEEDED(hr)) {
8704                         ok(!lstrcmpW(expected, received),
8705                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8706                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8707                         ok(lstrlenW(expected) == len,
8708                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8709                             lstrlenW(expected), len, test_index);
8710                     }
8711                 } else {
8712                     ok(hr == S_FALSE,
8713                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8714                         hr, S_FALSE, test_index);
8715                     if(SUCCEEDED(hr)) {
8716                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8717                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8718                             len, test_index);
8719                     }
8720                 }
8721                 SysFreeString(expected);
8722             }
8723         }
8724         if(uri) IUri_Release(uri);
8725     }
8726 }
8727
8728 static void test_IUriBuilder_GetPath(IUriBuilder *builder, const uri_builder_test *test,
8729                                      DWORD test_index) {
8730     HRESULT hr;
8731     DWORD i;
8732     LPCWSTR received = NULL;
8733     DWORD len = -1;
8734     const uri_builder_property *prop = NULL;
8735
8736     /* Check if the property was set earlier. */
8737     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8738         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PATH)
8739             prop = &(test->properties[i]);
8740     }
8741
8742     if(prop) {
8743         /* Use expected_value unless it's NULL, then use value. */
8744         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8745         hr = IUriBuilder_GetPath(builder, &len, &received);
8746         if(prop->todo) {
8747             todo_wine {
8748                 ok(hr == (expected ? S_OK : S_FALSE),
8749                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8750                     hr, (expected ? S_OK : S_FALSE), test_index);
8751             }
8752             if(SUCCEEDED(hr)) {
8753                 todo_wine {
8754                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8755                         expected, wine_dbgstr_w(received), test_index);
8756                 }
8757                 todo_wine {
8758                     ok(lstrlen(expected) == len,
8759                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8760                         lstrlen(expected), len, test_index);
8761                 }
8762             }
8763         } else {
8764             ok(hr == (expected ? S_OK : S_FALSE),
8765                 "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8766                 hr, (expected ? S_OK : S_FALSE), test_index);
8767             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8768                 expected, wine_dbgstr_w(received), test_index);
8769             ok(lstrlen(expected) == len,
8770                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8771                 lstrlen(expected), len, test_index);
8772         }
8773     } else {
8774         /* The property wasn't set earlier, so it should return whatever
8775          * the base IUri contains (if anything).
8776          */
8777         IUri *uri = NULL;
8778         hr = IUriBuilder_GetIUri(builder, &uri);
8779         ok(hr == S_OK,
8780             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8781             hr, S_OK, test_index);
8782         if(SUCCEEDED(hr)) {
8783             if(!uri) {
8784                 received = (void*) 0xdeadbeef;
8785                 len = -1;
8786
8787                 hr = IUriBuilder_GetPath(builder, &len, &received);
8788                 ok(hr == S_FALSE,
8789                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8790                     hr, S_FALSE, test_index);
8791                 if(SUCCEEDED(hr)) {
8792                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8793                         len, test_index);
8794                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8795                         received, test_index);
8796                 }
8797             } else {
8798                 BOOL has_prop = FALSE;
8799                 BSTR expected = NULL;
8800
8801                 hr = IUri_GetPath(uri, &expected);
8802                 ok(SUCCEEDED(hr),
8803                     "Error: Expected IUri_GetPath to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8804                     hr, test_index);
8805                 has_prop = hr == S_OK;
8806
8807                 hr = IUriBuilder_GetPath(builder, &len, &received);
8808                 if(has_prop) {
8809                     ok(hr == S_OK,
8810                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8811                         hr, S_OK, test_index);
8812                     if(SUCCEEDED(hr)) {
8813                         ok(!lstrcmpW(expected, received),
8814                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8815                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8816                         ok(lstrlenW(expected) == len,
8817                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8818                             lstrlenW(expected), len, test_index);
8819                     }
8820                 } else {
8821                     ok(hr == S_FALSE,
8822                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8823                         hr, S_FALSE, test_index);
8824                     if(SUCCEEDED(hr)) {
8825                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8826                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8827                             len, test_index);
8828                     }
8829                 }
8830                 SysFreeString(expected);
8831             }
8832         }
8833         if(uri) IUri_Release(uri);
8834     }
8835 }
8836
8837 static void test_IUriBuilder_GetPort(IUriBuilder *builder, const uri_builder_test *test,
8838                                      DWORD test_index) {
8839     HRESULT hr;
8840     BOOL has_port = FALSE;
8841     DWORD received = -1;
8842
8843     if(test->port_prop.change) {
8844         DWORD expected = test->port_prop.value;
8845
8846         hr = IUriBuilder_GetPort(builder, &has_port, &received);
8847         if(test->port_prop.todo) {
8848             todo_wine {
8849                 ok(hr == S_OK,
8850                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8851                     hr, S_OK, test_index);
8852             }
8853             if(SUCCEEDED(hr)) {
8854                 todo_wine {
8855                     ok(has_port == test->port_prop.set,
8856                         "Error: Expected has_port to be %d but was %d instead on uri_builder_tests[%d].\n",
8857                         test->port_prop.set, has_port, test_index);
8858                 }
8859                 todo_wine {
8860                     ok(received == expected,
8861                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8862                         expected, received, test_index);
8863                 }
8864             }
8865         } else {
8866             ok(hr == S_OK,
8867                 "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8868                 hr, S_OK, test_index);
8869             ok(has_port == test->port_prop.set,
8870                 "Error: Expected has_port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8871                 test->port_prop.set, has_port, test_index);
8872             ok(received == test->port_prop.value,
8873                 "Error: Expected port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8874                 test->port_prop.value, received, test_index);
8875         }
8876     } else {
8877         IUri *uri = NULL;
8878
8879         hr = IUriBuilder_GetIUri(builder, &uri);
8880         ok(hr == S_OK,
8881             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8882             hr, S_OK, test_index);
8883         if(SUCCEEDED(hr)) {
8884             if(!uri) {
8885                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8886                 ok(hr == S_OK,
8887                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8888                     hr, S_OK, test_index);
8889                 if(SUCCEEDED(hr)) {
8890                     ok(has_port == FALSE,
8891                         "Error: Expected has_port to be FALSE, but was %d instead on uri_builder_tests[%d].\n",
8892                         has_port, test_index);
8893                     ok(!received, "Error: Expected received to be 0, but was %d instead on uri_builder_tests[%d].\n",
8894                         received, test_index);
8895                 }
8896             } else {
8897                 DWORD expected;
8898
8899                 hr = IUri_GetPort(uri, &expected);
8900                 ok(SUCCEEDED(hr),
8901                     "Error: Expected IUri_Port to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8902                     hr, test_index);
8903
8904                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8905                 ok(hr == S_OK,
8906                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8907                     hr, S_OK, test_index);
8908                 if(SUCCEEDED(hr)) {
8909                     ok(!has_port,
8910                         "Error: Expected has_port to be FALSE but was TRUE instead on uri_builder_tests[%d].\n",
8911                         test_index);
8912                     ok(received == expected,
8913                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8914                         expected, received, test_index);
8915                 }
8916             }
8917         }
8918         if(uri) IUri_Release(uri);
8919     }
8920 }
8921
8922 static void test_IUriBuilder_GetQuery(IUriBuilder *builder, const uri_builder_test *test,
8923                                       DWORD test_index) {
8924     HRESULT hr;
8925     DWORD i;
8926     LPCWSTR received = NULL;
8927     DWORD len = -1;
8928     const uri_builder_property *prop = NULL;
8929
8930     /* Check if the property was set earlier. */
8931     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8932         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_QUERY)
8933             prop = &(test->properties[i]);
8934     }
8935
8936     if(prop) {
8937         /* Use expected_value unless it's NULL, then use value. */
8938         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8939         hr = IUriBuilder_GetQuery(builder, &len, &received);
8940         if(prop->todo) {
8941             todo_wine {
8942                 ok(hr == (expected ? S_OK : S_FALSE),
8943                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8944                     hr, (expected ? S_OK : S_FALSE), test_index);
8945             }
8946             if(SUCCEEDED(hr)) {
8947                 todo_wine {
8948                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8949                         expected, wine_dbgstr_w(received), test_index);
8950                 }
8951                 todo_wine {
8952                     ok(lstrlen(expected) == len,
8953                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8954                         lstrlen(expected), len, test_index);
8955                 }
8956             }
8957         } else {
8958             ok(hr == (expected ? S_OK : S_FALSE),
8959                 "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8960                 hr, (expected ? S_OK : S_FALSE), test_index);
8961             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8962                 expected, wine_dbgstr_w(received), test_index);
8963             ok(lstrlen(expected) == len,
8964                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8965                 lstrlen(expected), len, test_index);
8966         }
8967     } else {
8968         /* The property wasn't set earlier, so it should return whatever
8969          * the base IUri contains (if anything).
8970          */
8971         IUri *uri = NULL;
8972         hr = IUriBuilder_GetIUri(builder, &uri);
8973         ok(hr == S_OK,
8974             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8975             hr, S_OK, test_index);
8976         if(SUCCEEDED(hr)) {
8977             if(!uri) {
8978                 received = (void*) 0xdeadbeef;
8979                 len = -1;
8980
8981                 hr = IUriBuilder_GetQuery(builder, &len, &received);
8982                 ok(hr == S_FALSE,
8983                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8984                     hr, S_FALSE, test_index);
8985                 if(SUCCEEDED(hr)) {
8986                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8987                         len, test_index);
8988                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8989                         received, test_index);
8990                 }
8991             } else {
8992                 BOOL has_prop = FALSE;
8993                 BSTR expected = NULL;
8994
8995                 hr = IUri_GetQuery(uri, &expected);
8996                 ok(SUCCEEDED(hr),
8997                     "Error: Expected IUri_GetQuery to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8998                     hr, test_index);
8999                 has_prop = hr == S_OK;
9000
9001                 hr = IUriBuilder_GetQuery(builder, &len, &received);
9002                 if(has_prop) {
9003                     ok(hr == S_OK,
9004                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9005                         hr, S_OK, test_index);
9006                     if(SUCCEEDED(hr)) {
9007                         ok(!lstrcmpW(expected, received),
9008                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
9009                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
9010                         ok(lstrlenW(expected) == len,
9011                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9012                             lstrlenW(expected), len, test_index);
9013                     }
9014                 } else {
9015                     ok(hr == S_FALSE,
9016                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9017                         hr, S_FALSE, test_index);
9018                     if(SUCCEEDED(hr)) {
9019                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
9020                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
9021                             len, test_index);
9022                     }
9023                 }
9024                 SysFreeString(expected);
9025             }
9026         }
9027         if(uri) IUri_Release(uri);
9028     }
9029 }
9030
9031 static void test_IUriBuilder_GetSchemeName(IUriBuilder *builder, const uri_builder_test *test,
9032                                            DWORD test_index) {
9033     HRESULT hr;
9034     DWORD i;
9035     LPCWSTR received = NULL;
9036     DWORD len = -1;
9037     const uri_builder_property *prop = NULL;
9038
9039     /* Check if the property was set earlier. */
9040     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
9041         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_SCHEME_NAME)
9042             prop = &(test->properties[i]);
9043     }
9044
9045     if(prop) {
9046         /* Use expected_value unless it's NULL, then use value. */
9047         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
9048         hr = IUriBuilder_GetSchemeName(builder, &len, &received);
9049         if(prop->todo) {
9050             todo_wine {
9051                 ok(hr == (expected ? S_OK : S_FALSE),
9052                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9053                     hr, (expected ? S_OK : S_FALSE), test_index);
9054             }
9055             if(SUCCEEDED(hr)) {
9056                 todo_wine {
9057                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
9058                         expected, wine_dbgstr_w(received), test_index);
9059                 }
9060                 todo_wine {
9061                     ok(lstrlen(expected) == len,
9062                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9063                         lstrlen(expected), len, test_index);
9064                 }
9065             }
9066         } else {
9067             ok(hr == (expected ? S_OK : S_FALSE),
9068                 "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9069                 hr, (expected ? S_OK : S_FALSE), test_index);
9070             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
9071                 expected, wine_dbgstr_w(received), test_index);
9072             ok(lstrlen(expected) == len,
9073                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9074                 lstrlen(expected), len, test_index);
9075         }
9076     } else {
9077         /* The property wasn't set earlier, so it should return whatever
9078          * the base IUri contains (if anything).
9079          */
9080         IUri *uri = NULL;
9081         hr = IUriBuilder_GetIUri(builder, &uri);
9082         ok(hr == S_OK,
9083             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9084             hr, S_OK, test_index);
9085         if(SUCCEEDED(hr)) {
9086             if(!uri) {
9087                 received = (void*) 0xdeadbeef;
9088                 len = -1;
9089
9090                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
9091                 ok(hr == S_FALSE,
9092                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9093                     hr, S_FALSE, test_index);
9094                 if(SUCCEEDED(hr)) {
9095                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
9096                         len, test_index);
9097                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
9098                         received, test_index);
9099                 }
9100             } else {
9101                 BOOL has_prop = FALSE;
9102                 BSTR expected = NULL;
9103
9104                 hr = IUri_GetSchemeName(uri, &expected);
9105                 ok(SUCCEEDED(hr),
9106                     "Error: Expected IUri_GetSchemeName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
9107                     hr, test_index);
9108                 has_prop = hr == S_OK;
9109
9110                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
9111                 if(has_prop) {
9112                     ok(hr == S_OK,
9113                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9114                         hr, S_OK, test_index);
9115                     if(SUCCEEDED(hr)) {
9116                         ok(!lstrcmpW(expected, received),
9117                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
9118                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
9119                         ok(lstrlenW(expected) == len,
9120                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9121                             lstrlenW(expected), len, test_index);
9122                     }
9123                 } else {
9124                     ok(hr == S_FALSE,
9125                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9126                         hr, S_FALSE, test_index);
9127                     if(SUCCEEDED(hr)) {
9128                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
9129                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
9130                             len, test_index);
9131                     }
9132                 }
9133                 SysFreeString(expected);
9134             }
9135         }
9136         if(uri) IUri_Release(uri);
9137     }
9138 }
9139
9140 static void test_IUriBuilder_GetUserName(IUriBuilder *builder, const uri_builder_test *test,
9141                                          DWORD test_index) {
9142     HRESULT hr;
9143     DWORD i;
9144     LPCWSTR received = NULL;
9145     DWORD len = -1;
9146     const uri_builder_property *prop = NULL;
9147
9148     /* Check if the property was set earlier. */
9149     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
9150         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_USER_NAME)
9151             prop = &(test->properties[i]);
9152     }
9153
9154     if(prop && prop->value && *prop->value) {
9155         /* Use expected_value unless it's NULL, then use value. */
9156         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
9157         hr = IUriBuilder_GetUserName(builder, &len, &received);
9158         if(prop->todo) {
9159             todo_wine {
9160                 ok(hr == (expected ? S_OK : S_FALSE),
9161                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9162                     hr, (expected ? S_OK : S_FALSE), test_index);
9163             }
9164             if(SUCCEEDED(hr)) {
9165                 todo_wine {
9166                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
9167                         expected, wine_dbgstr_w(received), test_index);
9168                 }
9169                 todo_wine {
9170                     ok(lstrlen(expected) == len,
9171                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9172                         lstrlen(expected), len, test_index);
9173                 }
9174             }
9175         } else {
9176             ok(hr == (expected ? S_OK : S_FALSE),
9177                 "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9178                 hr, (expected ? S_OK : S_FALSE), test_index);
9179             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
9180                 expected, wine_dbgstr_w(received), test_index);
9181             ok(lstrlen(expected) == len,
9182                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9183                 lstrlen(expected), len, test_index);
9184         }
9185     } else {
9186         /* The property wasn't set earlier, so it should return whatever
9187          * the base IUri contains (if anything).
9188          */
9189         IUri *uri = NULL;
9190         hr = IUriBuilder_GetIUri(builder, &uri);
9191         ok(hr == S_OK,
9192             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9193             hr, S_OK, test_index);
9194         if(SUCCEEDED(hr)) {
9195             if(!uri) {
9196                 received = (void*) 0xdeadbeef;
9197                 len = -1;
9198
9199                 hr = IUriBuilder_GetUserName(builder, &len, &received);
9200                 ok(hr == S_FALSE,
9201                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9202                     hr, S_FALSE, test_index);
9203                 if(SUCCEEDED(hr)) {
9204                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
9205                         len, test_index);
9206                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
9207                         received, test_index);
9208                 }
9209             } else {
9210                 BSTR expected = NULL;
9211                 BOOL has_prop = FALSE;
9212
9213                 hr = IUri_GetUserName(uri, &expected);
9214                 ok(SUCCEEDED(hr),
9215                     "Error: Expected IUri_GetUserName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
9216                     hr, test_index);
9217                 has_prop = hr == S_OK;
9218
9219                 hr = IUriBuilder_GetUserName(builder, &len, &received);
9220                 if(has_prop) {
9221                     ok(hr == S_OK,
9222                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9223                         hr, S_OK, test_index);
9224                     if(SUCCEEDED(hr)) {
9225                         ok(!lstrcmpW(expected, received),
9226                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
9227                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
9228                         ok(lstrlenW(expected) == len,
9229                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9230                             lstrlenW(expected), len, test_index);
9231                     }
9232                 } else {
9233                     ok(hr == S_FALSE,
9234                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9235                         hr, S_FALSE, test_index);
9236                     if(SUCCEEDED(hr)) {
9237                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
9238                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
9239                             len, test_index);
9240                     }
9241                 }
9242                 SysFreeString(expected);
9243             }
9244         }
9245         if(uri) IUri_Release(uri);
9246     }
9247 }
9248
9249 /* Tests IUriBuilder functions. */
9250 static void test_IUriBuilder(void) {
9251     HRESULT hr;
9252     IUriBuilder *builder;
9253     DWORD i;
9254
9255     for(i = 0; i < sizeof(uri_builder_tests)/sizeof(uri_builder_tests[0]); ++i) {
9256         IUri *uri = NULL;
9257         uri_builder_test test = uri_builder_tests[i];
9258         LPWSTR uriW = NULL;
9259
9260         if(test.uri) {
9261             uriW = a2w(test.uri);
9262             hr = pCreateUri(uriW, test.create_flags, 0, &uri);
9263             ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9264                 hr, S_OK, i);
9265             if(FAILED(hr)) continue;
9266         }
9267         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9268         if(test.create_builder_todo) {
9269             todo_wine {
9270                 ok(hr == test.create_builder_expected,
9271                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9272                     hr, test.create_builder_expected, i);
9273             }
9274         } else {
9275             ok(hr == test.create_builder_expected,
9276                 "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9277                 hr, test.create_builder_expected, i);
9278         }
9279         if(SUCCEEDED(hr)) {
9280             DWORD j;
9281             BOOL modified = FALSE, received = FALSE;
9282
9283             /* Perform all the string property changes. */
9284             for(j = 0; j < URI_BUILDER_STR_PROPERTY_COUNT; ++j) {
9285                 uri_builder_property prop = test.properties[j];
9286                 if(prop.change) {
9287                     change_property(builder, &prop, i);
9288                     if(prop.property != Uri_PROPERTY_SCHEME_NAME &&
9289                        prop.property != Uri_PROPERTY_HOST)
9290                         modified = TRUE;
9291                     else if(prop.value && *prop.value)
9292                         modified = TRUE;
9293                     else if(prop.value && !*prop.value && prop.property == Uri_PROPERTY_HOST)
9294                         /* Host name property can't be NULL, but it can be empty. */
9295                         modified = TRUE;
9296                 }
9297             }
9298
9299             if(test.port_prop.change) {
9300                 hr = IUriBuilder_SetPort(builder, test.port_prop.set, test.port_prop.value);
9301                 modified = TRUE;
9302                 if(test.port_prop.todo) {
9303                     todo_wine {
9304                         ok(hr == test.port_prop.expected,
9305                             "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9306                             hr, test.port_prop.expected, i);
9307                     }
9308                 } else {
9309                     ok(hr == test.port_prop.expected,
9310                         "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9311                         hr, test.port_prop.expected, i);
9312                 }
9313             }
9314
9315             hr = IUriBuilder_HasBeenModified(builder, &received);
9316             ok(hr == S_OK,
9317                 "Error IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9318                 hr, S_OK, i);
9319             if(SUCCEEDED(hr))
9320                 ok(received == modified,
9321                     "Error: Expected received to be %d but was %d instead on uri_builder_tests[%d].\n",
9322                     modified, received, i);
9323
9324             /* Test the "Get*" functions. */
9325             test_IUriBuilder_GetFragment(builder, &test, i);
9326             test_IUriBuilder_GetHost(builder, &test, i);
9327             test_IUriBuilder_GetPassword(builder, &test, i);
9328             test_IUriBuilder_GetPath(builder, &test, i);
9329             test_IUriBuilder_GetPort(builder, &test, i);
9330             test_IUriBuilder_GetQuery(builder, &test, i);
9331             test_IUriBuilder_GetSchemeName(builder, &test, i);
9332             test_IUriBuilder_GetUserName(builder, &test, i);
9333
9334             test_IUriBuilder_CreateUri(builder, &test, i);
9335             test_IUriBuilder_CreateUriSimple(builder, &test, i);
9336             test_IUriBuilder_CreateUriWithFlags(builder, &test, i);
9337         }
9338         if(builder) IUriBuilder_Release(builder);
9339         if(uri) IUri_Release(uri);
9340         heap_free(uriW);
9341     }
9342 }
9343
9344 static void test_IUriBuilder_HasBeenModified(void) {
9345     HRESULT hr;
9346     IUriBuilder *builder = NULL;
9347
9348     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9349     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9350     if(SUCCEEDED(hr)) {
9351         static const WCHAR hostW[] = {'g','o','o','g','l','e','.','c','o','m',0};
9352         IUri *uri = NULL;
9353         BOOL received;
9354
9355         hr = IUriBuilder_HasBeenModified(builder, NULL);
9356         ok(hr == E_POINTER, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9357             hr, E_POINTER);
9358
9359         hr = IUriBuilder_SetHost(builder, hostW);
9360         ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n",
9361             hr, S_OK);
9362
9363         hr = IUriBuilder_HasBeenModified(builder, &received);
9364         ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9365             hr, S_OK);
9366         if(SUCCEEDED(hr))
9367             ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9368
9369         hr = pCreateUri(http_urlW, 0, 0, &uri);
9370         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9371         if(SUCCEEDED(hr)) {
9372             LPCWSTR prop;
9373             DWORD len = -1;
9374
9375             hr = IUriBuilder_SetIUri(builder, uri);
9376             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n",
9377                 hr, S_OK);
9378
9379             hr = IUriBuilder_HasBeenModified(builder, &received);
9380             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9381                 hr, S_OK);
9382             if(SUCCEEDED(hr))
9383                 ok(received == FALSE, "Error: Expected received to be FALSE.\n");
9384
9385             /* Test what happens with you call SetIUri with the same IUri again. */
9386             hr = IUriBuilder_SetHost(builder, hostW);
9387             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9388
9389             hr = IUriBuilder_HasBeenModified(builder, &received);
9390             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9391                 hr, S_OK);
9392             if(SUCCEEDED(hr))
9393                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9394
9395             hr = IUriBuilder_SetIUri(builder, uri);
9396             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9397
9398             /* IUriBuilder already had 'uri' as it's IUri property and so Windows doesn't
9399              * reset any of the changes that were made to the IUriBuilder.
9400              */
9401             hr = IUriBuilder_HasBeenModified(builder, &received);
9402             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9403             if(SUCCEEDED(hr))
9404                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9405
9406             hr = IUriBuilder_GetHost(builder, &len, &prop);
9407             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9408             if(SUCCEEDED(hr)) {
9409                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
9410                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
9411                 ok(len == lstrlenW(hostW), "Error: Expected len to be %d, but was %d instead.\n",
9412                     lstrlenW(hostW), len);
9413             }
9414
9415             hr = IUriBuilder_SetIUri(builder, NULL);
9416             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9417
9418             hr = IUriBuilder_SetHost(builder, hostW);
9419             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9420             hr = IUriBuilder_HasBeenModified(builder, &received);
9421             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9422                 hr, S_OK);
9423             if(SUCCEEDED(hr))
9424                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9425
9426             hr = IUriBuilder_SetIUri(builder, NULL);
9427             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%09x.\n", hr, S_OK);
9428
9429             hr = IUriBuilder_HasBeenModified(builder, &received);
9430             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9431                 hr, S_OK);
9432             if(SUCCEEDED(hr))
9433                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9434
9435             hr = IUriBuilder_GetHost(builder, &len, &prop);
9436             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9437             if(SUCCEEDED(hr)) {
9438                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
9439                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
9440                 ok(len == lstrlenW(hostW), "Error: Expected len to %d, but was %d instead.\n",
9441                     lstrlenW(hostW), len);
9442             }
9443         }
9444         if(uri) IUri_Release(uri);
9445     }
9446     if(builder) IUriBuilder_Release(builder);
9447 }
9448
9449 /* Test IUriBuilder {Get,Set}IUri functions. */
9450 static void test_IUriBuilder_IUriProperty(void) {
9451     IUriBuilder *builder = NULL;
9452     HRESULT hr;
9453
9454     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9455     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9456     if(SUCCEEDED(hr)) {
9457         IUri *uri = NULL;
9458
9459         hr = IUriBuilder_GetIUri(builder, NULL);
9460         ok(hr == E_POINTER, "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x.\n",
9461             hr, E_POINTER);
9462
9463         hr = pCreateUri(http_urlW, 0, 0, &uri);
9464         if(SUCCEEDED(hr)) {
9465             IUri *test = NULL;
9466             ULONG cur_count, orig_count;
9467
9468             /* IUriBuilder doesn't clone the IUri, it use the same IUri. */
9469             orig_count = get_refcnt(uri);
9470             hr = IUriBuilder_SetIUri(builder, uri);
9471             cur_count = get_refcnt(uri);
9472             if(SUCCEEDED(hr))
9473                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9474                     orig_count+1, cur_count);
9475
9476             hr = IUriBuilder_SetIUri(builder, NULL);
9477             cur_count = get_refcnt(uri);
9478             if(SUCCEEDED(hr))
9479                 ok(cur_count == orig_count, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9480                     orig_count, cur_count);
9481
9482             /* CreateUri* functions will return back the same IUri if nothing has changed. */
9483             hr = IUriBuilder_SetIUri(builder, uri);
9484             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9485             orig_count = get_refcnt(uri);
9486
9487             hr = IUriBuilder_CreateUri(builder, 0, 0, 0, &test);
9488             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9489             if(SUCCEEDED(hr)) {
9490                 cur_count = get_refcnt(uri);
9491                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9492                     orig_count+1, cur_count);
9493                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n",
9494                     uri, test);
9495             }
9496             if(test) IUri_Release(test);
9497
9498             test = NULL;
9499             hr = IUriBuilder_CreateUri(builder, -1, 0, 0, &test);
9500             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9501             if(SUCCEEDED(hr)) {
9502                 cur_count = get_refcnt(uri);
9503                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9504                     orig_count+1, cur_count);
9505                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9506             }
9507             if(test) IUri_Release(test);
9508
9509             /* Doesn't return the same IUri, if the flag combination is different then the one that created
9510              * the base IUri.
9511              */
9512             test = NULL;
9513             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, &test);
9514             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9515             if(SUCCEEDED(hr))
9516                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
9517
9518             if(test) IUri_Release(test);
9519
9520             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
9521              * explicitly set (because it's a default flags).
9522              */
9523             test = NULL;
9524             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_CANONICALIZE, 0, 0, &test);
9525             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9526             if(SUCCEEDED(hr)) {
9527                 cur_count = get_refcnt(uri);
9528                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9529                     orig_count+1, cur_count);
9530                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
9531             }
9532             if(test) IUri_Release(test);
9533
9534             test = NULL;
9535             hr = IUriBuilder_CreateUriSimple(builder, 0, 0, &test);
9536             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9537             if(SUCCEEDED(hr)) {
9538                 cur_count = get_refcnt(uri);
9539                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9540                     orig_count+1, cur_count);
9541                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9542             }
9543             if(test) IUri_Release(test);
9544
9545             test = NULL;
9546             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &test);
9547             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
9548                 hr, S_OK);
9549             if(SUCCEEDED(hr)) {
9550                 cur_count = get_refcnt(uri);
9551                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9552                     orig_count+1, cur_count);
9553                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9554             }
9555             if(test) IUri_Release(test);
9556
9557             /* Doesn't return the same IUri, if the flag combination is different then the one that created
9558              * the base IUri.
9559              */
9560             test = NULL;
9561             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, 0, &test);
9562             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9563             if(SUCCEEDED(hr))
9564                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
9565
9566             if(test) IUri_Release(test);
9567
9568             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
9569              * explicitly set (because it's a default flags).
9570              */
9571             test = NULL;
9572             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_CANONICALIZE, 0, 0, 0, &test);
9573             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9574             if(SUCCEEDED(hr)) {
9575                 cur_count = get_refcnt(uri);
9576                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9577                     orig_count+1, cur_count);
9578                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
9579             }
9580             if(test) IUri_Release(test);
9581         }
9582         if(uri) IUri_Release(uri);
9583     }
9584     if(builder) IUriBuilder_Release(builder);
9585 }
9586
9587 static void test_IUriBuilder_RemoveProperties(void) {
9588     IUriBuilder *builder = NULL;
9589     HRESULT hr;
9590     DWORD i;
9591
9592     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9593     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9594     if(SUCCEEDED(hr)) {
9595         /* Properties that can't be removed. */
9596         const DWORD invalid = Uri_HAS_ABSOLUTE_URI|Uri_HAS_DISPLAY_URI|Uri_HAS_RAW_URI|Uri_HAS_HOST_TYPE|
9597                               Uri_HAS_SCHEME|Uri_HAS_ZONE;
9598
9599         for(i = Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_DWORD_LAST; ++i) {
9600             hr = IUriBuilder_RemoveProperties(builder, i << 1);
9601             if((i << 1) & invalid) {
9602                 ok(hr == E_INVALIDARG,
9603                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
9604                     hr, E_INVALIDARG, i);
9605             } else {
9606                 ok(hr == S_OK,
9607                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
9608                     hr, S_OK, i);
9609             }
9610         }
9611
9612         /* Also doesn't accept anything that's outside the range of the
9613          * Uri_HAS flags.
9614          */
9615         hr = IUriBuilder_RemoveProperties(builder, (Uri_PROPERTY_DWORD_LAST+1) << 1);
9616         ok(hr == E_INVALIDARG, "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x.\n",
9617             hr, E_INVALIDARG);
9618     }
9619     if(builder) IUriBuilder_Release(builder);
9620
9621     for(i = 0; i < sizeof(uri_builder_remove_tests)/sizeof(uri_builder_remove_tests[0]); ++i) {
9622         uri_builder_remove_test test = uri_builder_remove_tests[i];
9623         IUri *uri = NULL;
9624         LPWSTR uriW;
9625
9626         uriW = a2w(test.uri);
9627         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
9628         if(SUCCEEDED(hr)) {
9629             builder = NULL;
9630
9631             hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9632             if(test.create_builder_todo) {
9633                 todo_wine {
9634                     ok(hr == test.create_builder_expected,
9635                         "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9636                         hr, test.create_builder_expected, i);
9637                 }
9638             } else {
9639                 ok(hr == test.create_builder_expected,
9640                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9641                     hr, test.create_builder_expected, i);
9642             }
9643             if(SUCCEEDED(hr)) {
9644                 hr = IUriBuilder_RemoveProperties(builder, test.remove_properties);
9645                 if(test.remove_todo) {
9646                     todo_wine {
9647                         ok(hr == test.remove_expected,
9648                             "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x on test %d.\n",
9649                             hr, test.remove_expected, i);
9650                     }
9651                 } else {
9652                     ok(hr == test.remove_expected,
9653                         "Error: IUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9654                         hr, test.remove_expected, i);
9655                 }
9656                 if(SUCCEEDED(hr)) {
9657                     IUri *result = NULL;
9658
9659                     hr = IUriBuilder_CreateUri(builder, test.expected_flags, 0, 0, &result);
9660                     if(test.expected_todo) {
9661                         todo_wine {
9662                             ok(hr == test.expected_hres,
9663                                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
9664                                 hr, test.expected_hres, i);
9665                         }
9666                     } else {
9667                         ok(hr == test.expected_hres,
9668                             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
9669                             hr, test.expected_hres, i);
9670                     }
9671                     if(SUCCEEDED(hr)) {
9672                         BSTR received = NULL;
9673
9674                         hr = IUri_GetAbsoluteUri(result, &received);
9675                         ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
9676                         ok(!strcmp_aw(test.expected_uri, received),
9677                             "Error: Expected %s but got %s instead on test %d.\n",
9678                             test.expected_uri, wine_dbgstr_w(received), i);
9679                         SysFreeString(received);
9680                     }
9681                     if(result) IUri_Release(result);
9682                 }
9683             }
9684             if(builder) IUriBuilder_Release(builder);
9685         }
9686         if(uri) IUri_Release(uri);
9687         heap_free(uriW);
9688     }
9689 }
9690
9691 static void test_IUriBuilder_Misc(void) {
9692     HRESULT hr;
9693     IUri *uri;
9694
9695     hr = pCreateUri(http_urlW, 0, 0, &uri);
9696     if(SUCCEEDED(hr)) {
9697         IUriBuilder *builder;
9698
9699         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9700         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9701         if(SUCCEEDED(hr)) {
9702             BOOL has = -1;
9703             DWORD port = -1;
9704
9705             hr = IUriBuilder_GetPort(builder, &has, &port);
9706             ok(hr == S_OK, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9707             if(SUCCEEDED(hr)) {
9708                 /* 'has' will be set to FALSE, even though uri had a port. */
9709                 ok(has == FALSE, "Error: Expected 'has' to be FALSE, was %d instead.\n", has);
9710                 /* Still sets 'port' to 80. */
9711                 ok(port == 80, "Error: Expected the port to be 80, but, was %d instead.\n", port);
9712             }
9713         }
9714         if(builder) IUriBuilder_Release(builder);
9715     }
9716     if(uri) IUri_Release(uri);
9717 }
9718
9719 static void test_IUriBuilderFactory(void) {
9720     HRESULT hr;
9721     IUri *uri;
9722     IUriBuilderFactory *factory;
9723     IUriBuilder *builder;
9724
9725     hr = pCreateUri(http_urlW, 0, 0, &uri);
9726     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9727     if(SUCCEEDED(hr)) {
9728         factory = NULL;
9729         hr = IUri_QueryInterface(uri, &IID_IUriBuilderFactory, (void**)&factory);
9730         ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x.\n", hr);
9731         ok(factory != NULL, "Error: Expected 'factory' to not be NULL.\n");
9732
9733         if(SUCCEEDED(hr)) {
9734             builder = (void*) 0xdeadbeef;
9735             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 10, 0, &builder);
9736             ok(hr == E_INVALIDARG, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9737                 hr, E_INVALIDARG);
9738             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9739
9740             builder = (void*) 0xdeadbeef;
9741             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 10, &builder);
9742             ok(hr == E_INVALIDARG, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9743                 hr, E_INVALIDARG);
9744             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9745
9746             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 0, NULL);
9747             ok(hr == E_POINTER, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9748                 hr, E_POINTER);
9749
9750             builder = NULL;
9751             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 0, &builder);
9752             ok(hr == S_OK, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9753                 hr, S_OK);
9754             if(SUCCEEDED(hr)) {
9755                 IUri *tmp = (void*) 0xdeadbeef;
9756                 LPCWSTR result;
9757                 DWORD result_len;
9758
9759                 hr = IUriBuilder_GetIUri(builder, &tmp);
9760                 ok(hr == S_OK, "Error: GetIUri returned 0x%08x, expected 0x%08x.\n",
9761                     hr, S_OK);
9762                 ok(!tmp, "Error: Expected 'tmp' to be NULL, but was %p instead.\n", tmp);
9763
9764                 hr = IUriBuilder_GetHost(builder, &result_len, &result);
9765                 ok(hr == S_FALSE, "Error: GetHost returned 0x%08x, expected 0x%08x.\n",
9766                     hr, S_FALSE);
9767             }
9768             if(builder) IUriBuilder_Release(builder);
9769
9770             builder = (void*) 0xdeadbeef;
9771             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 10, 0, &builder);
9772             ok(hr == E_INVALIDARG, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9773                 hr, E_INVALIDARG);
9774             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9775
9776             builder = (void*) 0xdeadbeef;
9777             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 10, &builder);
9778             ok(hr == E_INVALIDARG, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9779                 hr, E_INVALIDARG);
9780             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9781
9782             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 0, NULL);
9783             ok(hr == E_POINTER, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9784                 hr, E_POINTER);
9785
9786             builder = NULL;
9787             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 0, &builder);
9788             ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9789                 hr, S_OK);
9790             if(SUCCEEDED(hr)) {
9791                 IUri *tmp = NULL;
9792
9793                 hr = IUriBuilder_GetIUri(builder, &tmp);
9794                 ok(hr == S_OK, "Error: GetIUri return 0x%08x, expected 0x%08x.\n",
9795                     hr, S_OK);
9796                 ok(tmp == uri, "Error: Expected tmp to be %p, but was %p.\n", uri, tmp);
9797                 if(uri) IUri_Release(uri);
9798             }
9799             if(builder) IUriBuilder_Release(builder);
9800         }
9801         if(factory) IUriBuilderFactory_Release(factory);
9802     }
9803     if(uri) IUri_Release(uri);
9804 }
9805
9806 static void test_CoInternetCombineIUri(void) {
9807     HRESULT hr;
9808     IUri *base, *relative, *result;
9809     DWORD i;
9810
9811     base = NULL;
9812     hr = pCreateUri(http_urlW, 0, 0, &base);
9813     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9814     if(SUCCEEDED(hr)) {
9815         result = (void*) 0xdeadbeef;
9816         hr = pCoInternetCombineIUri(base, NULL, 0, &result, 0);
9817         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9818         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9819     }
9820
9821     relative = NULL;
9822     hr = pCreateUri(http_urlW, 0, 0, &relative);
9823     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9824     if(SUCCEEDED(hr)) {
9825         result = (void*) 0xdeadbeef;
9826         hr = pCoInternetCombineIUri(NULL, relative, 0, &result, 0);
9827         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9828         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9829     }
9830
9831     hr = pCoInternetCombineIUri(base, relative, 0, NULL, 0);
9832     ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9833
9834     if(base) IUri_Release(base);
9835     if(relative) IUri_Release(relative);
9836
9837     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
9838         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
9839
9840         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
9841         ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9842         if(SUCCEEDED(hr)) {
9843             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
9844
9845             hr = pCreateUri(relativeW, uri_combine_tests[i].relative_create_flags, 0, &relative);
9846             ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9847             if(SUCCEEDED(hr)) {
9848                 result = NULL;
9849
9850                 hr = pCoInternetCombineIUri(base, relative, uri_combine_tests[i].combine_flags, &result, 0);
9851                 if(uri_combine_tests[i].todo) {
9852                     todo_wine {
9853                         ok(hr == uri_combine_tests[i].expected,
9854                             "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9855                             hr, uri_combine_tests[i].expected, i);
9856                     }
9857                 } else {
9858                     ok(hr == uri_combine_tests[i].expected,
9859                         "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9860                         hr, uri_combine_tests[i]. expected, i);
9861                 }
9862                 if(SUCCEEDED(hr)) {
9863                     DWORD j;
9864
9865                     for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
9866                         uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
9867                         BSTR received;
9868
9869                         hr = IUri_GetPropertyBSTR(result, j, &received, 0);
9870                         if(prop.todo) {
9871                             todo_wine {
9872                                 ok(hr == prop.expected,
9873                                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9874                                     hr, prop.expected, i, j);
9875                             }
9876                             todo_wine {
9877                                 ok(!strcmp_aw(prop.value, received) ||
9878                                    broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9879                                     "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9880                                     prop.value, wine_dbgstr_w(received), i, j);
9881                             }
9882                         } else {
9883                             ok(hr == prop.expected,
9884                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9885                                 hr, prop.expected, i, j);
9886                             ok(!strcmp_aw(prop.value, received) ||
9887                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9888                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9889                                 prop.value, wine_dbgstr_w(received), i, j);
9890                         }
9891                         SysFreeString(received);
9892                     }
9893
9894                     for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
9895                         uri_dword_property prop = uri_combine_tests[i].dword_props[j];
9896                         DWORD received;
9897
9898                         hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
9899                         if(prop.todo) {
9900                             todo_wine {
9901                                 ok(hr == prop.expected,
9902                                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9903                                     hr, prop.expected, i, j);
9904                             }
9905                             todo_wine {
9906                                 ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9907                                     prop.value, received, i, j);
9908                             }
9909                         } else {
9910                             ok(hr == prop.expected,
9911                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9912                                 hr, prop.expected, i, j);
9913                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9914                                 prop.value, received, i, j);
9915                         }
9916                     }
9917                 }
9918                 if(result) IUri_Release(result);
9919             }
9920             if(relative) IUri_Release(relative);
9921             heap_free(relativeW);
9922         }
9923         if(base) IUri_Release(base);
9924         heap_free(baseW);
9925     }
9926 }
9927
9928 static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface,
9929                                                           REFIID riid, void **ppv)
9930 {
9931     ok(0, "unexpected call\n");
9932     return E_NOINTERFACE;
9933 }
9934
9935 static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
9936 {
9937     return 2;
9938 }
9939
9940 static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
9941 {
9942     return 1;
9943 }
9944
9945 static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
9946         PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
9947         DWORD *pcchResult, DWORD dwReserved)
9948 {
9949     CHECK_EXPECT(ParseUrl);
9950     ok(!lstrcmpW(pwzUrl, parse_urlW), "Error: Expected %s, but got %s instead.\n",
9951         wine_dbgstr_w(parse_urlW), wine_dbgstr_w(pwzUrl));
9952     ok(ParseAction == parse_action, "Error: Expected %d, but got %d.\n", parse_action, ParseAction);
9953     ok(dwParseFlags == parse_flags, "Error: Expected 0x%08x, but got 0x%08x.\n", parse_flags, dwParseFlags);
9954     ok(cchResult == 200, "Error: Got %d.\n", cchResult);
9955
9956     memcpy(pwzResult, parse_resultW, sizeof(parse_resultW));
9957     *pcchResult = lstrlenW(parse_resultW);
9958
9959     return S_OK;
9960 }
9961
9962 static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
9963         LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags,
9964         LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
9965 {
9966     CHECK_EXPECT(CombineUrl);
9967     ok(!lstrcmpW(pwzBaseUrl, combine_baseW), "Error: Expected %s, but got %s instead.\n",
9968         wine_dbgstr_w(combine_baseW), wine_dbgstr_w(pwzBaseUrl));
9969     ok(!lstrcmpW(pwzRelativeUrl, combine_relativeW), "Error: Expected %s, but got %s instead.\n",
9970         wine_dbgstr_w(combine_relativeW), wine_dbgstr_w(pwzRelativeUrl));
9971     ok(dwCombineFlags == (URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO),
9972         "Error: Expected 0, but got 0x%08x.\n", dwCombineFlags);
9973     ok(cchResult == INTERNET_MAX_URL_LENGTH+1, "Error: Got %d.\n", cchResult);
9974
9975     memcpy(pwzResult, combine_resultW, sizeof(combine_resultW));
9976     *pcchResult = lstrlenW(combine_resultW);
9977
9978     return S_OK;
9979 }
9980
9981 static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface,
9982         LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
9983 {
9984     ok(0, "unexpected call\n");
9985     return E_NOTIMPL;
9986 }
9987
9988 static HRESULT WINAPI InternetProtocolInfo_QueryInfo(IInternetProtocolInfo *iface,
9989         LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer,
9990         DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
9991 {
9992     ok(0, "unexpected call\n");
9993     return E_NOTIMPL;
9994 }
9995
9996 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl = {
9997     InternetProtocolInfo_QueryInterface,
9998     InternetProtocolInfo_AddRef,
9999     InternetProtocolInfo_Release,
10000     InternetProtocolInfo_ParseUrl,
10001     InternetProtocolInfo_CombineUrl,
10002     InternetProtocolInfo_CompareUrl,
10003     InternetProtocolInfo_QueryInfo
10004 };
10005
10006 static IInternetProtocolInfo protocol_info = { &InternetProtocolInfoVtbl };
10007
10008 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
10009 {
10010     if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
10011         *ppv = &protocol_info;
10012         return S_OK;
10013     }
10014
10015     ok(0, "unexpected call\n");
10016     return E_NOINTERFACE;
10017 }
10018
10019 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
10020 {
10021     return 2;
10022 }
10023
10024 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
10025 {
10026     return 1;
10027 }
10028
10029 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
10030                                         REFIID riid, void **ppv)
10031 {
10032     ok(0, "unexpected call\n");
10033     return E_NOTIMPL;
10034 }
10035
10036 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
10037 {
10038     ok(0, "unexpected call\n");
10039     return S_OK;
10040 }
10041
10042 static const IClassFactoryVtbl ClassFactoryVtbl = {
10043     ClassFactory_QueryInterface,
10044     ClassFactory_AddRef,
10045     ClassFactory_Release,
10046     ClassFactory_CreateInstance,
10047     ClassFactory_LockServer
10048 };
10049
10050 static IClassFactory protocol_cf = { &ClassFactoryVtbl };
10051
10052 static void register_protocols(void)
10053 {
10054     IInternetSession *session;
10055     HRESULT hres;
10056
10057     hres = pCoInternetGetSession(0, &session, 0);
10058     ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
10059     if(FAILED(hres))
10060         return;
10061
10062     hres = IInternetSession_RegisterNameSpace(session, &protocol_cf, &IID_NULL,
10063             winetestW, 0, NULL, 0);
10064     ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
10065
10066     IInternetSession_Release(session);
10067 }
10068
10069 static void unregister_protocols(void) {
10070     IInternetSession *session;
10071     HRESULT hr;
10072
10073     hr = pCoInternetGetSession(0, &session, 0);
10074     ok(hr == S_OK, "CoInternetGetSession failed: 0x%08x\n", hr);
10075     if(FAILED(hr))
10076         return;
10077
10078     hr = IInternetSession_UnregisterNameSpace(session, &protocol_cf, winetestW);
10079     ok(hr == S_OK, "UnregisterNameSpace failed: 0x%08x\n", hr);
10080
10081     IInternetSession_Release(session);
10082 }
10083
10084 static void test_CoInternetCombineIUri_Pluggable(void) {
10085     HRESULT hr;
10086     IUri *base = NULL;
10087
10088     hr = pCreateUri(combine_baseW, 0, 0, &base);
10089     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10090     if(SUCCEEDED(hr)) {
10091         IUri *relative = NULL;
10092
10093         hr = pCreateUri(combine_relativeW, Uri_CREATE_ALLOW_RELATIVE, 0, &relative);
10094         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10095         if(SUCCEEDED(hr)) {
10096             IUri *result = NULL;
10097
10098             SET_EXPECT(CombineUrl);
10099
10100             hr = pCoInternetCombineIUri(base, relative, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
10101                                         &result, 0);
10102             ok(hr == S_OK, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
10103
10104             CHECK_CALLED(CombineUrl);
10105
10106             if(SUCCEEDED(hr)) {
10107                 BSTR received = NULL;
10108                 hr = IUri_GetAbsoluteUri(result, &received);
10109                 ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
10110                 if(SUCCEEDED(hr)) {
10111                     ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
10112                         wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
10113                 }
10114                 SysFreeString(received);
10115             }
10116             if(result) IUri_Release(result);
10117         }
10118         if(relative) IUri_Release(relative);
10119     }
10120     if(base) IUri_Release(base);
10121 }
10122
10123 static void test_CoInternetCombineUrlEx(void) {
10124     HRESULT hr;
10125     IUri *base, *result;
10126     DWORD i;
10127
10128     base = NULL;
10129     hr = pCreateUri(http_urlW, 0, 0, &base);
10130     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10131     if(SUCCEEDED(hr)) {
10132         result = (void*) 0xdeadbeef;
10133         hr = pCoInternetCombineUrlEx(base, NULL, 0, &result, 0);
10134         ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
10135             hr, E_UNEXPECTED);
10136         ok(!result, "Error: Expected 'result' to be NULL was %p instead.\n", result);
10137     }
10138
10139     result = (void*) 0xdeadbeef;
10140     hr = pCoInternetCombineUrlEx(NULL, http_urlW, 0, &result, 0);
10141     ok(hr == E_INVALIDARG, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
10142         hr, E_INVALIDARG);
10143     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
10144
10145     result = (void*) 0xdeadbeef;
10146     hr = pCoInternetCombineUrlEx(NULL, NULL, 0, &result, 0);
10147     ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
10148         hr, E_UNEXPECTED);
10149     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
10150
10151     hr = pCoInternetCombineUrlEx(base, http_urlW, 0, NULL, 0);
10152     ok(hr == E_POINTER, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
10153         hr, E_POINTER);
10154     if(base) IUri_Release(base);
10155
10156     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
10157         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
10158
10159         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
10160         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_combine_tests[%d].\n", hr, i);
10161         if(SUCCEEDED(hr)) {
10162             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
10163
10164             hr = pCoInternetCombineUrlEx(base, relativeW, uri_combine_tests[i].combine_flags,
10165                                          &result, 0);
10166             if(uri_combine_tests[i].todo) {
10167                 todo_wine {
10168                     ok(hr == uri_combine_tests[i].expected,
10169                         "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
10170                         hr, uri_combine_tests[i].expected, i);
10171                 }
10172             } else {
10173                 ok(hr == uri_combine_tests[i].expected,
10174                     "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
10175                     hr, uri_combine_tests[i]. expected, i);
10176             }
10177             if(SUCCEEDED(hr)) {
10178                 DWORD j;
10179
10180                 for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
10181                     uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
10182                     BSTR received;
10183                     LPCSTR value = (prop.value_ex) ? prop.value_ex : prop.value;
10184
10185                     hr = IUri_GetPropertyBSTR(result, j, &received, 0);
10186                     if(prop.todo) {
10187                         todo_wine {
10188                             ok(hr == prop.expected,
10189                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
10190                                 hr, prop.expected, i, j);
10191                         }
10192                         todo_wine {
10193                             ok(!strcmp_aw(value, received) ||
10194                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
10195                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
10196                                 value, wine_dbgstr_w(received), i, j);
10197                         }
10198                     } else {
10199                         ok(hr == prop.expected,
10200                             "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
10201                             hr, prop.expected, i, j);
10202                         ok(!strcmp_aw(value, received) ||
10203                            broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
10204                             "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
10205                             value, wine_dbgstr_w(received), i, j);
10206                     }
10207                     SysFreeString(received);
10208                 }
10209
10210                 for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
10211                     uri_dword_property prop = uri_combine_tests[i].dword_props[j];
10212                     DWORD received;
10213
10214                     hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
10215                     if(prop.todo) {
10216                         todo_wine {
10217                             ok(hr == prop.expected,
10218                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
10219                                 hr, prop.expected, i, j);
10220                         }
10221                         todo_wine {
10222                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
10223                                 prop.value, received, i, j);
10224                         }
10225                     } else {
10226                         ok(hr == prop.expected,
10227                             "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
10228                             hr, prop.expected, i, j);
10229                         ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
10230                             prop.value, received, i, j);
10231                     }
10232                 }
10233             }
10234             if(result) IUri_Release(result);
10235             heap_free(relativeW);
10236         }
10237         if(base) IUri_Release(base);
10238         heap_free(baseW);
10239     }
10240 }
10241
10242 static void test_CoInternetCombineUrlEx_Pluggable(void) {
10243     HRESULT hr;
10244     IUri *base = NULL;
10245
10246     hr = pCreateUri(combine_baseW, 0, 0, &base);
10247     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10248     if(SUCCEEDED(hr)) {
10249         IUri *result = NULL;
10250
10251         SET_EXPECT(CombineUrl);
10252
10253         hr = pCoInternetCombineUrlEx(base, combine_relativeW, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
10254                                      &result, 0);
10255         ok(hr == S_OK, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
10256
10257         CHECK_CALLED(CombineUrl);
10258
10259         if(SUCCEEDED(hr)) {
10260             BSTR received = NULL;
10261             hr = IUri_GetAbsoluteUri(result, &received);
10262             ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
10263             if(SUCCEEDED(hr)) {
10264                 ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
10265                     wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
10266             }
10267             SysFreeString(received);
10268         }
10269         if(result) IUri_Release(result);
10270     }
10271     if(base) IUri_Release(base);
10272 }
10273
10274 static void test_CoInternetParseIUri_InvalidArgs(void) {
10275     HRESULT hr;
10276     IUri *uri = NULL;
10277     WCHAR tmp[3];
10278     DWORD result = -1;
10279
10280     hr = pCoInternetParseIUri(NULL, PARSE_CANONICALIZE, 0, tmp, 3, &result, 0);
10281     ok(hr == E_INVALIDARG, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10282         hr, E_INVALIDARG);
10283     ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10284
10285     hr = pCreateUri(http_urlW, 0, 0, &uri);
10286     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10287     if(SUCCEEDED(hr)) {
10288         DWORD expected_len;
10289
10290         result = -1;
10291         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, NULL, 0, &result, 0);
10292         ok(hr == E_INVALIDARG, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10293             hr, E_INVALIDARG);
10294         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10295
10296         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, tmp, 3, NULL, 0);
10297         ok(hr == E_POINTER, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10298             hr, E_POINTER);
10299
10300         result = -1;
10301         hr = pCoInternetParseIUri(uri, PARSE_SECURITY_URL, 0, tmp, 3, &result, 0);
10302         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x expected 0x%08x.\n",
10303             hr, E_FAIL);
10304         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10305
10306         result = -1;
10307         hr = pCoInternetParseIUri(uri, PARSE_MIME, 0, tmp, 3, &result, 0);
10308         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10309             hr, E_FAIL);
10310         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10311
10312         result = -1;
10313         hr = pCoInternetParseIUri(uri, PARSE_SERVER, 0, tmp, 3, &result, 0);
10314         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10315             hr, E_FAIL);
10316         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10317
10318         result = -1;
10319         hr = pCoInternetParseIUri(uri, PARSE_SECURITY_DOMAIN, 0, tmp, 3, &result, 0);
10320         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10321             hr, E_FAIL);
10322         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10323
10324         expected_len = lstrlenW(http_urlW);
10325         result = -1;
10326         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, tmp, 3, &result, 0);
10327         ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER,
10328             "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10329             hr, STRSAFE_E_INSUFFICIENT_BUFFER);
10330         ok(result == expected_len, "Error: Expected 'result' to be %d, but was %d instead.\n",
10331             expected_len, result);
10332     }
10333     if(uri) IUri_Release(uri);
10334 }
10335
10336 static void test_CoInternetParseIUri(void) {
10337     DWORD i;
10338
10339     for(i = 0; i < sizeof(uri_parse_tests)/sizeof(uri_parse_tests[0]); ++i) {
10340         HRESULT hr;
10341         IUri *uri;
10342         LPWSTR uriW;
10343         uri_parse_test test = uri_parse_tests[i];
10344
10345         uriW = a2w(test.uri);
10346         hr = pCreateUri(uriW, test.uri_flags, 0, &uri);
10347         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_parse_tests[%d].\n", hr, i);
10348         if(SUCCEEDED(hr)) {
10349             WCHAR result[INTERNET_MAX_URL_LENGTH+1];
10350             DWORD result_len = -1;
10351
10352             hr = pCoInternetParseIUri(uri, test.action, test.flags, result, INTERNET_MAX_URL_LENGTH+1, &result_len, 0);
10353             if(test.todo) {
10354                 todo_wine {
10355                     ok(hr == test.expected,
10356                         "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x on uri_parse_tests[%d].\n",
10357                         hr, test.expected, i);
10358                 }
10359             } else {
10360                 ok(hr == test.expected,
10361                     "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x on uri_parse_tests[%d].\n",
10362                     hr, test.expected, i);
10363             }
10364             if(SUCCEEDED(hr)) {
10365                 DWORD len = lstrlenA(test.property);
10366                 ok(!strcmp_aw(test.property, result),
10367                     "Error: Expected %s but got %s instead on uri_parse_tests[%d].\n",
10368                     test.property, wine_dbgstr_w(result), i);
10369                 ok(len == result_len,
10370                     "Error: Expected %d, but got %d instead on uri_parse_tests[%d].\n",
10371                     len, result_len, i);
10372             } else {
10373                 ok(!result_len,
10374                     "Error: Expected 'result_len' to be 0, but was %d on uri_parse_tests[%d].\n",
10375                     result_len, i);
10376             }
10377         }
10378         if(uri) IUri_Release(uri);
10379         heap_free(uriW);
10380     }
10381 }
10382
10383 static void test_CoInternetParseIUri_Pluggable(void) {
10384     HRESULT hr;
10385     IUri *uri = NULL;
10386
10387     hr = pCreateUri(parse_urlW, 0, 0, &uri);
10388     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, but got 0x%08x.\n", hr);
10389     if(SUCCEEDED(hr)) {
10390         WCHAR result[200];
10391         DWORD result_len;
10392
10393         SET_EXPECT(ParseUrl);
10394
10395         parse_action = PARSE_CANONICALIZE;
10396         parse_flags = URL_UNESCAPE|URL_ESCAPE_UNSAFE;
10397
10398         hr = pCoInternetParseIUri(uri, parse_action, parse_flags, result, 200, &result_len, 0);
10399         ok(hr == S_OK, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
10400
10401         CHECK_CALLED(ParseUrl);
10402
10403         if(SUCCEEDED(hr)) {
10404             ok(result_len == lstrlenW(parse_resultW), "Error: Expected %d, but got %d.\n",
10405                 lstrlenW(parse_resultW), result_len);
10406             ok(!lstrcmpW(result, parse_resultW), "Error: Expected %s, but got %s.\n",
10407                 wine_dbgstr_w(parse_resultW), wine_dbgstr_w(result));
10408         }
10409     }
10410     if(uri) IUri_Release(uri);
10411 }
10412
10413 typedef struct {
10414     const char *url;
10415     DWORD uri_flags;
10416     const char *base_url;
10417     DWORD base_uri_flags;
10418     const char *legacy_url;
10419     const char *uniform_url;
10420     const char *no_canon_url;
10421     const char *uri_url;
10422 } create_urlmon_test_t;
10423
10424 static const create_urlmon_test_t create_urlmon_tests[] = {
10425     {
10426         "http://www.winehq.org",Uri_CREATE_NO_CANONICALIZE,
10427         NULL,0,
10428         "http://www.winehq.org/",
10429         "http://www.winehq.org/",
10430         "http://www.winehq.org",
10431         "http://www.winehq.org"
10432     },
10433     {
10434         "file://c:\\dir\\file.txt",Uri_CREATE_NO_CANONICALIZE,
10435         NULL,0,
10436         "file://c:\\dir\\file.txt",
10437         "file:///c:/dir/file.txt",
10438         "file:///c:/dir/file.txt",
10439         "file:///c:/dir/file.txt"
10440     },
10441     {
10442         "file://c:\\dir\\file.txt",Uri_CREATE_FILE_USE_DOS_PATH,
10443         NULL,0,
10444         "file://c:\\dir\\file.txt",
10445         "file:///c:/dir/file.txt",
10446         "file:///c:/dir/file.txt",
10447         "file://c:\\dir\\file.txt"
10448     },
10449     {
10450         "dat%61",Uri_CREATE_ALLOW_RELATIVE,
10451         "http://www.winehq.org",0,
10452         "http://www.winehq.org/data",
10453         "http://www.winehq.org/data",
10454         "http://www.winehq.org:80/data",
10455     },
10456     {
10457         "file.txt",Uri_CREATE_ALLOW_RELATIVE,
10458         "file://c:\\dir\\x.txt",Uri_CREATE_NO_CANONICALIZE,
10459         "file://c:\\dir\\file.txt",
10460         "file:///c:/dir/file.txt",
10461         "file:///c:/dir/file.txt",
10462     },
10463     {
10464         "",Uri_CREATE_ALLOW_RELATIVE,
10465         NULL,0,
10466         "",
10467         "",
10468         "",
10469         ""
10470     },
10471     {
10472         "test",Uri_CREATE_ALLOW_RELATIVE,
10473         NULL,0,
10474         "test",
10475         "test",
10476         "test",
10477         "test"
10478     },
10479     {
10480         "c:\\dir\\file.txt",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME,
10481         NULL,0,
10482         "file://c:\\dir\\file.txt",
10483         "file:///c:/dir/file.txt",
10484         "file:///c:/dir/file.txt",
10485         "file:///c:/dir/file.txt",
10486     }
10487 };
10488
10489 #define test_urlmon_display_name(a,b) _test_urlmon_display_name(__LINE__,a,b)
10490 static void _test_urlmon_display_name(unsigned line, IMoniker *mon, const char *exurl)
10491 {
10492     WCHAR *display_name;
10493     HRESULT hres;
10494
10495     hres = IMoniker_GetDisplayName(mon, NULL, NULL, &display_name);
10496     ok_(__FILE__,line)(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
10497     ok_(__FILE__,line)(!strcmp_aw(exurl, display_name), "unexpected display name: %s, expected %s\n",
10498             wine_dbgstr_w(display_name), exurl);
10499
10500     CoTaskMemFree(display_name);
10501 }
10502
10503 #define test_display_uri(a,b) _test_display_uri(__LINE__,a,b)
10504 static void _test_display_uri(unsigned line, IMoniker *mon, const char *exurl)
10505 {
10506     IUriContainer *uri_container;
10507     IUri *uri;
10508     BSTR display_uri;
10509     HRESULT hres;
10510
10511     hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container);
10512     ok(hres == S_OK, "Could not get IUriContainer iface: %08x\n", hres);
10513
10514     uri = NULL;
10515     hres = IUriContainer_GetIUri(uri_container, &uri);
10516     IUriContainer_Release(uri_container);
10517     ok(hres == S_OK, "GetIUri failed: %08x\n", hres);
10518     ok(uri != NULL, "uri == NULL\n");
10519
10520     hres = IUri_GetDisplayUri(uri, &display_uri);
10521     IUri_Release(uri);
10522     ok(hres == S_OK, "GetDisplayUri failed: %08x\n", hres);
10523     ok_(__FILE__,line)(!strcmp_aw(exurl, display_uri), "unexpected display uri: %s, expected %s\n",
10524             wine_dbgstr_w(display_uri), exurl);
10525     SysFreeString(display_uri);
10526 }
10527
10528 static void test_CreateURLMoniker(void)
10529 {
10530     const create_urlmon_test_t *test;
10531     IMoniker *mon, *base_mon;
10532     WCHAR *url, *base_url;
10533     IUri *uri, *base_uri;
10534     HRESULT hres;
10535
10536     for(test = create_urlmon_tests; test < create_urlmon_tests + sizeof(create_urlmon_tests)/sizeof(*create_urlmon_tests); test++) {
10537         url = a2w(test->url);
10538         base_url = a2w(test->base_url);
10539
10540         if(base_url) {
10541             hres = pCreateUri(base_url, test->base_uri_flags, 0, &base_uri);
10542             ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
10543
10544             hres = pCreateURLMonikerEx2(NULL, base_uri, &base_mon, URL_MK_NO_CANONICALIZE);
10545             ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10546         }else {
10547             base_uri = NULL;
10548             base_mon = NULL;
10549         }
10550
10551         hres = CreateURLMoniker(base_mon, url, &mon);
10552         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10553         test_urlmon_display_name(mon, test->legacy_url);
10554         test_display_uri(mon, test->legacy_url);
10555         IMoniker_Release(mon);
10556
10557         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_LEGACY);
10558         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10559         test_urlmon_display_name(mon, test->legacy_url);
10560         test_display_uri(mon, test->legacy_url);
10561         IMoniker_Release(mon);
10562
10563         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_UNIFORM);
10564         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10565         test_urlmon_display_name(mon, test->uniform_url);
10566         test_display_uri(mon, test->uniform_url);
10567         IMoniker_Release(mon);
10568
10569         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_NO_CANONICALIZE);
10570         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10571         test_urlmon_display_name(mon, test->no_canon_url);
10572         test_display_uri(mon, test->no_canon_url);
10573         IMoniker_Release(mon);
10574
10575         hres = pCreateUri(url, test->uri_flags, 0, &uri);
10576         ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
10577
10578         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_LEGACY);
10579         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10580         test_urlmon_display_name(mon, base_url ? test->legacy_url : test->uri_url);
10581         test_display_uri(mon, base_url ? test->legacy_url : test->uri_url);
10582         IMoniker_Release(mon);
10583
10584         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_UNIFORM);
10585         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10586         test_urlmon_display_name(mon, base_url ? test->uniform_url : test->uri_url);
10587         test_display_uri(mon, base_url ? test->uniform_url : test->uri_url);
10588         IMoniker_Release(mon);
10589
10590         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_NO_CANONICALIZE);
10591         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10592         test_urlmon_display_name(mon, base_url ? test->no_canon_url : test->uri_url);
10593         test_display_uri(mon, base_url ? test->no_canon_url : test->uri_url);
10594         IMoniker_Release(mon);
10595
10596         IUri_Release(uri);
10597         heap_free(url);
10598         heap_free(base_url);
10599         if(base_uri)
10600             IUri_Release(base_uri);
10601         if(base_mon)
10602             IMoniker_Release(base_mon);
10603     }
10604 }
10605
10606 START_TEST(uri) {
10607     HMODULE hurlmon;
10608
10609     hurlmon = GetModuleHandle("urlmon.dll");
10610     pCoInternetGetSession = (void*) GetProcAddress(hurlmon, "CoInternetGetSession");
10611     pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri");
10612     pCreateUriWithFragment = (void*) GetProcAddress(hurlmon, "CreateUriWithFragment");
10613     pCreateIUriBuilder = (void*) GetProcAddress(hurlmon, "CreateIUriBuilder");
10614     pCoInternetCombineIUri = (void*) GetProcAddress(hurlmon, "CoInternetCombineIUri");
10615     pCoInternetCombineUrlEx = (void*) GetProcAddress(hurlmon, "CoInternetCombineUrlEx");
10616     pCoInternetParseIUri = (void*) GetProcAddress(hurlmon, "CoInternetParseIUri");
10617     pCreateURLMonikerEx = (void*) GetProcAddress(hurlmon, "CreateURLMonikerEx");
10618     pCreateURLMonikerEx2 = (void*) GetProcAddress(hurlmon, "CreateURLMonikerEx2");
10619
10620     if(!pCreateUri) {
10621         win_skip("CreateUri is not present, skipping tests.\n");
10622         return;
10623     }
10624
10625     trace("test CreateUri invalid flags...\n");
10626     test_CreateUri_InvalidFlags();
10627
10628     trace("test CreateUri invalid args...\n");
10629     test_CreateUri_InvalidArgs();
10630
10631     trace("test CreateUri invalid URIs...\n");
10632     test_CreateUri_InvalidUri();
10633
10634     trace("test IUri_GetPropertyBSTR...\n");
10635     test_IUri_GetPropertyBSTR();
10636
10637     trace("test IUri_GetPropertyDWORD...\n");
10638     test_IUri_GetPropertyDWORD();
10639
10640     trace("test IUri_GetStrProperties...\n");
10641     test_IUri_GetStrProperties();
10642
10643     trace("test IUri_GetDwordProperties...\n");
10644     test_IUri_GetDwordProperties();
10645
10646     trace("test IUri_GetPropertyLength...\n");
10647     test_IUri_GetPropertyLength();
10648
10649     trace("test IUri_GetProperties...\n");
10650     test_IUri_GetProperties();
10651
10652     trace("test IUri_HasProperty...\n");
10653     test_IUri_HasProperty();
10654
10655     trace("test IUri_IsEqual...\n");
10656     test_IUri_IsEqual();
10657
10658     trace("test CreateUriWithFragment invalid args...\n");
10659     test_CreateUriWithFragment_InvalidArgs();
10660
10661     trace("test CreateUriWithFragment invalid flags...\n");
10662     test_CreateUriWithFragment_InvalidFlags();
10663
10664     trace("test CreateUriWithFragment...\n");
10665     test_CreateUriWithFragment();
10666
10667     trace("test CreateIUriBuilder...\n");
10668     test_CreateIUriBuilder();
10669
10670     trace("test IUriBuilder_CreateInvalidArgs...\n");
10671     test_IUriBuilder_CreateInvalidArgs();
10672
10673     trace("test IUriBuilder...\n");
10674     test_IUriBuilder();
10675
10676     trace("test IUriBuilder_GetInvalidArgs...\n");
10677     test_IUriBuilder_GetInvalidArgs();
10678
10679     trace("test IUriBuilder_HasBeenModified...\n");
10680     test_IUriBuilder_HasBeenModified();
10681
10682     trace("test IUriBuilder_IUriProperty...\n");
10683     test_IUriBuilder_IUriProperty();
10684
10685     trace("test IUriBuilder_RemoveProperties...\n");
10686     test_IUriBuilder_RemoveProperties();
10687
10688     trace("test IUriBuilder miscellaneous...\n");
10689     test_IUriBuilder_Misc();
10690
10691     trace("test IUriBuilderFactory...\n");
10692     test_IUriBuilderFactory();
10693
10694     trace("test CoInternetCombineIUri...\n");
10695     test_CoInternetCombineIUri();
10696
10697     trace("test CoInternetCombineUrlEx...\n");
10698     test_CoInternetCombineUrlEx();
10699
10700     trace("test CoInternetParseIUri Invalid Args...\n");
10701     test_CoInternetParseIUri_InvalidArgs();
10702
10703     trace("test CoInternetParseIUri...\n");
10704     test_CoInternetParseIUri();
10705
10706     register_protocols();
10707
10708     trace("test CoInternetCombineIUri pluggable...\n");
10709     test_CoInternetCombineIUri_Pluggable();
10710
10711     trace("test CoInternetCombineUrlEx Pluggable...\n");
10712     test_CoInternetCombineUrlEx_Pluggable();
10713
10714     trace("test CoInternetParseIUri pluggable...\n");
10715     test_CoInternetParseIUri_Pluggable();
10716
10717     trace("test CreateURLMoniker...\n");
10718     test_CreateURLMoniker();
10719
10720     unregister_protocols();
10721 }