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
,TRUE
}, /* RAW_URI */
108 {"http",S_OK
,TRUE
}, /* 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
,TRUE
}, /* 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
,TRUE
},
142 {Uri_HOST_DNS
,S_OK
,TRUE
},
144 {URL_SCHEME_HTTP
,S_OK
,TRUE
},
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
,TRUE
},
171 {Uri_HOST_DNS
,S_OK
,TRUE
},
173 {URL_SCHEME_HTTP
,S_OK
,TRUE
},
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
,TRUE
},
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
,TRUE
},
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
,TRUE
},
226 {"winepass:wine",S_OK
,TRUE
},
227 {"winepass",S_OK
,TRUE
}
230 {Uri_HOST_DNS
,S_OK
,TRUE
},
232 {URL_SCHEME_FTP
,S_OK
,TRUE
},
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
,TRUE
},
258 {Uri_HOST_UNKNOWN
,S_OK
,TRUE
},
260 {URL_SCHEME_FILE
,S_OK
,TRUE
},
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
,TRUE
},
286 {Uri_HOST_UNKNOWN
,S_OK
,TRUE
},
288 {URL_SCHEME_FILE
,S_OK
,TRUE
},
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
,TRUE
},
314 {Uri_HOST_UNKNOWN
,S_OK
,TRUE
},
316 {URL_SCHEME_UNKNOWN
,S_OK
,TRUE
},
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
,TRUE
},
343 {Uri_HOST_IPV4
,S_OK
,TRUE
},
345 {URL_SCHEME_HTTP
,S_OK
,TRUE
},
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
,TRUE
},
372 {Uri_HOST_IPV6
,S_OK
,TRUE
},
374 {URL_SCHEME_HTTP
,S_OK
,TRUE
},
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
,TRUE
},
401 {Uri_HOST_IPV6
,S_OK
,TRUE
},
403 {URL_SCHEME_FTP
,S_OK
,TRUE
},
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
,TRUE
},
430 {Uri_HOST_IPV6
,S_OK
,TRUE
},
432 {URL_SCHEME_HTTP
,S_OK
,TRUE
},
433 {URLZONE_INVALID
,E_NOTIMPL
,FALSE
}
438 static inline LPWSTR
a2w(LPCSTR str
) {
442 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
443 ret
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
444 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
450 static inline BOOL
heap_free(void* mem
) {
451 return HeapFree(GetProcessHeap(), 0, mem
);
454 static inline DWORD
strcmp_aw(LPCSTR strA
, LPCWSTR strB
) {
455 LPWSTR strAW
= a2w(strA
);
456 DWORD ret
= lstrcmpW(strAW
, strB
);
462 * Simple tests to make sure the CreateUri function handles invalid flag combinations
465 static void test_CreateUri_InvalidFlags(void) {
468 for(i
= 0; i
< sizeof(invalid_flag_tests
)/sizeof(invalid_flag_tests
[0]); ++i
) {
470 IUri
*uri
= (void*) 0xdeadbeef;
472 hr
= pCreateUri(http_urlW
, invalid_flag_tests
[i
].flags
, 0, &uri
);
474 ok(hr
== invalid_flag_tests
[i
].expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x, flags=0x%08x\n",
475 hr
, invalid_flag_tests
[i
].expected
, invalid_flag_tests
[i
].flags
);
477 todo_wine
{ ok(uri
== NULL
, "Error: expected the IUri to be NULL, but it was %p instead\n", uri
); }
481 static void test_CreateUri_InvalidArgs(void) {
483 IUri
*uri
= (void*) 0xdeadbeef;
485 hr
= pCreateUri(http_urlW
, 0, 0, NULL
);
486 ok(hr
== E_INVALIDARG
, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr
, E_INVALIDARG
);
488 hr
= pCreateUri(NULL
, 0, 0, &uri
);
489 ok(hr
== E_INVALIDARG
, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr
, E_INVALIDARG
);
490 ok(uri
== NULL
, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri
);
493 static void test_IUri_GetPropertyBSTR(void) {
498 /* Make sure GetPropertyBSTR handles invalid args correctly. */
499 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
500 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
502 BSTR received
= NULL
;
504 hr
= IUri_GetPropertyBSTR(uri
, Uri_PROPERTY_RAW_URI
, NULL
, 0);
505 ok(hr
== E_POINTER
, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
507 /* Make sure it handles a invalid Uri_PROPERTY's correctly. */
508 hr
= IUri_GetPropertyBSTR(uri
, Uri_PROPERTY_PORT
, &received
, 0);
509 ok(hr
== S_OK
, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
510 ok(received
!= NULL
, "Error: Expected the string not to be NULL.\n");
511 ok(!SysStringLen(received
), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received
));
512 SysFreeString(received
);
514 /* Make sure it handles the ZONE property correctly. */
516 hr
= IUri_GetPropertyBSTR(uri
, Uri_PROPERTY_ZONE
, &received
, 0);
517 ok(hr
== S_FALSE
, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr
, S_FALSE
);
518 ok(received
!= NULL
, "Error: Expected the string not to be NULL.\n");
519 ok(!SysStringLen(received
), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received
));
520 SysFreeString(received
);
522 if(uri
) IUri_Release(uri
);
524 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
525 uri_properties test
= uri_tests
[i
];
529 uriW
= a2w(test
.uri
);
530 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
531 if(test
.create_todo
) {
533 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
534 hr
, test
.create_expected
, i
);
537 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
538 hr
, test
.create_expected
, i
);
544 /* Checks all the string properties of the uri. */
545 for(j
= Uri_PROPERTY_STRING_START
; j
<= Uri_PROPERTY_STRING_LAST
; ++j
) {
546 BSTR received
= NULL
;
547 uri_str_property prop
= test
.str_props
[j
];
549 hr
= IUri_GetPropertyBSTR(uri
, j
, &received
, 0);
552 ok(hr
== prop
.expected
, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
553 hr
, prop
.expected
, i
, j
);
556 ok(!strcmp_aw(prop
.value
, received
), "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
557 prop
.value
, wine_dbgstr_w(received
), i
, j
);
560 ok(hr
== prop
.expected
, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
561 hr
, prop
.expected
, i
, j
);
562 ok(!strcmp_aw(prop
.value
, received
), "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
563 prop
.value
, wine_dbgstr_w(received
), i
, j
);
566 SysFreeString(received
);
570 if(uri
) IUri_Release(uri
);
576 static void test_IUri_GetPropertyDWORD(void) {
581 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
582 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
584 DWORD received
= 0xdeadbeef;
586 hr
= IUri_GetPropertyDWORD(uri
, Uri_PROPERTY_DWORD_START
, NULL
, 0);
587 ok(hr
== E_INVALIDARG
, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
589 hr
= IUri_GetPropertyDWORD(uri
, Uri_PROPERTY_ABSOLUTE_URI
, &received
, 0);
590 ok(hr
== E_INVALIDARG
, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
591 ok(received
== 0, "Error: Expected received=%d but instead received=%d.\n", 0, received
);
593 if(uri
) IUri_Release(uri
);
595 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
596 uri_properties test
= uri_tests
[i
];
600 uriW
= a2w(test
.uri
);
601 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
602 if(test
.create_todo
) {
604 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
605 hr
, test
.create_expected
, i
);
608 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
609 hr
, test
.create_expected
, i
);
615 /* Checks all the DWORD properties of the uri. */
616 for(j
= 0; j
< sizeof(test
.dword_props
)/sizeof(test
.dword_props
[0]); ++j
) {
618 uri_dword_property prop
= test
.dword_props
[j
];
620 hr
= IUri_GetPropertyDWORD(uri
, j
+Uri_PROPERTY_DWORD_START
, &received
, 0);
623 ok(hr
== prop
.expected
, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
624 hr
, prop
.expected
, i
, j
);
627 ok(prop
.value
== received
, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
628 prop
.value
, received
, i
, j
);
631 ok(hr
== prop
.expected
, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
632 hr
, prop
.expected
, i
, j
);
633 ok(prop
.value
== received
, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
634 prop
.value
, received
, i
, j
);
639 if(uri
) IUri_Release(uri
);
645 /* Tests all the 'Get*' property functions which deal with strings. */
646 static void test_IUri_GetStrProperties(void) {
651 /* Make sure all the 'Get*' string property functions handle invalid args correctly. */
652 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
653 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
655 hr
= IUri_GetAbsoluteUri(uri
, NULL
);
656 ok(hr
== E_POINTER
, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
658 hr
= IUri_GetAuthority(uri
, NULL
);
659 ok(hr
== E_POINTER
, "Error: GetAuthority returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
661 hr
= IUri_GetDisplayUri(uri
, NULL
);
662 ok(hr
== E_POINTER
, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
664 hr
= IUri_GetDomain(uri
, NULL
);
665 ok(hr
== E_POINTER
, "Error: GetDomain returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
667 hr
= IUri_GetExtension(uri
, NULL
);
668 ok(hr
== E_POINTER
, "Error: GetExtension returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
670 hr
= IUri_GetFragment(uri
, NULL
);
671 ok(hr
== E_POINTER
, "Error: GetFragment returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
673 hr
= IUri_GetPassword(uri
, NULL
);
674 ok(hr
== E_POINTER
, "Error: GetPassword returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
676 hr
= IUri_GetPath(uri
, NULL
);
677 ok(hr
== E_POINTER
, "Error: GetPath returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
679 hr
= IUri_GetPathAndQuery(uri
, NULL
);
680 ok(hr
== E_POINTER
, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
682 hr
= IUri_GetQuery(uri
, NULL
);
683 ok(hr
== E_POINTER
, "Error: GetQuery returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
685 hr
= IUri_GetRawUri(uri
, NULL
);
686 ok(hr
== E_POINTER
, "Error: GetRawUri returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
688 hr
= IUri_GetSchemeName(uri
, NULL
);
689 ok(hr
== E_POINTER
, "Error: GetSchemeName returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
691 hr
= IUri_GetUserInfo(uri
, NULL
);
692 ok(hr
== E_POINTER
, "Error: GetUserInfo returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
694 hr
= IUri_GetUserName(uri
, NULL
);
695 ok(hr
== E_POINTER
, "Error: GetUserName returned 0x%08x, expected 0x%08x.\n", hr
, E_POINTER
);
697 if(uri
) IUri_Release(uri
);
699 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
700 uri_properties test
= uri_tests
[i
];
704 uriW
= a2w(test
.uri
);
705 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
706 if(test
.create_todo
) {
708 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
709 hr
, test
.create_expected
, i
);
712 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
713 hr
, test
.create_expected
, i
);
717 uri_str_property prop
;
718 BSTR received
= NULL
;
720 /* GetAbsoluteUri() tests. */
721 prop
= test
.str_props
[Uri_PROPERTY_ABSOLUTE_URI
];
722 hr
= IUri_GetAbsoluteUri(uri
, &received
);
725 ok(hr
== prop
.expected
, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
726 hr
, prop
.expected
, i
);
729 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
730 prop
.value
, wine_dbgstr_w(received
), i
);
733 ok(hr
== prop
.expected
, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
734 hr
, prop
.expected
, i
);
735 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
736 prop
.value
, wine_dbgstr_w(received
), i
);
738 SysFreeString(received
);
741 /* GetAuthority() tests. */
742 prop
= test
.str_props
[Uri_PROPERTY_AUTHORITY
];
743 hr
= IUri_GetAuthority(uri
, &received
);
746 ok(hr
== prop
.expected
, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
747 hr
, prop
.expected
, i
);
750 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
751 prop
.value
, wine_dbgstr_w(received
), i
);
754 ok(hr
== prop
.expected
, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
755 hr
, prop
.expected
, i
);
756 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
757 prop
.value
, wine_dbgstr_w(received
), i
);
759 SysFreeString(received
);
762 /* GetDisplayUri() tests. */
763 prop
= test
.str_props
[Uri_PROPERTY_DISPLAY_URI
];
764 hr
= IUri_GetDisplayUri(uri
, &received
);
767 ok(hr
== prop
.expected
, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
768 hr
, prop
.expected
, i
);
771 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_test[%d].\n",
772 prop
.value
, wine_dbgstr_w(received
), i
);
775 ok(hr
== prop
.expected
, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
776 hr
, prop
.expected
, i
);
777 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
778 prop
.value
, wine_dbgstr_w(received
), i
);
780 SysFreeString(received
);
783 /* GetDomain() tests. */
784 prop
= test
.str_props
[Uri_PROPERTY_DOMAIN
];
785 hr
= IUri_GetDomain(uri
, &received
);
788 ok(hr
== prop
.expected
, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
789 hr
, prop
.expected
, i
);
792 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
793 prop
.value
, wine_dbgstr_w(received
), i
);
796 ok(hr
== prop
.expected
, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
797 hr
, prop
.expected
, i
);
798 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
799 prop
.value
, wine_dbgstr_w(received
), i
);
801 SysFreeString(received
);
804 /* GetExtension() tests. */
805 prop
= test
.str_props
[Uri_PROPERTY_EXTENSION
];
806 hr
= IUri_GetExtension(uri
, &received
);
809 ok(hr
== prop
.expected
, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
810 hr
, prop
.expected
, i
);
813 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
814 prop
.value
, wine_dbgstr_w(received
), i
);
817 ok(hr
== prop
.expected
, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
818 hr
, prop
.expected
, i
);
819 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
820 prop
.value
, wine_dbgstr_w(received
), i
);
822 SysFreeString(received
);
825 /* GetFragment() tests. */
826 prop
= test
.str_props
[Uri_PROPERTY_FRAGMENT
];
827 hr
= IUri_GetFragment(uri
, &received
);
830 ok(hr
== prop
.expected
, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
831 hr
, prop
.expected
, i
);
834 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
835 prop
.value
, wine_dbgstr_w(received
), i
);
838 ok(hr
== prop
.expected
, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
839 hr
, prop
.expected
, i
);
840 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
841 prop
.value
, wine_dbgstr_w(received
), i
);
843 SysFreeString(received
);
846 /* GetPassword() tests. */
847 prop
= test
.str_props
[Uri_PROPERTY_PASSWORD
];
848 hr
= IUri_GetPassword(uri
, &received
);
851 ok(hr
== prop
.expected
, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
852 hr
, prop
.expected
, i
);
855 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
856 prop
.value
, wine_dbgstr_w(received
), i
);
859 ok(hr
== prop
.expected
, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
860 hr
, prop
.expected
, i
);
861 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
862 prop
.value
, wine_dbgstr_w(received
), i
);
864 SysFreeString(received
);
867 /* GetPath() tests. */
868 prop
= test
.str_props
[Uri_PROPERTY_PATH
];
869 hr
= IUri_GetPath(uri
, &received
);
872 ok(hr
== prop
.expected
, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
873 hr
, prop
.expected
, i
);
876 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
877 prop
.value
, wine_dbgstr_w(received
), i
);
880 ok(hr
== prop
.expected
, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
881 hr
, prop
.expected
, i
);
882 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
883 prop
.value
, wine_dbgstr_w(received
), i
);
885 SysFreeString(received
);
888 /* GetPathAndQuery() tests. */
889 prop
= test
.str_props
[Uri_PROPERTY_PATH_AND_QUERY
];
890 hr
= IUri_GetPathAndQuery(uri
, &received
);
893 ok(hr
== prop
.expected
, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
894 hr
, prop
.expected
, i
);
897 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
898 prop
.value
, wine_dbgstr_w(received
), i
);
901 ok(hr
== prop
.expected
, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
902 hr
, prop
.expected
, i
);
903 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
904 prop
.value
, wine_dbgstr_w(received
), i
);
906 SysFreeString(received
);
909 /* GetQuery() tests. */
910 prop
= test
.str_props
[Uri_PROPERTY_QUERY
];
911 hr
= IUri_GetQuery(uri
, &received
);
914 ok(hr
== prop
.expected
, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
915 hr
, prop
.expected
, i
);
918 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
919 prop
.value
, wine_dbgstr_w(received
), i
);
922 ok(hr
== prop
.expected
, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
923 hr
, prop
.expected
, i
);
924 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
925 prop
.value
, wine_dbgstr_w(received
), i
);
927 SysFreeString(received
);
930 /* GetRawUri() tests. */
931 prop
= test
.str_props
[Uri_PROPERTY_RAW_URI
];
932 hr
= IUri_GetRawUri(uri
, &received
);
935 ok(hr
== prop
.expected
, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
936 hr
, prop
.expected
, i
);
939 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
940 prop
.value
, wine_dbgstr_w(received
), i
);
943 ok(hr
== prop
.expected
, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
944 hr
, prop
.expected
, i
);
945 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
946 prop
.value
, wine_dbgstr_w(received
), i
);
948 SysFreeString(received
);
951 /* GetSchemeName() tests. */
952 prop
= test
.str_props
[Uri_PROPERTY_SCHEME_NAME
];
953 hr
= IUri_GetSchemeName(uri
, &received
);
956 ok(hr
== prop
.expected
, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
957 hr
, prop
.expected
, i
);
960 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
961 prop
.value
, wine_dbgstr_w(received
), i
);
964 ok(hr
== prop
.expected
, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
965 hr
, prop
.expected
, i
);
966 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
967 prop
.value
, wine_dbgstr_w(received
), i
);
969 SysFreeString(received
);
972 /* GetUserInfo() tests. */
973 prop
= test
.str_props
[Uri_PROPERTY_USER_INFO
];
974 hr
= IUri_GetUserInfo(uri
, &received
);
977 ok(hr
== prop
.expected
, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
978 hr
, prop
.expected
, i
);
981 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
982 prop
.value
, wine_dbgstr_w(received
), i
);
985 ok(hr
== prop
.expected
, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
986 hr
, prop
.expected
, i
);
987 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
988 prop
.value
, wine_dbgstr_w(received
), i
);
990 SysFreeString(received
);
993 /* GetUserName() tests. */
994 prop
= test
.str_props
[Uri_PROPERTY_USER_NAME
];
995 hr
= IUri_GetUserName(uri
, &received
);
998 ok(hr
== prop
.expected
, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
999 hr
, prop
.expected
, i
);
1002 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1003 prop
.value
, wine_dbgstr_w(received
), i
);
1006 ok(hr
== prop
.expected
, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1007 hr
, prop
.expected
, i
);
1008 ok(!strcmp_aw(prop
.value
, received
), "Error: Expected %s but got %s on uri_tests[%d].\n",
1009 prop
.value
, wine_dbgstr_w(received
), i
);
1011 SysFreeString(received
);
1014 if(uri
) IUri_Release(uri
);
1020 static void test_IUri_GetDwordProperties(void) {
1025 /* Make sure all the 'Get*' dword property functions handle invalid args correctly. */
1026 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
1027 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
1029 hr
= IUri_GetHostType(uri
, NULL
);
1030 ok(hr
== E_INVALIDARG
, "Error: GetHostType returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1032 hr
= IUri_GetPort(uri
, NULL
);
1033 ok(hr
== E_INVALIDARG
, "Error: GetPort returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1035 hr
= IUri_GetScheme(uri
, NULL
);
1036 ok(hr
== E_INVALIDARG
, "Error: GetScheme returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1038 hr
= IUri_GetZone(uri
, NULL
);
1039 ok(hr
== E_INVALIDARG
, "Error: GetZone returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1041 if(uri
) IUri_Release(uri
);
1043 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
1044 uri_properties test
= uri_tests
[i
];
1048 uriW
= a2w(test
.uri
);
1049 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
1050 if(test
.create_todo
) {
1052 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1053 hr
, test
.create_expected
, i
);
1056 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1057 hr
, test
.create_expected
, i
);
1061 uri_dword_property prop
;
1064 /* Assign an insane value so tests don't accidentally pass when
1067 received
= -9999999;
1069 /* GetHostType() tests. */
1070 prop
= test
.dword_props
[Uri_PROPERTY_HOST_TYPE
-Uri_PROPERTY_DWORD_START
];
1071 hr
= IUri_GetHostType(uri
, &received
);
1074 ok(hr
== prop
.expected
, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1075 hr
, prop
.expected
, i
);
1078 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1081 ok(hr
== prop
.expected
, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1082 hr
, prop
.expected
, i
);
1083 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1085 received
= -9999999;
1087 /* GetPort() tests. */
1088 prop
= test
.dword_props
[Uri_PROPERTY_PORT
-Uri_PROPERTY_DWORD_START
];
1089 hr
= IUri_GetPort(uri
, &received
);
1092 ok(hr
== prop
.expected
, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1093 hr
, prop
.expected
, i
);
1096 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1099 ok(hr
== prop
.expected
, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1100 hr
, prop
.expected
, i
);
1101 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1103 received
= -9999999;
1105 /* GetScheme() tests. */
1106 prop
= test
.dword_props
[Uri_PROPERTY_SCHEME
-Uri_PROPERTY_DWORD_START
];
1107 hr
= IUri_GetScheme(uri
, &received
);
1110 ok(hr
== prop
.expected
, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1111 hr
, prop
.expected
, i
);
1114 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1117 ok(hr
== prop
.expected
, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1118 hr
, prop
.expected
, i
);
1119 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1121 received
= -9999999;
1123 /* GetZone() tests. */
1124 prop
= test
.dword_props
[Uri_PROPERTY_ZONE
-Uri_PROPERTY_DWORD_START
];
1125 hr
= IUri_GetZone(uri
, &received
);
1128 ok(hr
== prop
.expected
, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1129 hr
, prop
.expected
, i
);
1132 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1135 ok(hr
== prop
.expected
, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1136 hr
, prop
.expected
, i
);
1137 ok(received
== prop
.value
, "Error: Expected %d but got %d on uri_tests[%d].\n", prop
.value
, received
, i
);
1141 if(uri
) IUri_Release(uri
);
1147 static void test_IUri_GetPropertyLength(void) {
1152 /* Make sure it handles invalid args correctly. */
1153 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
1154 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
1156 DWORD received
= 0xdeadbeef;
1158 hr
= IUri_GetPropertyLength(uri
, Uri_PROPERTY_STRING_START
, NULL
, 0);
1159 ok(hr
== E_INVALIDARG
, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1161 hr
= IUri_GetPropertyLength(uri
, Uri_PROPERTY_DWORD_START
, &received
, 0);
1162 ok(hr
== E_INVALIDARG
, "Error: GetPropertyLength return 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1163 ok(received
== 0xdeadbeef, "Error: Expected 0xdeadbeef but got 0x%08x.\n", received
);
1165 if(uri
) IUri_Release(uri
);
1167 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
1168 uri_properties test
= uri_tests
[i
];
1172 uriW
= a2w(test
.uri
);
1173 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
1174 if(test
.create_todo
) {
1176 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
1177 hr
, test
.create_expected
, i
);
1180 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_test[%d].\n",
1181 hr
, test
.create_expected
, i
);
1187 for(j
= Uri_PROPERTY_STRING_START
; j
<= Uri_PROPERTY_STRING_LAST
; ++j
) {
1188 DWORD expectedLen
, receivedLen
;
1189 uri_str_property prop
= test
.str_props
[j
];
1191 expectedLen
= lstrlen(prop
.value
);
1193 /* This won't be neccessary once GetPropertyLength is implemented. */
1196 hr
= IUri_GetPropertyLength(uri
, j
, &receivedLen
, 0);
1199 ok(hr
== prop
.expected
, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
1200 hr
, prop
.expected
, i
, j
);
1203 ok(receivedLen
== expectedLen
, "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
1204 expectedLen
, receivedLen
, i
, j
);
1207 ok(hr
== prop
.expected
, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
1208 hr
, prop
.expected
, i
, j
);
1209 ok(receivedLen
== expectedLen
, "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
1210 expectedLen
, receivedLen
, i
, j
);
1215 if(uri
) IUri_Release(uri
);
1221 static void test_IUri_GetProperties(void) {
1226 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
1227 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
1229 hr
= IUri_GetProperties(uri
, NULL
);
1230 ok(hr
== E_INVALIDARG
, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1232 if(uri
) IUri_Release(uri
);
1234 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
1235 uri_properties test
= uri_tests
[i
];
1239 uriW
= a2w(test
.uri
);
1240 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
1241 if(test
.create_todo
) {
1243 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, test
.create_expected
);
1246 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, test
.create_expected
);
1253 hr
= IUri_GetProperties(uri
, &received
);
1254 if(test
.props_todo
) {
1256 ok(hr
== S_OK
, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
1259 ok(hr
== S_OK
, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
1262 for(j
= 0; j
<= Uri_PROPERTY_DWORD_LAST
; ++j
) {
1263 /* (1 << j) converts a Uri_PROPERTY to its corresponding Uri_HAS_* flag mask. */
1264 if(test
.props
& (1 << j
)) {
1265 if(test
.props_todo
) {
1267 ok(received
& (1 << j
), "Error: Expected flag for property %d on uri_tests[%d].\n", j
, i
);
1270 ok(received
& (1 << j
), "Error: Expected flag for property %d on uri_tests[%d].\n", j
, i
);
1273 /* NOTE: Since received is initialized to 0, this test will always pass while
1274 * GetProperties is unimplemented.
1276 ok(!(received
& (1 << j
)), "Error: Received flag for property %d when not expected on uri_tests[%d].\n", j
, i
);
1281 if(uri
) IUri_Release(uri
);
1287 static void test_IUri_HasProperty(void) {
1292 hr
= pCreateUri(http_urlW
, 0, 0, &uri
);
1293 ok(hr
== S_OK
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, S_OK
);
1295 hr
= IUri_HasProperty(uri
, Uri_PROPERTY_RAW_URI
, NULL
);
1296 ok(hr
== E_INVALIDARG
, "Error: HasProperty returned 0x%08x, expected 0x%08x.\n", hr
, E_INVALIDARG
);
1298 if(uri
) IUri_Release(uri
);
1300 for(i
= 0; i
< sizeof(uri_tests
)/sizeof(uri_tests
[0]); ++i
) {
1301 uri_properties test
= uri_tests
[i
];
1305 uriW
= a2w(test
.uri
);
1307 hr
= pCreateUri(uriW
, test
.create_flags
, 0, &uri
);
1308 if(test
.create_todo
) {
1310 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, test
.create_expected
);
1313 ok(hr
== test
.create_expected
, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr
, test
.create_expected
);
1319 for(j
= 0; j
<= Uri_PROPERTY_DWORD_LAST
; ++j
) {
1320 /* Assign -1, then explicitly test for TRUE or FALSE later. */
1323 hr
= IUri_HasProperty(uri
, j
, &received
);
1324 if(test
.props_todo
) {
1326 ok(hr
== S_OK
, "Error: HasProperty returned 0x%08x, expected 0x%08x for property %d on uri_tests[%d].\n",
1330 /* Check if the property should be true. */
1331 if(test
.props
& (1 << j
)) {
1333 ok(received
== TRUE
, "Error: Expected to have property %d on uri_tests[%d].\n", j
, i
);
1337 ok(received
== FALSE
, "Error: Wasn't expecting to have property %d on uri_tests[%d].\n", j
, i
);
1341 ok(hr
== S_OK
, "Error: HasProperty returned 0x%08x, expected 0x%08x for property %d on uri_tests[%d].\n",
1344 if(test
.props
& (1 << j
)) {
1345 ok(received
== TRUE
, "Error: Expected to have property %d on uri_tests[%d].\n", j
, i
);
1347 ok(received
== FALSE
, "Error: Wasn't expecting to have property %d on uri_tests[%d].\n", j
, i
);
1353 if(uri
) IUri_Release(uri
);
1362 hurlmon
= GetModuleHandle("urlmon.dll");
1363 pCreateUri
= (void*) GetProcAddress(hurlmon
, "CreateUri");
1366 win_skip("CreateUri is not present, skipping tests.\n");
1370 trace("test CreateUri invalid flags...\n");
1371 test_CreateUri_InvalidFlags();
1373 trace("test CreateUri invalid args...\n");
1374 test_CreateUri_InvalidArgs();
1376 trace("test IUri_GetPropertyBSTR...\n");
1377 test_IUri_GetPropertyBSTR();
1379 trace("test IUri_GetPropertyDWORD...\n");
1380 test_IUri_GetPropertyDWORD();
1382 trace("test IUri_GetStrProperties...\n");
1383 test_IUri_GetStrProperties();
1385 trace("test IUri_GetDwordProperties...\n");
1386 test_IUri_GetDwordProperties();
1388 trace("test IUri_GetPropertyLength...\n");
1389 test_IUri_GetPropertyLength();
1391 trace("test IUri_GetProperties...\n");
1392 test_IUri_GetProperties();
1394 trace("test IUri_HasProperty...\n");
1395 test_IUri_HasProperty();