Release 1.1.37.
[wine/gsoc-2012-control.git] / dlls / shlwapi / tests / url.c
blobb69ab0053cd345746deb28d2c9f1d5469e5edf41
1 /* Unit test suite for Path functions
3 * Copyright 2002 Matthew Mastracci
4 * Copyright 2007,2008 Detlef Riekenberg
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
21 #include <stdarg.h>
22 #include <stdio.h>
24 #include "wine/test.h"
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winreg.h"
28 #include "shlwapi.h"
29 #include "wininet.h"
31 /* ################ */
32 static HMODULE hShlwapi;
33 static HRESULT (WINAPI *pUrlCanonicalizeW)(LPCWSTR, LPWSTR, LPDWORD, DWORD);
34 static HRESULT (WINAPI *pParseURLA)(LPCSTR,PARSEDURLA*);
35 static HRESULT (WINAPI *pParseURLW)(LPCWSTR,PARSEDURLW*);
37 static const char* TEST_URL_1 = "http://www.winehq.org/tests?date=10/10/1923";
38 static const char* TEST_URL_2 = "http://localhost:8080/tests%2e.html?date=Mon%2010/10/1923";
39 static const char* TEST_URL_3 = "http://foo:bar@localhost:21/internal.php?query=x&return=y";
40 static const WCHAR winehqW[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/',0};
41 static const CHAR winehqA[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/',0};
43 /* ################ */
45 static const CHAR untouchedA[] = "untouched";
47 #define TEST_APPLY_MAX_LENGTH INTERNET_MAX_URL_LENGTH
49 typedef struct _TEST_URL_APPLY {
50 const char * url;
51 DWORD flags;
52 HRESULT res;
53 DWORD newlen;
54 const char * newurl;
55 } TEST_URL_APPLY;
57 static const TEST_URL_APPLY TEST_APPLY[] = {
58 {"www.winehq.org", URL_APPLY_GUESSSCHEME | URL_APPLY_DEFAULT, S_OK, 21, "http://www.winehq.org"},
59 {"www.winehq.org", URL_APPLY_GUESSSCHEME, S_OK, 21, "http://www.winehq.org"},
60 {"www.winehq.org", URL_APPLY_DEFAULT, S_OK, 21, "http://www.winehq.org"},
61 {"ftp.winehq.org", URL_APPLY_GUESSSCHEME | URL_APPLY_DEFAULT, S_OK, 20, "ftp://ftp.winehq.org"},
62 {"ftp.winehq.org", URL_APPLY_GUESSSCHEME, S_OK, 20, "ftp://ftp.winehq.org"},
63 {"ftp.winehq.org", URL_APPLY_DEFAULT, S_OK, 21, "http://ftp.winehq.org"},
64 {"winehq.org", URL_APPLY_GUESSSCHEME | URL_APPLY_DEFAULT, S_OK, 17, "http://winehq.org"},
65 {"winehq.org", URL_APPLY_GUESSSCHEME, S_FALSE, TEST_APPLY_MAX_LENGTH, untouchedA},
66 {"winehq.org", URL_APPLY_DEFAULT, S_OK, 17, "http://winehq.org"},
67 {"", URL_APPLY_GUESSSCHEME | URL_APPLY_DEFAULT, S_OK, 7, "http://"},
68 {"", URL_APPLY_GUESSSCHEME, S_FALSE, TEST_APPLY_MAX_LENGTH, untouchedA},
69 {"", URL_APPLY_DEFAULT, S_OK, 7, "http://"}
72 /* ################ */
74 typedef struct _TEST_URL_CANONICALIZE {
75 const char *url;
76 DWORD flags;
77 HRESULT expectret;
78 const char *expecturl;
79 BOOL todo;
80 } TEST_URL_CANONICALIZE;
82 static const TEST_URL_CANONICALIZE TEST_CANONICALIZE[] = {
83 {"http://www.winehq.org/tests/../tests/../..", 0, S_OK, "http://www.winehq.org/", TRUE},
84 {"http://www.winehq.org/tests/../tests", 0, S_OK, "http://www.winehq.org/tests", FALSE},
85 {"http://www.winehq.org/tests\n", URL_WININET_COMPATIBILITY|URL_ESCAPE_SPACES_ONLY|URL_ESCAPE_UNSAFE, S_OK, "http://www.winehq.org/tests", FALSE},
86 {"http://www.winehq.org/tests\r", URL_WININET_COMPATIBILITY|URL_ESCAPE_SPACES_ONLY|URL_ESCAPE_UNSAFE, S_OK, "http://www.winehq.org/tests", FALSE},
87 {"http://www.winehq.org/tests\r", 0, S_OK, "http://www.winehq.org/tests", FALSE},
88 {"http://www.winehq.org/tests\r", URL_DONT_SIMPLIFY, S_OK, "http://www.winehq.org/tests", FALSE},
89 {"http://www.winehq.org/tests/../tests/", 0, S_OK, "http://www.winehq.org/tests/", FALSE},
90 {"http://www.winehq.org/tests/../tests/..", 0, S_OK, "http://www.winehq.org/", FALSE},
91 {"http://www.winehq.org/tests/../tests/../", 0, S_OK, "http://www.winehq.org/", FALSE},
92 {"http://www.winehq.org/tests/..", 0, S_OK, "http://www.winehq.org/", FALSE},
93 {"http://www.winehq.org/tests/../", 0, S_OK, "http://www.winehq.org/", FALSE},
94 {"http://www.winehq.org/tests/..?query=x&return=y", 0, S_OK, "http://www.winehq.org/?query=x&return=y", FALSE},
95 {"http://www.winehq.org/tests/../?query=x&return=y", 0, S_OK, "http://www.winehq.org/?query=x&return=y", FALSE},
96 {"http://www.winehq.org/tests/..#example", 0, S_OK, "http://www.winehq.org/#example", FALSE},
97 {"http://www.winehq.org/tests/../#example", 0, S_OK, "http://www.winehq.org/#example", FALSE},
98 {"http://www.winehq.org/tests\\../#example", 0, S_OK, "http://www.winehq.org/#example", FALSE},
99 {"http://www.winehq.org/tests/..\\#example", 0, S_OK, "http://www.winehq.org/#example", FALSE},
100 {"http://www.winehq.org\\tests/../#example", 0, S_OK, "http://www.winehq.org/#example", FALSE},
101 {"http://www.winehq.org/tests/../#example", URL_DONT_SIMPLIFY, S_OK, "http://www.winehq.org/tests/../#example", FALSE},
102 {"http://www.winehq.org/tests/foo bar", URL_ESCAPE_SPACES_ONLY| URL_DONT_ESCAPE_EXTRA_INFO , S_OK, "http://www.winehq.org/tests/foo%20bar", FALSE},
103 {"http://www.winehq.org/tests/foo%20bar", URL_UNESCAPE , S_OK, "http://www.winehq.org/tests/foo bar", FALSE},
104 {"file:///c:/tests/foo%20bar", URL_UNESCAPE , S_OK, "file:///c:/tests/foo bar", FALSE},
105 {"file:///c:/tests\\foo%20bar", URL_UNESCAPE , S_OK, "file:///c:/tests/foo bar", FALSE},
106 {"file:///c:/tests/foo%20bar", 0, S_OK, "file:///c:/tests/foo%20bar", FALSE},
107 {"file:///c:/tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
108 {"file://localhost/c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
109 {"file://localhost\\c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
110 {"file://localhost\\\\c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
111 {"file://localhost\\c:\\tests/../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
112 {"file://c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
113 {"file://c:/tests\\../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
114 {"file://c:/tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
115 {"file:///c://tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\\\tests\\foo bar", FALSE},
116 {"file:///c:\\tests\\foo bar", 0, S_OK, "file:///c:/tests/foo bar", FALSE},
117 {"file:///c:\\tests\\foo bar", URL_DONT_SIMPLIFY, S_OK, "file:///c:/tests/foo bar", FALSE},
118 {"http://www.winehq.org/site/about", URL_FILE_USE_PATHURL, S_OK, "http://www.winehq.org/site/about", FALSE},
119 {"file_://www.winehq.org/site/about", URL_FILE_USE_PATHURL, S_OK, "file_://www.winehq.org/site/about", FALSE},
120 {"c:\\dir\\file", 0, S_OK, "file:///c:/dir/file", FALSE},
121 {"file:///c:\\dir\\file", 0, S_OK, "file:///c:/dir/file", FALSE},
122 {"c:dir\\file", 0, S_OK, "file:///c:dir/file", FALSE},
123 {"c:\\tests\\foo bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
124 {"c:\\tests\\foo bar", 0, S_OK, "file:///c:/tests/foo%20bar", FALSE},
125 {"res://file", 0, S_OK, "res://file/", FALSE},
126 {"res://file", URL_FILE_USE_PATHURL, S_OK, "res://file/", FALSE},
127 {"res:///c:/tests/foo%20bar", URL_UNESCAPE , S_OK, "res:///c:/tests/foo bar", FALSE},
128 {"res:///c:/tests\\foo%20bar", URL_UNESCAPE , S_OK, "res:///c:/tests\\foo bar", FALSE},
129 {"res:///c:/tests/foo%20bar", 0, S_OK, "res:///c:/tests/foo%20bar", FALSE},
130 {"res:///c:/tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "res:///c:/tests/foo%20bar", FALSE},
131 {"res://c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "res://c:/tests/foo%20bar", FALSE},
132 {"res://c:/tests\\../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "res://c:/tests/foo%20bar", FALSE},
133 {"res://c:/tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "res://c:/tests/foo%20bar", FALSE},
134 {"res:///c://tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "res:///c://tests/foo%20bar", FALSE},
135 {"res:///c:\\tests\\foo bar", 0, S_OK, "res:///c:\\tests\\foo bar", FALSE},
136 {"res:///c:\\tests\\foo bar", URL_DONT_SIMPLIFY, S_OK, "res:///c:\\tests\\foo bar", FALSE},
137 {"res://c:\\tests\\foo bar/res", URL_FILE_USE_PATHURL, S_OK, "res://c:\\tests\\foo bar/res", FALSE},
138 {"res://c:\\tests/res\\foo%20bar/strange\\sth", 0, S_OK, "res://c:\\tests/res\\foo%20bar/strange\\sth", FALSE},
139 {"res://c:\\tests/res\\foo%20bar/strange\\sth", URL_FILE_USE_PATHURL, S_OK, "res://c:\\tests/res\\foo%20bar/strange\\sth", FALSE},
140 {"res://c:\\tests/res\\foo%20bar/strange\\sth", URL_UNESCAPE, S_OK, "res://c:\\tests/res\\foo bar/strange\\sth", FALSE},
141 {"A", 0, S_OK, "A", FALSE},
142 {"/uri-res/N2R?urn:sha1:B3K", URL_DONT_ESCAPE_EXTRA_INFO | URL_WININET_COMPATIBILITY /*0x82000000*/, S_OK, "/uri-res/N2R?urn:sha1:B3K", FALSE} /*LimeWire online installer calls this*/,
143 {"http:www.winehq.org/dir/../index.html", 0, S_OK, "http:www.winehq.org/index.html"},
146 /* ################ */
148 typedef struct _TEST_URL_ESCAPE {
149 const char *url;
150 DWORD flags;
151 DWORD expectescaped;
152 HRESULT expectret;
153 const char *expecturl;
154 } TEST_URL_ESCAPE;
156 static const TEST_URL_ESCAPE TEST_ESCAPE[] = {
157 {"http://www.winehq.org/tests0", 0, 0, S_OK, "http://www.winehq.org/tests0"},
158 {"http://www.winehq.org/tests1\n", 0, 0, S_OK, "http://www.winehq.org/tests1%0A"},
159 {"http://www.winehq.org/tests2\r", 0, 0, S_OK, "http://www.winehq.org/tests2%0D"},
160 {"http://www.winehq.org/tests3\r", URL_ESCAPE_SPACES_ONLY|URL_ESCAPE_UNSAFE, 0, S_OK, "http://www.winehq.org/tests3\r"},
161 {"http://www.winehq.org/tests4\r", URL_ESCAPE_SPACES_ONLY, 0, S_OK, "http://www.winehq.org/tests4\r"},
162 {"http://www.winehq.org/tests5\r", URL_WININET_COMPATIBILITY|URL_ESCAPE_SPACES_ONLY, 0, S_OK, "http://www.winehq.org/tests5\r"},
163 {"/direct/swhelp/series6/6.2i_latestservicepack.dat\r", URL_ESCAPE_SPACES_ONLY, 0, S_OK, "/direct/swhelp/series6/6.2i_latestservicepack.dat\r"},
165 {"file://////foo/bar\\baz", 0, 0, S_OK, "file://foo/bar/baz"},
166 {"file://///foo/bar\\baz", 0, 0, S_OK, "file://foo/bar/baz"},
167 {"file:////foo/bar\\baz", 0, 0, S_OK, "file://foo/bar/baz"},
168 {"file:///localhost/foo/bar\\baz", 0, 0, S_OK, "file:///localhost/foo/bar/baz"},
169 {"file:///foo/bar\\baz", 0, 0, S_OK, "file:///foo/bar/baz"},
170 {"file://loCalHost/foo/bar\\baz", 0, 0, S_OK, "file:///foo/bar/baz"},
171 {"file://foo/bar\\baz", 0, 0, S_OK, "file://foo/bar/baz"},
172 {"file:/localhost/foo/bar\\baz", 0, 0, S_OK, "file:///localhost/foo/bar/baz"},
173 {"file:/foo/bar\\baz", 0, 0, S_OK, "file:///foo/bar/baz"},
174 {"file:foo/bar\\baz", 0, 0, S_OK, "file:foo/bar/baz"},
175 {"file:\\foo/bar\\baz", 0, 0, S_OK, "file:///foo/bar/baz"},
176 {"file:\\\\foo/bar\\baz", 0, 0, S_OK, "file://foo/bar/baz"},
177 {"file:\\\\\\foo/bar\\baz", 0, 0, S_OK, "file:///foo/bar/baz"},
178 {"file:\\\\localhost\\foo/bar\\baz", 0, 0, S_OK, "file:///foo/bar/baz"},
179 {"file:///f oo/b?a r\\baz", 0, 0, S_OK, "file:///f%20oo/b?a r\\baz"},
180 {"file:///foo/b#a r\\baz", 0, 0, S_OK, "file:///foo/b%23a%20r/baz"},
181 {"file:///f o^&`{}|][\"<>\\%o/b#a r\\baz", 0, 0, S_OK, "file:///f%20o%5E%26%60%7B%7D%7C%5D%5B%22%3C%3E/%o/b%23a%20r/baz"},
182 {"file:///f o%o/b?a r\\b%az", URL_ESCAPE_PERCENT, 0, S_OK, "file:///f%20o%25o/b?a r\\b%az"},
183 {"file:/foo/bar\\baz", URL_ESCAPE_SEGMENT_ONLY, 0, S_OK, "file:%2Ffoo%2Fbar%5Cbaz"},
185 {"foo/b%ar\\ba?z\\", URL_ESCAPE_SEGMENT_ONLY, 0, S_OK, "foo%2Fb%ar%5Cba%3Fz%5C"},
186 {"foo/b%ar\\ba?z\\", URL_ESCAPE_PERCENT | URL_ESCAPE_SEGMENT_ONLY, 0, S_OK, "foo%2Fb%25ar%5Cba%3Fz%5C"},
187 {"foo/bar\\ba?z\\", 0, 0, S_OK, "foo/bar%5Cba?z\\"},
188 {"/foo/bar\\ba?z\\", 0, 0, S_OK, "/foo/bar%5Cba?z\\"},
189 {"/foo/bar\\ba#z\\", 0, 0, S_OK, "/foo/bar%5Cba#z\\"},
190 {"/foo/%5C", 0, 0, S_OK, "/foo/%5C"},
191 {"/foo/%5C", URL_ESCAPE_PERCENT, 0, S_OK, "/foo/%255C"},
193 {"http://////foo/bar\\baz", 0, 0, S_OK, "http://////foo/bar/baz"},
194 {"http://///foo/bar\\baz", 0, 0, S_OK, "http://///foo/bar/baz"},
195 {"http:////foo/bar\\baz", 0, 0, S_OK, "http:////foo/bar/baz"},
196 {"http:///foo/bar\\baz", 0, 0, S_OK, "http:///foo/bar/baz"},
197 {"http://localhost/foo/bar\\baz", 0, 0, S_OK, "http://localhost/foo/bar/baz"},
198 {"http://foo/bar\\baz", 0, 0, S_OK, "http://foo/bar/baz"},
199 {"http:/foo/bar\\baz", 0, 0, S_OK, "http:/foo/bar/baz"},
200 {"http:foo/bar\\ba?z\\", 0, 0, S_OK, "http:foo%2Fbar%2Fba?z\\"},
201 {"http:foo/bar\\ba#z\\", 0, 0, S_OK, "http:foo%2Fbar%2Fba#z\\"},
202 {"http:\\foo/bar\\baz", 0, 0, S_OK, "http:/foo/bar/baz"},
203 {"http:\\\\foo/bar\\baz", 0, 0, S_OK, "http://foo/bar/baz"},
204 {"http:\\\\\\foo/bar\\baz", 0, 0, S_OK, "http:///foo/bar/baz"},
205 {"http:\\\\\\\\foo/bar\\baz", 0, 0, S_OK, "http:////foo/bar/baz"},
206 {"http:/fo ?o/b ar\\baz", 0, 0, S_OK, "http:/fo%20?o/b ar\\baz"},
207 {"http:fo ?o/b ar\\baz", 0, 0, S_OK, "http:fo%20?o/b ar\\baz"},
208 {"http:/foo/bar\\baz", URL_ESCAPE_SEGMENT_ONLY, 0, S_OK, "http:%2Ffoo%2Fbar%5Cbaz"},
210 {"https://foo/bar\\baz", 0, 0, S_OK, "https://foo/bar/baz"},
211 {"https:/foo/bar\\baz", 0, 0, S_OK, "https:/foo/bar/baz"},
212 {"https:\\foo/bar\\baz", 0, 0, S_OK, "https:/foo/bar/baz"},
214 {"foo:////foo/bar\\baz", 0, 0, S_OK, "foo:////foo/bar%5Cbaz"},
215 {"foo:///foo/bar\\baz", 0, 0, S_OK, "foo:///foo/bar%5Cbaz"},
216 {"foo://localhost/foo/bar\\baz", 0, 0, S_OK, "foo://localhost/foo/bar%5Cbaz"},
217 {"foo://foo/bar\\baz", 0, 0, S_OK, "foo://foo/bar%5Cbaz"},
218 {"foo:/foo/bar\\baz", 0, 0, S_OK, "foo:/foo/bar%5Cbaz"},
219 {"foo:foo/bar\\baz", 0, 0, S_OK, "foo:foo%2Fbar%5Cbaz"},
220 {"foo:\\foo/bar\\baz", 0, 0, S_OK, "foo:%5Cfoo%2Fbar%5Cbaz"},
221 {"foo:/foo/bar\\ba?\\z", 0, 0, S_OK, "foo:/foo/bar%5Cba?\\z"},
222 {"foo:/foo/bar\\ba#\\z", 0, 0, S_OK, "foo:/foo/bar%5Cba#\\z"},
224 {"mailto:/fo/o@b\\%a?\\r.b#\\az", 0, 0, S_OK, "mailto:%2Ffo%2Fo@b%5C%a%3F%5Cr.b%23%5Caz"},
225 {"mailto:fo/o@b\\%a?\\r.b#\\az", 0, 0, S_OK, "mailto:fo%2Fo@b%5C%a%3F%5Cr.b%23%5Caz"},
226 {"mailto:fo/o@b\\%a?\\r.b#\\az", URL_ESCAPE_PERCENT, 0, S_OK, "mailto:fo%2Fo@b%5C%25a%3F%5Cr.b%23%5Caz"},
228 {"ftp:fo/o@bar.baz/foo/bar", 0, 0, S_OK, "ftp:fo%2Fo@bar.baz%2Ffoo%2Fbar"},
229 {"ftp:/fo/o@bar.baz/foo/bar", 0, 0, S_OK, "ftp:/fo/o@bar.baz/foo/bar"},
230 {"ftp://fo/o@bar.baz/fo?o\\bar", 0, 0, S_OK, "ftp://fo/o@bar.baz/fo?o\\bar"},
231 {"ftp://fo/o@bar.baz/fo#o\\bar", 0, 0, S_OK, "ftp://fo/o@bar.baz/fo#o\\bar"},
232 {"ftp://localhost/o@bar.baz/fo#o\\bar", 0, 0, S_OK, "ftp://localhost/o@bar.baz/fo#o\\bar"},
233 {"ftp:///fo/o@bar.baz/foo/bar", 0, 0, S_OK, "ftp:///fo/o@bar.baz/foo/bar"},
234 {"ftp:////fo/o@bar.baz/foo/bar", 0, 0, S_OK, "ftp:////fo/o@bar.baz/foo/bar"}
237 /* ################ */
239 typedef struct _TEST_URL_COMBINE {
240 const char *url1;
241 const char *url2;
242 DWORD flags;
243 HRESULT expectret;
244 const char *expecturl;
245 } TEST_URL_COMBINE;
247 static const TEST_URL_COMBINE TEST_COMBINE[] = {
248 {"http://www.winehq.org/tests", "tests1", 0, S_OK, "http://www.winehq.org/tests1"},
249 {"http://www.%77inehq.org/tests", "tests1", 0, S_OK, "http://www.%77inehq.org/tests1"},
250 /*FIXME {"http://www.winehq.org/tests", "../tests2", 0, S_OK, "http://www.winehq.org/tests2"},*/
251 {"http://www.winehq.org/tests/", "../tests3", 0, S_OK, "http://www.winehq.org/tests3"},
252 {"http://www.winehq.org/tests/test1", "test2", 0, S_OK, "http://www.winehq.org/tests/test2"},
253 {"http://www.winehq.org/tests/../tests", "tests4", 0, S_OK, "http://www.winehq.org/tests4"},
254 {"http://www.winehq.org/tests/../tests/", "tests5", 0, S_OK, "http://www.winehq.org/tests/tests5"},
255 {"http://www.winehq.org/tests/../tests/", "/tests6/..", 0, S_OK, "http://www.winehq.org/"},
256 {"http://www.winehq.org/tests/../tests/..", "tests7/..", 0, S_OK, "http://www.winehq.org/"},
257 {"http://www.winehq.org/tests/?query=x&return=y", "tests8", 0, S_OK, "http://www.winehq.org/tests/tests8"},
258 {"http://www.winehq.org/tests/#example", "tests9", 0, S_OK, "http://www.winehq.org/tests/tests9"},
259 {"http://www.winehq.org/tests/../tests/", "/tests10/..", URL_DONT_SIMPLIFY, S_OK, "http://www.winehq.org/tests10/.."},
260 {"http://www.winehq.org/tests/../", "tests11", URL_DONT_SIMPLIFY, S_OK, "http://www.winehq.org/tests/../tests11"},
261 {"file:///C:\\dir\\file.txt", "test.txt", 0, S_OK, "file:///C:/dir/test.txt"},
262 {"C:\\winehq\\winehq.txt", "C:\\Test\\test.txt", 0, S_OK, "file:///C:/Test/test.txt"},
263 {"http://www.winehq.org/test/", "test%20file.txt", 0, S_OK, "http://www.winehq.org/test/test%20file.txt"},
264 {"http://www.winehq.org/test/", "test%20file.txt", URL_FILE_USE_PATHURL, S_OK, "http://www.winehq.org/test/test%20file.txt"},
265 {"http://www.winehq.org%2ftest/", "test%20file.txt", URL_FILE_USE_PATHURL, S_OK, "http://www.winehq.org%2ftest/test%20file.txt"},
266 {"xxx:@MSITStore:file.chm/file.html", "dir/file", 0, S_OK, "xxx:dir/file"},
267 {"mk:@MSITStore:file.chm::/file.html", "/dir/file", 0, S_OK, "mk:@MSITStore:file.chm::/dir/file"},
268 {"mk:@MSITStore:file.chm::/file.html", "mk:@MSITStore:file.chm::/dir/file", 0, S_OK, "mk:@MSITStore:file.chm::/dir/file"},
269 {"foo:today", "foo:calendar", 0, S_OK, "foo:calendar"},
270 {"foo:today", "bar:calendar", 0, S_OK, "bar:calendar"},
271 {"foo:/today", "foo:calendar", 0, S_OK, "foo:/calendar"},
272 {"foo:/today/", "foo:calendar", 0, S_OK, "foo:/today/calendar"},
273 {"mk:@MSITStore:dir/test.chm::dir/index.html", "image.jpg", 0, S_OK, "mk:@MSITStore:dir/test.chm::dir/image.jpg"},
274 {"mk:@MSITStore:dir/test.chm::dir/dir2/index.html", "../image.jpg", 0, S_OK, "mk:@MSITStore:dir/test.chm::dir/image.jpg"},
275 /* UrlCombine case 2 tests. Schemes do not match */
276 {"outbind://xxxxxxxxx","http://wine1/dir",0, S_OK,"http://wine1/dir"},
277 {"xxxx://xxxxxxxxx","http://wine2/dir",0, S_OK,"http://wine2/dir"},
278 {"ftp://xxxxxxxxx/","http://wine3/dir",0, S_OK,"http://wine3/dir"},
279 {"outbind://xxxxxxxxx","http://wine4/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"http://wine4/dir"},
280 {"xxx://xxxxxxxxx","http://wine5/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"http://wine5/dir"},
281 {"ftp://xxxxxxxxx/","http://wine6/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"http://wine6/dir"},
282 {"http://xxxxxxxxx","outbind://wine7/dir",0, S_OK,"outbind://wine7/dir"},
283 {"xxx://xxxxxxxxx","ftp://wine8/dir",0, S_OK,"ftp://wine8/dir"},
284 {"ftp://xxxxxxxxx/","xxx://wine9/dir",0, S_OK,"xxx://wine9/dir"},
285 {"http://xxxxxxxxx","outbind://wine10/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"outbind://wine10/dir"},
286 {"xxx://xxxxxxxxx","ftp://wine11/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"ftp://wine11/dir"},
287 {"ftp://xxxxxxxxx/","xxx://wine12/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"xxx://wine12/dir"},
288 {"http://xxxxxxxxx","outbind:wine13/dir",0, S_OK,"outbind:wine13/dir"},
289 {"xxx://xxxxxxxxx","ftp:wine14/dir",0, S_OK,"ftp:wine14/dir"},
290 {"ftp://xxxxxxxxx/","xxx:wine15/dir",0, S_OK,"xxx:wine15/dir"},
291 {"outbind://xxxxxxxxx/","http:wine16/dir",0, S_OK,"http:wine16/dir"},
292 {"http://xxxxxxxxx","outbind:wine17/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"outbind:wine17/dir"},
293 {"xxx://xxxxxxxxx","ftp:wine18/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"ftp:wine18/dir"},
294 {"ftp://xxxxxxxxx/","xxx:wine19/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"xxx:wine19/dir"},
295 {"outbind://xxxxxxxxx/","http:wine20/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"http:wine20/dir"},
296 {"file:///c:/dir/file.txt","index.html?test=c:/abc",URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO,S_OK,"file:///c:/dir/index.html?test=c:/abc"}
299 /* ################ */
301 static const struct {
302 const char *path;
303 const char *url;
304 DWORD ret;
305 } TEST_URLFROMPATH [] = {
306 {"foo", "file:foo", S_OK},
307 {"foo\\bar", "file:foo/bar", S_OK},
308 {"\\foo\\bar", "file:///foo/bar", S_OK},
309 {"c:\\foo\\bar", "file:///c:/foo/bar", S_OK},
310 {"c:foo\\bar", "file:///c:foo/bar", S_OK},
311 {"c:\\foo/b a%r", "file:///c:/foo/b%20a%25r", S_OK},
312 {"c:\\foo\\foo bar", "file:///c:/foo/foo%20bar", S_OK},
313 #if 0
314 /* The following test fails on native shlwapi as distributed with Win95/98.
315 * Wine matches the behaviour of later versions.
317 {"xx:c:\\foo\\bar", "xx:c:\\foo\\bar", S_FALSE}
318 #endif
321 /* ################ */
323 static struct {
324 char url[30];
325 const char *expect;
326 } TEST_URL_UNESCAPE[] = {
327 {"file://foo/bar", "file://foo/bar"},
328 {"file://fo%20o%5Ca/bar", "file://fo o\\a/bar"},
329 {"file://%24%25foobar", "file://$%foobar"}
332 /* ################ */
334 static const struct {
335 const char *path;
336 BOOL expect;
337 } TEST_PATH_IS_URL[] = {
338 {"http://foo/bar", TRUE},
339 {"c:\\foo\\bar", FALSE},
340 {"foo://foo/bar", TRUE},
341 {"foo\\bar", FALSE},
342 {"foo.bar", FALSE},
343 {"bogusscheme:", TRUE},
344 {"http:partial", TRUE}
347 /* ################ */
349 static const struct {
350 const char *url;
351 BOOL expectOpaque;
352 BOOL expectFile;
353 } TEST_URLIS_ATTRIBS[] = {
354 { "ftp:", FALSE, FALSE },
355 { "http:", FALSE, FALSE },
356 { "gopher:", FALSE, FALSE },
357 { "mailto:", TRUE, FALSE },
358 { "news:", FALSE, FALSE },
359 { "nntp:", FALSE, FALSE },
360 { "telnet:", FALSE, FALSE },
361 { "wais:", FALSE, FALSE },
362 { "file:", FALSE, TRUE },
363 { "mk:", FALSE, FALSE },
364 { "https:", FALSE, FALSE },
365 { "shell:", TRUE, FALSE },
366 { "https:", FALSE, FALSE },
367 { "snews:", FALSE, FALSE },
368 { "local:", FALSE, FALSE },
369 { "javascript:", TRUE, FALSE },
370 { "vbscript:", TRUE, FALSE },
371 { "about:", TRUE, FALSE },
372 { "res:", FALSE, FALSE },
373 { "bogusscheme:", FALSE, FALSE },
374 { "file:\\\\e:\\b\\c", FALSE, TRUE },
375 { "file://e:/b/c", FALSE, TRUE },
376 { "http:partial", FALSE, FALSE },
377 { "mailto://www.winehq.org/test.html", TRUE, FALSE },
378 { "file:partial", FALSE, TRUE }
381 /* ########################### */
383 static LPWSTR GetWideString(const char* szString)
385 LPWSTR wszString = HeapAlloc(GetProcessHeap(), 0, (2*INTERNET_MAX_URL_LENGTH) * sizeof(WCHAR));
387 MultiByteToWideChar(0, 0, szString, -1, wszString, INTERNET_MAX_URL_LENGTH);
389 return wszString;
393 static void FreeWideString(LPWSTR wszString)
395 HeapFree(GetProcessHeap(), 0, wszString);
398 /* ########################### */
400 static void test_UrlApplyScheme(void)
402 CHAR newurl[TEST_APPLY_MAX_LENGTH];
403 WCHAR urlW[TEST_APPLY_MAX_LENGTH];
404 WCHAR newurlW[TEST_APPLY_MAX_LENGTH];
405 HRESULT res;
406 DWORD len;
407 DWORD i;
409 for(i = 0; i < sizeof(TEST_APPLY)/sizeof(TEST_APPLY[0]); i++) {
410 len = TEST_APPLY_MAX_LENGTH;
411 lstrcpyA(newurl, untouchedA);
412 res = UrlApplySchemeA(TEST_APPLY[i].url, newurl, &len, TEST_APPLY[i].flags);
413 ok( res == TEST_APPLY[i].res,
414 "#%dA: got HRESULT 0x%x (expected 0x%x)\n", i, res, TEST_APPLY[i].res);
416 ok( len == TEST_APPLY[i].newlen,
417 "#%dA: got len %d (expected %d)\n", i, len, TEST_APPLY[i].newlen);
419 ok( !lstrcmpA(newurl, TEST_APPLY[i].newurl),
420 "#%dA: got '%s' (expected '%s')\n", i, newurl, TEST_APPLY[i].newurl);
422 /* returned length is in character */
423 len = TEST_APPLY_MAX_LENGTH;
424 lstrcpyA(newurl, untouchedA);
425 MultiByteToWideChar(CP_ACP, 0, newurl, -1, newurlW, len);
426 MultiByteToWideChar(CP_ACP, 0, TEST_APPLY[i].url, -1, urlW, len);
428 res = UrlApplySchemeW(urlW, newurlW, &len, TEST_APPLY[i].flags);
429 WideCharToMultiByte(CP_ACP, 0, newurlW, -1, newurl, TEST_APPLY_MAX_LENGTH, NULL, NULL);
430 ok( res == TEST_APPLY[i].res,
431 "#%dW: got HRESULT 0x%x (expected 0x%x)\n", i, res, TEST_APPLY[i].res);
433 ok( len == TEST_APPLY[i].newlen,
434 "#%dW: got len %d (expected %d)\n", i, len, TEST_APPLY[i].newlen);
436 ok( !lstrcmpA(newurl, TEST_APPLY[i].newurl),
437 "#%dW: got '%s' (expected '%s')\n", i, newurl, TEST_APPLY[i].newurl);
441 /* buffer too small */
442 lstrcpyA(newurl, untouchedA);
443 len = lstrlenA(TEST_APPLY[0].newurl);
444 res = UrlApplySchemeA(TEST_APPLY[0].url, newurl, &len, TEST_APPLY[0].flags);
445 ok(res == E_POINTER, "got HRESULT 0x%x (expected E_POINTER)\n", res);
446 /* The returned length include the space for the terminating 0 */
447 i = lstrlenA(TEST_APPLY[0].newurl)+1;
448 ok(len == i, "got len %d (expected %d)\n", len, i);
449 ok(!lstrcmpA(newurl, untouchedA), "got '%s' (expected '%s')\n", newurl, untouchedA);
451 /* NULL as parameter. The length and the buffer are not modified */
452 lstrcpyA(newurl, untouchedA);
453 len = TEST_APPLY_MAX_LENGTH;
454 res = UrlApplySchemeA(NULL, newurl, &len, TEST_APPLY[0].flags);
455 ok(res == E_INVALIDARG, "got HRESULT 0x%x (expected E_INVALIDARG)\n", res);
456 ok(len == TEST_APPLY_MAX_LENGTH, "got len %d\n", len);
457 ok(!lstrcmpA(newurl, untouchedA), "got '%s' (expected '%s')\n", newurl, untouchedA);
459 len = TEST_APPLY_MAX_LENGTH;
460 res = UrlApplySchemeA(TEST_APPLY[0].url, NULL, &len, TEST_APPLY[0].flags);
461 ok(res == E_INVALIDARG, "got HRESULT 0x%x (expected E_INVALIDARG)\n", res);
462 ok(len == TEST_APPLY_MAX_LENGTH, "got len %d\n", len);
464 lstrcpyA(newurl, untouchedA);
465 res = UrlApplySchemeA(TEST_APPLY[0].url, newurl, NULL, TEST_APPLY[0].flags);
466 ok(res == E_INVALIDARG, "got HRESULT 0x%x (expected E_INVALIDARG)\n", res);
467 ok(!lstrcmpA(newurl, untouchedA), "got '%s' (expected '%s')\n", newurl, untouchedA);
471 /* ########################### */
473 static void hash_url(const char* szUrl)
475 LPCSTR szTestUrl = szUrl;
476 LPWSTR wszTestUrl = GetWideString(szTestUrl);
478 DWORD cbSize = sizeof(DWORD);
479 DWORD dwHash1, dwHash2;
480 ok(UrlHashA(szTestUrl, (LPBYTE)&dwHash1, cbSize) == S_OK, "UrlHashA didn't return S_OK\n");
481 ok(UrlHashW(wszTestUrl, (LPBYTE)&dwHash2, cbSize) == S_OK, "UrlHashW didn't return S_OK\n");
483 FreeWideString(wszTestUrl);
485 ok(dwHash1 == dwHash2, "Hashes didn't compare\n");
488 static void test_UrlHash(void)
490 hash_url(TEST_URL_1);
491 hash_url(TEST_URL_2);
492 hash_url(TEST_URL_3);
495 /* ########################### */
497 static void test_url_part(const char* szUrl, DWORD dwPart, DWORD dwFlags, const char* szExpected)
499 CHAR szPart[INTERNET_MAX_URL_LENGTH];
500 WCHAR wszPart[INTERNET_MAX_URL_LENGTH];
501 LPWSTR wszUrl = GetWideString(szUrl);
502 LPWSTR wszConvertedPart;
504 DWORD dwSize;
506 dwSize = INTERNET_MAX_URL_LENGTH;
507 ok( UrlGetPartA(szUrl, szPart, &dwSize, dwPart, dwFlags) == S_OK, "UrlGetPartA for \"%s\" part 0x%08x didn't return S_OK but \"%s\"\n", szUrl, dwPart, szPart);
508 dwSize = INTERNET_MAX_URL_LENGTH;
509 ok( UrlGetPartW(wszUrl, wszPart, &dwSize, dwPart, dwFlags) == S_OK, "UrlGetPartW didn't return S_OK\n" );
511 wszConvertedPart = GetWideString(szPart);
513 ok(lstrcmpW(wszPart,wszConvertedPart)==0, "Strings didn't match between ascii and unicode UrlGetPart!\n");
515 FreeWideString(wszUrl);
516 FreeWideString(wszConvertedPart);
518 /* Note that v6.0 and later don't return '?' with the query */
519 ok(strcmp(szPart,szExpected)==0 ||
520 (*szExpected=='?' && !strcmp(szPart,szExpected+1)),
521 "Expected %s, but got %s\n", szExpected, szPart);
524 /* ########################### */
526 static void test_UrlGetPart(void)
528 const char* file_url = "file://h o s t/c:/windows/file";
529 const char* http_url = "http://user:pass 123@www.wine hq.org";
531 CHAR szPart[INTERNET_MAX_URL_LENGTH];
532 DWORD dwSize;
533 HRESULT res;
535 dwSize = sizeof szPart;
536 szPart[0]='x'; szPart[1]=0;
537 res = UrlGetPartA("hi", szPart, &dwSize, URL_PART_SCHEME, 0);
538 todo_wine {
539 ok (res==S_FALSE, "UrlGetPartA(\"hi\") returned %08X\n", res);
540 ok(szPart[0]==0, "UrlGetPartA(\"hi\") return \"%s\" instead of \"\"\n", szPart);
542 dwSize = sizeof szPart;
543 szPart[0]='x'; szPart[1]=0;
544 res = UrlGetPartA("hi", szPart, &dwSize, URL_PART_QUERY, 0);
545 todo_wine {
546 ok (res==S_FALSE, "UrlGetPartA(\"hi\") returned %08X\n", res);
547 ok(szPart[0]==0, "UrlGetPartA(\"hi\") return \"%s\" instead of \"\"\n", szPart);
550 test_url_part(TEST_URL_3, URL_PART_HOSTNAME, 0, "localhost");
551 test_url_part(TEST_URL_3, URL_PART_PORT, 0, "21");
552 test_url_part(TEST_URL_3, URL_PART_USERNAME, 0, "foo");
553 test_url_part(TEST_URL_3, URL_PART_PASSWORD, 0, "bar");
554 test_url_part(TEST_URL_3, URL_PART_SCHEME, 0, "http");
555 test_url_part(TEST_URL_3, URL_PART_QUERY, 0, "?query=x&return=y");
557 test_url_part(file_url, URL_PART_HOSTNAME, 0, "h o s t");
559 test_url_part(http_url, URL_PART_HOSTNAME, 0, "www.wine hq.org");
560 test_url_part(http_url, URL_PART_PASSWORD, 0, "pass 123");
562 dwSize = sizeof(szPart);
563 res = UrlGetPartA("file://c:\\index.htm", szPart, &dwSize, URL_PART_HOSTNAME, 0);
564 ok(res==S_FALSE, "returned %08x\n", res);
566 dwSize = sizeof(szPart);
567 szPart[0] = 'x'; szPart[1] = '\0';
568 res = UrlGetPartA("file:some text", szPart, &dwSize, URL_PART_HOSTNAME, 0);
569 ok(res==S_FALSE, "returned %08x\n", res);
570 ok(szPart[0] == '\0', "szPart[0] = %c\n", szPart[0]);
571 ok(dwSize == 0, "dwSize = %d\n", dwSize);
574 /* ########################### */
576 static void test_url_escape(const char *szUrl, DWORD dwFlags, HRESULT dwExpectReturn, const char *szExpectUrl)
578 CHAR szReturnUrl[INTERNET_MAX_URL_LENGTH];
579 DWORD dwEscaped;
580 WCHAR ret_urlW[INTERNET_MAX_URL_LENGTH];
581 WCHAR *urlW, *expected_urlW;
582 dwEscaped=INTERNET_MAX_URL_LENGTH;
584 ok(UrlEscapeA(szUrl, szReturnUrl, &dwEscaped, dwFlags) == dwExpectReturn, "UrlEscapeA didn't return 0x%08x from \"%s\"\n", dwExpectReturn, szUrl);
585 ok(strcmp(szReturnUrl,szExpectUrl)==0, "Expected \"%s\", but got \"%s\" from \"%s\"\n", szExpectUrl, szReturnUrl, szUrl);
587 dwEscaped = INTERNET_MAX_URL_LENGTH;
588 urlW = GetWideString(szUrl);
589 expected_urlW = GetWideString(szExpectUrl);
590 ok(UrlEscapeW(urlW, ret_urlW, &dwEscaped, dwFlags) == dwExpectReturn, "UrlEscapeW didn't return 0x%08x from \"%s\"\n", dwExpectReturn, szUrl);
591 WideCharToMultiByte(CP_ACP,0,ret_urlW,-1,szReturnUrl,INTERNET_MAX_URL_LENGTH,0,0);
592 ok(lstrcmpW(ret_urlW, expected_urlW)==0, "Expected \"%s\", but got \"%s\" from \"%s\" flags %08x\n", szExpectUrl, szReturnUrl, szUrl, dwFlags);
593 FreeWideString(urlW);
594 FreeWideString(expected_urlW);
598 static void test_url_canonicalize(int index, const char *szUrl, DWORD dwFlags, HRESULT dwExpectReturn, HRESULT dwExpectReturnAlt, const char *szExpectUrl, BOOL todo)
600 CHAR szReturnUrl[INTERNET_MAX_URL_LENGTH];
601 WCHAR wszReturnUrl[INTERNET_MAX_URL_LENGTH];
602 LPWSTR wszUrl = GetWideString(szUrl);
603 LPWSTR wszExpectUrl = GetWideString(szExpectUrl);
604 LPWSTR wszConvertedUrl;
605 HRESULT ret;
607 DWORD dwSize;
609 dwSize = INTERNET_MAX_URL_LENGTH;
610 ok(UrlCanonicalizeA(szUrl, NULL, &dwSize, dwFlags) != dwExpectReturn, "Unexpected return for NULL buffer, index %d\n", index);
611 ret = UrlCanonicalizeA(szUrl, szReturnUrl, &dwSize, dwFlags);
612 ok(ret == dwExpectReturn || ret == dwExpectReturnAlt,
613 "UrlCanonicalizeA failed: expected=0x%08x or 0x%08x, got=0x%08x, index %d\n",
614 dwExpectReturn, dwExpectReturnAlt, ret, index);
615 if (todo)
616 todo_wine
617 ok(strcmp(szReturnUrl,szExpectUrl)==0, "UrlCanonicalizeA dwFlags 0x%08x url '%s' Expected \"%s\", but got \"%s\", index %d\n", dwFlags, szUrl, szExpectUrl, szReturnUrl, index);
618 else
619 ok(strcmp(szReturnUrl,szExpectUrl)==0, "UrlCanonicalizeA dwFlags 0x%08x url '%s' Expected \"%s\", but got \"%s\", index %d\n", dwFlags, szUrl, szExpectUrl, szReturnUrl, index);
621 dwSize = INTERNET_MAX_URL_LENGTH;
622 ok(UrlCanonicalizeW(wszUrl, NULL, &dwSize, dwFlags) != dwExpectReturn, "Unexpected return for NULL buffer, index %d\n", index);
623 ok(UrlCanonicalizeW(wszUrl, wszReturnUrl, &dwSize, dwFlags) == dwExpectReturn, "UrlCanonicalizeW didn't return 0x%08x, index %d\n", dwExpectReturn, index);
624 wszConvertedUrl = GetWideString(szReturnUrl);
625 ok(lstrcmpW(wszReturnUrl, wszConvertedUrl)==0, "Strings didn't match between ascii and unicode UrlCanonicalize, index %d!\n", index);
626 FreeWideString(wszConvertedUrl);
629 FreeWideString(wszUrl);
630 FreeWideString(wszExpectUrl);
634 static void test_UrlEscape(void)
636 DWORD size = 0;
637 HRESULT ret;
638 unsigned int i;
639 char empty_string[] = "";
641 ret = UrlEscapeA("/woningplan/woonkamer basis.swf", NULL, &size, URL_ESCAPE_SPACES_ONLY);
642 ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
643 ok(size == 0, "got %d, expected %d\n", size, 0);
645 size = 0;
646 ret = UrlEscapeA("/woningplan/woonkamer basis.swf", empty_string, &size, URL_ESCAPE_SPACES_ONLY);
647 ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
648 ok(size == 0, "got %d, expected %d\n", size, 0);
650 size = 1;
651 ret = UrlEscapeA("/woningplan/woonkamer basis.swf", NULL, &size, URL_ESCAPE_SPACES_ONLY);
652 ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
653 ok(size == 1, "got %d, expected %d\n", size, 1);
655 size = 1;
656 ret = UrlEscapeA("/woningplan/woonkamer basis.swf", empty_string, NULL, URL_ESCAPE_SPACES_ONLY);
657 ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
658 ok(size == 1, "got %d, expected %d\n", size, 1);
660 size = 1;
661 ret = UrlEscapeA("/woningplan/woonkamer basis.swf", empty_string, &size, URL_ESCAPE_SPACES_ONLY);
662 ok(ret == E_POINTER, "got %x, expected %x\n", ret, E_POINTER);
663 ok(size == 34, "got %d, expected %d\n", size, 34);
665 for(i=0; i<sizeof(TEST_ESCAPE)/sizeof(TEST_ESCAPE[0]); i++) {
666 test_url_escape(TEST_ESCAPE[i].url, TEST_ESCAPE[i].flags,
667 TEST_ESCAPE[i].expectret, TEST_ESCAPE[i].expecturl);
671 /* ########################### */
673 static void test_UrlCanonicalizeA(void)
675 unsigned int i;
676 CHAR szReturnUrl[INTERNET_MAX_URL_LENGTH];
677 DWORD dwSize;
678 DWORD urllen;
679 HRESULT hr;
681 urllen = lstrlenA(winehqA);
683 /* buffer has no space for the result */
684 dwSize=urllen-1;
685 memset(szReturnUrl, '#', urllen+4);
686 szReturnUrl[urllen+4] = '\0';
687 SetLastError(0xdeadbeef);
688 hr = UrlCanonicalizeA(winehqA, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE);
689 ok( (hr == E_POINTER) && (dwSize == (urllen + 1)),
690 "got 0x%x with %u and size %u for '%s' and %u (expected 'E_POINTER' and size %u)\n",
691 hr, GetLastError(), dwSize, szReturnUrl, lstrlenA(szReturnUrl), urllen+1);
693 /* buffer has no space for the terminating '\0' */
694 dwSize=urllen;
695 memset(szReturnUrl, '#', urllen+4);
696 szReturnUrl[urllen+4] = '\0';
697 SetLastError(0xdeadbeef);
698 hr = UrlCanonicalizeA(winehqA, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE);
699 ok( (hr == E_POINTER) && (dwSize == (urllen + 1)),
700 "got 0x%x with %u and size %u for '%s' and %u (expected 'E_POINTER' and size %u)\n",
701 hr, GetLastError(), dwSize, szReturnUrl, lstrlenA(szReturnUrl), urllen+1);
703 /* buffer has the required size */
704 dwSize=urllen+1;
705 memset(szReturnUrl, '#', urllen+4);
706 szReturnUrl[urllen+4] = '\0';
707 SetLastError(0xdeadbeef);
708 hr = UrlCanonicalizeA(winehqA, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE);
709 ok( (hr == S_OK) && (dwSize == urllen),
710 "got 0x%x with %u and size %u for '%s' and %u (expected 'S_OK' and size %u)\n",
711 hr, GetLastError(), dwSize, szReturnUrl, lstrlenA(szReturnUrl), urllen);
713 /* buffer is larger as the required size */
714 dwSize=urllen+2;
715 memset(szReturnUrl, '#', urllen+4);
716 szReturnUrl[urllen+4] = '\0';
717 SetLastError(0xdeadbeef);
718 hr = UrlCanonicalizeA(winehqA, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE);
719 ok( (hr == S_OK) && (dwSize == urllen),
720 "got 0x%x with %u and size %u for '%s' and %u (expected 'S_OK' and size %u)\n",
721 hr, GetLastError(), dwSize, szReturnUrl, lstrlenA(szReturnUrl), urllen);
723 test_url_canonicalize(-1, "", 0, S_OK, S_FALSE /* Vista/win2k8 */, "", FALSE);
725 /* test url-modification */
726 for(i=0; i<sizeof(TEST_CANONICALIZE)/sizeof(TEST_CANONICALIZE[0]); i++) {
727 test_url_canonicalize(i, TEST_CANONICALIZE[i].url, TEST_CANONICALIZE[i].flags,
728 TEST_CANONICALIZE[i].expectret, TEST_CANONICALIZE[i].expectret, TEST_CANONICALIZE[i].expecturl,
729 TEST_CANONICALIZE[i].todo);
733 /* ########################### */
735 static void test_UrlCanonicalizeW(void)
737 WCHAR szReturnUrl[INTERNET_MAX_URL_LENGTH];
738 DWORD dwSize;
739 DWORD urllen;
740 HRESULT hr;
741 int i;
744 if (!pUrlCanonicalizeW) {
745 skip("UrlCanonicalizeW\n");
746 return;
748 urllen = lstrlenW(winehqW);
750 /* buffer has no space for the result */
751 dwSize = (urllen-1);
752 memset(szReturnUrl, '#', (urllen+4) * sizeof(WCHAR));
753 szReturnUrl[urllen+4] = '\0';
754 SetLastError(0xdeadbeef);
755 hr = pUrlCanonicalizeW(winehqW, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE);
756 ok( (hr == E_POINTER) && (dwSize == (urllen + 1)),
757 "got 0x%x with %u and size %u for %u (expected 'E_POINTER' and size %u)\n",
758 hr, GetLastError(), dwSize, lstrlenW(szReturnUrl), urllen+1);
761 /* buffer has no space for the terminating '\0' */
762 dwSize = urllen;
763 memset(szReturnUrl, '#', (urllen+4) * sizeof(WCHAR));
764 szReturnUrl[urllen+4] = '\0';
765 SetLastError(0xdeadbeef);
766 hr = pUrlCanonicalizeW(winehqW, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE);
767 ok( (hr == E_POINTER) && (dwSize == (urllen + 1)),
768 "got 0x%x with %u and size %u for %u (expected 'E_POINTER' and size %u)\n",
769 hr, GetLastError(), dwSize, lstrlenW(szReturnUrl), urllen+1);
771 /* buffer has the required size */
772 dwSize = urllen +1;
773 memset(szReturnUrl, '#', (urllen+4) * sizeof(WCHAR));
774 szReturnUrl[urllen+4] = '\0';
775 SetLastError(0xdeadbeef);
776 hr = pUrlCanonicalizeW(winehqW, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE);
777 ok( (hr == S_OK) && (dwSize == urllen),
778 "got 0x%x with %u and size %u for %u (expected 'S_OK' and size %u)\n",
779 hr, GetLastError(), dwSize, lstrlenW(szReturnUrl), urllen);
781 /* buffer is larger as the required size */
782 dwSize = (urllen+2);
783 memset(szReturnUrl, '#', (urllen+4) * sizeof(WCHAR));
784 szReturnUrl[urllen+4] = '\0';
785 SetLastError(0xdeadbeef);
786 hr = pUrlCanonicalizeW(winehqW, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE);
787 ok( (hr == S_OK) && (dwSize == urllen),
788 "got 0x%x with %u and size %u for %u (expected 'S_OK' and size %u)\n",
789 hr, GetLastError(), dwSize, lstrlenW(szReturnUrl), urllen);
791 /* check that the characters 1..32 are chopped from the end of the string */
792 for (i = 1; i < 65536; i++)
794 WCHAR szUrl[128];
795 BOOL choped;
796 int pos;
798 MultiByteToWideChar(CP_ACP, 0, "http://www.winehq.org/X", -1, szUrl, 128);
799 pos = lstrlenW(szUrl) - 1;
800 szUrl[pos] = i;
801 urllen = INTERNET_MAX_URL_LENGTH;
802 pUrlCanonicalizeW(szUrl, szReturnUrl, &urllen, 0);
803 choped = lstrlenW(szReturnUrl) < lstrlenW(szUrl);
804 ok(choped == (i <= 32), "Incorrect char chopping for char %d\n", i);
808 /* ########################### */
810 static void test_url_combine(const char *szUrl1, const char *szUrl2, DWORD dwFlags, HRESULT dwExpectReturn, const char *szExpectUrl)
812 HRESULT hr;
813 CHAR szReturnUrl[INTERNET_MAX_URL_LENGTH];
814 WCHAR wszReturnUrl[INTERNET_MAX_URL_LENGTH];
815 LPWSTR wszUrl1 = GetWideString(szUrl1);
816 LPWSTR wszUrl2 = GetWideString(szUrl2);
817 LPWSTR wszExpectUrl = GetWideString(szExpectUrl);
818 LPWSTR wszConvertedUrl;
820 DWORD dwSize;
821 DWORD dwExpectLen = lstrlen(szExpectUrl);
823 hr = UrlCombineA(szUrl1, szUrl2, NULL, NULL, dwFlags);
824 ok(hr == E_INVALIDARG, "UrlCombineA returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
826 dwSize = 0;
827 hr = UrlCombineA(szUrl1, szUrl2, NULL, &dwSize, dwFlags);
828 ok(hr == E_POINTER, "Checking length of string, return was 0x%08x, expected 0x%08x\n", hr, E_POINTER);
829 ok(dwSize == dwExpectLen+1, "Got length %d, expected %d\n", dwSize, dwExpectLen+1);
831 dwSize--;
832 hr = UrlCombineA(szUrl1, szUrl2, szReturnUrl, &dwSize, dwFlags);
833 ok(hr == E_POINTER, "UrlCombineA returned 0x%08x, expected 0x%08x\n", hr, E_POINTER);
834 ok(dwSize == dwExpectLen+1, "Got length %d, expected %d\n", dwSize, dwExpectLen+1);
836 hr = UrlCombineA(szUrl1, szUrl2, szReturnUrl, &dwSize, dwFlags);
837 ok(hr == dwExpectReturn, "UrlCombineA returned 0x%08x, expected 0x%08x\n", hr, dwExpectReturn);
838 ok(dwSize == dwExpectLen, "Got length %d, expected %d\n", dwSize, dwExpectLen);
839 if(SUCCEEDED(hr)) {
840 ok(strcmp(szReturnUrl,szExpectUrl)==0, "Expected %s, but got %s\n", szExpectUrl, szReturnUrl);
843 dwSize = 0;
844 hr = UrlCombineW(wszUrl1, wszUrl2, NULL, &dwSize, dwFlags);
845 ok(hr == E_POINTER, "Checking length of string, return was 0x%08x, expected 0x%08x\n", hr, E_POINTER);
846 ok(dwSize == dwExpectLen+1, "Got length %d, expected %d\n", dwSize, dwExpectLen+1);
848 dwSize--;
849 hr = UrlCombineW(wszUrl1, wszUrl2, wszReturnUrl, &dwSize, dwFlags);
850 ok(hr == E_POINTER, "UrlCombineA returned 0x%08x, expected 0x%08x\n", hr, E_POINTER);
851 ok(dwSize == dwExpectLen+1, "Got length %d, expected %d\n", dwSize, dwExpectLen+1);
853 hr = UrlCombineW(wszUrl1, wszUrl2, wszReturnUrl, &dwSize, dwFlags);
854 ok(hr == dwExpectReturn, "UrlCombineW returned 0x%08x, expected 0x%08x\n", hr, dwExpectReturn);
855 ok(dwSize == dwExpectLen, "Got length %d, expected %d\n", dwSize, dwExpectLen);
856 if(SUCCEEDED(hr)) {
857 wszConvertedUrl = GetWideString(szReturnUrl);
858 ok(lstrcmpW(wszReturnUrl, wszConvertedUrl)==0, "Strings didn't match between ascii and unicode UrlCombine!\n");
859 FreeWideString(wszConvertedUrl);
862 FreeWideString(wszUrl1);
863 FreeWideString(wszUrl2);
864 FreeWideString(wszExpectUrl);
867 /* ########################### */
869 static void test_UrlCombine(void)
871 unsigned int i;
872 for(i=0; i<sizeof(TEST_COMBINE)/sizeof(TEST_COMBINE[0]); i++) {
873 test_url_combine(TEST_COMBINE[i].url1, TEST_COMBINE[i].url2, TEST_COMBINE[i].flags,
874 TEST_COMBINE[i].expectret, TEST_COMBINE[i].expecturl);
878 /* ########################### */
880 static void test_UrlCreateFromPath(void)
882 size_t i;
883 char ret_url[INTERNET_MAX_URL_LENGTH];
884 DWORD len, ret;
885 WCHAR ret_urlW[INTERNET_MAX_URL_LENGTH];
886 WCHAR *pathW, *urlW;
888 for(i = 0; i < sizeof(TEST_URLFROMPATH) / sizeof(TEST_URLFROMPATH[0]); i++) {
889 len = INTERNET_MAX_URL_LENGTH;
890 ret = UrlCreateFromPathA(TEST_URLFROMPATH[i].path, ret_url, &len, 0);
891 ok(ret == TEST_URLFROMPATH[i].ret, "ret %08x from path %s\n", ret, TEST_URLFROMPATH[i].path);
892 ok(!lstrcmpi(ret_url, TEST_URLFROMPATH[i].url), "url %s from path %s\n", ret_url, TEST_URLFROMPATH[i].path);
893 ok(len == strlen(ret_url), "ret len %d from path %s\n", len, TEST_URLFROMPATH[i].path);
895 len = INTERNET_MAX_URL_LENGTH;
896 pathW = GetWideString(TEST_URLFROMPATH[i].path);
897 urlW = GetWideString(TEST_URLFROMPATH[i].url);
898 ret = UrlCreateFromPathW(pathW, ret_urlW, &len, 0);
899 WideCharToMultiByte(CP_ACP, 0, ret_urlW, -1, ret_url, sizeof(ret_url),0,0);
900 ok(ret == TEST_URLFROMPATH[i].ret, "ret %08x from path L\"%s\", expected %08x\n",
901 ret, TEST_URLFROMPATH[i].path, TEST_URLFROMPATH[i].ret);
902 ok(!lstrcmpiW(ret_urlW, urlW), "got %s expected %s from path L\"%s\"\n", ret_url, TEST_URLFROMPATH[i].url, TEST_URLFROMPATH[i].path);
903 ok(len == lstrlenW(ret_urlW), "ret len %d from path L\"%s\"\n", len, TEST_URLFROMPATH[i].path);
904 FreeWideString(urlW);
905 FreeWideString(pathW);
909 /* ########################### */
911 static void test_UrlIs(void)
913 BOOL ret;
914 size_t i;
915 WCHAR wurl[80];
917 for(i = 0; i < sizeof(TEST_PATH_IS_URL) / sizeof(TEST_PATH_IS_URL[0]); i++) {
918 MultiByteToWideChar(CP_ACP, 0, TEST_PATH_IS_URL[i].path, -1, wurl, 80);
920 ret = UrlIsA( TEST_PATH_IS_URL[i].path, URLIS_URL );
921 ok( ret == TEST_PATH_IS_URL[i].expect,
922 "returned %d from path %s, expected %d\n", ret, TEST_PATH_IS_URL[i].path,
923 TEST_PATH_IS_URL[i].expect );
925 ret = UrlIsW( wurl, URLIS_URL );
926 ok( ret == TEST_PATH_IS_URL[i].expect,
927 "returned %d from path (UrlIsW) %s, expected %d\n", ret, TEST_PATH_IS_URL[i].path,
928 TEST_PATH_IS_URL[i].expect );
930 for(i = 0; i < sizeof(TEST_URLIS_ATTRIBS) / sizeof(TEST_URLIS_ATTRIBS[0]); i++) {
931 MultiByteToWideChar(CP_ACP, 0, TEST_URLIS_ATTRIBS[i].url, -1, wurl, 80);
933 ret = UrlIsA( TEST_URLIS_ATTRIBS[i].url, URLIS_OPAQUE);
934 ok( ret == TEST_URLIS_ATTRIBS[i].expectOpaque,
935 "returned %d for URLIS_OPAQUE, url \"%s\", expected %d\n", ret, TEST_URLIS_ATTRIBS[i].url,
936 TEST_URLIS_ATTRIBS[i].expectOpaque );
937 ret = UrlIsA( TEST_URLIS_ATTRIBS[i].url, URLIS_FILEURL);
938 ok( ret == TEST_URLIS_ATTRIBS[i].expectFile,
939 "returned %d for URLIS_FILEURL, url \"%s\", expected %d\n", ret, TEST_URLIS_ATTRIBS[i].url,
940 TEST_URLIS_ATTRIBS[i].expectFile );
942 ret = UrlIsW( wurl, URLIS_OPAQUE);
943 ok( ret == TEST_URLIS_ATTRIBS[i].expectOpaque,
944 "returned %d for URLIS_OPAQUE (UrlIsW), url \"%s\", expected %d\n", ret, TEST_URLIS_ATTRIBS[i].url,
945 TEST_URLIS_ATTRIBS[i].expectOpaque );
946 ret = UrlIsW( wurl, URLIS_FILEURL);
947 ok( ret == TEST_URLIS_ATTRIBS[i].expectFile,
948 "returned %d for URLIS_FILEURL (UrlIsW), url \"%s\", expected %d\n", ret, TEST_URLIS_ATTRIBS[i].url,
949 TEST_URLIS_ATTRIBS[i].expectFile );
953 /* ########################### */
955 static void test_UrlUnescape(void)
957 CHAR szReturnUrl[INTERNET_MAX_URL_LENGTH];
958 WCHAR ret_urlW[INTERNET_MAX_URL_LENGTH];
959 WCHAR *urlW, *expected_urlW;
960 DWORD dwEscaped;
961 size_t i;
962 static char inplace[] = "file:///C:/Program%20Files";
963 static char another_inplace[] = "file:///C:/Program%20Files";
964 static const char expected[] = "file:///C:/Program Files";
965 static WCHAR inplaceW[] = {'f','i','l','e',':','/','/','/','C',':','/','P','r','o','g','r','a','m',' ','F','i','l','e','s',0};
966 static WCHAR another_inplaceW[] = {'f','i','l','e',':','/','/','/','C',':','/','P','r','o','g','r','a','m','%','2','0','F','i','l','e','s',0};
968 for(i=0; i<sizeof(TEST_URL_UNESCAPE)/sizeof(TEST_URL_UNESCAPE[0]); i++) {
969 dwEscaped=INTERNET_MAX_URL_LENGTH;
970 ok(UrlUnescapeA(TEST_URL_UNESCAPE[i].url, szReturnUrl, &dwEscaped, 0) == S_OK, "UrlUnescapeA didn't return 0x%08x from \"%s\"\n", S_OK, TEST_URL_UNESCAPE[i].url);
971 ok(strcmp(szReturnUrl,TEST_URL_UNESCAPE[i].expect)==0, "Expected \"%s\", but got \"%s\" from \"%s\"\n", TEST_URL_UNESCAPE[i].expect, szReturnUrl, TEST_URL_UNESCAPE[i].url);
973 ZeroMemory(szReturnUrl, sizeof(szReturnUrl));
974 /* if we set the bufferpointer to NULL here UrlUnescape fails and string gets not converted */
975 ok(UrlUnescapeA(TEST_URL_UNESCAPE[i].url, szReturnUrl, NULL, 0) == E_INVALIDARG, "UrlUnescapeA didn't return 0x%08x from \"%s\"\n", E_INVALIDARG ,TEST_URL_UNESCAPE[i].url);
976 ok(strcmp(szReturnUrl,"")==0, "Expected empty string\n");
978 dwEscaped = INTERNET_MAX_URL_LENGTH;
979 urlW = GetWideString(TEST_URL_UNESCAPE[i].url);
980 expected_urlW = GetWideString(TEST_URL_UNESCAPE[i].expect);
981 ok(UrlUnescapeW(urlW, ret_urlW, &dwEscaped, 0) == S_OK, "UrlUnescapeW didn't return 0x%08x from \"%s\"\n", S_OK, TEST_URL_UNESCAPE[i].url);
982 WideCharToMultiByte(CP_ACP,0,ret_urlW,-1,szReturnUrl,INTERNET_MAX_URL_LENGTH,0,0);
983 ok(lstrcmpW(ret_urlW, expected_urlW)==0, "Expected \"%s\", but got \"%s\" from \"%s\" flags %08lx\n", TEST_URL_UNESCAPE[i].expect, szReturnUrl, TEST_URL_UNESCAPE[i].url, 0L);
984 FreeWideString(urlW);
985 FreeWideString(expected_urlW);
988 dwEscaped = sizeof(inplace);
989 ok(UrlUnescapeA(inplace, NULL, &dwEscaped, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeA failed unexpectedly\n");
990 ok(!strcmp(inplace, expected), "got %s expected %s\n", inplace, expected);
991 ok(dwEscaped == 27, "got %d expected 27\n", dwEscaped);
993 /* if we set the bufferpointer to NULL, the string apparently still gets converted (Google Lively does this)) */
994 ok(UrlUnescapeA(another_inplace, NULL, NULL, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeA failed unexpectedly\n");
995 ok(!strcmp(another_inplace, expected), "got %s expected %s\n", another_inplace, expected);
997 dwEscaped = sizeof(inplaceW);
998 ok(UrlUnescapeW(inplaceW, NULL, &dwEscaped, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeW failed unexpectedly\n");
999 ok(dwEscaped == 50, "got %d expected 50\n", dwEscaped);
1001 /* if we set the bufferpointer to NULL, the string apparently still gets converted (Google Lively does this)) */
1002 ok(UrlUnescapeW(another_inplaceW, NULL, NULL, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeW failed unexpectedly\n");
1003 ok(lstrlenW(another_inplaceW) == 24, "got %d expected 24\n", lstrlenW(another_inplaceW));
1007 static const struct parse_url_test_t {
1008 const char *url;
1009 HRESULT hres;
1010 UINT protocol_len;
1011 UINT scheme;
1012 } parse_url_tests[] = {
1013 {"http://www.winehq.org/",S_OK,4,URL_SCHEME_HTTP},
1014 {"https://www.winehq.org/",S_OK,5,URL_SCHEME_HTTPS},
1015 {"ftp://www.winehq.org/",S_OK,3,URL_SCHEME_FTP},
1016 {"test.txt?test=c:/dir",0x80041001},
1017 {"test.txt",0x80041001},
1018 {"xxx://www.winehq.org/",S_OK,3,URL_SCHEME_UNKNOWN},
1019 {"1xx://www.winehq.org/",S_OK,3,URL_SCHEME_UNKNOWN},
1020 {"-xx://www.winehq.org/",S_OK,3,URL_SCHEME_UNKNOWN},
1021 {"xx0://www.winehq.org/",S_OK,3,URL_SCHEME_UNKNOWN},
1022 {"x://www.winehq.org/",0x80041001},
1023 {"xx$://www.winehq.org/",0x80041001},
1024 {"htt?p://www.winehq.org/",0x80041001},
1025 {"ab-://www.winehq.org/",S_OK,3,URL_SCHEME_UNKNOWN},
1026 {" http://www.winehq.org/",0x80041001},
1029 static void test_ParseURL(void)
1031 const struct parse_url_test_t *test;
1032 WCHAR url[INTERNET_MAX_URL_LENGTH];
1033 PARSEDURLA parseda;
1034 PARSEDURLW parsedw;
1035 HRESULT hres;
1037 for(test = parse_url_tests; test < parse_url_tests + sizeof(parse_url_tests)/sizeof(*parse_url_tests); test++) {
1038 memset(&parseda, 0xd0, sizeof(parseda));
1039 parseda.cbSize = sizeof(parseda);
1040 hres = pParseURLA(test->url, &parseda);
1041 ok(hres == test->hres, "ParseURL failed: %08x, expected %08x\n", hres, test->hres);
1042 if(hres == S_OK) {
1043 ok(parseda.pszProtocol == test->url, "parseda.pszProtocol = %s, expected %s\n",
1044 parseda.pszProtocol, test->url);
1045 ok(parseda.cchProtocol == test->protocol_len, "parseda.cchProtocol = %d, expected %d\n",
1046 parseda.cchProtocol, test->protocol_len);
1047 ok(parseda.pszSuffix == test->url+test->protocol_len+1, "parseda.pszSuffix = %s, expected %s\n",
1048 parseda.pszSuffix, test->url+test->protocol_len+1);
1049 ok(parseda.cchSuffix == strlen(test->url+test->protocol_len+1),
1050 "parseda.pszSuffix = %d, expected %d\n",
1051 parseda.cchSuffix, lstrlenA(test->url+test->protocol_len+1));
1052 ok(parseda.nScheme == test->scheme, "parseda.nScheme = %d, expected %d\n",
1053 parseda.nScheme, test->scheme);
1054 }else {
1055 ok(!parseda.pszProtocol, "parseda.pszProtocol = %p\n", parseda.pszProtocol);
1056 ok(parseda.nScheme == 0xd0d0d0d0, "nScheme = %d\n", parseda.nScheme);
1059 MultiByteToWideChar(CP_ACP, 0, test->url, -1, url, sizeof(url)/sizeof(WCHAR));
1061 memset(&parsedw, 0xd0, sizeof(parsedw));
1062 parsedw.cbSize = sizeof(parsedw);
1063 hres = pParseURLW(url, &parsedw);
1064 ok(hres == test->hres, "ParseURL failed: %08x, expected %08x\n", hres, test->hres);
1065 if(hres == S_OK) {
1066 ok(parsedw.pszProtocol == url, "parsedw.pszProtocol = %s, expected %s\n",
1067 wine_dbgstr_w(parsedw.pszProtocol), wine_dbgstr_w(url));
1068 ok(parsedw.cchProtocol == test->protocol_len, "parsedw.cchProtocol = %d, expected %d\n",
1069 parsedw.cchProtocol, test->protocol_len);
1070 ok(parsedw.pszSuffix == url+test->protocol_len+1, "parsedw.pszSuffix = %s, expected %s\n",
1071 wine_dbgstr_w(parsedw.pszSuffix), wine_dbgstr_w(url+test->protocol_len+1));
1072 ok(parsedw.cchSuffix == strlen(test->url+test->protocol_len+1),
1073 "parsedw.pszSuffix = %d, expected %d\n",
1074 parsedw.cchSuffix, lstrlenA(test->url+test->protocol_len+1));
1075 ok(parsedw.nScheme == test->scheme, "parsedw.nScheme = %d, expected %d\n",
1076 parsedw.nScheme, test->scheme);
1077 }else {
1078 ok(!parsedw.pszProtocol, "parsedw.pszProtocol = %p\n", parseda.pszProtocol);
1079 ok(parsedw.nScheme == 0xd0d0d0d0, "nScheme = %d\n", parsedw.nScheme);
1084 /* ########################### */
1086 START_TEST(url)
1089 hShlwapi = GetModuleHandleA("shlwapi.dll");
1090 pUrlCanonicalizeW = (void *) GetProcAddress(hShlwapi, "UrlCanonicalizeW");
1091 pParseURLA = (void*)GetProcAddress(hShlwapi, (LPCSTR)1);
1092 pParseURLW = (void*)GetProcAddress(hShlwapi, (LPCSTR)2);
1094 test_UrlApplyScheme();
1095 test_UrlHash();
1096 test_UrlGetPart();
1097 test_UrlCanonicalizeA();
1098 test_UrlCanonicalizeW();
1099 test_UrlEscape();
1100 test_UrlCombine();
1101 test_UrlCreateFromPath();
1102 test_UrlIs();
1103 test_UrlUnescape();
1104 test_ParseURL();