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
;
82 uri_str_property str_props
[URI_STR_PROPERTY_COUNT
];
83 uri_dword_property dword_props
[URI_DWORD_PROPERTY_COUNT
];
86 static const uri_properties uri_tests
[] = {
87 { "http://www.winehq.org/tests/../tests/../..", 0, S_OK
, FALSE
,
89 {"http://www.winehq.org/",S_OK
,TRUE
}, /* ABSOLUTE_URI */
90 {"www.winehq.org",S_OK
,TRUE
}, /* AUTHORITY */
91 {"http://www.winehq.org/",S_OK
,TRUE
}, /* DISPLAY_URI */
92 {"winehq.org",S_OK
,TRUE
}, /* DOMAIN */
93 {"",S_FALSE
,TRUE
}, /* EXTENSION */
94 {"",S_FALSE
,TRUE
}, /* FRAGMENT */
95 {"www.winehq.org",S_OK
,TRUE
}, /* HOST */
96 {"",S_FALSE
,TRUE
}, /* PASSWORD */
97 {"/",S_OK
,TRUE
}, /* PATH */
98 {"/",S_OK
,TRUE
}, /* PATH_AND_QUERY */
99 {"",S_FALSE
,TRUE
}, /* QUERY */
100 {"http://www.winehq.org/tests/../tests/../..",S_OK
,TRUE
}, /* RAW_URI */
101 {"http",S_OK
,TRUE
}, /* SCHEME_NAME */
102 {"",S_FALSE
,TRUE
}, /* USER_INFO */
103 {"",S_FALSE
,TRUE
} /* USER_NAME */
106 {Uri_HOST_DNS
,S_OK
,TRUE
}, /* HOST_TYPE */
107 {80,S_OK
,TRUE
}, /* PORT */
108 {URL_SCHEME_HTTP
,S_OK
,TRUE
}, /* SCHEME */
109 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
} /* ZONE */
112 { "http://winehq.org/tests/.././tests", 0, S_OK
, FALSE
,
114 {"http://winehq.org/tests",S_OK
,TRUE
},
115 {"winehq.org",S_OK
,TRUE
},
116 {"http://winehq.org/tests",S_OK
,TRUE
},
117 {"winehq.org",S_OK
,TRUE
},
120 {"winehq.org",S_OK
,TRUE
},
122 {"/tests",S_OK
,TRUE
},
123 {"/tests",S_OK
,TRUE
},
125 {"http://winehq.org/tests/.././tests",S_OK
,TRUE
},
131 {Uri_HOST_DNS
,S_OK
,TRUE
},
133 {URL_SCHEME_HTTP
,S_OK
,TRUE
},
134 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
137 { "HtTp://www.winehq.org/tests/..?query=x&return=y", 0, S_OK
, FALSE
,
139 {"http://www.winehq.org/?query=x&return=y",S_OK
,TRUE
},
140 {"www.winehq.org",S_OK
,TRUE
},
141 {"http://www.winehq.org/?query=x&return=y",S_OK
,TRUE
},
142 {"winehq.org",S_OK
,TRUE
},
145 {"www.winehq.org",S_OK
,TRUE
},
148 {"/?query=x&return=y",S_OK
,TRUE
},
149 {"?query=x&return=y",S_OK
,TRUE
},
150 {"HtTp://www.winehq.org/tests/..?query=x&return=y",S_OK
,TRUE
},
156 {Uri_HOST_DNS
,S_OK
,TRUE
},
158 {URL_SCHEME_HTTP
,S_OK
,TRUE
},
159 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
},
162 { "hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters", 0, S_OK
, FALSE
,
164 {"http://usEr%3Ainfo@example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK
,TRUE
},
165 {"usEr%3Ainfo@example.com",S_OK
,TRUE
},
166 {"http://example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK
,TRUE
},
167 {"example.com",S_OK
,TRUE
},
170 {"example.com",S_OK
,TRUE
},
172 {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK
,TRUE
},
173 {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK
,TRUE
},
175 {"hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters",S_OK
,TRUE
},
177 {"usEr%3Ainfo",S_OK
,TRUE
},
178 {"usEr%3Ainfo",S_OK
,TRUE
}
181 {Uri_HOST_DNS
,S_OK
,TRUE
},
183 {URL_SCHEME_HTTP
,S_OK
,TRUE
},
184 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
},
187 { "ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt", 0, S_OK
, FALSE
,
189 {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK
,TRUE
},
190 {"winepass:wine@ftp.winehq.org:9999",S_OK
,TRUE
},
191 {"ftp://ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK
,TRUE
},
192 {"winehq.org",S_OK
,TRUE
},
195 {"ftp.winehq.org",S_OK
,TRUE
},
197 {"/dir/foo%20bar.txt",S_OK
,TRUE
},
198 {"/dir/foo%20bar.txt",S_OK
,TRUE
},
200 {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt",S_OK
,TRUE
},
202 {"winepass:wine",S_OK
,TRUE
},
203 {"winepass",S_OK
,TRUE
}
206 {Uri_HOST_DNS
,S_OK
,TRUE
},
208 {URL_SCHEME_FTP
,S_OK
,TRUE
},
209 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
212 { "file://c:\\tests\\../tests/foo%20bar.mp3", 0, S_OK
, FALSE
,
214 {"file:///c:/tests/foo%2520bar.mp3",S_OK
,TRUE
},
216 {"file:///c:/tests/foo%2520bar.mp3",S_OK
,TRUE
},
222 {"/c:/tests/foo%2520bar.mp3",S_OK
,TRUE
},
223 {"/c:/tests/foo%2520bar.mp3",S_OK
,TRUE
},
225 {"file://c:\\tests\\../tests/foo%20bar.mp3",S_OK
,TRUE
},
231 {Uri_HOST_UNKNOWN
,S_OK
,TRUE
},
233 {URL_SCHEME_FILE
,S_OK
,TRUE
},
234 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
237 { "FILE://localhost/test dir\\../tests/test%20file.README.txt", 0, S_OK
, FALSE
,
239 {"file:///tests/test%20file.README.txt",S_OK
,TRUE
},
241 {"file:///tests/test%20file.README.txt",S_OK
,TRUE
},
247 {"/tests/test%20file.README.txt",S_OK
,TRUE
},
248 {"/tests/test%20file.README.txt",S_OK
,TRUE
},
250 {"FILE://localhost/test dir\\../tests/test%20file.README.txt",S_OK
,TRUE
},
256 {Uri_HOST_UNKNOWN
,S_OK
,TRUE
},
258 {URL_SCHEME_FILE
,S_OK
,TRUE
},
259 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
262 { "urn:nothing:should:happen here", 0, S_OK
, FALSE
,
264 {"urn:nothing:should:happen here",S_OK
,TRUE
},
266 {"urn:nothing:should:happen here",S_OK
,TRUE
},
272 {"nothing:should:happen here",S_OK
,TRUE
},
273 {"nothing:should:happen here",S_OK
,TRUE
},
275 {"urn:nothing:should:happen here",S_OK
,TRUE
},
281 {Uri_HOST_UNKNOWN
,S_OK
,TRUE
},
283 {URL_SCHEME_UNKNOWN
,S_OK
,TRUE
},
284 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
287 { "http://127.0.0.1/tests/../test dir/./test.txt", 0, S_OK
, FALSE
,
289 {"http://127.0.0.1/test%20dir/test.txt",S_OK
,TRUE
},
290 {"127.0.0.1",S_OK
,TRUE
},
291 {"http://127.0.0.1/test%20dir/test.txt",S_OK
,TRUE
},
295 {"127.0.0.1",S_OK
,TRUE
},
297 {"/test%20dir/test.txt",S_OK
,TRUE
},
298 {"/test%20dir/test.txt",S_OK
,TRUE
},
300 {"http://127.0.0.1/tests/../test dir/./test.txt",S_OK
,TRUE
},
306 {Uri_HOST_IPV4
,S_OK
,TRUE
},
308 {URL_SCHEME_HTTP
,S_OK
,TRUE
},
309 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
312 { "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", 0, S_OK
, FALSE
,
314 {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK
,TRUE
},
315 {"[fedc:ba98:7654:3210:fedc:ba98:7654:3210]",S_OK
,TRUE
},
316 {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK
,TRUE
},
320 {"fedc:ba98:7654:3210:fedc:ba98:7654:3210",S_OK
,TRUE
},
325 {"http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]",S_OK
,TRUE
},
331 {Uri_HOST_IPV6
,S_OK
,TRUE
},
333 {URL_SCHEME_HTTP
,S_OK
,TRUE
},
334 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
337 { "ftp://[::13.1.68.3]", 0, S_OK
, FALSE
,
339 {"ftp://[::13.1.68.3]/",S_OK
,TRUE
},
340 {"[::13.1.68.3]",S_OK
,TRUE
},
341 {"ftp://[::13.1.68.3]/",S_OK
,TRUE
},
345 {"::13.1.68.3",S_OK
,TRUE
},
350 {"ftp://[::13.1.68.3]",S_OK
,TRUE
},
356 {Uri_HOST_IPV6
,S_OK
,TRUE
},
358 {URL_SCHEME_FTP
,S_OK
,TRUE
},
359 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
362 { "http://[FEDC:BA98:0:0:0:0:0:3210]", 0, S_OK
, FALSE
,
364 {"http://[fedc:ba98::3210]/",S_OK
,TRUE
},
365 {"[fedc:ba98::3210]",S_OK
,TRUE
},
366 {"http://[fedc:ba98::3210]/",S_OK
,TRUE
},
370 {"fedc:ba98::3210",S_OK
,TRUE
},
375 {"http://[FEDC:BA98:0:0:0:0:0:3210]",S_OK
,TRUE
},
381 {Uri_HOST_IPV6
,S_OK
,TRUE
},
383 {URL_SCHEME_HTTP
,S_OK
,TRUE
},
384 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
389 static inline LPWSTR
a2w(LPCSTR str
) {
393 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
394 ret
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
395 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
401 static inline BOOL
heap_free(void* mem
) {
402 return HeapFree(GetProcessHeap(), 0, mem
);
405 static inline DWORD
strcmp_aw(LPCSTR strA
, LPCWSTR strB
) {
406 LPWSTR strAW
= a2w(strA
);
407 DWORD ret
= lstrcmpW(strAW
, strB
);
413 * Simple tests to make sure the CreateUri function handles invalid flag combinations
416 static void test_CreateUri_InvalidFlags(void) {
419 for(i
= 0; i
< sizeof(invalid_flag_tests
)/sizeof(invalid_flag_tests
[0]); ++i
) {
421 IUri
*uri
= (void*) 0xdeadbeef;
423 hr
= pCreateUri(http_urlW
, invalid_flag_tests
[i
].flags
, 0, &uri
);
425 ok(hr
== invalid_flag_tests
[i
].expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x, flags=0x%08x\n",
426 hr
, invalid_flag_tests
[i
].expected
, invalid_flag_tests
[i
].flags
);
428 todo_wine
{ ok(uri
== NULL
, "Error: expected the IUri to be NULL, but it was %p instead\n", uri
); }
432 static void test_CreateUri_InvalidArgs(void) {
434 IUri
*uri
= (void*) 0xdeadbeef;
436 hr
= pCreateUri(http_urlW
, 0, 0, NULL
);
437 ok(hr
== E_INVALIDARG
, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr
, E_INVALIDARG
);
439 hr
= pCreateUri(NULL
, 0, 0, &uri
);
440 ok(hr
== E_INVALIDARG
, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr
, E_INVALIDARG
);
441 ok(uri
== NULL
, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri
);
444 static void test_IUri_GetPropertyBSTR(void) {
447 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
448 uri_properties test
= uri_tests
[i
];
453 uriW
= a2w(test
.uri
);
454 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
455 if(test
.create_todo
) {
457 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
458 hr
, test
.create_expected
, i
);
461 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
462 hr
, test
.create_expected
, i
);
468 /* Checks all the string properties of the uri. */
469 for(j
= Uri_PROPERTY_STRING_START
; j
<= Uri_PROPERTY_STRING_LAST
; ++j
) {
470 BSTR received
= NULL
;
471 uri_str_property prop
= test
.str_props
[j
];
473 hr
= IUri_GetPropertyBSTR(uri
, j
, &received
, 0);
476 ok(hr
== prop
.expected
, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
477 hr
, prop
.expected
, i
, j
);
480 ok(!strcmp_aw(prop
.value
, received
), "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
481 prop
.value
, wine_dbgstr_w(received
), i
, j
);
484 ok(hr
== prop
.expected
, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
485 hr
, prop
.expected
, i
, j
);
486 ok(!strcmp_aw(prop
.value
, received
), "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
487 prop
.value
, wine_dbgstr_w(received
), i
, j
);
490 SysFreeString(received
);
494 if(uri
) IUri_Release(uri
);
500 static void test_IUri_GetPropertyDWORD(void) {
505 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
506 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
508 hr
= IUri_GetPropertyDWORD(uri
, Uri_PROPERTY_DWORD_START
, NULL
, 0);
509 ok(hr
== E_INVALIDARG
, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
511 if(uri
) IUri_Release(uri
);
513 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
514 uri_properties test
= uri_tests
[i
];
518 uriW
= a2w(test
.uri
);
519 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
520 if(test
.create_todo
) {
522 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
523 hr
, test
.create_expected
, i
);
526 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
527 hr
, test
.create_expected
, i
);
533 /* Checks all the DWORD properties of the uri. */
534 for(j
= 0; j
< sizeof(test
.dword_props
)/sizeof(test
.dword_props
[0]); ++j
) {
536 uri_dword_property prop
= test
.dword_props
[j
];
538 hr
= IUri_GetPropertyDWORD(uri
, j
+Uri_PROPERTY_DWORD_START
, &received
, 0);
541 ok(hr
== prop
.expected
, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
542 hr
, prop
.expected
, i
, j
);
545 ok(prop
.value
== received
, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
546 prop
.value
, received
, i
, j
);
549 ok(hr
== prop
.expected
, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
550 hr
, prop
.expected
, i
, j
);
551 ok(prop
.value
== received
, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
552 prop
.value
, received
, i
, j
);
557 if(uri
) IUri_Release(uri
);
563 /* Tests all the 'Get*' property functions which deal with strings. */
564 static void test_IUri_GetStrProperties(void) {
569 /* Make sure all the 'Get*' string property functions handle invalid args correctly. */
570 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
571 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
573 hr
= IUri_GetAbsoluteUri(uri
, NULL
);
574 ok(hr
== E_POINTER
, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
576 hr
= IUri_GetAuthority(uri
, NULL
);
577 ok(hr
== E_POINTER
, "Error: GetAuthority returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
579 hr
= IUri_GetDisplayUri(uri
, NULL
);
580 ok(hr
== E_POINTER
, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
582 hr
= IUri_GetDomain(uri
, NULL
);
583 ok(hr
== E_POINTER
, "Error: GetDomain returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
585 hr
= IUri_GetExtension(uri
, NULL
);
586 ok(hr
== E_POINTER
, "Error: GetExtension returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
588 hr
= IUri_GetFragment(uri
, NULL
);
589 ok(hr
== E_POINTER
, "Error: GetFragment returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
591 hr
= IUri_GetPassword(uri
, NULL
);
592 ok(hr
== E_POINTER
, "Error: GetPassword returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
594 hr
= IUri_GetPath(uri
, NULL
);
595 ok(hr
== E_POINTER
, "Error: GetPath returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
597 hr
= IUri_GetPathAndQuery(uri
, NULL
);
598 ok(hr
== E_POINTER
, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
600 hr
= IUri_GetQuery(uri
, NULL
);
601 ok(hr
== E_POINTER
, "Error: GetQuery returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
603 hr
= IUri_GetRawUri(uri
, NULL
);
604 ok(hr
== E_POINTER
, "Error: GetRawUri returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
606 hr
= IUri_GetSchemeName(uri
, NULL
);
607 ok(hr
== E_POINTER
, "Error: GetSchemeName returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
609 hr
= IUri_GetUserInfo(uri
, NULL
);
610 ok(hr
== E_POINTER
, "Error: GetUserInfo returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
612 hr
= IUri_GetUserName(uri
, NULL
);
613 ok(hr
== E_POINTER
, "Error: GetUserName returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
615 if(uri
) IUri_Release(uri
);
617 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
618 uri_properties test
= uri_tests
[i
];
622 uriW
= a2w(test
.uri
);
623 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
624 if(test
.create_todo
) {
626 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
627 hr
, test
.create_expected
, i
);
630 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
631 hr
, test
.create_expected
, i
);
635 uri_str_property prop
;
636 BSTR received
= NULL
;
638 /* GetAbsoluteUri() tests. */
639 prop
= test
.str_props
[Uri_PROPERTY_ABSOLUTE_URI
];
640 hr
= IUri_GetAbsoluteUri(uri
, &received
);
643 ok(hr
== prop
.expected
, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
644 hr
, prop
.expected
, i
);
647 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
648 prop
.value
, wine_dbgstr_w(received
), i
);
651 ok(hr
== prop
.expected
, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
652 hr
, prop
.expected
, i
);
653 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
654 prop
.value
, wine_dbgstr_w(received
), i
);
656 SysFreeString(received
);
659 /* GetAuthority() tests. */
660 prop
= test
.str_props
[Uri_PROPERTY_AUTHORITY
];
661 hr
= IUri_GetAuthority(uri
, &received
);
664 ok(hr
== prop
.expected
, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
665 hr
, prop
.expected
, i
);
668 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
669 prop
.value
, wine_dbgstr_w(received
), i
);
672 ok(hr
== prop
.expected
, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
673 hr
, prop
.expected
, i
);
674 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
675 prop
.value
, wine_dbgstr_w(received
), i
);
677 SysFreeString(received
);
680 /* GetDisplayUri() tests. */
681 prop
= test
.str_props
[Uri_PROPERTY_DISPLAY_URI
];
682 hr
= IUri_GetDisplayUri(uri
, &received
);
685 ok(hr
== prop
.expected
, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
686 hr
, prop
.expected
, i
);
689 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_test[%d].\n",
690 prop
.value
, wine_dbgstr_w(received
), i
);
693 ok(hr
== prop
.expected
, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
694 hr
, prop
.expected
, i
);
695 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
696 prop
.value
, wine_dbgstr_w(received
), i
);
698 SysFreeString(received
);
701 /* GetDomain() tests. */
702 prop
= test
.str_props
[Uri_PROPERTY_DOMAIN
];
703 hr
= IUri_GetDomain(uri
, &received
);
706 ok(hr
== prop
.expected
, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
707 hr
, prop
.expected
, i
);
710 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
711 prop
.value
, wine_dbgstr_w(received
), i
);
714 ok(hr
== prop
.expected
, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
715 hr
, prop
.expected
, i
);
716 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
717 prop
.value
, wine_dbgstr_w(received
), i
);
719 SysFreeString(received
);
722 /* GetExtension() tests. */
723 prop
= test
.str_props
[Uri_PROPERTY_EXTENSION
];
724 hr
= IUri_GetExtension(uri
, &received
);
727 ok(hr
== prop
.expected
, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
728 hr
, prop
.expected
, i
);
731 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
732 prop
.value
, wine_dbgstr_w(received
), i
);
735 ok(hr
== prop
.expected
, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
736 hr
, prop
.expected
, i
);
737 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
738 prop
.value
, wine_dbgstr_w(received
), i
);
740 SysFreeString(received
);
743 /* GetFragment() tests. */
744 prop
= test
.str_props
[Uri_PROPERTY_FRAGMENT
];
745 hr
= IUri_GetFragment(uri
, &received
);
748 ok(hr
== prop
.expected
, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
749 hr
, prop
.expected
, i
);
752 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
753 prop
.value
, wine_dbgstr_w(received
), i
);
756 ok(hr
== prop
.expected
, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
757 hr
, prop
.expected
, i
);
758 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
759 prop
.value
, wine_dbgstr_w(received
), i
);
761 SysFreeString(received
);
764 /* GetPassword() tests. */
765 prop
= test
.str_props
[Uri_PROPERTY_PASSWORD
];
766 hr
= IUri_GetPassword(uri
, &received
);
769 ok(hr
== prop
.expected
, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
770 hr
, prop
.expected
, i
);
773 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
774 prop
.value
, wine_dbgstr_w(received
), i
);
777 ok(hr
== prop
.expected
, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
778 hr
, prop
.expected
, i
);
779 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
780 prop
.value
, wine_dbgstr_w(received
), i
);
782 SysFreeString(received
);
785 /* GetPath() tests. */
786 prop
= test
.str_props
[Uri_PROPERTY_PATH
];
787 hr
= IUri_GetPath(uri
, &received
);
790 ok(hr
== prop
.expected
, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
791 hr
, prop
.expected
, i
);
794 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
795 prop
.value
, wine_dbgstr_w(received
), i
);
798 ok(hr
== prop
.expected
, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
799 hr
, prop
.expected
, i
);
800 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
801 prop
.value
, wine_dbgstr_w(received
), i
);
803 SysFreeString(received
);
806 /* GetPathAndQuery() tests. */
807 prop
= test
.str_props
[Uri_PROPERTY_PATH_AND_QUERY
];
808 hr
= IUri_GetPathAndQuery(uri
, &received
);
811 ok(hr
== prop
.expected
, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
812 hr
, prop
.expected
, i
);
815 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
816 prop
.value
, wine_dbgstr_w(received
), i
);
819 ok(hr
== prop
.expected
, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
820 hr
, prop
.expected
, i
);
821 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
822 prop
.value
, wine_dbgstr_w(received
), i
);
824 SysFreeString(received
);
827 /* GetQuery() tests. */
828 prop
= test
.str_props
[Uri_PROPERTY_QUERY
];
829 hr
= IUri_GetQuery(uri
, &received
);
832 ok(hr
== prop
.expected
, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
833 hr
, prop
.expected
, i
);
836 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
837 prop
.value
, wine_dbgstr_w(received
), i
);
840 ok(hr
== prop
.expected
, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
841 hr
, prop
.expected
, i
);
842 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
843 prop
.value
, wine_dbgstr_w(received
), i
);
845 SysFreeString(received
);
848 /* GetRawUri() tests. */
849 prop
= test
.str_props
[Uri_PROPERTY_RAW_URI
];
850 hr
= IUri_GetRawUri(uri
, &received
);
853 ok(hr
== prop
.expected
, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
854 hr
, prop
.expected
, i
);
857 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
858 prop
.value
, wine_dbgstr_w(received
), i
);
861 ok(hr
== prop
.expected
, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
862 hr
, prop
.expected
, i
);
863 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
864 prop
.value
, wine_dbgstr_w(received
), i
);
866 SysFreeString(received
);
869 /* GetSchemeName() tests. */
870 prop
= test
.str_props
[Uri_PROPERTY_SCHEME_NAME
];
871 hr
= IUri_GetSchemeName(uri
, &received
);
874 ok(hr
== prop
.expected
, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
875 hr
, prop
.expected
, i
);
878 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
879 prop
.value
, wine_dbgstr_w(received
), i
);
882 ok(hr
== prop
.expected
, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
883 hr
, prop
.expected
, i
);
884 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
885 prop
.value
, wine_dbgstr_w(received
), i
);
887 SysFreeString(received
);
890 /* GetUserInfo() tests. */
891 prop
= test
.str_props
[Uri_PROPERTY_USER_INFO
];
892 hr
= IUri_GetUserInfo(uri
, &received
);
895 ok(hr
== prop
.expected
, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
896 hr
, prop
.expected
, i
);
899 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
900 prop
.value
, wine_dbgstr_w(received
), i
);
903 ok(hr
== prop
.expected
, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
904 hr
, prop
.expected
, i
);
905 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
906 prop
.value
, wine_dbgstr_w(received
), i
);
908 SysFreeString(received
);
911 /* GetUserName() tests. */
912 prop
= test
.str_props
[Uri_PROPERTY_USER_NAME
];
913 hr
= IUri_GetUserName(uri
, &received
);
916 ok(hr
== prop
.expected
, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
917 hr
, prop
.expected
, i
);
920 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
921 prop
.value
, wine_dbgstr_w(received
), i
);
924 ok(hr
== prop
.expected
, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
925 hr
, prop
.expected
, i
);
926 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
927 prop
.value
, wine_dbgstr_w(received
), i
);
929 SysFreeString(received
);
932 if(uri
) IUri_Release(uri
);
938 static void test_IUri_GetDwordProperties(void) {
943 /* Make sure all the 'Get*' dword property functions handle invalid args correctly. */
944 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
945 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
947 hr
= IUri_GetHostType(uri
, NULL
);
948 ok(hr
== E_INVALIDARG
, "Error: GetHostType returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
950 hr
= IUri_GetPort(uri
, NULL
);
951 ok(hr
== E_INVALIDARG
, "Error: GetPort returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
953 hr
= IUri_GetScheme(uri
, NULL
);
954 ok(hr
== E_INVALIDARG
, "Error: GetScheme returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
956 hr
= IUri_GetZone(uri
, NULL
);
957 ok(hr
== E_INVALIDARG
, "Error: GetZone returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
959 if(uri
) IUri_Release(uri
);
961 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
962 uri_properties test
= uri_tests
[i
];
966 uriW
= a2w(test
.uri
);
967 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
968 if(test
.create_todo
) {
970 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
971 hr
, test
.create_expected
, i
);
974 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
975 hr
, test
.create_expected
, i
);
979 uri_dword_property prop
;
982 /* Assign an insane value so tests don't accidentally pass when
987 /* GetHostType() tests. */
988 prop
= test
.dword_props
[Uri_PROPERTY_HOST_TYPE
-Uri_PROPERTY_DWORD_START
];
989 hr
= IUri_GetHostType(uri
, &received
);
992 ok(hr
== prop
.expected
, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
993 hr
, prop
.expected
, i
);
996 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
999 ok(hr
== prop
.expected
, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1000 hr
, prop
.expected
, i
);
1001 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1003 received
= -9999999;
1005 /* GetPort() tests. */
1006 prop
= test
.dword_props
[Uri_PROPERTY_PORT
-Uri_PROPERTY_DWORD_START
];
1007 hr
= IUri_GetPort(uri
, &received
);
1010 ok(hr
== prop
.expected
, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1011 hr
, prop
.expected
, i
);
1014 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1017 ok(hr
== prop
.expected
, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1018 hr
, prop
.expected
, i
);
1019 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1021 received
= -9999999;
1023 /* GetScheme() tests. */
1024 prop
= test
.dword_props
[Uri_PROPERTY_SCHEME
-Uri_PROPERTY_DWORD_START
];
1025 hr
= IUri_GetScheme(uri
, &received
);
1028 ok(hr
== prop
.expected
, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1029 hr
, prop
.expected
, i
);
1032 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1035 ok(hr
== prop
.expected
, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1036 hr
, prop
.expected
, i
);
1037 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1039 received
= -9999999;
1041 /* GetZone() tests. */
1042 prop
= test
.dword_props
[Uri_PROPERTY_ZONE
-Uri_PROPERTY_DWORD_START
];
1043 hr
= IUri_GetZone(uri
, &received
);
1046 ok(hr
== prop
.expected
, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1047 hr
, prop
.expected
, i
);
1050 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1053 ok(hr
== prop
.expected
, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1054 hr
, prop
.expected
, i
);
1055 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1059 if(uri
) IUri_Release(uri
);
1068 hurlmon
= GetModuleHandle("urlmon.dll");
1069 pCreateUri
= (void*) GetProcAddress(hurlmon
, "CreateUri");
1072 win_skip("CreateUri is not present, skipping tests.\n");
1076 trace("test CreateUri invalid flags...\n");
1077 test_CreateUri_InvalidFlags();
1079 trace("test CreateUri invalid args...\n");
1080 test_CreateUri_InvalidArgs();
1082 trace("test IUri_GetPropertyBSTR...\n");
1083 test_IUri_GetPropertyBSTR();
1085 trace("test IUri_GetPropertyDWORD...\n");
1086 test_IUri_GetPropertyDWORD();
1088 trace("test IUri_GetStrProperties...\n");
1089 test_IUri_GetStrProperties();
1091 trace("test IUri_GetDwordProperties...\n");
1092 test_IUri_GetDwordProperties();