4 * Copyright 2010 Thomas Mullaly
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.
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.
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
22 * IUri testing framework goals:
25 * - invalid args (IUri, uri string)
26 * - Test parsing for components when no canonicalization occurs
27 * - Test parsing for components when canonicalization occurs.
31 #include <wine/test.h>
42 #define URI_STR_PROPERTY_COUNT Uri_PROPERTY_STRING_LAST+1
43 #define URI_DWORD_PROPERTY_COUNT (Uri_PROPERTY_DWORD_LAST - Uri_PROPERTY_DWORD_START)+1
45 static HRESULT (WINAPI
*pCreateUri
)(LPCWSTR
, DWORD
, DWORD_PTR
, IUri
**);
47 static const WCHAR http_urlW
[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
48 '.','o','r','g','/',0};
50 typedef struct _uri_create_flag_test
{
53 } uri_create_flag_test
;
55 static const uri_create_flag_test invalid_flag_tests
[] = {
56 /* Set of invalid flag combinations to test for. */
57 {Uri_CREATE_DECODE_EXTRA_INFO
| Uri_CREATE_NO_DECODE_EXTRA_INFO
, E_INVALIDARG
},
58 {Uri_CREATE_CANONICALIZE
| Uri_CREATE_NO_CANONICALIZE
, E_INVALIDARG
},
59 {Uri_CREATE_CRACK_UNKNOWN_SCHEMES
| Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES
, E_INVALIDARG
},
60 {Uri_CREATE_PRE_PROCESS_HTML_URI
| Uri_CREATE_NO_PRE_PROCESS_HTML_URI
, E_INVALIDARG
},
61 {Uri_CREATE_IE_SETTINGS
| Uri_CREATE_NO_IE_SETTINGS
, E_INVALIDARG
}
64 typedef struct _uri_str_property
{
70 typedef struct _uri_dword_property
{
76 typedef struct _uri_properties
{
79 HRESULT create_expected
;
84 uri_str_property str_props
[URI_STR_PROPERTY_COUNT
];
85 uri_dword_property dword_props
[URI_DWORD_PROPERTY_COUNT
];
88 static const uri_properties uri_tests
[] = {
89 { "http://www.winehq.org/tests/../tests/../..", 0, S_OK
, FALSE
,
90 /* A flag bitmap containing all the Uri_HAS_* flags that correspond to this uri. */
91 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_AUTHORITY
|Uri_HAS_DISPLAY_URI
|Uri_HAS_DOMAIN
|Uri_HAS_HOST
|
92 Uri_HAS_PATH
|Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|Uri_HAS_SCHEME_NAME
|Uri_HAS_HOST_TYPE
|
93 Uri_HAS_PORT
|Uri_HAS_SCHEME
,
96 {"http://www.winehq.org/",S_OK
,TRUE
}, /* ABSOLUTE_URI */
97 {"www.winehq.org",S_OK
,TRUE
}, /* AUTHORITY */
98 {"http://www.winehq.org/",S_OK
,TRUE
}, /* DISPLAY_URI */
99 {"winehq.org",S_OK
,TRUE
}, /* DOMAIN */
100 {"",S_FALSE
,TRUE
}, /* EXTENSION */
101 {"",S_FALSE
,TRUE
}, /* FRAGMENT */
102 {"www.winehq.org",S_OK
,TRUE
}, /* HOST */
103 {"",S_FALSE
,TRUE
}, /* PASSWORD */
104 {"/",S_OK
,TRUE
}, /* PATH */
105 {"/",S_OK
,TRUE
}, /* PATH_AND_QUERY */
106 {"",S_FALSE
,TRUE
}, /* QUERY */
107 {"http://www.winehq.org/tests/../tests/../..",S_OK
,FALSE
}, /* RAW_URI */
108 {"http",S_OK
,FALSE
}, /* SCHEME_NAME */
109 {"",S_FALSE
,TRUE
}, /* USER_INFO */
110 {"",S_FALSE
,TRUE
} /* USER_NAME */
113 {Uri_HOST_DNS
,S_OK
,TRUE
}, /* HOST_TYPE */
114 {80,S_OK
,TRUE
}, /* PORT */
115 {URL_SCHEME_HTTP
,S_OK
,FALSE
}, /* SCHEME */
116 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
} /* ZONE */
119 { "http://winehq.org/tests/.././tests", 0, S_OK
, FALSE
,
120 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_AUTHORITY
|Uri_HAS_DISPLAY_URI
|Uri_HAS_DOMAIN
|Uri_HAS_HOST
|
121 Uri_HAS_PATH
|Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|Uri_HAS_SCHEME_NAME
|Uri_HAS_HOST_TYPE
|
122 Uri_HAS_PORT
|Uri_HAS_SCHEME
,
125 {"http://winehq.org/tests",S_OK
,TRUE
},
126 {"winehq.org",S_OK
,TRUE
},
127 {"http://winehq.org/tests",S_OK
,TRUE
},
128 {"winehq.org",S_OK
,TRUE
},
131 {"winehq.org",S_OK
,TRUE
},
133 {"/tests",S_OK
,TRUE
},
134 {"/tests",S_OK
,TRUE
},
136 {"http://winehq.org/tests/.././tests",S_OK
,FALSE
},
142 {Uri_HOST_DNS
,S_OK
,TRUE
},
144 {URL_SCHEME_HTTP
,S_OK
,FALSE
},
145 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
148 { "HtTp://www.winehq.org/tests/..?query=x&return=y", 0, S_OK
, FALSE
,
149 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_AUTHORITY
|Uri_HAS_DISPLAY_URI
|Uri_HAS_DOMAIN
|Uri_HAS_HOST
|
150 Uri_HAS_DOMAIN
|Uri_HAS_PATH
|Uri_HAS_PATH_AND_QUERY
|Uri_HAS_QUERY
|Uri_HAS_RAW_URI
|
151 Uri_HAS_SCHEME_NAME
|Uri_HAS_HOST_TYPE
|Uri_HAS_PORT
|Uri_HAS_SCHEME
,
154 {"http://www.winehq.org/?query=x&return=y",S_OK
,TRUE
},
155 {"www.winehq.org",S_OK
,TRUE
},
156 {"http://www.winehq.org/?query=x&return=y",S_OK
,TRUE
},
157 {"winehq.org",S_OK
,TRUE
},
160 {"www.winehq.org",S_OK
,TRUE
},
163 {"/?query=x&return=y",S_OK
,TRUE
},
164 {"?query=x&return=y",S_OK
,TRUE
},
165 {"HtTp://www.winehq.org/tests/..?query=x&return=y",S_OK
,FALSE
},
171 {Uri_HOST_DNS
,S_OK
,TRUE
},
173 {URL_SCHEME_HTTP
,S_OK
,FALSE
},
174 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
},
177 { "hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters", 0, S_OK
, FALSE
,
178 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_AUTHORITY
|Uri_HAS_DISPLAY_URI
|Uri_HAS_DOMAIN
|Uri_HAS_HOST
|Uri_HAS_PATH
|
179 Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|Uri_HAS_SCHEME_NAME
|Uri_HAS_USER_INFO
|Uri_HAS_USER_NAME
|
180 Uri_HAS_HOST_TYPE
|Uri_HAS_PORT
|Uri_HAS_SCHEME
,
183 {"http://usEr%3Ainfo@example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK
,TRUE
},
184 {"usEr%3Ainfo@example.com",S_OK
,TRUE
},
185 {"http://example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK
,TRUE
},
186 {"example.com",S_OK
,TRUE
},
189 {"example.com",S_OK
,TRUE
},
191 {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK
,TRUE
},
192 {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK
,TRUE
},
194 {"hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters",S_OK
,FALSE
},
196 {"usEr%3Ainfo",S_OK
,TRUE
},
197 {"usEr%3Ainfo",S_OK
,TRUE
}
200 {Uri_HOST_DNS
,S_OK
,TRUE
},
202 {URL_SCHEME_HTTP
,S_OK
,FALSE
},
203 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
},
206 { "ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt", 0, S_OK
, FALSE
,
207 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_AUTHORITY
|Uri_HAS_DISPLAY_URI
|Uri_HAS_DOMAIN
|Uri_HAS_EXTENSION
|
208 Uri_HAS_HOST
|Uri_HAS_PASSWORD
|Uri_HAS_PATH
|Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|
209 Uri_HAS_SCHEME_NAME
|Uri_HAS_USER_INFO
|Uri_HAS_USER_NAME
|Uri_HAS_HOST_TYPE
|Uri_HAS_PORT
|
213 {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK
,TRUE
},
214 {"winepass:wine@ftp.winehq.org:9999",S_OK
,TRUE
},
215 {"ftp://ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK
,TRUE
},
216 {"winehq.org",S_OK
,TRUE
},
219 {"ftp.winehq.org",S_OK
,TRUE
},
221 {"/dir/foo%20bar.txt",S_OK
,TRUE
},
222 {"/dir/foo%20bar.txt",S_OK
,TRUE
},
224 {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt",S_OK
,FALSE
},
226 {"winepass:wine",S_OK
,TRUE
},
227 {"winepass",S_OK
,TRUE
}
230 {Uri_HOST_DNS
,S_OK
,TRUE
},
232 {URL_SCHEME_FTP
,S_OK
,FALSE
},
233 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
236 { "file://c:\\tests\\../tests/foo%20bar.mp3", 0, S_OK
, FALSE
,
237 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_DISPLAY_URI
|Uri_HAS_EXTENSION
|Uri_HAS_PATH
|
238 Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|Uri_HAS_SCHEME_NAME
|Uri_HAS_HOST_TYPE
|Uri_HAS_SCHEME
,
241 {"file:///c:/tests/foo%2520bar.mp3",S_OK
,TRUE
},
243 {"file:///c:/tests/foo%2520bar.mp3",S_OK
,TRUE
},
249 {"/c:/tests/foo%2520bar.mp3",S_OK
,TRUE
},
250 {"/c:/tests/foo%2520bar.mp3",S_OK
,TRUE
},
252 {"file://c:\\tests\\../tests/foo%20bar.mp3",S_OK
,FALSE
},
258 {Uri_HOST_UNKNOWN
,S_OK
,TRUE
},
260 {URL_SCHEME_FILE
,S_OK
,FALSE
},
261 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
264 { "FILE://localhost/test dir\\../tests/test%20file.README.txt", 0, S_OK
, FALSE
,
265 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_DISPLAY_URI
|Uri_HAS_EXTENSION
|Uri_HAS_PATH
|
266 Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|Uri_HAS_SCHEME_NAME
|Uri_HAS_HOST_TYPE
|Uri_HAS_SCHEME
,
269 {"file:///tests/test%20file.README.txt",S_OK
,TRUE
},
271 {"file:///tests/test%20file.README.txt",S_OK
,TRUE
},
277 {"/tests/test%20file.README.txt",S_OK
,TRUE
},
278 {"/tests/test%20file.README.txt",S_OK
,TRUE
},
280 {"FILE://localhost/test dir\\../tests/test%20file.README.txt",S_OK
,FALSE
},
286 {Uri_HOST_UNKNOWN
,S_OK
,TRUE
},
288 {URL_SCHEME_FILE
,S_OK
,FALSE
},
289 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
292 { "urn:nothing:should:happen here", 0, S_OK
, FALSE
,
293 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_DISPLAY_URI
|Uri_HAS_PATH
|Uri_HAS_PATH_AND_QUERY
|
294 Uri_HAS_RAW_URI
|Uri_HAS_SCHEME_NAME
|Uri_HAS_HOST_TYPE
|Uri_HAS_SCHEME
,
297 {"urn:nothing:should:happen here",S_OK
,TRUE
},
299 {"urn:nothing:should:happen here",S_OK
,TRUE
},
305 {"nothing:should:happen here",S_OK
,TRUE
},
306 {"nothing:should:happen here",S_OK
,TRUE
},
308 {"urn:nothing:should:happen here",S_OK
,FALSE
},
314 {Uri_HOST_UNKNOWN
,S_OK
,TRUE
},
316 {URL_SCHEME_UNKNOWN
,S_OK
,FALSE
},
317 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
320 { "http://127.0.0.1/tests/../test dir/./test.txt", 0, S_OK
, FALSE
,
321 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_AUTHORITY
|Uri_HAS_DISPLAY_URI
|Uri_HAS_EXTENSION
|
322 Uri_HAS_HOST
|Uri_HAS_PATH
|Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|Uri_HAS_SCHEME_NAME
|
323 Uri_HAS_HOST_TYPE
|Uri_HAS_PORT
|Uri_HAS_SCHEME
,
326 {"http://127.0.0.1/test%20dir/test.txt",S_OK
,TRUE
},
327 {"127.0.0.1",S_OK
,TRUE
},
328 {"http://127.0.0.1/test%20dir/test.txt",S_OK
,TRUE
},
332 {"127.0.0.1",S_OK
,TRUE
},
334 {"/test%20dir/test.txt",S_OK
,TRUE
},
335 {"/test%20dir/test.txt",S_OK
,TRUE
},
337 {"http://127.0.0.1/tests/../test dir/./test.txt",S_OK
,FALSE
},
343 {Uri_HOST_IPV4
,S_OK
,TRUE
},
345 {URL_SCHEME_HTTP
,S_OK
,FALSE
},
346 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
349 { "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", 0, S_OK
, FALSE
,
350 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_AUTHORITY
|Uri_HAS_DISPLAY_URI
|Uri_HAS_HOST
|
351 Uri_HAS_PATH
|Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|Uri_HAS_SCHEME_NAME
|
352 Uri_HAS_HOST_TYPE
|Uri_HAS_PORT
|Uri_HAS_SCHEME
,
355 {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK
,TRUE
},
356 {"[fedc:ba98:7654:3210:fedc:ba98:7654:3210]",S_OK
,TRUE
},
357 {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK
,TRUE
},
361 {"fedc:ba98:7654:3210:fedc:ba98:7654:3210",S_OK
,TRUE
},
366 {"http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]",S_OK
,FALSE
},
372 {Uri_HOST_IPV6
,S_OK
,TRUE
},
374 {URL_SCHEME_HTTP
,S_OK
,FALSE
},
375 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
378 { "ftp://[::13.1.68.3]", 0, S_OK
, FALSE
,
379 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_AUTHORITY
|Uri_HAS_DISPLAY_URI
|Uri_HAS_HOST
|
380 Uri_HAS_PATH
|Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|Uri_HAS_SCHEME_NAME
|
381 Uri_HAS_HOST_TYPE
|Uri_HAS_PORT
|Uri_HAS_SCHEME
,
384 {"ftp://[::13.1.68.3]/",S_OK
,TRUE
},
385 {"[::13.1.68.3]",S_OK
,TRUE
},
386 {"ftp://[::13.1.68.3]/",S_OK
,TRUE
},
390 {"::13.1.68.3",S_OK
,TRUE
},
395 {"ftp://[::13.1.68.3]",S_OK
,FALSE
},
401 {Uri_HOST_IPV6
,S_OK
,TRUE
},
403 {URL_SCHEME_FTP
,S_OK
,FALSE
},
404 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
407 { "http://[FEDC:BA98:0:0:0:0:0:3210]", 0, S_OK
, FALSE
,
408 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_AUTHORITY
|Uri_HAS_DISPLAY_URI
|Uri_HAS_HOST
|
409 Uri_HAS_PATH
|Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|Uri_HAS_SCHEME_NAME
|
410 Uri_HAS_HOST_TYPE
|Uri_HAS_PORT
|Uri_HAS_SCHEME
,
413 {"http://[fedc:ba98::3210]/",S_OK
,TRUE
},
414 {"[fedc:ba98::3210]",S_OK
,TRUE
},
415 {"http://[fedc:ba98::3210]/",S_OK
,TRUE
},
419 {"fedc:ba98::3210",S_OK
,TRUE
},
424 {"http://[FEDC:BA98:0:0:0:0:0:3210]",S_OK
,FALSE
},
430 {Uri_HOST_IPV6
,S_OK
,TRUE
},
432 {URL_SCHEME_HTTP
,S_OK
,FALSE
},
433 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
436 { "1234://www.winehq.org", 0, S_OK
, FALSE
,
437 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_AUTHORITY
|Uri_HAS_DISPLAY_URI
|Uri_HAS_DOMAIN
|
438 Uri_HAS_HOST
|Uri_HAS_PATH
|Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|Uri_HAS_SCHEME_NAME
|
439 Uri_HAS_HOST_TYPE
|Uri_HAS_SCHEME
,
442 {"1234://www.winehq.org/",S_OK
,TRUE
},
443 {"www.winehq.org",S_OK
,TRUE
},
444 {"1234://www.winehq.org/",S_OK
,TRUE
},
445 {"winehq.org",S_OK
,TRUE
},
448 {"www.winehq.org",S_OK
,TRUE
},
453 {"1234://www.winehq.org",S_OK
,FALSE
},
459 {Uri_HOST_DNS
,S_OK
,TRUE
},
461 {URL_SCHEME_UNKNOWN
,S_OK
,FALSE
},
462 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
465 { "://www.winehq.org", 0, E_INVALIDARG
, FALSE
,
485 {Uri_HOST_UNKNOWN
,S_FALSE
,TRUE
},
487 {URL_SCHEME_UNKNOWN
,S_FALSE
,FALSE
},
488 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
491 /* Window's doesn't like URI's which are implicitly file paths without the ALLOW_IMPLICIT_FILE_SCHEME flag set. */
492 { "C:/test/test.mp3", 0, E_INVALIDARG
, FALSE
,
512 {Uri_HOST_UNKNOWN
,S_FALSE
,FALSE
},
514 {URL_SCHEME_INVALID
,S_FALSE
,FALSE
},
515 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
518 /* Window's doesn't like URI's which are implicitly file paths without the ALLOW_IMPLICIT_FILE_SCHEME flag set. */
519 { "\\\\Server/test/test.mp3", 0, E_INVALIDARG
, FALSE
,
539 {Uri_HOST_UNKNOWN
,S_FALSE
,FALSE
},
541 {URL_SCHEME_INVALID
,S_FALSE
,FALSE
},
542 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
545 /* Window's doesn't like URI's which are implicitly file paths without the ALLOW_IMPLICIT_FILE_SCHEME flag set. */
546 { "\\\\Server/test/test.mp3", Uri_CREATE_ALLOW_RELATIVE
, E_INVALIDARG
, FALSE
,
566 {Uri_HOST_UNKNOWN
,S_FALSE
,FALSE
},
568 {URL_SCHEME_INVALID
,S_FALSE
,FALSE
},
569 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
572 /* Window's doesn't like URI's which are implicitly file paths without the ALLOW_IMPLICIT_FILE_SCHEME flag set. */
573 { "C:/test/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME
, E_INVALIDARG
, FALSE
,
593 {Uri_HOST_UNKNOWN
,S_FALSE
,FALSE
},
595 {URL_SCHEME_INVALID
,S_FALSE
,FALSE
},
596 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
599 /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
600 { "C:/test/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME
, S_OK
, FALSE
,
601 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_DISPLAY_URI
|Uri_HAS_EXTENSION
|Uri_HAS_PATH
|
602 Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|Uri_HAS_SCHEME_NAME
|Uri_HAS_HOST_TYPE
|Uri_HAS_SCHEME
,
605 {"file:///C:/test/test.mp3",S_OK
,TRUE
},
607 {"file:///C:/test/test.mp3",S_OK
,TRUE
},
613 {"/C:/test/test.mp3",S_OK
,TRUE
},
614 {"/C:/test/test.mp3",S_OK
,TRUE
},
616 {"C:/test/test.mp3",S_OK
,FALSE
},
622 {Uri_HOST_UNKNOWN
,S_OK
,TRUE
},
624 {URL_SCHEME_FILE
,S_OK
,FALSE
},
625 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
628 /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
629 { "\\\\Server/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME
, S_OK
, FALSE
,
630 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_AUTHORITY
|Uri_HAS_DISPLAY_URI
|Uri_HAS_EXTENSION
|
631 Uri_HAS_PATH
|Uri_HAS_PATH_AND_QUERY
|Uri_HAS_HOST
|Uri_HAS_RAW_URI
|Uri_HAS_SCHEME_NAME
|
632 Uri_HAS_HOST_TYPE
|Uri_HAS_SCHEME
,
635 {"file://server/test.mp3",S_OK
,TRUE
},
636 {"server",S_OK
,TRUE
},
637 {"file://server/test.mp3",S_OK
,TRUE
},
641 {"server",S_OK
,TRUE
},
643 {"/test.mp3",S_OK
,TRUE
},
644 {"/test.mp3",S_OK
,TRUE
},
646 {"\\\\Server/test.mp3",S_OK
,FALSE
},
652 {Uri_HOST_DNS
,S_OK
,TRUE
},
654 {URL_SCHEME_FILE
,S_OK
,FALSE
},
655 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
658 { "www.winehq.org/test", Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME
, S_OK
, FALSE
,
659 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_AUTHORITY
|Uri_HAS_DISPLAY_URI
|Uri_HAS_DOMAIN
|Uri_HAS_HOST
|
660 Uri_HAS_PATH
|Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|Uri_HAS_SCHEME_NAME
|Uri_HAS_HOST_TYPE
|
664 {"*:www.winehq.org/test",S_OK
,TRUE
},
665 {"www.winehq.org",S_OK
,TRUE
},
666 {"*:www.winehq.org/test",S_OK
,TRUE
},
667 {"winehq.org",S_OK
,TRUE
},
670 {"www.winehq.org",S_OK
,TRUE
},
675 {"www.winehq.org/test",S_OK
,FALSE
},
681 {Uri_HOST_DNS
,S_OK
,TRUE
},
683 {URL_SCHEME_WILDCARD
,S_OK
,FALSE
},
684 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
687 /* Valid since the '*' is the only character in the scheme name. */
688 { "*:www.winehq.org/test", 0, S_OK
, FALSE
,
689 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_AUTHORITY
|Uri_HAS_DISPLAY_URI
|Uri_HAS_DOMAIN
|Uri_HAS_HOST
|
690 Uri_HAS_PATH
|Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|Uri_HAS_SCHEME_NAME
|Uri_HAS_HOST_TYPE
|
694 {"*:www.winehq.org/test",S_OK
,TRUE
},
695 {"www.winehq.org",S_OK
,TRUE
},
696 {"*:www.winehq.org/test",S_OK
,TRUE
},
697 {"winehq.org",S_OK
,TRUE
},
700 {"www.winehq.org",S_OK
,TRUE
},
705 {"*:www.winehq.org/test",S_OK
,FALSE
},
711 {Uri_HOST_DNS
,S_OK
,TRUE
},
713 {URL_SCHEME_WILDCARD
,S_OK
,FALSE
},
714 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
717 /* Not valid since a '*' is only allowed to appear if its the only character in scheme. */
718 { "*abcd://not.valid.com", 0, E_INVALIDARG
, FALSE
,
738 {Uri_HOST_UNKNOWN
,S_FALSE
,FALSE
},
740 {URL_SCHEME_INVALID
,S_FALSE
,FALSE
},
741 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
744 /* Not valid since a '*' is only allowed to appear if its the only character in scheme. */
745 { "*a*b*c*d://not.valid.com", 0, E_INVALIDARG
, FALSE
,
765 {Uri_HOST_UNKNOWN
,S_FALSE
,FALSE
},
767 {URL_SCHEME_INVALID
,S_FALSE
,FALSE
},
768 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
771 { "/../some dir/test.ext", Uri_CREATE_ALLOW_RELATIVE
, S_OK
, FALSE
,
772 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_DISPLAY_URI
|Uri_HAS_EXTENSION
|Uri_HAS_PATH
|
773 Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|Uri_HAS_HOST_TYPE
|Uri_HAS_SCHEME
,
776 {"/../some dir/test.ext",S_OK
,TRUE
},
778 {"/../some dir/test.ext",S_OK
,TRUE
},
784 {"/../some dir/test.ext",S_OK
,TRUE
},
785 {"/../some dir/test.ext",S_OK
,TRUE
},
787 {"/../some dir/test.ext",S_OK
,FALSE
},
793 {Uri_HOST_UNKNOWN
,S_OK
,TRUE
},
795 {URL_SCHEME_UNKNOWN
,S_OK
,FALSE
},
796 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
799 { "//implicit/wildcard/uri scheme", Uri_CREATE_ALLOW_RELATIVE
|Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME
, S_OK
, FALSE
,
800 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_AUTHORITY
|Uri_HAS_DISPLAY_URI
|Uri_HAS_HOST
|Uri_HAS_PATH
|
801 Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|Uri_HAS_SCHEME_NAME
|Uri_HAS_HOST_TYPE
|Uri_HAS_SCHEME
,
804 {"*://implicit/wildcard/uri%20scheme",S_OK
,TRUE
},
806 {"*://implicit/wildcard/uri%20scheme",S_OK
,TRUE
},
812 {"//implicit/wildcard/uri%20scheme",S_OK
,TRUE
},
813 {"//implicit/wildcard/uri%20scheme",S_OK
,TRUE
},
815 {"//implicit/wildcard/uri scheme",S_OK
,FALSE
},
821 {Uri_HOST_UNKNOWN
,S_OK
,TRUE
},
823 {URL_SCHEME_WILDCARD
,S_OK
,FALSE
},
824 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
827 /* URI is considered opaque since CREATE_NO_CRACK_UNKNOWN_SCHEMES is set and its an unknown scheme. */
828 { "zip://google.com", Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES
, S_OK
, FALSE
,
829 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_DISPLAY_URI
|Uri_HAS_EXTENSION
|Uri_HAS_PATH
|
830 Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|Uri_HAS_HOST_TYPE
|Uri_HAS_SCHEME_NAME
|
834 {"zip:/.//google.com",S_OK
,TRUE
},
836 {"zip:/.//google.com",S_OK
,TRUE
},
842 {"/.//google.com",S_OK
,TRUE
},
843 {"/.//google.com",S_OK
,TRUE
},
845 {"zip://google.com",S_OK
,FALSE
},
851 {Uri_HOST_UNKNOWN
,S_OK
,TRUE
},
853 {URL_SCHEME_UNKNOWN
,S_OK
,FALSE
},
854 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
857 /* Windows uses the first occurence of ':' to delimit the userinfo. */
858 { "ftp://user:pass:word@winehq.org/", 0, S_OK
, FALSE
,
859 Uri_HAS_ABSOLUTE_URI
|Uri_HAS_AUTHORITY
|Uri_HAS_DISPLAY_URI
|Uri_HAS_DOMAIN
|
860 Uri_HAS_HOST
|Uri_HAS_PASSWORD
|Uri_HAS_PATH
|Uri_HAS_PATH_AND_QUERY
|Uri_HAS_RAW_URI
|
861 Uri_HAS_SCHEME_NAME
|Uri_HAS_USER_INFO
|Uri_HAS_USER_NAME
|Uri_HAS_HOST_TYPE
|Uri_HAS_PORT
|
865 {"ftp://user:pass:word@winehq.org/",S_OK
,TRUE
},
866 {"user:pass:word@winehq.org",S_OK
,TRUE
},
867 {"ftp://winehq.org/",S_OK
,TRUE
},
868 {"winehq.org",S_OK
,TRUE
},
871 {"winehq.org",S_OK
,TRUE
},
872 {"pass:word",S_OK
,TRUE
},
876 {"ftp://user:pass:word@winehq.org/",S_OK
,FALSE
},
878 {"user:pass:word",S_OK
,TRUE
},
882 {Uri_HOST_DNS
,S_OK
,TRUE
},
884 {URL_SCHEME_FTP
,S_OK
,FALSE
},
885 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
890 typedef struct _uri_equality
{
892 DWORD create_flags_a
;
895 DWORD create_flags_b
;
901 static const uri_equality equality_tests
[] = {
903 "HTTP://www.winehq.org/test dir/./",0,FALSE
,
904 "http://www.winehq.org/test dir/../test dir/",0,FALSE
,
908 /* http://www.winehq.org/test%20dir */
909 "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
,
910 "http://www.winehq.org/test dir",0,FALSE
,
914 "c:\\test.mp3",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME
,FALSE
,
915 "file:///c:/test.mp3",0,FALSE
,
919 "ftp://ftp.winehq.org/",0,FALSE
,
920 "ftp://ftp.winehq.org",0,FALSE
,
924 "ftp://ftp.winehq.org/test/test2/../../testB/",0,FALSE
,
925 "ftp://ftp.winehq.org/t%45stB/",0,FALSE
,
930 static inline LPWSTR
a2w(LPCSTR str
) {
934 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
935 ret
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
936 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
942 static inline BOOL
heap_free(void* mem
) {
943 return HeapFree(GetProcessHeap(), 0, mem
);
946 static inline DWORD
strcmp_aw(LPCSTR strA
, LPCWSTR strB
) {
947 LPWSTR strAW
= a2w(strA
);
948 DWORD ret
= lstrcmpW(strAW
, strB
);
954 * Simple tests to make sure the CreateUri function handles invalid flag combinations
957 static void test_CreateUri_InvalidFlags(void) {
960 for(i
= 0; i
< sizeof(invalid_flag_tests
)/sizeof(invalid_flag_tests
[0]); ++i
) {
962 IUri
*uri
= (void*) 0xdeadbeef;
964 hr
= pCreateUri(http_urlW
, invalid_flag_tests
[i
].flags
, 0, &uri
);
966 ok(hr
== invalid_flag_tests
[i
].expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x, flags=0x%08x\n",
967 hr
, invalid_flag_tests
[i
].expected
, invalid_flag_tests
[i
].flags
);
969 todo_wine
{ ok(uri
== NULL
, "Error: expected the IUri to be NULL, but it was %p instead\n", uri
); }
973 static void test_CreateUri_InvalidArgs(void) {
975 IUri
*uri
= (void*) 0xdeadbeef;
977 const WCHAR invalidW
[] = {'i','n','v','a','l','i','d',0};
979 hr
= pCreateUri(http_urlW
, 0, 0, NULL
);
980 ok(hr
== E_INVALIDARG
, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr
, E_INVALIDARG
);
982 hr
= pCreateUri(NULL
, 0, 0, &uri
);
983 ok(hr
== E_INVALIDARG
, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr
, E_INVALIDARG
);
984 ok(uri
== NULL
, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri
);
986 uri
= (void*) 0xdeadbeef;
987 hr
= pCreateUri(invalidW
, 0, 0, &uri
);
988 ok(hr
== E_INVALIDARG
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
989 ok(uri
== NULL
, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri
);
992 static void test_IUri_GetPropertyBSTR(void) {
997 /* Make sure GetPropertyBSTR handles invalid args correctly. */
998 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
999 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
1001 BSTR received
= NULL
;
1003 hr
= IUri_GetPropertyBSTR(uri
, Uri_PROPERTY_RAW_URI
, NULL
, 0);
1004 ok(hr
== E_POINTER
, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
1006 /* Make sure it handles a invalid Uri_PROPERTY's correctly. */
1007 hr
= IUri_GetPropertyBSTR(uri
, Uri_PROPERTY_PORT
, &received
, 0);
1008 ok(hr
== S_OK
, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
1009 ok(received
!= NULL
, "Error: Expected the string not to be NULL.\n");
1010 ok(!SysStringLen(received
), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received
));
1011 SysFreeString(received
);
1013 /* Make sure it handles the ZONE property correctly. */
1015 hr
= IUri_GetPropertyBSTR(uri
, Uri_PROPERTY_ZONE
, &received
, 0);
1016 ok(hr
== S_FALSE
, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr
, S_FALSE
);
1017 ok(received
!= NULL
, "Error: Expected the string not to be NULL.\n");
1018 ok(!SysStringLen(received
), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received
));
1019 SysFreeString(received
);
1021 if(uri
) IUri_Release(uri
);
1023 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
1024 uri_properties test
= uri_tests
[i
];
1028 uriW
= a2w(test
.uri
);
1029 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
1030 if(test
.create_todo
) {
1032 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
1033 hr
, test
.create_expected
, i
);
1036 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
1037 hr
, test
.create_expected
, i
);
1043 /* Checks all the string properties of the uri. */
1044 for(j
= Uri_PROPERTY_STRING_START
; j
<= Uri_PROPERTY_STRING_LAST
; ++j
) {
1045 BSTR received
= NULL
;
1046 uri_str_property prop
= test
.str_props
[j
];
1048 hr
= IUri_GetPropertyBSTR(uri
, j
, &received
, 0);
1051 ok(hr
== prop
.expected
, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
1052 hr
, prop
.expected
, i
, j
);
1055 ok(!strcmp_aw(prop
.value
, received
), "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
1056 prop
.value
, wine_dbgstr_w(received
), i
, j
);
1059 ok(hr
== prop
.expected
, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
1060 hr
, prop
.expected
, i
, j
);
1061 ok(!strcmp_aw(prop
.value
, received
), "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
1062 prop
.value
, wine_dbgstr_w(received
), i
, j
);
1065 SysFreeString(received
);
1069 if(uri
) IUri_Release(uri
);
1075 static void test_IUri_GetPropertyDWORD(void) {
1080 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
1081 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
1083 DWORD received
= 0xdeadbeef;
1085 hr
= IUri_GetPropertyDWORD(uri
, Uri_PROPERTY_DWORD_START
, NULL
, 0);
1086 ok(hr
== E_INVALIDARG
, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1088 hr
= IUri_GetPropertyDWORD(uri
, Uri_PROPERTY_ABSOLUTE_URI
, &received
, 0);
1089 ok(hr
== E_INVALIDARG
, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1090 ok(received
== 0, "Error: Expected received=%d but instead received=%d.\n", 0, received
);
1092 if(uri
) IUri_Release(uri
);
1094 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
1095 uri_properties test
= uri_tests
[i
];
1099 uriW
= a2w(test
.uri
);
1100 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
1101 if(test
.create_todo
) {
1103 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
1104 hr
, test
.create_expected
, i
);
1107 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
1108 hr
, test
.create_expected
, i
);
1114 /* Checks all the DWORD properties of the uri. */
1115 for(j
= 0; j
< sizeof(test
.dword_props
)/sizeof(test
.dword_props
[0]); ++j
) {
1117 uri_dword_property prop
= test
.dword_props
[j
];
1119 hr
= IUri_GetPropertyDWORD(uri
, j
+Uri_PROPERTY_DWORD_START
, &received
, 0);
1122 ok(hr
== prop
.expected
, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
1123 hr
, prop
.expected
, i
, j
);
1126 ok(prop
.value
== received
, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
1127 prop
.value
, received
, i
, j
);
1130 ok(hr
== prop
.expected
, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
1131 hr
, prop
.expected
, i
, j
);
1132 ok(prop
.value
== received
, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
1133 prop
.value
, received
, i
, j
);
1138 if(uri
) IUri_Release(uri
);
1144 /* Tests all the 'Get*' property functions which deal with strings. */
1145 static void test_IUri_GetStrProperties(void) {
1150 /* Make sure all the 'Get*' string property functions handle invalid args correctly. */
1151 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
1152 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
1154 hr
= IUri_GetAbsoluteUri(uri
, NULL
);
1155 ok(hr
== E_POINTER
, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
1157 hr
= IUri_GetAuthority(uri
, NULL
);
1158 ok(hr
== E_POINTER
, "Error: GetAuthority returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
1160 hr
= IUri_GetDisplayUri(uri
, NULL
);
1161 ok(hr
== E_POINTER
, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
1163 hr
= IUri_GetDomain(uri
, NULL
);
1164 ok(hr
== E_POINTER
, "Error: GetDomain returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
1166 hr
= IUri_GetExtension(uri
, NULL
);
1167 ok(hr
== E_POINTER
, "Error: GetExtension returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
1169 hr
= IUri_GetFragment(uri
, NULL
);
1170 ok(hr
== E_POINTER
, "Error: GetFragment returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
1172 hr
= IUri_GetHost(uri
, NULL
);
1173 ok(hr
== E_POINTER
, "Error: GetHost returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
1175 hr
= IUri_GetPassword(uri
, NULL
);
1176 ok(hr
== E_POINTER
, "Error: GetPassword returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
1178 hr
= IUri_GetPath(uri
, NULL
);
1179 ok(hr
== E_POINTER
, "Error: GetPath returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
1181 hr
= IUri_GetPathAndQuery(uri
, NULL
);
1182 ok(hr
== E_POINTER
, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
1184 hr
= IUri_GetQuery(uri
, NULL
);
1185 ok(hr
== E_POINTER
, "Error: GetQuery returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
1187 hr
= IUri_GetRawUri(uri
, NULL
);
1188 ok(hr
== E_POINTER
, "Error: GetRawUri returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
1190 hr
= IUri_GetSchemeName(uri
, NULL
);
1191 ok(hr
== E_POINTER
, "Error: GetSchemeName returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
1193 hr
= IUri_GetUserInfo(uri
, NULL
);
1194 ok(hr
== E_POINTER
, "Error: GetUserInfo returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
1196 hr
= IUri_GetUserName(uri
, NULL
);
1197 ok(hr
== E_POINTER
, "Error: GetUserName returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
1199 if(uri
) IUri_Release(uri
);
1201 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
1202 uri_properties test
= uri_tests
[i
];
1206 uriW
= a2w(test
.uri
);
1207 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
1208 if(test
.create_todo
) {
1210 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1211 hr
, test
.create_expected
, i
);
1214 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1215 hr
, test
.create_expected
, i
);
1219 uri_str_property prop
;
1220 BSTR received
= NULL
;
1222 /* GetAbsoluteUri() tests. */
1223 prop
= test
.str_props
[Uri_PROPERTY_ABSOLUTE_URI
];
1224 hr
= IUri_GetAbsoluteUri(uri
, &received
);
1227 ok(hr
== prop
.expected
, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1228 hr
, prop
.expected
, i
);
1231 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1232 prop
.value
, wine_dbgstr_w(received
), i
);
1235 ok(hr
== prop
.expected
, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1236 hr
, prop
.expected
, i
);
1237 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1238 prop
.value
, wine_dbgstr_w(received
), i
);
1240 SysFreeString(received
);
1243 /* GetAuthority() tests. */
1244 prop
= test
.str_props
[Uri_PROPERTY_AUTHORITY
];
1245 hr
= IUri_GetAuthority(uri
, &received
);
1248 ok(hr
== prop
.expected
, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1249 hr
, prop
.expected
, i
);
1252 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1253 prop
.value
, wine_dbgstr_w(received
), i
);
1256 ok(hr
== prop
.expected
, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1257 hr
, prop
.expected
, i
);
1258 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1259 prop
.value
, wine_dbgstr_w(received
), i
);
1261 SysFreeString(received
);
1264 /* GetDisplayUri() tests. */
1265 prop
= test
.str_props
[Uri_PROPERTY_DISPLAY_URI
];
1266 hr
= IUri_GetDisplayUri(uri
, &received
);
1269 ok(hr
== prop
.expected
, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1270 hr
, prop
.expected
, i
);
1273 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_test[%d].\n",
1274 prop
.value
, wine_dbgstr_w(received
), i
);
1277 ok(hr
== prop
.expected
, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1278 hr
, prop
.expected
, i
);
1279 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1280 prop
.value
, wine_dbgstr_w(received
), i
);
1282 SysFreeString(received
);
1285 /* GetDomain() tests. */
1286 prop
= test
.str_props
[Uri_PROPERTY_DOMAIN
];
1287 hr
= IUri_GetDomain(uri
, &received
);
1290 ok(hr
== prop
.expected
, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1291 hr
, prop
.expected
, i
);
1294 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1295 prop
.value
, wine_dbgstr_w(received
), i
);
1298 ok(hr
== prop
.expected
, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1299 hr
, prop
.expected
, i
);
1300 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1301 prop
.value
, wine_dbgstr_w(received
), i
);
1303 SysFreeString(received
);
1306 /* GetExtension() tests. */
1307 prop
= test
.str_props
[Uri_PROPERTY_EXTENSION
];
1308 hr
= IUri_GetExtension(uri
, &received
);
1311 ok(hr
== prop
.expected
, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1312 hr
, prop
.expected
, i
);
1315 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1316 prop
.value
, wine_dbgstr_w(received
), i
);
1319 ok(hr
== prop
.expected
, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1320 hr
, prop
.expected
, i
);
1321 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1322 prop
.value
, wine_dbgstr_w(received
), i
);
1324 SysFreeString(received
);
1327 /* GetFragment() tests. */
1328 prop
= test
.str_props
[Uri_PROPERTY_FRAGMENT
];
1329 hr
= IUri_GetFragment(uri
, &received
);
1332 ok(hr
== prop
.expected
, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1333 hr
, prop
.expected
, i
);
1336 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1337 prop
.value
, wine_dbgstr_w(received
), i
);
1340 ok(hr
== prop
.expected
, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1341 hr
, prop
.expected
, i
);
1342 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1343 prop
.value
, wine_dbgstr_w(received
), i
);
1345 SysFreeString(received
);
1348 /* GetHost() tests. */
1349 prop
= test
.str_props
[Uri_PROPERTY_HOST
];
1350 hr
= IUri_GetHost(uri
, &received
);
1353 ok(hr
== prop
.expected
, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1354 hr
, prop
.expected
, i
);
1357 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1358 prop
.value
, wine_dbgstr_w(received
), i
);
1361 ok(hr
== prop
.expected
, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1362 hr
, prop
.expected
, i
);
1363 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1364 prop
.value
, wine_dbgstr_w(received
), i
);
1366 SysFreeString(received
);
1369 /* GetPassword() tests. */
1370 prop
= test
.str_props
[Uri_PROPERTY_PASSWORD
];
1371 hr
= IUri_GetPassword(uri
, &received
);
1374 ok(hr
== prop
.expected
, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1375 hr
, prop
.expected
, i
);
1378 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1379 prop
.value
, wine_dbgstr_w(received
), i
);
1382 ok(hr
== prop
.expected
, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1383 hr
, prop
.expected
, i
);
1384 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1385 prop
.value
, wine_dbgstr_w(received
), i
);
1387 SysFreeString(received
);
1390 /* GetPath() tests. */
1391 prop
= test
.str_props
[Uri_PROPERTY_PATH
];
1392 hr
= IUri_GetPath(uri
, &received
);
1395 ok(hr
== prop
.expected
, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1396 hr
, prop
.expected
, i
);
1399 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1400 prop
.value
, wine_dbgstr_w(received
), i
);
1403 ok(hr
== prop
.expected
, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1404 hr
, prop
.expected
, i
);
1405 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1406 prop
.value
, wine_dbgstr_w(received
), i
);
1408 SysFreeString(received
);
1411 /* GetPathAndQuery() tests. */
1412 prop
= test
.str_props
[Uri_PROPERTY_PATH_AND_QUERY
];
1413 hr
= IUri_GetPathAndQuery(uri
, &received
);
1416 ok(hr
== prop
.expected
, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1417 hr
, prop
.expected
, i
);
1420 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1421 prop
.value
, wine_dbgstr_w(received
), i
);
1424 ok(hr
== prop
.expected
, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1425 hr
, prop
.expected
, i
);
1426 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1427 prop
.value
, wine_dbgstr_w(received
), i
);
1429 SysFreeString(received
);
1432 /* GetQuery() tests. */
1433 prop
= test
.str_props
[Uri_PROPERTY_QUERY
];
1434 hr
= IUri_GetQuery(uri
, &received
);
1437 ok(hr
== prop
.expected
, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1438 hr
, prop
.expected
, i
);
1441 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1442 prop
.value
, wine_dbgstr_w(received
), i
);
1445 ok(hr
== prop
.expected
, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1446 hr
, prop
.expected
, i
);
1447 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1448 prop
.value
, wine_dbgstr_w(received
), i
);
1450 SysFreeString(received
);
1453 /* GetRawUri() tests. */
1454 prop
= test
.str_props
[Uri_PROPERTY_RAW_URI
];
1455 hr
= IUri_GetRawUri(uri
, &received
);
1458 ok(hr
== prop
.expected
, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1459 hr
, prop
.expected
, i
);
1462 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1463 prop
.value
, wine_dbgstr_w(received
), i
);
1466 ok(hr
== prop
.expected
, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1467 hr
, prop
.expected
, i
);
1468 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1469 prop
.value
, wine_dbgstr_w(received
), i
);
1471 SysFreeString(received
);
1474 /* GetSchemeName() tests. */
1475 prop
= test
.str_props
[Uri_PROPERTY_SCHEME_NAME
];
1476 hr
= IUri_GetSchemeName(uri
, &received
);
1479 ok(hr
== prop
.expected
, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1480 hr
, prop
.expected
, i
);
1483 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1484 prop
.value
, wine_dbgstr_w(received
), i
);
1487 ok(hr
== prop
.expected
, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1488 hr
, prop
.expected
, i
);
1489 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1490 prop
.value
, wine_dbgstr_w(received
), i
);
1492 SysFreeString(received
);
1495 /* GetUserInfo() tests. */
1496 prop
= test
.str_props
[Uri_PROPERTY_USER_INFO
];
1497 hr
= IUri_GetUserInfo(uri
, &received
);
1500 ok(hr
== prop
.expected
, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1501 hr
, prop
.expected
, i
);
1504 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1505 prop
.value
, wine_dbgstr_w(received
), i
);
1508 ok(hr
== prop
.expected
, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1509 hr
, prop
.expected
, i
);
1510 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1511 prop
.value
, wine_dbgstr_w(received
), i
);
1513 SysFreeString(received
);
1516 /* GetUserName() tests. */
1517 prop
= test
.str_props
[Uri_PROPERTY_USER_NAME
];
1518 hr
= IUri_GetUserName(uri
, &received
);
1521 ok(hr
== prop
.expected
, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1522 hr
, prop
.expected
, i
);
1525 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1526 prop
.value
, wine_dbgstr_w(received
), i
);
1529 ok(hr
== prop
.expected
, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1530 hr
, prop
.expected
, i
);
1531 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1532 prop
.value
, wine_dbgstr_w(received
), i
);
1534 SysFreeString(received
);
1537 if(uri
) IUri_Release(uri
);
1543 static void test_IUri_GetDwordProperties(void) {
1548 /* Make sure all the 'Get*' dword property functions handle invalid args correctly. */
1549 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
1550 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
1552 hr
= IUri_GetHostType(uri
, NULL
);
1553 ok(hr
== E_INVALIDARG
, "Error: GetHostType returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1555 hr
= IUri_GetPort(uri
, NULL
);
1556 ok(hr
== E_INVALIDARG
, "Error: GetPort returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1558 hr
= IUri_GetScheme(uri
, NULL
);
1559 ok(hr
== E_INVALIDARG
, "Error: GetScheme returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1561 hr
= IUri_GetZone(uri
, NULL
);
1562 ok(hr
== E_INVALIDARG
, "Error: GetZone returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1564 if(uri
) IUri_Release(uri
);
1566 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
1567 uri_properties test
= uri_tests
[i
];
1571 uriW
= a2w(test
.uri
);
1572 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
1573 if(test
.create_todo
) {
1575 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1576 hr
, test
.create_expected
, i
);
1579 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1580 hr
, test
.create_expected
, i
);
1584 uri_dword_property prop
;
1587 /* Assign an insane value so tests don't accidentally pass when
1590 received
= -9999999;
1592 /* GetHostType() tests. */
1593 prop
= test
.dword_props
[Uri_PROPERTY_HOST_TYPE
-Uri_PROPERTY_DWORD_START
];
1594 hr
= IUri_GetHostType(uri
, &received
);
1597 ok(hr
== prop
.expected
, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1598 hr
, prop
.expected
, i
);
1601 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1604 ok(hr
== prop
.expected
, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1605 hr
, prop
.expected
, i
);
1606 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1608 received
= -9999999;
1610 /* GetPort() tests. */
1611 prop
= test
.dword_props
[Uri_PROPERTY_PORT
-Uri_PROPERTY_DWORD_START
];
1612 hr
= IUri_GetPort(uri
, &received
);
1615 ok(hr
== prop
.expected
, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1616 hr
, prop
.expected
, i
);
1619 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1622 ok(hr
== prop
.expected
, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1623 hr
, prop
.expected
, i
);
1624 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1626 received
= -9999999;
1628 /* GetScheme() tests. */
1629 prop
= test
.dword_props
[Uri_PROPERTY_SCHEME
-Uri_PROPERTY_DWORD_START
];
1630 hr
= IUri_GetScheme(uri
, &received
);
1633 ok(hr
== prop
.expected
, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1634 hr
, prop
.expected
, i
);
1637 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1640 ok(hr
== prop
.expected
, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1641 hr
, prop
.expected
, i
);
1642 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1644 received
= -9999999;
1646 /* GetZone() tests. */
1647 prop
= test
.dword_props
[Uri_PROPERTY_ZONE
-Uri_PROPERTY_DWORD_START
];
1648 hr
= IUri_GetZone(uri
, &received
);
1651 ok(hr
== prop
.expected
, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1652 hr
, prop
.expected
, i
);
1655 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1658 ok(hr
== prop
.expected
, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1659 hr
, prop
.expected
, i
);
1660 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1664 if(uri
) IUri_Release(uri
);
1670 static void test_IUri_GetPropertyLength(void) {
1675 /* Make sure it handles invalid args correctly. */
1676 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
1677 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
1679 DWORD received
= 0xdeadbeef;
1681 hr
= IUri_GetPropertyLength(uri
, Uri_PROPERTY_STRING_START
, NULL
, 0);
1682 ok(hr
== E_INVALIDARG
, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1684 hr
= IUri_GetPropertyLength(uri
, Uri_PROPERTY_DWORD_START
, &received
, 0);
1685 ok(hr
== E_INVALIDARG
, "Error: GetPropertyLength return 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1686 ok(received
== 0xdeadbeef, "Error: Expected 0xdeadbeef but got 0x%08x.\n", received
);
1688 if(uri
) IUri_Release(uri
);
1690 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
1691 uri_properties test
= uri_tests
[i
];
1695 uriW
= a2w(test
.uri
);
1696 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
1697 if(test
.create_todo
) {
1699 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1700 hr
, test
.create_expected
, i
);
1703 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_test[%d].\n",
1704 hr
, test
.create_expected
, i
);
1710 for(j
= Uri_PROPERTY_STRING_START
; j
<= Uri_PROPERTY_STRING_LAST
; ++j
) {
1711 DWORD expectedLen
, receivedLen
;
1712 uri_str_property prop
= test
.str_props
[j
];
1714 expectedLen
= lstrlen(prop
.value
);
1716 /* This won't be necessary once GetPropertyLength is implemented. */
1719 hr
= IUri_GetPropertyLength(uri
, j
, &receivedLen
, 0);
1722 ok(hr
== prop
.expected
, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
1723 hr
, prop
.expected
, i
, j
);
1726 ok(receivedLen
== expectedLen
, "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
1727 expectedLen
, receivedLen
, i
, j
);
1730 ok(hr
== prop
.expected
, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
1731 hr
, prop
.expected
, i
, j
);
1732 ok(receivedLen
== expectedLen
, "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
1733 expectedLen
, receivedLen
, i
, j
);
1738 if(uri
) IUri_Release(uri
);
1744 static void test_IUri_GetProperties(void) {
1749 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
1750 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
1752 hr
= IUri_GetProperties(uri
, NULL
);
1753 ok(hr
== E_INVALIDARG
, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1755 if(uri
) IUri_Release(uri
);
1757 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
1758 uri_properties test
= uri_tests
[i
];
1762 uriW
= a2w(test
.uri
);
1763 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
1764 if(test
.create_todo
) {
1766 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, test
.create_expected
);
1769 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, test
.create_expected
);
1776 hr
= IUri_GetProperties(uri
, &received
);
1777 if(test
.props_todo
) {
1779 ok(hr
== S_OK
, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
1782 ok(hr
== S_OK
, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
1785 for(j
= 0; j
<= Uri_PROPERTY_DWORD_LAST
; ++j
) {
1786 /* (1 << j) converts a Uri_PROPERTY to its corresponding Uri_HAS_* flag mask. */
1787 if(test
.props
& (1 << j
)) {
1788 if(test
.props_todo
) {
1790 ok(received
& (1 << j
), "Error: Expected flag for property %d on uri_tests[%d].\n", j
, i
);
1793 ok(received
& (1 << j
), "Error: Expected flag for property %d on uri_tests[%d].\n", j
, i
);
1796 /* NOTE: Since received is initialized to 0, this test will always pass while
1797 * GetProperties is unimplemented.
1799 ok(!(received
& (1 << j
)), "Error: Received flag for property %d when not expected on uri_tests[%d].\n", j
, i
);
1804 if(uri
) IUri_Release(uri
);
1810 static void test_IUri_HasProperty(void) {
1815 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
1816 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
1818 hr
= IUri_HasProperty(uri
, Uri_PROPERTY_RAW_URI
, NULL
);
1819 ok(hr
== E_INVALIDARG
, "Error: HasProperty returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1821 if(uri
) IUri_Release(uri
);
1823 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
1824 uri_properties test
= uri_tests
[i
];
1828 uriW
= a2w(test
.uri
);
1830 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
1831 if(test
.create_todo
) {
1833 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, test
.create_expected
);
1836 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, test
.create_expected
);
1842 for(j
= 0; j
<= Uri_PROPERTY_DWORD_LAST
; ++j
) {
1843 /* Assign -1, then explicitly test for TRUE or FALSE later. */
1846 hr
= IUri_HasProperty(uri
, j
, &received
);
1847 if(test
.props_todo
) {
1849 ok(hr
== S_OK
, "Error: HasProperty returned 0x%08x, expected 0x%08x for property %d on uri_tests[%d].\n",
1853 /* Check if the property should be true. */
1854 if(test
.props
& (1 << j
)) {
1856 ok(received
== TRUE
, "Error: Expected to have property %d on uri_tests[%d].\n", j
, i
);
1860 ok(received
== FALSE
, "Error: Wasn't expecting to have property %d on uri_tests[%d].\n", j
, i
);
1864 ok(hr
== S_OK
, "Error: HasProperty returned 0x%08x, expected 0x%08x for property %d on uri_tests[%d].\n",
1867 if(test
.props
& (1 << j
)) {
1868 ok(received
== TRUE
, "Error: Expected to have property %d on uri_tests[%d].\n", j
, i
);
1870 ok(received
== FALSE
, "Error: Wasn't expecting to have property %d on uri_tests[%d].\n", j
, i
);
1876 if(uri
) IUri_Release(uri
);
1882 static void test_IUri_IsEqual(void) {
1889 /* Make sure IsEqual handles invalid args correctly. */
1890 hrA
= pCreateUri(http_urlW
, 0, 0, &uriA
);
1891 hrB
= pCreateUri(http_urlW
, 0, 0, &uriB
);
1892 ok(hrA
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hrA
, S_OK
);
1893 ok(hrB
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hrB
, S_OK
);
1894 if(SUCCEEDED(hrA
) && SUCCEEDED(hrB
)) {
1896 hrA
= IUri_IsEqual(uriA
, NULL
, &equal
);
1897 ok(hrA
== S_OK
, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hrA
, S_OK
);
1898 ok(equal
== FALSE
, "Error: Expected equal to be FALSE, but was %d instead.\n", equal
);
1900 hrA
= IUri_IsEqual(uriA
, uriB
, NULL
);
1901 ok(hrA
== E_POINTER
, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hrA
, E_POINTER
);
1903 if(uriA
) IUri_Release(uriA
);
1904 if(uriB
) IUri_Release(uriB
);
1906 for(i
= 0; i
< sizeof(equality_tests
)/sizeof(equality_tests
[0]); ++i
) {
1907 uri_equality test
= equality_tests
[i
];
1908 LPWSTR uriA_W
, uriB_W
;
1912 uriA_W
= a2w(test
.a
);
1913 uriB_W
= a2w(test
.b
);
1915 hrA
= pCreateUri(uriA_W
, test
.create_flags_a
, 0, &uriA
);
1916 if(test
.create_todo_a
) {
1918 ok(hrA
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n",
1922 ok(hrA
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n",
1926 hrB
= pCreateUri(uriB_W
, test
.create_flags_b
, 0, &uriB
);
1927 if(test
.create_todo_b
) {
1929 ok(hrB
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n",
1933 ok(hrB
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n",
1937 if(SUCCEEDED(hrA
) && SUCCEEDED(hrB
)) {
1940 hrA
= IUri_IsEqual(uriA
, uriB
, &equal
);
1943 ok(hrA
== S_OK
, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n",
1947 ok(equal
== test
.equal
, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test
.equal
, i
);
1950 ok(hrA
== S_OK
, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n", hrA
, S_OK
, i
);
1951 ok(equal
== test
.equal
, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test
.equal
, i
);
1954 if(uriA
) IUri_Release(uriA
);
1955 if(uriB
) IUri_Release(uriB
);
1965 hurlmon
= GetModuleHandle("urlmon.dll");
1966 pCreateUri
= (void*) GetProcAddress(hurlmon
, "CreateUri");
1969 win_skip("CreateUri is not present, skipping tests.\n");
1973 trace("test CreateUri invalid flags...\n");
1974 test_CreateUri_InvalidFlags();
1976 trace("test CreateUri invalid args...\n");
1977 test_CreateUri_InvalidArgs();
1979 trace("test IUri_GetPropertyBSTR...\n");
1980 test_IUri_GetPropertyBSTR();
1982 trace("test IUri_GetPropertyDWORD...\n");
1983 test_IUri_GetPropertyDWORD();
1985 trace("test IUri_GetStrProperties...\n");
1986 test_IUri_GetStrProperties();
1988 trace("test IUri_GetDwordProperties...\n");
1989 test_IUri_GetDwordProperties();
1991 trace("test IUri_GetPropertyLength...\n");
1992 test_IUri_GetPropertyLength();
1994 trace("test IUri_GetProperties...\n");
1995 test_IUri_GetProperties();
1997 trace("test IUri_HasProperty...\n");
1998 test_IUri_HasProperty();
2000 trace("test IUri_IsEqual...\n");
2001 test_IUri_IsEqual();