crypt32: Add additional path for Solaris 11 Express.
[wine] / dlls / urlmon / tests / uri.c
1 /*
2  * UrlMon IUri tests
3  *
4  * Copyright 2010 Thomas Mullaly
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <wine/test.h>
22 #include <stdarg.h>
23 #include <stddef.h>
24
25 #define COBJMACROS
26 #define CONST_VTABLE
27
28 #include "windef.h"
29 #include "winbase.h"
30 #include "urlmon.h"
31 #include "shlwapi.h"
32 #include "wininet.h"
33 #include "strsafe.h"
34
35 #define URI_STR_PROPERTY_COUNT Uri_PROPERTY_STRING_LAST+1
36 #define URI_DWORD_PROPERTY_COUNT (Uri_PROPERTY_DWORD_LAST - Uri_PROPERTY_DWORD_START)+1
37 #define URI_BUILDER_STR_PROPERTY_COUNT 7
38
39 #define DEFINE_EXPECT(func) \
40     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
41
42 #define SET_EXPECT(func) \
43     expect_ ## func = TRUE
44
45 #define CHECK_EXPECT(func) \
46     do { \
47         ok(expect_ ##func, "unexpected call " #func "\n"); \
48         expect_ ## func = FALSE; \
49         called_ ## func = TRUE; \
50     }while(0)
51
52 #define CHECK_EXPECT2(func) \
53     do { \
54         ok(expect_ ##func, "unexpected call " #func "\n"); \
55         called_ ## func = TRUE; \
56     }while(0)
57
58 #define CHECK_CALLED(func) \
59     do { \
60         ok(called_ ## func, "expected " #func "\n"); \
61         expect_ ## func = called_ ## func = FALSE; \
62     }while(0)
63
64 DEFINE_EXPECT(CombineUrl);
65 DEFINE_EXPECT(ParseUrl);
66
67 static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**);
68 static HRESULT (WINAPI *pCreateUriWithFragment)(LPCWSTR, LPCWSTR, DWORD, DWORD_PTR, IUri**);
69 static HRESULT (WINAPI *pCreateIUriBuilder)(IUri*, DWORD, DWORD_PTR, IUriBuilder**);
70 static HRESULT (WINAPI *pCoInternetCombineIUri)(IUri*,IUri*,DWORD,IUri**,DWORD_PTR);
71 static HRESULT (WINAPI *pCoInternetGetSession)(DWORD,IInternetSession**,DWORD);
72 static HRESULT (WINAPI *pCoInternetCombineUrlEx)(IUri*,LPCWSTR,DWORD,IUri**,DWORD_PTR);
73 static HRESULT (WINAPI *pCoInternetParseIUri)(IUri*,PARSEACTION,DWORD,LPWSTR,DWORD,DWORD*,DWORD_PTR);
74 static HRESULT (WINAPI *pCreateURLMonikerEx)(IMoniker*,LPCWSTR,IMoniker**,DWORD);
75 static HRESULT (WINAPI *pCreateURLMonikerEx2)(IMoniker*,IUri*,IMoniker**,DWORD);
76
77 static const WCHAR http_urlW[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
78         '.','o','r','g','/',0};
79 static const WCHAR http_url_fragW[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
80         '.','o','r','g','/','#','F','r','a','g',0};
81
82 static const WCHAR combine_baseW[] = {'w','i','n','e','t','e','s','t',':','?','t',
83         'e','s','t','i','n','g',0};
84 static const WCHAR combine_relativeW[] = {'?','t','e','s','t',0};
85 static const WCHAR combine_resultW[] = {'z','i','p',':','t','e','s','t',0};
86
87 static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0};
88
89 static const WCHAR parse_urlW[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t',0};
90 static const WCHAR parse_resultW[] = {'z','i','p',':','t','e','s','t',0};
91
92 static PARSEACTION parse_action;
93 static DWORD parse_flags;
94
95 typedef struct _uri_create_flag_test {
96     DWORD   flags;
97     HRESULT expected;
98 } uri_create_flag_test;
99
100 static const uri_create_flag_test invalid_flag_tests[] = {
101     /* Set of invalid flag combinations to test for. */
102     {Uri_CREATE_DECODE_EXTRA_INFO | Uri_CREATE_NO_DECODE_EXTRA_INFO, E_INVALIDARG},
103     {Uri_CREATE_CANONICALIZE | Uri_CREATE_NO_CANONICALIZE, E_INVALIDARG},
104     {Uri_CREATE_CRACK_UNKNOWN_SCHEMES | Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, E_INVALIDARG},
105     {Uri_CREATE_PRE_PROCESS_HTML_URI | Uri_CREATE_NO_PRE_PROCESS_HTML_URI, E_INVALIDARG},
106     {Uri_CREATE_IE_SETTINGS | Uri_CREATE_NO_IE_SETTINGS, E_INVALIDARG}
107 };
108
109 typedef struct _uri_str_property {
110     const char* value;
111     HRESULT     expected;
112     BOOL        todo;
113     const char* broken_value;
114 } uri_str_property;
115
116 typedef struct _uri_dword_property {
117     DWORD   value;
118     HRESULT expected;
119     BOOL    todo;
120 } uri_dword_property;
121
122 typedef struct _uri_properties {
123     const char*         uri;
124     DWORD               create_flags;
125     HRESULT             create_expected;
126     BOOL                create_todo;
127
128     uri_str_property    str_props[URI_STR_PROPERTY_COUNT];
129     uri_dword_property  dword_props[URI_DWORD_PROPERTY_COUNT];
130 } uri_properties;
131
132 static const uri_properties uri_tests[] = {
133     {   "http://www.winehq.org/tests/../tests/../..", 0, S_OK, FALSE,
134         {
135             {"http://www.winehq.org/",S_OK,FALSE},                      /* ABSOLUTE_URI */
136             {"www.winehq.org",S_OK,FALSE},                              /* AUTHORITY */
137             {"http://www.winehq.org/",S_OK,FALSE},                      /* DISPLAY_URI */
138             {"winehq.org",S_OK,FALSE},                                  /* DOMAIN */
139             {"",S_FALSE,FALSE},                                         /* EXTENSION */
140             {"",S_FALSE,FALSE},                                         /* FRAGMENT */
141             {"www.winehq.org",S_OK,FALSE},                              /* HOST */
142             {"",S_FALSE,FALSE},                                         /* PASSWORD */
143             {"/",S_OK,FALSE},                                           /* PATH */
144             {"/",S_OK,FALSE},                                           /* PATH_AND_QUERY */
145             {"",S_FALSE,FALSE},                                         /* QUERY */
146             {"http://www.winehq.org/tests/../tests/../..",S_OK,FALSE},  /* RAW_URI */
147             {"http",S_OK,FALSE},                                        /* SCHEME_NAME */
148             {"",S_FALSE,FALSE},                                         /* USER_INFO */
149             {"",S_FALSE,FALSE}                                          /* USER_NAME */
150         },
151         {
152             {Uri_HOST_DNS,S_OK,FALSE},                                  /* HOST_TYPE */
153             {80,S_OK,FALSE},                                            /* PORT */
154             {URL_SCHEME_HTTP,S_OK,FALSE},                               /* SCHEME */
155             {URLZONE_INVALID,E_NOTIMPL,FALSE}                           /* ZONE */
156         }
157     },
158     {   "http://winehq.org/tests/.././tests", 0, S_OK, FALSE,
159         {
160             {"http://winehq.org/tests",S_OK,FALSE},
161             {"winehq.org",S_OK,FALSE},
162             {"http://winehq.org/tests",S_OK,FALSE},
163             {"winehq.org",S_OK,FALSE},
164             {"",S_FALSE,FALSE},
165             {"",S_FALSE,FALSE},
166             {"winehq.org",S_OK,FALSE},
167             {"",S_FALSE,FALSE},
168             {"/tests",S_OK,FALSE},
169             {"/tests",S_OK,FALSE},
170             {"",S_FALSE,FALSE},
171             {"http://winehq.org/tests/.././tests",S_OK,FALSE},
172             {"http",S_OK,FALSE},
173             {"",S_FALSE,FALSE},
174             {"",S_FALSE,FALSE}
175         },
176         {
177             {Uri_HOST_DNS,S_OK,FALSE},
178             {80,S_OK,FALSE},
179             {URL_SCHEME_HTTP,S_OK,FALSE},
180             {URLZONE_INVALID,E_NOTIMPL,FALSE}
181         }
182     },
183     {   "HtTp://www.winehq.org/tests/..?query=x&return=y", 0, S_OK, FALSE,
184         {
185             {"http://www.winehq.org/?query=x&return=y",S_OK,FALSE},
186             {"www.winehq.org",S_OK,FALSE},
187             {"http://www.winehq.org/?query=x&return=y",S_OK,FALSE},
188             {"winehq.org",S_OK,FALSE},
189             {"",S_FALSE,FALSE},
190             {"",S_FALSE,FALSE},
191             {"www.winehq.org",S_OK,FALSE},
192             {"",S_FALSE,FALSE},
193             {"/",S_OK,FALSE},
194             {"/?query=x&return=y",S_OK,FALSE},
195             {"?query=x&return=y",S_OK,FALSE},
196             {"HtTp://www.winehq.org/tests/..?query=x&return=y",S_OK,FALSE},
197             {"http",S_OK,FALSE},
198             {"",S_FALSE,FALSE},
199             {"",S_FALSE,FALSE}
200         },
201         {
202             {Uri_HOST_DNS,S_OK,FALSE},
203             {80,S_OK,FALSE},
204             {URL_SCHEME_HTTP,S_OK,FALSE},
205             {URLZONE_INVALID,E_NOTIMPL,FALSE},
206         }
207     },
208     {   "hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters", 0, S_OK, FALSE,
209         {
210             {"http://usEr%3Ainfo@example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
211             {"usEr%3Ainfo@example.com",S_OK,FALSE},
212             {"http://example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
213             {"example.com",S_OK,FALSE},
214             {"",S_FALSE,FALSE},
215             {"",S_FALSE,FALSE},
216             {"example.com",S_OK,FALSE},
217             {"",S_FALSE,FALSE},
218             {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
219             {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
220             {"",S_FALSE,FALSE},
221             {"hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters",S_OK,FALSE},
222             {"http",S_OK,FALSE},
223             {"usEr%3Ainfo",S_OK,FALSE},
224             {"usEr%3Ainfo",S_OK,FALSE}
225         },
226         {
227             {Uri_HOST_DNS,S_OK,FALSE},
228             {80,S_OK,FALSE},
229             {URL_SCHEME_HTTP,S_OK,FALSE},
230             {URLZONE_INVALID,E_NOTIMPL,FALSE},
231         }
232     },
233     {   "ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt", 0, S_OK, FALSE,
234         {
235             {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK,FALSE},
236             {"winepass:wine@ftp.winehq.org:9999",S_OK,FALSE},
237             {"ftp://ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK,FALSE},
238             {"winehq.org",S_OK,FALSE},
239             {".txt",S_OK,FALSE},
240             {"",S_FALSE,FALSE},
241             {"ftp.winehq.org",S_OK,FALSE},
242             {"wine",S_OK,FALSE},
243             {"/dir/foo%20bar.txt",S_OK,FALSE},
244             {"/dir/foo%20bar.txt",S_OK,FALSE},
245             {"",S_FALSE,FALSE},
246             {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt",S_OK,FALSE},
247             {"ftp",S_OK,FALSE},
248             {"winepass:wine",S_OK,FALSE},
249             {"winepass",S_OK,FALSE}
250         },
251         {
252             {Uri_HOST_DNS,S_OK,FALSE},
253             {9999,S_OK,FALSE},
254             {URL_SCHEME_FTP,S_OK,FALSE},
255             {URLZONE_INVALID,E_NOTIMPL,FALSE}
256         }
257     },
258     {   "file://c:\\tests\\../tests/foo%20bar.mp3", 0, S_OK, FALSE,
259         {
260             {"file:///c:/tests/foo%2520bar.mp3",S_OK,FALSE},
261             {"",S_FALSE,FALSE},
262             {"file:///c:/tests/foo%2520bar.mp3",S_OK,FALSE},
263             {"",S_FALSE,FALSE},
264             {".mp3",S_OK,FALSE},
265             {"",S_FALSE,FALSE},
266             {"",S_FALSE,FALSE},
267             {"",S_FALSE,FALSE},
268             {"/c:/tests/foo%2520bar.mp3",S_OK,FALSE},
269             {"/c:/tests/foo%2520bar.mp3",S_OK,FALSE},
270             {"",S_FALSE,FALSE},
271             {"file://c:\\tests\\../tests/foo%20bar.mp3",S_OK,FALSE},
272             {"file",S_OK,FALSE},
273             {"",S_FALSE,FALSE},
274             {"",S_FALSE,FALSE}
275         },
276         {
277             {Uri_HOST_UNKNOWN,S_OK,FALSE},
278             {0,S_FALSE,FALSE},
279             {URL_SCHEME_FILE,S_OK,FALSE},
280             {URLZONE_INVALID,E_NOTIMPL,FALSE}
281         }
282     },
283     {   "FILE://localhost/test dir\\../tests/test%20file.README.txt", 0, S_OK, FALSE,
284         {
285             {"file:///tests/test%20file.README.txt",S_OK,FALSE},
286             {"",S_FALSE,FALSE},
287             {"file:///tests/test%20file.README.txt",S_OK,FALSE},
288             {"",S_FALSE,FALSE},
289             {".txt",S_OK,FALSE},
290             {"",S_FALSE,FALSE},
291             {"",S_FALSE,FALSE},
292             {"",S_FALSE,FALSE},
293             {"/tests/test%20file.README.txt",S_OK,FALSE},
294             {"/tests/test%20file.README.txt",S_OK,FALSE},
295             {"",S_FALSE,FALSE},
296             {"FILE://localhost/test dir\\../tests/test%20file.README.txt",S_OK,FALSE},
297             {"file",S_OK,FALSE},
298             {"",S_FALSE,FALSE},
299             {"",S_FALSE,FALSE}
300         },
301         {
302             {Uri_HOST_UNKNOWN,S_OK,FALSE},
303             {0,S_FALSE,FALSE},
304             {URL_SCHEME_FILE,S_OK,FALSE},
305             {URLZONE_INVALID,E_NOTIMPL,FALSE}
306         }
307     },
308     {   "urn:nothing:should:happen here", 0, S_OK, FALSE,
309         {
310             {"urn:nothing:should:happen here",S_OK,FALSE},
311             {"",S_FALSE,FALSE},
312             {"urn:nothing:should:happen here",S_OK,FALSE},
313             {"",S_FALSE,FALSE},
314             {"",S_FALSE,FALSE},
315             {"",S_FALSE,FALSE},
316             {"",S_FALSE,FALSE},
317             {"",S_FALSE,FALSE},
318             {"nothing:should:happen here",S_OK,FALSE},
319             {"nothing:should:happen here",S_OK,FALSE},
320             {"",S_FALSE,FALSE},
321             {"urn:nothing:should:happen here",S_OK,FALSE},
322             {"urn",S_OK,FALSE},
323             {"",S_FALSE,FALSE},
324             {"",S_FALSE,FALSE}
325         },
326         {
327             {Uri_HOST_UNKNOWN,S_OK,FALSE},
328             {0,S_FALSE,FALSE},
329             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
330             {URLZONE_INVALID,E_NOTIMPL,FALSE}
331         }
332     },
333     {   "http://127.0.0.1/tests/../test dir/./test.txt", 0, S_OK, FALSE,
334         {
335             {"http://127.0.0.1/test%20dir/test.txt",S_OK,FALSE},
336             {"127.0.0.1",S_OK,FALSE},
337             {"http://127.0.0.1/test%20dir/test.txt",S_OK,FALSE},
338             {"",S_FALSE,FALSE},
339             {".txt",S_OK,FALSE},
340             {"",S_FALSE,FALSE},
341             {"127.0.0.1",S_OK,FALSE},
342             {"",S_FALSE,FALSE},
343             {"/test%20dir/test.txt",S_OK,FALSE},
344             {"/test%20dir/test.txt",S_OK,FALSE},
345             {"",S_FALSE,FALSE},
346             {"http://127.0.0.1/tests/../test dir/./test.txt",S_OK,FALSE},
347             {"http",S_OK,FALSE},
348             {"",S_FALSE,FALSE},
349             {"",S_FALSE,FALSE}
350         },
351         {
352             {Uri_HOST_IPV4,S_OK,FALSE},
353             {80,S_OK,FALSE},
354             {URL_SCHEME_HTTP,S_OK,FALSE},
355             {URLZONE_INVALID,E_NOTIMPL,FALSE}
356         }
357     },
358     {   "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", 0, S_OK, FALSE,
359         {
360             {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,FALSE},
361             {"[fedc:ba98:7654:3210:fedc:ba98:7654:3210]",S_OK,FALSE},
362             {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,FALSE},
363             {"",S_FALSE,FALSE},
364             {"",S_FALSE,FALSE},
365             {"",S_FALSE,FALSE},
366             {"fedc:ba98:7654:3210:fedc:ba98:7654:3210",S_OK,FALSE},
367             {"",S_FALSE,FALSE},
368             {"/",S_OK,FALSE},
369             {"/",S_OK,FALSE},
370             {"",S_FALSE,FALSE},
371             {"http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]",S_OK,FALSE},
372             {"http",S_OK,FALSE},
373             {"",S_FALSE,FALSE},
374             {"",S_FALSE,FALSE}
375         },
376         {
377             {Uri_HOST_IPV6,S_OK,FALSE},
378             {80,S_OK,FALSE},
379             {URL_SCHEME_HTTP,S_OK,FALSE},
380             {URLZONE_INVALID,E_NOTIMPL,FALSE}
381         }
382     },
383     {   "ftp://[::13.1.68.3]", 0, S_OK, FALSE,
384         {
385             {"ftp://[::13.1.68.3]/",S_OK,FALSE},
386             {"[::13.1.68.3]",S_OK,FALSE},
387             {"ftp://[::13.1.68.3]/",S_OK,FALSE},
388             {"",S_FALSE,FALSE},
389             {"",S_FALSE,FALSE},
390             {"",S_FALSE,FALSE},
391             {"::13.1.68.3",S_OK,FALSE},
392             {"",S_FALSE,FALSE},
393             {"/",S_OK,FALSE},
394             {"/",S_OK,FALSE},
395             {"",S_FALSE,FALSE},
396             {"ftp://[::13.1.68.3]",S_OK,FALSE},
397             {"ftp",S_OK,FALSE},
398             {"",S_FALSE,FALSE},
399             {"",S_FALSE,FALSE}
400         },
401         {
402             {Uri_HOST_IPV6,S_OK,FALSE},
403             {21,S_OK,FALSE},
404             {URL_SCHEME_FTP,S_OK,FALSE},
405             {URLZONE_INVALID,E_NOTIMPL,FALSE}
406         }
407     },
408     {   "http://[FEDC:BA98:0:0:0:0:0:3210]", 0, S_OK, FALSE,
409         {
410             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
411             {"[fedc:ba98::3210]",S_OK,FALSE},
412             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
413             {"",S_FALSE,FALSE},
414             {"",S_FALSE,FALSE},
415             {"",S_FALSE,FALSE},
416             {"fedc:ba98::3210",S_OK,FALSE},
417             {"",S_FALSE,FALSE},
418             {"/",S_OK,FALSE},
419             {"/",S_OK,FALSE},
420             {"",S_FALSE,FALSE},
421             {"http://[FEDC:BA98:0:0:0:0:0:3210]",S_OK,FALSE},
422             {"http",S_OK,FALSE},
423             {"",S_FALSE,FALSE},
424             {"",S_FALSE,FALSE},
425         },
426         {
427             {Uri_HOST_IPV6,S_OK,FALSE},
428             {80,S_OK,FALSE},
429             {URL_SCHEME_HTTP,S_OK,FALSE},
430             {URLZONE_INVALID,E_NOTIMPL,FALSE}
431         }
432     },
433     {   "1234://www.winehq.org", 0, S_OK, FALSE,
434         {
435             {"1234://www.winehq.org/",S_OK,FALSE},
436             {"www.winehq.org",S_OK,FALSE},
437             {"1234://www.winehq.org/",S_OK,FALSE},
438             {"winehq.org",S_OK,FALSE},
439             {"",S_FALSE,FALSE},
440             {"",S_FALSE,FALSE},
441             {"www.winehq.org",S_OK,FALSE},
442             {"",S_FALSE,FALSE},
443             {"/",S_OK,FALSE},
444             {"/",S_OK,FALSE},
445             {"",S_FALSE,FALSE},
446             {"1234://www.winehq.org",S_OK,FALSE},
447             {"1234",S_OK,FALSE},
448             {"",S_FALSE,FALSE},
449             {"",S_FALSE,FALSE}
450         },
451         {
452             {Uri_HOST_DNS,S_OK,FALSE},
453             {0,S_FALSE,FALSE},
454             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
455             {URLZONE_INVALID,E_NOTIMPL,FALSE}
456         }
457     },
458     /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
459     {   "C:/test/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
460         {
461             {"file:///C:/test/test.mp3",S_OK,FALSE},
462             {"",S_FALSE,FALSE},
463             {"file:///C:/test/test.mp3",S_OK,FALSE},
464             {"",S_FALSE,FALSE},
465             {".mp3",S_OK,FALSE},
466             {"",S_FALSE,FALSE},
467             {"",S_FALSE,FALSE},
468             {"",S_FALSE,FALSE},
469             {"/C:/test/test.mp3",S_OK,FALSE},
470             {"/C:/test/test.mp3",S_OK,FALSE},
471             {"",S_FALSE,FALSE},
472             {"C:/test/test.mp3",S_OK,FALSE},
473             {"file",S_OK,FALSE},
474             {"",S_FALSE,FALSE},
475             {"",S_FALSE,FALSE}
476         },
477         {
478             {Uri_HOST_UNKNOWN,S_OK,FALSE},
479             {0,S_FALSE,FALSE},
480             {URL_SCHEME_FILE,S_OK,FALSE},
481             {URLZONE_INVALID,E_NOTIMPL,FALSE}
482         }
483     },
484     /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
485     {   "\\\\Server/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
486         {
487             {"file://server/test.mp3",S_OK,FALSE},
488             {"server",S_OK,FALSE},
489             {"file://server/test.mp3",S_OK,FALSE},
490             {"",S_FALSE,FALSE},
491             {".mp3",S_OK,FALSE},
492             {"",S_FALSE,FALSE},
493             {"server",S_OK,FALSE},
494             {"",S_FALSE,FALSE},
495             {"/test.mp3",S_OK,FALSE},
496             {"/test.mp3",S_OK,FALSE},
497             {"",S_FALSE,FALSE},
498             {"\\\\Server/test.mp3",S_OK,FALSE},
499             {"file",S_OK,FALSE},
500             {"",S_FALSE,FALSE},
501             {"",S_FALSE,FALSE}
502         },
503         {
504             {Uri_HOST_DNS,S_OK,FALSE},
505             {0,S_FALSE,FALSE},
506             {URL_SCHEME_FILE,S_OK,FALSE},
507             {URLZONE_INVALID,E_NOTIMPL,FALSE}
508         }
509     },
510     {   "www.winehq.org/test", Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
511         {
512             {"*:www.winehq.org/test",S_OK,FALSE},
513             {"www.winehq.org",S_OK,FALSE},
514             {"*:www.winehq.org/test",S_OK,FALSE},
515             {"winehq.org",S_OK,FALSE},
516             {"",S_FALSE,FALSE},
517             {"",S_FALSE,FALSE},
518             {"www.winehq.org",S_OK,FALSE},
519             {"",S_FALSE,FALSE},
520             {"/test",S_OK,FALSE},
521             {"/test",S_OK,FALSE},
522             {"",S_FALSE,FALSE},
523             {"www.winehq.org/test",S_OK,FALSE},
524             {"*",S_OK,FALSE},
525             {"",S_FALSE,FALSE},
526             {"",S_FALSE,FALSE}
527         },
528         {
529             {Uri_HOST_DNS,S_OK,FALSE},
530             {0,S_FALSE,FALSE},
531             {URL_SCHEME_WILDCARD,S_OK,FALSE},
532             {URLZONE_INVALID,E_NOTIMPL,FALSE}
533         }
534     },
535     /* Valid since the '*' is the only character in the scheme name. */
536     {   "*:www.winehq.org/test", 0, S_OK, FALSE,
537         {
538             {"*:www.winehq.org/test",S_OK,FALSE},
539             {"www.winehq.org",S_OK,FALSE},
540             {"*:www.winehq.org/test",S_OK,FALSE},
541             {"winehq.org",S_OK,FALSE},
542             {"",S_FALSE,FALSE},
543             {"",S_FALSE,FALSE},
544             {"www.winehq.org",S_OK,FALSE},
545             {"",S_FALSE,FALSE},
546             {"/test",S_OK,FALSE},
547             {"/test",S_OK,FALSE},
548             {"",S_FALSE,FALSE},
549             {"*:www.winehq.org/test",S_OK,FALSE},
550             {"*",S_OK,FALSE},
551             {"",S_FALSE,FALSE},
552             {"",S_FALSE,FALSE}
553         },
554         {
555             {Uri_HOST_DNS,S_OK,FALSE},
556             {0,S_FALSE,FALSE},
557             {URL_SCHEME_WILDCARD,S_OK,FALSE},
558             {URLZONE_INVALID,E_NOTIMPL,FALSE}
559         }
560     },
561     {   "/../some dir/test.ext", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
562         {
563             {"/../some dir/test.ext",S_OK,FALSE},
564             {"",S_FALSE,FALSE},
565             {"/../some dir/test.ext",S_OK,FALSE},
566             {"",S_FALSE,FALSE},
567             {".ext",S_OK,FALSE},
568             {"",S_FALSE,FALSE},
569             {"",S_FALSE,FALSE},
570             {"",S_FALSE,FALSE},
571             {"/../some dir/test.ext",S_OK,FALSE},
572             {"/../some dir/test.ext",S_OK,FALSE},
573             {"",S_FALSE,FALSE},
574             {"/../some dir/test.ext",S_OK,FALSE},
575             {"",S_FALSE,FALSE},
576             {"",S_FALSE,FALSE},
577             {"",S_FALSE,FALSE}
578         },
579         {
580             {Uri_HOST_UNKNOWN,S_OK,FALSE},
581             {0,S_FALSE,FALSE},
582             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
583             {URLZONE_INVALID,E_NOTIMPL,FALSE}
584         }
585     },
586     {   "//implicit/wildcard/uri scheme", Uri_CREATE_ALLOW_RELATIVE|Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
587         {
588             {"*://implicit/wildcard/uri%20scheme",S_OK,FALSE},
589             {"",S_OK,FALSE},
590             {"*://implicit/wildcard/uri%20scheme",S_OK,FALSE},
591             {"",S_FALSE,FALSE},
592             {"",S_FALSE,FALSE},
593             {"",S_FALSE,FALSE},
594             {"",S_OK,FALSE},
595             {"",S_FALSE,FALSE},
596             {"//implicit/wildcard/uri%20scheme",S_OK,FALSE},
597             {"//implicit/wildcard/uri%20scheme",S_OK,FALSE},
598             {"",S_FALSE,FALSE},
599             {"//implicit/wildcard/uri scheme",S_OK,FALSE},
600             {"*",S_OK,FALSE},
601             {"",S_FALSE,FALSE},
602             {"",S_FALSE,FALSE},
603         },
604         {
605             {Uri_HOST_UNKNOWN,S_OK,FALSE},
606             {0,S_FALSE,FALSE},
607             {URL_SCHEME_WILDCARD,S_OK,FALSE},
608             {URLZONE_INVALID,E_NOTIMPL,FALSE}
609         }
610     },
611     /* URI is considered opaque since CREATE_NO_CRACK_UNKNOWN_SCHEMES is set and its an unknown scheme. */
612     {   "zip://google.com", Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, S_OK, FALSE,
613         {
614             {"zip:/.//google.com",S_OK,FALSE},
615             {"",S_FALSE,FALSE},
616             {"zip:/.//google.com",S_OK,FALSE},
617             {"",S_FALSE,FALSE},
618             {".com",S_OK,FALSE},
619             {"",S_FALSE,FALSE},
620             {"",S_FALSE,FALSE},
621             {"",S_FALSE,FALSE},
622             {"/.//google.com",S_OK,FALSE},
623             {"/.//google.com",S_OK,FALSE},
624             {"",S_FALSE,FALSE},
625             {"zip://google.com",S_OK,FALSE},
626             {"zip",S_OK,FALSE},
627             {"",S_FALSE,FALSE},
628             {"",S_FALSE,FALSE}
629         },
630         {
631             {Uri_HOST_UNKNOWN,S_OK,FALSE},
632             {0,S_FALSE,FALSE},
633             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
634             {URLZONE_INVALID,E_NOTIMPL,FALSE}
635         }
636     },
637     /* Windows uses the first occurrence of ':' to delimit the userinfo. */
638     {   "ftp://user:pass:word@winehq.org/", 0, S_OK, FALSE,
639         {
640             {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
641             {"user:pass:word@winehq.org",S_OK,FALSE},
642             {"ftp://winehq.org/",S_OK,FALSE},
643             {"winehq.org",S_OK,FALSE},
644             {"",S_FALSE,FALSE},
645             {"",S_FALSE,FALSE},
646             {"winehq.org",S_OK,FALSE},
647             {"pass:word",S_OK,FALSE},
648             {"/",S_OK,FALSE},
649             {"/",S_OK,FALSE},
650             {"",S_FALSE,FALSE},
651             {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
652             {"ftp",S_OK,FALSE},
653             {"user:pass:word",S_OK,FALSE},
654             {"user",S_OK,FALSE}
655         },
656         {
657             {Uri_HOST_DNS,S_OK,FALSE},
658             {21,S_OK,FALSE},
659             {URL_SCHEME_FTP,S_OK,FALSE},
660             {URLZONE_INVALID,E_NOTIMPL,FALSE}
661         }
662     },
663     /* Make sure % encoded unreserved characters are decoded. */
664     {   "ftp://w%49%4Ee:PA%53%53@ftp.google.com/", 0, S_OK, FALSE,
665         {
666             {"ftp://wINe:PASS@ftp.google.com/",S_OK,FALSE},
667             {"wINe:PASS@ftp.google.com",S_OK,FALSE},
668             {"ftp://ftp.google.com/",S_OK,FALSE},
669             {"google.com",S_OK,FALSE},
670             {"",S_FALSE,FALSE},
671             {"",S_FALSE,FALSE},
672             {"ftp.google.com",S_OK,FALSE},
673             {"PASS",S_OK,FALSE},
674             {"/",S_OK,FALSE},
675             {"/",S_OK,FALSE},
676             {"",S_FALSE,FALSE},
677             {"ftp://w%49%4Ee:PA%53%53@ftp.google.com/",S_OK,FALSE},
678             {"ftp",S_OK,FALSE},
679             {"wINe:PASS",S_OK,FALSE},
680             {"wINe",S_OK,FALSE}
681         },
682         {
683             {Uri_HOST_DNS,S_OK,FALSE},
684             {21,S_OK,FALSE},
685             {URL_SCHEME_FTP,S_OK,FALSE},
686             {URLZONE_INVALID,E_NOTIMPL,FALSE}
687         }
688     },
689     /* Make sure % encoded characters which are NOT unreserved are NOT decoded. */
690     {   "ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/", 0, S_OK, FALSE,
691         {
692             {"ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/",S_OK,FALSE},
693             {"w%5D%5Be:PA%7B%7D@ftp.google.com",S_OK,FALSE},
694             {"ftp://ftp.google.com/",S_OK,FALSE},
695             {"google.com",S_OK,FALSE},
696             {"",S_FALSE,FALSE},
697             {"",S_FALSE,FALSE},
698             {"ftp.google.com",S_OK,FALSE},
699             {"PA%7B%7D",S_OK,FALSE},
700             {"/",S_OK,FALSE},
701             {"/",S_OK,FALSE},
702             {"",S_FALSE,FALSE},
703             {"ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/",S_OK,FALSE},
704             {"ftp",S_OK,FALSE},
705             {"w%5D%5Be:PA%7B%7D",S_OK,FALSE},
706             {"w%5D%5Be",S_OK,FALSE}
707         },
708         {
709             {Uri_HOST_DNS,S_OK,FALSE},
710             {21,S_OK,FALSE},
711             {URL_SCHEME_FTP,S_OK,FALSE},
712             {URLZONE_INVALID,E_NOTIMPL,FALSE}
713         }
714     },
715     /* You're allowed to have an empty password portion in the userinfo section. */
716     {   "ftp://empty:@ftp.google.com/", 0, S_OK, FALSE,
717         {
718             {"ftp://empty:@ftp.google.com/",S_OK,FALSE},
719             {"empty:@ftp.google.com",S_OK,FALSE},
720             {"ftp://ftp.google.com/",S_OK,FALSE},
721             {"google.com",S_OK,FALSE},
722             {"",S_FALSE,FALSE},
723             {"",S_FALSE,FALSE},
724             {"ftp.google.com",S_OK,FALSE},
725             {"",S_OK,FALSE},
726             {"/",S_OK,FALSE},
727             {"/",S_OK,FALSE},
728             {"",S_FALSE,FALSE},
729             {"ftp://empty:@ftp.google.com/",S_OK,FALSE},
730             {"ftp",S_OK,FALSE},
731             {"empty:",S_OK,FALSE},
732             {"empty",S_OK,FALSE}
733         },
734         {
735             {Uri_HOST_DNS,S_OK,FALSE},
736             {21,S_OK,FALSE},
737             {URL_SCHEME_FTP,S_OK,FALSE},
738             {URLZONE_INVALID,E_NOTIMPL,FALSE}
739         }
740     },
741     /* Make sure forbidden characters in "userinfo" get encoded. */
742     {   "ftp://\" \"weird@ftp.google.com/", 0, S_OK, FALSE,
743         {
744             {"ftp://%22%20%22weird@ftp.google.com/",S_OK,FALSE},
745             {"%22%20%22weird@ftp.google.com",S_OK,FALSE},
746             {"ftp://ftp.google.com/",S_OK,FALSE},
747             {"google.com",S_OK,FALSE},
748             {"",S_FALSE,FALSE},
749             {"",S_FALSE,FALSE},
750             {"ftp.google.com",S_OK,FALSE},
751             {"",S_FALSE,FALSE},
752             {"/",S_OK,FALSE},
753             {"/",S_OK,FALSE},
754             {"",S_FALSE,FALSE},
755             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
756             {"ftp",S_OK,FALSE},
757             {"%22%20%22weird",S_OK,FALSE},
758             {"%22%20%22weird",S_OK,FALSE}
759         },
760         {
761             {Uri_HOST_DNS,S_OK,FALSE},
762             {21,S_OK,FALSE},
763             {URL_SCHEME_FTP,S_OK,FALSE},
764             {URLZONE_INVALID,E_NOTIMPL,FALSE}
765         }
766     },
767     /* Make sure the forbidden characters don't get percent encoded. */
768     {   "ftp://\" \"weird@ftp.google.com/", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
769         {
770             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
771             {"\" \"weird@ftp.google.com",S_OK,FALSE},
772             {"ftp://ftp.google.com/",S_OK,FALSE},
773             {"google.com",S_OK,FALSE},
774             {"",S_FALSE,FALSE},
775             {"",S_FALSE,FALSE},
776             {"ftp.google.com",S_OK,FALSE},
777             {"",S_FALSE,FALSE},
778             {"/",S_OK,FALSE},
779             {"/",S_OK,FALSE},
780             {"",S_FALSE,FALSE},
781             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
782             {"ftp",S_OK,FALSE},
783             {"\" \"weird",S_OK,FALSE},
784             {"\" \"weird",S_OK,FALSE}
785         },
786         {
787             {Uri_HOST_DNS,S_OK,FALSE},
788             {21,S_OK,FALSE},
789             {URL_SCHEME_FTP,S_OK,FALSE},
790             {URLZONE_INVALID,E_NOTIMPL,FALSE}
791         }
792     },
793     /* Make sure already percent encoded characters don't get unencoded. */
794     {   "ftp://\"%20\"weird@ftp.google.com/\"%20\"weird", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
795         {
796             {"ftp://\"%20\"weird@ftp.google.com/\"%20\"weird",S_OK,FALSE},
797             {"\"%20\"weird@ftp.google.com",S_OK,FALSE},
798             {"ftp://ftp.google.com/\"%20\"weird",S_OK,FALSE},
799             {"google.com",S_OK,FALSE},
800             {"",S_FALSE,FALSE},
801             {"",S_FALSE,FALSE},
802             {"ftp.google.com",S_OK,FALSE},
803             {"",S_FALSE,FALSE},
804             {"/\"%20\"weird",S_OK,FALSE},
805             {"/\"%20\"weird",S_OK,FALSE},
806             {"",S_FALSE,FALSE},
807             {"ftp://\"%20\"weird@ftp.google.com/\"%20\"weird",S_OK,FALSE},
808             {"ftp",S_OK,FALSE},
809             {"\"%20\"weird",S_OK,FALSE},
810             {"\"%20\"weird",S_OK,FALSE}
811         },
812         {
813             {Uri_HOST_DNS,S_OK,FALSE},
814             {21,S_OK,FALSE},
815             {URL_SCHEME_FTP,S_OK,FALSE},
816             {URLZONE_INVALID,E_NOTIMPL,FALSE}
817         }
818     },
819     /* Allowed to have invalid % encoded because its an unknown scheme type. */
820     {   "zip://%xy:word@winehq.org/", 0, S_OK, FALSE,
821         {
822             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
823             {"%xy:word@winehq.org",S_OK,FALSE},
824             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
825             {"winehq.org",S_OK,FALSE},
826             {"",S_FALSE,FALSE},
827             {"",S_FALSE,FALSE},
828             {"winehq.org",S_OK,FALSE},
829             {"word",S_OK,FALSE},
830             {"/",S_OK,FALSE},
831             {"/",S_OK,FALSE},
832             {"",S_FALSE,FALSE},
833             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
834             {"zip",S_OK,FALSE},
835             {"%xy:word",S_OK,FALSE},
836             {"%xy",S_OK,FALSE}
837         },
838         {
839             {Uri_HOST_DNS,S_OK,FALSE},
840             {0,S_FALSE,FALSE},
841             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
842             {URLZONE_INVALID,E_NOTIMPL,FALSE}
843         }
844     },
845     /* Unreserved, percent encoded characters aren't decoded in the userinfo becuase the scheme
846      * isn't known.
847      */
848     {   "zip://%2E:%52%53ord@winehq.org/", 0, S_OK, FALSE,
849         {
850             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
851             {"%2E:%52%53ord@winehq.org",S_OK,FALSE},
852             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
853             {"winehq.org",S_OK,FALSE},
854             {"",S_FALSE,FALSE},
855             {"",S_FALSE,FALSE},
856             {"winehq.org",S_OK,FALSE},
857             {"%52%53ord",S_OK,FALSE},
858             {"/",S_OK,FALSE},
859             {"/",S_OK,FALSE},
860             {"",S_FALSE,FALSE},
861             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
862             {"zip",S_OK,FALSE},
863             {"%2E:%52%53ord",S_OK,FALSE},
864             {"%2E",S_OK,FALSE}
865         },
866         {
867             {Uri_HOST_DNS,S_OK,FALSE},
868             {0,S_FALSE,FALSE},
869             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
870             {URLZONE_INVALID,E_NOTIMPL,FALSE}
871         }
872     },
873     {   "ftp://[](),'test':word@winehq.org/", 0, S_OK, FALSE,
874         {
875             {"ftp://[](),'test':word@winehq.org/",S_OK,FALSE},
876             {"[](),'test':word@winehq.org",S_OK,FALSE},
877             {"ftp://winehq.org/",S_OK,FALSE},
878             {"winehq.org",S_OK,FALSE},
879             {"",S_FALSE,FALSE},
880             {"",S_FALSE,FALSE},
881             {"winehq.org",S_OK,FALSE},
882             {"word",S_OK,FALSE},
883             {"/",S_OK,FALSE},
884             {"/",S_OK,FALSE},
885             {"",S_FALSE,FALSE},
886             {"ftp://[](),'test':word@winehq.org/",S_OK,FALSE},
887             {"ftp",S_OK,FALSE},
888             {"[](),'test':word",S_OK,FALSE},
889             {"[](),'test'",S_OK,FALSE}
890         },
891         {
892             {Uri_HOST_DNS,S_OK,FALSE},
893             {21,S_OK,FALSE},
894             {URL_SCHEME_FTP,S_OK,FALSE},
895             {URLZONE_INVALID,E_NOTIMPL,FALSE}
896         }
897     },
898     {   "ftp://test?:word@winehq.org/", 0, S_OK, FALSE,
899         {
900             {"ftp://test/?:word@winehq.org/",S_OK,FALSE},
901             {"test",S_OK,FALSE},
902             {"ftp://test/?:word@winehq.org/",S_OK,FALSE},
903             {"",S_FALSE,FALSE},
904             {"",S_FALSE,FALSE},
905             {"",S_FALSE,FALSE},
906             {"test",S_OK,FALSE},
907             {"",S_FALSE,FALSE},
908             {"/",S_OK,FALSE},
909             {"/?:word@winehq.org/",S_OK,FALSE},
910             {"?:word@winehq.org/",S_OK,FALSE},
911             {"ftp://test?:word@winehq.org/",S_OK,FALSE},
912             {"ftp",S_OK,FALSE},
913             {"",S_FALSE,FALSE},
914             {"",S_FALSE,FALSE}
915         },
916         {
917             {Uri_HOST_DNS,S_OK,FALSE},
918             {21,S_OK,FALSE},
919             {URL_SCHEME_FTP,S_OK,FALSE},
920             {URLZONE_INVALID,E_NOTIMPL,FALSE}
921         }
922     },
923     {   "ftp://test#:word@winehq.org/", 0, S_OK, FALSE,
924         {
925             {"ftp://test/#:word@winehq.org/",S_OK,FALSE},
926             {"test",S_OK,FALSE},
927             {"ftp://test/#:word@winehq.org/",S_OK,FALSE},
928             {"",S_FALSE,FALSE},
929             {"",S_FALSE,FALSE},
930             {"#:word@winehq.org/",S_OK,FALSE},
931             {"test",S_OK,FALSE},
932             {"",S_FALSE,FALSE},
933             {"/",S_OK,FALSE},
934             {"/",S_OK,FALSE},
935             {"",S_FALSE,FALSE},
936             {"ftp://test#:word@winehq.org/",S_OK,FALSE},
937             {"ftp",S_OK,FALSE},
938             {"",S_FALSE,FALSE},
939             {"",S_FALSE,FALSE}
940         },
941         {
942             {Uri_HOST_DNS,S_OK,FALSE},
943             {21,S_OK,FALSE},
944             {URL_SCHEME_FTP,S_OK,FALSE},
945             {URLZONE_INVALID,E_NOTIMPL,FALSE}
946         }
947     },
948     /* Allowed to have a backslash in the userinfo since it's an unknown scheme. */
949     {   "zip://test\\:word@winehq.org/", 0, S_OK, FALSE,
950         {
951             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
952             {"test\\:word@winehq.org",S_OK,FALSE},
953             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
954             {"winehq.org",S_OK,FALSE},
955             {"",S_FALSE,FALSE},
956             {"",S_FALSE,FALSE},
957             {"winehq.org",S_OK,FALSE},
958             {"word",S_OK,FALSE},
959             {"/",S_OK,FALSE},
960             {"/",S_OK,FALSE},
961             {"",S_FALSE,FALSE},
962             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
963             {"zip",S_OK,FALSE},
964             {"test\\:word",S_OK,FALSE},
965             {"test\\",S_OK,FALSE}
966         },
967         {
968             {Uri_HOST_DNS,S_OK,FALSE},
969             {0,S_FALSE,FALSE},
970             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
971             {URLZONE_INVALID,E_NOTIMPL,FALSE}
972         }
973     },
974     /* It normalizes IPv4 addresses correctly. */
975     {   "http://127.000.000.100/", 0, S_OK, FALSE,
976         {
977             {"http://127.0.0.100/",S_OK,FALSE},
978             {"127.0.0.100",S_OK,FALSE},
979             {"http://127.0.0.100/",S_OK,FALSE},
980             {"",S_FALSE,FALSE},
981             {"",S_FALSE,FALSE},
982             {"",S_FALSE,FALSE},
983             {"127.0.0.100",S_OK,FALSE},
984             {"",S_FALSE,FALSE},
985             {"/",S_OK,FALSE},
986             {"/",S_OK,FALSE},
987             {"",S_FALSE,FALSE},
988             {"http://127.000.000.100/",S_OK,FALSE},
989             {"http",S_OK,FALSE},
990             {"",S_FALSE,FALSE},
991             {"",S_FALSE,FALSE}
992         },
993         {
994             {Uri_HOST_IPV4,S_OK,FALSE},
995             {80,S_OK,FALSE},
996             {URL_SCHEME_HTTP,S_OK,FALSE},
997             {URLZONE_INVALID,E_NOTIMPL,FALSE}
998         }
999     },
1000     /* Make sure it normalizes partial IPv4 addresses correctly. */
1001     {   "http://127.0/", 0, S_OK, FALSE,
1002         {
1003             {"http://127.0.0.0/",S_OK,FALSE},
1004             {"127.0.0.0",S_OK,FALSE},
1005             {"http://127.0.0.0/",S_OK,FALSE},
1006             {"",S_FALSE,FALSE},
1007             {"",S_FALSE,FALSE},
1008             {"",S_FALSE,FALSE},
1009             {"127.0.0.0",S_OK,FALSE},
1010             {"",S_FALSE,FALSE},
1011             {"/",S_OK,FALSE},
1012             {"/",S_OK,FALSE},
1013             {"",S_FALSE,FALSE},
1014             {"http://127.0/",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     /* Make sure it converts implicit IPv4's correctly. */
1027     {   "http://123456/", 0, S_OK, FALSE,
1028         {
1029             {"http://0.1.226.64/",S_OK,FALSE},
1030             {"0.1.226.64",S_OK,FALSE},
1031             {"http://0.1.226.64/",S_OK,FALSE},
1032             {"",S_FALSE,FALSE},
1033             {"",S_FALSE,FALSE},
1034             {"",S_FALSE,FALSE},
1035             {"0.1.226.64",S_OK,FALSE},
1036             {"",S_FALSE,FALSE},
1037             {"/",S_OK,FALSE},
1038             {"/",S_OK,FALSE},
1039             {"",S_FALSE,FALSE},
1040             {"http://123456/",S_OK,FALSE},
1041             {"http",S_OK,FALSE},
1042             {"",S_FALSE,FALSE},
1043             {"",S_FALSE,FALSE}
1044         },
1045         {
1046             {Uri_HOST_IPV4,S_OK,FALSE},
1047             {80,S_OK,FALSE},
1048             {URL_SCHEME_HTTP,S_OK,FALSE},
1049             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1050         }
1051     },
1052     /* UINT_MAX */
1053     {   "http://4294967295/", 0, S_OK, FALSE,
1054         {
1055             {"http://255.255.255.255/",S_OK,FALSE},
1056             {"255.255.255.255",S_OK,FALSE},
1057             {"http://255.255.255.255/",S_OK,FALSE},
1058             {"",S_FALSE,FALSE},
1059             {"",S_FALSE,FALSE},
1060             {"",S_FALSE,FALSE},
1061             {"255.255.255.255",S_OK,FALSE},
1062             {"",S_FALSE,FALSE},
1063             {"/",S_OK,FALSE},
1064             {"/",S_OK,FALSE},
1065             {"",S_FALSE,FALSE},
1066             {"http://4294967295/",S_OK,FALSE},
1067             {"http",S_OK,FALSE},
1068             {"",S_FALSE,FALSE},
1069             {"",S_FALSE,FALSE}
1070         },
1071         {
1072             {Uri_HOST_IPV4,S_OK,FALSE},
1073             {80,S_OK,FALSE},
1074             {URL_SCHEME_HTTP,S_OK,FALSE},
1075             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1076         }
1077     },
1078     /* UINT_MAX+1 */
1079     {   "http://4294967296/", 0, S_OK, FALSE,
1080         {
1081             {"http://4294967296/",S_OK,FALSE},
1082             {"4294967296",S_OK,FALSE},
1083             {"http://4294967296/",S_OK,FALSE},
1084             {"",S_FALSE,FALSE},
1085             {"",S_FALSE,FALSE},
1086             {"",S_FALSE,FALSE},
1087             {"4294967296",S_OK,FALSE},
1088             {"",S_FALSE,FALSE},
1089             {"/",S_OK,FALSE},
1090             {"/",S_OK,FALSE},
1091             {"",S_FALSE,FALSE},
1092             {"http://4294967296/",S_OK,FALSE},
1093             {"http",S_OK,FALSE},
1094             {"",S_FALSE,FALSE},
1095             {"",S_FALSE,FALSE}
1096         },
1097         {
1098             {Uri_HOST_DNS,S_OK,FALSE},
1099             {80,S_OK,FALSE},
1100             {URL_SCHEME_HTTP,S_OK,FALSE},
1101             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1102         }
1103     },
1104     /* Window's doesn't normalize IP address for unknown schemes. */
1105     {   "1234://4294967295/", 0, S_OK, FALSE,
1106         {
1107             {"1234://4294967295/",S_OK,FALSE},
1108             {"4294967295",S_OK,FALSE},
1109             {"1234://4294967295/",S_OK,FALSE},
1110             {"",S_FALSE,FALSE},
1111             {"",S_FALSE,FALSE},
1112             {"",S_FALSE,FALSE},
1113             {"4294967295",S_OK,FALSE},
1114             {"",S_FALSE,FALSE},
1115             {"/",S_OK,FALSE},
1116             {"/",S_OK,FALSE},
1117             {"",S_FALSE,FALSE},
1118             {"1234://4294967295/",S_OK,FALSE},
1119             {"1234",S_OK,FALSE},
1120             {"",S_FALSE,FALSE},
1121             {"",S_FALSE,FALSE}
1122         },
1123         {
1124             {Uri_HOST_IPV4,S_OK,FALSE},
1125             {0,S_FALSE,FALSE},
1126             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1127             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1128         }
1129     },
1130     /* Window's doesn't normalize IP address for unknown schemes. */
1131     {   "1234://127.001/", 0, S_OK, FALSE,
1132         {
1133             {"1234://127.001/",S_OK,FALSE},
1134             {"127.001",S_OK,FALSE},
1135             {"1234://127.001/",S_OK,FALSE},
1136             {"",S_FALSE,FALSE},
1137             {"",S_FALSE,FALSE},
1138             {"",S_FALSE,FALSE},
1139             {"127.001",S_OK,FALSE},
1140             {"",S_FALSE,FALSE},
1141             {"/",S_OK,FALSE},
1142             {"/",S_OK,FALSE},
1143             {"",S_FALSE,FALSE},
1144             {"1234://127.001/",S_OK,FALSE},
1145             {"1234",S_OK,FALSE},
1146             {"",S_FALSE,FALSE},
1147             {"",S_FALSE,FALSE}
1148         },
1149         {
1150             {Uri_HOST_IPV4,S_OK,FALSE},
1151             {0,S_FALSE,FALSE},
1152             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1153             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1154         }
1155     },
1156     {   "http://[FEDC:BA98::3210]", 0, S_OK, FALSE,
1157         {
1158             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
1159             {"[fedc:ba98::3210]",S_OK,FALSE},
1160             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
1161             {"",S_FALSE,FALSE},
1162             {"",S_FALSE,FALSE},
1163             {"",S_FALSE,FALSE},
1164             {"fedc:ba98::3210",S_OK,FALSE},
1165             {"",S_FALSE,FALSE},
1166             {"/",S_OK,FALSE},
1167             {"/",S_OK,FALSE},
1168             {"",S_FALSE,FALSE},
1169             {"http://[FEDC:BA98::3210]",S_OK,FALSE},
1170             {"http",S_OK,FALSE},
1171             {"",S_FALSE,FALSE},
1172             {"",S_FALSE,FALSE},
1173         },
1174         {
1175             {Uri_HOST_IPV6,S_OK,FALSE},
1176             {80,S_OK,FALSE},
1177             {URL_SCHEME_HTTP,S_OK,FALSE},
1178             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1179         }
1180     },
1181     {   "http://[::]", 0, S_OK, FALSE,
1182         {
1183             {"http://[::]/",S_OK,FALSE},
1184             {"[::]",S_OK,FALSE},
1185             {"http://[::]/",S_OK,FALSE},
1186             {"",S_FALSE,FALSE},
1187             {"",S_FALSE,FALSE},
1188             {"",S_FALSE,FALSE},
1189             {"::",S_OK,FALSE},
1190             {"",S_FALSE,FALSE},
1191             {"/",S_OK,FALSE},
1192             {"/",S_OK,FALSE},
1193             {"",S_FALSE,FALSE},
1194             {"http://[::]",S_OK,FALSE},
1195             {"http",S_OK,FALSE},
1196             {"",S_FALSE,FALSE},
1197             {"",S_FALSE,FALSE},
1198         },
1199         {
1200             {Uri_HOST_IPV6,S_OK,FALSE},
1201             {80,S_OK,FALSE},
1202             {URL_SCHEME_HTTP,S_OK,FALSE},
1203             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1204         }
1205     },
1206     {   "http://[FEDC:BA98::]", 0, S_OK, FALSE,
1207         {
1208             {"http://[fedc:ba98::]/",S_OK,FALSE},
1209             {"[fedc:ba98::]",S_OK,FALSE},
1210             {"http://[fedc:ba98::]/",S_OK,FALSE},
1211             {"",S_FALSE,FALSE},
1212             {"",S_FALSE,FALSE},
1213             {"",S_FALSE,FALSE},
1214             {"fedc:ba98::",S_OK,FALSE},
1215             {"",S_FALSE,FALSE},
1216             {"/",S_OK,FALSE},
1217             {"/",S_OK,FALSE},
1218             {"",S_FALSE,FALSE},
1219             {"http://[FEDC:BA98::]",S_OK,FALSE},
1220             {"http",S_OK,FALSE},
1221             {"",S_FALSE,FALSE},
1222             {"",S_FALSE,FALSE},
1223         },
1224         {
1225             {Uri_HOST_IPV6,S_OK,FALSE},
1226             {80,S_OK,FALSE},
1227             {URL_SCHEME_HTTP,S_OK,FALSE},
1228             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1229         }
1230     },
1231     /* Valid even with 2 byte elision because it doesn't appear the beginning or end. */
1232     {   "http://[1::3:4:5:6:7:8]", 0, S_OK, FALSE,
1233         {
1234             {"http://[1:0:3:4:5:6:7:8]/",S_OK,FALSE},
1235             {"[1:0:3:4:5:6:7:8]",S_OK,FALSE},
1236             {"http://[1:0:3:4:5:6:7:8]/",S_OK,FALSE},
1237             {"",S_FALSE,FALSE},
1238             {"",S_FALSE,FALSE},
1239             {"",S_FALSE,FALSE},
1240             {"1:0:3:4:5:6:7:8",S_OK,FALSE},
1241             {"",S_FALSE,FALSE},
1242             {"/",S_OK,FALSE},
1243             {"/",S_OK,FALSE},
1244             {"",S_FALSE,FALSE},
1245             {"http://[1::3:4:5:6:7:8]",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://[v2.34]/", 0, S_OK, FALSE,
1258         {
1259             {"http://[v2.34]/",S_OK,FALSE},
1260             {"[v2.34]",S_OK,FALSE},
1261             {"http://[v2.34]/",S_OK,FALSE},
1262             {"",S_FALSE,FALSE},
1263             {"",S_FALSE,FALSE},
1264             {"",S_FALSE,FALSE},
1265             {"[v2.34]",S_OK,FALSE},
1266             {"",S_FALSE,FALSE},
1267             {"/",S_OK,FALSE},
1268             {"/",S_OK,FALSE},
1269             {"",S_FALSE,FALSE},
1270             {"http://[v2.34]/",S_OK,FALSE},
1271             {"http",S_OK,FALSE},
1272             {"",S_FALSE,FALSE},
1273             {"",S_FALSE,FALSE}
1274         },
1275         {
1276             {Uri_HOST_UNKNOWN,S_OK,FALSE},
1277             {80,S_OK,FALSE},
1278             {URL_SCHEME_HTTP,S_OK,FALSE},
1279             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1280         }
1281     },
1282     /* Windows ignores ':' if they appear after a '[' on a non-IPLiteral host. */
1283     {   "http://[xyz:12345.com/test", 0, S_OK, FALSE,
1284         {
1285             {"http://[xyz:12345.com/test",S_OK,FALSE},
1286             {"[xyz:12345.com",S_OK,FALSE},
1287             {"http://[xyz:12345.com/test",S_OK,FALSE},
1288             {"[xyz:12345.com",S_OK,FALSE},
1289             {"",S_FALSE,FALSE},
1290             {"",S_FALSE,FALSE},
1291             {"[xyz:12345.com",S_OK,FALSE},
1292             {"",S_FALSE,FALSE},
1293             {"/test",S_OK,FALSE},
1294             {"/test",S_OK,FALSE},
1295             {"",S_FALSE,FALSE},
1296             {"http://[xyz:12345.com/test",S_OK,FALSE},
1297             {"http",S_OK,FALSE},
1298             {"",S_FALSE,FALSE},
1299             {"",S_FALSE,FALSE}
1300         },
1301         {
1302             {Uri_HOST_DNS,S_OK,FALSE},
1303             {80,S_OK,FALSE},
1304             {URL_SCHEME_HTTP,S_OK,FALSE},
1305             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1306         }
1307     },
1308     /* Valid URI since the '[' and ']' don't appear at the beginning and end
1309      * of the host name (respectively).
1310      */
1311     {   "ftp://www.[works].com/", 0, S_OK, FALSE,
1312         {
1313             {"ftp://www.[works].com/",S_OK,FALSE},
1314             {"www.[works].com",S_OK,FALSE},
1315             {"ftp://www.[works].com/",S_OK,FALSE},
1316             {"[works].com",S_OK,FALSE},
1317             {"",S_FALSE,FALSE},
1318             {"",S_FALSE,FALSE},
1319             {"www.[works].com",S_OK,FALSE},
1320             {"",S_FALSE,FALSE},
1321             {"/",S_OK,FALSE},
1322             {"/",S_OK,FALSE},
1323             {"",S_FALSE,FALSE},
1324             {"ftp://www.[works].com/",S_OK,FALSE},
1325             {"ftp",S_OK,FALSE},
1326             {"",S_FALSE,FALSE},
1327             {"",S_FALSE,FALSE}
1328         },
1329         {
1330             {Uri_HOST_DNS,S_OK,FALSE},
1331             {21,S_OK,FALSE},
1332             {URL_SCHEME_FTP,S_OK,FALSE},
1333             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1334         }
1335     },
1336     /* Considers ':' a delimiter since it appears after the ']'. */
1337     {   "http://www.google.com]:12345/", 0, S_OK, FALSE,
1338         {
1339             {"http://www.google.com]:12345/",S_OK,FALSE},
1340             {"www.google.com]:12345",S_OK,FALSE},
1341             {"http://www.google.com]:12345/",S_OK,FALSE},
1342             {"google.com]",S_OK,FALSE},
1343             {"",S_FALSE,FALSE},
1344             {"",S_FALSE,FALSE},
1345             {"www.google.com]",S_OK,FALSE},
1346             {"",S_FALSE,FALSE},
1347             {"/",S_OK,FALSE},
1348             {"/",S_OK,FALSE},
1349             {"",S_FALSE,FALSE},
1350             {"http://www.google.com]:12345/",S_OK,FALSE},
1351             {"http",S_OK,FALSE},
1352             {"",S_FALSE,FALSE},
1353             {"",S_FALSE,FALSE}
1354         },
1355         {
1356             {Uri_HOST_DNS,S_OK,FALSE},
1357             {12345,S_OK,FALSE},
1358             {URL_SCHEME_HTTP,S_OK,FALSE},
1359             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1360         }
1361     },
1362     /* Unknown scheme types can have invalid % encoded data in the hostname. */
1363     {   "zip://w%XXw%GEw.google.com/", 0, S_OK, FALSE,
1364         {
1365             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1366             {"w%XXw%GEw.google.com",S_OK,FALSE},
1367             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1368             {"google.com",S_OK,FALSE},
1369             {"",S_FALSE,FALSE},
1370             {"",S_FALSE,FALSE},
1371             {"w%XXw%GEw.google.com",S_OK,FALSE},
1372             {"",S_FALSE,FALSE},
1373             {"/",S_OK,FALSE},
1374             {"/",S_OK,FALSE},
1375             {"",S_FALSE,FALSE},
1376             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1377             {"zip",S_OK,FALSE},
1378             {"",S_FALSE,FALSE},
1379             {"",S_FALSE,FALSE}
1380         },
1381         {
1382             {Uri_HOST_DNS,S_OK,FALSE},
1383             {0,S_FALSE,FALSE},
1384             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1385             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1386         }
1387     },
1388     /* Unknown scheme types hostname doesn't get lower cased. */
1389     {   "zip://GOOGLE.com/", 0, S_OK, FALSE,
1390         {
1391             {"zip://GOOGLE.com/",S_OK,FALSE},
1392             {"GOOGLE.com",S_OK,FALSE},
1393             {"zip://GOOGLE.com/",S_OK,FALSE},
1394             {"GOOGLE.com",S_OK,FALSE},
1395             {"",S_FALSE,FALSE},
1396             {"",S_FALSE,FALSE},
1397             {"GOOGLE.com",S_OK,FALSE},
1398             {"",S_FALSE,FALSE},
1399             {"/",S_OK,FALSE},
1400             {"/",S_OK,FALSE},
1401             {"",S_FALSE,FALSE},
1402             {"zip://GOOGLE.com/",S_OK,FALSE},
1403             {"zip",S_OK,FALSE},
1404             {"",S_FALSE,FALSE},
1405             {"",S_FALSE,FALSE}
1406         },
1407         {
1408             {Uri_HOST_DNS,S_OK,FALSE},
1409             {0,S_FALSE,FALSE},
1410             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1411             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1412         }
1413     },
1414     /* Hostname get's lower cased for known scheme types. */
1415     {   "http://WWW.GOOGLE.com/", 0, S_OK, FALSE,
1416         {
1417             {"http://www.google.com/",S_OK,FALSE},
1418             {"www.google.com",S_OK,FALSE},
1419             {"http://www.google.com/",S_OK,FALSE},
1420             {"google.com",S_OK,FALSE},
1421             {"",S_FALSE,FALSE},
1422             {"",S_FALSE,FALSE},
1423             {"www.google.com",S_OK,FALSE},
1424             {"",S_FALSE,FALSE},
1425             {"/",S_OK,FALSE},
1426             {"/",S_OK,FALSE},
1427             {"",S_FALSE,FALSE},
1428             {"http://WWW.GOOGLE.com/",S_OK,FALSE},
1429             {"http",S_OK,FALSE},
1430             {"",S_FALSE,FALSE},
1431             {"",S_FALSE,FALSE}
1432         },
1433         {
1434             {Uri_HOST_DNS,S_OK,FALSE},
1435             {80,S_OK,FALSE},
1436             {URL_SCHEME_HTTP,S_OK,FALSE},
1437             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1438         }
1439     },
1440     /* Characters that get % encoded in the hostname also have their percent
1441      * encoded forms lower cased.
1442      */
1443     {   "http://www.%7Cgoogle|.com/", 0, S_OK, FALSE,
1444         {
1445             {"http://www.%7cgoogle%7c.com/",S_OK,FALSE},
1446             {"www.%7cgoogle%7c.com",S_OK,FALSE},
1447             {"http://www.%7cgoogle%7c.com/",S_OK,FALSE},
1448             {"%7cgoogle%7c.com",S_OK,FALSE},
1449             {"",S_FALSE,FALSE},
1450             {"",S_FALSE,FALSE},
1451             {"www.%7cgoogle%7c.com",S_OK,FALSE},
1452             {"",S_FALSE,FALSE},
1453             {"/",S_OK,FALSE},
1454             {"/",S_OK,FALSE},
1455             {"",S_FALSE,FALSE},
1456             {"http://www.%7Cgoogle|.com/",S_OK,FALSE},
1457             {"http",S_OK,FALSE},
1458             {"",S_FALSE,FALSE},
1459             {"",S_FALSE,FALSE}
1460         },
1461         {
1462             {Uri_HOST_DNS,S_OK,FALSE},
1463             {80,S_OK,FALSE},
1464             {URL_SCHEME_HTTP,S_OK,FALSE},
1465             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1466         }
1467     },
1468     /* IPv4 addresses attached to IPv6 can be included in elisions. */
1469     {   "http://[1:2:3:4:5:6:0.0.0.0]", 0, S_OK, FALSE,
1470         {
1471             {"http://[1:2:3:4:5:6::]/",S_OK,FALSE},
1472             {"[1:2:3:4:5:6::]",S_OK,FALSE},
1473             {"http://[1:2:3:4:5:6::]/",S_OK,FALSE},
1474             {"",S_FALSE,FALSE},
1475             {"",S_FALSE,FALSE},
1476             {"",S_FALSE,FALSE},
1477             {"1:2:3:4:5:6::",S_OK,FALSE},
1478             {"",S_FALSE,FALSE},
1479             {"/",S_OK,FALSE},
1480             {"/",S_OK,FALSE},
1481             {"",S_FALSE,FALSE},
1482             {"http://[1:2:3:4:5:6:0.0.0.0]",S_OK,FALSE},
1483             {"http",S_OK,FALSE},
1484             {"",S_FALSE,FALSE},
1485             {"",S_FALSE,FALSE},
1486         },
1487         {
1488             {Uri_HOST_IPV6,S_OK,FALSE},
1489             {80,S_OK,FALSE},
1490             {URL_SCHEME_HTTP,S_OK,FALSE},
1491             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1492         }
1493     },
1494     /* IPv4 addresses get normalized. */
1495     {   "http://[::001.002.003.000]", 0, S_OK, FALSE,
1496         {
1497             {"http://[::1.2.3.0]/",S_OK,FALSE},
1498             {"[::1.2.3.0]",S_OK,FALSE},
1499             {"http://[::1.2.3.0]/",S_OK,FALSE},
1500             {"",S_FALSE,FALSE},
1501             {"",S_FALSE,FALSE},
1502             {"",S_FALSE,FALSE},
1503             {"::1.2.3.0",S_OK,FALSE},
1504             {"",S_FALSE,FALSE},
1505             {"/",S_OK,FALSE},
1506             {"/",S_OK,FALSE},
1507             {"",S_FALSE,FALSE},
1508             {"http://[::001.002.003.000]",S_OK,FALSE},
1509             {"http",S_OK,FALSE},
1510             {"",S_FALSE,FALSE},
1511             {"",S_FALSE,FALSE},
1512         },
1513         {
1514             {Uri_HOST_IPV6,S_OK,FALSE},
1515             {80,S_OK,FALSE},
1516             {URL_SCHEME_HTTP,S_OK,FALSE},
1517             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1518         }
1519     },
1520     /* Windows doesn't do anything to IPv6's in unknown schemes. */
1521     {   "zip://[0001:0:000:0004:0005:0006:001.002.003.000]", 0, S_OK, FALSE,
1522         {
1523             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]/",S_OK,FALSE},
1524             {"[0001:0:000:0004:0005:0006:001.002.003.000]",S_OK,FALSE},
1525             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]/",S_OK,FALSE},
1526             {"",S_FALSE,FALSE},
1527             {"",S_FALSE,FALSE},
1528             {"",S_FALSE,FALSE},
1529             {"0001:0:000:0004:0005:0006:001.002.003.000",S_OK,FALSE},
1530             {"",S_FALSE,FALSE},
1531             {"/",S_OK,FALSE},
1532             {"/",S_OK,FALSE},
1533             {"",S_FALSE,FALSE},
1534             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]",S_OK,FALSE},
1535             {"zip",S_OK,FALSE},
1536             {"",S_FALSE,FALSE},
1537             {"",S_FALSE,FALSE},
1538         },
1539         {
1540             {Uri_HOST_IPV6,S_OK,FALSE},
1541             {0,S_FALSE,FALSE},
1542             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1543             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1544         }
1545     },
1546     /* IPv4 address is converted into 2 h16 components. */
1547     {   "http://[ffff::192.222.111.32]", 0, S_OK, FALSE,
1548         {
1549             {"http://[ffff::c0de:6f20]/",S_OK,FALSE},
1550             {"[ffff::c0de:6f20]",S_OK,FALSE},
1551             {"http://[ffff::c0de:6f20]/",S_OK,FALSE},
1552             {"",S_FALSE,FALSE},
1553             {"",S_FALSE,FALSE},
1554             {"",S_FALSE,FALSE},
1555             {"ffff::c0de:6f20",S_OK,FALSE},
1556             {"",S_FALSE,FALSE},
1557             {"/",S_OK,FALSE},
1558             {"/",S_OK,FALSE},
1559             {"",S_FALSE,FALSE},
1560             {"http://[ffff::192.222.111.32]",S_OK,FALSE},
1561             {"http",S_OK,FALSE},
1562             {"",S_FALSE,FALSE},
1563             {"",S_FALSE,FALSE},
1564         },
1565         {
1566             {Uri_HOST_IPV6,S_OK,FALSE},
1567             {80,S_OK,FALSE},
1568             {URL_SCHEME_HTTP,S_OK,FALSE},
1569             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1570         }
1571     },
1572     /* Max value for a port. */
1573     {   "http://google.com:65535", 0, S_OK, FALSE,
1574         {
1575             {"http://google.com:65535/",S_OK,FALSE},
1576             {"google.com:65535",S_OK,FALSE},
1577             {"http://google.com:65535/",S_OK,FALSE},
1578             {"google.com",S_OK,FALSE},
1579             {"",S_FALSE,FALSE},
1580             {"",S_FALSE,FALSE},
1581             {"google.com",S_OK,FALSE},
1582             {"",S_FALSE,FALSE},
1583             {"/",S_OK,FALSE},
1584             {"/",S_OK,FALSE},
1585             {"",S_FALSE,FALSE},
1586             {"http://google.com:65535",S_OK,FALSE},
1587             {"http",S_OK,FALSE},
1588             {"",S_FALSE,FALSE},
1589             {"",S_FALSE,FALSE}
1590         },
1591         {
1592             {Uri_HOST_DNS,S_OK,FALSE},
1593             {65535,S_OK,FALSE},
1594             {URL_SCHEME_HTTP,S_OK,FALSE},
1595             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1596         }
1597     },
1598     {   "zip://google.com:65536", 0, S_OK, FALSE,
1599         {
1600             {"zip://google.com:65536/",S_OK,FALSE},
1601             {"google.com:65536",S_OK,FALSE},
1602             {"zip://google.com:65536/",S_OK,FALSE},
1603             {"google.com:65536",S_OK,FALSE},
1604             {"",S_FALSE,FALSE},
1605             {"",S_FALSE,FALSE},
1606             {"google.com:65536",S_OK,FALSE},
1607             {"",S_FALSE,FALSE},
1608             {"/",S_OK,FALSE},
1609             {"/",S_OK,FALSE},
1610             {"",S_FALSE,FALSE},
1611             {"zip://google.com:65536",S_OK,FALSE},
1612             {"zip",S_OK,FALSE},
1613             {"",S_FALSE,FALSE},
1614             {"",S_FALSE,FALSE}
1615         },
1616         {
1617             {Uri_HOST_DNS,S_OK,FALSE},
1618             {0,S_FALSE,FALSE},
1619             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1620             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1621         }
1622     },
1623     {   "zip://google.com:65536:25", 0, S_OK, FALSE,
1624         {
1625             {"zip://google.com:65536:25/",S_OK,FALSE},
1626             {"google.com:65536:25",S_OK,FALSE},
1627             {"zip://google.com:65536:25/",S_OK,FALSE},
1628             {"google.com:65536:25",S_OK,FALSE},
1629             {"",S_FALSE,FALSE},
1630             {"",S_FALSE,FALSE},
1631             {"google.com:65536:25",S_OK,FALSE},
1632             {"",S_FALSE,FALSE},
1633             {"/",S_OK,FALSE},
1634             {"/",S_OK,FALSE},
1635             {"",S_FALSE,FALSE},
1636             {"zip://google.com:65536:25",S_OK,FALSE},
1637             {"zip",S_OK,FALSE},
1638             {"",S_FALSE,FALSE},
1639             {"",S_FALSE,FALSE}
1640         },
1641         {
1642             {Uri_HOST_DNS,S_OK,FALSE},
1643             {0,S_FALSE,FALSE},
1644             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1645             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1646         }
1647     },
1648     {   "zip://[::ffff]:abcd", 0, S_OK, FALSE,
1649         {
1650             {"zip://[::ffff]:abcd/",S_OK,FALSE},
1651             {"[::ffff]:abcd",S_OK,FALSE},
1652             {"zip://[::ffff]:abcd/",S_OK,FALSE},
1653             {"",S_FALSE,FALSE},
1654             {"",S_FALSE,FALSE},
1655             {"",S_FALSE,FALSE},
1656             {"[::ffff]:abcd",S_OK,FALSE},
1657             {"",S_FALSE,FALSE},
1658             {"/",S_OK,FALSE},
1659             {"/",S_OK,FALSE},
1660             {"",S_FALSE,FALSE},
1661             {"zip://[::ffff]:abcd",S_OK,FALSE},
1662             {"zip",S_OK,FALSE},
1663             {"",S_FALSE,FALSE},
1664             {"",S_FALSE,FALSE}
1665         },
1666         {
1667             {Uri_HOST_DNS,S_OK,FALSE},
1668             {0,S_FALSE,FALSE},
1669             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1670             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1671         }
1672     },
1673     {   "zip://127.0.0.1:abcd", 0, S_OK, FALSE,
1674         {
1675             {"zip://127.0.0.1:abcd/",S_OK,FALSE},
1676             {"127.0.0.1:abcd",S_OK,FALSE},
1677             {"zip://127.0.0.1:abcd/",S_OK,FALSE},
1678             {"0.1:abcd",S_OK,FALSE},
1679             {"",S_FALSE,FALSE},
1680             {"",S_FALSE,FALSE},
1681             {"127.0.0.1:abcd",S_OK,FALSE},
1682             {"",S_FALSE,FALSE},
1683             {"/",S_OK,FALSE},
1684             {"/",S_OK,FALSE},
1685             {"",S_FALSE,FALSE},
1686             {"zip://127.0.0.1:abcd",S_OK,FALSE},
1687             {"zip",S_OK,FALSE},
1688             {"",S_FALSE,FALSE},
1689             {"",S_FALSE,FALSE}
1690         },
1691         {
1692             {Uri_HOST_DNS,S_OK,FALSE},
1693             {0,S_FALSE,FALSE},
1694             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1695             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1696         }
1697     },
1698     /* Port is just copied over. */
1699     {   "http://google.com:00035", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1700         {
1701             {"http://google.com:00035",S_OK,FALSE},
1702             {"google.com:00035",S_OK,FALSE},
1703             {"http://google.com:00035",S_OK,FALSE,"http://google.com:35"},
1704             {"google.com",S_OK,FALSE},
1705             {"",S_FALSE,FALSE},
1706             {"",S_FALSE,FALSE},
1707             {"google.com",S_OK,FALSE},
1708             {"",S_FALSE,FALSE},
1709             {"",S_FALSE,FALSE},
1710             {"",S_FALSE,FALSE},
1711             {"",S_FALSE,FALSE},
1712             {"http://google.com:00035",S_OK,FALSE},
1713             {"http",S_OK,FALSE},
1714             {"",S_FALSE,FALSE},
1715             {"",S_FALSE,FALSE}
1716         },
1717         {
1718             {Uri_HOST_DNS,S_OK,FALSE},
1719             {35,S_OK,FALSE},
1720             {URL_SCHEME_HTTP,S_OK,FALSE},
1721             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1722         }
1723     },
1724     /* Default port is copied over. */
1725     {   "http://google.com:80", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1726         {
1727             {"http://google.com:80",S_OK,FALSE},
1728             {"google.com:80",S_OK,FALSE},
1729             {"http://google.com:80",S_OK,FALSE},
1730             {"google.com",S_OK,FALSE},
1731             {"",S_FALSE,FALSE},
1732             {"",S_FALSE,FALSE},
1733             {"google.com",S_OK,FALSE},
1734             {"",S_FALSE,FALSE},
1735             {"",S_FALSE,FALSE},
1736             {"",S_FALSE,FALSE},
1737             {"",S_FALSE,FALSE},
1738             {"http://google.com:80",S_OK,FALSE},
1739             {"http",S_OK,FALSE},
1740             {"",S_FALSE,FALSE},
1741             {"",S_FALSE,FALSE}
1742         },
1743         {
1744             {Uri_HOST_DNS,S_OK,FALSE},
1745             {80,S_OK,FALSE},
1746             {URL_SCHEME_HTTP,S_OK,FALSE},
1747             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1748         }
1749     },
1750     {   "http://google.com.uk", 0, S_OK, FALSE,
1751         {
1752             {"http://google.com.uk/",S_OK,FALSE},
1753             {"google.com.uk",S_OK,FALSE},
1754             {"http://google.com.uk/",S_OK,FALSE},
1755             {"google.com.uk",S_OK,FALSE},
1756             {"",S_FALSE,FALSE},
1757             {"",S_FALSE,FALSE},
1758             {"google.com.uk",S_OK,FALSE},
1759             {"",S_FALSE,FALSE},
1760             {"/",S_OK,FALSE},
1761             {"/",S_OK,FALSE},
1762             {"",S_FALSE,FALSE},
1763             {"http://google.com.uk",S_OK,FALSE},
1764             {"http",S_OK,FALSE},
1765             {"",S_FALSE,FALSE},
1766             {"",S_FALSE,FALSE}
1767         },
1768         {
1769             {Uri_HOST_DNS,S_OK,FALSE},
1770             {80,S_OK,FALSE},
1771             {URL_SCHEME_HTTP,S_OK,FALSE},
1772             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1773         }
1774     },
1775     {   "http://google.com.com", 0, S_OK, FALSE,
1776         {
1777             {"http://google.com.com/",S_OK,FALSE},
1778             {"google.com.com",S_OK,FALSE},
1779             {"http://google.com.com/",S_OK,FALSE},
1780             {"com.com",S_OK,FALSE},
1781             {"",S_FALSE,FALSE},
1782             {"",S_FALSE,FALSE},
1783             {"google.com.com",S_OK,FALSE},
1784             {"",S_FALSE,FALSE},
1785             {"/",S_OK,FALSE},
1786             {"/",S_OK,FALSE},
1787             {"",S_FALSE,FALSE},
1788             {"http://google.com.com",S_OK,FALSE},
1789             {"http",S_OK,FALSE},
1790             {"",S_FALSE,FALSE},
1791             {"",S_FALSE,FALSE}
1792         },
1793         {
1794             {Uri_HOST_DNS,S_OK,FALSE},
1795             {80,S_OK,FALSE},
1796             {URL_SCHEME_HTTP,S_OK,FALSE},
1797             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1798         }
1799     },
1800     {   "http://google.uk.1", 0, S_OK, FALSE,
1801         {
1802             {"http://google.uk.1/",S_OK,FALSE},
1803             {"google.uk.1",S_OK,FALSE},
1804             {"http://google.uk.1/",S_OK,FALSE},
1805             {"google.uk.1",S_OK,FALSE},
1806             {"",S_FALSE,FALSE},
1807             {"",S_FALSE,FALSE},
1808             {"google.uk.1",S_OK,FALSE},
1809             {"",S_FALSE,FALSE},
1810             {"/",S_OK,FALSE},
1811             {"/",S_OK,FALSE},
1812             {"",S_FALSE,FALSE},
1813             {"http://google.uk.1",S_OK,FALSE},
1814             {"http",S_OK,FALSE},
1815             {"",S_FALSE,FALSE},
1816             {"",S_FALSE,FALSE}
1817         },
1818         {
1819             {Uri_HOST_DNS,S_OK,FALSE},
1820             {80,S_OK,FALSE},
1821             {URL_SCHEME_HTTP,S_OK,FALSE},
1822             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1823         }
1824     },
1825     /* Since foo isn't a recognized 3 character TLD its considered the domain name. */
1826     {   "http://google.foo.uk", 0, S_OK, FALSE,
1827         {
1828             {"http://google.foo.uk/",S_OK,FALSE},
1829             {"google.foo.uk",S_OK,FALSE},
1830             {"http://google.foo.uk/",S_OK,FALSE},
1831             {"foo.uk",S_OK,FALSE},
1832             {"",S_FALSE,FALSE},
1833             {"",S_FALSE,FALSE},
1834             {"google.foo.uk",S_OK,FALSE},
1835             {"",S_FALSE,FALSE},
1836             {"/",S_OK,FALSE},
1837             {"/",S_OK,FALSE},
1838             {"",S_FALSE,FALSE},
1839             {"http://google.foo.uk",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://.com", 0, S_OK, FALSE,
1852         {
1853             {"http://.com/",S_OK,FALSE},
1854             {".com",S_OK,FALSE},
1855             {"http://.com/",S_OK,FALSE},
1856             {".com",S_OK,FALSE},
1857             {"",S_FALSE,FALSE},
1858             {"",S_FALSE,FALSE},
1859             {".com",S_OK,FALSE},
1860             {"",S_FALSE,FALSE},
1861             {"/",S_OK,FALSE},
1862             {"/",S_OK,FALSE},
1863             {"",S_FALSE,FALSE},
1864             {"http://.com",S_OK,FALSE},
1865             {"http",S_OK,FALSE},
1866             {"",S_FALSE,FALSE},
1867             {"",S_FALSE,FALSE}
1868         },
1869         {
1870             {Uri_HOST_DNS,S_OK,FALSE},
1871             {80,S_OK,FALSE},
1872             {URL_SCHEME_HTTP,S_OK,FALSE},
1873             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1874         }
1875     },
1876     {   "http://.uk", 0, S_OK, FALSE,
1877         {
1878             {"http://.uk/",S_OK,FALSE},
1879             {".uk",S_OK,FALSE},
1880             {"http://.uk/",S_OK,FALSE},
1881             {"",S_FALSE,FALSE},
1882             {"",S_FALSE,FALSE},
1883             {"",S_FALSE,FALSE},
1884             {".uk",S_OK,FALSE},
1885             {"",S_FALSE,FALSE},
1886             {"/",S_OK,FALSE},
1887             {"/",S_OK,FALSE},
1888             {"",S_FALSE,FALSE},
1889             {"http://.uk",S_OK,FALSE},
1890             {"http",S_OK,FALSE},
1891             {"",S_FALSE,FALSE},
1892             {"",S_FALSE,FALSE}
1893         },
1894         {
1895             {Uri_HOST_DNS,S_OK,FALSE},
1896             {80,S_OK,FALSE},
1897             {URL_SCHEME_HTTP,S_OK,FALSE},
1898             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1899         }
1900     },
1901     {   "http://www.co.google.com.[]", 0, S_OK, FALSE,
1902         {
1903             {"http://www.co.google.com.[]/",S_OK,FALSE},
1904             {"www.co.google.com.[]",S_OK,FALSE},
1905             {"http://www.co.google.com.[]/",S_OK,FALSE},
1906             {"google.com.[]",S_OK,FALSE},
1907             {"",S_FALSE,FALSE},
1908             {"",S_FALSE,FALSE},
1909             {"www.co.google.com.[]",S_OK,FALSE},
1910             {"",S_FALSE,FALSE},
1911             {"/",S_OK,FALSE},
1912             {"/",S_OK,FALSE},
1913             {"",S_FALSE,FALSE},
1914             {"http://www.co.google.com.[]",S_OK,FALSE},
1915             {"http",S_OK,FALSE},
1916             {"",S_FALSE,FALSE},
1917             {"",S_FALSE,FALSE}
1918         },
1919         {
1920             {Uri_HOST_DNS,S_OK,FALSE},
1921             {80,S_OK,FALSE},
1922             {URL_SCHEME_HTTP,S_OK,FALSE},
1923             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1924         }
1925     },
1926     {   "http://co.uk", 0, S_OK, FALSE,
1927         {
1928             {"http://co.uk/",S_OK,FALSE},
1929             {"co.uk",S_OK,FALSE},
1930             {"http://co.uk/",S_OK,FALSE},
1931             {"",S_FALSE,FALSE},
1932             {"",S_FALSE,FALSE},
1933             {"",S_FALSE,FALSE},
1934             {"co.uk",S_OK,FALSE},
1935             {"",S_FALSE,FALSE},
1936             {"/",S_OK,FALSE},
1937             {"/",S_OK,FALSE},
1938             {"",S_FALSE,FALSE},
1939             {"http://co.uk",S_OK,FALSE},
1940             {"http",S_OK,FALSE},
1941             {"",S_FALSE,FALSE},
1942             {"",S_FALSE,FALSE}
1943         },
1944         {
1945             {Uri_HOST_DNS,S_OK,FALSE},
1946             {80,S_OK,FALSE},
1947             {URL_SCHEME_HTTP,S_OK,FALSE},
1948             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1949         }
1950     },
1951     {   "http://www.co.google.us.test", 0, S_OK, FALSE,
1952         {
1953             {"http://www.co.google.us.test/",S_OK,FALSE},
1954             {"www.co.google.us.test",S_OK,FALSE},
1955             {"http://www.co.google.us.test/",S_OK,FALSE},
1956             {"us.test",S_OK,FALSE},
1957             {"",S_FALSE,FALSE},
1958             {"",S_FALSE,FALSE},
1959             {"www.co.google.us.test",S_OK,FALSE},
1960             {"",S_FALSE,FALSE},
1961             {"/",S_OK,FALSE},
1962             {"/",S_OK,FALSE},
1963             {"",S_FALSE,FALSE},
1964             {"http://www.co.google.us.test",S_OK,FALSE},
1965             {"http",S_OK,FALSE},
1966             {"",S_FALSE,FALSE},
1967             {"",S_FALSE,FALSE}
1968         },
1969         {
1970             {Uri_HOST_DNS,S_OK,FALSE},
1971             {80,S_OK,FALSE},
1972             {URL_SCHEME_HTTP,S_OK,FALSE},
1973             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1974         }
1975     },
1976     {   "http://gov.uk", 0, S_OK, FALSE,
1977         {
1978             {"http://gov.uk/",S_OK,FALSE},
1979             {"gov.uk",S_OK,FALSE},
1980             {"http://gov.uk/",S_OK,FALSE},
1981             {"",S_FALSE,FALSE},
1982             {"",S_FALSE,FALSE},
1983             {"",S_FALSE,FALSE},
1984             {"gov.uk",S_OK,FALSE},
1985             {"",S_FALSE,FALSE},
1986             {"/",S_OK,FALSE},
1987             {"/",S_OK,FALSE},
1988             {"",S_FALSE,FALSE},
1989             {"http://gov.uk",S_OK,FALSE},
1990             {"http",S_OK,FALSE},
1991             {"",S_FALSE,FALSE},
1992             {"",S_FALSE,FALSE}
1993         },
1994         {
1995             {Uri_HOST_DNS,S_OK,FALSE},
1996             {80,S_OK,FALSE},
1997             {URL_SCHEME_HTTP,S_OK,FALSE},
1998             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1999         }
2000     },
2001     {   "zip://www.google.com\\test", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2002         {
2003             {"zip://www.google.com\\test",S_OK,FALSE},
2004             {"www.google.com\\test",S_OK,FALSE},
2005             {"zip://www.google.com\\test",S_OK,FALSE},
2006             {"google.com\\test",S_OK,FALSE},
2007             {"",S_FALSE,FALSE},
2008             {"",S_FALSE,FALSE},
2009             {"www.google.com\\test",S_OK,FALSE},
2010             {"",S_FALSE,FALSE},
2011             {"",S_FALSE,FALSE},
2012             {"",S_FALSE,FALSE},
2013             {"",S_FALSE,FALSE},
2014             {"zip://www.google.com\\test",S_OK,FALSE},
2015             {"zip",S_OK,FALSE},
2016             {"",S_FALSE,FALSE},
2017             {"",S_FALSE,FALSE}
2018         },
2019         {
2020             {Uri_HOST_DNS,S_OK,FALSE},
2021             {0,S_FALSE,FALSE},
2022             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2023             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2024         }
2025     },
2026     {   "urn:excepts:bad:%XY:encoded", 0, S_OK, FALSE,
2027         {
2028             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2029             {"",S_FALSE,FALSE},
2030             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2031             {"",S_FALSE,FALSE},
2032             {"",S_FALSE,FALSE},
2033             {"",S_FALSE,FALSE},
2034             {"",S_FALSE,FALSE},
2035             {"",S_FALSE,FALSE},
2036             {"excepts:bad:%XY:encoded",S_OK,FALSE},
2037             {"excepts:bad:%XY:encoded",S_OK,FALSE},
2038             {"",S_FALSE,FALSE},
2039             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2040             {"urn",S_OK,FALSE},
2041             {"",S_FALSE,FALSE},
2042             {"",S_FALSE,FALSE}
2043         },
2044         {
2045             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2046             {0,S_FALSE,FALSE},
2047             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2048             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2049         }
2050     },
2051     /* Since the original URI doesn't contain an extra '/' before the path no % encoded values
2052      * are decoded and all '%' are encoded.
2053      */
2054     {   "file://C:/te%3Es%2Et/tes%t.mp3", 0, S_OK, FALSE,
2055         {
2056             {"file:///C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2057             {"",S_FALSE,FALSE},
2058             {"file:///C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2059             {"",S_FALSE,FALSE},
2060             {".mp3",S_OK,FALSE},
2061             {"",S_FALSE,FALSE},
2062             {"",S_FALSE,FALSE},
2063             {"",S_FALSE,FALSE},
2064             {"/C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2065             {"/C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2066             {"",S_FALSE,FALSE},
2067             {"file://C:/te%3Es%2Et/tes%t.mp3",S_OK,FALSE},
2068             {"file",S_OK,FALSE},
2069             {"",S_FALSE,FALSE},
2070             {"",S_FALSE,FALSE}
2071         },
2072         {
2073             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2074             {0,S_FALSE,FALSE},
2075             {URL_SCHEME_FILE,S_OK,FALSE},
2076             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2077         }
2078     },
2079     /* Since there's a '/' in front of the drive letter, any percent encoded, non-forbidden character
2080      * is decoded and only %'s in front of invalid hex digits are encoded.
2081      */
2082     {   "file:///C:/te%3Es%2Et/t%23es%t.mp3", 0, S_OK, FALSE,
2083         {
2084             {"file:///C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2085             {"",S_FALSE,FALSE},
2086             {"file:///C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2087             {"",S_FALSE,FALSE},
2088             {".mp3",S_OK,FALSE},
2089             {"",S_FALSE,FALSE},
2090             {"",S_FALSE,FALSE},
2091             {"",S_FALSE,FALSE},
2092             {"/C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2093             {"/C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2094             {"",S_FALSE,FALSE},
2095             {"file:///C:/te%3Es%2Et/t%23es%t.mp3",S_OK,FALSE},
2096             {"file",S_OK,FALSE},
2097             {"",S_FALSE,FALSE},
2098             {"",S_FALSE,FALSE}
2099         },
2100         {
2101             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2102             {0,S_FALSE,FALSE},
2103             {URL_SCHEME_FILE,S_OK,FALSE},
2104             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2105         }
2106     },
2107     /* Only unreserved percent encoded characters are decoded for known schemes that aren't file. */
2108     {   "http://[::001.002.003.000]/%3F%23%2E%54/test", 0, S_OK, FALSE,
2109         {
2110             {"http://[::1.2.3.0]/%3F%23.T/test",S_OK,FALSE},
2111             {"[::1.2.3.0]",S_OK,FALSE},
2112             {"http://[::1.2.3.0]/%3F%23.T/test",S_OK,FALSE},
2113             {"",S_FALSE,FALSE},
2114             {"",S_FALSE,FALSE},
2115             {"",S_FALSE,FALSE},
2116             {"::1.2.3.0",S_OK,FALSE},
2117             {"",S_FALSE,FALSE},
2118             {"/%3F%23.T/test",S_OK,FALSE},
2119             {"/%3F%23.T/test",S_OK,FALSE},
2120             {"",S_FALSE,FALSE},
2121             {"http://[::001.002.003.000]/%3F%23%2E%54/test",S_OK,FALSE},
2122             {"http",S_OK,FALSE},
2123             {"",S_FALSE,FALSE},
2124             {"",S_FALSE,FALSE},
2125         },
2126         {
2127             {Uri_HOST_IPV6,S_OK,FALSE},
2128             {80,S_OK,FALSE},
2129             {URL_SCHEME_HTTP,S_OK,FALSE},
2130             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2131         }
2132     },
2133     /* Forbidden characters are always encoded for file URIs. */
2134     {   "file:///C:/\"test\"/test.mp3", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2135         {
2136             {"file:///C:/%22test%22/test.mp3",S_OK,FALSE},
2137             {"",S_FALSE,FALSE},
2138             {"file:///C:/%22test%22/test.mp3",S_OK,FALSE},
2139             {"",S_FALSE,FALSE},
2140             {".mp3",S_OK,FALSE},
2141             {"",S_FALSE,FALSE},
2142             {"",S_FALSE,FALSE},
2143             {"",S_FALSE,FALSE},
2144             {"/C:/%22test%22/test.mp3",S_OK,FALSE},
2145             {"/C:/%22test%22/test.mp3",S_OK,FALSE},
2146             {"",S_FALSE,FALSE},
2147             {"file:///C:/\"test\"/test.mp3",S_OK,FALSE},
2148             {"file",S_OK,FALSE},
2149             {"",S_FALSE,FALSE},
2150             {"",S_FALSE,FALSE}
2151         },
2152         {
2153             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2154             {0,S_FALSE,FALSE},
2155             {URL_SCHEME_FILE,S_OK,FALSE},
2156             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2157         }
2158     },
2159     /* Forbidden characters are never encoded for unknown scheme types. */
2160     {   "1234://4294967295/<|>\" test<|>", 0, S_OK, FALSE,
2161         {
2162             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2163             {"4294967295",S_OK,FALSE},
2164             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2165             {"",S_FALSE,FALSE},
2166             {"",S_FALSE,FALSE},
2167             {"",S_FALSE,FALSE},
2168             {"4294967295",S_OK,FALSE},
2169             {"",S_FALSE,FALSE},
2170             {"/<|>\" test<|>",S_OK,FALSE},
2171             {"/<|>\" test<|>",S_OK,FALSE},
2172             {"",S_FALSE,FALSE},
2173             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2174             {"1234",S_OK,FALSE},
2175             {"",S_FALSE,FALSE},
2176             {"",S_FALSE,FALSE}
2177         },
2178         {
2179             {Uri_HOST_IPV4,S_OK,FALSE},
2180             {0,S_FALSE,FALSE},
2181             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2182             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2183         }
2184     },
2185     /* Make sure forbidden characters are percent encoded. */
2186     {   "http://gov.uk/<|> test<|>", 0, S_OK, FALSE,
2187         {
2188             {"http://gov.uk/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2189             {"gov.uk",S_OK,FALSE},
2190             {"http://gov.uk/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2191             {"",S_FALSE,FALSE},
2192             {"",S_FALSE,FALSE},
2193             {"",S_FALSE,FALSE},
2194             {"gov.uk",S_OK,FALSE},
2195             {"",S_FALSE,FALSE},
2196             {"/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2197             {"/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2198             {"",S_FALSE,FALSE},
2199             {"http://gov.uk/<|> test<|>",S_OK,FALSE},
2200             {"http",S_OK,FALSE},
2201             {"",S_FALSE,FALSE},
2202             {"",S_FALSE,FALSE}
2203         },
2204         {
2205             {Uri_HOST_DNS,S_OK,FALSE},
2206             {80,S_OK,FALSE},
2207             {URL_SCHEME_HTTP,S_OK,FALSE},
2208             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2209         }
2210     },
2211     {   "http://gov.uk/test/../test2/././../test3/.././././", 0, S_OK, FALSE,
2212         {
2213             {"http://gov.uk/",S_OK,FALSE},
2214             {"gov.uk",S_OK,FALSE},
2215             {"http://gov.uk/",S_OK,FALSE},
2216             {"",S_FALSE,FALSE},
2217             {"",S_FALSE,FALSE},
2218             {"",S_FALSE,FALSE},
2219             {"gov.uk",S_OK,FALSE},
2220             {"",S_FALSE,FALSE},
2221             {"/",S_OK,FALSE},
2222             {"/",S_OK,FALSE},
2223             {"",S_FALSE,FALSE},
2224             {"http://gov.uk/test/../test2/././../test3/.././././",S_OK,FALSE},
2225             {"http",S_OK,FALSE},
2226             {"",S_FALSE,FALSE},
2227             {"",S_FALSE,FALSE}
2228         },
2229         {
2230             {Uri_HOST_DNS,S_OK,FALSE},
2231             {80,S_OK,FALSE},
2232             {URL_SCHEME_HTTP,S_OK,FALSE},
2233             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2234         }
2235     },
2236     {   "http://gov.uk/test/test2/../../..", 0, S_OK, FALSE,
2237         {
2238             {"http://gov.uk/",S_OK,FALSE},
2239             {"gov.uk",S_OK,FALSE},
2240             {"http://gov.uk/",S_OK,FALSE},
2241             {"",S_FALSE,FALSE},
2242             {"",S_FALSE,FALSE},
2243             {"",S_FALSE,FALSE},
2244             {"gov.uk",S_OK,FALSE},
2245             {"",S_FALSE,FALSE},
2246             {"/",S_OK,FALSE},
2247             {"/",S_OK,FALSE},
2248             {"",S_FALSE,FALSE},
2249             {"http://gov.uk/test/test2/../../..",S_OK,FALSE},
2250             {"http",S_OK,FALSE},
2251             {"",S_FALSE,FALSE},
2252             {"",S_FALSE,FALSE}
2253         },
2254         {
2255             {Uri_HOST_DNS,S_OK,FALSE},
2256             {80,S_OK,FALSE},
2257             {URL_SCHEME_HTTP,S_OK,FALSE},
2258             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2259         }
2260     },
2261     {   "http://gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2262         {
2263             {"http://gov.uk/",S_OK,FALSE},
2264             {"gov.uk",S_OK,FALSE},
2265             {"http://gov.uk/",S_OK,FALSE},
2266             {"",S_FALSE,FALSE},
2267             {"",S_FALSE,FALSE},
2268             {"",S_FALSE,FALSE},
2269             {"gov.uk",S_OK,FALSE},
2270             {"",S_FALSE,FALSE},
2271             {"/",S_OK,FALSE},
2272             {"/",S_OK,FALSE},
2273             {"",S_FALSE,FALSE},
2274             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2275             {"http",S_OK,FALSE},
2276             {"",S_FALSE,FALSE},
2277             {"",S_FALSE,FALSE}
2278         },
2279         {
2280             {Uri_HOST_DNS,S_OK,FALSE},
2281             {80,S_OK,FALSE},
2282             {URL_SCHEME_HTTP,S_OK,FALSE},
2283             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2284         }
2285     },
2286     {   "file://c:\\tests\\../tests\\./.\\..\\foo%20bar.mp3", 0, S_OK, FALSE,
2287         {
2288             {"file:///c:/foo%2520bar.mp3",S_OK,FALSE},
2289             {"",S_FALSE,FALSE},
2290             {"file:///c:/foo%2520bar.mp3",S_OK,FALSE},
2291             {"",S_FALSE,FALSE},
2292             {".mp3",S_OK,FALSE},
2293             {"",S_FALSE,FALSE},
2294             {"",S_FALSE,FALSE},
2295             {"",S_FALSE,FALSE},
2296             {"/c:/foo%2520bar.mp3",S_OK,FALSE},
2297             {"/c:/foo%2520bar.mp3",S_OK,FALSE},
2298             {"",S_FALSE,FALSE},
2299             {"file://c:\\tests\\../tests\\./.\\..\\foo%20bar.mp3",S_OK,FALSE},
2300             {"file",S_OK,FALSE},
2301             {"",S_FALSE,FALSE},
2302             {"",S_FALSE,FALSE}
2303         },
2304         {
2305             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2306             {0,S_FALSE,FALSE},
2307             {URL_SCHEME_FILE,S_OK,FALSE},
2308             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2309         }
2310     },
2311     /* Dot removal happens for unknown scheme types. */
2312     {   "zip://gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2313         {
2314             {"zip://gov.uk/",S_OK,FALSE},
2315             {"gov.uk",S_OK,FALSE},
2316             {"zip://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             {"zip://gov.uk/test/test2/../../.",S_OK,FALSE},
2326             {"zip",S_OK,FALSE},
2327             {"",S_FALSE,FALSE},
2328             {"",S_FALSE,FALSE}
2329         },
2330         {
2331             {Uri_HOST_DNS,S_OK,FALSE},
2332             {0,S_FALSE,FALSE},
2333             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2334             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2335         }
2336     },
2337     /* Dot removal doesn't happen if NO_CANONICALIZE is set. */
2338     {   "http://gov.uk/test/test2/../../.", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2339         {
2340             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2341             {"gov.uk",S_OK,FALSE},
2342             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2343             {"",S_FALSE,FALSE},
2344             {".",S_OK,FALSE},
2345             {"",S_FALSE,FALSE},
2346             {"gov.uk",S_OK,FALSE},
2347             {"",S_FALSE,FALSE},
2348             {"/test/test2/../../.",S_OK,FALSE},
2349             {"/test/test2/../../.",S_OK,FALSE},
2350             {"",S_FALSE,FALSE},
2351             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2352             {"http",S_OK,FALSE},
2353             {"",S_FALSE,FALSE},
2354             {"",S_FALSE,FALSE}
2355         },
2356         {
2357             {Uri_HOST_DNS,S_OK,FALSE},
2358             {80,S_OK,FALSE},
2359             {URL_SCHEME_HTTP,S_OK,FALSE},
2360             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2361         }
2362     },
2363     /* Dot removal doesn't happen for wildcard scheme types. */
2364     {   "*:gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2365         {
2366             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2367             {"gov.uk",S_OK,FALSE},
2368             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2369             {"",S_FALSE,FALSE},
2370             {".",S_OK,FALSE},
2371             {"",S_FALSE,FALSE},
2372             {"gov.uk",S_OK,FALSE},
2373             {"",S_FALSE,FALSE},
2374             {"/test/test2/../../.",S_OK,FALSE},
2375             {"/test/test2/../../.",S_OK,FALSE},
2376             {"",S_FALSE,FALSE},
2377             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2378             {"*",S_OK,FALSE},
2379             {"",S_FALSE,FALSE},
2380             {"",S_FALSE,FALSE}
2381         },
2382         {
2383             {Uri_HOST_DNS,S_OK,FALSE},
2384             {0,S_FALSE,FALSE},
2385             {URL_SCHEME_WILDCARD,S_OK,FALSE},
2386             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2387         }
2388     },
2389     /* Forbidden characters are encoded for opaque known scheme types. */
2390     {   "mailto:\"acco<|>unt@example.com\"", 0, S_OK, FALSE,
2391         {
2392             {"mailto:%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2393             {"",S_FALSE,FALSE},
2394             {"mailto:%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2395             {"",S_FALSE,FALSE},
2396             {".com%22",S_OK,FALSE},
2397             {"",S_FALSE,FALSE},
2398             {"",S_FALSE,FALSE},
2399             {"",S_FALSE,FALSE},
2400             {"%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2401             {"%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2402             {"",S_FALSE,FALSE},
2403             {"mailto:\"acco<|>unt@example.com\"",S_OK,FALSE},
2404             {"mailto",S_OK,FALSE},
2405             {"",S_FALSE,FALSE},
2406             {"",S_FALSE,FALSE}
2407         },
2408         {
2409             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2410             {0,S_FALSE,FALSE},
2411             {URL_SCHEME_MAILTO,S_OK,FALSE},
2412             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2413         }
2414     },
2415     {   "news:test.tes<|>t.com", 0, S_OK, FALSE,
2416         {
2417             {"news:test.tes%3C%7C%3Et.com",S_OK,FALSE},
2418             {"",S_FALSE,FALSE},
2419             {"news:test.tes%3C%7C%3Et.com",S_OK,FALSE},
2420             {"",S_FALSE,FALSE},
2421             {".com",S_OK,FALSE},
2422             {"",S_FALSE,FALSE},
2423             {"",S_FALSE,FALSE},
2424             {"",S_FALSE,FALSE},
2425             {"test.tes%3C%7C%3Et.com",S_OK,FALSE},
2426             {"test.tes%3C%7C%3Et.com",S_OK,FALSE},
2427             {"",S_FALSE,FALSE},
2428             {"news:test.tes<|>t.com",S_OK,FALSE},
2429             {"news",S_OK,FALSE},
2430             {"",S_FALSE,FALSE},
2431             {"",S_FALSE,FALSE}
2432         },
2433         {
2434             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2435             {0,S_FALSE,FALSE},
2436             {URL_SCHEME_NEWS,S_OK,FALSE},
2437             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2438         }
2439     },
2440     /* Don't encode forbidden characters. */
2441     {   "news:test.tes<|>t.com", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2442         {
2443             {"news:test.tes<|>t.com",S_OK,FALSE},
2444             {"",S_FALSE,FALSE},
2445             {"news:test.tes<|>t.com",S_OK,FALSE},
2446             {"",S_FALSE,FALSE},
2447             {".com",S_OK,FALSE},
2448             {"",S_FALSE,FALSE},
2449             {"",S_FALSE,FALSE},
2450             {"",S_FALSE,FALSE},
2451             {"test.tes<|>t.com",S_OK,FALSE},
2452             {"test.tes<|>t.com",S_OK,FALSE},
2453             {"",S_FALSE,FALSE},
2454             {"news:test.tes<|>t.com",S_OK,FALSE},
2455             {"news",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_NEWS,S_OK,FALSE},
2463             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2464         }
2465     },
2466     /* Forbidden characters aren't encoded for unknown, opaque URIs. */
2467     {   "urn:test.tes<|>t.com", 0, S_OK, FALSE,
2468         {
2469             {"urn:test.tes<|>t.com",S_OK,FALSE},
2470             {"",S_FALSE,FALSE},
2471             {"urn:test.tes<|>t.com",S_OK,FALSE},
2472             {"",S_FALSE,FALSE},
2473             {".com",S_OK,FALSE},
2474             {"",S_FALSE,FALSE},
2475             {"",S_FALSE,FALSE},
2476             {"",S_FALSE,FALSE},
2477             {"test.tes<|>t.com",S_OK,FALSE},
2478             {"test.tes<|>t.com",S_OK,FALSE},
2479             {"",S_FALSE,FALSE},
2480             {"urn:test.tes<|>t.com",S_OK,FALSE},
2481             {"urn",S_OK,FALSE},
2482             {"",S_FALSE,FALSE},
2483             {"",S_FALSE,FALSE}
2484         },
2485         {
2486             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2487             {0,S_FALSE,FALSE},
2488             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2489             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2490         }
2491     },
2492     /* Percent encoded unreserved characters are decoded for known opaque URIs. */
2493     {   "news:test.%74%65%73%74.com", 0, S_OK, FALSE,
2494         {
2495             {"news:test.test.com",S_OK,FALSE},
2496             {"",S_FALSE,FALSE},
2497             {"news:test.test.com",S_OK,FALSE},
2498             {"",S_FALSE,FALSE},
2499             {".com",S_OK,FALSE},
2500             {"",S_FALSE,FALSE},
2501             {"",S_FALSE,FALSE},
2502             {"",S_FALSE,FALSE},
2503             {"test.test.com",S_OK,FALSE},
2504             {"test.test.com",S_OK,FALSE},
2505             {"",S_FALSE,FALSE},
2506             {"news:test.%74%65%73%74.com",S_OK,FALSE},
2507             {"news",S_OK,FALSE},
2508             {"",S_FALSE,FALSE},
2509             {"",S_FALSE,FALSE}
2510         },
2511         {
2512             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2513             {0,S_FALSE,FALSE},
2514             {URL_SCHEME_NEWS,S_OK,FALSE},
2515             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2516         }
2517     },
2518     /* Percent encoded characters are still decoded for known scheme types. */
2519     {   "news:test.%74%65%73%74.com", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2520         {
2521             {"news:test.test.com",S_OK,FALSE},
2522             {"",S_FALSE,FALSE},
2523             {"news:test.test.com",S_OK,FALSE},
2524             {"",S_FALSE,FALSE},
2525             {".com",S_OK,FALSE},
2526             {"",S_FALSE,FALSE},
2527             {"",S_FALSE,FALSE},
2528             {"",S_FALSE,FALSE},
2529             {"test.test.com",S_OK,FALSE},
2530             {"test.test.com",S_OK,FALSE},
2531             {"",S_FALSE,FALSE},
2532             {"news:test.%74%65%73%74.com",S_OK,FALSE},
2533             {"news",S_OK,FALSE},
2534             {"",S_FALSE,FALSE},
2535             {"",S_FALSE,FALSE}
2536         },
2537         {
2538             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2539             {0,S_FALSE,FALSE},
2540             {URL_SCHEME_NEWS,S_OK,FALSE},
2541             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2542         }
2543     },
2544     /* Percent encoded characters aren't decoded for unknown scheme types. */
2545     {   "urn:test.%74%65%73%74.com", 0, S_OK, FALSE,
2546         {
2547             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2548             {"",S_FALSE,FALSE},
2549             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2550             {"",S_FALSE,FALSE},
2551             {".com",S_OK,FALSE},
2552             {"",S_FALSE,FALSE},
2553             {"",S_FALSE,FALSE},
2554             {"",S_FALSE,FALSE},
2555             {"test.%74%65%73%74.com",S_OK,FALSE},
2556             {"test.%74%65%73%74.com",S_OK,FALSE},
2557             {"",S_FALSE,FALSE},
2558             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2559             {"urn",S_OK,FALSE},
2560             {"",S_FALSE,FALSE},
2561             {"",S_FALSE,FALSE}
2562         },
2563         {
2564             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2565             {0,S_FALSE,FALSE},
2566             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2567             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2568         }
2569     },
2570     /* Unknown scheme types can have invalid % encoded data in query string. */
2571     {   "zip://www.winehq.org/tests/..?query=%xx&return=y", 0, S_OK, FALSE,
2572         {
2573             {"zip://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2574             {"www.winehq.org",S_OK,FALSE},
2575             {"zip://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2576             {"winehq.org",S_OK,FALSE},
2577             {"",S_FALSE,FALSE},
2578             {"",S_FALSE,FALSE},
2579             {"www.winehq.org",S_OK,FALSE},
2580             {"",S_FALSE,FALSE},
2581             {"/",S_OK,FALSE},
2582             {"/?query=%xx&return=y",S_OK,FALSE},
2583             {"?query=%xx&return=y",S_OK,FALSE},
2584             {"zip://www.winehq.org/tests/..?query=%xx&return=y",S_OK,FALSE},
2585             {"zip",S_OK,FALSE},
2586             {"",S_FALSE,FALSE},
2587             {"",S_FALSE,FALSE}
2588         },
2589         {
2590             {Uri_HOST_DNS,S_OK,FALSE},
2591             {0,S_FALSE,FALSE},
2592             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2593             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2594         }
2595     },
2596     /* Known scheme types can have invalid % encoded data with the right flags. */
2597     {   "http://www.winehq.org/tests/..?query=%xx&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2598         {
2599             {"http://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2600             {"www.winehq.org",S_OK,FALSE},
2601             {"http://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2602             {"winehq.org",S_OK,FALSE},
2603             {"",S_FALSE,FALSE},
2604             {"",S_FALSE,FALSE},
2605             {"www.winehq.org",S_OK,FALSE},
2606             {"",S_FALSE,FALSE},
2607             {"/",S_OK,FALSE},
2608             {"/?query=%xx&return=y",S_OK,FALSE},
2609             {"?query=%xx&return=y",S_OK,FALSE},
2610             {"http://www.winehq.org/tests/..?query=%xx&return=y",S_OK,FALSE},
2611             {"http",S_OK,FALSE},
2612             {"",S_FALSE,FALSE},
2613             {"",S_FALSE,FALSE}
2614         },
2615         {
2616             {Uri_HOST_DNS,S_OK,FALSE},
2617             {80,S_OK,FALSE},
2618             {URL_SCHEME_HTTP,S_OK,FALSE},
2619             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2620         }
2621     },
2622     /* Forbidden characters in query aren't percent encoded for known scheme types with this flag. */
2623     {   "http://www.winehq.org/tests/..?query=<|>&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2624         {
2625             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2626             {"www.winehq.org",S_OK,FALSE},
2627             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2628             {"winehq.org",S_OK,FALSE},
2629             {"",S_FALSE,FALSE},
2630             {"",S_FALSE,FALSE},
2631             {"www.winehq.org",S_OK,FALSE},
2632             {"",S_FALSE,FALSE},
2633             {"/",S_OK,FALSE},
2634             {"/?query=<|>&return=y",S_OK,FALSE},
2635             {"?query=<|>&return=y",S_OK,FALSE},
2636             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2637             {"http",S_OK,FALSE},
2638             {"",S_FALSE,FALSE},
2639             {"",S_FALSE,FALSE}
2640         },
2641         {
2642             {Uri_HOST_DNS,S_OK,FALSE},
2643             {80,S_OK,FALSE},
2644             {URL_SCHEME_HTTP,S_OK,FALSE},
2645             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2646         }
2647     },
2648     /* Forbidden characters in query aren't percent encoded for known scheme types with this flag. */
2649     {   "http://www.winehq.org/tests/..?query=<|>&return=y", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2650         {
2651             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2652             {"www.winehq.org",S_OK,FALSE},
2653             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2654             {"winehq.org",S_OK,FALSE},
2655             {"",S_FALSE,FALSE},
2656             {"",S_FALSE,FALSE},
2657             {"www.winehq.org",S_OK,FALSE},
2658             {"",S_FALSE,FALSE},
2659             {"/",S_OK,FALSE},
2660             {"/?query=<|>&return=y",S_OK,FALSE},
2661             {"?query=<|>&return=y",S_OK,FALSE},
2662             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2663             {"http",S_OK,FALSE},
2664             {"",S_FALSE,FALSE},
2665             {"",S_FALSE,FALSE}
2666         },
2667         {
2668             {Uri_HOST_DNS,S_OK,FALSE},
2669             {80,S_OK,FALSE},
2670             {URL_SCHEME_HTTP,S_OK,FALSE},
2671             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2672         }
2673     },
2674     /* Forbidden characters are encoded for known scheme types. */
2675     {   "http://www.winehq.org/tests/..?query=<|>&return=y", 0, S_OK, FALSE,
2676         {
2677             {"http://www.winehq.org/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2678             {"www.winehq.org",S_OK,FALSE},
2679             {"http://www.winehq.org/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2680             {"winehq.org",S_OK,FALSE},
2681             {"",S_FALSE,FALSE},
2682             {"",S_FALSE,FALSE},
2683             {"www.winehq.org",S_OK,FALSE},
2684             {"",S_FALSE,FALSE},
2685             {"/",S_OK,FALSE},
2686             {"/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2687             {"?query=%3C%7C%3E&return=y",S_OK,FALSE},
2688             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2689             {"http",S_OK,FALSE},
2690             {"",S_FALSE,FALSE},
2691             {"",S_FALSE,FALSE}
2692         },
2693         {
2694             {Uri_HOST_DNS,S_OK,FALSE},
2695             {80,S_OK,FALSE},
2696             {URL_SCHEME_HTTP,S_OK,FALSE},
2697             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2698         }
2699     },
2700     /* Forbidden characters are not encoded for unknown scheme types. */
2701     {   "zip://www.winehq.org/tests/..?query=<|>&return=y", 0, S_OK, FALSE,
2702         {
2703             {"zip://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2704             {"www.winehq.org",S_OK,FALSE},
2705             {"zip://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2706             {"winehq.org",S_OK,FALSE},
2707             {"",S_FALSE,FALSE},
2708             {"",S_FALSE,FALSE},
2709             {"www.winehq.org",S_OK,FALSE},
2710             {"",S_FALSE,FALSE},
2711             {"/",S_OK,FALSE},
2712             {"/?query=<|>&return=y",S_OK,FALSE},
2713             {"?query=<|>&return=y",S_OK,FALSE},
2714             {"zip://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2715             {"zip",S_OK,FALSE},
2716             {"",S_FALSE,FALSE},
2717             {"",S_FALSE,FALSE}
2718         },
2719         {
2720             {Uri_HOST_DNS,S_OK,FALSE},
2721             {0,S_FALSE,FALSE},
2722             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2723             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2724         }
2725     },
2726     /* Percent encoded, unreserved characters are decoded for known scheme types. */
2727     {   "http://www.winehq.org/tests/..?query=%30%31&return=y", 0, S_OK, FALSE,
2728         {
2729             {"http://www.winehq.org/?query=01&return=y",S_OK,FALSE},
2730             {"www.winehq.org",S_OK,FALSE},
2731             {"http://www.winehq.org/?query=01&return=y",S_OK,FALSE},
2732             {"winehq.org",S_OK,FALSE},
2733             {"",S_FALSE,FALSE},
2734             {"",S_FALSE,FALSE},
2735             {"www.winehq.org",S_OK,FALSE},
2736             {"",S_FALSE,FALSE},
2737             {"/",S_OK,FALSE},
2738             {"/?query=01&return=y",S_OK,FALSE},
2739             {"?query=01&return=y",S_OK,FALSE},
2740             {"http://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2741             {"http",S_OK,FALSE},
2742             {"",S_FALSE,FALSE},
2743             {"",S_FALSE,FALSE}
2744         },
2745         {
2746             {Uri_HOST_DNS,S_OK,FALSE},
2747             {80,S_OK,FALSE},
2748             {URL_SCHEME_HTTP,S_OK,FALSE},
2749             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2750         }
2751     },
2752     /* Percent encoded, unreserved characters aren't decoded for unknown scheme types. */
2753     {   "zip://www.winehq.org/tests/..?query=%30%31&return=y", 0, S_OK, FALSE,
2754         {
2755             {"zip://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2756             {"www.winehq.org",S_OK,FALSE},
2757             {"zip://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2758             {"winehq.org",S_OK,FALSE},
2759             {"",S_FALSE,FALSE},
2760             {"",S_FALSE,FALSE},
2761             {"www.winehq.org",S_OK,FALSE},
2762             {"",S_FALSE,FALSE},
2763             {"/",S_OK,FALSE},
2764             {"/?query=%30%31&return=y",S_OK,FALSE},
2765             {"?query=%30%31&return=y",S_OK,FALSE},
2766             {"zip://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2767             {"zip",S_OK,FALSE},
2768             {"",S_FALSE,FALSE},
2769             {"",S_FALSE,FALSE}
2770         },
2771         {
2772             {Uri_HOST_DNS,S_OK,FALSE},
2773             {0,S_FALSE,FALSE},
2774             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2775             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2776         }
2777     },
2778     /* Percent encoded characters aren't decoded when NO_DECODE_EXTRA_INFO is set. */
2779     {   "http://www.winehq.org/tests/..?query=%30%31&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2780         {
2781             {"http://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2782             {"www.winehq.org",S_OK,FALSE},
2783             {"http://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2784             {"winehq.org",S_OK,FALSE},
2785             {"",S_FALSE,FALSE},
2786             {"",S_FALSE,FALSE},
2787             {"www.winehq.org",S_OK,FALSE},
2788             {"",S_FALSE,FALSE},
2789             {"/",S_OK,FALSE},
2790             {"/?query=%30%31&return=y",S_OK,FALSE},
2791             {"?query=%30%31&return=y",S_OK,FALSE},
2792             {"http://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2793             {"http",S_OK,FALSE},
2794             {"",S_FALSE,FALSE},
2795             {"",S_FALSE,FALSE}
2796         },
2797         {
2798             {Uri_HOST_DNS,S_OK,FALSE},
2799             {80,S_OK,FALSE},
2800             {URL_SCHEME_HTTP,S_OK,FALSE},
2801             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2802         }
2803     },
2804     {   "http://www.winehq.org?query=12&return=y", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2805         {
2806             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2807             {"www.winehq.org",S_OK,FALSE},
2808             {"http://www.winehq.org?query=12&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_FALSE,FALSE},
2815             {"?query=12&return=y",S_OK,FALSE},
2816             {"?query=12&return=y",S_OK,FALSE},
2817             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2818             {"http",S_OK,FALSE},
2819             {"",S_FALSE,FALSE},
2820             {"",S_FALSE,FALSE}
2821         },
2822         {
2823             {Uri_HOST_DNS,S_OK,FALSE},
2824             {80,S_OK,FALSE},
2825             {URL_SCHEME_HTTP,S_OK,FALSE},
2826             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2827         }
2828     },
2829     /* Unknown scheme types can have invalid % encoded data in fragments. */
2830     {   "zip://www.winehq.org/tests/#Te%xx", 0, S_OK, FALSE,
2831         {
2832             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2833             {"www.winehq.org",S_OK,FALSE},
2834             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2835             {"winehq.org",S_OK,FALSE},
2836             {"",S_FALSE,FALSE},
2837             {"#Te%xx",S_OK,FALSE},
2838             {"www.winehq.org",S_OK,FALSE},
2839             {"",S_FALSE,FALSE},
2840             {"/tests/",S_OK,FALSE},
2841             {"/tests/",S_OK,FALSE},
2842             {"",S_FALSE,FALSE},
2843             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2844             {"zip",S_OK,FALSE},
2845             {"",S_FALSE,FALSE},
2846             {"",S_FALSE,FALSE}
2847         },
2848         {
2849             {Uri_HOST_DNS,S_OK,FALSE},
2850             {0,S_FALSE,FALSE},
2851             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2852             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2853         }
2854     },
2855     /* Forbidden characters in fragment aren't encoded for unknown schemes. */
2856     {   "zip://www.winehq.org/tests/#Te<|>", 0, S_OK, FALSE,
2857         {
2858             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2859             {"www.winehq.org",S_OK,FALSE},
2860             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2861             {"winehq.org",S_OK,FALSE},
2862             {"",S_FALSE,FALSE},
2863             {"#Te<|>",S_OK,FALSE},
2864             {"www.winehq.org",S_OK,FALSE},
2865             {"",S_FALSE,FALSE},
2866             {"/tests/",S_OK,FALSE},
2867             {"/tests/",S_OK,FALSE},
2868             {"",S_FALSE,FALSE},
2869             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2870             {"zip",S_OK,FALSE},
2871             {"",S_FALSE,FALSE},
2872             {"",S_FALSE,FALSE}
2873         },
2874         {
2875             {Uri_HOST_DNS,S_OK,FALSE},
2876             {0,S_FALSE,FALSE},
2877             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2878             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2879         }
2880     },
2881     /* Forbidden characters in the fragment are percent encoded for known schemes. */
2882     {   "http://www.winehq.org/tests/#Te<|>", 0, S_OK, FALSE,
2883         {
2884             {"http://www.winehq.org/tests/#Te%3C%7C%3E",S_OK,FALSE},
2885             {"www.winehq.org",S_OK,FALSE},
2886             {"http://www.winehq.org/tests/#Te%3C%7C%3E",S_OK,FALSE},
2887             {"winehq.org",S_OK,FALSE},
2888             {"",S_FALSE,FALSE},
2889             {"#Te%3C%7C%3E",S_OK,FALSE},
2890             {"www.winehq.org",S_OK,FALSE},
2891             {"",S_FALSE,FALSE},
2892             {"/tests/",S_OK,FALSE},
2893             {"/tests/",S_OK,FALSE},
2894             {"",S_FALSE,FALSE},
2895             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2896             {"http",S_OK,FALSE},
2897             {"",S_FALSE,FALSE},
2898             {"",S_FALSE,FALSE}
2899         },
2900         {
2901             {Uri_HOST_DNS,S_OK,FALSE},
2902             {80,S_OK,FALSE},
2903             {URL_SCHEME_HTTP,S_OK,FALSE},
2904             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2905         }
2906     },
2907     /* Forbidden characters aren't encoded in the fragment with this flag. */
2908     {   "http://www.winehq.org/tests/#Te<|>", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2909         {
2910             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2911             {"www.winehq.org",S_OK,FALSE},
2912             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2913             {"winehq.org",S_OK,FALSE},
2914             {"",S_FALSE,FALSE},
2915             {"#Te<|>",S_OK,FALSE},
2916             {"www.winehq.org",S_OK,FALSE},
2917             {"",S_FALSE,FALSE},
2918             {"/tests/",S_OK,FALSE},
2919             {"/tests/",S_OK,FALSE},
2920             {"",S_FALSE,FALSE},
2921             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2922             {"http",S_OK,FALSE},
2923             {"",S_FALSE,FALSE},
2924             {"",S_FALSE,FALSE}
2925         },
2926         {
2927             {Uri_HOST_DNS,S_OK,FALSE},
2928             {80,S_OK,FALSE},
2929             {URL_SCHEME_HTTP,S_OK,FALSE},
2930             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2931         }
2932     },
2933     /* Forbidden characters aren't encoded in the fragment with this flag. */
2934     {   "http://www.winehq.org/tests/#Te<|>", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2935         {
2936             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2937             {"www.winehq.org",S_OK,FALSE},
2938             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2939             {"winehq.org",S_OK,FALSE},
2940             {"",S_FALSE,FALSE},
2941             {"#Te<|>",S_OK,FALSE},
2942             {"www.winehq.org",S_OK,FALSE},
2943             {"",S_FALSE,FALSE},
2944             {"/tests/",S_OK,FALSE},
2945             {"/tests/",S_OK,FALSE},
2946             {"",S_FALSE,FALSE},
2947             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2948             {"http",S_OK,FALSE},
2949             {"",S_FALSE,FALSE},
2950             {"",S_FALSE,FALSE}
2951         },
2952         {
2953             {Uri_HOST_DNS,S_OK,FALSE},
2954             {80,S_OK,FALSE},
2955             {URL_SCHEME_HTTP,S_OK,FALSE},
2956             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2957         }
2958     },
2959     /* Percent encoded, unreserved characters aren't decoded for known scheme types. */
2960     {   "zip://www.winehq.org/tests/#Te%30%31%32", 0, S_OK, FALSE,
2961         {
2962             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2963             {"www.winehq.org",S_OK,FALSE},
2964             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2965             {"winehq.org",S_OK,FALSE},
2966             {"",S_FALSE,FALSE},
2967             {"#Te%30%31%32",S_OK,FALSE},
2968             {"www.winehq.org",S_OK,FALSE},
2969             {"",S_FALSE,FALSE},
2970             {"/tests/",S_OK,FALSE},
2971             {"/tests/",S_OK,FALSE},
2972             {"",S_FALSE,FALSE},
2973             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2974             {"zip",S_OK,FALSE},
2975             {"",S_FALSE,FALSE},
2976             {"",S_FALSE,FALSE}
2977         },
2978         {
2979             {Uri_HOST_DNS,S_OK,FALSE},
2980             {0,S_FALSE,FALSE},
2981             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2982             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2983         }
2984     },
2985     /* Percent encoded, unreserved characters are decoded for known schemes. */
2986     {   "http://www.winehq.org/tests/#Te%30%31%32", 0, S_OK, FALSE,
2987         {
2988             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
2989             {"www.winehq.org",S_OK,FALSE},
2990             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
2991             {"winehq.org",S_OK,FALSE},
2992             {"",S_FALSE,FALSE},
2993             {"#Te012",S_OK,FALSE},
2994             {"www.winehq.org",S_OK,FALSE},
2995             {"",S_FALSE,FALSE},
2996             {"/tests/",S_OK,FALSE},
2997             {"/tests/",S_OK,FALSE},
2998             {"",S_FALSE,FALSE},
2999             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3000             {"http",S_OK,FALSE},
3001             {"",S_FALSE,FALSE},
3002             {"",S_FALSE,FALSE}
3003         },
3004         {
3005             {Uri_HOST_DNS,S_OK,FALSE},
3006             {80,S_OK,FALSE},
3007             {URL_SCHEME_HTTP,S_OK,FALSE},
3008             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3009         }
3010     },
3011     /* Percent encoded, unreserved characters are decoded even if NO_CANONICALIZE is set. */
3012     {   "http://www.winehq.org/tests/#Te%30%31%32", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
3013         {
3014             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
3015             {"www.winehq.org",S_OK,FALSE},
3016             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
3017             {"winehq.org",S_OK,FALSE},
3018             {"",S_FALSE,FALSE},
3019             {"#Te012",S_OK,FALSE},
3020             {"www.winehq.org",S_OK,FALSE},
3021             {"",S_FALSE,FALSE},
3022             {"/tests/",S_OK,FALSE},
3023             {"/tests/",S_OK,FALSE},
3024             {"",S_FALSE,FALSE},
3025             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3026             {"http",S_OK,FALSE},
3027             {"",S_FALSE,FALSE},
3028             {"",S_FALSE,FALSE}
3029         },
3030         {
3031             {Uri_HOST_DNS,S_OK,FALSE},
3032             {80,S_OK,FALSE},
3033             {URL_SCHEME_HTTP,S_OK,FALSE},
3034             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3035         }
3036     },
3037     /* Percent encoded, unreserved characters aren't decoded when NO_DECODE_EXTRA is set. */
3038     {   "http://www.winehq.org/tests/#Te%30%31%32", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
3039         {
3040             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3041             {"www.winehq.org",S_OK,FALSE},
3042             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3043             {"winehq.org",S_OK,FALSE},
3044             {"",S_FALSE,FALSE},
3045             {"#Te%30%31%32",S_OK,FALSE},
3046             {"www.winehq.org",S_OK,FALSE},
3047             {"",S_FALSE,FALSE},
3048             {"/tests/",S_OK,FALSE},
3049             {"/tests/",S_OK,FALSE},
3050             {"",S_FALSE,FALSE},
3051             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3052             {"http",S_OK,FALSE},
3053             {"",S_FALSE,FALSE},
3054             {"",S_FALSE,FALSE}
3055         },
3056         {
3057             {Uri_HOST_DNS,S_OK,FALSE},
3058             {80,S_OK,FALSE},
3059             {URL_SCHEME_HTTP,S_OK,FALSE},
3060             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3061         }
3062     },
3063     /* Leading/Trailing whitespace is removed. */
3064     {   "    http://google.com/     ", 0, S_OK, FALSE,
3065         {
3066             {"http://google.com/",S_OK,FALSE},
3067             {"google.com",S_OK,FALSE},
3068             {"http://google.com/",S_OK,FALSE},
3069             {"google.com",S_OK,FALSE},
3070             {"",S_FALSE,FALSE},
3071             {"",S_FALSE,FALSE},
3072             {"google.com",S_OK,FALSE},
3073             {"",S_FALSE,FALSE},
3074             {"/",S_OK,FALSE},
3075             {"/",S_OK,FALSE},
3076             {"",S_FALSE,FALSE},
3077             {"http://google.com/",S_OK,FALSE},
3078             {"http",S_OK,FALSE},
3079             {"",S_FALSE,FALSE},
3080             {"",S_FALSE,FALSE}
3081         },
3082         {
3083             {Uri_HOST_DNS,S_OK,FALSE},
3084             {80,S_OK,FALSE},
3085             {URL_SCHEME_HTTP,S_OK,FALSE},
3086             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3087         }
3088     },
3089     {   "\t\t\r\nhttp\n://g\noogle.co\rm/\n\n\n", 0, S_OK, FALSE,
3090         {
3091             {"http://google.com/",S_OK,FALSE},
3092             {"google.com",S_OK,FALSE},
3093             {"http://google.com/",S_OK,FALSE},
3094             {"google.com",S_OK,FALSE},
3095             {"",S_FALSE,FALSE},
3096             {"",S_FALSE,FALSE},
3097             {"google.com",S_OK,FALSE},
3098             {"",S_FALSE,FALSE},
3099             {"/",S_OK,FALSE},
3100             {"/",S_OK,FALSE},
3101             {"",S_FALSE,FALSE},
3102             {"http://google.com/",S_OK,FALSE},
3103             {"http",S_OK,FALSE},
3104             {"",S_FALSE,FALSE},
3105             {"",S_FALSE,FALSE}
3106         },
3107         {
3108             {Uri_HOST_DNS,S_OK,FALSE},
3109             {80,S_OK,FALSE},
3110             {URL_SCHEME_HTTP,S_OK,FALSE},
3111             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3112         }
3113     },
3114     {   "http://g\noogle.co\rm/\n\n\n", Uri_CREATE_NO_PRE_PROCESS_HTML_URI, S_OK, FALSE,
3115         {
3116             {"http://g%0aoogle.co%0dm/%0A%0A%0A",S_OK,FALSE},
3117             {"g%0aoogle.co%0dm",S_OK,FALSE},
3118             {"http://g%0aoogle.co%0dm/%0A%0A%0A",S_OK,FALSE},
3119             {"g%0aoogle.co%0dm",S_OK,FALSE},
3120             {"",S_FALSE,FALSE},
3121             {"",S_FALSE,FALSE},
3122             {"g%0aoogle.co%0dm",S_OK,FALSE},
3123             {"",S_FALSE,FALSE},
3124             {"/%0A%0A%0A",S_OK,FALSE},
3125             {"/%0A%0A%0A",S_OK,FALSE},
3126             {"",S_FALSE,FALSE},
3127             {"http://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3128             {"http",S_OK,FALSE},
3129             {"",S_FALSE,FALSE},
3130             {"",S_FALSE,FALSE}
3131         },
3132         {
3133             {Uri_HOST_DNS,S_OK,FALSE},
3134             {80,S_OK,FALSE},
3135             {URL_SCHEME_HTTP,S_OK,FALSE},
3136             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3137         }
3138     },
3139     {   "zip://g\noogle.co\rm/\n\n\n", Uri_CREATE_NO_PRE_PROCESS_HTML_URI, S_OK, FALSE,
3140         {
3141             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3142             {"g\noogle.co\rm",S_OK,FALSE},
3143             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3144             {"g\noogle.co\rm",S_OK,FALSE},
3145             {"",S_FALSE,FALSE},
3146             {"",S_FALSE,FALSE},
3147             {"g\noogle.co\rm",S_OK,FALSE},
3148             {"",S_FALSE,FALSE},
3149             {"/\n\n\n",S_OK,FALSE},
3150             {"/\n\n\n",S_OK,FALSE},
3151             {"",S_FALSE,FALSE},
3152             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3153             {"zip",S_OK,FALSE},
3154             {"",S_FALSE,FALSE},
3155             {"",S_FALSE,FALSE}
3156         },
3157         {
3158             {Uri_HOST_DNS,S_OK,FALSE},
3159             {0,S_FALSE,FALSE},
3160             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3161             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3162         }
3163     },
3164     /* Since file URLs are usually hierarchical, it returns an empty string
3165      * for the absolute URI property since it was declared as an opaque URI.
3166      */
3167     {   "file:index.html", 0, S_OK, FALSE,
3168         {
3169             {"",S_FALSE,FALSE},
3170             {"",S_FALSE,FALSE},
3171             {"file:index.html",S_OK,FALSE},
3172             {"",S_FALSE,FALSE},
3173             {".html",S_OK,FALSE},
3174             {"",S_FALSE,FALSE},
3175             {"",S_FALSE,FALSE},
3176             {"",S_FALSE,FALSE},
3177             {"index.html",S_OK,FALSE},
3178             {"index.html",S_OK,FALSE},
3179             {"",S_FALSE,FALSE},
3180             {"file:index.html",S_OK,FALSE},
3181             {"file",S_OK,FALSE},
3182             {"",S_FALSE,FALSE},
3183             {"",S_FALSE,FALSE}
3184         },
3185         {
3186             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3187             {0,S_FALSE,FALSE},
3188             {URL_SCHEME_FILE,S_OK,FALSE},
3189             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3190         }
3191     },
3192     /* Doesn't have an absolute since it's opaque, but gets it port set. */
3193     {   "http:test.com/index.html", 0, S_OK, FALSE,
3194         {
3195             {"",S_FALSE,FALSE},
3196             {"",S_FALSE,FALSE},
3197             {"http:test.com/index.html",S_OK,FALSE},
3198             {"",S_FALSE,FALSE},
3199             {".html",S_OK,FALSE},
3200             {"",S_FALSE,FALSE},
3201             {"",S_FALSE,FALSE},
3202             {"",S_FALSE,FALSE},
3203             {"test.com/index.html",S_OK,FALSE},
3204             {"test.com/index.html",S_OK,FALSE},
3205             {"",S_FALSE,FALSE},
3206             {"http:test.com/index.html",S_OK,FALSE},
3207             {"http",S_OK,FALSE},
3208             {"",S_FALSE,FALSE},
3209             {"",S_FALSE,FALSE}
3210         },
3211         {
3212             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3213             {80,S_OK,FALSE},
3214             {URL_SCHEME_HTTP,S_OK,FALSE},
3215             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3216         }
3217     },
3218     {   "ftp:test.com/index.html", 0, S_OK, FALSE,
3219         {
3220             {"",S_FALSE,FALSE},
3221             {"",S_FALSE,FALSE},
3222             {"ftp:test.com/index.html",S_OK,FALSE},
3223             {"",S_FALSE,FALSE},
3224             {".html",S_OK,FALSE},
3225             {"",S_FALSE,FALSE},
3226             {"",S_FALSE,FALSE},
3227             {"",S_FALSE,FALSE},
3228             {"test.com/index.html",S_OK,FALSE},
3229             {"test.com/index.html",S_OK,FALSE},
3230             {"",S_FALSE,FALSE},
3231             {"ftp:test.com/index.html",S_OK,FALSE},
3232             {"ftp",S_OK,FALSE},
3233             {"",S_FALSE,FALSE},
3234             {"",S_FALSE,FALSE}
3235         },
3236         {
3237             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3238             {21,S_OK,FALSE},
3239             {URL_SCHEME_FTP,S_OK,FALSE},
3240             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3241         }
3242     },
3243     {   "file://C|/test.mp3", 0, S_OK, FALSE,
3244         {
3245             {"file:///C:/test.mp3",S_OK,FALSE},
3246             {"",S_FALSE,FALSE},
3247             {"file:///C:/test.mp3",S_OK,FALSE},
3248             {"",S_FALSE,FALSE},
3249             {".mp3",S_OK,FALSE},
3250             {"",S_FALSE,FALSE},
3251             {"",S_FALSE,FALSE},
3252             {"",S_FALSE,FALSE},
3253             {"/C:/test.mp3",S_OK,FALSE},
3254             {"/C:/test.mp3",S_OK,FALSE},
3255             {"",S_FALSE,FALSE},
3256             {"file://C|/test.mp3",S_OK,FALSE},
3257             {"file",S_OK,FALSE},
3258             {"",S_FALSE,FALSE},
3259             {"",S_FALSE,FALSE}
3260         },
3261         {
3262             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3263             {0,S_FALSE,FALSE},
3264             {URL_SCHEME_FILE,S_OK,FALSE},
3265             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3266         }
3267     },
3268     {   "file:///C|/test.mp3", 0, S_OK, FALSE,
3269         {
3270             {"file:///C:/test.mp3",S_OK,FALSE},
3271             {"",S_FALSE,FALSE},
3272             {"file:///C:/test.mp3",S_OK,FALSE},
3273             {"",S_FALSE,FALSE},
3274             {".mp3",S_OK,FALSE},
3275             {"",S_FALSE,FALSE},
3276             {"",S_FALSE,FALSE},
3277             {"",S_FALSE,FALSE},
3278             {"/C:/test.mp3",S_OK,FALSE},
3279             {"/C:/test.mp3",S_OK,FALSE},
3280             {"",S_FALSE,FALSE},
3281             {"file:///C|/test.mp3",S_OK,FALSE},
3282             {"file",S_OK,FALSE},
3283             {"",S_FALSE,FALSE},
3284             {"",S_FALSE,FALSE}
3285         },
3286         {
3287             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3288             {0,S_FALSE,FALSE},
3289             {URL_SCHEME_FILE,S_OK,FALSE},
3290             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3291         }
3292     },
3293     /* Extra '/' isn't added before "c:" since USE_DOS_PATH is set and '/' are converted
3294      * to '\\'.
3295      */
3296     {   "file://c:/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3297         {
3298             {"file://c:\\dir\\index.html",S_OK,FALSE},
3299             {"",S_FALSE,FALSE},
3300             {"file://c:\\dir\\index.html",S_OK,FALSE},
3301             {"",S_FALSE,FALSE},
3302             {".html",S_OK,FALSE},
3303             {"",S_FALSE,FALSE},
3304             {"",S_FALSE,FALSE},
3305             {"",S_FALSE,FALSE},
3306             {"c:\\dir\\index.html",S_OK,FALSE},
3307             {"c:\\dir\\index.html",S_OK,FALSE},
3308             {"",S_FALSE,FALSE},
3309             {"file://c:/dir/index.html",S_OK,FALSE},
3310             {"file",S_OK,FALSE},
3311             {"",S_FALSE,FALSE},
3312             {"",S_FALSE,FALSE}
3313         },
3314         {
3315             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3316             {0,S_FALSE,FALSE},
3317             {URL_SCHEME_FILE,S_OK,FALSE},
3318             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3319         }
3320     },
3321     /* Extra '/' after "file://" is removed. */
3322     {   "file:///c:/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3323         {
3324             {"file://c:\\dir\\index.html",S_OK,FALSE},
3325             {"",S_FALSE,FALSE},
3326             {"file://c:\\dir\\index.html",S_OK,FALSE},
3327             {"",S_FALSE,FALSE},
3328             {".html",S_OK,FALSE},
3329             {"",S_FALSE,FALSE},
3330             {"",S_FALSE,FALSE},
3331             {"",S_FALSE,FALSE},
3332             {"c:\\dir\\index.html",S_OK,FALSE},
3333             {"c:\\dir\\index.html",S_OK,FALSE},
3334             {"",S_FALSE,FALSE},
3335             {"file:///c:/dir/index.html",S_OK,FALSE},
3336             {"file",S_OK,FALSE},
3337             {"",S_FALSE,FALSE},
3338             {"",S_FALSE,FALSE}
3339         },
3340         {
3341             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3342             {0,S_FALSE,FALSE},
3343             {URL_SCHEME_FILE,S_OK,FALSE},
3344             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3345         }
3346     },
3347     /* Allow more characters when Uri_CREATE_FILE_USE_DOS_PATH is specified */
3348     {   "file:///c:/dir\\%%61%20%5Fname/file%2A.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3349         {
3350             {"file://c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3351             {"",S_FALSE,FALSE},
3352             {"file://c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3353             {"",S_FALSE,FALSE},
3354             {".html",S_OK,FALSE},
3355             {"",S_FALSE,FALSE},
3356             {"",S_FALSE,FALSE},
3357             {"",S_FALSE,FALSE},
3358             {"c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3359             {"c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3360             {"",S_FALSE,FALSE},
3361             {"file:///c:/dir\\%%61%20%5Fname/file%2A.html",S_OK,FALSE},
3362             {"file",S_OK,FALSE},
3363             {"",S_FALSE,FALSE},
3364             {"",S_FALSE,FALSE}
3365         },
3366         {
3367             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3368             {0,S_FALSE,FALSE},
3369             {URL_SCHEME_FILE,S_OK,FALSE},
3370             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3371         }
3372     },
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     /* The backslashes after the scheme name are converted to forward slashes. */
3399     {   "file:\\\\c:\\dir\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3400         {
3401             {"file://c:\\dir\\index.html",S_OK,FALSE},
3402             {"",S_FALSE,FALSE},
3403             {"file://c:\\dir\\index.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\\index.html",S_OK,FALSE},
3410             {"c:\\dir\\index.html",S_OK,FALSE},
3411             {"",S_FALSE,FALSE},
3412             {"file:\\\\c:\\dir\\index.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", 0, 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     {   "http:\\\\google.com", 0, S_OK, FALSE,
3450         {
3451             {"http://google.com/",S_OK,FALSE},
3452             {"google.com",S_OK,FALSE},
3453             {"http://google.com/",S_OK,FALSE},
3454             {"google.com",S_OK,FALSE},
3455             {"",S_FALSE,FALSE},
3456             {"",S_FALSE,FALSE},
3457             {"google.com",S_OK,FALSE},
3458             {"",S_FALSE,FALSE},
3459             {"/",S_OK,FALSE},
3460             {"/",S_OK,FALSE},
3461             {"",S_FALSE,FALSE},
3462             {"http:\\\\google.com",S_OK,FALSE},
3463             {"http",S_OK,FALSE},
3464             {"",S_FALSE,FALSE},
3465             {"",S_FALSE,FALSE}
3466         },
3467         {
3468             {Uri_HOST_DNS,S_OK,FALSE},
3469             {80,S_OK,FALSE},
3470             {URL_SCHEME_HTTP,S_OK,FALSE},
3471             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3472         }
3473     },
3474     /* the "\\\\" aren't converted to "//" for unknown scheme types and it's considered opaque. */
3475     {   "zip:\\\\google.com", 0, S_OK, FALSE,
3476         {
3477             {"zip:\\\\google.com",S_OK,FALSE},
3478             {"",S_FALSE,FALSE},
3479             {"zip:\\\\google.com",S_OK,FALSE},
3480             {"",S_FALSE,FALSE},
3481             {".com",S_OK,FALSE},
3482             {"",S_FALSE,FALSE},
3483             {"",S_FALSE,FALSE},
3484             {"",S_FALSE,FALSE},
3485             {"\\\\google.com",S_OK,FALSE},
3486             {"\\\\google.com",S_OK,FALSE},
3487             {"",S_FALSE,FALSE},
3488             {"zip:\\\\google.com",S_OK,FALSE},
3489             {"zip",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_UNKNOWN,S_OK,FALSE},
3497             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3498         }
3499     },
3500     /* Dot segments aren't removed. */
3501     {   "file://c:\\dir\\../..\\./index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3502         {
3503             {"file://c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3504             {"",S_FALSE,FALSE},
3505             {"file://c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3506             {"",S_FALSE,FALSE},
3507             {".html",S_OK,FALSE},
3508             {"",S_FALSE,FALSE},
3509             {"",S_FALSE,FALSE},
3510             {"",S_FALSE,FALSE},
3511             {"c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3512             {"c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3513             {"",S_FALSE,FALSE},
3514             {"file://c:\\dir\\../..\\./index.html",S_OK,FALSE},
3515             {"file",S_OK,FALSE},
3516             {"",S_FALSE,FALSE},
3517             {"",S_FALSE,FALSE}
3518         },
3519         {
3520             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3521             {0,S_FALSE,FALSE},
3522             {URL_SCHEME_FILE,S_OK,FALSE},
3523             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3524         }
3525     },
3526     /* Forbidden characters aren't percent encoded. */
3527     {   "file://c:\\dir\\i^|ndex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3528         {
3529             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3530             {"",S_FALSE,FALSE},
3531             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3532             {"",S_FALSE,FALSE},
3533             {".html",S_OK,FALSE},
3534             {"",S_FALSE,FALSE},
3535             {"",S_FALSE,FALSE},
3536             {"",S_FALSE,FALSE},
3537             {"c:\\dir\\i^|ndex.html",S_OK,FALSE},
3538             {"c:\\dir\\i^|ndex.html",S_OK,FALSE},
3539             {"",S_FALSE,FALSE},
3540             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3541             {"file",S_OK,FALSE},
3542             {"",S_FALSE,FALSE},
3543             {"",S_FALSE,FALSE}
3544         },
3545         {
3546             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3547             {0,S_FALSE,FALSE},
3548             {URL_SCHEME_FILE,S_OK,FALSE},
3549             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3550         }
3551     },
3552     /* The '\' are still converted to '/' even though it's an opaque file URI. */
3553     {   "file:c:\\dir\\../..\\index.html", 0, S_OK, FALSE,
3554         {
3555             {"",S_FALSE,FALSE},
3556             {"",S_FALSE,FALSE},
3557             {"file:c:/dir/../../index.html",S_OK,FALSE},
3558             {"",S_FALSE,FALSE},
3559             {".html",S_OK,FALSE},
3560             {"",S_FALSE,FALSE},
3561             {"",S_FALSE,FALSE},
3562             {"",S_FALSE,FALSE},
3563             {"c:/dir/../../index.html",S_OK,FALSE},
3564             {"c:/dir/../../index.html",S_OK,FALSE},
3565             {"",S_FALSE,FALSE},
3566             {"file:c:\\dir\\../..\\index.html",S_OK,FALSE},
3567             {"file",S_OK,FALSE},
3568             {"",S_FALSE,FALSE},
3569             {"",S_FALSE,FALSE}
3570         },
3571         {
3572             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3573             {0,S_FALSE,FALSE},
3574             {URL_SCHEME_FILE,S_OK,FALSE},
3575             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3576         }
3577     },
3578     /* '/' are still converted to '\' even though it's an opaque URI. */
3579     {   "file:c:/dir\\../..\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3580         {
3581             {"",S_FALSE,FALSE},
3582             {"",S_FALSE,FALSE},
3583             {"file:c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3584             {"",S_FALSE,FALSE},
3585             {".html",S_OK,FALSE},
3586             {"",S_FALSE,FALSE},
3587             {"",S_FALSE,FALSE},
3588             {"",S_FALSE,FALSE},
3589             {"c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3590             {"c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3591             {"",S_FALSE,FALSE},
3592             {"file:c:/dir\\../..\\index.html",S_OK,FALSE},
3593             {"file",S_OK,FALSE},
3594             {"",S_FALSE,FALSE},
3595             {"",S_FALSE,FALSE}
3596         },
3597         {
3598             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3599             {0,S_FALSE,FALSE},
3600             {URL_SCHEME_FILE,S_OK,FALSE},
3601             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3602         }
3603     },
3604     /* Forbidden characters aren't percent encoded. */
3605     {   "file:c:\\in^|dex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3606         {
3607             {"",S_FALSE,FALSE},
3608             {"",S_FALSE,FALSE},
3609             {"file:c:\\in^|dex.html",S_OK,FALSE},
3610             {"",S_FALSE,FALSE},
3611             {".html",S_OK,FALSE},
3612             {"",S_FALSE,FALSE},
3613             {"",S_FALSE,FALSE},
3614             {"",S_FALSE,FALSE},
3615             {"c:\\in^|dex.html",S_OK,FALSE},
3616             {"c:\\in^|dex.html",S_OK,FALSE},
3617             {"",S_FALSE,FALSE},
3618             {"file:c:\\in^|dex.html",S_OK,FALSE},
3619             {"file",S_OK,FALSE},
3620             {"",S_FALSE,FALSE},
3621             {"",S_FALSE,FALSE}
3622         },
3623         {
3624             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3625             {0,S_FALSE,FALSE},
3626             {URL_SCHEME_FILE,S_OK,FALSE},
3627             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3628         }
3629     },
3630     /* Doesn't have a UserName since the ':' appears at the beginning of the
3631      * userinfo section.
3632      */
3633     {   "http://:password@gov.uk", 0, S_OK, FALSE,
3634         {
3635             {"http://:password@gov.uk/",S_OK,FALSE},
3636             {":password@gov.uk",S_OK,FALSE},
3637             {"http://gov.uk/",S_OK,FALSE},
3638             {"",S_FALSE,FALSE},
3639             {"",S_FALSE,FALSE},
3640             {"",S_FALSE,FALSE},
3641             {"gov.uk",S_OK,FALSE},
3642             {"password",S_OK,FALSE},
3643             {"/",S_OK,FALSE},
3644             {"/",S_OK,FALSE},
3645             {"",S_FALSE,FALSE},
3646             {"http://:password@gov.uk",S_OK,FALSE},
3647             {"http",S_OK,FALSE},
3648             {":password",S_OK,FALSE},
3649             {"",S_FALSE,FALSE}
3650         },
3651         {
3652             {Uri_HOST_DNS,S_OK,FALSE},
3653             {80,S_OK,FALSE},
3654             {URL_SCHEME_HTTP,S_OK,FALSE},
3655             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3656         }
3657     },
3658     /* Has a UserName since the userinfo section doesn't contain a password. */
3659     {   "http://@gov.uk", 0, S_OK, FALSE,
3660         {
3661             {"http://gov.uk/",S_OK,FALSE,"http://@gov.uk/"},
3662             {"@gov.uk",S_OK,FALSE},
3663             {"http://gov.uk/",S_OK,FALSE},
3664             {"",S_FALSE,FALSE},
3665             {"",S_FALSE,FALSE},
3666             {"",S_FALSE,FALSE},
3667             {"gov.uk",S_OK,FALSE},
3668             {"",S_FALSE,FALSE},
3669             {"/",S_OK,FALSE},
3670             {"/",S_OK,FALSE},
3671             {"",S_FALSE,FALSE},
3672             {"http://@gov.uk",S_OK,FALSE},
3673             {"http",S_OK,FALSE},
3674             {"",S_OK,FALSE},
3675             {"",S_OK,FALSE}
3676         },
3677         {
3678             {Uri_HOST_DNS,S_OK,FALSE},
3679             {80,S_OK,FALSE},
3680             {URL_SCHEME_HTTP,S_OK,FALSE},
3681             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3682         }
3683     },
3684     /* ":@" not included in the absolute URI. */
3685     {   "http://:@gov.uk", 0, S_OK, FALSE,
3686         {
3687             {"http://gov.uk/",S_OK,FALSE,"http://:@gov.uk/"},
3688             {":@gov.uk",S_OK,FALSE},
3689             {"http://gov.uk/",S_OK,FALSE},
3690             {"",S_FALSE,FALSE},
3691             {"",S_FALSE,FALSE},
3692             {"",S_FALSE,FALSE},
3693             {"gov.uk",S_OK,FALSE},
3694             {"",S_OK,FALSE},
3695             {"/",S_OK,FALSE},
3696             {"/",S_OK,FALSE},
3697             {"",S_FALSE,FALSE},
3698             {"http://:@gov.uk",S_OK,FALSE},
3699             {"http",S_OK,FALSE},
3700             {":",S_OK,FALSE},
3701             {"",S_FALSE,FALSE}
3702         },
3703         {
3704             {Uri_HOST_DNS,S_OK,FALSE},
3705             {80,S_OK,FALSE},
3706             {URL_SCHEME_HTTP,S_OK,FALSE},
3707             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3708         }
3709     },
3710     /* '@' is included because it's an unknown scheme type. */
3711     {   "zip://@gov.uk", 0, S_OK, FALSE,
3712         {
3713             {"zip://@gov.uk/",S_OK,FALSE},
3714             {"@gov.uk",S_OK,FALSE},
3715             {"zip://@gov.uk/",S_OK,FALSE},
3716             {"",S_FALSE,FALSE},
3717             {"",S_FALSE,FALSE},
3718             {"",S_FALSE,FALSE},
3719             {"gov.uk",S_OK,FALSE},
3720             {"",S_FALSE,FALSE},
3721             {"/",S_OK,FALSE},
3722             {"/",S_OK,FALSE},
3723             {"",S_FALSE,FALSE},
3724             {"zip://@gov.uk",S_OK,FALSE},
3725             {"zip",S_OK,FALSE},
3726             {"",S_OK,FALSE},
3727             {"",S_OK,FALSE}
3728         },
3729         {
3730             {Uri_HOST_DNS,S_OK,FALSE},
3731             {0,S_FALSE,FALSE},
3732             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3733             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3734         }
3735     },
3736     /* ":@" are included because it's an unknown scheme type. */
3737     {   "zip://:@gov.uk", 0, S_OK, FALSE,
3738         {
3739             {"zip://:@gov.uk/",S_OK,FALSE},
3740             {":@gov.uk",S_OK,FALSE},
3741             {"zip://:@gov.uk/",S_OK,FALSE},
3742             {"",S_FALSE,FALSE},
3743             {"",S_FALSE,FALSE},
3744             {"",S_FALSE,FALSE},
3745             {"gov.uk",S_OK,FALSE},
3746             {"",S_OK,FALSE},
3747             {"/",S_OK,FALSE},
3748             {"/",S_OK,FALSE},
3749             {"",S_FALSE,FALSE},
3750             {"zip://:@gov.uk",S_OK,FALSE},
3751             {"zip",S_OK,FALSE},
3752             {":",S_OK,FALSE},
3753             {"",S_FALSE,FALSE}
3754         },
3755         {
3756             {Uri_HOST_DNS,S_OK,FALSE},
3757             {0,S_FALSE,FALSE},
3758             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3759             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3760         }
3761     },
3762     {   "about:blank", 0, S_OK, FALSE,
3763         {
3764             {"about:blank",S_OK,FALSE},
3765             {"",S_FALSE,FALSE},
3766             {"about:blank",S_OK,FALSE},
3767             {"",S_FALSE,FALSE},
3768             {"",S_FALSE,FALSE},
3769             {"",S_FALSE,FALSE},
3770             {"",S_FALSE,FALSE},
3771             {"",S_FALSE,FALSE},
3772             {"blank",S_OK,FALSE},
3773             {"blank",S_OK,FALSE},
3774             {"",S_FALSE,FALSE},
3775             {"about:blank",S_OK,FALSE},
3776             {"about",S_OK,FALSE},
3777             {"",S_FALSE,FALSE},
3778             {"",S_FALSE,FALSE}
3779         },
3780         {
3781             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3782             {0,S_FALSE,FALSE},
3783             {URL_SCHEME_ABOUT,S_OK,FALSE},
3784             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3785         }
3786     },
3787     {   "mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",0,S_OK,FALSE,
3788         {
3789             {"mk:@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3790             {"",S_FALSE,FALSE},
3791             {"mk:@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3792             {"",S_FALSE,FALSE},
3793             {".htm",S_OK,FALSE},
3794             {"",S_FALSE,FALSE},
3795             {"",S_FALSE,FALSE},
3796             {"",S_FALSE,FALSE},
3797             {"@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3798             {"@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3799             {"",S_FALSE,FALSE},
3800             {"mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3801             {"mk",S_OK,FALSE},
3802             {"",S_FALSE,FALSE},
3803             {"",S_FALSE,FALSE}
3804         },
3805         {
3806             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3807             {0,S_FALSE,FALSE},
3808             {URL_SCHEME_MK,S_OK,FALSE},
3809             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3810         }
3811     },
3812     {   "mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",0,S_OK,FALSE,
3813         {
3814             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3815             {"",S_FALSE,FALSE},
3816             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3817             {"",S_FALSE,FALSE},
3818             {".htm",S_OK,FALSE},
3819             {"",S_FALSE,FALSE},
3820             {"",S_FALSE,FALSE},
3821             {"",S_FALSE,FALSE},
3822             {"@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3823             {"@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3824             {"",S_FALSE,FALSE},
3825             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3826             {"mk",S_OK,FALSE},
3827             {"",S_FALSE,FALSE},
3828             {"",S_FALSE,FALSE}
3829         },
3830         {
3831             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3832             {0,S_FALSE,FALSE},
3833             {URL_SCHEME_MK,S_OK,FALSE},
3834             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3835         }
3836     },
3837     /* Two '\' are added to the URI when USE_DOS_PATH is set, and it's a UNC path. */
3838     {   "file://server/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3839         {
3840             {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
3841             {"server",S_OK,FALSE},
3842             {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
3843             {"",S_FALSE,FALSE},
3844             {".html",S_OK,FALSE},
3845             {"",S_FALSE,FALSE},
3846             {"server",S_OK,FALSE},
3847             {"",S_FALSE,FALSE},
3848             {"\\dir\\index.html",S_OK,FALSE},
3849             {"\\dir\\index.html",S_OK,FALSE},
3850             {"",S_FALSE,FALSE},
3851             {"file://server/dir/index.html",S_OK,FALSE},
3852             {"file",S_OK,FALSE},
3853             {"",S_FALSE,FALSE},
3854             {"",S_FALSE,FALSE}
3855         },
3856         {
3857             {Uri_HOST_DNS,S_OK,FALSE},
3858             {0,S_FALSE,FALSE},
3859             {URL_SCHEME_FILE,S_OK,FALSE},
3860             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3861         }
3862     },
3863     /* When CreateUri generates an IUri, it still displays the default port in the
3864      * authority.
3865      */
3866     {   "http://google.com:80/", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
3867         {
3868             {"http://google.com:80/",S_OK,FALSE},
3869             {"google.com:80",S_OK,FALSE},
3870             {"http://google.com:80/",S_OK,FALSE},
3871             {"google.com",S_OK,FALSE},
3872             {"",S_FALSE,FALSE},
3873             {"",S_FALSE,FALSE},
3874             {"google.com",S_OK,FALSE},
3875             {"",S_FALSE,FALSE},
3876             {"/",S_OK,FALSE},
3877             {"/",S_OK,FALSE},
3878             {"",S_FALSE,FALSE},
3879             {"http://google.com:80/",S_OK,FALSE},
3880             {"http",S_OK,FALSE},
3881             {"",S_FALSE,FALSE},
3882             {"",S_FALSE,FALSE}
3883         },
3884         {
3885             {Uri_HOST_DNS,S_OK,FALSE},
3886             {80,S_OK,FALSE},
3887             {URL_SCHEME_HTTP,S_OK,FALSE},
3888             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3889         }
3890     },
3891     /* For res URIs the host is everything up until the first '/'. */
3892     {   "res://C:\\dir\\file.exe/DATA/test.html", 0, S_OK, FALSE,
3893         {
3894             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3895             {"C:\\dir\\file.exe",S_OK,FALSE},
3896             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3897             {"",S_FALSE,FALSE},
3898             {".html",S_OK,FALSE},
3899             {"",S_FALSE,FALSE},
3900             {"C:\\dir\\file.exe",S_OK,FALSE},
3901             {"",S_FALSE,FALSE},
3902             {"/DATA/test.html",S_OK,FALSE},
3903             {"/DATA/test.html",S_OK,FALSE},
3904             {"",S_FALSE,FALSE},
3905             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3906             {"res",S_OK,FALSE},
3907             {"",S_FALSE,FALSE},
3908             {"",S_FALSE,FALSE}
3909         },
3910         {
3911             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3912             {0,S_FALSE,FALSE},
3913             {URL_SCHEME_RES,S_OK,FALSE},
3914             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3915         }
3916     },
3917     /* Res URI can contain a '|' in the host name. */
3918     {   "res://c:\\di|r\\file.exe/test", 0, S_OK, FALSE,
3919         {
3920             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3921             {"c:\\di|r\\file.exe",S_OK,FALSE},
3922             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3923             {"",S_FALSE,FALSE},
3924             {"",S_FALSE,FALSE},
3925             {"",S_FALSE,FALSE},
3926             {"c:\\di|r\\file.exe",S_OK,FALSE},
3927             {"",S_FALSE,FALSE},
3928             {"/test",S_OK,FALSE},
3929             {"/test",S_OK,FALSE},
3930             {"",S_FALSE,FALSE},
3931             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3932             {"res",S_OK,FALSE},
3933             {"",S_FALSE,FALSE},
3934             {"",S_FALSE,FALSE}
3935         },
3936         {
3937             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3938             {0,S_FALSE,FALSE},
3939             {URL_SCHEME_RES,S_OK,FALSE},
3940             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3941         }
3942     },
3943     /* Res URIs can have invalid percent encoded values. */
3944     {   "res://c:\\dir%xx\\file.exe/test", 0, S_OK, FALSE,
3945         {
3946             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3947             {"c:\\dir%xx\\file.exe",S_OK,FALSE},
3948             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3949             {"",S_FALSE,FALSE},
3950             {"",S_FALSE,FALSE},
3951             {"",S_FALSE,FALSE},
3952             {"c:\\dir%xx\\file.exe",S_OK,FALSE},
3953             {"",S_FALSE,FALSE},
3954             {"/test",S_OK,FALSE},
3955             {"/test",S_OK,FALSE},
3956             {"",S_FALSE,FALSE},
3957             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3958             {"res",S_OK,FALSE},
3959             {"",S_FALSE,FALSE},
3960             {"",S_FALSE,FALSE}
3961         },
3962         {
3963             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3964             {0,S_FALSE,FALSE},
3965             {URL_SCHEME_RES,S_OK,FALSE},
3966             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3967         }
3968     },
3969     /* Res doesn't get forbidden characters percent encoded in it's path. */
3970     {   "res://c:\\test/tes<|>t", 0, S_OK, FALSE,
3971         {
3972             {"res://c:\\test/tes<|>t",S_OK,FALSE},
3973             {"c:\\test",S_OK,FALSE},
3974             {"res://c:\\test/tes<|>t",S_OK,FALSE},
3975             {"",S_FALSE,FALSE},
3976             {"",S_FALSE,FALSE},
3977             {"",S_FALSE,FALSE},
3978             {"c:\\test",S_OK,FALSE},
3979             {"",S_FALSE,FALSE},
3980             {"/tes<|>t",S_OK,FALSE},
3981             {"/tes<|>t",S_OK,FALSE},
3982             {"",S_FALSE,FALSE},
3983             {"res://c:\\test/tes<|>t",S_OK,FALSE},
3984             {"res",S_OK,FALSE},
3985             {"",S_FALSE,FALSE},
3986             {"",S_FALSE,FALSE}
3987         },
3988         {
3989             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3990             {0,S_FALSE,FALSE},
3991             {URL_SCHEME_RES,S_OK,FALSE},
3992             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3993         }
3994     },
3995     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg", 0, S_OK, FALSE,
3996         {
3997             {"mk:@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
3998             {"",S_FALSE,FALSE},
3999             {"mk:@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4000             {"",S_FALSE,FALSE},
4001             {".jpg",S_OK,FALSE},
4002             {"",S_FALSE,FALSE},
4003             {"",S_FALSE,FALSE},
4004             {"",S_FALSE,FALSE},
4005             {"@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4006             {"@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4007             {"",S_FALSE,FALSE},
4008             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4009             {"mk",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_MK,S_OK,FALSE},
4017             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4018         }
4019     },
4020     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
4021         {
4022             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4023             {"",S_FALSE,FALSE},
4024             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4025             {"",S_FALSE,FALSE},
4026             {".jpg",S_OK,FALSE},
4027             {"",S_FALSE,FALSE},
4028             {"",S_FALSE,FALSE},
4029             {"",S_FALSE,FALSE},
4030             {"@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4031             {"@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4032             {"",S_FALSE,FALSE},
4033             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4034             {"mk",S_OK,FALSE},
4035             {"",S_FALSE,FALSE},
4036             {"",S_FALSE,FALSE}
4037         },
4038         {
4039             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4040             {0,S_FALSE,FALSE},
4041             {URL_SCHEME_MK,S_OK,FALSE},
4042             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4043         }
4044     },
4045     {   "xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg", 0, S_OK, FALSE,
4046         {
4047             {"xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4048             {"",S_FALSE,FALSE},
4049             {"xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4050             {"",S_FALSE,FALSE},
4051             {".jpg",S_OK,FALSE},
4052             {"",S_FALSE,FALSE},
4053             {"",S_FALSE,FALSE},
4054             {"",S_FALSE,FALSE},
4055             {"@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4056             {"@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4057             {"",S_FALSE,FALSE},
4058             {"xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4059             {"xx",S_OK,FALSE},
4060             {"",S_FALSE,FALSE},
4061             {"",S_FALSE,FALSE}
4062         },
4063         {
4064             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4065             {0,S_FALSE,FALSE},
4066             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
4067             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4068         }
4069     },
4070     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../../images/xxx.jpg", 0, S_OK, FALSE,
4071         {
4072             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4073             {"",S_FALSE,FALSE},
4074             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4075             {"",S_FALSE,FALSE},
4076             {".jpg",S_OK,FALSE},
4077             {"",S_FALSE,FALSE},
4078             {"",S_FALSE,FALSE},
4079             {"",S_FALSE,FALSE},
4080             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4081             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4082             {"",S_FALSE,FALSE},
4083             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../../images/xxx.jpg",S_OK,FALSE},
4084             {"mk",S_OK,FALSE},
4085             {"",S_FALSE,FALSE},
4086             {"",S_FALSE,FALSE}
4087         },
4088         {
4089             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4090             {0,S_FALSE,FALSE},
4091             {URL_SCHEME_MK,S_OK,FALSE},
4092             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4093         }
4094     },
4095     {   "mk:@MSITStore:Z:\\dir\\dir2\\..\\test.chm::/html/../../images/xxx.jpg", 0, S_OK, FALSE,
4096         {
4097             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4098             {"",S_FALSE,FALSE},
4099             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4100             {"",S_FALSE,FALSE},
4101             {".jpg",S_OK,FALSE},
4102             {"",S_FALSE,FALSE},
4103             {"",S_FALSE,FALSE},
4104             {"",S_FALSE,FALSE},
4105             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4106             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4107             {"",S_FALSE,FALSE},
4108             {"mk:@MSITStore:Z:\\dir\\dir2\\..\\test.chm::/html/../../images/xxx.jpg",S_OK,FALSE},
4109             {"mk",S_OK,FALSE},
4110             {"",S_FALSE,FALSE},
4111             {"",S_FALSE,FALSE}
4112         },
4113         {
4114             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4115             {0,S_FALSE,FALSE},
4116             {URL_SCHEME_MK,S_OK,FALSE},
4117             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4118         }
4119     },
4120     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../../../../images/xxx.jpg", 0, S_OK, FALSE,
4121         {
4122             {"mk:images/xxx.jpg",S_OK,FALSE},
4123             {"",S_FALSE,FALSE},
4124             {"mk:images/xxx.jpg",S_OK,FALSE},
4125             {"",S_FALSE,FALSE},
4126             {".jpg",S_OK,FALSE},
4127             {"",S_FALSE,FALSE},
4128             {"",S_FALSE,FALSE},
4129             {"",S_FALSE,FALSE},
4130             {"images/xxx.jpg",S_OK,FALSE},
4131             {"images/xxx.jpg",S_OK,FALSE},
4132             {"",S_FALSE,FALSE},
4133             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../../../../images/xxx.jpg",S_OK,FALSE},
4134             {"mk",S_OK,FALSE},
4135             {"",S_FALSE,FALSE},
4136             {"",S_FALSE,FALSE}
4137         },
4138         {
4139             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4140             {0,S_FALSE,FALSE},
4141             {URL_SCHEME_MK,S_OK,FALSE},
4142             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4143         }
4144     },
4145     {   "", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
4146         {
4147             {"",S_OK,FALSE},
4148             {"",S_FALSE,FALSE},
4149             {"",S_OK,FALSE},
4150             {"",S_FALSE,FALSE},
4151             {"",S_FALSE,FALSE},
4152             {"",S_FALSE,FALSE},
4153             {"",S_FALSE,FALSE},
4154             {"",S_FALSE,FALSE},
4155             {"",S_OK,FALSE},
4156             {"",S_OK,FALSE},
4157             {"",S_FALSE,FALSE},
4158             {"",S_OK,FALSE},
4159             {"",S_FALSE,FALSE},
4160             {"",S_FALSE,FALSE},
4161             {"",S_FALSE,FALSE}
4162         },
4163         {
4164             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4165             {0,S_FALSE,FALSE},
4166             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
4167             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4168         }
4169     },
4170     {   " \t ", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
4171         {
4172             {"",S_OK,FALSE},
4173             {"",S_FALSE,FALSE},
4174             {"",S_OK,FALSE},
4175             {"",S_FALSE,FALSE},
4176             {"",S_FALSE,FALSE},
4177             {"",S_FALSE,FALSE},
4178             {"",S_FALSE,FALSE},
4179             {"",S_FALSE,FALSE},
4180             {"",S_OK,FALSE},
4181             {"",S_OK,FALSE},
4182             {"",S_FALSE,FALSE},
4183             {"",S_OK,FALSE},
4184             {"",S_FALSE,FALSE},
4185             {"",S_FALSE,FALSE},
4186             {"",S_FALSE,FALSE}
4187         },
4188         {
4189             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4190             {0,S_FALSE,FALSE},
4191             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
4192             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4193         }
4194     },
4195
4196 };
4197
4198 typedef struct _invalid_uri {
4199     const char* uri;
4200     DWORD       flags;
4201     BOOL        todo;
4202 } invalid_uri;
4203
4204 static const invalid_uri invalid_uri_tests[] = {
4205     /* Has to have a scheme name. */
4206     {"://www.winehq.org",0,FALSE},
4207     /* Window's doesn't like URI's which are implicitly file paths without the
4208      * ALLOW_IMPLICIT_FILE_SCHEME flag set.
4209      */
4210     {"C:/test/test.mp3",0,FALSE},
4211     {"\\\\Server/test/test.mp3",0,FALSE},
4212     {"C:/test/test.mp3",Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME,FALSE},
4213     {"\\\\Server/test/test.mp3",Uri_CREATE_ALLOW_RELATIVE,FALSE},
4214     /* Invalid schemes. */
4215     {"*abcd://not.valid.com",0,FALSE},
4216     {"*a*b*c*d://not.valid.com",0,FALSE},
4217     /* Not allowed to have invalid % encoded data. */
4218     {"ftp://google.co%XX/",0,FALSE},
4219     /* To many h16 components. */
4220     {"http://[1:2:3:4:5:6:7:8:9]",0,FALSE},
4221     /* Not enough room for IPv4 address. */
4222     {"http://[1:2:3:4:5:6:7:192.0.1.0]",0,FALSE},
4223     /* Not enough h16 components. */
4224     {"http://[1:2:3:4]",0,FALSE},
4225     /* Not enough components including IPv4. */
4226     {"http://[1:192.0.1.0]",0,FALSE},
4227     /* Not allowed to have partial IPv4 in IPv6. */
4228     {"http://[::192.0]",0,FALSE},
4229     /* Can't have elision of 1 h16 at beginning of address. */
4230     {"http://[::2:3:4:5:6:7:8]",0,FALSE},
4231     /* Can't have elision of 1 h16 at end of address. */
4232     {"http://[1:2:3:4:5:6:7::]",0,FALSE},
4233     /* Expects a valid IP Literal. */
4234     {"ftp://[not.valid.uri]/",0,FALSE},
4235     /* Expects valid port for a known scheme type. */
4236     {"ftp://www.winehq.org:123fgh",0,FALSE},
4237     /* Port exceeds USHORT_MAX for known scheme type. */
4238     {"ftp://www.winehq.org:65536",0,FALSE},
4239     /* Invalid port with IPv4 address. */
4240     {"http://www.winehq.org:1abcd",0,FALSE},
4241     /* Invalid port with IPv6 address. */
4242     {"http://[::ffff]:32xy",0,FALSE},
4243     /* Not allowed to have backslashes with NO_CANONICALIZE. */
4244     {"gopher://www.google.com\\test",Uri_CREATE_NO_CANONICALIZE,FALSE},
4245     /* Not allowed to have invalid % encoded data in opaque URI path. */
4246     {"news:test%XX",0,FALSE},
4247     {"mailto:wine@winehq%G8.com",0,FALSE},
4248     /* Known scheme types can't have invalid % encoded data in query string. */
4249     {"http://google.com/?query=te%xx",0,FALSE},
4250     /* Invalid % encoded data in fragment of know scheme type. */
4251     {"ftp://google.com/#Test%xx",0,FALSE},
4252     {"  http://google.com/",Uri_CREATE_NO_PRE_PROCESS_HTML_URI,FALSE},
4253     {"\n\nhttp://google.com/",Uri_CREATE_NO_PRE_PROCESS_HTML_URI,FALSE},
4254     {"file://c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4255     {"file://c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4256     {"file://c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4257     {"file:c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4258     {"file:c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4259     {"file:c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4260     /* res URIs aren't allowed to have forbidden dos path characters in the
4261      * hostname.
4262      */
4263     {"res://c:\\te<st\\test/test",0,FALSE},
4264     {"res://c:\\te>st\\test/test",0,FALSE},
4265     {"res://c:\\te\"st\\test/test",0,FALSE},
4266     {"res://c:\\test/te%xxst",0,FALSE}
4267 };
4268
4269 typedef struct _uri_equality {
4270     const char* a;
4271     DWORD       create_flags_a;
4272     BOOL        create_todo_a;
4273     const char* b;
4274     DWORD       create_flags_b;
4275     BOOL        create_todo_b;
4276     BOOL        equal;
4277     BOOL        todo;
4278 } uri_equality;
4279
4280 static const uri_equality equality_tests[] = {
4281     {
4282         "HTTP://www.winehq.org/test dir/./",0,FALSE,
4283         "http://www.winehq.org/test dir/../test dir/",0,FALSE,
4284         TRUE, FALSE
4285     },
4286     {
4287         /* http://www.winehq.org/test%20dir */
4288         "http://%77%77%77%2E%77%69%6E%65%68%71%2E%6F%72%67/%74%65%73%74%20%64%69%72",0,FALSE,
4289         "http://www.winehq.org/test dir",0,FALSE,
4290         TRUE, FALSE
4291     },
4292     {
4293         "c:\\test.mp3",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME,FALSE,
4294         "file:///c:/test.mp3",0,FALSE,
4295         TRUE, FALSE
4296     },
4297     {
4298         "ftp://ftp.winehq.org/",0,FALSE,
4299         "ftp://ftp.winehq.org",0,FALSE,
4300         TRUE, FALSE
4301     },
4302     {
4303         "ftp://ftp.winehq.org/test/test2/../../testB/",0,FALSE,
4304         "ftp://ftp.winehq.org/t%45stB/",0,FALSE,
4305         FALSE, FALSE
4306     },
4307     {
4308         "http://google.com/TEST",0,FALSE,
4309         "http://google.com/test",0,FALSE,
4310         FALSE, FALSE
4311     },
4312     {
4313         "http://GOOGLE.com/",0,FALSE,
4314         "http://google.com/",0,FALSE,
4315         TRUE, FALSE
4316     },
4317     /* Performs case insensitive compare of host names (for known scheme types). */
4318     {
4319         "ftp://GOOGLE.com/",Uri_CREATE_NO_CANONICALIZE,FALSE,
4320         "ftp://google.com/",0,FALSE,
4321         TRUE, FALSE
4322     },
4323     {
4324         "zip://GOOGLE.com/",0,FALSE,
4325         "zip://google.com/",0,FALSE,
4326         FALSE, FALSE
4327     },
4328     {
4329         "file:///c:/TEST/TeST/",0,FALSE,
4330         "file:///c:/test/test/",0,FALSE,
4331         TRUE, FALSE
4332     },
4333     {
4334         "file:///server/TEST",0,FALSE,
4335         "file:///SERVER/TEST",0,FALSE,
4336         TRUE, FALSE
4337     },
4338     {
4339         "http://google.com",Uri_CREATE_NO_CANONICALIZE,FALSE,
4340         "http://google.com/",0,FALSE,
4341         TRUE, FALSE
4342     },
4343     {
4344         "ftp://google.com:21/",0,FALSE,
4345         "ftp://google.com/",0,FALSE,
4346         TRUE, FALSE
4347     },
4348     {
4349         "http://google.com:80/",Uri_CREATE_NO_CANONICALIZE,FALSE,
4350         "http://google.com/",0,FALSE,
4351         TRUE, FALSE
4352     },
4353     {
4354         "http://google.com:70/",0,FALSE,
4355         "http://google.com:71/",0,FALSE,
4356         FALSE, FALSE
4357     }
4358 };
4359
4360 typedef struct _uri_with_fragment {
4361     const char* uri;
4362     const char* fragment;
4363     DWORD       create_flags;
4364     HRESULT     create_expected;
4365     BOOL        create_todo;
4366
4367     const char* expected_uri;
4368     BOOL        expected_todo;
4369 } uri_with_fragment;
4370
4371 static const uri_with_fragment uri_fragment_tests[] = {
4372     {
4373         "http://google.com/","#fragment",0,S_OK,FALSE,
4374         "http://google.com/#fragment",FALSE
4375     },
4376     {
4377         "http://google.com/","fragment",0,S_OK,FALSE,
4378         "http://google.com/#fragment",FALSE
4379     },
4380     {
4381         "zip://test.com/","?test",0,S_OK,FALSE,
4382         "zip://test.com/#?test",FALSE
4383     },
4384     /* The fragment can be empty. */
4385     {
4386         "ftp://ftp.google.com/","",0,S_OK,FALSE,
4387         "ftp://ftp.google.com/#",FALSE
4388     }
4389 };
4390
4391 typedef struct _uri_builder_property {
4392     BOOL            change;
4393     const char      *value;
4394     const char      *expected_value;
4395     Uri_PROPERTY    property;
4396     HRESULT         expected;
4397     BOOL            todo;
4398 } uri_builder_property;
4399
4400 typedef struct _uri_builder_port {
4401     BOOL    change;
4402     BOOL    set;
4403     DWORD   value;
4404     HRESULT expected;
4405     BOOL    todo;
4406 } uri_builder_port;
4407
4408 typedef struct _uri_builder_str_property {
4409     const char* expected;
4410     HRESULT     result;
4411     BOOL        todo;
4412 } uri_builder_str_property;
4413
4414 typedef struct _uri_builder_dword_property {
4415     DWORD   expected;
4416     HRESULT result;
4417     BOOL    todo;
4418 } uri_builder_dword_property;
4419
4420 typedef struct _uri_builder_test {
4421     const char                  *uri;
4422     DWORD                       create_flags;
4423     HRESULT                     create_builder_expected;
4424     BOOL                        create_builder_todo;
4425
4426     uri_builder_property        properties[URI_BUILDER_STR_PROPERTY_COUNT];
4427
4428     uri_builder_port            port_prop;
4429
4430     DWORD                       uri_flags;
4431     HRESULT                     uri_hres;
4432     BOOL                        uri_todo;
4433
4434     DWORD                       uri_simple_encode_flags;
4435     HRESULT                     uri_simple_hres;
4436     BOOL                        uri_simple_todo;
4437
4438     DWORD                       uri_with_flags;
4439     DWORD                       uri_with_builder_flags;
4440     DWORD                       uri_with_encode_flags;
4441     HRESULT                     uri_with_hres;
4442     BOOL                        uri_with_todo;
4443
4444     uri_builder_str_property    expected_str_props[URI_STR_PROPERTY_COUNT];
4445     uri_builder_dword_property  expected_dword_props[URI_DWORD_PROPERTY_COUNT];
4446 } uri_builder_test;
4447
4448 static const uri_builder_test uri_builder_tests[] = {
4449     {   "http://google.com/",0,S_OK,FALSE,
4450         {
4451             {TRUE,"#fragment",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4452             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE},
4453             {TRUE,"?query=x",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE},
4454             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4455         },
4456         {FALSE},
4457         0,S_OK,FALSE,
4458         0,S_OK,FALSE,
4459         0,0,0,S_OK,FALSE,
4460         {
4461             {"http://username:password@google.com/?query=x#fragment",S_OK},
4462             {"username:password@google.com",S_OK},
4463             {"http://google.com/?query=x#fragment",S_OK},
4464             {"google.com",S_OK},
4465             {"",S_FALSE},
4466             {"#fragment",S_OK},
4467             {"google.com",S_OK},
4468             {"password",S_OK},
4469             {"/",S_OK},
4470             {"/?query=x",S_OK},
4471             {"?query=x",S_OK},
4472             {"http://username:password@google.com/?query=x#fragment",S_OK},
4473             {"http",S_OK},
4474             {"username:password",S_OK},
4475             {"username",S_OK}
4476         },
4477         {
4478             {Uri_HOST_DNS,S_OK},
4479             {80,S_OK},
4480             {URL_SCHEME_HTTP,S_OK},
4481             {URLZONE_INVALID,E_NOTIMPL}
4482         }
4483     },
4484     {   "http://google.com/",0,S_OK,FALSE,
4485         {
4486             {TRUE,"test",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
4487         },
4488         {TRUE,TRUE,120,S_OK,FALSE},
4489         0,S_OK,FALSE,
4490         0,S_OK,FALSE,
4491         0,0,0,S_OK,FALSE,
4492         {
4493             {"test://google.com:120/",S_OK},
4494             {"google.com:120",S_OK},
4495             {"test://google.com:120/",S_OK},
4496             {"google.com",S_OK},
4497             {"",S_FALSE},
4498             {"",S_FALSE},
4499             {"google.com",S_OK},
4500             {"",S_FALSE},
4501             {"/",S_OK},
4502             {"/",S_OK},
4503             {"",S_FALSE},
4504             {"test://google.com:120/",S_OK},
4505             {"test",S_OK},
4506             {"",S_FALSE},
4507             {"",S_FALSE}
4508         },
4509         {
4510             {Uri_HOST_DNS,S_OK},
4511             {120,S_OK},
4512             {URL_SCHEME_UNKNOWN,S_OK},
4513             {URLZONE_INVALID,E_NOTIMPL}
4514         }
4515     },
4516     {   "/Test/test dir",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4517         {
4518             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
4519             {TRUE,"::192.2.3.4",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
4520             {TRUE,NULL,NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
4521         },
4522         {FALSE},
4523         0,S_OK,FALSE,
4524         0,S_OK,FALSE,
4525         0,0,0,S_OK,FALSE,
4526         {
4527             {"http://[::192.2.3.4]/",S_OK},
4528             {"[::192.2.3.4]",S_OK},
4529             {"http://[::192.2.3.4]/",S_OK},
4530             {"",S_FALSE},
4531             {"",S_FALSE},
4532             {"",S_FALSE},
4533             {"::192.2.3.4",S_OK},
4534             {"",S_FALSE},
4535             {"/",S_OK},
4536             {"/",S_OK},
4537             {"",S_FALSE},
4538             {"http://[::192.2.3.4]/",S_OK},
4539             {"http",S_OK},
4540             {"",S_FALSE},
4541             {"",S_FALSE}
4542         },
4543         {
4544             {Uri_HOST_IPV6,S_OK},
4545             {80,S_OK},
4546             {URL_SCHEME_HTTP,S_OK},
4547             {URLZONE_INVALID,E_NOTIMPL}
4548         }
4549     },
4550     {   "http://google.com/",0,S_OK,FALSE,
4551         {
4552             {TRUE,"Frag","#Frag",Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4553         },
4554         {FALSE},
4555         0,S_OK,FALSE,
4556         0,S_OK,FALSE,
4557         0,0,0,S_OK,FALSE,
4558         {
4559             {"http://google.com/#Frag",S_OK},
4560             {"google.com",S_OK},
4561             {"http://google.com/#Frag",S_OK},
4562             {"google.com",S_OK},
4563             {"",S_FALSE},
4564             {"#Frag",S_OK},
4565             {"google.com",S_OK},
4566             {"",S_FALSE},
4567             {"/",S_OK},
4568             {"/",S_OK},
4569             {"",S_FALSE},
4570             {"http://google.com/#Frag",S_OK},
4571             {"http",S_OK},
4572             {"",S_FALSE},
4573             {"",S_FALSE}
4574         },
4575         {
4576             {Uri_HOST_DNS,S_OK},
4577             {80,S_OK},
4578             {URL_SCHEME_HTTP,S_OK},
4579             {URLZONE_INVALID,E_NOTIMPL}
4580         }
4581     },
4582     {   "http://google.com/",0,S_OK,FALSE,
4583         {
4584             {TRUE,"","#",Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4585         },
4586         {FALSE},
4587         0,S_OK,FALSE,
4588         0,S_OK,FALSE,
4589         0,0,0,S_OK,FALSE,
4590         {
4591             {"http://google.com/#",S_OK},
4592             {"google.com",S_OK},
4593             {"http://google.com/#",S_OK},
4594             {"google.com",S_OK},
4595             {"",S_FALSE},
4596             {"#",S_OK},
4597             {"google.com",S_OK},
4598             {"",S_FALSE},
4599             {"/",S_OK},
4600             {"/",S_OK},
4601             {"",S_FALSE},
4602             {"http://google.com/#",S_OK},
4603             {"http",S_OK},
4604             {"",S_FALSE},
4605             {"",S_FALSE}
4606         },
4607         {
4608             {Uri_HOST_DNS,S_OK},
4609             {80,S_OK},
4610             {URL_SCHEME_HTTP,S_OK},
4611             {URLZONE_INVALID,E_NOTIMPL}
4612         }
4613     },
4614     {   "http://google.com/",0,S_OK,FALSE,
4615         {
4616             {TRUE,":password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4617         },
4618         {FALSE},
4619         0,S_OK,FALSE,
4620         0,S_OK,FALSE,
4621         0,0,0,S_OK,FALSE,
4622         {
4623             {"http://::password@google.com/",S_OK},
4624             {"::password@google.com",S_OK},
4625             {"http://google.com/",S_OK},
4626             {"google.com",S_OK},
4627             {"",S_FALSE},
4628             {"",S_FALSE},
4629             {"google.com",S_OK},
4630             {":password",S_OK},
4631             {"/",S_OK},
4632             {"/",S_OK},
4633             {"",S_FALSE},
4634             {"http://::password@google.com/",S_OK},
4635             {"http",S_OK},
4636             {"::password",S_OK},
4637             {"",S_FALSE}
4638         },
4639         {
4640             {Uri_HOST_DNS,S_OK},
4641             {80,S_OK},
4642             {URL_SCHEME_HTTP,S_OK},
4643             {URLZONE_INVALID,E_NOTIMPL}
4644         }
4645     },
4646     {   "test/test",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4647         {
4648             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4649         },
4650         {FALSE},
4651         Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4652         0,S_OK,FALSE,
4653         Uri_CREATE_ALLOW_RELATIVE,0,0,S_OK,FALSE,
4654         {
4655             {":password@test/test",S_OK},
4656             {":password@",S_OK},
4657             {":password@test/test",S_OK},
4658             {"",S_FALSE},
4659             {"",S_FALSE},
4660             {"",S_FALSE},
4661             {"",S_FALSE},
4662             {"password",S_OK},
4663             {"test/test",S_OK},
4664             {"test/test",S_OK},
4665             {"",S_FALSE},
4666             {":password@test/test",S_OK},
4667             {"",S_FALSE},
4668             {":password",S_OK},
4669             {"",S_FALSE}
4670         },
4671         {
4672             {Uri_HOST_UNKNOWN,S_OK},
4673             {0,S_FALSE},
4674             {URL_SCHEME_UNKNOWN,S_OK},
4675             {URLZONE_INVALID,E_NOTIMPL}
4676         }
4677     },
4678     {   "http://google.com/",0,S_OK,FALSE,
4679         {
4680             {TRUE,"test/test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4681         },
4682         {FALSE},
4683         0,S_OK,FALSE,
4684         0,S_OK,FALSE,
4685         0,0,0,S_OK,FALSE,
4686         {
4687             {"http://google.com/test/test",S_OK},
4688             {"google.com",S_OK},
4689             {"http://google.com/test/test",S_OK},
4690             {"google.com",S_OK},
4691             {"",S_FALSE},
4692             {"",S_FALSE},
4693             {"google.com",S_OK},
4694             {"",S_FALSE},
4695             {"/test/test",S_OK},
4696             {"/test/test",S_OK},
4697             {"",S_FALSE},
4698             {"http://google.com/test/test",S_OK},
4699             {"http",S_OK},
4700             {"",S_FALSE},
4701             {"",S_FALSE}
4702         },
4703         {
4704             {Uri_HOST_DNS,S_OK},
4705             {80,S_OK},
4706             {URL_SCHEME_HTTP,S_OK},
4707             {URLZONE_INVALID,E_NOTIMPL}
4708         }
4709     },
4710     {   "zip:testing/test",0,S_OK,FALSE,
4711         {
4712             {TRUE,"test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4713         },
4714         {FALSE},
4715         0,S_OK,FALSE,
4716         0,S_OK,FALSE,
4717         0,0,0,S_OK,FALSE,
4718         {
4719             {"zip:test",S_OK},
4720             {"",S_FALSE},
4721             {"zip:test",S_OK},
4722             {"",S_FALSE},
4723             {"",S_FALSE},
4724             {"",S_FALSE},
4725             {"",S_FALSE},
4726             {"",S_FALSE},
4727             {"test",S_OK},
4728             {"test",S_OK},
4729             {"",S_FALSE},
4730             {"zip:test",S_OK},
4731             {"zip",S_OK},
4732             {"",S_FALSE},
4733             {"",S_FALSE}
4734         },
4735         {
4736             {Uri_HOST_UNKNOWN,S_OK},
4737             {0,S_FALSE},
4738             {URL_SCHEME_UNKNOWN,S_OK},
4739             {URLZONE_INVALID,E_NOTIMPL}
4740         }
4741     },
4742     {   "http://google.com/",0,S_OK,FALSE,
4743         {
4744             {FALSE},
4745         },
4746         /* 555 will be returned from GetPort even though FALSE was passed as the hasPort parameter. */
4747         {TRUE,FALSE,555,S_OK,FALSE},
4748         0,S_OK,FALSE,
4749         0,S_OK,FALSE,
4750         0,0,0,S_OK,FALSE,
4751         {
4752             {"http://google.com/",S_OK},
4753             {"google.com",S_OK},
4754             {"http://google.com/",S_OK},
4755             {"google.com",S_OK},
4756             {"",S_FALSE},
4757             {"",S_FALSE},
4758             {"google.com",S_OK},
4759             {"",S_FALSE},
4760             {"/",S_OK},
4761             {"/",S_OK},
4762             {"",S_FALSE},
4763             {"http://google.com/",S_OK},
4764             {"http",S_OK},
4765             {"",S_FALSE},
4766             {"",S_FALSE}
4767         },
4768         {
4769             {Uri_HOST_DNS,S_OK},
4770             /* Still returns 80, even though earlier the port was disabled. */
4771             {80,S_OK},
4772             {URL_SCHEME_HTTP,S_OK},
4773             {URLZONE_INVALID,E_NOTIMPL}
4774         }
4775     },
4776     {   "http://google.com/",0,S_OK,FALSE,
4777         {
4778             {FALSE},
4779         },
4780         /* Instead of getting "TRUE" back as the "hasPort" parameter in GetPort,
4781          * you'll get 122345 instead.
4782          */
4783         {TRUE,122345,222,S_OK,FALSE},
4784         0,S_OK,FALSE,
4785         0,S_OK,FALSE,
4786         0,0,0,S_OK,FALSE,
4787         {
4788             {"http://google.com:222/",S_OK},
4789             {"google.com:222",S_OK},
4790             {"http://google.com:222/",S_OK},
4791             {"google.com",S_OK},
4792             {"",S_FALSE},
4793             {"",S_FALSE},
4794             {"google.com",S_OK},
4795             {"",S_FALSE},
4796             {"/",S_OK},
4797             {"/",S_OK},
4798             {"",S_FALSE},
4799             {"http://google.com:222/",S_OK},
4800             {"http",S_OK},
4801             {"",S_FALSE},
4802             {"",S_FALSE}
4803         },
4804         {
4805             {Uri_HOST_DNS,S_OK},
4806             {222,S_OK},
4807             {URL_SCHEME_HTTP,S_OK},
4808             {URLZONE_INVALID,E_NOTIMPL}
4809         }
4810     },
4811     /* IUri's created with the IUriBuilder can have ports that exceed USHORT_MAX. */
4812     {   "http://google.com/",0,S_OK,FALSE,
4813         {
4814             {FALSE},
4815         },
4816         {TRUE,TRUE,999999,S_OK,FALSE},
4817         0,S_OK,FALSE,
4818         0,S_OK,FALSE,
4819         0,0,0,S_OK,FALSE,
4820         {
4821             {"http://google.com:999999/",S_OK},
4822             {"google.com:999999",S_OK},
4823             {"http://google.com:999999/",S_OK},
4824             {"google.com",S_OK},
4825             {"",S_FALSE},
4826             {"",S_FALSE},
4827             {"google.com",S_OK},
4828             {"",S_FALSE},
4829             {"/",S_OK},
4830             {"/",S_OK},
4831             {"",S_FALSE},
4832             {"http://google.com:999999/",S_OK},
4833             {"http",S_OK},
4834             {"",S_FALSE},
4835             {"",S_FALSE}
4836         },
4837         {
4838             {Uri_HOST_DNS,S_OK},
4839             {999999,S_OK},
4840             {URL_SCHEME_HTTP,S_OK},
4841             {URLZONE_INVALID,E_NOTIMPL}
4842         }
4843     },
4844     {   "http://google.com/",0,S_OK,FALSE,
4845         {
4846             {TRUE,"test","?test",Uri_PROPERTY_QUERY,S_OK,FALSE},
4847         },
4848
4849         {FALSE},
4850         0,S_OK,FALSE,
4851         0,S_OK,FALSE,
4852         0,0,0,S_OK,FALSE,
4853         {
4854             {"http://google.com/?test",S_OK},
4855             {"google.com",S_OK},
4856             {"http://google.com/?test",S_OK},
4857             {"google.com",S_OK},
4858             {"",S_FALSE},
4859             {"",S_FALSE},
4860             {"google.com",S_OK},
4861             {"",S_FALSE},
4862             {"/",S_OK},
4863             {"/?test",S_OK},
4864             {"?test",S_OK},
4865             {"http://google.com/?test",S_OK},
4866             {"http",S_OK},
4867             {"",S_FALSE},
4868             {"",S_FALSE}
4869         },
4870         {
4871             {Uri_HOST_DNS,S_OK},
4872             {80,S_OK},
4873             {URL_SCHEME_HTTP,S_OK},
4874             {URLZONE_INVALID,E_NOTIMPL}
4875         }
4876     },
4877     {   "http://:password@google.com/",0,S_OK,FALSE,
4878         {
4879             {FALSE},
4880         },
4881         {FALSE},
4882         0,S_OK,FALSE,
4883         0,S_OK,FALSE,
4884         0,0,0,S_OK,FALSE,
4885         {
4886             {"http://:password@google.com/",S_OK},
4887             {":password@google.com",S_OK},
4888             {"http://google.com/",S_OK},
4889             {"google.com",S_OK},
4890             {"",S_FALSE},
4891             {"",S_FALSE},
4892             {"google.com",S_OK},
4893             {"password",S_OK},
4894             {"/",S_OK},
4895             {"/",S_OK},
4896             {"",S_FALSE},
4897             {"http://:password@google.com/",S_OK},
4898             {"http",S_OK},
4899             {":password",S_OK},
4900             {"",S_FALSE}
4901         },
4902         {
4903             {Uri_HOST_DNS,S_OK},
4904             {80,S_OK},
4905             {URL_SCHEME_HTTP,S_OK},
4906             {URLZONE_INVALID,E_NOTIMPL}
4907         }
4908     },
4909     /* IUriBuilder doesn't need a base IUri to build a IUri. */
4910     {   NULL,0,S_OK,FALSE,
4911         {
4912             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
4913             {TRUE,"google.com",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
4914         },
4915         {FALSE},
4916         0,S_OK,FALSE,
4917         0,S_OK,FALSE,
4918         0,0,0,S_OK,FALSE,
4919         {
4920             {"http://google.com/",S_OK},
4921             {"google.com",S_OK},
4922             {"http://google.com/",S_OK},
4923             {"google.com",S_OK},
4924             {"",S_FALSE},
4925             {"",S_FALSE},
4926             {"google.com",S_OK},
4927             {"",S_FALSE},
4928             {"/",S_OK},
4929             {"/",S_OK},
4930             {"",S_FALSE},
4931             {"http://google.com/",S_OK},
4932             {"http",S_OK},
4933             {"",S_FALSE},
4934             {"",S_FALSE}
4935         },
4936         {
4937             {Uri_HOST_DNS,S_OK},
4938             {80,S_OK},
4939             {URL_SCHEME_HTTP,S_OK},
4940             {URLZONE_INVALID,E_NOTIMPL}
4941         }
4942     },
4943     /* Can't set the scheme name to NULL. */
4944     {   "zip://google.com/",0,S_OK,FALSE,
4945         {
4946             {TRUE,NULL,"zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
4947         },
4948         {FALSE},
4949         0,S_OK,FALSE,
4950         0,S_OK,FALSE,
4951         0,0,0,S_OK,FALSE,
4952         {
4953             {"zip://google.com/",S_OK},
4954             {"google.com",S_OK},
4955             {"zip://google.com/",S_OK},
4956             {"google.com",S_OK},
4957             {"",S_FALSE},
4958             {"",S_FALSE},
4959             {"google.com",S_OK},
4960             {"",S_FALSE},
4961             {"/",S_OK},
4962             {"/",S_OK},
4963             {"",S_FALSE},
4964             {"zip://google.com/",S_OK},
4965             {"zip",S_OK},
4966             {"",S_FALSE},
4967             {"",S_FALSE}
4968         },
4969         {
4970             {Uri_HOST_DNS,S_OK},
4971             {0,S_FALSE},
4972             {URL_SCHEME_UNKNOWN,S_OK},
4973             {URLZONE_INVALID,E_NOTIMPL}
4974         }
4975     },
4976     /* Can't set the scheme name to an empty string. */
4977     {   "zip://google.com/",0,S_OK,FALSE,
4978         {
4979             {TRUE,"","zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
4980         },
4981         {FALSE},
4982         0,S_OK,FALSE,
4983         0,S_OK,FALSE,
4984         0,0,0,S_OK,FALSE,
4985         {
4986             {"zip://google.com/",S_OK},
4987             {"google.com",S_OK},
4988             {"zip://google.com/",S_OK},
4989             {"google.com",S_OK},
4990             {"",S_FALSE},
4991             {"",S_FALSE},
4992             {"google.com",S_OK},
4993             {"",S_FALSE},
4994             {"/",S_OK},
4995             {"/",S_OK},
4996             {"",S_FALSE},
4997             {"zip://google.com/",S_OK},
4998             {"zip",S_OK},
4999             {"",S_FALSE},
5000             {"",S_FALSE}
5001         },
5002         {
5003             {Uri_HOST_DNS,S_OK},
5004             {0,S_FALSE},
5005             {URL_SCHEME_UNKNOWN,S_OK},
5006             {URLZONE_INVALID,E_NOTIMPL}
5007         }
5008     },
5009     /* -1 to CreateUri makes it use the same flags as the base IUri was created with.
5010      * CreateUriSimple always uses the flags the base IUri was created with (if any).
5011      */
5012     {   "http://google.com/../../",Uri_CREATE_NO_CANONICALIZE,S_OK,FALSE,
5013         {{FALSE}},
5014         {FALSE},
5015         -1,S_OK,FALSE,
5016         0,S_OK,FALSE,
5017         0,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5018         {
5019             {"http://google.com/../../",S_OK},
5020             {"google.com",S_OK},
5021             {"http://google.com/../../",S_OK},
5022             {"google.com",S_OK},
5023             {"",S_FALSE},
5024             {"",S_FALSE},
5025             {"google.com",S_OK},
5026             {"",S_FALSE},
5027             {"/../../",S_OK},
5028             {"/../../",S_OK},
5029             {"",S_FALSE},
5030             {"http://google.com/../../",S_OK},
5031             {"http",S_OK},
5032             {"",S_FALSE},
5033             {"",S_FALSE}
5034         },
5035         {
5036             {Uri_HOST_DNS,S_OK},
5037             {80,S_OK},
5038             {URL_SCHEME_HTTP,S_OK},
5039             {URLZONE_INVALID,E_NOTIMPL}
5040         }
5041     },
5042     {   "http://google.com/",0,S_OK,FALSE,
5043         {
5044             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5045         },
5046         {FALSE},
5047         -1,S_OK,FALSE,
5048         0,S_OK,FALSE,
5049         Uri_CREATE_NO_DECODE_EXTRA_INFO,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5050         {
5051             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5052             {"google.com",S_OK},
5053             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5054             {"google.com",S_OK},
5055             {"",S_FALSE},
5056             {"#Fr%3C%7C%3Eg",S_OK},
5057             {"google.com",S_OK},
5058             {"",S_FALSE},
5059             {"/",S_OK},
5060             {"/",S_OK},
5061             {"",S_FALSE},
5062             {"http://google.com/#Fr<|>g",S_OK},
5063             {"http",S_OK},
5064             {"",S_FALSE},
5065             {"",S_FALSE}
5066         },
5067         {
5068             {Uri_HOST_DNS,S_OK},
5069             {80,S_OK},
5070             {URL_SCHEME_HTTP,S_OK},
5071             {URLZONE_INVALID,E_NOTIMPL}
5072         }
5073     },
5074     {   "http://google.com/",0,S_OK,FALSE,
5075         {
5076             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5077         },
5078         {FALSE},
5079         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,E_INVALIDARG,FALSE,
5080         0,S_OK,FALSE,
5081         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5082         {
5083             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5084             {"google.com",S_OK},
5085             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5086             {"google.com",S_OK},
5087             {"",S_FALSE},
5088             {"#Fr%3C%7C%3Eg",S_OK},
5089             {"google.com",S_OK},
5090             {"",S_FALSE},
5091             {"/",S_OK},
5092             {"/",S_OK},
5093             {"",S_FALSE},
5094             {"http://google.com/#Fr<|>g",S_OK},
5095             {"http",S_OK},
5096             {"",S_FALSE},
5097             {"",S_FALSE}
5098         },
5099         {
5100             {Uri_HOST_DNS,S_OK},
5101             {80,S_OK},
5102             {URL_SCHEME_HTTP,S_OK},
5103             {URLZONE_INVALID,E_NOTIMPL}
5104         }
5105     },
5106     {   NULL,0,S_OK,FALSE,
5107         {
5108             {TRUE,"/test/test/",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
5109             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5110         },
5111         {FALSE},
5112         0,INET_E_INVALID_URL,FALSE,
5113         0,INET_E_INVALID_URL,FALSE,
5114         0,0,0,INET_E_INVALID_URL,FALSE
5115     },
5116     {   "http://google.com/",0,S_OK,FALSE,
5117         {
5118             {TRUE,"ht%xxtp",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
5119         },
5120         {FALSE},
5121         0,INET_E_INVALID_URL,FALSE,
5122         0,INET_E_INVALID_URL,FALSE,
5123         0,0,0,INET_E_INVALID_URL,FALSE
5124     },
5125     /* File scheme's can't have a username set. */
5126     {   "file://google.com/",0,S_OK,FALSE,
5127         {
5128             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5129         },
5130         {FALSE},
5131         0,INET_E_INVALID_URL,FALSE,
5132         0,INET_E_INVALID_URL,FALSE,
5133         0,0,0,INET_E_INVALID_URL,FALSE
5134     },
5135     /* File schemes can't have a password set. */
5136     {   "file://google.com/",0,S_OK,FALSE,
5137         {
5138             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5139         },
5140         {FALSE},
5141         0,INET_E_INVALID_URL,FALSE,
5142         0,INET_E_INVALID_URL,FALSE,
5143         0,0,0,INET_E_INVALID_URL,FALSE
5144     },
5145     /* UserName can't contain any character that is a delimeter for another
5146      * component that appears after it in a normal URI.
5147      */
5148     {   "http://google.com/",0,S_OK,FALSE,
5149         {
5150             {TRUE,"user:pass",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5151         },
5152         {FALSE},
5153         0,INET_E_INVALID_URL,FALSE,
5154         0,INET_E_INVALID_URL,FALSE,
5155         0,0,0,INET_E_INVALID_URL,FALSE
5156     },
5157     {   "http://google.com/",0,S_OK,FALSE,
5158         {
5159             {TRUE,"user@google.com",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5160         },
5161         {FALSE},
5162         0,INET_E_INVALID_URL,FALSE,
5163         0,INET_E_INVALID_URL,FALSE,
5164         0,0,0,INET_E_INVALID_URL,FALSE
5165     },
5166     {   "http://google.com/",0,S_OK,FALSE,
5167         {
5168             {TRUE,"user/path",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5169         },
5170         {FALSE},
5171         0,INET_E_INVALID_URL,FALSE,
5172         0,INET_E_INVALID_URL,FALSE,
5173         0,0,0,INET_E_INVALID_URL,FALSE
5174     },
5175     {   "http://google.com/",0,S_OK,FALSE,
5176         {
5177             {TRUE,"user?Query",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5178         },
5179         {FALSE},
5180         0,INET_E_INVALID_URL,FALSE,
5181         0,INET_E_INVALID_URL,FALSE,
5182         0,0,0,INET_E_INVALID_URL,FALSE
5183     },
5184     {   "http://google.com/",0,S_OK,FALSE,
5185         {
5186             {TRUE,"user#Frag",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5187         },
5188         {FALSE},
5189         0,INET_E_INVALID_URL,FALSE,
5190         0,INET_E_INVALID_URL,FALSE,
5191         0,0,0,INET_E_INVALID_URL,FALSE
5192     },
5193     {   "http://google.com/",0,S_OK,FALSE,
5194         {
5195             {TRUE,"pass@google.com",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5196         },
5197         {FALSE},
5198         0,INET_E_INVALID_URL,FALSE,
5199         0,INET_E_INVALID_URL,FALSE,
5200         0,0,0,INET_E_INVALID_URL,FALSE
5201     },
5202     {   "http://google.com/",0,S_OK,FALSE,
5203         {
5204             {TRUE,"pass/path",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5205         },
5206         {FALSE},
5207         0,INET_E_INVALID_URL,FALSE,
5208         0,INET_E_INVALID_URL,FALSE,
5209         0,0,0,INET_E_INVALID_URL,FALSE
5210     },
5211     {   "http://google.com/",0,S_OK,FALSE,
5212         {
5213             {TRUE,"pass?query",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5214         },
5215         {FALSE},
5216         0,INET_E_INVALID_URL,FALSE,
5217         0,INET_E_INVALID_URL,FALSE,
5218        0,0,0,INET_E_INVALID_URL,FALSE
5219     },
5220     {   "http://google.com/",0,S_OK,FALSE,
5221         {
5222             {TRUE,"pass#frag",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5223         },
5224         {FALSE},
5225         0,INET_E_INVALID_URL,FALSE,
5226         0,INET_E_INVALID_URL,FALSE,
5227         0,0,0,INET_E_INVALID_URL,FALSE
5228     },
5229     {   "http://google.com/",0,S_OK,FALSE,
5230         {
5231             {TRUE,"winehq.org/test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5232         },
5233         {FALSE},
5234         0,INET_E_INVALID_URL,FALSE,
5235         0,INET_E_INVALID_URL,FALSE,
5236         0,0,0,INET_E_INVALID_URL,FALSE
5237     },
5238     {   "http://google.com/",0,S_OK,FALSE,
5239         {
5240             {TRUE,"winehq.org?test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5241         },
5242         {FALSE},
5243         0,INET_E_INVALID_URL,FALSE,
5244         0,INET_E_INVALID_URL,FALSE,
5245         0,0,0,INET_E_INVALID_URL,FALSE
5246     },
5247     {   "http://google.com/",0,S_OK,FALSE,
5248         {
5249             {TRUE,"winehq.org#test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5250         },
5251         {FALSE},
5252         0,INET_E_INVALID_URL,FALSE,
5253         0,INET_E_INVALID_URL,FALSE,
5254         0,0,0,INET_E_INVALID_URL,FALSE
5255     },
5256     /* Hostname is allowed to contain a ':' (even for known scheme types). */
5257     {   "http://google.com/",0,S_OK,FALSE,
5258         {
5259             {TRUE,"winehq.org:test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
5260         },
5261         {FALSE},
5262         0,S_OK,FALSE,
5263         0,S_OK,FALSE,
5264         0,0,0,S_OK,FALSE,
5265         {
5266             {"http://winehq.org:test/",S_OK},
5267             {"winehq.org:test",S_OK},
5268             {"http://winehq.org:test/",S_OK},
5269             {"winehq.org:test",S_OK},
5270             {"",S_FALSE},
5271             {"",S_FALSE},
5272             {"winehq.org:test",S_OK},
5273             {"",S_FALSE},
5274             {"/",S_OK},
5275             {"/",S_OK},
5276             {"",S_FALSE},
5277             {"http://winehq.org:test/",S_OK},
5278             {"http",S_OK},
5279             {"",S_FALSE},
5280             {"",S_FALSE}
5281         },
5282         {
5283             {Uri_HOST_DNS,S_OK},
5284             {80,S_OK},
5285             {URL_SCHEME_HTTP,S_OK},
5286             {URLZONE_INVALID,E_NOTIMPL}
5287         }
5288     },
5289     /* Can't set the host name to NULL. */
5290     {   "http://google.com/",0,S_OK,FALSE,
5291         {
5292             {TRUE,NULL,"google.com",Uri_PROPERTY_HOST,E_INVALIDARG,FALSE}
5293         },
5294         {FALSE},
5295         0,S_OK,FALSE,
5296         0,S_OK,FALSE,
5297         0,0,0,S_OK,FALSE,
5298         {
5299             {"http://google.com/",S_OK},
5300             {"google.com",S_OK},
5301             {"http://google.com/",S_OK},
5302             {"google.com",S_OK},
5303             {"",S_FALSE},
5304             {"",S_FALSE},
5305             {"google.com",S_OK},
5306             {"",S_FALSE},
5307             {"/",S_OK},
5308             {"/",S_OK},
5309             {"",S_FALSE},
5310             {"http://google.com/",S_OK},
5311             {"http",S_OK},
5312             {"",S_FALSE},
5313             {"",S_FALSE}
5314         },
5315         {
5316             {Uri_HOST_DNS,S_OK},
5317             {80,S_OK},
5318             {URL_SCHEME_HTTP,S_OK},
5319             {URLZONE_INVALID,E_NOTIMPL}
5320         }
5321     },
5322     /* Can set the host name to an empty string. */
5323     {   "http://google.com/",0,S_OK,FALSE,
5324         {
5325             {TRUE,"",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5326         },
5327         {FALSE},
5328         0,S_OK,FALSE,
5329         0,S_OK,FALSE,
5330         0,0,0,S_OK,FALSE,
5331         {
5332             {"http:///",S_OK},
5333             {"",S_OK},
5334             {"http:///",S_OK},
5335             {"",S_FALSE},
5336             {"",S_FALSE},
5337             {"",S_FALSE},
5338             {"",S_OK},
5339             {"",S_FALSE},
5340             {"/",S_OK},
5341             {"/",S_OK},
5342             {"",S_FALSE},
5343             {"http:///",S_OK},
5344             {"http",S_OK},
5345             {"",S_FALSE},
5346             {"",S_FALSE}
5347         },
5348         {
5349             {Uri_HOST_UNKNOWN,S_OK},
5350             {80,S_OK},
5351             {URL_SCHEME_HTTP,S_OK},
5352             {URLZONE_INVALID,E_NOTIMPL}
5353         }
5354     },
5355     {   "http://google.com/",0,S_OK,FALSE,
5356         {
5357             {TRUE,"/path?query",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5358         },
5359         {FALSE},
5360         0,INET_E_INVALID_URL,FALSE,
5361         0,INET_E_INVALID_URL,FALSE,
5362         0,0,0,INET_E_INVALID_URL,FALSE
5363     },
5364     {   "http://google.com/",0,S_OK,FALSE,
5365         {
5366             {TRUE,"/path#test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5367         },
5368         {FALSE},
5369         0,INET_E_INVALID_URL,FALSE,
5370         0,INET_E_INVALID_URL,FALSE,
5371         0,0,0,INET_E_INVALID_URL,FALSE
5372     },
5373     {   "http://google.com/",0,S_OK,FALSE,
5374         {
5375             {TRUE,"?path#test",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE}
5376         },
5377         {FALSE},
5378         0,INET_E_INVALID_URL,FALSE,
5379         0,INET_E_INVALID_URL,FALSE,
5380         0,0,0,INET_E_INVALID_URL,FALSE
5381     }
5382 };
5383
5384 typedef struct _uri_builder_remove_test {
5385     const char  *uri;
5386     DWORD       create_flags;
5387     HRESULT     create_builder_expected;
5388     BOOL        create_builder_todo;
5389
5390     DWORD       remove_properties;
5391     HRESULT     remove_expected;
5392     BOOL        remove_todo;
5393
5394     const char  *expected_uri;
5395     DWORD       expected_flags;
5396     HRESULT     expected_hres;
5397     BOOL        expected_todo;
5398 } uri_builder_remove_test;
5399
5400 static const uri_builder_remove_test uri_builder_remove_tests[] = {
5401     {   "http://google.com/test?test=y#Frag",0,S_OK,FALSE,
5402         Uri_HAS_FRAGMENT|Uri_HAS_PATH|Uri_HAS_QUERY,S_OK,FALSE,
5403         "http://google.com/",0,S_OK,FALSE
5404     },
5405     {   "http://user:pass@winehq.org/",0,S_OK,FALSE,
5406         Uri_HAS_USER_NAME|Uri_HAS_PASSWORD,S_OK,FALSE,
5407         "http://winehq.org/",0,S_OK,FALSE
5408     },
5409     {   "zip://google.com?Test=x",0,S_OK,FALSE,
5410         Uri_HAS_HOST,S_OK,FALSE,
5411         "zip:/?Test=x",0,S_OK,FALSE
5412     },
5413     /* Doesn't remove the whole userinfo component. */
5414     {   "http://username:pass@google.com/",0,S_OK,FALSE,
5415         Uri_HAS_USER_INFO,S_OK,FALSE,
5416         "http://username:pass@google.com/",0,S_OK,FALSE
5417     },
5418     /* Doesn't remove the domain. */
5419     {   "http://google.com/",0,S_OK,FALSE,
5420         Uri_HAS_DOMAIN,S_OK,FALSE,
5421         "http://google.com/",0,S_OK,FALSE
5422     },
5423     {   "http://google.com:120/",0,S_OK,FALSE,
5424         Uri_HAS_AUTHORITY,S_OK,FALSE,
5425         "http://google.com:120/",0,S_OK,FALSE
5426     },
5427     {   "http://google.com/test.com/",0,S_OK,FALSE,
5428         Uri_HAS_EXTENSION,S_OK,FALSE,
5429         "http://google.com/test.com/",0,S_OK,FALSE
5430     },
5431     {   "http://google.com/?test=x",0,S_OK,FALSE,
5432         Uri_HAS_PATH_AND_QUERY,S_OK,FALSE,
5433         "http://google.com/?test=x",0,S_OK,FALSE
5434     },
5435     /* Can't remove the scheme name. */
5436     {   "http://google.com/?test=x",0,S_OK,FALSE,
5437         Uri_HAS_SCHEME_NAME|Uri_HAS_QUERY,E_INVALIDARG,FALSE,
5438         "http://google.com/?test=x",0,S_OK,FALSE
5439     }
5440 };
5441
5442 typedef struct _uri_combine_str_property {
5443     const char  *value;
5444     HRESULT     expected;
5445     BOOL        todo;
5446     const char  *broken_value;
5447     const char  *value_ex;
5448 } uri_combine_str_property;
5449
5450 typedef struct _uri_combine_test {
5451     const char  *base_uri;
5452     DWORD       base_create_flags;
5453     const char  *relative_uri;
5454     DWORD       relative_create_flags;
5455     DWORD       combine_flags;
5456     HRESULT     expected;
5457     BOOL        todo;
5458
5459     uri_combine_str_property    str_props[URI_STR_PROPERTY_COUNT];
5460     uri_dword_property          dword_props[URI_DWORD_PROPERTY_COUNT];
5461 } uri_combine_test;
5462
5463 static const uri_combine_test uri_combine_tests[] = {
5464     {   "http://google.com/fun/stuff",0,
5465         "../not/fun/stuff",Uri_CREATE_ALLOW_RELATIVE,
5466         0,S_OK,FALSE,
5467         {
5468             {"http://google.com/not/fun/stuff",S_OK},
5469             {"google.com",S_OK},
5470             {"http://google.com/not/fun/stuff",S_OK},
5471             {"google.com",S_OK},
5472             {"",S_FALSE},
5473             {"",S_FALSE},
5474             {"google.com",S_OK},
5475             {"",S_FALSE},
5476             {"/not/fun/stuff",S_OK},
5477             {"/not/fun/stuff",S_OK},
5478             {"",S_FALSE},
5479             {"http://google.com/not/fun/stuff",S_OK},
5480             {"http",S_OK},
5481             {"",S_FALSE},
5482             {"",S_FALSE}
5483         },
5484         {
5485             {Uri_HOST_DNS,S_OK},
5486             {80,S_OK},
5487             {URL_SCHEME_HTTP,S_OK},
5488             {URLZONE_INVALID,E_NOTIMPL}
5489         }
5490     },
5491     {   "http://google.com/test",0,
5492         "zip://test.com/cool",0,
5493         0,S_OK,FALSE,
5494         {
5495             {"zip://test.com/cool",S_OK},
5496             {"test.com",S_OK},
5497             {"zip://test.com/cool",S_OK},
5498             {"test.com",S_OK},
5499             {"",S_FALSE},
5500             {"",S_FALSE},
5501             {"test.com",S_OK},
5502             {"",S_FALSE},
5503             {"/cool",S_OK},
5504             {"/cool",S_OK},
5505             {"",S_FALSE},
5506             {"zip://test.com/cool",S_OK},
5507             {"zip",S_OK},
5508             {"",S_FALSE},
5509             {"",S_FALSE}
5510         },
5511         {
5512             {Uri_HOST_DNS,S_OK},
5513             {0,S_FALSE},
5514             {URL_SCHEME_UNKNOWN,S_OK},
5515             {URLZONE_INVALID,E_NOTIMPL}
5516         }
5517     },
5518     {   "http://google.com/use/base/path",0,
5519         "?relative",Uri_CREATE_ALLOW_RELATIVE,
5520         0,S_OK,FALSE,
5521         {
5522             {"http://google.com/use/base/path?relative",S_OK},
5523             {"google.com",S_OK},
5524             {"http://google.com/use/base/path?relative",S_OK},
5525             {"google.com",S_OK},
5526             {"",S_FALSE},
5527             {"",S_FALSE},
5528             {"google.com",S_OK},
5529             {"",S_FALSE},
5530             {"/use/base/path",S_OK},
5531             {"/use/base/path?relative",S_OK},
5532             {"?relative",S_OK},
5533             {"http://google.com/use/base/path?relative",S_OK},
5534             {"http",S_OK},
5535             {"",S_FALSE},
5536             {"",S_FALSE}
5537         },
5538         {
5539             {Uri_HOST_DNS,S_OK},
5540             {80,S_OK},
5541             {URL_SCHEME_HTTP,S_OK},
5542             {URLZONE_INVALID,E_NOTIMPL}
5543         }
5544     },
5545     {   "http://google.com/path",0,
5546         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5547         0,S_OK,FALSE,
5548         {
5549             {"http://google.com/testing",S_OK},
5550             {"google.com",S_OK},
5551             {"http://google.com/testing",S_OK},
5552             {"google.com",S_OK},
5553             {"",S_FALSE},
5554             {"",S_FALSE},
5555             {"google.com",S_OK},
5556             {"",S_FALSE},
5557             {"/testing",S_OK},
5558             {"/testing",S_OK},
5559             {"",S_FALSE},
5560             {"http://google.com/testing",S_OK},
5561             {"http",S_OK},
5562             {"",S_FALSE},
5563             {"",S_FALSE}
5564         },
5565         {
5566             {Uri_HOST_DNS,S_OK},
5567             {80,S_OK},
5568             {URL_SCHEME_HTTP,S_OK},
5569             {URLZONE_INVALID,E_NOTIMPL}
5570         }
5571     },
5572     {   "http://google.com/path",0,
5573         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5574         URL_DONT_SIMPLIFY,S_OK,FALSE,
5575         {
5576             {"http://google.com:80/test/../test/.././testing",S_OK},
5577             {"google.com",S_OK},
5578             {"http://google.com:80/test/../test/.././testing",S_OK},
5579             {"google.com",S_OK},
5580             {"",S_FALSE},
5581             {"",S_FALSE},
5582             {"google.com",S_OK},
5583             {"",S_FALSE},
5584             {"/test/../test/.././testing",S_OK},
5585             {"/test/../test/.././testing",S_OK},
5586             {"",S_FALSE},
5587             {"http://google.com:80/test/../test/.././testing",S_OK},
5588             {"http",S_OK},
5589             {"",S_FALSE},
5590             {"",S_FALSE}
5591         },
5592         {
5593             {Uri_HOST_DNS,S_OK},
5594             {80,S_OK},
5595             {URL_SCHEME_HTTP,S_OK},
5596             {URLZONE_INVALID,E_NOTIMPL}
5597         }
5598     },
5599     {   "http://winehq.org/test/abc",0,
5600         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5601         0,S_OK,FALSE,
5602         {
5603             {"http://winehq.org/test/testing/test",S_OK},
5604             {"winehq.org",S_OK},
5605             {"http://winehq.org/test/testing/test",S_OK},
5606             {"winehq.org",S_OK},
5607             {"",S_FALSE},
5608             {"",S_FALSE},
5609             {"winehq.org",S_OK},
5610             {"",S_FALSE},
5611             {"/test/testing/test",S_OK},
5612             {"/test/testing/test",S_OK},
5613             {"",S_FALSE},
5614             {"http://winehq.org/test/testing/test",S_OK},
5615             {"http",S_OK},
5616             {"",S_FALSE},
5617             {"",S_FALSE}
5618         },
5619         {
5620             {Uri_HOST_DNS,S_OK},
5621             {80,S_OK},
5622             {URL_SCHEME_HTTP,S_OK},
5623             {URLZONE_INVALID,E_NOTIMPL}
5624         }
5625     },
5626     {   "http://winehq.org/test/abc",0,
5627         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5628         URL_DONT_SIMPLIFY,S_OK,FALSE,
5629         {
5630             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5631             /* Default port is hidden in the authority. */
5632             {"winehq.org",S_OK},
5633             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5634             {"winehq.org",S_OK},
5635             {"",S_FALSE},
5636             {"",S_FALSE},
5637             {"winehq.org",S_OK},
5638             {"",S_FALSE},
5639             {"/test/testing/abc/../test",S_OK},
5640             {"/test/testing/abc/../test",S_OK},
5641             {"",S_FALSE},
5642             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5643             {"http",S_OK},
5644             {"",S_FALSE},
5645             {"",S_FALSE}
5646         },
5647         {
5648             {Uri_HOST_DNS,S_OK},
5649             {80,S_OK},
5650             {URL_SCHEME_HTTP,S_OK},
5651             {URLZONE_INVALID,E_NOTIMPL}
5652         }
5653     },
5654     {   "http://winehq.org/test?query",0,
5655         "testing",Uri_CREATE_ALLOW_RELATIVE,
5656         0,S_OK,FALSE,
5657         {
5658             {"http://winehq.org/testing",S_OK},
5659             {"winehq.org",S_OK},
5660             {"http://winehq.org/testing",S_OK},
5661             {"winehq.org",S_OK},
5662             {"",S_FALSE},
5663             {"",S_FALSE},
5664             {"winehq.org",S_OK},
5665             {"",S_FALSE},
5666             {"/testing",S_OK},
5667             {"/testing",S_OK},
5668             {"",S_FALSE},
5669             {"http://winehq.org/testing",S_OK},
5670             {"http",S_OK},
5671             {"",S_FALSE},
5672             {"",S_FALSE}
5673         },
5674         {
5675             {Uri_HOST_DNS,S_OK},
5676             {80,S_OK},
5677             {URL_SCHEME_HTTP,S_OK},
5678             {URLZONE_INVALID,E_NOTIMPL}
5679         }
5680     },
5681     {   "http://winehq.org/test#frag",0,
5682         "testing",Uri_CREATE_ALLOW_RELATIVE,
5683         0,S_OK,FALSE,
5684         {
5685             {"http://winehq.org/testing",S_OK},
5686             {"winehq.org",S_OK},
5687             {"http://winehq.org/testing",S_OK},
5688             {"winehq.org",S_OK},
5689             {"",S_FALSE},
5690             {"",S_FALSE},
5691             {"winehq.org",S_OK},
5692             {"",S_FALSE},
5693             {"/testing",S_OK},
5694             {"/testing",S_OK},
5695             {"",S_FALSE},
5696             {"http://winehq.org/testing",S_OK},
5697             {"http",S_OK},
5698             {"",S_FALSE},
5699             {"",S_FALSE}
5700         },
5701         {
5702             {Uri_HOST_DNS,S_OK},
5703             {80,S_OK},
5704             {URL_SCHEME_HTTP,S_OK},
5705             {URLZONE_INVALID,E_NOTIMPL}
5706         }
5707     },
5708     {   "testing?query#frag",Uri_CREATE_ALLOW_RELATIVE,
5709         "test",Uri_CREATE_ALLOW_RELATIVE,
5710         0,S_OK,FALSE,
5711         {
5712             {"test",S_OK},
5713             {"",S_FALSE},
5714             {"test",S_OK},
5715             {"",S_FALSE},
5716             {"",S_FALSE},
5717             {"",S_FALSE},
5718             {"",S_FALSE},
5719             {"",S_FALSE},
5720             {"test",S_OK},
5721             {"test",S_OK},
5722             {"",S_FALSE},
5723             {"test",S_OK},
5724             {"",S_FALSE},
5725             {"",S_FALSE},
5726             {"",S_FALSE}
5727         },
5728         {
5729             {Uri_HOST_UNKNOWN,S_OK},
5730             {0,S_FALSE},
5731             {URL_SCHEME_UNKNOWN,S_OK},
5732             {URLZONE_INVALID,E_NOTIMPL}
5733         }
5734     },
5735     {   "file:///c:/test/test",0,
5736         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5737         URL_FILE_USE_PATHURL,S_OK,FALSE,
5738         {
5739             {"file://c:\\testing.mp3",S_OK},
5740             {"",S_FALSE},
5741             {"file://c:\\testing.mp3",S_OK},
5742             {"",S_FALSE},
5743             {".mp3",S_OK},
5744             {"",S_FALSE},
5745             {"",S_FALSE},
5746             {"",S_FALSE},
5747             {"c:\\testing.mp3",S_OK},
5748             {"c:\\testing.mp3",S_OK},
5749             {"",S_FALSE},
5750             {"file://c:\\testing.mp3",S_OK},
5751             {"file",S_OK},
5752             {"",S_FALSE},
5753             {"",S_FALSE}
5754         },
5755         {
5756             {Uri_HOST_UNKNOWN,S_OK},
5757             {0,S_FALSE},
5758             {URL_SCHEME_FILE,S_OK},
5759             {URLZONE_INVALID,E_NOTIMPL}
5760         }
5761     },
5762     {   "file:///c:/test/test",0,
5763         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5764         0,S_OK,FALSE,
5765         {
5766             {"file:///c:/testing.mp3",S_OK},
5767             {"",S_FALSE},
5768             {"file:///c:/testing.mp3",S_OK},
5769             {"",S_FALSE},
5770             {".mp3",S_OK},
5771             {"",S_FALSE},
5772             {"",S_FALSE},
5773             {"",S_FALSE},
5774             {"/c:/testing.mp3",S_OK},
5775             {"/c:/testing.mp3",S_OK},
5776             {"",S_FALSE},
5777             {"file:///c:/testing.mp3",S_OK},
5778             {"file",S_OK},
5779             {"",S_FALSE},
5780             {"",S_FALSE}
5781         },
5782         {
5783             {Uri_HOST_UNKNOWN,S_OK},
5784             {0,S_FALSE},
5785             {URL_SCHEME_FILE,S_OK},
5786             {URLZONE_INVALID,E_NOTIMPL}
5787         }
5788     },
5789     {   "file://test.com/test/test",0,
5790         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5791         URL_FILE_USE_PATHURL,S_OK,FALSE,
5792         {
5793             {"file://\\\\test.com\\testing.mp3",S_OK},
5794             {"test.com",S_OK},
5795             {"file://\\\\test.com\\testing.mp3",S_OK},
5796             {"test.com",S_OK},
5797             {".mp3",S_OK},
5798             {"",S_FALSE},
5799             {"test.com",S_OK},
5800             {"",S_FALSE},
5801             {"\\testing.mp3",S_OK},
5802             {"\\testing.mp3",S_OK},
5803             {"",S_FALSE},
5804             {"file://\\\\test.com\\testing.mp3",S_OK},
5805             {"file",S_OK},
5806             {"",S_FALSE},
5807             {"",S_FALSE}
5808         },
5809         {
5810             {Uri_HOST_DNS,S_OK},
5811             {0,S_FALSE},
5812             {URL_SCHEME_FILE,S_OK},
5813             {URLZONE_INVALID,E_NOTIMPL}
5814         }
5815     },
5816     /* URL_DONT_SIMPLIFY has no effect. */
5817     {   "http://google.com/test",0,
5818         "zip://test.com/cool/../cool/test",0,
5819         URL_DONT_SIMPLIFY,S_OK,FALSE,
5820         {
5821             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
5822             {"test.com",S_OK},
5823             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
5824             {"test.com",S_OK},
5825             {"",S_FALSE},
5826             {"",S_FALSE},
5827             {"test.com",S_OK},
5828             {"",S_FALSE},
5829             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
5830             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
5831             {"",S_FALSE},
5832             /* The resulting IUri has the same Raw URI as the relative URI (only IE 8).
5833              * On IE 7 it reduces the path in the Raw URI.
5834              */
5835             {"zip://test.com/cool/../cool/test",S_OK,FALSE,"zip://test.com/cool/test"},
5836             {"zip",S_OK},
5837             {"",S_FALSE},
5838             {"",S_FALSE}
5839         },
5840         {
5841             {Uri_HOST_DNS,S_OK},
5842             {0,S_FALSE},
5843             {URL_SCHEME_UNKNOWN,S_OK},
5844             {URLZONE_INVALID,E_NOTIMPL}
5845         }
5846     },
5847     /* FILE_USE_PATHURL has no effect in IE 8, in IE 7 the
5848      * resulting URI is converted into a dos path.
5849      */
5850     {   "http://google.com/test",0,
5851         "file:///c:/test/",0,
5852         URL_FILE_USE_PATHURL,S_OK,FALSE,
5853         {
5854             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
5855             {"",S_FALSE},
5856             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
5857             {"",S_FALSE},
5858             {"",S_FALSE},
5859             {"",S_FALSE},
5860             {"",S_FALSE},
5861             {"",S_FALSE},
5862             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
5863             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
5864             {"",S_FALSE},
5865             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
5866             {"file",S_OK},
5867             {"",S_FALSE},
5868             {"",S_FALSE}
5869         },
5870         {
5871             {Uri_HOST_UNKNOWN,S_OK},
5872             {0,S_FALSE},
5873             {URL_SCHEME_FILE,S_OK},
5874             {URLZONE_INVALID,E_NOTIMPL}
5875         }
5876     },
5877     {   "http://google.com/test",0,
5878         "http://test.com/test#%30test",0,
5879         URL_DONT_UNESCAPE_EXTRA_INFO,S_OK,FALSE,
5880         {
5881             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
5882             {"test.com",S_OK},
5883             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
5884             {"test.com",S_OK},
5885             {"",S_FALSE},
5886             {"#0test",S_OK,FALSE,NULL,"#%30test"},
5887             {"test.com",S_OK},
5888             {"",S_FALSE},
5889             {"/test",S_OK},
5890             {"/test",S_OK},
5891             {"",S_FALSE},
5892             /* IE 7 decodes the %30 to a 0 in the Raw URI. */
5893             {"http://test.com/test#%30test",S_OK,FALSE,"http://test.com/test#0test"},
5894             {"http",S_OK},
5895             {"",S_FALSE},
5896             {"",S_FALSE}
5897         },
5898         {
5899             {Uri_HOST_DNS,S_OK},
5900             {80,S_OK},
5901             {URL_SCHEME_HTTP,S_OK},
5902             {URLZONE_INVALID,E_NOTIMPL}
5903         }
5904     },
5905     /* Windows validates the path component from the relative Uri. */
5906     {   "http://google.com/test",0,
5907         "/Te%XXst",Uri_CREATE_ALLOW_RELATIVE,
5908         0,E_INVALIDARG,FALSE
5909     },
5910     /* Windows doesn't validate the query from the relative Uri. */
5911     {   "http://google.com/test",0,
5912         "?Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
5913         0,S_OK,FALSE,
5914         {
5915             {"http://google.com/test?Tes%XXt",S_OK},
5916             {"google.com",S_OK},
5917             {"http://google.com/test?Tes%XXt",S_OK},
5918             {"google.com",S_OK},
5919             {"",S_FALSE},
5920             {"",S_FALSE},
5921             {"google.com",S_OK},
5922             {"",S_FALSE},
5923             {"/test",S_OK},
5924             {"/test?Tes%XXt",S_OK},
5925             {"?Tes%XXt",S_OK},
5926             {"http://google.com/test?Tes%XXt",S_OK},
5927             {"http",S_OK},
5928             {"",S_FALSE},
5929             {"",S_FALSE}
5930         },
5931         {
5932             {Uri_HOST_DNS,S_OK},
5933             {80,S_OK},
5934             {URL_SCHEME_HTTP,S_OK},
5935             {URLZONE_INVALID,E_NOTIMPL}
5936         }
5937     },
5938     /* Windows doesn't validate the fragment from the relative Uri. */
5939     {   "http://google.com/test",0,
5940         "#Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
5941         0,S_OK,FALSE,
5942         {
5943             {"http://google.com/test#Tes%XXt",S_OK},
5944             {"google.com",S_OK},
5945             {"http://google.com/test#Tes%XXt",S_OK},
5946             {"google.com",S_OK},
5947             {"",S_FALSE},
5948             {"#Tes%XXt",S_OK},
5949             {"google.com",S_OK},
5950             {"",S_FALSE},
5951             {"/test",S_OK},
5952             {"/test",S_OK},
5953             {"",S_FALSE},
5954             {"http://google.com/test#Tes%XXt",S_OK},
5955             {"http",S_OK},
5956             {"",S_FALSE},
5957             {"",S_FALSE}
5958         },
5959         {
5960             {Uri_HOST_DNS,S_OK},
5961             {80,S_OK},
5962             {URL_SCHEME_HTTP,S_OK},
5963             {URLZONE_INVALID,E_NOTIMPL}
5964         }
5965     },
5966     /* Creates an IUri which contains an invalid dos path char. */
5967     {   "file:///c:/test",0,
5968         "/test<ing",Uri_CREATE_ALLOW_RELATIVE,
5969         URL_FILE_USE_PATHURL,S_OK,FALSE,
5970         {
5971             {"file://c:\\test<ing",S_OK},
5972             {"",S_FALSE},
5973             {"file://c:\\test<ing",S_OK},
5974             {"",S_FALSE},
5975             {"",S_FALSE},
5976             {"",S_FALSE},
5977             {"",S_FALSE},
5978             {"",S_FALSE},
5979             {"c:\\test<ing",S_OK},
5980             {"c:\\test<ing",S_OK},
5981             {"",S_FALSE},
5982             {"file://c:\\test<ing",S_OK},
5983             {"file",S_OK},
5984             {"",S_FALSE},
5985             {"",S_FALSE}
5986         },
5987         {
5988             {Uri_HOST_UNKNOWN,S_OK},
5989             {0,S_FALSE},
5990             {URL_SCHEME_FILE,S_OK},
5991             {URLZONE_INVALID,E_NOTIMPL}
5992         }
5993     },
5994     /* Appends the path after the drive letter (if any). */
5995     {   "file:///c:/test",0,
5996         "/c:/testing",Uri_CREATE_ALLOW_RELATIVE,
5997         0,S_OK,FALSE,
5998         {
5999             {"file:///c:/c:/testing",S_OK},
6000             {"",S_FALSE},
6001             {"file:///c:/c:/testing",S_OK},
6002             {"",S_FALSE},
6003             {"",S_FALSE},
6004             {"",S_FALSE},
6005             {"",S_FALSE},
6006             {"",S_FALSE},
6007             {"/c:/c:/testing",S_OK},
6008             {"/c:/c:/testing",S_OK},
6009             {"",S_FALSE},
6010             {"file:///c:/c:/testing",S_OK},
6011             {"file",S_OK},
6012             {"",S_FALSE},
6013             {"",S_FALSE}
6014         },
6015         {
6016             {Uri_HOST_UNKNOWN,S_OK},
6017             {0,S_FALSE},
6018             {URL_SCHEME_FILE,S_OK},
6019             {URLZONE_INVALID,E_NOTIMPL}
6020         }
6021     },
6022     /* A '/' is added if the base URI doesn't have a path and the
6023      * relative URI doesn't contain a path (since the base URI is
6024      * hierarchical.
6025      */
6026     {   "http://google.com",Uri_CREATE_NO_CANONICALIZE,
6027         "?test",Uri_CREATE_ALLOW_RELATIVE,
6028         0,S_OK,FALSE,
6029         {
6030             {"http://google.com/?test",S_OK},
6031             {"google.com",S_OK},
6032             {"http://google.com/?test",S_OK},
6033             {"google.com",S_OK},
6034             {"",S_FALSE},
6035             {"",S_FALSE},
6036             {"google.com",S_OK},
6037             {"",S_FALSE},
6038             {"/",S_OK},
6039             {"/?test",S_OK},
6040             {"?test",S_OK},
6041             {"http://google.com/?test",S_OK},
6042             {"http",S_OK},
6043             {"",S_FALSE},
6044             {"",S_FALSE}
6045         },
6046         {
6047             {Uri_HOST_DNS,S_OK},
6048             {80,S_OK},
6049             {URL_SCHEME_HTTP,S_OK},
6050             {URLZONE_INVALID,E_NOTIMPL}
6051         }
6052     },
6053     {   "zip://google.com",Uri_CREATE_NO_CANONICALIZE,
6054         "?test",Uri_CREATE_ALLOW_RELATIVE,
6055         0,S_OK,FALSE,
6056         {
6057             {"zip://google.com/?test",S_OK},
6058             {"google.com",S_OK},
6059             {"zip://google.com/?test",S_OK},
6060             {"google.com",S_OK},
6061             {"",S_FALSE},
6062             {"",S_FALSE},
6063             {"google.com",S_OK},
6064             {"",S_FALSE},
6065             {"/",S_OK},
6066             {"/?test",S_OK},
6067             {"?test",S_OK},
6068             {"zip://google.com/?test",S_OK},
6069             {"zip",S_OK},
6070             {"",S_FALSE},
6071             {"",S_FALSE}
6072         },
6073         {
6074             {Uri_HOST_DNS,S_OK},
6075             {0,S_FALSE},
6076             {URL_SCHEME_UNKNOWN,S_OK},
6077             {URLZONE_INVALID,E_NOTIMPL}
6078         }
6079     },
6080     /* No path is appended since the base URI is opaque. */
6081     {   "zip:?testing",0,
6082         "?test",Uri_CREATE_ALLOW_RELATIVE,
6083         0,S_OK,FALSE,
6084         {
6085             {"zip:?test",S_OK},
6086             {"",S_FALSE},
6087             {"zip:?test",S_OK},
6088             {"",S_FALSE},
6089             {"",S_FALSE},
6090             {"",S_FALSE},
6091             {"",S_FALSE},
6092             {"",S_FALSE},
6093             {"",S_OK},
6094             {"?test",S_OK},
6095             {"?test",S_OK},
6096             {"zip:?test",S_OK},
6097             {"zip",S_OK},
6098             {"",S_FALSE},
6099             {"",S_FALSE}
6100         },
6101         {
6102             {Uri_HOST_UNKNOWN,S_OK},
6103             {0,S_FALSE},
6104             {URL_SCHEME_UNKNOWN,S_OK},
6105             {URLZONE_INVALID,E_NOTIMPL}
6106         }
6107     },
6108     {   "file:///c:/",0,
6109         "../testing/test",Uri_CREATE_ALLOW_RELATIVE,
6110         0,S_OK,FALSE,
6111         {
6112             {"file:///c:/testing/test",S_OK},
6113             {"",S_FALSE},
6114             {"file:///c:/testing/test",S_OK},
6115             {"",S_FALSE},
6116             {"",S_FALSE},
6117             {"",S_FALSE},
6118             {"",S_FALSE},
6119             {"",S_FALSE},
6120             {"/c:/testing/test",S_OK},
6121             {"/c:/testing/test",S_OK},
6122             {"",S_FALSE},
6123             {"file:///c:/testing/test",S_OK},
6124             {"file",S_OK},
6125             {"",S_FALSE},
6126             {"",S_FALSE}
6127         },
6128         {
6129             {Uri_HOST_UNKNOWN,S_OK},
6130             {0,S_FALSE},
6131             {URL_SCHEME_FILE,S_OK},
6132             {URLZONE_INVALID,E_NOTIMPL}
6133         }
6134     },
6135     {   "http://winehq.org/dir/testfile",0,
6136         "test?querystring",Uri_CREATE_ALLOW_RELATIVE,
6137         0,S_OK,FALSE,
6138         {
6139             {"http://winehq.org/dir/test?querystring",S_OK},
6140             {"winehq.org",S_OK},
6141             {"http://winehq.org/dir/test?querystring",S_OK},
6142             {"winehq.org",S_OK},
6143             {"",S_FALSE},
6144             {"",S_FALSE},
6145             {"winehq.org",S_OK},
6146             {"",S_FALSE},
6147             {"/dir/test",S_OK},
6148             {"/dir/test?querystring",S_OK},
6149             {"?querystring",S_OK},
6150             {"http://winehq.org/dir/test?querystring",S_OK},
6151             {"http",S_OK},
6152             {"",S_FALSE},
6153             {"",S_FALSE}
6154         },
6155         {
6156             {Uri_HOST_DNS,S_OK},
6157             {80,S_OK},
6158             {URL_SCHEME_HTTP,S_OK},
6159             {URLZONE_INVALID,E_NOTIMPL}
6160         }
6161     },
6162     {   "http://winehq.org/dir/test",0,
6163         "test?querystring",Uri_CREATE_ALLOW_RELATIVE,
6164         0,S_OK,FALSE,
6165         {
6166             {"http://winehq.org/dir/test?querystring",S_OK},
6167             {"winehq.org",S_OK},
6168             {"http://winehq.org/dir/test?querystring",S_OK},
6169             {"winehq.org",S_OK},
6170             {"",S_FALSE},
6171             {"",S_FALSE},
6172             {"winehq.org",S_OK},
6173             {"",S_FALSE},
6174             {"/dir/test",S_OK},
6175             {"/dir/test?querystring",S_OK},
6176             {"?querystring",S_OK},
6177             {"http://winehq.org/dir/test?querystring",S_OK},
6178             {"http",S_OK},
6179             {"",S_FALSE},
6180             {"",S_FALSE}
6181         },
6182         {
6183             {Uri_HOST_DNS,S_OK},
6184             {80,S_OK},
6185             {URL_SCHEME_HTTP,S_OK},
6186             {URLZONE_INVALID,E_NOTIMPL}
6187         }
6188     },
6189     {   "http://winehq.org/dir/test?querystring",0,
6190         "#hash",Uri_CREATE_ALLOW_RELATIVE,
6191         0,S_OK,FALSE,
6192         {
6193             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6194             {"winehq.org",S_OK},
6195             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6196             {"winehq.org",S_OK},
6197             {"",S_FALSE},
6198             {"#hash",S_OK},
6199             {"winehq.org",S_OK},
6200             {"",S_FALSE},
6201             {"/dir/test",S_OK},
6202             {"/dir/test?querystring",S_OK},
6203             {"?querystring",S_OK},
6204             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6205             {"http",S_OK},
6206             {"",S_FALSE},
6207             {"",S_FALSE}
6208         },
6209         {
6210             {Uri_HOST_DNS,S_OK},
6211             {80,S_OK},
6212             {URL_SCHEME_HTTP,S_OK},
6213             {URLZONE_INVALID,E_NOTIMPL}
6214         }
6215     }
6216 };
6217
6218 typedef struct _uri_parse_test {
6219     const char  *uri;
6220     DWORD       uri_flags;
6221     PARSEACTION action;
6222     DWORD       flags;
6223     const char  *property;
6224     HRESULT     expected;
6225     BOOL        todo;
6226 } uri_parse_test;
6227
6228 static const uri_parse_test uri_parse_tests[] = {
6229     /* PARSE_CANONICALIZE tests. */
6230     {"zip://google.com/test<|>",0,PARSE_CANONICALIZE,0,"zip://google.com/test<|>",S_OK,FALSE},
6231     {"http://google.com/test<|>",0,PARSE_CANONICALIZE,0,"http://google.com/test%3C%7C%3E",S_OK,FALSE},
6232     {"http://google.com/%30%23%3F",0,PARSE_CANONICALIZE,URL_UNESCAPE,"http://google.com/0#?",S_OK,FALSE},
6233     {"test <|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_ESCAPE_UNSAFE,"test %3C%7C%3E",S_OK,FALSE},
6234     {"test <|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_ESCAPE_SPACES_ONLY,"test%20<|>",S_OK,FALSE},
6235     {"test%20<|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_UNESCAPE|URL_ESCAPE_UNSAFE,"test%20%3C%7C%3E",S_OK,FALSE},
6236     {"http://google.com/%20",0,PARSE_CANONICALIZE,URL_ESCAPE_PERCENT,"http://google.com/%2520",S_OK,FALSE},
6237     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_DONT_SIMPLIFY,"http://google.com/test/../",S_OK,FALSE},
6238     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_NO_META,"http://google.com/test/../",S_OK,FALSE},
6239     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,0,"http://google.com/",S_OK,FALSE},
6240     {"zip://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,0,"zip://google.com/",S_OK,FALSE},
6241     {"file:///c:/test/../test",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_DONT_SIMPLIFY,"file:///c:/test/../test",S_OK,FALSE},
6242
6243     /* PARSE_FRIENDLY tests. */
6244     {"http://test@google.com/test#test",0,PARSE_FRIENDLY,0,"http://google.com/test#test",S_OK,FALSE},
6245     {"zip://test@google.com/test",0,PARSE_FRIENDLY,0,"zip://test@google.com/test",S_OK,FALSE},
6246
6247     /* PARSE_ROOTDOCUMENT tests. */
6248     {"http://google.com:200/test/test",0,PARSE_ROOTDOCUMENT,0,"http://google.com:200/",S_OK,FALSE},
6249     {"http://google.com",Uri_CREATE_NO_CANONICALIZE,PARSE_ROOTDOCUMENT,0,"http://google.com/",S_OK,FALSE},
6250     {"zip://google.com/",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6251     {"file:///c:/testing/",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6252     {"file://server/test",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6253     {"zip:test/test",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6254
6255     /* PARSE_DOCUMENT tests. */
6256     {"http://test@google.com/test?query#frag",0,PARSE_DOCUMENT,0,"http://test@google.com/test?query",S_OK,FALSE},
6257     {"http:testing#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6258     {"file:///c:/test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6259     {"zip://google.com/#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6260     {"zip:test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6261     {"testing#frag",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6262
6263     /* PARSE_PATH_FROM_URL tests. */
6264     {"file:///c:/test.mp3",0,PARSE_PATH_FROM_URL,0,"c:\\test.mp3",S_OK,FALSE},
6265     {"file:///c:/t<|>est.mp3",0,PARSE_PATH_FROM_URL,0,"c:\\t<|>est.mp3",S_OK,FALSE},
6266     {"file:///c:/te%XX t/",0,PARSE_PATH_FROM_URL,0,"c:\\te%XX t\\",S_OK,FALSE},
6267     {"file://server/test",0,PARSE_PATH_FROM_URL,0,"\\\\server\\test",S_OK,FALSE},
6268     {"http://google.com/",0,PARSE_PATH_FROM_URL,0,"",E_INVALIDARG,FALSE},
6269
6270     /* PARSE_URL_FROM_PATH tests. */
6271     /* This function almost seems to useless (just returns the absolute uri). */
6272     {"test.com",Uri_CREATE_ALLOW_RELATIVE,PARSE_URL_FROM_PATH,0,"test.com",S_OK,FALSE},
6273     {"/test/test",Uri_CREATE_ALLOW_RELATIVE,PARSE_URL_FROM_PATH,0,"/test/test",S_OK,FALSE},
6274     {"file://c:\\test\\test",Uri_CREATE_FILE_USE_DOS_PATH,PARSE_URL_FROM_PATH,0,"file://c:\\test\\test",S_OK,FALSE},
6275     {"file:c:/test",0,PARSE_URL_FROM_PATH,0,"",S_OK,FALSE},
6276     {"http:google.com/",0,PARSE_URL_FROM_PATH,0,"",S_OK,FALSE},
6277
6278     /* PARSE_SCHEMA tests. */
6279     {"http://google.com/test",0,PARSE_SCHEMA,0,"http",S_OK,FALSE},
6280     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_SCHEMA,0,"",S_OK,FALSE},
6281
6282     /* PARSE_SITE tests. */
6283     {"http://google.uk.com/",0,PARSE_SITE,0,"google.uk.com",S_OK,FALSE},
6284     {"http://google.com.com/",0,PARSE_SITE,0,"google.com.com",S_OK,FALSE},
6285     {"google.com",Uri_CREATE_ALLOW_RELATIVE,PARSE_SITE,0,"",S_OK,FALSE},
6286     {"file://server/test",0,PARSE_SITE,0,"server",S_OK,FALSE},
6287
6288     /* PARSE_DOMAIN tests. */
6289     {"http://google.com.uk/",0,PARSE_DOMAIN,0,"google.com.uk",S_OK,FALSE},
6290     {"http://google.com.com/",0,PARSE_DOMAIN,0,"com.com",S_OK,FALSE},
6291     {"test/test",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOMAIN,0,"",S_OK,FALSE},
6292     {"file://server/test",0,PARSE_DOMAIN,0,"",S_OK,FALSE},
6293
6294     /* PARSE_LOCATION and PARSE_ANCHOR tests. */
6295     {"http://google.com/test#Test",0,PARSE_ANCHOR,0,"#Test",S_OK,FALSE},
6296     {"http://google.com/test#Test",0,PARSE_LOCATION,0,"#Test",S_OK,FALSE},
6297     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_ANCHOR,0,"",S_OK,FALSE},
6298     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_LOCATION,0,"",S_OK,FALSE}
6299 };
6300
6301 static inline LPWSTR a2w(LPCSTR str) {
6302     LPWSTR ret = NULL;
6303
6304     if(str) {
6305         DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
6306         ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
6307         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
6308     }
6309
6310     return ret;
6311 }
6312
6313 static inline BOOL heap_free(void* mem) {
6314     return HeapFree(GetProcessHeap(), 0, mem);
6315 }
6316
6317 static inline DWORD strcmp_aw(LPCSTR strA, LPCWSTR strB) {
6318     LPWSTR strAW = a2w(strA);
6319     DWORD ret = lstrcmpW(strAW, strB);
6320     heap_free(strAW);
6321     return ret;
6322 }
6323
6324 static inline ULONG get_refcnt(IUri *uri) {
6325     IUri_AddRef(uri);
6326     return IUri_Release(uri);
6327 }
6328
6329 static void change_property(IUriBuilder *builder, const uri_builder_property *prop,
6330                             DWORD test_index) {
6331     HRESULT hr;
6332     LPWSTR valueW;
6333
6334     valueW = a2w(prop->value);
6335     switch(prop->property) {
6336     case Uri_PROPERTY_FRAGMENT:
6337         hr = IUriBuilder_SetFragment(builder, valueW);
6338         if(prop->todo) {
6339             todo_wine {
6340                 ok(hr == prop->expected,
6341                     "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6342                     hr, prop->expected, test_index);
6343             }
6344         } else {
6345             ok(hr == prop->expected,
6346                 "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6347                 hr, prop->expected, test_index);
6348         }
6349         break;
6350     case Uri_PROPERTY_HOST:
6351         hr = IUriBuilder_SetHost(builder, valueW);
6352         if(prop->todo) {
6353             todo_wine {
6354                 ok(hr == prop->expected,
6355                     "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6356                     hr, prop->expected, test_index);
6357             }
6358         } else {
6359             ok(hr == prop->expected,
6360                 "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6361                 hr, prop->expected, test_index);
6362         }
6363         break;
6364     case Uri_PROPERTY_PASSWORD:
6365         hr = IUriBuilder_SetPassword(builder, valueW);
6366         if(prop->todo) {
6367             todo_wine {
6368                 ok(hr == prop->expected,
6369                     "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6370                     hr, prop->expected, test_index);
6371             }
6372         } else {
6373             ok(hr == prop->expected,
6374                 "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6375                 hr, prop->expected, test_index);
6376         }
6377         break;
6378     case Uri_PROPERTY_PATH:
6379         hr = IUriBuilder_SetPath(builder, valueW);
6380         if(prop->todo) {
6381             todo_wine {
6382                 ok(hr == prop->expected,
6383                     "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6384                     hr, prop->expected, test_index);
6385             }
6386         } else {
6387             ok(hr == prop->expected,
6388                 "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6389                 hr, prop->expected, test_index);
6390         }
6391         break;
6392     case Uri_PROPERTY_QUERY:
6393         hr = IUriBuilder_SetQuery(builder, valueW);
6394         if(prop->todo) {
6395             todo_wine {
6396                 ok(hr == prop->expected,
6397                     "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6398                     hr, prop->expected, test_index);
6399             }
6400         } else {
6401             ok(hr == prop->expected,
6402                 "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6403                 hr, prop->expected, test_index);
6404         }
6405         break;
6406     case Uri_PROPERTY_SCHEME_NAME:
6407         hr = IUriBuilder_SetSchemeName(builder, valueW);
6408         if(prop->todo) {
6409             todo_wine {
6410                 ok(hr == prop->expected,
6411                     "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6412                     hr, prop->expected, test_index);
6413             }
6414         } else {
6415             ok(hr == prop->expected,
6416                 "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6417                 hr, prop->expected, test_index);
6418         }
6419         break;
6420     case Uri_PROPERTY_USER_NAME:
6421         hr = IUriBuilder_SetUserName(builder, valueW);
6422         if(prop->todo) {
6423             todo_wine {
6424                 ok(hr == prop->expected,
6425                     "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6426                     hr, prop->expected, test_index);
6427             }
6428         } else {
6429             ok(hr == prop->expected,
6430                 "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6431                 hr, prop->expected, test_index);
6432         }
6433         break;
6434     default:
6435         trace("Unsupported operation for %d on uri_builder_tests[%d].\n", prop->property, test_index);
6436     }
6437
6438     heap_free(valueW);
6439 }
6440
6441 /*
6442  * Simple tests to make sure the CreateUri function handles invalid flag combinations
6443  * correctly.
6444  */
6445 static void test_CreateUri_InvalidFlags(void) {
6446     DWORD i;
6447
6448     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
6449         HRESULT hr;
6450         IUri *uri = (void*) 0xdeadbeef;
6451
6452         hr = pCreateUri(http_urlW, invalid_flag_tests[i].flags, 0, &uri);
6453         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUri returned 0x%08x, expected 0x%08x, flags=0x%08x\n",
6454                 hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
6455         ok(uri == NULL, "Error: expected the IUri to be NULL, but it was %p instead\n", uri);
6456     }
6457 }
6458
6459 static void test_CreateUri_InvalidArgs(void) {
6460     HRESULT hr;
6461     IUri *uri = (void*) 0xdeadbeef;
6462
6463     const WCHAR invalidW[] = {'i','n','v','a','l','i','d',0};
6464     static const WCHAR emptyW[] = {0};
6465
6466     hr = pCreateUri(http_urlW, 0, 0, NULL);
6467     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6468
6469     hr = pCreateUri(NULL, 0, 0, &uri);
6470     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6471     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6472
6473     uri = (void*) 0xdeadbeef;
6474     hr = pCreateUri(invalidW, 0, 0, &uri);
6475     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6476     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6477
6478     uri = (void*) 0xdeadbeef;
6479     hr = pCreateUri(emptyW, 0, 0, &uri);
6480     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6481     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6482 }
6483
6484 static void test_CreateUri_InvalidUri(void) {
6485     DWORD i;
6486
6487     for(i = 0; i < sizeof(invalid_uri_tests)/sizeof(invalid_uri_tests[0]); ++i) {
6488         invalid_uri test = invalid_uri_tests[i];
6489         IUri *uri = NULL;
6490         LPWSTR uriW;
6491         HRESULT hr;
6492
6493         uriW = a2w(test.uri);
6494         hr = pCreateUri(uriW, test.flags, 0, &uri);
6495         if(test.todo) {
6496             todo_wine {
6497                 ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6498                     hr, E_INVALIDARG, i);
6499             }
6500         } else {
6501             ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6502                 hr, E_INVALIDARG, i);
6503         }
6504         if(uri) IUri_Release(uri);
6505
6506         heap_free(uriW);
6507     }
6508 }
6509
6510 static void test_IUri_GetPropertyBSTR(void) {
6511     IUri *uri = NULL;
6512     HRESULT hr;
6513     DWORD i;
6514
6515     /* Make sure GetPropertyBSTR handles invalid args correctly. */
6516     hr = pCreateUri(http_urlW, 0, 0, &uri);
6517     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6518     if(SUCCEEDED(hr)) {
6519         BSTR received = NULL;
6520
6521         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_RAW_URI, NULL, 0);
6522         ok(hr == E_POINTER, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6523
6524         /* Make sure it handles a invalid Uri_PROPERTY's correctly. */
6525         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_PORT, &received, 0);
6526         ok(hr == S_OK, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6527         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6528         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6529         SysFreeString(received);
6530
6531         /* Make sure it handles the ZONE property correctly. */
6532         received = NULL;
6533         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_ZONE, &received, 0);
6534         ok(hr == S_FALSE, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_FALSE);
6535         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6536         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6537         SysFreeString(received);
6538     }
6539     if(uri) IUri_Release(uri);
6540
6541     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6542         uri_properties test = uri_tests[i];
6543         LPWSTR uriW;
6544         uri = NULL;
6545
6546         uriW = a2w(test.uri);
6547         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6548         if(test.create_todo) {
6549             todo_wine {
6550                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6551                         hr, test.create_expected, i);
6552             }
6553         } else {
6554             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6555                     hr, test.create_expected, i);
6556         }
6557
6558         if(SUCCEEDED(hr)) {
6559             DWORD j;
6560
6561             /* Checks all the string properties of the uri. */
6562             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
6563                 BSTR received = NULL;
6564                 uri_str_property prop = test.str_props[j];
6565
6566                 hr = IUri_GetPropertyBSTR(uri, j, &received, 0);
6567                 if(prop.todo) {
6568                     todo_wine {
6569                         ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6570                                 hr, prop.expected, i, j);
6571                     }
6572                     todo_wine {
6573                         ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6574                                 "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6575                                 prop.value, wine_dbgstr_w(received), i, j);
6576                     }
6577                 } else {
6578                     ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6579                             hr, prop.expected, i, j);
6580                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6581                             "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6582                             prop.value, wine_dbgstr_w(received), i, j);
6583                 }
6584
6585                 SysFreeString(received);
6586             }
6587         }
6588
6589         if(uri) IUri_Release(uri);
6590
6591         heap_free(uriW);
6592     }
6593 }
6594
6595 static void test_IUri_GetPropertyDWORD(void) {
6596     IUri *uri = NULL;
6597     HRESULT hr;
6598     DWORD i;
6599
6600     hr = pCreateUri(http_urlW, 0, 0, &uri);
6601     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6602     if(SUCCEEDED(hr)) {
6603         DWORD received = 0xdeadbeef;
6604
6605         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_DWORD_START, NULL, 0);
6606         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6607
6608         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_ABSOLUTE_URI, &received, 0);
6609         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6610         ok(received == 0, "Error: Expected received=%d but instead received=%d.\n", 0, received);
6611     }
6612     if(uri) IUri_Release(uri);
6613
6614     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6615         uri_properties test = uri_tests[i];
6616         LPWSTR uriW;
6617         uri = NULL;
6618
6619         uriW = a2w(test.uri);
6620         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6621         if(test.create_todo) {
6622             todo_wine {
6623                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6624                         hr, test.create_expected, i);
6625             }
6626         } else {
6627             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6628                     hr, test.create_expected, i);
6629         }
6630
6631         if(SUCCEEDED(hr)) {
6632             DWORD j;
6633
6634             /* Checks all the DWORD properties of the uri. */
6635             for(j = 0; j < sizeof(test.dword_props)/sizeof(test.dword_props[0]); ++j) {
6636                 DWORD received;
6637                 uri_dword_property prop = test.dword_props[j];
6638
6639                 hr = IUri_GetPropertyDWORD(uri, j+Uri_PROPERTY_DWORD_START, &received, 0);
6640                 if(prop.todo) {
6641                     todo_wine {
6642                         ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
6643                                 hr, prop.expected, i, j);
6644                     }
6645                     todo_wine {
6646                         ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
6647                                 prop.value, received, i, j);
6648                     }
6649                 } else {
6650                     ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
6651                             hr, prop.expected, i, j);
6652                     ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
6653                             prop.value, received, i, j);
6654                 }
6655             }
6656         }
6657
6658         if(uri) IUri_Release(uri);
6659
6660         heap_free(uriW);
6661     }
6662 }
6663
6664 /* Tests all the 'Get*' property functions which deal with strings. */
6665 static void test_IUri_GetStrProperties(void) {
6666     IUri *uri = NULL;
6667     HRESULT hr;
6668     DWORD i;
6669
6670     /* Make sure all the 'Get*' string property functions handle invalid args correctly. */
6671     hr = pCreateUri(http_urlW, 0, 0, &uri);
6672     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6673     if(SUCCEEDED(hr)) {
6674         hr = IUri_GetAbsoluteUri(uri, NULL);
6675         ok(hr == E_POINTER, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6676
6677         hr = IUri_GetAuthority(uri, NULL);
6678         ok(hr == E_POINTER, "Error: GetAuthority returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6679
6680         hr = IUri_GetDisplayUri(uri, NULL);
6681         ok(hr == E_POINTER, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6682
6683         hr = IUri_GetDomain(uri, NULL);
6684         ok(hr == E_POINTER, "Error: GetDomain returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6685
6686         hr = IUri_GetExtension(uri, NULL);
6687         ok(hr == E_POINTER, "Error: GetExtension returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6688
6689         hr = IUri_GetFragment(uri, NULL);
6690         ok(hr == E_POINTER, "Error: GetFragment returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6691
6692         hr = IUri_GetHost(uri, NULL);
6693         ok(hr == E_POINTER, "Error: GetHost returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6694
6695         hr = IUri_GetPassword(uri, NULL);
6696         ok(hr == E_POINTER, "Error: GetPassword returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6697
6698         hr = IUri_GetPath(uri, NULL);
6699         ok(hr == E_POINTER, "Error: GetPath returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6700
6701         hr = IUri_GetPathAndQuery(uri, NULL);
6702         ok(hr == E_POINTER, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6703
6704         hr = IUri_GetQuery(uri, NULL);
6705         ok(hr == E_POINTER, "Error: GetQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6706
6707         hr = IUri_GetRawUri(uri, NULL);
6708         ok(hr == E_POINTER, "Error: GetRawUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6709
6710         hr = IUri_GetSchemeName(uri, NULL);
6711         ok(hr == E_POINTER, "Error: GetSchemeName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6712
6713         hr = IUri_GetUserInfo(uri, NULL);
6714         ok(hr == E_POINTER, "Error: GetUserInfo returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6715
6716         hr = IUri_GetUserName(uri, NULL);
6717         ok(hr == E_POINTER, "Error: GetUserName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6718     }
6719     if(uri) IUri_Release(uri);
6720
6721     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6722         uri_properties test = uri_tests[i];
6723         LPWSTR uriW;
6724         uri = NULL;
6725
6726         uriW = a2w(test.uri);
6727         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6728         if(test.create_todo) {
6729             todo_wine {
6730                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6731                         hr, test.create_expected, i);
6732             }
6733         } else {
6734             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6735                     hr, test.create_expected, i);
6736         }
6737
6738         if(SUCCEEDED(hr)) {
6739             uri_str_property prop;
6740             BSTR received = NULL;
6741
6742             /* GetAbsoluteUri() tests. */
6743             prop = test.str_props[Uri_PROPERTY_ABSOLUTE_URI];
6744             hr = IUri_GetAbsoluteUri(uri, &received);
6745             if(prop.todo) {
6746                 todo_wine {
6747                     ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6748                             hr, prop.expected, i);
6749                 }
6750                 todo_wine {
6751                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6752                             "Error: Expected %s but got %s on uri_tests[%d].\n",
6753                             prop.value, wine_dbgstr_w(received), i);
6754                 }
6755             } else {
6756                 ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6757                         hr, prop.expected, i);
6758                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6759                         "Error: Expected %s but got %s on uri_tests[%d].\n",
6760                         prop.value, wine_dbgstr_w(received), i);
6761             }
6762             SysFreeString(received);
6763             received = NULL;
6764
6765             /* GetAuthority() tests. */
6766             prop = test.str_props[Uri_PROPERTY_AUTHORITY];
6767             hr = IUri_GetAuthority(uri, &received);
6768             if(prop.todo) {
6769                 todo_wine {
6770                     ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6771                             hr, prop.expected, i);
6772                 }
6773                 todo_wine {
6774                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6775                             prop.value, wine_dbgstr_w(received), i);
6776                 }
6777             } else {
6778                 ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6779                         hr, prop.expected, i);
6780                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6781                         prop.value, wine_dbgstr_w(received), i);
6782             }
6783             SysFreeString(received);
6784             received = NULL;
6785
6786             /* GetDisplayUri() tests. */
6787             prop = test.str_props[Uri_PROPERTY_DISPLAY_URI];
6788             hr = IUri_GetDisplayUri(uri, &received);
6789             if(prop.todo) {
6790                 todo_wine {
6791                     ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6792                             hr, prop.expected, i);
6793                 }
6794                 todo_wine {
6795                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6796                             "Error: Expected %s but got %s on uri_test[%d].\n",
6797                             prop.value, wine_dbgstr_w(received), i);
6798                 }
6799             } else {
6800                 ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6801                         hr, prop.expected, i);
6802                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6803                         "Error: Expected %s but got %s on uri_tests[%d].\n",
6804                         prop.value, wine_dbgstr_w(received), i);
6805             }
6806             SysFreeString(received);
6807             received = NULL;
6808
6809             /* GetDomain() tests. */
6810             prop = test.str_props[Uri_PROPERTY_DOMAIN];
6811             hr = IUri_GetDomain(uri, &received);
6812             if(prop.todo) {
6813                 todo_wine {
6814                     ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6815                             hr, prop.expected, i);
6816                 }
6817                 todo_wine {
6818                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6819                             prop.value, wine_dbgstr_w(received), i);
6820                 }
6821             } else {
6822                 ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6823                         hr, prop.expected, i);
6824                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6825                         prop.value, wine_dbgstr_w(received), i);
6826             }
6827             SysFreeString(received);
6828             received = NULL;
6829
6830             /* GetExtension() tests. */
6831             prop = test.str_props[Uri_PROPERTY_EXTENSION];
6832             hr = IUri_GetExtension(uri, &received);
6833             if(prop.todo) {
6834                 todo_wine {
6835                     ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6836                             hr, prop.expected, i);
6837                 }
6838                 todo_wine {
6839                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6840                             prop.value, wine_dbgstr_w(received), i);
6841                 }
6842             } else {
6843                 ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6844                         hr, prop.expected, i);
6845                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6846                         prop.value, wine_dbgstr_w(received), i);
6847             }
6848             SysFreeString(received);
6849             received = NULL;
6850
6851             /* GetFragment() tests. */
6852             prop = test.str_props[Uri_PROPERTY_FRAGMENT];
6853             hr = IUri_GetFragment(uri, &received);
6854             if(prop.todo) {
6855                 todo_wine {
6856                     ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6857                             hr, prop.expected, i);
6858                 }
6859                 todo_wine {
6860                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6861                             prop.value, wine_dbgstr_w(received), i);
6862                 }
6863             } else {
6864                 ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6865                         hr, prop.expected, i);
6866                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6867                         prop.value, wine_dbgstr_w(received), i);
6868             }
6869             SysFreeString(received);
6870             received = NULL;
6871
6872             /* GetHost() tests. */
6873             prop = test.str_props[Uri_PROPERTY_HOST];
6874             hr = IUri_GetHost(uri, &received);
6875             if(prop.todo) {
6876                 todo_wine {
6877                     ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6878                             hr, prop.expected, i);
6879                 }
6880                 todo_wine {
6881                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6882                             prop.value, wine_dbgstr_w(received), i);
6883                 }
6884             } else {
6885                 ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6886                         hr, prop.expected, i);
6887                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6888                         prop.value, wine_dbgstr_w(received), i);
6889             }
6890             SysFreeString(received);
6891             received = NULL;
6892
6893             /* GetPassword() tests. */
6894             prop = test.str_props[Uri_PROPERTY_PASSWORD];
6895             hr = IUri_GetPassword(uri, &received);
6896             if(prop.todo) {
6897                 todo_wine {
6898                     ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6899                             hr, prop.expected, i);
6900                 }
6901                 todo_wine {
6902                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6903                             prop.value, wine_dbgstr_w(received), i);
6904                 }
6905             } else {
6906                 ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6907                         hr, prop.expected, i);
6908                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6909                         prop.value, wine_dbgstr_w(received), i);
6910             }
6911             SysFreeString(received);
6912             received = NULL;
6913
6914             /* GetPath() tests. */
6915             prop = test.str_props[Uri_PROPERTY_PATH];
6916             hr = IUri_GetPath(uri, &received);
6917             if(prop.todo) {
6918                 todo_wine {
6919                     ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6920                             hr, prop.expected, i);
6921                 }
6922                 todo_wine {
6923                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6924                             prop.value, wine_dbgstr_w(received), i);
6925                 }
6926             } else {
6927                 ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6928                         hr, prop.expected, i);
6929                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6930                         prop.value, wine_dbgstr_w(received), i);
6931             }
6932             SysFreeString(received);
6933             received = NULL;
6934
6935             /* GetPathAndQuery() tests. */
6936             prop = test.str_props[Uri_PROPERTY_PATH_AND_QUERY];
6937             hr = IUri_GetPathAndQuery(uri, &received);
6938             if(prop.todo) {
6939                 todo_wine {
6940                     ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6941                             hr, prop.expected, i);
6942                 }
6943                 todo_wine {
6944                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6945                             prop.value, wine_dbgstr_w(received), i);
6946                 }
6947             } else {
6948                 ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6949                         hr, prop.expected, i);
6950                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6951                         prop.value, wine_dbgstr_w(received), i);
6952             }
6953             SysFreeString(received);
6954             received = NULL;
6955
6956             /* GetQuery() tests. */
6957             prop = test.str_props[Uri_PROPERTY_QUERY];
6958             hr = IUri_GetQuery(uri, &received);
6959             if(prop.todo) {
6960                 todo_wine {
6961                     ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6962                             hr, prop.expected, i);
6963                 }
6964                 todo_wine {
6965                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6966                             prop.value, wine_dbgstr_w(received), i);
6967                 }
6968             } else {
6969                 ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6970                         hr, prop.expected, i);
6971                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6972                         prop.value, wine_dbgstr_w(received), i);
6973             }
6974             SysFreeString(received);
6975             received = NULL;
6976
6977             /* GetRawUri() tests. */
6978             prop = test.str_props[Uri_PROPERTY_RAW_URI];
6979             hr = IUri_GetRawUri(uri, &received);
6980             if(prop.todo) {
6981                 todo_wine {
6982                     ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6983                             hr, prop.expected, i);
6984                 }
6985                 todo_wine {
6986                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6987                             prop.value, wine_dbgstr_w(received), i);
6988                 }
6989             } else {
6990                 ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6991                         hr, prop.expected, i);
6992                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6993                         prop.value, wine_dbgstr_w(received), i);
6994             }
6995             SysFreeString(received);
6996             received = NULL;
6997
6998             /* GetSchemeName() tests. */
6999             prop = test.str_props[Uri_PROPERTY_SCHEME_NAME];
7000             hr = IUri_GetSchemeName(uri, &received);
7001             if(prop.todo) {
7002                 todo_wine {
7003                     ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7004                             hr, prop.expected, i);
7005                 }
7006                 todo_wine {
7007                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7008                             prop.value, wine_dbgstr_w(received), i);
7009                 }
7010             } else {
7011                 ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7012                         hr, prop.expected, i);
7013                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7014                         prop.value, wine_dbgstr_w(received), i);
7015             }
7016             SysFreeString(received);
7017             received = NULL;
7018
7019             /* GetUserInfo() tests. */
7020             prop = test.str_props[Uri_PROPERTY_USER_INFO];
7021             hr = IUri_GetUserInfo(uri, &received);
7022             if(prop.todo) {
7023                 todo_wine {
7024                     ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7025                             hr, prop.expected, i);
7026                 }
7027                 todo_wine {
7028                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7029                             prop.value, wine_dbgstr_w(received), i);
7030                 }
7031             } else {
7032                 ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7033                         hr, prop.expected, i);
7034                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7035                         prop.value, wine_dbgstr_w(received), i);
7036             }
7037             SysFreeString(received);
7038             received = NULL;
7039
7040             /* GetUserName() tests. */
7041             prop = test.str_props[Uri_PROPERTY_USER_NAME];
7042             hr = IUri_GetUserName(uri, &received);
7043             if(prop.todo) {
7044                 todo_wine {
7045                     ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7046                             hr, prop.expected, i);
7047                 }
7048                 todo_wine {
7049                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7050                             prop.value, wine_dbgstr_w(received), i);
7051                 }
7052             } else {
7053                 ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7054                         hr, prop.expected, i);
7055                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7056                         prop.value, wine_dbgstr_w(received), i);
7057             }
7058             SysFreeString(received);
7059         }
7060
7061         if(uri) IUri_Release(uri);
7062
7063         heap_free(uriW);
7064     }
7065 }
7066
7067 static void test_IUri_GetDwordProperties(void) {
7068     IUri *uri = NULL;
7069     HRESULT hr;
7070     DWORD i;
7071
7072     /* Make sure all the 'Get*' dword property functions handle invalid args correctly. */
7073     hr = pCreateUri(http_urlW, 0, 0, &uri);
7074     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7075     if(SUCCEEDED(hr)) {
7076         hr = IUri_GetHostType(uri, NULL);
7077         ok(hr == E_INVALIDARG, "Error: GetHostType returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7078
7079         hr = IUri_GetPort(uri, NULL);
7080         ok(hr == E_INVALIDARG, "Error: GetPort returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7081
7082         hr = IUri_GetScheme(uri, NULL);
7083         ok(hr == E_INVALIDARG, "Error: GetScheme returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7084
7085         hr = IUri_GetZone(uri, NULL);
7086         ok(hr == E_INVALIDARG, "Error: GetZone returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7087     }
7088     if(uri) IUri_Release(uri);
7089
7090     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7091         uri_properties test = uri_tests[i];
7092         LPWSTR uriW;
7093         uri = NULL;
7094
7095         uriW = a2w(test.uri);
7096         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7097         if(test.create_todo) {
7098             todo_wine {
7099                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7100                         hr, test.create_expected, i);
7101             }
7102         } else {
7103             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7104                     hr, test.create_expected, i);
7105         }
7106
7107         if(SUCCEEDED(hr)) {
7108             uri_dword_property prop;
7109             DWORD received;
7110
7111             /* Assign an insane value so tests don't accidentally pass when
7112              * they shouldn't!
7113              */
7114             received = -9999999;
7115
7116             /* GetHostType() tests. */
7117             prop = test.dword_props[Uri_PROPERTY_HOST_TYPE-Uri_PROPERTY_DWORD_START];
7118             hr = IUri_GetHostType(uri, &received);
7119             if(prop.todo) {
7120                 todo_wine {
7121                     ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7122                             hr, prop.expected, i);
7123                 }
7124                 todo_wine {
7125                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7126                 }
7127             } else {
7128                 ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7129                         hr, prop.expected, i);
7130                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7131             }
7132             received = -9999999;
7133
7134             /* GetPort() tests. */
7135             prop = test.dword_props[Uri_PROPERTY_PORT-Uri_PROPERTY_DWORD_START];
7136             hr = IUri_GetPort(uri, &received);
7137             if(prop.todo) {
7138                 todo_wine {
7139                     ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7140                             hr, prop.expected, i);
7141                 }
7142                 todo_wine {
7143                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7144                 }
7145             } else {
7146                 ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7147                         hr, prop.expected, i);
7148                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7149             }
7150             received = -9999999;
7151
7152             /* GetScheme() tests. */
7153             prop = test.dword_props[Uri_PROPERTY_SCHEME-Uri_PROPERTY_DWORD_START];
7154             hr = IUri_GetScheme(uri, &received);
7155             if(prop.todo) {
7156                 todo_wine {
7157                     ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7158                             hr, prop.expected, i);
7159                 }
7160                 todo_wine {
7161                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7162                 }
7163             } else {
7164                 ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7165                         hr, prop.expected, i);
7166                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7167             }
7168             received = -9999999;
7169
7170             /* GetZone() tests. */
7171             prop = test.dword_props[Uri_PROPERTY_ZONE-Uri_PROPERTY_DWORD_START];
7172             hr = IUri_GetZone(uri, &received);
7173             if(prop.todo) {
7174                 todo_wine {
7175                     ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7176                             hr, prop.expected, i);
7177                 }
7178                 todo_wine {
7179                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7180                 }
7181             } else {
7182                 ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7183                         hr, prop.expected, i);
7184                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7185             }
7186         }
7187
7188         if(uri) IUri_Release(uri);
7189
7190         heap_free(uriW);
7191     }
7192 }
7193
7194 static void test_IUri_GetPropertyLength(void) {
7195     IUri *uri = NULL;
7196     HRESULT hr;
7197     DWORD i;
7198
7199     /* Make sure it handles invalid args correctly. */
7200     hr = pCreateUri(http_urlW, 0, 0, &uri);
7201     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7202     if(SUCCEEDED(hr)) {
7203         DWORD received = 0xdeadbeef;
7204
7205         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_STRING_START, NULL, 0);
7206         ok(hr == E_INVALIDARG, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7207
7208         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_DWORD_START, &received, 0);
7209         ok(hr == E_INVALIDARG, "Error: GetPropertyLength return 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7210         ok(received == 0xdeadbeef, "Error: Expected 0xdeadbeef but got 0x%08x.\n", received);
7211     }
7212     if(uri) IUri_Release(uri);
7213
7214     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7215         uri_properties test = uri_tests[i];
7216         LPWSTR uriW;
7217         uri = NULL;
7218
7219         uriW = a2w(test.uri);
7220         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7221         if(test.create_todo) {
7222             todo_wine {
7223                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7224                         hr, test.create_expected, i);
7225             }
7226         } else {
7227             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_test[%d].\n",
7228                     hr, test.create_expected, i);
7229         }
7230
7231         if(SUCCEEDED(hr)) {
7232             DWORD j;
7233
7234             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
7235                 DWORD expectedLen, brokenLen, receivedLen;
7236                 uri_str_property prop = test.str_props[j];
7237
7238                 expectedLen = lstrlen(prop.value);
7239                 brokenLen = lstrlen(prop.broken_value);
7240
7241                 /* This won't be necessary once GetPropertyLength is implemented. */
7242                 receivedLen = -1;
7243
7244                 hr = IUri_GetPropertyLength(uri, j, &receivedLen, 0);
7245                 if(prop.todo) {
7246                     todo_wine {
7247                         ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
7248                                 hr, prop.expected, i, j);
7249                     }
7250                     todo_wine {
7251                         ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
7252                                 "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
7253                                 expectedLen, receivedLen, i, j);
7254                     }
7255                 } else {
7256                     ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
7257                             hr, prop.expected, i, j);
7258                     ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
7259                             "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
7260                             expectedLen, receivedLen, i, j);
7261                 }
7262             }
7263         }
7264
7265         if(uri) IUri_Release(uri);
7266
7267         heap_free(uriW);
7268     }
7269 }
7270
7271 static DWORD compute_expected_props(uri_properties *test)
7272 {
7273     DWORD ret = 0, i;
7274
7275     for(i=Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_STRING_LAST; i++) {
7276         if(test->str_props[i-Uri_PROPERTY_STRING_START].expected == S_OK)
7277             ret |= 1<<i;
7278     }
7279
7280     for(i=Uri_PROPERTY_DWORD_START; i <= Uri_PROPERTY_DWORD_LAST; i++) {
7281         if(test->dword_props[i-Uri_PROPERTY_DWORD_START].expected == S_OK)
7282             ret |= 1<<i;
7283     }
7284
7285     return ret;
7286 }
7287
7288 static void test_IUri_GetProperties(void) {
7289     IUri *uri = NULL;
7290     HRESULT hr;
7291     DWORD i;
7292
7293     hr = pCreateUri(http_urlW, 0, 0, &uri);
7294     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7295     if(SUCCEEDED(hr)) {
7296         hr = IUri_GetProperties(uri, NULL);
7297         ok(hr == E_INVALIDARG, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7298     }
7299     if(uri) IUri_Release(uri);
7300
7301     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7302         uri_properties test = uri_tests[i];
7303         LPWSTR uriW;
7304         uri = NULL;
7305
7306         uriW = a2w(test.uri);
7307         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7308         if(test.create_todo) {
7309             todo_wine {
7310                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7311             }
7312         } else {
7313             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7314         }
7315
7316         if(SUCCEEDED(hr)) {
7317             DWORD received = 0, expected_props;
7318             DWORD j;
7319
7320             hr = IUri_GetProperties(uri, &received);
7321             ok(hr == S_OK, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7322
7323             expected_props = compute_expected_props(&test);
7324
7325             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
7326                 /* (1 << j) converts a Uri_PROPERTY to its corresponding Uri_HAS_* flag mask. */
7327                 if(expected_props & (1 << j))
7328                     ok(received & (1 << j), "Error: Expected flag for property %d on uri_tests[%d].\n", j, i);
7329                 else
7330                     ok(!(received & (1 << j)), "Error: Received flag for property %d when not expected on uri_tests[%d].\n", j, i);
7331             }
7332         }
7333
7334         if(uri) IUri_Release(uri);
7335
7336         heap_free(uriW);
7337     }
7338 }
7339
7340 static void test_IUri_HasProperty(void) {
7341     IUri *uri = NULL;
7342     HRESULT hr;
7343     DWORD i;
7344
7345     hr = pCreateUri(http_urlW, 0, 0, &uri);
7346     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7347     if(SUCCEEDED(hr)) {
7348         hr = IUri_HasProperty(uri, Uri_PROPERTY_RAW_URI, NULL);
7349         ok(hr == E_INVALIDARG, "Error: HasProperty returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7350     }
7351     if(uri) IUri_Release(uri);
7352
7353     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7354         uri_properties test = uri_tests[i];
7355         LPWSTR uriW;
7356         uri = NULL;
7357
7358         uriW = a2w(test.uri);
7359
7360         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7361         if(test.create_todo) {
7362             todo_wine {
7363                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7364             }
7365         } else {
7366             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7367         }
7368
7369         if(SUCCEEDED(hr)) {
7370             DWORD expected_props, j;
7371
7372             expected_props = compute_expected_props(&test);
7373
7374             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
7375                 /* Assign -1, then explicitly test for TRUE or FALSE later. */
7376                 BOOL received = -1;
7377
7378                 hr = IUri_HasProperty(uri, j, &received);
7379                 ok(hr == S_OK, "Error: HasProperty returned 0x%08x, expected 0x%08x for property %d on uri_tests[%d].\n",
7380                         hr, S_OK, j, i);
7381
7382                 if(expected_props & (1 << j)) {
7383                     ok(received == TRUE, "Error: Expected to have property %d on uri_tests[%d].\n", j, i);
7384                 } else {
7385                     ok(received == FALSE, "Error: Wasn't expecting to have property %d on uri_tests[%d].\n", j, i);
7386                 }
7387             }
7388         }
7389
7390         if(uri) IUri_Release(uri);
7391
7392         heap_free(uriW);
7393     }
7394 }
7395
7396 static void test_IUri_IsEqual(void) {
7397     IUri *uriA, *uriB;
7398     HRESULT hrA, hrB;
7399     DWORD i;
7400
7401     uriA = uriB = NULL;
7402
7403     /* Make sure IsEqual handles invalid args correctly. */
7404     hrA = pCreateUri(http_urlW, 0, 0, &uriA);
7405     hrB = pCreateUri(http_urlW, 0, 0, &uriB);
7406     ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hrA, S_OK);
7407     ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hrB, S_OK);
7408     if(SUCCEEDED(hrA) && SUCCEEDED(hrB)) {
7409         BOOL equal = -1;
7410         hrA = IUri_IsEqual(uriA, NULL, &equal);
7411         ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hrA, S_OK);
7412         ok(equal == FALSE, "Error: Expected equal to be FALSE, but was %d instead.\n", equal);
7413
7414         hrA = IUri_IsEqual(uriA, uriB, NULL);
7415         ok(hrA == E_POINTER, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hrA, E_POINTER);
7416     }
7417     if(uriA) IUri_Release(uriA);
7418     if(uriB) IUri_Release(uriB);
7419
7420     for(i = 0; i < sizeof(equality_tests)/sizeof(equality_tests[0]); ++i) {
7421         uri_equality test = equality_tests[i];
7422         LPWSTR uriA_W, uriB_W;
7423
7424         uriA = uriB = NULL;
7425
7426         uriA_W = a2w(test.a);
7427         uriB_W = a2w(test.b);
7428
7429         hrA = pCreateUri(uriA_W, test.create_flags_a, 0, &uriA);
7430         if(test.create_todo_a) {
7431             todo_wine {
7432                 ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n",
7433                         hrA, S_OK, i);
7434             }
7435         } else {
7436             ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n",
7437                     hrA, S_OK, i);
7438         }
7439
7440         hrB = pCreateUri(uriB_W, test.create_flags_b, 0, &uriB);
7441         if(test.create_todo_b) {
7442             todo_wine {
7443                 ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n",
7444                         hrB, S_OK, i);
7445             }
7446         } else {
7447             ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n",
7448                     hrB, S_OK, i);
7449         }
7450
7451         if(SUCCEEDED(hrA) && SUCCEEDED(hrB)) {
7452             BOOL equal = -1;
7453
7454             hrA = IUri_IsEqual(uriA, uriB, &equal);
7455             if(test.todo) {
7456                 todo_wine {
7457                     ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n",
7458                             hrA, S_OK, i);
7459                 }
7460                 todo_wine {
7461                     ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7462                 }
7463             } else {
7464                 ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n", hrA, S_OK, i);
7465                 ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7466             }
7467         }
7468         if(uriA) IUri_Release(uriA);
7469         if(uriB) IUri_Release(uriB);
7470
7471         heap_free(uriA_W);
7472         heap_free(uriB_W);
7473     }
7474 }
7475
7476 static void test_CreateUriWithFragment_InvalidArgs(void) {
7477     HRESULT hr;
7478     IUri *uri = (void*) 0xdeadbeef;
7479     const WCHAR fragmentW[] = {'#','f','r','a','g','m','e','n','t',0};
7480
7481     hr = pCreateUriWithFragment(NULL, fragmentW, 0, 0, &uri);
7482     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7483     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7484
7485     hr = pCreateUriWithFragment(http_urlW, fragmentW, 0, 0, NULL);
7486     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7487
7488     /* Original URI can't already contain a fragment component. */
7489     uri = (void*) 0xdeadbeef;
7490     hr = pCreateUriWithFragment(http_url_fragW, fragmentW, 0, 0, &uri);
7491     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7492     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7493 }
7494
7495 /* CreateUriWithFragment has the same invalid flag combinations as CreateUri. */
7496 static void test_CreateUriWithFragment_InvalidFlags(void) {
7497     DWORD i;
7498
7499     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
7500         HRESULT hr;
7501         IUri *uri = (void*) 0xdeadbeef;
7502
7503         hr = pCreateUriWithFragment(http_urlW, NULL, invalid_flag_tests[i].flags, 0, &uri);
7504         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x. flags=0x%08x.\n",
7505             hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
7506         ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7507     }
7508 }
7509
7510 static void test_CreateUriWithFragment(void) {
7511     DWORD i;
7512
7513     for(i = 0; i < sizeof(uri_fragment_tests)/sizeof(uri_fragment_tests[0]); ++i) {
7514         HRESULT hr;
7515         IUri *uri = NULL;
7516         LPWSTR uriW, fragW;
7517         uri_with_fragment test = uri_fragment_tests[i];
7518
7519         uriW = a2w(test.uri);
7520         fragW = a2w(test.fragment);
7521
7522         hr = pCreateUriWithFragment(uriW, fragW, test.create_flags, 0, &uri);
7523         if(test.expected_todo) {
7524             todo_wine {
7525                 ok(hr == test.create_expected,
7526                     "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7527                     hr, test.create_expected, i);
7528             }
7529         } else
7530             ok(hr == test.create_expected,
7531                 "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7532                 hr, test.create_expected, i);
7533
7534         if(SUCCEEDED(hr)) {
7535             BSTR received = NULL;
7536
7537             hr = IUri_GetAbsoluteUri(uri, &received);
7538             if(test.expected_todo) {
7539                 todo_wine {
7540                     ok(hr == S_OK,
7541                         "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7542                         hr, S_OK, i);
7543                 }
7544                 todo_wine {
7545                     ok(!strcmp_aw(test.expected_uri, received),
7546                         "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7547                         test.expected_uri, wine_dbgstr_w(received), i);
7548                 }
7549             } else {
7550                 ok(hr == S_OK, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7551                     hr, S_OK, i);
7552                 ok(!strcmp_aw(test.expected_uri, received), "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7553                     test.expected_uri, wine_dbgstr_w(received), i);
7554             }
7555
7556             SysFreeString(received);
7557         }
7558
7559         if(uri) IUri_Release(uri);
7560         heap_free(uriW);
7561         heap_free(fragW);
7562     }
7563 }
7564
7565 static void test_CreateIUriBuilder(void) {
7566     HRESULT hr;
7567     IUriBuilder *builder = NULL;
7568     IUri *uri;
7569
7570     hr = pCreateIUriBuilder(NULL, 0, 0, NULL);
7571     ok(hr == E_POINTER, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x\n",
7572         hr, E_POINTER);
7573
7574     /* CreateIUriBuilder increases the ref count of the IUri it receives. */
7575     hr = pCreateUri(http_urlW, 0, 0, &uri);
7576     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7577     if(SUCCEEDED(hr)) {
7578         ULONG cur_count, orig_count;
7579
7580         orig_count = get_refcnt(uri);
7581         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
7582         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7583         ok(builder != NULL, "Error: Expecting builder not to be NULL\n");
7584
7585         cur_count = get_refcnt(uri);
7586         ok(cur_count == orig_count+1, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count+1, cur_count);
7587
7588         if(builder) IUriBuilder_Release(builder);
7589         cur_count = get_refcnt(uri);
7590         ok(cur_count == orig_count, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count, cur_count);
7591     }
7592     if(uri) IUri_Release(uri);
7593 }
7594
7595 static void test_IUriBuilder_CreateUri(IUriBuilder *builder, const uri_builder_test *test,
7596                                        DWORD test_index) {
7597     HRESULT hr;
7598     IUri *uri = NULL;
7599
7600     hr = IUriBuilder_CreateUri(builder, test->uri_flags, 0, 0, &uri);
7601     if(test->uri_todo) {
7602         todo_wine {
7603             ok(hr == test->uri_hres,
7604                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7605                 hr, test->uri_hres, test_index);
7606         }
7607     } else {
7608         ok(hr == test->uri_hres,
7609             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7610             hr, test->uri_hres, test_index);
7611     }
7612
7613     if(SUCCEEDED(hr)) {
7614         DWORD i;
7615
7616         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7617             uri_builder_str_property prop = test->expected_str_props[i];
7618             BSTR received = NULL;
7619
7620             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7621             if(prop.todo) {
7622                 todo_wine {
7623                     ok(hr == prop.result,
7624                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7625                         hr, prop.result, test_index, i);
7626                 }
7627             } else {
7628                 ok(hr == prop.result,
7629                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7630                     hr, prop.result, test_index, i);
7631             }
7632             if(SUCCEEDED(hr)) {
7633                 if(prop.todo) {
7634                     todo_wine {
7635                         ok(!strcmp_aw(prop.expected, received),
7636                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7637                             prop.expected, wine_dbgstr_w(received), test_index, i);
7638                     }
7639                 } else {
7640                     ok(!strcmp_aw(prop.expected, received),
7641                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7642                         prop.expected, wine_dbgstr_w(received), test_index, i);
7643                 }
7644             }
7645             SysFreeString(received);
7646         }
7647
7648         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7649             uri_builder_dword_property prop = test->expected_dword_props[i];
7650             DWORD received = -2;
7651
7652             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7653             if(prop.todo) {
7654                 todo_wine {
7655                     ok(hr == prop.result,
7656                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7657                         hr, prop.result, test_index, i);
7658                 }
7659             } else {
7660                 ok(hr == prop.result,
7661                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7662                     hr, prop.result, test_index, i);
7663             }
7664             if(SUCCEEDED(hr)) {
7665                 if(prop.todo) {
7666                     todo_wine {
7667                         ok(received == prop.expected,
7668                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7669                             prop.expected, received, test_index, i);
7670                     }
7671                 } else {
7672                     ok(received == prop.expected,
7673                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7674                         prop.expected, received, test_index, i);
7675                 }
7676             }
7677         }
7678     }
7679     if(uri) IUri_Release(uri);
7680 }
7681
7682 static void test_IUriBuilder_CreateUriSimple(IUriBuilder *builder, const uri_builder_test *test,
7683                                        DWORD test_index) {
7684     HRESULT hr;
7685     IUri *uri = NULL;
7686
7687     hr = IUriBuilder_CreateUriSimple(builder, test->uri_simple_encode_flags, 0, &uri);
7688     if(test->uri_simple_todo) {
7689         todo_wine {
7690             ok(hr == test->uri_simple_hres,
7691                 "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7692                 hr, test->uri_simple_hres, test_index);
7693         }
7694     } else {
7695         ok(hr == test->uri_simple_hres,
7696             "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7697             hr, test->uri_simple_hres, test_index);
7698     }
7699
7700     if(SUCCEEDED(hr)) {
7701         DWORD i;
7702
7703         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7704             uri_builder_str_property prop = test->expected_str_props[i];
7705             BSTR received = NULL;
7706
7707             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7708             if(prop.todo) {
7709                 todo_wine {
7710                     ok(hr == prop.result,
7711                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7712                         hr, prop.result, test_index, i);
7713                 }
7714             } else {
7715                 ok(hr == prop.result,
7716                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7717                     hr, prop.result, test_index, i);
7718             }
7719             if(SUCCEEDED(hr)) {
7720                 if(prop.todo) {
7721                     todo_wine {
7722                         ok(!strcmp_aw(prop.expected, received),
7723                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7724                             prop.expected, wine_dbgstr_w(received), test_index, i);
7725                     }
7726                 } else {
7727                     ok(!strcmp_aw(prop.expected, received),
7728                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7729                         prop.expected, wine_dbgstr_w(received), test_index, i);
7730                 }
7731             }
7732             SysFreeString(received);
7733         }
7734
7735         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7736             uri_builder_dword_property prop = test->expected_dword_props[i];
7737             DWORD received = -2;
7738
7739             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7740             if(prop.todo) {
7741                 todo_wine {
7742                     ok(hr == prop.result,
7743                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7744                         hr, prop.result, test_index, i);
7745                 }
7746             } else {
7747                 ok(hr == prop.result,
7748                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7749                     hr, prop.result, test_index, i);
7750             }
7751             if(SUCCEEDED(hr)) {
7752                 if(prop.todo) {
7753                     todo_wine {
7754                         ok(received == prop.expected,
7755                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7756                             prop.expected, received, test_index, i);
7757                     }
7758                 } else {
7759                     ok(received == prop.expected,
7760                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7761                         prop.expected, received, test_index, i);
7762                 }
7763             }
7764         }
7765     }
7766     if(uri) IUri_Release(uri);
7767 }
7768
7769 static void test_IUriBuilder_CreateUriWithFlags(IUriBuilder *builder, const uri_builder_test *test,
7770                                                 DWORD test_index) {
7771     HRESULT hr;
7772     IUri *uri = NULL;
7773
7774     hr = IUriBuilder_CreateUriWithFlags(builder, test->uri_with_flags, test->uri_with_builder_flags,
7775                                         test->uri_with_encode_flags, 0, &uri);
7776     if(test->uri_with_todo) {
7777         todo_wine {
7778             ok(hr == test->uri_with_hres,
7779                 "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7780                 hr, test->uri_with_hres, test_index);
7781         }
7782     } else {
7783         ok(hr == test->uri_with_hres,
7784             "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7785             hr, test->uri_with_hres, test_index);
7786     }
7787
7788     if(SUCCEEDED(hr)) {
7789         DWORD i;
7790
7791         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7792             uri_builder_str_property prop = test->expected_str_props[i];
7793             BSTR received = NULL;
7794
7795             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7796             if(prop.todo) {
7797                 todo_wine {
7798                     ok(hr == prop.result,
7799                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7800                         hr, prop.result, test_index, i);
7801                 }
7802             } else {
7803                 ok(hr == prop.result,
7804                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7805                     hr, prop.result, test_index, i);
7806             }
7807             if(SUCCEEDED(hr)) {
7808                 if(prop.todo) {
7809                     todo_wine {
7810                         ok(!strcmp_aw(prop.expected, received),
7811                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7812                             prop.expected, wine_dbgstr_w(received), test_index, i);
7813                     }
7814                 } else {
7815                     ok(!strcmp_aw(prop.expected, received),
7816                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7817                         prop.expected, wine_dbgstr_w(received), test_index, i);
7818                 }
7819             }
7820             SysFreeString(received);
7821         }
7822
7823         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7824             uri_builder_dword_property prop = test->expected_dword_props[i];
7825             DWORD received = -2;
7826
7827             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7828             if(prop.todo) {
7829                 todo_wine {
7830                     ok(hr == prop.result,
7831                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7832                         hr, prop.result, test_index, i);
7833                 }
7834             } else {
7835                 ok(hr == prop.result,
7836                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7837                     hr, prop.result, test_index, i);
7838             }
7839             if(SUCCEEDED(hr)) {
7840                 if(prop.todo) {
7841                     todo_wine {
7842                         ok(received == prop.expected,
7843                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7844                             prop.expected, received, test_index, i);
7845                     }
7846                 } else {
7847                     ok(received == prop.expected,
7848                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7849                         prop.expected, received, test_index, i);
7850                 }
7851             }
7852         }
7853     }
7854     if(uri) IUri_Release(uri);
7855 }
7856
7857 static void test_IUriBuilder_CreateInvalidArgs(void) {
7858     IUriBuilder *builder;
7859     HRESULT hr;
7860
7861     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
7862     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7863     if(SUCCEEDED(hr)) {
7864         IUri *test = NULL, *uri = (void*) 0xdeadbeef;
7865
7866         /* Test what happens if the IUriBuilder doesn't have a IUri set. */
7867         hr = IUriBuilder_CreateUri(builder, 0, 0, 0, NULL);
7868         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7869
7870         uri = (void*) 0xdeadbeef;
7871         hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
7872         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_NOTIMPL);
7873         ok(uri == NULL, "Error: expected uri to be NULL, but was %p instead.\n", uri);
7874
7875         hr = IUriBuilder_CreateUriSimple(builder, 0, 0, NULL);
7876         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
7877             hr, E_POINTER);
7878
7879         uri = (void*) 0xdeadbeef;
7880         hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
7881         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
7882             hr, E_NOTIMPL);
7883         ok(!uri, "Error: Expected uri to NULL, but was %p instead.\n", uri);
7884
7885         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, NULL);
7886         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
7887             hr, E_POINTER);
7888
7889         uri = (void*) 0xdeadbeef;
7890         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
7891         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
7892             hr, E_NOTIMPL);
7893         ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7894
7895         hr = pCreateUri(http_urlW, 0, 0, &test);
7896         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7897         if(SUCCEEDED(hr)) {
7898             hr = IUriBuilder_SetIUri(builder, test);
7899             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7900
7901             /* No longer returns E_NOTIMPL, since a IUri has been set and hasn't been modified. */
7902             uri = NULL;
7903             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
7904             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7905             ok(uri != NULL, "Error: The uri was NULL.\n");
7906             if(uri) IUri_Release(uri);
7907
7908             uri = NULL;
7909             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
7910             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
7911                 hr, S_OK);
7912             ok(uri != NULL, "Error: uri was NULL.\n");
7913             if(uri) IUri_Release(uri);
7914
7915             uri = NULL;
7916             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &uri);
7917             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
7918                 hr, S_OK);
7919             ok(uri != NULL, "Error: uri was NULL.\n");
7920             if(uri) IUri_Release(uri);
7921
7922             hr = IUriBuilder_SetFragment(builder, NULL);
7923             ok(hr == S_OK, "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7924
7925             /* The IUriBuilder is changed, so it returns E_NOTIMPL again. */
7926             uri = (void*) 0xdeadbeef;
7927             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
7928             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7929             ok(!uri, "Error: Expected uri to be NULL but was %p instead.\n", uri);
7930
7931             uri = (void*) 0xdeadbeef;
7932             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
7933             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
7934                 hr, S_OK);
7935             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7936
7937             uri = (void*) 0xdeadbeef;
7938             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
7939             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
7940                 hr, E_NOTIMPL);
7941             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7942         }
7943         if(test) IUri_Release(test);
7944     }
7945     if(builder) IUriBuilder_Release(builder);
7946 }
7947
7948 /* Tests invalid args to the "Get*" functions. */
7949 static void test_IUriBuilder_GetInvalidArgs(void) {
7950     IUriBuilder *builder = NULL;
7951     HRESULT hr;
7952
7953     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
7954     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7955     if(SUCCEEDED(hr)) {
7956         LPCWSTR received = (void*) 0xdeadbeef;
7957         DWORD len = -1, port = -1;
7958         BOOL set = -1;
7959
7960         hr = IUriBuilder_GetFragment(builder, NULL, NULL);
7961         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
7962             hr, E_POINTER);
7963         hr = IUriBuilder_GetFragment(builder, NULL, &received);
7964         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
7965             hr, E_POINTER);
7966         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7967         hr = IUriBuilder_GetFragment(builder, &len, NULL);
7968         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
7969             hr, E_POINTER);
7970         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7971
7972         hr = IUriBuilder_GetHost(builder, NULL, NULL);
7973         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
7974             hr, E_POINTER);
7975         received = (void*) 0xdeadbeef;
7976         hr = IUriBuilder_GetHost(builder, NULL, &received);
7977         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
7978             hr, E_POINTER);
7979         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7980         len = -1;
7981         hr = IUriBuilder_GetHost(builder, &len, NULL);
7982         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
7983             hr, E_POINTER);
7984         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7985
7986         hr = IUriBuilder_GetPassword(builder, NULL, NULL);
7987         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
7988             hr, E_POINTER);
7989         received = (void*) 0xdeadbeef;
7990         hr = IUriBuilder_GetPassword(builder, NULL, &received);
7991         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
7992             hr, E_POINTER);
7993         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7994         len = -1;
7995         hr = IUriBuilder_GetPassword(builder, &len, NULL);
7996         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
7997             hr, E_POINTER);
7998         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7999
8000         hr = IUriBuilder_GetPath(builder, NULL, NULL);
8001         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8002             hr, E_POINTER);
8003         received = (void*) 0xdeadbeef;
8004         hr = IUriBuilder_GetPath(builder, NULL, &received);
8005         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8006             hr, E_POINTER);
8007         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8008         len = -1;
8009         hr = IUriBuilder_GetPath(builder, &len, NULL);
8010         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8011             hr, E_POINTER);
8012         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8013
8014         hr = IUriBuilder_GetPort(builder, NULL, NULL);
8015         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8016             hr, E_POINTER);
8017         hr = IUriBuilder_GetPort(builder, NULL, &port);
8018         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8019             hr, E_POINTER);
8020         ok(!port, "Error: Expected port to be 0, but was %d instead.\n", port);
8021         hr = IUriBuilder_GetPort(builder, &set, NULL);
8022         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8023             hr, E_POINTER);
8024         ok(!set, "Error: Expected set to be FALSE, but was %d instead.\n", set);
8025
8026         hr = IUriBuilder_GetQuery(builder, NULL, NULL);
8027         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8028             hr, E_POINTER);
8029         received = (void*) 0xdeadbeef;
8030         hr = IUriBuilder_GetQuery(builder, NULL, &received);
8031         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8032             hr, E_POINTER);
8033         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8034         len = -1;
8035         hr = IUriBuilder_GetQuery(builder, &len, NULL);
8036         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8037             hr, E_POINTER);
8038         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8039
8040         hr = IUriBuilder_GetSchemeName(builder, NULL, NULL);
8041         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8042             hr, E_POINTER);
8043         received = (void*) 0xdeadbeef;
8044         hr = IUriBuilder_GetSchemeName(builder, NULL, &received);
8045         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8046             hr, E_POINTER);
8047         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8048         len = -1;
8049         hr = IUriBuilder_GetSchemeName(builder, &len, NULL);
8050         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8051             hr, E_POINTER);
8052         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8053
8054         hr = IUriBuilder_GetUserName(builder, NULL, NULL);
8055         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8056             hr, E_POINTER);
8057         received = (void*) 0xdeadbeef;
8058         hr = IUriBuilder_GetUserName(builder, NULL, &received);
8059         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8060             hr, E_POINTER);
8061         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8062         len = -1;
8063         hr = IUriBuilder_GetUserName(builder, &len, NULL);
8064         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8065             hr, E_POINTER);
8066         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8067     }
8068     if(builder) IUriBuilder_Release(builder);
8069 }
8070
8071 static void test_IUriBuilder_GetFragment(IUriBuilder *builder, const uri_builder_test *test,
8072                                          DWORD test_index) {
8073     HRESULT hr;
8074     DWORD i;
8075     LPCWSTR received = NULL;
8076     DWORD len = -1;
8077     const uri_builder_property *prop = NULL;
8078
8079     /* Check if the property was set earlier. */
8080     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8081         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_FRAGMENT)
8082             prop = &(test->properties[i]);
8083     }
8084
8085     if(prop) {
8086         /* Use expected_value unless it's NULL, then use value. */
8087         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8088         hr = IUriBuilder_GetFragment(builder, &len, &received);
8089         if(prop->todo) {
8090             todo_wine {
8091                 ok(hr == (expected ? S_OK : S_FALSE),
8092                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8093                     hr, (expected ? S_OK : S_FALSE), test_index);
8094             }
8095             if(SUCCEEDED(hr)) {
8096                 todo_wine {
8097                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8098                         expected, wine_dbgstr_w(received), test_index);
8099                 }
8100                 todo_wine {
8101                     ok(lstrlen(expected) == len,
8102                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8103                         lstrlen(expected), len, test_index);
8104                 }
8105             }
8106         } else {
8107             ok(hr == (expected ? S_OK : S_FALSE),
8108                 "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8109                 hr, (expected ? S_OK : S_FALSE), test_index);
8110             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8111                 expected, wine_dbgstr_w(received), test_index);
8112             ok(lstrlen(expected) == len,
8113                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8114                 lstrlen(expected), len, test_index);
8115         }
8116     } else {
8117         /* The property wasn't set earlier, so it should return whatever
8118          * the base IUri contains (if anything).
8119          */
8120         IUri *uri = NULL;
8121         hr = IUriBuilder_GetIUri(builder, &uri);
8122         ok(hr == S_OK,
8123             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8124             hr, S_OK, test_index);
8125         if(SUCCEEDED(hr)) {
8126             if(!uri) {
8127                 received = (void*) 0xdeadbeef;
8128                 len = -1;
8129
8130                 hr = IUriBuilder_GetFragment(builder, &len, &received);
8131                 ok(hr == S_FALSE,
8132                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8133                     hr, S_FALSE, test_index);
8134                 if(SUCCEEDED(hr)) {
8135                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8136                         len, test_index);
8137                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8138                         received, test_index);
8139                 }
8140             } else {
8141                 BOOL has_prop = FALSE;
8142                 BSTR expected = NULL;
8143
8144                 hr = IUri_GetFragment(uri, &expected);
8145                 ok(SUCCEEDED(hr),
8146                     "Error: Expected IUri_GetFragment to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8147                     hr, test_index);
8148                 has_prop = hr == S_OK;
8149
8150                 hr = IUriBuilder_GetFragment(builder, &len, &received);
8151                 if(has_prop) {
8152                     ok(hr == S_OK,
8153                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8154                         hr, S_OK, test_index);
8155                     if(SUCCEEDED(hr)) {
8156                         ok(!lstrcmpW(expected, received),
8157                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8158                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8159                         ok(lstrlenW(expected) == len,
8160                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8161                             lstrlenW(expected), len, test_index);
8162                     }
8163                 } else {
8164                     ok(hr == S_FALSE,
8165                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8166                         hr, S_FALSE, test_index);
8167                     if(SUCCEEDED(hr)) {
8168                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8169                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8170                             len, test_index);
8171                     }
8172                 }
8173                 SysFreeString(expected);
8174             }
8175         }
8176         if(uri) IUri_Release(uri);
8177     }
8178 }
8179
8180 static void test_IUriBuilder_GetHost(IUriBuilder *builder, const uri_builder_test *test,
8181                                      DWORD test_index) {
8182     HRESULT hr;
8183     DWORD i;
8184     LPCWSTR received = NULL;
8185     DWORD len = -1;
8186     const uri_builder_property *prop = NULL;
8187
8188     /* Check if the property was set earlier. */
8189     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8190         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_HOST)
8191             prop = &(test->properties[i]);
8192     }
8193
8194     if(prop) {
8195         /* Use expected_value unless it's NULL, then use value. */
8196         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8197         hr = IUriBuilder_GetHost(builder, &len, &received);
8198         if(prop->todo) {
8199             todo_wine {
8200                 ok(hr == (expected ? S_OK : S_FALSE),
8201                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8202                     hr, (expected ? S_OK : S_FALSE), test_index);
8203             }
8204             if(SUCCEEDED(hr)) {
8205                 todo_wine {
8206                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8207                         expected, wine_dbgstr_w(received), test_index);
8208                 }
8209                 todo_wine {
8210                     ok(lstrlen(expected) == len,
8211                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8212                         lstrlen(expected), len, test_index);
8213                 }
8214             }
8215         } else {
8216             ok(hr == (expected ? S_OK : S_FALSE),
8217                 "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8218                 hr, (expected ? S_OK : S_FALSE), test_index);
8219             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8220                 expected, wine_dbgstr_w(received), test_index);
8221             ok(lstrlen(expected) == len,
8222                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8223                 lstrlen(expected), len, test_index);
8224         }
8225     } else {
8226         /* The property wasn't set earlier, so it should return whatever
8227          * the base IUri contains (if anything).
8228          */
8229         IUri *uri = NULL;
8230         hr = IUriBuilder_GetIUri(builder, &uri);
8231         ok(hr == S_OK,
8232             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8233             hr, S_OK, test_index);
8234         if(SUCCEEDED(hr)) {
8235             if(!uri) {
8236                 received = (void*) 0xdeadbeef;
8237                 len = -1;
8238
8239                 hr = IUriBuilder_GetHost(builder, &len, &received);
8240                 ok(hr == S_FALSE,
8241                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8242                     hr, S_FALSE, test_index);
8243                 if(SUCCEEDED(hr)) {
8244                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8245                         len, test_index);
8246                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8247                         received, test_index);
8248                 }
8249             } else {
8250                 BOOL has_prop = FALSE;
8251                 BSTR expected = NULL;
8252
8253                 hr = IUri_GetHost(uri, &expected);
8254                 ok(SUCCEEDED(hr),
8255                     "Error: Expected IUri_GetHost to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8256                     hr, test_index);
8257                 has_prop = hr == S_OK;
8258
8259                 hr = IUriBuilder_GetHost(builder, &len, &received);
8260                 if(has_prop) {
8261                     ok(hr == S_OK,
8262                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8263                         hr, S_OK, test_index);
8264                     if(SUCCEEDED(hr)) {
8265                         ok(!lstrcmpW(expected, received),
8266                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8267                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8268                         ok(lstrlenW(expected) == len,
8269                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8270                             lstrlenW(expected), len, test_index);
8271                     }
8272                 } else {
8273                     ok(hr == S_FALSE,
8274                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8275                         hr, S_FALSE, test_index);
8276                     if(SUCCEEDED(hr)) {
8277                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8278                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8279                             len, test_index);
8280                     }
8281                 }
8282                 SysFreeString(expected);
8283             }
8284         }
8285         if(uri) IUri_Release(uri);
8286     }
8287 }
8288
8289 static void test_IUriBuilder_GetPassword(IUriBuilder *builder, const uri_builder_test *test,
8290                                          DWORD test_index) {
8291     HRESULT hr;
8292     DWORD i;
8293     LPCWSTR received = NULL;
8294     DWORD len = -1;
8295     const uri_builder_property *prop = NULL;
8296
8297     /* Check if the property was set earlier. */
8298     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8299         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PASSWORD)
8300             prop = &(test->properties[i]);
8301     }
8302
8303     if(prop) {
8304         /* Use expected_value unless it's NULL, then use value. */
8305         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8306         hr = IUriBuilder_GetPassword(builder, &len, &received);
8307         if(prop->todo) {
8308             todo_wine {
8309                 ok(hr == (expected ? S_OK : S_FALSE),
8310                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8311                     hr, (expected ? S_OK : S_FALSE), test_index);
8312             }
8313             if(SUCCEEDED(hr)) {
8314                 todo_wine {
8315                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8316                         expected, wine_dbgstr_w(received), test_index);
8317                 }
8318                 todo_wine {
8319                     ok(lstrlen(expected) == len,
8320                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8321                         lstrlen(expected), len, test_index);
8322                 }
8323             }
8324         } else {
8325             ok(hr == (expected ? S_OK : S_FALSE),
8326                 "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8327                 hr, (expected ? S_OK : S_FALSE), test_index);
8328             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8329                 expected, wine_dbgstr_w(received), test_index);
8330             ok(lstrlen(expected) == len,
8331                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8332                 lstrlen(expected), len, test_index);
8333         }
8334     } else {
8335         /* The property wasn't set earlier, so it should return whatever
8336          * the base IUri contains (if anything).
8337          */
8338         IUri *uri = NULL;
8339         hr = IUriBuilder_GetIUri(builder, &uri);
8340         ok(hr == S_OK,
8341             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8342             hr, S_OK, test_index);
8343         if(SUCCEEDED(hr)) {
8344             if(!uri) {
8345                 received = (void*) 0xdeadbeef;
8346                 len = -1;
8347
8348                 hr = IUriBuilder_GetPassword(builder, &len, &received);
8349                 ok(hr == S_FALSE,
8350                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8351                     hr, S_FALSE, test_index);
8352                 if(SUCCEEDED(hr)) {
8353                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8354                         len, test_index);
8355                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8356                         received, test_index);
8357                 }
8358             } else {
8359                 BOOL has_prop = FALSE;
8360                 BSTR expected = NULL;
8361
8362                 hr = IUri_GetPassword(uri, &expected);
8363                 ok(SUCCEEDED(hr),
8364                     "Error: Expected IUri_GetPassword to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8365                     hr, test_index);
8366                 has_prop = hr == S_OK;
8367
8368                 hr = IUriBuilder_GetPassword(builder, &len, &received);
8369                 if(has_prop) {
8370                     ok(hr == S_OK,
8371                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8372                         hr, S_OK, test_index);
8373                     if(SUCCEEDED(hr)) {
8374                         ok(!lstrcmpW(expected, received),
8375                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8376                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8377                         ok(lstrlenW(expected) == len,
8378                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8379                             lstrlenW(expected), len, test_index);
8380                     }
8381                 } else {
8382                     ok(hr == S_FALSE,
8383                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8384                         hr, S_FALSE, test_index);
8385                     if(SUCCEEDED(hr)) {
8386                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8387                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8388                             len, test_index);
8389                     }
8390                 }
8391                 SysFreeString(expected);
8392             }
8393         }
8394         if(uri) IUri_Release(uri);
8395     }
8396 }
8397
8398 static void test_IUriBuilder_GetPath(IUriBuilder *builder, const uri_builder_test *test,
8399                                      DWORD test_index) {
8400     HRESULT hr;
8401     DWORD i;
8402     LPCWSTR received = NULL;
8403     DWORD len = -1;
8404     const uri_builder_property *prop = NULL;
8405
8406     /* Check if the property was set earlier. */
8407     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8408         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PATH)
8409             prop = &(test->properties[i]);
8410     }
8411
8412     if(prop) {
8413         /* Use expected_value unless it's NULL, then use value. */
8414         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8415         hr = IUriBuilder_GetPath(builder, &len, &received);
8416         if(prop->todo) {
8417             todo_wine {
8418                 ok(hr == (expected ? S_OK : S_FALSE),
8419                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8420                     hr, (expected ? S_OK : S_FALSE), test_index);
8421             }
8422             if(SUCCEEDED(hr)) {
8423                 todo_wine {
8424                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8425                         expected, wine_dbgstr_w(received), test_index);
8426                 }
8427                 todo_wine {
8428                     ok(lstrlen(expected) == len,
8429                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8430                         lstrlen(expected), len, test_index);
8431                 }
8432             }
8433         } else {
8434             ok(hr == (expected ? S_OK : S_FALSE),
8435                 "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8436                 hr, (expected ? S_OK : S_FALSE), test_index);
8437             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8438                 expected, wine_dbgstr_w(received), test_index);
8439             ok(lstrlen(expected) == len,
8440                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8441                 lstrlen(expected), len, test_index);
8442         }
8443     } else {
8444         /* The property wasn't set earlier, so it should return whatever
8445          * the base IUri contains (if anything).
8446          */
8447         IUri *uri = NULL;
8448         hr = IUriBuilder_GetIUri(builder, &uri);
8449         ok(hr == S_OK,
8450             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8451             hr, S_OK, test_index);
8452         if(SUCCEEDED(hr)) {
8453             if(!uri) {
8454                 received = (void*) 0xdeadbeef;
8455                 len = -1;
8456
8457                 hr = IUriBuilder_GetPath(builder, &len, &received);
8458                 ok(hr == S_FALSE,
8459                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8460                     hr, S_FALSE, test_index);
8461                 if(SUCCEEDED(hr)) {
8462                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8463                         len, test_index);
8464                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8465                         received, test_index);
8466                 }
8467             } else {
8468                 BOOL has_prop = FALSE;
8469                 BSTR expected = NULL;
8470
8471                 hr = IUri_GetPath(uri, &expected);
8472                 ok(SUCCEEDED(hr),
8473                     "Error: Expected IUri_GetPath to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8474                     hr, test_index);
8475                 has_prop = hr == S_OK;
8476
8477                 hr = IUriBuilder_GetPath(builder, &len, &received);
8478                 if(has_prop) {
8479                     ok(hr == S_OK,
8480                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8481                         hr, S_OK, test_index);
8482                     if(SUCCEEDED(hr)) {
8483                         ok(!lstrcmpW(expected, received),
8484                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8485                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8486                         ok(lstrlenW(expected) == len,
8487                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8488                             lstrlenW(expected), len, test_index);
8489                     }
8490                 } else {
8491                     ok(hr == S_FALSE,
8492                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8493                         hr, S_FALSE, test_index);
8494                     if(SUCCEEDED(hr)) {
8495                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8496                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8497                             len, test_index);
8498                     }
8499                 }
8500                 SysFreeString(expected);
8501             }
8502         }
8503         if(uri) IUri_Release(uri);
8504     }
8505 }
8506
8507 static void test_IUriBuilder_GetPort(IUriBuilder *builder, const uri_builder_test *test,
8508                                      DWORD test_index) {
8509     HRESULT hr;
8510     BOOL has_port = FALSE;
8511     DWORD received = -1;
8512
8513     if(test->port_prop.change) {
8514         DWORD expected = test->port_prop.value;
8515
8516         hr = IUriBuilder_GetPort(builder, &has_port, &received);
8517         if(test->port_prop.todo) {
8518             todo_wine {
8519                 ok(hr == S_OK,
8520                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8521                     hr, S_OK, test_index);
8522             }
8523             if(SUCCEEDED(hr)) {
8524                 todo_wine {
8525                     ok(has_port == test->port_prop.set,
8526                         "Error: Expected has_port to be %d but was %d instead on uri_builder_tests[%d].\n",
8527                         test->port_prop.set, has_port, test_index);
8528                 }
8529                 todo_wine {
8530                     ok(received == expected,
8531                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8532                         expected, received, test_index);
8533                 }
8534             }
8535         } else {
8536             ok(hr == S_OK,
8537                 "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8538                 hr, S_OK, test_index);
8539             ok(has_port == test->port_prop.set,
8540                 "Error: Expected has_port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8541                 test->port_prop.set, has_port, test_index);
8542             ok(received == test->port_prop.value,
8543                 "Error: Expected port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8544                 test->port_prop.value, received, test_index);
8545         }
8546     } else {
8547         IUri *uri = NULL;
8548
8549         hr = IUriBuilder_GetIUri(builder, &uri);
8550         ok(hr == S_OK,
8551             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8552             hr, S_OK, test_index);
8553         if(SUCCEEDED(hr)) {
8554             if(!uri) {
8555                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8556                 ok(hr == S_OK,
8557                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8558                     hr, S_OK, test_index);
8559                 if(SUCCEEDED(hr)) {
8560                     ok(has_port == FALSE,
8561                         "Error: Expected has_port to be FALSE, but was %d instead on uri_builder_tests[%d].\n",
8562                         has_port, test_index);
8563                     ok(!received, "Error: Expected received to be 0, but was %d instead on uri_builder_tests[%d].\n",
8564                         received, test_index);
8565                 }
8566             } else {
8567                 DWORD expected;
8568
8569                 hr = IUri_GetPort(uri, &expected);
8570                 ok(SUCCEEDED(hr),
8571                     "Error: Expected IUri_Port to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8572                     hr, test_index);
8573
8574                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8575                 ok(hr == S_OK,
8576                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8577                     hr, S_OK, test_index);
8578                 if(SUCCEEDED(hr)) {
8579                     ok(!has_port,
8580                         "Error: Expected has_port to be FALSE but was TRUE instead on uri_builder_tests[%d].\n",
8581                         test_index);
8582                     ok(received == expected,
8583                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8584                         expected, received, test_index);
8585                 }
8586             }
8587         }
8588         if(uri) IUri_Release(uri);
8589     }
8590 }
8591
8592 static void test_IUriBuilder_GetQuery(IUriBuilder *builder, const uri_builder_test *test,
8593                                       DWORD test_index) {
8594     HRESULT hr;
8595     DWORD i;
8596     LPCWSTR received = NULL;
8597     DWORD len = -1;
8598     const uri_builder_property *prop = NULL;
8599
8600     /* Check if the property was set earlier. */
8601     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8602         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_QUERY)
8603             prop = &(test->properties[i]);
8604     }
8605
8606     if(prop) {
8607         /* Use expected_value unless it's NULL, then use value. */
8608         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8609         hr = IUriBuilder_GetQuery(builder, &len, &received);
8610         if(prop->todo) {
8611             todo_wine {
8612                 ok(hr == (expected ? S_OK : S_FALSE),
8613                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8614                     hr, (expected ? S_OK : S_FALSE), test_index);
8615             }
8616             if(SUCCEEDED(hr)) {
8617                 todo_wine {
8618                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8619                         expected, wine_dbgstr_w(received), test_index);
8620                 }
8621                 todo_wine {
8622                     ok(lstrlen(expected) == len,
8623                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8624                         lstrlen(expected), len, test_index);
8625                 }
8626             }
8627         } else {
8628             ok(hr == (expected ? S_OK : S_FALSE),
8629                 "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8630                 hr, (expected ? S_OK : S_FALSE), test_index);
8631             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8632                 expected, wine_dbgstr_w(received), test_index);
8633             ok(lstrlen(expected) == len,
8634                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8635                 lstrlen(expected), len, test_index);
8636         }
8637     } else {
8638         /* The property wasn't set earlier, so it should return whatever
8639          * the base IUri contains (if anything).
8640          */
8641         IUri *uri = NULL;
8642         hr = IUriBuilder_GetIUri(builder, &uri);
8643         ok(hr == S_OK,
8644             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8645             hr, S_OK, test_index);
8646         if(SUCCEEDED(hr)) {
8647             if(!uri) {
8648                 received = (void*) 0xdeadbeef;
8649                 len = -1;
8650
8651                 hr = IUriBuilder_GetQuery(builder, &len, &received);
8652                 ok(hr == S_FALSE,
8653                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8654                     hr, S_FALSE, test_index);
8655                 if(SUCCEEDED(hr)) {
8656                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8657                         len, test_index);
8658                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8659                         received, test_index);
8660                 }
8661             } else {
8662                 BOOL has_prop = FALSE;
8663                 BSTR expected = NULL;
8664
8665                 hr = IUri_GetQuery(uri, &expected);
8666                 ok(SUCCEEDED(hr),
8667                     "Error: Expected IUri_GetQuery to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8668                     hr, test_index);
8669                 has_prop = hr == S_OK;
8670
8671                 hr = IUriBuilder_GetQuery(builder, &len, &received);
8672                 if(has_prop) {
8673                     ok(hr == S_OK,
8674                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8675                         hr, S_OK, test_index);
8676                     if(SUCCEEDED(hr)) {
8677                         ok(!lstrcmpW(expected, received),
8678                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8679                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8680                         ok(lstrlenW(expected) == len,
8681                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8682                             lstrlenW(expected), len, test_index);
8683                     }
8684                 } else {
8685                     ok(hr == S_FALSE,
8686                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8687                         hr, S_FALSE, test_index);
8688                     if(SUCCEEDED(hr)) {
8689                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8690                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8691                             len, test_index);
8692                     }
8693                 }
8694                 SysFreeString(expected);
8695             }
8696         }
8697         if(uri) IUri_Release(uri);
8698     }
8699 }
8700
8701 static void test_IUriBuilder_GetSchemeName(IUriBuilder *builder, const uri_builder_test *test,
8702                                            DWORD test_index) {
8703     HRESULT hr;
8704     DWORD i;
8705     LPCWSTR received = NULL;
8706     DWORD len = -1;
8707     const uri_builder_property *prop = NULL;
8708
8709     /* Check if the property was set earlier. */
8710     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8711         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_SCHEME_NAME)
8712             prop = &(test->properties[i]);
8713     }
8714
8715     if(prop) {
8716         /* Use expected_value unless it's NULL, then use value. */
8717         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8718         hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8719         if(prop->todo) {
8720             todo_wine {
8721                 ok(hr == (expected ? S_OK : S_FALSE),
8722                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8723                     hr, (expected ? S_OK : S_FALSE), test_index);
8724             }
8725             if(SUCCEEDED(hr)) {
8726                 todo_wine {
8727                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8728                         expected, wine_dbgstr_w(received), test_index);
8729                 }
8730                 todo_wine {
8731                     ok(lstrlen(expected) == len,
8732                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8733                         lstrlen(expected), len, test_index);
8734                 }
8735             }
8736         } else {
8737             ok(hr == (expected ? S_OK : S_FALSE),
8738                 "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8739                 hr, (expected ? S_OK : S_FALSE), test_index);
8740             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8741                 expected, wine_dbgstr_w(received), test_index);
8742             ok(lstrlen(expected) == len,
8743                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8744                 lstrlen(expected), len, test_index);
8745         }
8746     } else {
8747         /* The property wasn't set earlier, so it should return whatever
8748          * the base IUri contains (if anything).
8749          */
8750         IUri *uri = NULL;
8751         hr = IUriBuilder_GetIUri(builder, &uri);
8752         ok(hr == S_OK,
8753             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8754             hr, S_OK, test_index);
8755         if(SUCCEEDED(hr)) {
8756             if(!uri) {
8757                 received = (void*) 0xdeadbeef;
8758                 len = -1;
8759
8760                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8761                 ok(hr == S_FALSE,
8762                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8763                     hr, S_FALSE, test_index);
8764                 if(SUCCEEDED(hr)) {
8765                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8766                         len, test_index);
8767                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8768                         received, test_index);
8769                 }
8770             } else {
8771                 BOOL has_prop = FALSE;
8772                 BSTR expected = NULL;
8773
8774                 hr = IUri_GetSchemeName(uri, &expected);
8775                 ok(SUCCEEDED(hr),
8776                     "Error: Expected IUri_GetSchemeName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8777                     hr, test_index);
8778                 has_prop = hr == S_OK;
8779
8780                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8781                 if(has_prop) {
8782                     ok(hr == S_OK,
8783                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8784                         hr, S_OK, test_index);
8785                     if(SUCCEEDED(hr)) {
8786                         ok(!lstrcmpW(expected, received),
8787                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8788                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8789                         ok(lstrlenW(expected) == len,
8790                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8791                             lstrlenW(expected), len, test_index);
8792                     }
8793                 } else {
8794                     ok(hr == S_FALSE,
8795                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8796                         hr, S_FALSE, test_index);
8797                     if(SUCCEEDED(hr)) {
8798                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8799                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8800                             len, test_index);
8801                     }
8802                 }
8803                 SysFreeString(expected);
8804             }
8805         }
8806         if(uri) IUri_Release(uri);
8807     }
8808 }
8809
8810 static void test_IUriBuilder_GetUserName(IUriBuilder *builder, const uri_builder_test *test,
8811                                          DWORD test_index) {
8812     HRESULT hr;
8813     DWORD i;
8814     LPCWSTR received = NULL;
8815     DWORD len = -1;
8816     const uri_builder_property *prop = NULL;
8817
8818     /* Check if the property was set earlier. */
8819     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8820         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_USER_NAME)
8821             prop = &(test->properties[i]);
8822     }
8823
8824     if(prop && prop->value && *prop->value) {
8825         /* Use expected_value unless it's NULL, then use value. */
8826         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8827         hr = IUriBuilder_GetUserName(builder, &len, &received);
8828         if(prop->todo) {
8829             todo_wine {
8830                 ok(hr == (expected ? S_OK : S_FALSE),
8831                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8832                     hr, (expected ? S_OK : S_FALSE), test_index);
8833             }
8834             if(SUCCEEDED(hr)) {
8835                 todo_wine {
8836                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8837                         expected, wine_dbgstr_w(received), test_index);
8838                 }
8839                 todo_wine {
8840                     ok(lstrlen(expected) == len,
8841                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8842                         lstrlen(expected), len, test_index);
8843                 }
8844             }
8845         } else {
8846             ok(hr == (expected ? S_OK : S_FALSE),
8847                 "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8848                 hr, (expected ? S_OK : S_FALSE), test_index);
8849             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8850                 expected, wine_dbgstr_w(received), test_index);
8851             ok(lstrlen(expected) == len,
8852                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8853                 lstrlen(expected), len, test_index);
8854         }
8855     } else {
8856         /* The property wasn't set earlier, so it should return whatever
8857          * the base IUri contains (if anything).
8858          */
8859         IUri *uri = NULL;
8860         hr = IUriBuilder_GetIUri(builder, &uri);
8861         ok(hr == S_OK,
8862             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8863             hr, S_OK, test_index);
8864         if(SUCCEEDED(hr)) {
8865             if(!uri) {
8866                 received = (void*) 0xdeadbeef;
8867                 len = -1;
8868
8869                 hr = IUriBuilder_GetUserName(builder, &len, &received);
8870                 ok(hr == S_FALSE,
8871                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8872                     hr, S_FALSE, test_index);
8873                 if(SUCCEEDED(hr)) {
8874                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8875                         len, test_index);
8876                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8877                         received, test_index);
8878                 }
8879             } else {
8880                 BSTR expected = NULL;
8881                 BOOL has_prop = FALSE;
8882
8883                 hr = IUri_GetUserName(uri, &expected);
8884                 ok(SUCCEEDED(hr),
8885                     "Error: Expected IUri_GetUserName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8886                     hr, test_index);
8887                 has_prop = hr == S_OK;
8888
8889                 hr = IUriBuilder_GetUserName(builder, &len, &received);
8890                 if(has_prop) {
8891                     ok(hr == S_OK,
8892                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8893                         hr, S_OK, test_index);
8894                     if(SUCCEEDED(hr)) {
8895                         ok(!lstrcmpW(expected, received),
8896                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8897                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8898                         ok(lstrlenW(expected) == len,
8899                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8900                             lstrlenW(expected), len, test_index);
8901                     }
8902                 } else {
8903                     ok(hr == S_FALSE,
8904                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8905                         hr, S_FALSE, test_index);
8906                     if(SUCCEEDED(hr)) {
8907                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8908                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8909                             len, test_index);
8910                     }
8911                 }
8912                 SysFreeString(expected);
8913             }
8914         }
8915         if(uri) IUri_Release(uri);
8916     }
8917 }
8918
8919 /* Tests IUriBuilder functions. */
8920 static void test_IUriBuilder(void) {
8921     HRESULT hr;
8922     IUriBuilder *builder;
8923     DWORD i;
8924
8925     for(i = 0; i < sizeof(uri_builder_tests)/sizeof(uri_builder_tests[0]); ++i) {
8926         IUri *uri = NULL;
8927         uri_builder_test test = uri_builder_tests[i];
8928         LPWSTR uriW = NULL;
8929
8930         if(test.uri) {
8931             uriW = a2w(test.uri);
8932             hr = pCreateUri(uriW, test.create_flags, 0, &uri);
8933             ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8934                 hr, S_OK, i);
8935             if(FAILED(hr)) continue;
8936         }
8937         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
8938         if(test.create_builder_todo) {
8939             todo_wine {
8940                 ok(hr == test.create_builder_expected,
8941                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8942                     hr, test.create_builder_expected, i);
8943             }
8944         } else {
8945             ok(hr == test.create_builder_expected,
8946                 "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8947                 hr, test.create_builder_expected, i);
8948         }
8949         if(SUCCEEDED(hr)) {
8950             DWORD j;
8951             BOOL modified = FALSE, received = FALSE;
8952
8953             /* Perform all the string property changes. */
8954             for(j = 0; j < URI_BUILDER_STR_PROPERTY_COUNT; ++j) {
8955                 uri_builder_property prop = test.properties[j];
8956                 if(prop.change) {
8957                     change_property(builder, &prop, i);
8958                     if(prop.property != Uri_PROPERTY_SCHEME_NAME &&
8959                        prop.property != Uri_PROPERTY_HOST)
8960                         modified = TRUE;
8961                     else if(prop.value && *prop.value)
8962                         modified = TRUE;
8963                     else if(prop.value && !*prop.value && prop.property == Uri_PROPERTY_HOST)
8964                         /* Host name property can't be NULL, but it can be empty. */
8965                         modified = TRUE;
8966                 }
8967             }
8968
8969             if(test.port_prop.change) {
8970                 hr = IUriBuilder_SetPort(builder, test.port_prop.set, test.port_prop.value);
8971                 modified = TRUE;
8972                 if(test.port_prop.todo) {
8973                     todo_wine {
8974                         ok(hr == test.port_prop.expected,
8975                             "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8976                             hr, test.port_prop.expected, i);
8977                     }
8978                 } else {
8979                     ok(hr == test.port_prop.expected,
8980                         "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8981                         hr, test.port_prop.expected, i);
8982                 }
8983             }
8984
8985             hr = IUriBuilder_HasBeenModified(builder, &received);
8986             ok(hr == S_OK,
8987                 "Error IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8988                 hr, S_OK, i);
8989             if(SUCCEEDED(hr))
8990                 ok(received == modified,
8991                     "Error: Expected received to be %d but was %d instead on uri_builder_tests[%d].\n",
8992                     modified, received, i);
8993
8994             /* Test the "Get*" functions. */
8995             test_IUriBuilder_GetFragment(builder, &test, i);
8996             test_IUriBuilder_GetHost(builder, &test, i);
8997             test_IUriBuilder_GetPassword(builder, &test, i);
8998             test_IUriBuilder_GetPath(builder, &test, i);
8999             test_IUriBuilder_GetPort(builder, &test, i);
9000             test_IUriBuilder_GetQuery(builder, &test, i);
9001             test_IUriBuilder_GetSchemeName(builder, &test, i);
9002             test_IUriBuilder_GetUserName(builder, &test, i);
9003
9004             test_IUriBuilder_CreateUri(builder, &test, i);
9005             test_IUriBuilder_CreateUriSimple(builder, &test, i);
9006             test_IUriBuilder_CreateUriWithFlags(builder, &test, i);
9007         }
9008         if(builder) IUriBuilder_Release(builder);
9009         if(uri) IUri_Release(uri);
9010         heap_free(uriW);
9011     }
9012 }
9013
9014 static void test_IUriBuilder_HasBeenModified(void) {
9015     HRESULT hr;
9016     IUriBuilder *builder = NULL;
9017
9018     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9019     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9020     if(SUCCEEDED(hr)) {
9021         static const WCHAR hostW[] = {'g','o','o','g','l','e','.','c','o','m',0};
9022         IUri *uri = NULL;
9023         BOOL received;
9024
9025         hr = IUriBuilder_HasBeenModified(builder, NULL);
9026         ok(hr == E_POINTER, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9027             hr, E_POINTER);
9028
9029         hr = IUriBuilder_SetHost(builder, hostW);
9030         ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n",
9031             hr, S_OK);
9032
9033         hr = IUriBuilder_HasBeenModified(builder, &received);
9034         ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9035             hr, S_OK);
9036         if(SUCCEEDED(hr))
9037             ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9038
9039         hr = pCreateUri(http_urlW, 0, 0, &uri);
9040         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9041         if(SUCCEEDED(hr)) {
9042             LPCWSTR prop;
9043             DWORD len = -1;
9044
9045             hr = IUriBuilder_SetIUri(builder, uri);
9046             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n",
9047                 hr, S_OK);
9048
9049             hr = IUriBuilder_HasBeenModified(builder, &received);
9050             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9051                 hr, S_OK);
9052             if(SUCCEEDED(hr))
9053                 ok(received == FALSE, "Error: Expected received to be FALSE.\n");
9054
9055             /* Test what happens with you call SetIUri with the same IUri again. */
9056             hr = IUriBuilder_SetHost(builder, hostW);
9057             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9058
9059             hr = IUriBuilder_HasBeenModified(builder, &received);
9060             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9061                 hr, S_OK);
9062             if(SUCCEEDED(hr))
9063                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9064
9065             hr = IUriBuilder_SetIUri(builder, uri);
9066             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9067
9068             /* IUriBuilder already had 'uri' as it's IUri property and so Windows doesn't
9069              * reset any of the changes that were made to the IUriBuilder.
9070              */
9071             hr = IUriBuilder_HasBeenModified(builder, &received);
9072             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9073             if(SUCCEEDED(hr))
9074                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9075
9076             hr = IUriBuilder_GetHost(builder, &len, &prop);
9077             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9078             if(SUCCEEDED(hr)) {
9079                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
9080                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
9081                 ok(len == lstrlenW(hostW), "Error: Expected len to be %d, but was %d instead.\n",
9082                     lstrlenW(hostW), len);
9083             }
9084
9085             hr = IUriBuilder_SetIUri(builder, NULL);
9086             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9087
9088             hr = IUriBuilder_SetHost(builder, hostW);
9089             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9090             hr = IUriBuilder_HasBeenModified(builder, &received);
9091             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9092                 hr, S_OK);
9093             if(SUCCEEDED(hr))
9094                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9095
9096             hr = IUriBuilder_SetIUri(builder, NULL);
9097             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%09x.\n", hr, S_OK);
9098
9099             hr = IUriBuilder_HasBeenModified(builder, &received);
9100             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9101                 hr, S_OK);
9102             if(SUCCEEDED(hr))
9103                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9104
9105             hr = IUriBuilder_GetHost(builder, &len, &prop);
9106             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9107             if(SUCCEEDED(hr)) {
9108                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
9109                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
9110                 ok(len == lstrlenW(hostW), "Error: Expected len to %d, but was %d instead.\n",
9111                     lstrlenW(hostW), len);
9112             }
9113         }
9114         if(uri) IUri_Release(uri);
9115     }
9116     if(builder) IUriBuilder_Release(builder);
9117 }
9118
9119 /* Test IUriBuilder {Get,Set}IUri functions. */
9120 static void test_IUriBuilder_IUriProperty(void) {
9121     IUriBuilder *builder = NULL;
9122     HRESULT hr;
9123
9124     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9125     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9126     if(SUCCEEDED(hr)) {
9127         IUri *uri = NULL;
9128
9129         hr = IUriBuilder_GetIUri(builder, NULL);
9130         ok(hr == E_POINTER, "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x.\n",
9131             hr, E_POINTER);
9132
9133         hr = pCreateUri(http_urlW, 0, 0, &uri);
9134         if(SUCCEEDED(hr)) {
9135             IUri *test = NULL;
9136             ULONG cur_count, orig_count;
9137
9138             /* IUriBuilder doesn't clone the IUri, it use the same IUri. */
9139             orig_count = get_refcnt(uri);
9140             hr = IUriBuilder_SetIUri(builder, uri);
9141             cur_count = get_refcnt(uri);
9142             if(SUCCEEDED(hr))
9143                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9144                     orig_count+1, cur_count);
9145
9146             hr = IUriBuilder_SetIUri(builder, NULL);
9147             cur_count = get_refcnt(uri);
9148             if(SUCCEEDED(hr))
9149                 ok(cur_count == orig_count, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9150                     orig_count, cur_count);
9151
9152             /* CreateUri* functions will return back the same IUri if nothing has changed. */
9153             hr = IUriBuilder_SetIUri(builder, uri);
9154             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9155             orig_count = get_refcnt(uri);
9156
9157             hr = IUriBuilder_CreateUri(builder, 0, 0, 0, &test);
9158             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9159             if(SUCCEEDED(hr)) {
9160                 cur_count = get_refcnt(uri);
9161                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9162                     orig_count+1, cur_count);
9163                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n",
9164                     uri, test);
9165             }
9166             if(test) IUri_Release(test);
9167
9168             test = NULL;
9169             hr = IUriBuilder_CreateUri(builder, -1, 0, 0, &test);
9170             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9171             if(SUCCEEDED(hr)) {
9172                 cur_count = get_refcnt(uri);
9173                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9174                     orig_count+1, cur_count);
9175                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9176             }
9177             if(test) IUri_Release(test);
9178
9179             /* Doesn't return the same IUri, if the flag combination is different then the one that created
9180              * the base IUri.
9181              */
9182             test = NULL;
9183             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, &test);
9184             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9185             if(SUCCEEDED(hr))
9186                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
9187
9188             if(test) IUri_Release(test);
9189
9190             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
9191              * explicitly set (because it's a default flags).
9192              */
9193             test = NULL;
9194             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_CANONICALIZE, 0, 0, &test);
9195             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9196             if(SUCCEEDED(hr)) {
9197                 cur_count = get_refcnt(uri);
9198                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9199                     orig_count+1, cur_count);
9200                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
9201             }
9202             if(test) IUri_Release(test);
9203
9204             test = NULL;
9205             hr = IUriBuilder_CreateUriSimple(builder, 0, 0, &test);
9206             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9207             if(SUCCEEDED(hr)) {
9208                 cur_count = get_refcnt(uri);
9209                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9210                     orig_count+1, cur_count);
9211                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9212             }
9213             if(test) IUri_Release(test);
9214
9215             test = NULL;
9216             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &test);
9217             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
9218                 hr, S_OK);
9219             if(SUCCEEDED(hr)) {
9220                 cur_count = get_refcnt(uri);
9221                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9222                     orig_count+1, cur_count);
9223                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9224             }
9225             if(test) IUri_Release(test);
9226
9227             /* Doesn't return the same IUri, if the flag combination is different then the one that created
9228              * the base IUri.
9229              */
9230             test = NULL;
9231             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, 0, &test);
9232             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9233             if(SUCCEEDED(hr))
9234                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
9235
9236             if(test) IUri_Release(test);
9237
9238             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
9239              * explicitly set (because it's a default flags).
9240              */
9241             test = NULL;
9242             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_CANONICALIZE, 0, 0, 0, &test);
9243             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9244             if(SUCCEEDED(hr)) {
9245                 cur_count = get_refcnt(uri);
9246                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9247                     orig_count+1, cur_count);
9248                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
9249             }
9250             if(test) IUri_Release(test);
9251         }
9252         if(uri) IUri_Release(uri);
9253     }
9254     if(builder) IUriBuilder_Release(builder);
9255 }
9256
9257 static void test_IUriBuilder_RemoveProperties(void) {
9258     IUriBuilder *builder = NULL;
9259     HRESULT hr;
9260     DWORD i;
9261
9262     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9263     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9264     if(SUCCEEDED(hr)) {
9265         /* Properties that can't be removed. */
9266         const DWORD invalid = Uri_HAS_ABSOLUTE_URI|Uri_HAS_DISPLAY_URI|Uri_HAS_RAW_URI|Uri_HAS_HOST_TYPE|
9267                               Uri_HAS_SCHEME|Uri_HAS_ZONE;
9268
9269         for(i = Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_DWORD_LAST; ++i) {
9270             hr = IUriBuilder_RemoveProperties(builder, i << 1);
9271             if((i << 1) & invalid) {
9272                 ok(hr == E_INVALIDARG,
9273                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
9274                     hr, E_INVALIDARG, i);
9275             } else {
9276                 ok(hr == S_OK,
9277                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
9278                     hr, S_OK, i);
9279             }
9280         }
9281
9282         /* Also doesn't accept anything that's outside the range of the
9283          * Uri_HAS flags.
9284          */
9285         hr = IUriBuilder_RemoveProperties(builder, (Uri_PROPERTY_DWORD_LAST+1) << 1);
9286         ok(hr == E_INVALIDARG, "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x.\n",
9287             hr, E_INVALIDARG);
9288     }
9289     if(builder) IUriBuilder_Release(builder);
9290
9291     for(i = 0; i < sizeof(uri_builder_remove_tests)/sizeof(uri_builder_remove_tests[0]); ++i) {
9292         uri_builder_remove_test test = uri_builder_remove_tests[i];
9293         IUri *uri = NULL;
9294         LPWSTR uriW;
9295
9296         uriW = a2w(test.uri);
9297         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
9298         if(SUCCEEDED(hr)) {
9299             builder = NULL;
9300
9301             hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9302             if(test.create_builder_todo) {
9303                 todo_wine {
9304                     ok(hr == test.create_builder_expected,
9305                         "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9306                         hr, test.create_builder_expected, i);
9307                 }
9308             } else {
9309                 ok(hr == test.create_builder_expected,
9310                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9311                     hr, test.create_builder_expected, i);
9312             }
9313             if(SUCCEEDED(hr)) {
9314                 hr = IUriBuilder_RemoveProperties(builder, test.remove_properties);
9315                 if(test.remove_todo) {
9316                     todo_wine {
9317                         ok(hr == test.remove_expected,
9318                             "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x on test %d.\n",
9319                             hr, test.remove_expected, i);
9320                     }
9321                 } else {
9322                     ok(hr == test.remove_expected,
9323                         "Error: IUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9324                         hr, test.remove_expected, i);
9325                 }
9326                 if(SUCCEEDED(hr)) {
9327                     IUri *result = NULL;
9328
9329                     hr = IUriBuilder_CreateUri(builder, test.expected_flags, 0, 0, &result);
9330                     if(test.expected_todo) {
9331                         todo_wine {
9332                             ok(hr == test.expected_hres,
9333                                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
9334                                 hr, test.expected_hres, i);
9335                         }
9336                     } else {
9337                         ok(hr == test.expected_hres,
9338                             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
9339                             hr, test.expected_hres, i);
9340                     }
9341                     if(SUCCEEDED(hr)) {
9342                         BSTR received = NULL;
9343
9344                         hr = IUri_GetAbsoluteUri(result, &received);
9345                         ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
9346                         ok(!strcmp_aw(test.expected_uri, received),
9347                             "Error: Expected %s but got %s instead on test %d.\n",
9348                             test.expected_uri, wine_dbgstr_w(received), i);
9349                         SysFreeString(received);
9350                     }
9351                     if(result) IUri_Release(result);
9352                 }
9353             }
9354             if(builder) IUriBuilder_Release(builder);
9355         }
9356         if(uri) IUri_Release(uri);
9357         heap_free(uriW);
9358     }
9359 }
9360
9361 static void test_IUriBuilder_Misc(void) {
9362     HRESULT hr;
9363     IUri *uri;
9364
9365     hr = pCreateUri(http_urlW, 0, 0, &uri);
9366     if(SUCCEEDED(hr)) {
9367         IUriBuilder *builder;
9368
9369         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9370         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9371         if(SUCCEEDED(hr)) {
9372             BOOL has = -1;
9373             DWORD port = -1;
9374
9375             hr = IUriBuilder_GetPort(builder, &has, &port);
9376             ok(hr == S_OK, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9377             if(SUCCEEDED(hr)) {
9378                 /* 'has' will be set to FALSE, even though uri had a port. */
9379                 ok(has == FALSE, "Error: Expected 'has' to be FALSE, was %d instead.\n", has);
9380                 /* Still sets 'port' to 80. */
9381                 ok(port == 80, "Error: Expected the port to be 80, but, was %d instead.\n", port);
9382             }
9383         }
9384         if(builder) IUriBuilder_Release(builder);
9385     }
9386     if(uri) IUri_Release(uri);
9387 }
9388
9389 static void test_IUriBuilderFactory(void) {
9390     HRESULT hr;
9391     IUri *uri;
9392     IUriBuilderFactory *factory;
9393     IUriBuilder *builder;
9394
9395     hr = pCreateUri(http_urlW, 0, 0, &uri);
9396     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9397     if(SUCCEEDED(hr)) {
9398         factory = NULL;
9399         hr = IUri_QueryInterface(uri, &IID_IUriBuilderFactory, (void**)&factory);
9400         ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x.\n", hr);
9401         ok(factory != NULL, "Error: Expected 'factory' to not be NULL.\n");
9402
9403         if(SUCCEEDED(hr)) {
9404             builder = (void*) 0xdeadbeef;
9405             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 10, 0, &builder);
9406             ok(hr == E_INVALIDARG, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9407                 hr, E_INVALIDARG);
9408             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9409
9410             builder = (void*) 0xdeadbeef;
9411             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 10, &builder);
9412             ok(hr == E_INVALIDARG, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9413                 hr, E_INVALIDARG);
9414             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9415
9416             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 0, NULL);
9417             ok(hr == E_POINTER, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9418                 hr, E_POINTER);
9419
9420             builder = NULL;
9421             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 0, &builder);
9422             ok(hr == S_OK, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9423                 hr, S_OK);
9424             if(SUCCEEDED(hr)) {
9425                 IUri *tmp = (void*) 0xdeadbeef;
9426                 LPCWSTR result;
9427                 DWORD result_len;
9428
9429                 hr = IUriBuilder_GetIUri(builder, &tmp);
9430                 ok(hr == S_OK, "Error: GetIUri returned 0x%08x, expected 0x%08x.\n",
9431                     hr, S_OK);
9432                 ok(!tmp, "Error: Expected 'tmp' to be NULL, but was %p instead.\n", tmp);
9433
9434                 hr = IUriBuilder_GetHost(builder, &result_len, &result);
9435                 ok(hr == S_FALSE, "Error: GetHost returned 0x%08x, expected 0x%08x.\n",
9436                     hr, S_FALSE);
9437             }
9438             if(builder) IUriBuilder_Release(builder);
9439
9440             builder = (void*) 0xdeadbeef;
9441             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 10, 0, &builder);
9442             ok(hr == E_INVALIDARG, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9443                 hr, E_INVALIDARG);
9444             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9445
9446             builder = (void*) 0xdeadbeef;
9447             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 10, &builder);
9448             ok(hr == E_INVALIDARG, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9449                 hr, E_INVALIDARG);
9450             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9451
9452             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 0, NULL);
9453             ok(hr == E_POINTER, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9454                 hr, E_POINTER);
9455
9456             builder = NULL;
9457             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 0, &builder);
9458             ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9459                 hr, S_OK);
9460             if(SUCCEEDED(hr)) {
9461                 IUri *tmp = NULL;
9462
9463                 hr = IUriBuilder_GetIUri(builder, &tmp);
9464                 ok(hr == S_OK, "Error: GetIUri return 0x%08x, expected 0x%08x.\n",
9465                     hr, S_OK);
9466                 ok(tmp == uri, "Error: Expected tmp to be %p, but was %p.\n", uri, tmp);
9467                 if(uri) IUri_Release(uri);
9468             }
9469             if(builder) IUriBuilder_Release(builder);
9470         }
9471         if(factory) IUriBuilderFactory_Release(factory);
9472     }
9473     if(uri) IUri_Release(uri);
9474 }
9475
9476 static void test_CoInternetCombineIUri(void) {
9477     HRESULT hr;
9478     IUri *base, *relative, *result;
9479     DWORD i;
9480
9481     base = NULL;
9482     hr = pCreateUri(http_urlW, 0, 0, &base);
9483     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9484     if(SUCCEEDED(hr)) {
9485         result = (void*) 0xdeadbeef;
9486         hr = pCoInternetCombineIUri(base, NULL, 0, &result, 0);
9487         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9488         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9489     }
9490
9491     relative = NULL;
9492     hr = pCreateUri(http_urlW, 0, 0, &relative);
9493     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9494     if(SUCCEEDED(hr)) {
9495         result = (void*) 0xdeadbeef;
9496         hr = pCoInternetCombineIUri(NULL, relative, 0, &result, 0);
9497         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9498         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9499     }
9500
9501     hr = pCoInternetCombineIUri(base, relative, 0, NULL, 0);
9502     ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9503
9504     if(base) IUri_Release(base);
9505     if(relative) IUri_Release(relative);
9506
9507     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
9508         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
9509
9510         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
9511         ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9512         if(SUCCEEDED(hr)) {
9513             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
9514
9515             hr = pCreateUri(relativeW, uri_combine_tests[i].relative_create_flags, 0, &relative);
9516             ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9517             if(SUCCEEDED(hr)) {
9518                 result = NULL;
9519
9520                 hr = pCoInternetCombineIUri(base, relative, uri_combine_tests[i].combine_flags, &result, 0);
9521                 if(uri_combine_tests[i].todo) {
9522                     todo_wine {
9523                         ok(hr == uri_combine_tests[i].expected,
9524                             "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9525                             hr, uri_combine_tests[i].expected, i);
9526                     }
9527                 } else {
9528                     ok(hr == uri_combine_tests[i].expected,
9529                         "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9530                         hr, uri_combine_tests[i]. expected, i);
9531                 }
9532                 if(SUCCEEDED(hr)) {
9533                     DWORD j;
9534
9535                     for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
9536                         uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
9537                         BSTR received;
9538
9539                         hr = IUri_GetPropertyBSTR(result, j, &received, 0);
9540                         if(prop.todo) {
9541                             todo_wine {
9542                                 ok(hr == prop.expected,
9543                                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9544                                     hr, prop.expected, i, j);
9545                             }
9546                             todo_wine {
9547                                 ok(!strcmp_aw(prop.value, received) ||
9548                                    broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9549                                     "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9550                                     prop.value, wine_dbgstr_w(received), i, j);
9551                             }
9552                         } else {
9553                             ok(hr == prop.expected,
9554                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9555                                 hr, prop.expected, i, j);
9556                             ok(!strcmp_aw(prop.value, received) ||
9557                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9558                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9559                                 prop.value, wine_dbgstr_w(received), i, j);
9560                         }
9561                         SysFreeString(received);
9562                     }
9563
9564                     for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
9565                         uri_dword_property prop = uri_combine_tests[i].dword_props[j];
9566                         DWORD received;
9567
9568                         hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
9569                         if(prop.todo) {
9570                             todo_wine {
9571                                 ok(hr == prop.expected,
9572                                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9573                                     hr, prop.expected, i, j);
9574                             }
9575                             todo_wine {
9576                                 ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9577                                     prop.value, received, i, j);
9578                             }
9579                         } else {
9580                             ok(hr == prop.expected,
9581                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9582                                 hr, prop.expected, i, j);
9583                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9584                                 prop.value, received, i, j);
9585                         }
9586                     }
9587                 }
9588                 if(result) IUri_Release(result);
9589             }
9590             if(relative) IUri_Release(relative);
9591             heap_free(relativeW);
9592         }
9593         if(base) IUri_Release(base);
9594         heap_free(baseW);
9595     }
9596 }
9597
9598 static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface,
9599                                                           REFIID riid, void **ppv)
9600 {
9601     ok(0, "unexpected call\n");
9602     return E_NOINTERFACE;
9603 }
9604
9605 static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
9606 {
9607     return 2;
9608 }
9609
9610 static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
9611 {
9612     return 1;
9613 }
9614
9615 static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
9616         PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
9617         DWORD *pcchResult, DWORD dwReserved)
9618 {
9619     CHECK_EXPECT(ParseUrl);
9620     ok(!lstrcmpW(pwzUrl, parse_urlW), "Error: Expected %s, but got %s instead.\n",
9621         wine_dbgstr_w(parse_urlW), wine_dbgstr_w(pwzUrl));
9622     ok(ParseAction == parse_action, "Error: Expected %d, but got %d.\n", parse_action, ParseAction);
9623     ok(dwParseFlags == parse_flags, "Error: Expected 0x%08x, but got 0x%08x.\n", parse_flags, dwParseFlags);
9624     ok(cchResult == 200, "Error: Got %d.\n", cchResult);
9625
9626     memcpy(pwzResult, parse_resultW, sizeof(parse_resultW));
9627     *pcchResult = lstrlenW(parse_resultW);
9628
9629     return S_OK;
9630 }
9631
9632 static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
9633         LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags,
9634         LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
9635 {
9636     CHECK_EXPECT(CombineUrl);
9637     ok(!lstrcmpW(pwzBaseUrl, combine_baseW), "Error: Expected %s, but got %s instead.\n",
9638         wine_dbgstr_w(combine_baseW), wine_dbgstr_w(pwzBaseUrl));
9639     ok(!lstrcmpW(pwzRelativeUrl, combine_relativeW), "Error: Expected %s, but got %s instead.\n",
9640         wine_dbgstr_w(combine_relativeW), wine_dbgstr_w(pwzRelativeUrl));
9641     ok(dwCombineFlags == (URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO),
9642         "Error: Expected 0, but got 0x%08x.\n", dwCombineFlags);
9643     ok(cchResult == INTERNET_MAX_URL_LENGTH+1, "Error: Got %d.\n", cchResult);
9644
9645     memcpy(pwzResult, combine_resultW, sizeof(combine_resultW));
9646     *pcchResult = lstrlenW(combine_resultW);
9647
9648     return S_OK;
9649 }
9650
9651 static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface,
9652         LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
9653 {
9654     ok(0, "unexpected call\n");
9655     return E_NOTIMPL;
9656 }
9657
9658 static HRESULT WINAPI InternetProtocolInfo_QueryInfo(IInternetProtocolInfo *iface,
9659         LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer,
9660         DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
9661 {
9662     ok(0, "unexpected call\n");
9663     return E_NOTIMPL;
9664 }
9665
9666 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl = {
9667     InternetProtocolInfo_QueryInterface,
9668     InternetProtocolInfo_AddRef,
9669     InternetProtocolInfo_Release,
9670     InternetProtocolInfo_ParseUrl,
9671     InternetProtocolInfo_CombineUrl,
9672     InternetProtocolInfo_CompareUrl,
9673     InternetProtocolInfo_QueryInfo
9674 };
9675
9676 static IInternetProtocolInfo protocol_info = { &InternetProtocolInfoVtbl };
9677
9678 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
9679 {
9680     if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
9681         *ppv = &protocol_info;
9682         return S_OK;
9683     }
9684
9685     ok(0, "unexpected call\n");
9686     return E_NOINTERFACE;
9687 }
9688
9689 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
9690 {
9691     return 2;
9692 }
9693
9694 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
9695 {
9696     return 1;
9697 }
9698
9699 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
9700                                         REFIID riid, void **ppv)
9701 {
9702     ok(0, "unexpected call\n");
9703     return E_NOTIMPL;
9704 }
9705
9706 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
9707 {
9708     ok(0, "unexpected call\n");
9709     return S_OK;
9710 }
9711
9712 static const IClassFactoryVtbl ClassFactoryVtbl = {
9713     ClassFactory_QueryInterface,
9714     ClassFactory_AddRef,
9715     ClassFactory_Release,
9716     ClassFactory_CreateInstance,
9717     ClassFactory_LockServer
9718 };
9719
9720 static IClassFactory protocol_cf = { &ClassFactoryVtbl };
9721
9722 static void register_protocols(void)
9723 {
9724     IInternetSession *session;
9725     HRESULT hres;
9726
9727     hres = pCoInternetGetSession(0, &session, 0);
9728     ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
9729     if(FAILED(hres))
9730         return;
9731
9732     hres = IInternetSession_RegisterNameSpace(session, &protocol_cf, &IID_NULL,
9733             winetestW, 0, NULL, 0);
9734     ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
9735
9736     IInternetSession_Release(session);
9737 }
9738
9739 static void unregister_protocols(void) {
9740     IInternetSession *session;
9741     HRESULT hr;
9742
9743     hr = pCoInternetGetSession(0, &session, 0);
9744     ok(hr == S_OK, "CoInternetGetSession failed: 0x%08x\n", hr);
9745     if(FAILED(hr))
9746         return;
9747
9748     hr = IInternetSession_UnregisterNameSpace(session, &protocol_cf, winetestW);
9749     ok(hr == S_OK, "UnregisterNameSpace failed: 0x%08x\n", hr);
9750
9751     IInternetSession_Release(session);
9752 }
9753
9754 static void test_CoInternetCombineIUri_Pluggable(void) {
9755     HRESULT hr;
9756     IUri *base = NULL;
9757
9758     hr = pCreateUri(combine_baseW, 0, 0, &base);
9759     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9760     if(SUCCEEDED(hr)) {
9761         IUri *relative = NULL;
9762
9763         hr = pCreateUri(combine_relativeW, Uri_CREATE_ALLOW_RELATIVE, 0, &relative);
9764         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9765         if(SUCCEEDED(hr)) {
9766             IUri *result = NULL;
9767
9768             SET_EXPECT(CombineUrl);
9769
9770             hr = pCoInternetCombineIUri(base, relative, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
9771                                         &result, 0);
9772             ok(hr == S_OK, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9773
9774             CHECK_CALLED(CombineUrl);
9775
9776             if(SUCCEEDED(hr)) {
9777                 BSTR received = NULL;
9778                 hr = IUri_GetAbsoluteUri(result, &received);
9779                 ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
9780                 if(SUCCEEDED(hr)) {
9781                     ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
9782                         wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
9783                 }
9784                 SysFreeString(received);
9785             }
9786             if(result) IUri_Release(result);
9787         }
9788         if(relative) IUri_Release(relative);
9789     }
9790     if(base) IUri_Release(base);
9791 }
9792
9793 static void test_CoInternetCombineUrlEx(void) {
9794     HRESULT hr;
9795     IUri *base, *result;
9796     DWORD i;
9797
9798     base = NULL;
9799     hr = pCreateUri(http_urlW, 0, 0, &base);
9800     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9801     if(SUCCEEDED(hr)) {
9802         result = (void*) 0xdeadbeef;
9803         hr = pCoInternetCombineUrlEx(base, NULL, 0, &result, 0);
9804         ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9805             hr, E_UNEXPECTED);
9806         ok(!result, "Error: Expected 'result' to be NULL was %p instead.\n", result);
9807     }
9808
9809     result = (void*) 0xdeadbeef;
9810     hr = pCoInternetCombineUrlEx(NULL, http_urlW, 0, &result, 0);
9811     ok(hr == E_INVALIDARG, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9812         hr, E_INVALIDARG);
9813     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
9814
9815     result = (void*) 0xdeadbeef;
9816     hr = pCoInternetCombineUrlEx(NULL, NULL, 0, &result, 0);
9817     ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9818         hr, E_UNEXPECTED);
9819     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
9820
9821     hr = pCoInternetCombineUrlEx(base, http_urlW, 0, NULL, 0);
9822     ok(hr == E_POINTER, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9823         hr, E_POINTER);
9824     if(base) IUri_Release(base);
9825
9826     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
9827         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
9828
9829         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
9830         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_combine_tests[%d].\n", hr, i);
9831         if(SUCCEEDED(hr)) {
9832             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
9833
9834             hr = pCoInternetCombineUrlEx(base, relativeW, uri_combine_tests[i].combine_flags,
9835                                          &result, 0);
9836             if(uri_combine_tests[i].todo) {
9837                 todo_wine {
9838                     ok(hr == uri_combine_tests[i].expected,
9839                         "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9840                         hr, uri_combine_tests[i].expected, i);
9841                 }
9842             } else {
9843                 ok(hr == uri_combine_tests[i].expected,
9844                     "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9845                     hr, uri_combine_tests[i]. expected, i);
9846             }
9847             if(SUCCEEDED(hr)) {
9848                 DWORD j;
9849
9850                 for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
9851                     uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
9852                     BSTR received;
9853                     LPCSTR value = (prop.value_ex) ? prop.value_ex : prop.value;
9854
9855                     hr = IUri_GetPropertyBSTR(result, j, &received, 0);
9856                     if(prop.todo) {
9857                         todo_wine {
9858                             ok(hr == prop.expected,
9859                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9860                                 hr, prop.expected, i, j);
9861                         }
9862                         todo_wine {
9863                             ok(!strcmp_aw(value, received) ||
9864                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9865                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9866                                 value, wine_dbgstr_w(received), i, j);
9867                         }
9868                     } else {
9869                         ok(hr == prop.expected,
9870                             "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9871                             hr, prop.expected, i, j);
9872                         ok(!strcmp_aw(value, received) ||
9873                            broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9874                             "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9875                             value, wine_dbgstr_w(received), i, j);
9876                     }
9877                     SysFreeString(received);
9878                 }
9879
9880                 for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
9881                     uri_dword_property prop = uri_combine_tests[i].dword_props[j];
9882                     DWORD received;
9883
9884                     hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
9885                     if(prop.todo) {
9886                         todo_wine {
9887                             ok(hr == prop.expected,
9888                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9889                                 hr, prop.expected, i, j);
9890                         }
9891                         todo_wine {
9892                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9893                                 prop.value, received, i, j);
9894                         }
9895                     } else {
9896                         ok(hr == prop.expected,
9897                             "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9898                             hr, prop.expected, i, j);
9899                         ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9900                             prop.value, received, i, j);
9901                     }
9902                 }
9903             }
9904             if(result) IUri_Release(result);
9905             heap_free(relativeW);
9906         }
9907         if(base) IUri_Release(base);
9908         heap_free(baseW);
9909     }
9910 }
9911
9912 static void test_CoInternetCombineUrlEx_Pluggable(void) {
9913     HRESULT hr;
9914     IUri *base = NULL;
9915
9916     hr = pCreateUri(combine_baseW, 0, 0, &base);
9917     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9918     if(SUCCEEDED(hr)) {
9919         IUri *result = NULL;
9920
9921         SET_EXPECT(CombineUrl);
9922
9923         hr = pCoInternetCombineUrlEx(base, combine_relativeW, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
9924                                      &result, 0);
9925         ok(hr == S_OK, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9926
9927         CHECK_CALLED(CombineUrl);
9928
9929         if(SUCCEEDED(hr)) {
9930             BSTR received = NULL;
9931             hr = IUri_GetAbsoluteUri(result, &received);
9932             ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
9933             if(SUCCEEDED(hr)) {
9934                 ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
9935                     wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
9936             }
9937             SysFreeString(received);
9938         }
9939         if(result) IUri_Release(result);
9940     }
9941     if(base) IUri_Release(base);
9942 }
9943
9944 static void test_CoInternetParseIUri_InvalidArgs(void) {
9945     HRESULT hr;
9946     IUri *uri = NULL;
9947     WCHAR tmp[3];
9948     DWORD result = -1;
9949
9950     hr = pCoInternetParseIUri(NULL, PARSE_CANONICALIZE, 0, tmp, 3, &result, 0);
9951     ok(hr == E_INVALIDARG, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9952         hr, E_INVALIDARG);
9953     ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9954
9955     hr = pCreateUri(http_urlW, 0, 0, &uri);
9956     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9957     if(SUCCEEDED(hr)) {
9958         DWORD expected_len;
9959
9960         result = -1;
9961         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, NULL, 0, &result, 0);
9962         ok(hr == E_INVALIDARG, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9963             hr, E_INVALIDARG);
9964         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9965
9966         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, tmp, 3, NULL, 0);
9967         ok(hr == E_POINTER, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9968             hr, E_POINTER);
9969
9970         result = -1;
9971         hr = pCoInternetParseIUri(uri, PARSE_SECURITY_URL, 0, tmp, 3, &result, 0);
9972         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x expected 0x%08x.\n",
9973             hr, E_FAIL);
9974         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9975
9976         result = -1;
9977         hr = pCoInternetParseIUri(uri, PARSE_MIME, 0, tmp, 3, &result, 0);
9978         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9979             hr, E_FAIL);
9980         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9981
9982         result = -1;
9983         hr = pCoInternetParseIUri(uri, PARSE_SERVER, 0, tmp, 3, &result, 0);
9984         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9985             hr, E_FAIL);
9986         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9987
9988         result = -1;
9989         hr = pCoInternetParseIUri(uri, PARSE_SECURITY_DOMAIN, 0, tmp, 3, &result, 0);
9990         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9991             hr, E_FAIL);
9992         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9993
9994         expected_len = lstrlenW(http_urlW);
9995         result = -1;
9996         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, tmp, 3, &result, 0);
9997         ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER,
9998             "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9999             hr, STRSAFE_E_INSUFFICIENT_BUFFER);
10000         ok(result == expected_len, "Error: Expected 'result' to be %d, but was %d instead.\n",
10001             expected_len, result);
10002     }
10003     if(uri) IUri_Release(uri);
10004 }
10005
10006 static void test_CoInternetParseIUri(void) {
10007     DWORD i;
10008
10009     for(i = 0; i < sizeof(uri_parse_tests)/sizeof(uri_parse_tests[0]); ++i) {
10010         HRESULT hr;
10011         IUri *uri;
10012         LPWSTR uriW;
10013         uri_parse_test test = uri_parse_tests[i];
10014
10015         uriW = a2w(test.uri);
10016         hr = pCreateUri(uriW, test.uri_flags, 0, &uri);
10017         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_parse_tests[%d].\n", hr, i);
10018         if(SUCCEEDED(hr)) {
10019             WCHAR result[INTERNET_MAX_URL_LENGTH+1];
10020             DWORD result_len = -1;
10021
10022             hr = pCoInternetParseIUri(uri, test.action, test.flags, result, INTERNET_MAX_URL_LENGTH+1, &result_len, 0);
10023             if(test.todo) {
10024                 todo_wine {
10025                     ok(hr == test.expected,
10026                         "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x on uri_parse_tests[%d].\n",
10027                         hr, test.expected, i);
10028                 }
10029             } else {
10030                 ok(hr == test.expected,
10031                     "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x on uri_parse_tests[%d].\n",
10032                     hr, test.expected, i);
10033             }
10034             if(SUCCEEDED(hr)) {
10035                 DWORD len = lstrlenA(test.property);
10036                 ok(!strcmp_aw(test.property, result),
10037                     "Error: Expected %s but got %s instead on uri_parse_tests[%d].\n",
10038                     test.property, wine_dbgstr_w(result), i);
10039                 ok(len == result_len,
10040                     "Error: Expected %d, but got %d instead on uri_parse_tests[%d].\n",
10041                     len, result_len, i);
10042             } else {
10043                 ok(!result_len,
10044                     "Error: Expected 'result_len' to be 0, but was %d on uri_parse_tests[%d].\n",
10045                     result_len, i);
10046             }
10047         }
10048         if(uri) IUri_Release(uri);
10049         heap_free(uriW);
10050     }
10051 }
10052
10053 static void test_CoInternetParseIUri_Pluggable(void) {
10054     HRESULT hr;
10055     IUri *uri = NULL;
10056
10057     hr = pCreateUri(parse_urlW, 0, 0, &uri);
10058     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, but got 0x%08x.\n", hr);
10059     if(SUCCEEDED(hr)) {
10060         WCHAR result[200];
10061         DWORD result_len;
10062
10063         SET_EXPECT(ParseUrl);
10064
10065         parse_action = PARSE_CANONICALIZE;
10066         parse_flags = URL_UNESCAPE|URL_ESCAPE_UNSAFE;
10067
10068         hr = pCoInternetParseIUri(uri, parse_action, parse_flags, result, 200, &result_len, 0);
10069         ok(hr == S_OK, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
10070
10071         CHECK_CALLED(ParseUrl);
10072
10073         if(SUCCEEDED(hr)) {
10074             ok(result_len == lstrlenW(parse_resultW), "Error: Expected %d, but got %d.\n",
10075                 lstrlenW(parse_resultW), result_len);
10076             ok(!lstrcmpW(result, parse_resultW), "Error: Expected %s, but got %s.\n",
10077                 wine_dbgstr_w(parse_resultW), wine_dbgstr_w(result));
10078         }
10079     }
10080     if(uri) IUri_Release(uri);
10081 }
10082
10083 typedef struct {
10084     const char *url;
10085     DWORD uri_flags;
10086     const char *base_url;
10087     DWORD base_uri_flags;
10088     const char *legacy_url;
10089     const char *uniform_url;
10090     const char *no_canon_url;
10091     const char *uri_url;
10092 } create_urlmon_test_t;
10093
10094 static const create_urlmon_test_t create_urlmon_tests[] = {
10095     {
10096         "http://www.winehq.org",Uri_CREATE_NO_CANONICALIZE,
10097         NULL,0,
10098         "http://www.winehq.org/",
10099         "http://www.winehq.org/",
10100         "http://www.winehq.org",
10101         "http://www.winehq.org"
10102     },
10103     {
10104         "file://c:\\dir\\file.txt",Uri_CREATE_NO_CANONICALIZE,
10105         NULL,0,
10106         "file://c:\\dir\\file.txt",
10107         "file:///c:/dir/file.txt",
10108         "file:///c:/dir/file.txt",
10109         "file:///c:/dir/file.txt"
10110     },
10111     {
10112         "file://c:\\dir\\file.txt",Uri_CREATE_FILE_USE_DOS_PATH,
10113         NULL,0,
10114         "file://c:\\dir\\file.txt",
10115         "file:///c:/dir/file.txt",
10116         "file:///c:/dir/file.txt",
10117         "file://c:\\dir\\file.txt"
10118     },
10119     {
10120         "dat%61",Uri_CREATE_ALLOW_RELATIVE,
10121         "http://www.winehq.org",0,
10122         "http://www.winehq.org/data",
10123         "http://www.winehq.org/data",
10124         "http://www.winehq.org:80/data",
10125     },
10126     {
10127         "file.txt",Uri_CREATE_ALLOW_RELATIVE,
10128         "file://c:\\dir\\x.txt",Uri_CREATE_NO_CANONICALIZE,
10129         "file://c:\\dir\\file.txt",
10130         "file:///c:/dir/file.txt",
10131         "file:///c:/dir/file.txt",
10132     },
10133     {
10134         "",Uri_CREATE_ALLOW_RELATIVE,
10135         NULL,0,
10136         "",
10137         "",
10138         "",
10139         ""
10140     },
10141     {
10142         "test",Uri_CREATE_ALLOW_RELATIVE,
10143         NULL,0,
10144         "test",
10145         "test",
10146         "test",
10147         "test"
10148     },
10149     {
10150         "c:\\dir\\file.txt",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME,
10151         NULL,0,
10152         "file://c:\\dir\\file.txt",
10153         "file:///c:/dir/file.txt",
10154         "file:///c:/dir/file.txt",
10155         "file:///c:/dir/file.txt",
10156     }
10157 };
10158
10159 #define test_urlmon_display_name(a,b) _test_urlmon_display_name(__LINE__,a,b)
10160 static void _test_urlmon_display_name(unsigned line, IMoniker *mon, const char *exurl)
10161 {
10162     WCHAR *display_name;
10163     HRESULT hres;
10164
10165     hres = IMoniker_GetDisplayName(mon, NULL, NULL, &display_name);
10166     ok_(__FILE__,line)(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
10167     ok_(__FILE__,line)(!strcmp_aw(exurl, display_name), "unexpected display name: %s, expected %s\n",
10168             wine_dbgstr_w(display_name), exurl);
10169
10170     CoTaskMemFree(display_name);
10171 }
10172
10173 #define test_display_uri(a,b) _test_display_uri(__LINE__,a,b)
10174 static void _test_display_uri(unsigned line, IMoniker *mon, const char *exurl)
10175 {
10176     IUriContainer *uri_container;
10177     IUri *uri;
10178     BSTR display_uri;
10179     HRESULT hres;
10180
10181     hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container);
10182     ok(hres == S_OK, "Could not get IUriContainer iface: %08x\n", hres);
10183
10184     uri = NULL;
10185     hres = IUriContainer_GetIUri(uri_container, &uri);
10186     IUriContainer_Release(uri_container);
10187     ok(hres == S_OK, "GetIUri failed: %08x\n", hres);
10188     ok(uri != NULL, "uri == NULL\n");
10189
10190     hres = IUri_GetDisplayUri(uri, &display_uri);
10191     IUri_Release(uri);
10192     ok(hres == S_OK, "GetDisplayUri failed: %08x\n", hres);
10193     ok_(__FILE__,line)(!strcmp_aw(exurl, display_uri), "unexpected display uri: %s, expected %s\n",
10194             wine_dbgstr_w(display_uri), exurl);
10195     SysFreeString(display_uri);
10196 }
10197
10198 static void test_CreateURLMoniker(void)
10199 {
10200     const create_urlmon_test_t *test;
10201     IMoniker *mon, *base_mon;
10202     WCHAR *url, *base_url;
10203     IUri *uri, *base_uri;
10204     HRESULT hres;
10205
10206     for(test = create_urlmon_tests; test < create_urlmon_tests + sizeof(create_urlmon_tests)/sizeof(*create_urlmon_tests); test++) {
10207         url = a2w(test->url);
10208         base_url = a2w(test->base_url);
10209
10210         if(base_url) {
10211             hres = pCreateUri(base_url, test->base_uri_flags, 0, &base_uri);
10212             ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
10213
10214             hres = pCreateURLMonikerEx2(NULL, base_uri, &base_mon, URL_MK_NO_CANONICALIZE);
10215             ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10216         }else {
10217             base_uri = NULL;
10218             base_mon = NULL;
10219         }
10220
10221         hres = CreateURLMoniker(base_mon, url, &mon);
10222         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10223         test_urlmon_display_name(mon, test->legacy_url);
10224         test_display_uri(mon, test->legacy_url);
10225         IMoniker_Release(mon);
10226
10227         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_LEGACY);
10228         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10229         test_urlmon_display_name(mon, test->legacy_url);
10230         test_display_uri(mon, test->legacy_url);
10231         IMoniker_Release(mon);
10232
10233         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_UNIFORM);
10234         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10235         test_urlmon_display_name(mon, test->uniform_url);
10236         test_display_uri(mon, test->uniform_url);
10237         IMoniker_Release(mon);
10238
10239         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_NO_CANONICALIZE);
10240         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10241         test_urlmon_display_name(mon, test->no_canon_url);
10242         test_display_uri(mon, test->no_canon_url);
10243         IMoniker_Release(mon);
10244
10245         hres = pCreateUri(url, test->uri_flags, 0, &uri);
10246         ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
10247
10248         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_LEGACY);
10249         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10250         test_urlmon_display_name(mon, base_url ? test->legacy_url : test->uri_url);
10251         test_display_uri(mon, base_url ? test->legacy_url : test->uri_url);
10252         IMoniker_Release(mon);
10253
10254         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_UNIFORM);
10255         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10256         test_urlmon_display_name(mon, base_url ? test->uniform_url : test->uri_url);
10257         test_display_uri(mon, base_url ? test->uniform_url : test->uri_url);
10258         IMoniker_Release(mon);
10259
10260         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_NO_CANONICALIZE);
10261         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10262         test_urlmon_display_name(mon, base_url ? test->no_canon_url : test->uri_url);
10263         test_display_uri(mon, base_url ? test->no_canon_url : test->uri_url);
10264         IMoniker_Release(mon);
10265
10266         IUri_Release(uri);
10267         heap_free(url);
10268         heap_free(base_url);
10269         if(base_uri)
10270             IUri_Release(base_uri);
10271         if(base_mon)
10272             IMoniker_Release(base_mon);
10273     }
10274 }
10275
10276 START_TEST(uri) {
10277     HMODULE hurlmon;
10278
10279     hurlmon = GetModuleHandle("urlmon.dll");
10280     pCoInternetGetSession = (void*) GetProcAddress(hurlmon, "CoInternetGetSession");
10281     pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri");
10282     pCreateUriWithFragment = (void*) GetProcAddress(hurlmon, "CreateUriWithFragment");
10283     pCreateIUriBuilder = (void*) GetProcAddress(hurlmon, "CreateIUriBuilder");
10284     pCoInternetCombineIUri = (void*) GetProcAddress(hurlmon, "CoInternetCombineIUri");
10285     pCoInternetCombineUrlEx = (void*) GetProcAddress(hurlmon, "CoInternetCombineUrlEx");
10286     pCoInternetParseIUri = (void*) GetProcAddress(hurlmon, "CoInternetParseIUri");
10287     pCreateURLMonikerEx = (void*) GetProcAddress(hurlmon, "CreateURLMonikerEx");
10288     pCreateURLMonikerEx2 = (void*) GetProcAddress(hurlmon, "CreateURLMonikerEx2");
10289
10290     if(!pCreateUri) {
10291         win_skip("CreateUri is not present, skipping tests.\n");
10292         return;
10293     }
10294
10295     trace("test CreateUri invalid flags...\n");
10296     test_CreateUri_InvalidFlags();
10297
10298     trace("test CreateUri invalid args...\n");
10299     test_CreateUri_InvalidArgs();
10300
10301     trace("test CreateUri invalid URIs...\n");
10302     test_CreateUri_InvalidUri();
10303
10304     trace("test IUri_GetPropertyBSTR...\n");
10305     test_IUri_GetPropertyBSTR();
10306
10307     trace("test IUri_GetPropertyDWORD...\n");
10308     test_IUri_GetPropertyDWORD();
10309
10310     trace("test IUri_GetStrProperties...\n");
10311     test_IUri_GetStrProperties();
10312
10313     trace("test IUri_GetDwordProperties...\n");
10314     test_IUri_GetDwordProperties();
10315
10316     trace("test IUri_GetPropertyLength...\n");
10317     test_IUri_GetPropertyLength();
10318
10319     trace("test IUri_GetProperties...\n");
10320     test_IUri_GetProperties();
10321
10322     trace("test IUri_HasProperty...\n");
10323     test_IUri_HasProperty();
10324
10325     trace("test IUri_IsEqual...\n");
10326     test_IUri_IsEqual();
10327
10328     trace("test CreateUriWithFragment invalid args...\n");
10329     test_CreateUriWithFragment_InvalidArgs();
10330
10331     trace("test CreateUriWithFragment invalid flags...\n");
10332     test_CreateUriWithFragment_InvalidFlags();
10333
10334     trace("test CreateUriWithFragment...\n");
10335     test_CreateUriWithFragment();
10336
10337     trace("test CreateIUriBuilder...\n");
10338     test_CreateIUriBuilder();
10339
10340     trace("test IUriBuilder_CreateInvalidArgs...\n");
10341     test_IUriBuilder_CreateInvalidArgs();
10342
10343     trace("test IUriBuilder...\n");
10344     test_IUriBuilder();
10345
10346     trace("test IUriBuilder_GetInvalidArgs...\n");
10347     test_IUriBuilder_GetInvalidArgs();
10348
10349     trace("test IUriBuilder_HasBeenModified...\n");
10350     test_IUriBuilder_HasBeenModified();
10351
10352     trace("test IUriBuilder_IUriProperty...\n");
10353     test_IUriBuilder_IUriProperty();
10354
10355     trace("test IUriBuilder_RemoveProperties...\n");
10356     test_IUriBuilder_RemoveProperties();
10357
10358     trace("test IUriBuilder miscellaneous...\n");
10359     test_IUriBuilder_Misc();
10360
10361     trace("test IUriBuilderFactory...\n");
10362     test_IUriBuilderFactory();
10363
10364     trace("test CoInternetCombineIUri...\n");
10365     test_CoInternetCombineIUri();
10366
10367     trace("test CoInternetCombineUrlEx...\n");
10368     test_CoInternetCombineUrlEx();
10369
10370     trace("test CoInternetParseIUri Invalid Args...\n");
10371     test_CoInternetParseIUri_InvalidArgs();
10372
10373     trace("test CoInternetParseIUri...\n");
10374     test_CoInternetParseIUri();
10375
10376     register_protocols();
10377
10378     trace("test CoInternetCombineIUri pluggable...\n");
10379     test_CoInternetCombineIUri_Pluggable();
10380
10381     trace("test CoInternetCombineUrlEx Pluggable...\n");
10382     test_CoInternetCombineUrlEx_Pluggable();
10383
10384     trace("test CoInternetParseIUri pluggable...\n");
10385     test_CoInternetParseIUri_Pluggable();
10386
10387     trace("test CreateURLMoniker...\n");
10388     test_CreateURLMoniker();
10389
10390     unregister_protocols();
10391 }