2 * Copyright 2005-2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define NONAMELESSUNION
23 #include <wine/test.h>
34 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
36 #define DEFINE_EXPECT(func) \
37 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
39 #define SET_EXPECT(func) \
40 expect_ ## func = TRUE
42 #define CHECK_EXPECT(func) \
44 ok(expect_ ##func, "unexpected call " #func "\n"); \
45 expect_ ## func = FALSE; \
46 called_ ## func = TRUE; \
49 #define CHECK_EXPECT2(func) \
51 ok(expect_ ##func, "unexpected call " #func "\n"); \
52 called_ ## func = TRUE; \
55 #define CHECK_CALLED(func) \
57 ok(called_ ## func, "expected " #func "\n"); \
58 expect_ ## func = called_ ## func = FALSE; \
61 DEFINE_EXPECT(ParseUrl);
62 DEFINE_EXPECT(QI_IInternetProtocolInfo);
63 DEFINE_EXPECT(CreateInstance);
64 DEFINE_EXPECT(unk_Release);
66 static HRESULT (WINAPI *pCoInternetCompareUrl)(LPCWSTR, LPCWSTR, DWORD);
67 static HRESULT (WINAPI *pCoInternetGetSecurityUrl)(LPCWSTR, LPWSTR*, PSUACTION, DWORD);
68 static HRESULT (WINAPI *pCoInternetGetSession)(DWORD, IInternetSession **, DWORD);
69 static HRESULT (WINAPI *pCoInternetParseUrl)(LPCWSTR, PARSEACTION, DWORD, LPWSTR, DWORD, DWORD *, DWORD);
70 static HRESULT (WINAPI *pCoInternetQueryInfo)(LPCWSTR, QUERYOPTION, DWORD, LPVOID, DWORD, DWORD *, DWORD);
71 static HRESULT (WINAPI *pCopyStgMedium)(const STGMEDIUM *, STGMEDIUM *);
72 static HRESULT (WINAPI *pFindMimeFromData)(LPBC, LPCWSTR, LPVOID, DWORD, LPCWSTR,
73 DWORD, LPWSTR*, DWORD);
74 static HRESULT (WINAPI *pObtainUserAgentString)(DWORD, LPSTR, DWORD*);
75 static HRESULT (WINAPI *pReleaseBindInfo)(BINDINFO*);
76 static HRESULT (WINAPI *pUrlMkGetSessionOption)(DWORD, LPVOID, DWORD, DWORD *, DWORD);
79 static void test_CreateFormatEnum(void)
81 IEnumFORMATETC *fenum = NULL, *fenum2 = NULL;
86 static DVTARGETDEVICE dev = {sizeof(dev),0,0,0,0,{0}};
87 static FORMATETC formatetc[] = {
95 hres = CreateFormatEnumerator(0, formatetc, &fenum);
96 ok(hres == E_FAIL, "CreateFormatEnumerator failed: %08x, expected E_FAIL\n", hres);
97 hres = CreateFormatEnumerator(0, formatetc, NULL);
98 ok(hres == E_INVALIDARG, "CreateFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres);
99 hres = CreateFormatEnumerator(5, formatetc, NULL);
100 ok(hres == E_INVALIDARG, "CreateFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres);
103 hres = CreateFormatEnumerator(5, formatetc, &fenum);
104 ok(hres == S_OK, "CreateFormatEnumerator failed: %08x\n", hres);
108 hres = IEnumFORMATETC_Next(fenum, 2, NULL, &ul);
109 ok(hres == E_INVALIDARG, "Next failed: %08x, expected E_INVALIDARG\n", hres);
111 hres = IEnumFORMATETC_Next(fenum, 0, fetc, &ul);
112 ok(hres == S_OK, "Next failed: %08x\n", hres);
113 ok(ul == 0, "ul=%d, expected 0\n", ul);
115 hres = IEnumFORMATETC_Next(fenum, 2, fetc, &ul);
116 ok(hres == S_OK, "Next failed: %08x\n", hres);
117 ok(fetc[0].lindex == 0, "fetc[0].lindex=%d, expected 0\n", fetc[0].lindex);
118 ok(fetc[1].lindex == 1, "fetc[1].lindex=%d, expected 1\n", fetc[1].lindex);
119 ok(fetc[0].ptd == &dev, "fetc[0].ptd=%p, expected %p\n", fetc[0].ptd, &dev);
120 ok(ul == 2, "ul=%d, expected 2\n", ul);
122 hres = IEnumFORMATETC_Skip(fenum, 1);
123 ok(hres == S_OK, "Skip failed: %08x\n", hres);
125 hres = IEnumFORMATETC_Next(fenum, 4, fetc, &ul);
126 ok(hres == S_FALSE, "Next failed: %08x, expected S_FALSE\n", hres);
127 ok(fetc[0].lindex == 3, "fetc[0].lindex=%d, expected 3\n", fetc[0].lindex);
128 ok(fetc[1].lindex == 4, "fetc[1].lindex=%d, expected 4\n", fetc[1].lindex);
129 ok(fetc[0].ptd == NULL, "fetc[0].ptd=%p, expected NULL\n", fetc[0].ptd);
130 ok(ul == 2, "ul=%d, expected 2\n", ul);
132 hres = IEnumFORMATETC_Next(fenum, 4, fetc, &ul);
133 ok(hres == S_FALSE, "Next failed: %08x, expected S_FALSE\n", hres);
134 ok(ul == 0, "ul=%d, expected 0\n", ul);
136 hres = IEnumFORMATETC_Next(fenum, 0, fetc, &ul);
137 ok(hres == S_OK, "Next failed: %08x\n", hres);
138 ok(ul == 0, "ul=%d, expected 0\n", ul);
140 hres = IEnumFORMATETC_Skip(fenum, 3);
141 ok(hres == S_FALSE, "Skip failed: %08x, expected S_FALSE\n", hres);
143 hres = IEnumFORMATETC_Reset(fenum);
144 ok(hres == S_OK, "Reset failed: %08x\n", hres);
146 hres = IEnumFORMATETC_Next(fenum, 5, fetc, NULL);
147 ok(hres == S_OK, "Next failed: %08x\n", hres);
148 ok(fetc[0].lindex == 0, "fetc[0].lindex=%d, expected 0\n", fetc[0].lindex);
150 hres = IEnumFORMATETC_Reset(fenum);
151 ok(hres == S_OK, "Reset failed: %08x\n", hres);
153 hres = IEnumFORMATETC_Skip(fenum, 2);
154 ok(hres == S_OK, "Skip failed: %08x\n", hres);
156 hres = IEnumFORMATETC_Clone(fenum, NULL);
157 ok(hres == E_INVALIDARG, "Clone failed: %08x, expected E_INVALIDARG\n", hres);
159 hres = IEnumFORMATETC_Clone(fenum, &fenum2);
160 ok(hres == S_OK, "Clone failed: %08x\n", hres);
162 if(SUCCEEDED(hres)) {
163 ok(fenum != fenum2, "fenum == fenum2\n");
165 hres = IEnumFORMATETC_Next(fenum2, 2, fetc, &ul);
166 ok(hres == S_OK, "Next failed: %08x\n", hres);
167 ok(fetc[0].lindex == 2, "fetc[0].lindex=%d, expected 2\n", fetc[0].lindex);
169 IEnumFORMATETC_Release(fenum2);
172 hres = IEnumFORMATETC_Next(fenum, 2, fetc, &ul);
173 ok(hres == S_OK, "Next failed: %08x\n", hres);
174 ok(fetc[0].lindex == 2, "fetc[0].lindex=%d, expected 2\n", fetc[0].lindex);
176 hres = IEnumFORMATETC_Skip(fenum, 1);
177 ok(hres == S_OK, "Skip failed: %08x\n", hres);
179 IEnumFORMATETC_Release(fenum);
182 static void test_RegisterFormatEnumerator(void)
184 IBindCtx *bctx = NULL;
185 IEnumFORMATETC *format = NULL, *format2 = NULL;
186 IUnknown *unk = NULL;
189 static FORMATETC formatetc = {0,NULL,0,0,0};
190 static WCHAR wszEnumFORMATETC[] =
191 {'_','E','n','u','m','F','O','R','M','A','T','E','T','C','_',0};
193 CreateBindCtx(0, &bctx);
195 hres = CreateFormatEnumerator(1, &formatetc, &format);
196 ok(hres == S_OK, "CreateFormatEnumerator failed: %08x\n", hres);
200 hres = RegisterFormatEnumerator(NULL, format, 0);
201 ok(hres == E_INVALIDARG,
202 "RegisterFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres);
203 hres = RegisterFormatEnumerator(bctx, NULL, 0);
204 ok(hres == E_INVALIDARG,
205 "RegisterFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres);
207 hres = RegisterFormatEnumerator(bctx, format, 0);
208 ok(hres == S_OK, "RegisterFormatEnumerator failed: %08x\n", hres);
210 hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
211 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
212 ok(unk == (IUnknown*)format, "unk != format\n");
214 hres = RevokeFormatEnumerator(NULL, format);
215 ok(hres == E_INVALIDARG,
216 "RevokeFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres);
218 hres = RevokeFormatEnumerator(bctx, format);
219 ok(hres == S_OK, "RevokeFormatEnumerator failed: %08x\n", hres);
221 hres = RevokeFormatEnumerator(bctx, format);
222 ok(hres == E_FAIL, "RevokeFormatEnumerator failed: %08x, expected E_FAIL\n", hres);
224 hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
225 ok(hres == E_FAIL, "GetObjectParam failed: %08x, expected E_FAIL\n", hres);
227 hres = RegisterFormatEnumerator(bctx, format, 0);
228 ok(hres == S_OK, "RegisterFormatEnumerator failed: %08x\n", hres);
230 hres = CreateFormatEnumerator(1, &formatetc, &format2);
231 ok(hres == S_OK, "CreateFormatEnumerator failed: %08x\n", hres);
233 if(SUCCEEDED(hres)) {
234 hres = RevokeFormatEnumerator(bctx, format);
235 ok(hres == S_OK, "RevokeFormatEnumerator failed: %08x\n", hres);
237 IEnumFORMATETC_Release(format2);
240 hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
241 ok(hres == E_FAIL, "GetObjectParam failed: %08x, expected E_FAIL\n", hres);
243 IEnumFORMATETC_Release(format);
245 hres = RegisterFormatEnumerator(bctx, format, 0);
246 ok(hres == S_OK, "RegisterFormatEnumerator failed: %08x\n", hres);
247 hres = RevokeFormatEnumerator(bctx, NULL);
248 ok(hres == S_OK, "RevokeFormatEnumerator failed: %08x\n", hres);
249 hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
250 ok(hres == E_FAIL, "GetObjectParam failed: %08x, expected E_FAIL\n", hres);
252 IEnumFORMATETC_Release(format);
253 IBindCtx_Release(bctx);
256 static const WCHAR url1[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',
257 '/','b','l','a','n','k','.','h','t','m',0};
258 static const WCHAR url2[] = {'i','n','d','e','x','.','h','t','m',0};
259 static const WCHAR url3[] = {'f','i','l','e',':','/','/','c',':','\\','I','n','d','e','x','.','h','t','m',0};
260 static const WCHAR url4[] = {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e',
261 '%','2','e','j','p','g',0};
262 static const WCHAR url5[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
264 static const WCHAR url6[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
265 static const WCHAR url7[] = {'f','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g','/',
266 'f','i','l','e','.','t','e','s','t',0};
267 static const WCHAR url8[] = {'t','e','s','t',':','1','2','3','a','b','c',0};
268 static const WCHAR url9[] =
269 {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',
270 '/','s','i','t','e','/','a','b','o','u','t',0};
271 static const WCHAR url10[] = {'f','i','l','e',':','/','/','s','o','m','e','%','2','0','f','i','l','e',
274 static const WCHAR url4e[] = {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e',
277 static const WCHAR path3[] = {'c',':','\\','I','n','d','e','x','.','h','t','m',0};
278 static const WCHAR path4[] = {'s','o','m','e',' ','f','i','l','e','.','j','p','g',0};
280 static const WCHAR wszRes[] = {'r','e','s',0};
281 static const WCHAR wszFile[] = {'f','i','l','e',0};
282 static const WCHAR wszHttp[] = {'h','t','t','p',0};
283 static const WCHAR wszAbout[] = {'a','b','o','u','t',0};
284 static const WCHAR wszEmpty[] = {0};
286 static const WCHAR wszWineHQ[] = {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
287 static const WCHAR wszHttpWineHQ[] = {'h','t','t','p',':','/','/','w','w','w','.',
288 'w','i','n','e','h','q','.','o','r','g',0};
299 LPCWSTR rootdocument;
300 HRESULT rootdocument_hres;
303 static const struct parse_test parse_tests[] = {
304 {url1, S_OK, url1, E_INVALIDARG, NULL, wszRes, NULL, E_FAIL, NULL, E_FAIL},
305 {url2, E_FAIL, url2, E_INVALIDARG, NULL, wszEmpty, NULL, E_FAIL, NULL, E_FAIL},
306 {url3, E_FAIL, url3, S_OK, path3, wszFile, wszEmpty, S_OK, NULL, E_FAIL},
307 {url4, E_FAIL, url4e, S_OK, path4, wszFile, wszEmpty, S_OK, NULL, E_FAIL},
308 {url5, E_FAIL, url5, E_INVALIDARG, NULL, wszHttp, wszWineHQ, S_OK, wszHttpWineHQ, S_OK},
309 {url6, S_OK, url6, E_INVALIDARG, NULL, wszAbout, NULL, E_FAIL, NULL, E_FAIL},
312 static void test_CoInternetParseUrl(void)
318 static WCHAR buf[4096];
320 if (!pCoInternetParseUrl) {
324 memset(buf, 0xf0, sizeof(buf));
325 hres = pCoInternetParseUrl(parse_tests[0].url, PARSE_SCHEMA, 0, buf,
327 ok(hres == E_POINTER, "schema failed: %08x, expected E_POINTER\n", hres);
329 for(i=0; i < sizeof(parse_tests)/sizeof(parse_tests[0]); i++) {
330 memset(buf, 0xf0, sizeof(buf));
331 hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_SECURITY_URL, 0, buf,
332 sizeof(buf)/sizeof(WCHAR), &size, 0);
333 ok(hres == parse_tests[i].secur_hres, "[%d] security url failed: %08x, expected %08x\n",
334 i, hres, parse_tests[i].secur_hres);
336 memset(buf, 0xf0, sizeof(buf));
337 hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_ENCODE, 0, buf,
338 sizeof(buf)/sizeof(WCHAR), &size, 0);
339 ok(hres == S_OK, "[%d] encoding failed: %08x\n", i, hres);
340 ok(size == lstrlenW(parse_tests[i].encoded_url), "[%d] wrong size\n", i);
341 ok(!lstrcmpW(parse_tests[i].encoded_url, buf), "[%d] wrong encoded url\n", i);
343 memset(buf, 0xf0, sizeof(buf));
344 hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_PATH_FROM_URL, 0, buf,
345 sizeof(buf)/sizeof(WCHAR), &size, 0);
346 ok(hres == parse_tests[i].path_hres, "[%d] path failed: %08x, expected %08x\n",
347 i, hres, parse_tests[i].path_hres);
348 if(parse_tests[i].path) {
349 ok(size == lstrlenW(parse_tests[i].path), "[%d] wrong size\n", i);
350 ok(!lstrcmpW(parse_tests[i].path, buf), "[%d] wrong path\n", i);
353 memset(buf, 0xf0, sizeof(buf));
354 hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_SCHEMA, 0, buf,
355 sizeof(buf)/sizeof(WCHAR), &size, 0);
356 ok(hres == S_OK, "[%d] schema failed: %08x\n", i, hres);
357 ok(size == lstrlenW(parse_tests[i].schema), "[%d] wrong size\n", i);
358 ok(!lstrcmpW(parse_tests[i].schema, buf), "[%d] wrong schema\n", i);
360 if(memcmp(parse_tests[i].url, wszRes, 3*sizeof(WCHAR))
361 && memcmp(parse_tests[i].url, wszAbout, 5*sizeof(WCHAR))) {
362 memset(buf, 0xf0, sizeof(buf));
363 hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_DOMAIN, 0, buf,
364 sizeof(buf)/sizeof(WCHAR), &size, 0);
365 ok(hres == parse_tests[i].domain_hres, "[%d] domain failed: %08x\n", i, hres);
366 if(parse_tests[i].domain)
367 ok(!lstrcmpW(parse_tests[i].domain, buf), "[%d] wrong domain, received %s\n", i, wine_dbgstr_w(buf));
370 memset(buf, 0xf0, sizeof(buf));
371 hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_ROOTDOCUMENT, 0, buf,
372 sizeof(buf)/sizeof(WCHAR), &size, 0);
373 ok(hres == parse_tests[i].rootdocument_hres, "[%d] rootdocument failed: %08x\n", i, hres);
374 if(parse_tests[i].rootdocument)
375 ok(!lstrcmpW(parse_tests[i].rootdocument, buf), "[%d] wrong rootdocument, received %s\n", i, wine_dbgstr_w(buf));
379 static void test_CoInternetCompareUrl(void)
383 if (!pCoInternetCompareUrl) {
387 hres = pCoInternetCompareUrl(url1, url1, 0);
388 ok(hres == S_OK, "CoInternetCompareUrl failed: %08x\n", hres);
390 hres = pCoInternetCompareUrl(url1, url3, 0);
391 ok(hres == S_FALSE, "CoInternetCompareUrl failed: %08x\n", hres);
393 hres = pCoInternetCompareUrl(url3, url1, 0);
394 ok(hres == S_FALSE, "CoInternetCompareUrl failed: %08x\n", hres);
397 static const struct {
400 } query_info_tests[] = {
411 static void test_CoInternetQueryInfo(void)
417 if (!pCoInternetQueryInfo) {
421 for(i=0; i < sizeof(query_info_tests)/sizeof(query_info_tests[0]); i++) {
423 memset(buf, '?', sizeof(buf));
424 hres = pCoInternetQueryInfo(query_info_tests[0].url, QUERY_USES_NETWORK, 0, buf, sizeof(buf), &cb, 0);
425 ok(hres == S_OK, "[%d] CoInternetQueryInfo failed: %08x\n", i, hres);
426 ok(cb == sizeof(DWORD), "[%d] cb = %d\n", i, cb);
427 ok(*(DWORD*)buf == query_info_tests[i].uses_net, "[%d] ret %x, expected %x\n",
428 i, *(DWORD*)buf, query_info_tests[i].uses_net);
430 hres = pCoInternetQueryInfo(query_info_tests[0].url, QUERY_USES_NETWORK, 0, buf, 3, &cb, 0);
431 ok(hres == E_FAIL, "[%d] CoInternetQueryInfo failed: %08x, expected E_FAIL\n", i, hres);
432 hres = pCoInternetQueryInfo(query_info_tests[0].url, QUERY_USES_NETWORK, 0, NULL, sizeof(buf), &cb, 0);
433 ok(hres == E_FAIL, "[%d] CoInternetQueryInfo failed: %08x, expected E_FAIL\n", i, hres);
435 memset(buf, '?', sizeof(buf));
436 hres = pCoInternetQueryInfo(query_info_tests[0].url, QUERY_USES_NETWORK, 0, buf, sizeof(buf), NULL, 0);
437 ok(hres == S_OK, "[%d] CoInternetQueryInfo failed: %08x\n", i, hres);
438 ok(*(DWORD*)buf == query_info_tests[i].uses_net, "[%d] ret %x, expected %x\n",
439 i, *(DWORD*)buf, query_info_tests[i].uses_net);
443 static const WCHAR mimeTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
444 static const WCHAR mimeTextPlain[] = {'t','e','x','t','/','p','l','a','i','n',0};
445 static const WCHAR mimeTextRichtext[] = {'t','e','x','t','/','r','i','c','h','t','e','x','t',0};
446 static const WCHAR mimeAppOctetStream[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
447 'o','c','t','e','t','-','s','t','r','e','a','m',0};
448 static const WCHAR mimeImagePjpeg[] = {'i','m','a','g','e','/','p','j','p','e','g',0};
449 static const WCHAR mimeImageGif[] = {'i','m','a','g','e','/','g','i','f',0};
450 static const WCHAR mimeImageBmp[] = {'i','m','a','g','e','/','b','m','p',0};
451 static const WCHAR mimeImageXPng[] = {'i','m','a','g','e','/','x','-','p','n','g',0};
452 static const WCHAR mimeImageTiff[] = {'i','m','a','g','e','/','t','i','f','f',0};
453 static const WCHAR mimeVideoAvi[] = {'v','i','d','e','o','/','a','v','i',0};
454 static const WCHAR mimeVideoMpeg[] = {'v','i','d','e','o','/','m','p','e','g',0};
455 static const WCHAR mimeAppPostscript[] =
456 {'a','p','p','l','i','c','a','t','i','o','n','/','p','o','s','t','s','c','r','i','p','t',0};
457 static const WCHAR mimeAppXCompressed[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
458 'x','-','c','o','m','p','r','e','s','s','e','d',0};
459 static const WCHAR mimeAppXZip[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
460 'x','-','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0};
461 static const WCHAR mimeAppXGzip[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
462 'x','-','g','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0};
463 static const WCHAR mimeAppJava[] = {'a','p','p','l','i','c','a','t','i','o','n','/','j','a','v','a',0};
464 static const WCHAR mimeAppPdf[] = {'a','p','p','l','i','c','a','t','i','o','n','/','p','d','f',0};
465 static const WCHAR mimeAppXMSDownload[] =
466 {'a','p','p','l','i','c','a','t','i','o','n','/','x','-','m','s','d','o','w','n','l','o','a','d',0};
467 static const WCHAR mimeAudioWav[] = {'a','u','d','i','o','/','w','a','v',0};
468 static const WCHAR mimeAudioBasic[] = {'a','u','d','i','o','/','b','a','s','i','c',0};
470 static const struct {
475 {url1, mimeTextHtml, S_OK},
476 {url2, mimeTextHtml, S_OK},
477 {url3, mimeTextHtml, S_OK},
478 {url4, NULL, E_FAIL},
479 {url5, NULL, __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)},
480 {url6, NULL, E_FAIL},
481 {url7, NULL, __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)}
484 static BYTE data1[] = "test data\n";
485 static BYTE data2[] = {31,'t','e','s',0xfa,'t',' ','d','a','t','a','\n',0};
486 static BYTE data3[] = {0,0,0};
487 static BYTE data4[] = {'t','e','s',0xfa,'t',' ','d','a','t','a','\n',0,0};
488 static BYTE data5[] = {0xa,0xa,0xa,'x',32,'x',0};
489 static BYTE data6[] = {0xfa,0xfa,0xfa,0xfa,'\n','\r','\t','x','x','x',1};
490 static BYTE data7[] = "<html>blahblah";
491 static BYTE data8[] = {'t','e','s',0xfa,'t',' ','<','h','t','m','l','>','d','a','t','a','\n',0,0};
492 static BYTE data9[] = {'t','e',0,'s',0xfa,'t',' ','<','h','t','m','l','>','d','a','t','a','\n',0,0};
493 static BYTE data10[] = "<HtmL>blahblah";
494 static BYTE data11[] = "blah<HTML>blahblah";
495 static BYTE data12[] = "blah<HTMLblahblah";
496 static BYTE data13[] = "blahHTML>blahblah";
497 static BYTE data14[] = "blah<HTMblahblah";
498 static BYTE data15[] = {0xff,0xd8};
499 static BYTE data16[] = {0xff,0xd8,'h'};
500 static BYTE data17[] = {0,0xff,0xd8};
501 static BYTE data18[] = {0xff,0xd8,'<','h','t','m','l','>'};
502 static BYTE data19[] = {'G','I','F','8','7','a'};
503 static BYTE data20[] = {'G','I','F','8','9','a'};
504 static BYTE data21[] = {'G','I','F','8','7'};
505 static BYTE data22[] = {'G','i','F','8','7','a'};
506 static BYTE data23[] = {'G','i','F','8','8','a'};
507 static BYTE data24[] = {'g','i','f','8','7','a'};
508 static BYTE data25[] = {'G','i','F','8','7','A'};
509 static BYTE data26[] = {'G','i','F','8','7','a','<','h','t','m','l','>'};
510 static BYTE data27[] = {0x30,'G','i','F','8','7','A'};
511 static BYTE data28[] = {0x42,0x4d,0x6e,0x42,0x1c,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00};
512 static BYTE data29[] = {0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'x','x','x','x'};
513 static BYTE data30[] = {0x42,0x4d,'x','x','x','x',0x00,0x01,0x00,0x00,'x','x','x','x'};
514 static BYTE data31[] = {0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'<','h','t','m','l','>'};
515 static BYTE data32[] = {0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'x','x','x'};
516 static BYTE data33[] = {0x00,0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'x','x','x'};
517 static BYTE data34[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'x'};
518 static BYTE data35[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'x','x','x','x',0};
519 static BYTE data36[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,'x','x'};
520 static BYTE data37[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'<','h','t','m','l','>'};
521 static BYTE data38[] = {0x00,0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'x'};
522 static BYTE data39[] = {0x4d,0x4d,0x00,0x2a};
523 static BYTE data40[] = {0x4d,0x4d,0x00,0x2a,'<','h','t','m','l','>',0};
524 static BYTE data41[] = {0x4d,0x4d,0xff};
525 static BYTE data42[] = {0x4d,0x4d};
526 static BYTE data43[] = {0x00,0x4d,0x4d,0x00};
527 static BYTE data44[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x20,0xff};
528 static BYTE data45[] = {'R','I','F','f',0xff,0xff,0xff,0xff,'A','V','I',0x20,0xff};
529 static BYTE data46[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x20};
530 static BYTE data47[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x21,0xff};
531 static BYTE data48[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x20,'<','h','t','m','l','>'};
532 static BYTE data49[] = {'R','I','F','F',0x0f,0x0f,0xf0,0xf0,'A','V','I',0x20,0xf0,0x00};
533 static BYTE data50[] = {0x00,0x00,0x01,0xb3,0xff};
534 static BYTE data51[] = {0x00,0x00,0x01,0xba,0xff};
535 static BYTE data52[] = {0x00,0x00,0x01,0xb8,0xff};
536 static BYTE data53[] = {0x00,0x00,0x01,0xba};
537 static BYTE data54[] = {0x00,0x00,0x01,0xba,'<','h','t','m','l','>'};
538 static BYTE data55[] = {0x1f,0x8b,'x'};
539 static BYTE data56[] = {0x1f};
540 static BYTE data57[] = {0x1f,0x8b,'<','h','t','m','l','>','t','e','s','t',0};
541 static BYTE data58[] = {0x1f,0x8b};
542 static BYTE data59[] = {0x50,0x4b,'x'};
543 static BYTE data60[] = {0x50,0x4b};
544 static BYTE data61[] = {0x50,0x4b,'<','h','t','m','l','>',0};
545 static BYTE data62[] = {0xca,0xfe,0xba,0xbe,'x'};
546 static BYTE data63[] = {0xca,0xfe,0xba,0xbe};
547 static BYTE data64[] = {0xca,0xfe,0xba,0xbe,'<','h','t','m','l','>',0};
548 static BYTE data65[] = {0x25,0x50,0x44,0x46,'x'};
549 static BYTE data66[] = {0x25,0x50,0x44,0x46};
550 static BYTE data67[] = {0x25,0x50,0x44,0x46,'x','<','h','t','m','l','>'};
551 static BYTE data68[] = {'M','Z','x'};
552 static BYTE data69[] = {'M','Z'};
553 static BYTE data70[] = {'M','Z','<','h','t','m','l','>',0xff};
554 static BYTE data71[] = {'{','\\','r','t','f',0};
555 static BYTE data72[] = {'{','\\','r','t','f'};
556 static BYTE data73[] = {' ','{','\\','r','t','f',' '};
557 static BYTE data74[] = {'{','\\','r','t','f','<','h','t','m','l','>',' '};
558 static BYTE data75[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'W','A','V','E',0xff};
559 static BYTE data76[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'W','A','V','E'};
560 static BYTE data77[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'W','A','V',0xff,0xff};
561 static BYTE data78[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'<','h','t','m','l','>',0xff};
562 static BYTE data79[] = {'%','!',0xff};
563 static BYTE data80[] = {'%','!'};
564 static BYTE data81[] = {'%','!','P','S','<','h','t','m','l','>'};
565 static BYTE data82[] = {'.','s','n','d',0};
566 static BYTE data83[] = {'.','s','n','d'};
567 static BYTE data84[] = {'.','s','n','d',0,'<','h','t','m','l','>',1,1};
568 static BYTE data85[] = {'.','S','N','D',0};
570 static const struct {
573 LPCWSTR mime, mime_alt;
575 {data1, sizeof(data1), mimeTextPlain},
576 {data2, sizeof(data2), mimeAppOctetStream},
577 {data3, sizeof(data3), mimeAppOctetStream},
578 {data4, sizeof(data4), mimeAppOctetStream},
579 {data5, sizeof(data5), mimeTextPlain},
580 {data6, sizeof(data6), mimeTextPlain},
581 {data7, sizeof(data7), mimeTextHtml, mimeTextPlain /* IE8 */},
582 {data8, sizeof(data8), mimeTextHtml, mimeTextPlain /* IE8 */},
583 {data9, sizeof(data9), mimeTextHtml, mimeImagePjpeg /* IE8 */},
584 {data10, sizeof(data10), mimeTextHtml, mimeTextPlain /* IE8 */},
585 {data11, sizeof(data11), mimeTextHtml, mimeTextPlain /* IE8 */},
586 {data12, sizeof(data12), mimeTextHtml, mimeTextPlain /* IE8 */},
587 {data13, sizeof(data13), mimeTextPlain},
588 {data14, sizeof(data14), mimeTextPlain},
589 {data15, sizeof(data15), mimeTextPlain},
590 {data16, sizeof(data16), mimeImagePjpeg},
591 {data17, sizeof(data17), mimeAppOctetStream},
592 {data18, sizeof(data18), mimeTextHtml},
593 {data19, sizeof(data19), mimeImageGif},
594 {data20, sizeof(data20), mimeImageGif},
595 {data21, sizeof(data21), mimeTextPlain},
596 {data22, sizeof(data22), mimeImageGif},
597 {data23, sizeof(data23), mimeTextPlain},
598 {data24, sizeof(data24), mimeImageGif},
599 {data25, sizeof(data25), mimeImageGif},
600 {data26, sizeof(data26), mimeTextHtml, mimeImageGif /* IE8 */},
601 {data27, sizeof(data27), mimeTextPlain},
602 {data28, sizeof(data28), mimeImageBmp},
603 {data29, sizeof(data29), mimeImageBmp},
604 {data30, sizeof(data30), mimeAppOctetStream},
605 {data31, sizeof(data31), mimeTextHtml, mimeImageBmp /* IE8 */},
606 {data32, sizeof(data32), mimeAppOctetStream},
607 {data33, sizeof(data33), mimeAppOctetStream},
608 {data34, sizeof(data34), mimeImageXPng},
609 {data35, sizeof(data35), mimeImageXPng},
610 {data36, sizeof(data36), mimeAppOctetStream},
611 {data37, sizeof(data37), mimeTextHtml, mimeImageXPng /* IE8 */},
612 {data38, sizeof(data38), mimeAppOctetStream},
613 {data39, sizeof(data39), mimeImageTiff},
614 {data40, sizeof(data40), mimeTextHtml, mimeImageTiff /* IE8 */},
615 {data41, sizeof(data41), mimeImageTiff},
616 {data42, sizeof(data42), mimeTextPlain},
617 {data43, sizeof(data43), mimeAppOctetStream},
618 {data44, sizeof(data44), mimeVideoAvi},
619 {data45, sizeof(data45), mimeTextPlain},
620 {data46, sizeof(data46), mimeTextPlain},
621 {data47, sizeof(data47), mimeTextPlain},
622 {data48, sizeof(data48), mimeTextHtml, mimeVideoAvi /* IE8 */},
623 {data49, sizeof(data49), mimeVideoAvi},
624 {data50, sizeof(data50), mimeVideoMpeg},
625 {data51, sizeof(data51), mimeVideoMpeg},
626 {data52, sizeof(data52), mimeAppOctetStream},
627 {data53, sizeof(data53), mimeAppOctetStream},
628 {data54, sizeof(data54), mimeTextHtml, mimeVideoMpeg /* IE8 */},
629 {data55, sizeof(data55), mimeAppXGzip},
630 {data56, sizeof(data56), mimeTextPlain},
631 {data57, sizeof(data57), mimeTextHtml, mimeAppXGzip /* IE8 */},
632 {data58, sizeof(data58), mimeAppOctetStream},
633 {data59, sizeof(data59), mimeAppXZip},
634 {data60, sizeof(data60), mimeTextPlain},
635 {data61, sizeof(data61), mimeTextHtml, mimeAppXZip /* IE8 */},
636 {data62, sizeof(data62), mimeAppJava},
637 {data63, sizeof(data63), mimeTextPlain},
638 {data64, sizeof(data64), mimeTextHtml, mimeAppJava /* IE8 */},
639 {data65, sizeof(data65), mimeAppPdf},
640 {data66, sizeof(data66), mimeTextPlain},
641 {data67, sizeof(data67), mimeTextHtml, mimeAppPdf /* IE8 */},
642 {data68, sizeof(data68), mimeAppXMSDownload},
643 {data69, sizeof(data69), mimeTextPlain},
644 {data70, sizeof(data70), mimeTextHtml, mimeAppXMSDownload /* IE8 */},
645 {data71, sizeof(data71), mimeTextRichtext},
646 {data72, sizeof(data72), mimeTextPlain},
647 {data73, sizeof(data73), mimeTextPlain},
648 {data74, sizeof(data74), mimeTextHtml, mimeTextRichtext /* IE8 */},
649 {data75, sizeof(data75), mimeAudioWav},
650 {data76, sizeof(data76), mimeTextPlain},
651 {data77, sizeof(data77), mimeTextPlain},
652 {data78, sizeof(data78), mimeTextHtml, mimeTextPlain /* IE8 */},
653 {data79, sizeof(data79), mimeAppPostscript},
654 {data80, sizeof(data80), mimeTextPlain},
655 {data81, sizeof(data81), mimeTextHtml, mimeAppPostscript /* IE8 */},
656 {data82, sizeof(data82), mimeAudioBasic},
657 {data83, sizeof(data83), mimeTextPlain},
658 {data84, sizeof(data84), mimeTextHtml, mimeAudioBasic /* IE8 */},
659 {data85, sizeof(data85), mimeTextPlain}
662 static void test_FindMimeFromData(void)
668 if (!pFindMimeFromData) {
672 for(i=0; i<sizeof(mime_tests)/sizeof(mime_tests[0]); i++) {
673 mime = (LPWSTR)0xf0f0f0f0;
674 hres = pFindMimeFromData(NULL, mime_tests[i].url, NULL, 0, NULL, 0, &mime, 0);
675 if(mime_tests[i].mime) {
676 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
677 ok(!lstrcmpW(mime, mime_tests[i].mime), "[%d] wrong mime\n", i);
680 ok(hres == E_FAIL || hres == mime_tests[i].hres,
681 "[%d] FindMimeFromData failed: %08x, expected %08x\n",
682 i, hres, mime_tests[i].hres);
683 ok(mime == (LPWSTR)0xf0f0f0f0, "[%d] mime != 0xf0f0f0f0\n", i);
686 mime = (LPWSTR)0xf0f0f0f0;
687 hres = pFindMimeFromData(NULL, mime_tests[i].url, NULL, 0, mimeTextPlain, 0, &mime, 0);
688 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
689 ok(!lstrcmpW(mime, mimeTextPlain), "[%d] wrong mime\n", i);
692 mime = (LPWSTR)0xf0f0f0f0;
693 hres = pFindMimeFromData(NULL, mime_tests[i].url, NULL, 0, mimeAppOctetStream, 0, &mime, 0);
694 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
695 ok(!lstrcmpW(mime, mimeAppOctetStream), "[%d] wrong mime\n", i);
699 for(i=0; i < sizeof(mime_tests2)/sizeof(mime_tests2[0]); i++) {
700 hres = pFindMimeFromData(NULL, NULL, mime_tests2[i].data, mime_tests2[i].size,
702 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
703 ok(!lstrcmpW(mime, mime_tests2[i].mime), "[%d] wrong mime: %s\n", i, wine_dbgstr_w(mime));
706 hres = pFindMimeFromData(NULL, NULL, mime_tests2[i].data, mime_tests2[i].size,
707 mimeTextHtml, 0, &mime, 0);
708 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
709 if(!lstrcmpW(mimeAppOctetStream, mime_tests2[i].mime)
710 || !lstrcmpW(mimeTextPlain, mime_tests2[i].mime))
711 ok(!lstrcmpW(mime, mimeTextHtml), "[%d] wrong mime\n", i);
713 ok(!lstrcmpW(mime, mime_tests2[i].mime), "[%d] wrong mime\n", i);
716 hres = pFindMimeFromData(NULL, NULL, mime_tests2[i].data, mime_tests2[i].size,
717 mimeImagePjpeg, 0, &mime, 0);
718 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
719 if(!lstrcmpW(mimeAppOctetStream, mime_tests2[i].mime) || i == 17)
720 ok(!lstrcmpW(mime, mimeImagePjpeg), "[%d] wrong mime\n", i);
722 ok(!lstrcmpW(mime, mime_tests2[i].mime) ||
723 (mime_tests2[i].mime_alt && !lstrcmpW(mime, mime_tests2[i].mime_alt)),
724 "[%d] wrong mime, got %s\n", i, wine_dbgstr_w(mime));
729 hres = pFindMimeFromData(NULL, url1, data1, sizeof(data1), NULL, 0, &mime, 0);
730 ok(hres == S_OK, "FindMimeFromData failed: %08x\n", hres);
731 ok(!lstrcmpW(mime, mimeTextPlain), "wrong mime\n");
734 hres = pFindMimeFromData(NULL, url1, data1, sizeof(data1), mimeAppOctetStream, 0, &mime, 0);
735 ok(hres == S_OK, "FindMimeFromData failed: %08x\n", hres);
736 ok(!lstrcmpW(mime, mimeTextPlain), "wrong mime\n");
739 hres = pFindMimeFromData(NULL, url4, data1, sizeof(data1), mimeAppOctetStream, 0, &mime, 0);
740 ok(hres == S_OK, "FindMimeFromData failed: %08x\n", hres);
741 ok(!lstrcmpW(mime, mimeTextPlain), "wrong mime\n");
744 hres = pFindMimeFromData(NULL, NULL, NULL, 0, NULL, 0, &mime, 0);
745 ok(hres == E_INVALIDARG, "FindMimeFromData failed: %08x, excepted E_INVALIDARG\n", hres);
747 hres = pFindMimeFromData(NULL, NULL, NULL, 0, mimeTextPlain, 0, &mime, 0);
748 ok(hres == E_INVALIDARG, "FindMimeFromData failed: %08x, expected E_INVALIDARG\n", hres);
750 hres = pFindMimeFromData(NULL, NULL, data1, 0, NULL, 0, &mime, 0);
751 ok(hres == E_FAIL, "FindMimeFromData failed: %08x, expected E_FAIL\n", hres);
753 hres = pFindMimeFromData(NULL, url1, data1, 0, NULL, 0, &mime, 0);
754 ok(hres == E_FAIL, "FindMimeFromData failed: %08x, expected E_FAIL\n", hres);
756 hres = pFindMimeFromData(NULL, NULL, data1, 0, mimeTextPlain, 0, &mime, 0);
757 ok(hres == S_OK, "FindMimeFromData failed: %08x\n", hres);
758 ok(!lstrcmpW(mime, mimeTextPlain), "wrong mime\n");
761 hres = pFindMimeFromData(NULL, NULL, data1, 0, mimeTextPlain, 0, NULL, 0);
762 ok(hres == E_INVALIDARG, "FindMimeFromData failed: %08x, expected E_INVALIDARG\n", hres);
765 static void register_protocols(void)
767 IInternetSession *session;
768 IClassFactory *factory;
771 static const WCHAR wszAbout[] = {'a','b','o','u','t',0};
773 if (!pCoInternetGetSession) {
777 hres = pCoInternetGetSession(0, &session, 0);
778 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
782 hres = CoGetClassObject(&CLSID_AboutProtocol, CLSCTX_INPROC_SERVER, NULL,
783 &IID_IClassFactory, (void**)&factory);
784 ok(hres == S_OK, "Coud not get AboutProtocol factory: %08x\n", hres);
788 IInternetSession_RegisterNameSpace(session, factory, &CLSID_AboutProtocol,
789 wszAbout, 0, NULL, 0);
790 IClassFactory_Release(factory);
792 IInternetSession_Release(session);
795 static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface,
796 REFIID riid, void **ppv)
798 ok(0, "unexpected call\n");
799 return E_NOINTERFACE;
802 static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
807 static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
812 static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
813 PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
814 DWORD *pcchResult, DWORD dwReserved)
816 CHECK_EXPECT2(ParseUrl);
818 if(ParseAction == PARSE_SECURITY_URL) {
820 *pcchResult = sizeof(url1)/sizeof(WCHAR);
822 if(cchResult<sizeof(url1)/sizeof(WCHAR))
825 memcpy(pwzResult, url1, sizeof(url1));
832 static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
833 LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags,
834 LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
836 ok(0, "unexpected call\n");
840 static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface,
841 LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
843 ok(0, "unexpected call\n");
847 static HRESULT WINAPI InternetProtocolInfo_QueryInfo(IInternetProtocolInfo *iface,
848 LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer,
849 DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
851 ok(0, "unexpected call\n");
855 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl = {
856 InternetProtocolInfo_QueryInterface,
857 InternetProtocolInfo_AddRef,
858 InternetProtocolInfo_Release,
859 InternetProtocolInfo_ParseUrl,
860 InternetProtocolInfo_CombineUrl,
861 InternetProtocolInfo_CompareUrl,
862 InternetProtocolInfo_QueryInfo
865 static IInternetProtocolInfo protocol_info = { &InternetProtocolInfoVtbl };
867 static HRESULT qiret;
868 static IClassFactory *expect_cf;
870 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
872 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
873 CHECK_EXPECT2(QI_IInternetProtocolInfo);
874 ok(iface == expect_cf, "unexpected iface\n");
875 *ppv = &protocol_info;
879 ok(0, "unexpected call\n");
880 return E_NOINTERFACE;
883 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
888 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
893 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
894 REFIID riid, void **ppv)
896 ok(0, "unexpected call\n");
900 static HRESULT WINAPI ProtocolCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
901 REFIID riid, void **ppv)
903 CHECK_EXPECT(CreateInstance);
905 ok(iface == expect_cf, "unexpected iface\n");
906 ok(pOuter == NULL, "pOuter = %p\n", pOuter);
907 ok(IsEqualGUID(&IID_IInternetProtocolInfo, riid), "unexpected riid\n");
908 ok(ppv != NULL, "ppv == NULL\n");
910 *ppv = &protocol_info;
914 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
916 ok(0, "unexpected call\n");
920 static const IClassFactoryVtbl ClassFactoryVtbl = {
921 ClassFactory_QueryInterface,
923 ClassFactory_Release,
924 ClassFactory_CreateInstance,
925 ClassFactory_LockServer
928 static const IClassFactoryVtbl ProtocolCFVtbl = {
929 ClassFactory_QueryInterface,
931 ClassFactory_Release,
932 ProtocolCF_CreateInstance,
933 ClassFactory_LockServer
936 static IClassFactory test_protocol_cf = { &ProtocolCFVtbl };
937 static IClassFactory test_protocol_cf2 = { &ProtocolCFVtbl };
938 static IClassFactory test_cf = { &ClassFactoryVtbl };
940 static void test_NameSpace(void)
942 IInternetSession *session;
948 static const WCHAR wszTest[] = {'t','e','s','t',0};
950 if (!pCoInternetGetSession || !pCoInternetParseUrl) {
954 hres = pCoInternetGetSession(0, &session, 0);
955 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
959 hres = IInternetSession_RegisterNameSpace(session, NULL, &IID_NULL,
960 wszTest, 0, NULL, 0);
961 ok(hres == E_INVALIDARG, "RegisterNameSpace failed: %08x\n", hres);
963 hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf, &IID_NULL,
965 ok(hres == E_INVALIDARG, "RegisterNameSpace failed: %08x\n", hres);
967 hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf, &IID_NULL,
968 wszTest, 0, NULL, 0);
969 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
971 qiret = E_NOINTERFACE;
972 expect_cf = &test_protocol_cf;
973 SET_EXPECT(QI_IInternetProtocolInfo);
974 SET_EXPECT(CreateInstance);
975 SET_EXPECT(ParseUrl);
977 hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
979 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
981 CHECK_CALLED(QI_IInternetProtocolInfo);
982 CHECK_CALLED(CreateInstance);
983 CHECK_CALLED(ParseUrl);
986 SET_EXPECT(QI_IInternetProtocolInfo);
987 SET_EXPECT(ParseUrl);
989 hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
991 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
993 CHECK_CALLED(QI_IInternetProtocolInfo);
994 CHECK_CALLED(ParseUrl);
996 SET_EXPECT(QI_IInternetProtocolInfo);
997 SET_EXPECT(ParseUrl);
999 hres = pCoInternetParseUrl(url8, PARSE_SECURITY_URL, 0, buf,
1000 sizeof(buf)/sizeof(WCHAR), &size, 0);
1001 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
1002 ok(size == sizeof(url1)/sizeof(WCHAR), "Size = %d\n", size);
1003 if(size == sizeof(url1)/sizeof(WCHAR))
1004 ok(!memcmp(buf, url1, sizeof(url1)), "Encoded url = %s\n", wine_dbgstr_w(buf));
1006 CHECK_CALLED(QI_IInternetProtocolInfo);
1007 CHECK_CALLED(ParseUrl);
1009 SET_EXPECT(QI_IInternetProtocolInfo);
1010 SET_EXPECT(ParseUrl);
1012 if (pCoInternetGetSecurityUrl) {
1013 hres = pCoInternetGetSecurityUrl(url8, &sec_url, PSU_SECURITY_URL_ONLY, 0);
1014 ok(hres == S_OK, "CoInternetGetSecurityUrl failed: %08x\n", hres);
1016 ok(lstrlenW(sec_url)>sizeof(wszFile)/sizeof(WCHAR) &&
1017 !memcmp(sec_url, wszFile, sizeof(wszFile)-sizeof(WCHAR)),
1018 "Encoded url = %s\n", wine_dbgstr_w(sec_url));
1019 CoTaskMemFree(sec_url);
1022 CHECK_CALLED(QI_IInternetProtocolInfo);
1023 CHECK_CALLED(ParseUrl);
1026 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
1027 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
1029 hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
1031 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
1033 hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf2, &IID_NULL,
1034 wszTest, 0, NULL, 0);
1035 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
1037 hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf, &IID_NULL,
1038 wszTest, 0, NULL, 0);
1039 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
1041 hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf, &IID_NULL,
1042 wszTest, 0, NULL, 0);
1043 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
1045 SET_EXPECT(QI_IInternetProtocolInfo);
1046 SET_EXPECT(ParseUrl);
1048 hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
1050 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
1052 CHECK_CALLED(QI_IInternetProtocolInfo);
1053 CHECK_CALLED(ParseUrl);
1055 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
1056 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
1058 SET_EXPECT(QI_IInternetProtocolInfo);
1059 SET_EXPECT(ParseUrl);
1061 hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
1063 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
1065 CHECK_CALLED(QI_IInternetProtocolInfo);
1066 CHECK_CALLED(ParseUrl);
1068 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
1069 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
1071 expect_cf = &test_protocol_cf2;
1072 SET_EXPECT(QI_IInternetProtocolInfo);
1073 SET_EXPECT(ParseUrl);
1075 hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
1077 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
1079 CHECK_CALLED(QI_IInternetProtocolInfo);
1080 CHECK_CALLED(ParseUrl);
1082 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
1083 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
1084 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
1085 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
1086 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, NULL);
1087 ok(hres == E_INVALIDARG, "UnregisterNameSpace failed: %08x\n", hres);
1088 hres = IInternetSession_UnregisterNameSpace(session, NULL, wszTest);
1089 ok(hres == E_INVALIDARG, "UnregisterNameSpace failed: %08x\n", hres);
1091 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf2, wszTest);
1092 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
1094 hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
1096 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
1098 IInternetSession_Release(session);
1101 static void test_MimeFilter(void)
1103 IInternetSession *session;
1106 static const WCHAR mimeW[] = {'t','e','s','t','/','m','i','m','e',0};
1108 if (!pCoInternetGetSession) {
1112 hres = pCoInternetGetSession(0, &session, 0);
1113 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
1117 hres = IInternetSession_RegisterMimeFilter(session, &test_cf, &IID_NULL, mimeW);
1118 ok(hres == S_OK, "RegisterMimeFilter failed: %08x\n", hres);
1120 hres = IInternetSession_UnregisterMimeFilter(session, &test_cf, mimeW);
1121 ok(hres == S_OK, "UnregisterMimeFilter failed: %08x\n", hres);
1123 hres = IInternetSession_UnregisterMimeFilter(session, &test_cf, mimeW);
1124 ok(hres == S_OK, "UnregisterMimeFilter failed: %08x\n", hres);
1126 hres = IInternetSession_UnregisterMimeFilter(session, (void*)0xdeadbeef, mimeW);
1127 ok(hres == S_OK, "UnregisterMimeFilter failed: %08x\n", hres);
1129 IInternetSession_Release(session);
1132 static ULONG WINAPI unk_Release(IUnknown *iface)
1134 CHECK_EXPECT(unk_Release);
1138 static const IUnknownVtbl unk_vtbl = {
1144 static void test_ReleaseBindInfo(void)
1147 IUnknown unk = { &unk_vtbl };
1149 if (!pReleaseBindInfo) {
1153 pReleaseBindInfo(NULL); /* shouldn't crash */
1155 memset(&bi, 0, sizeof(bi));
1156 bi.cbSize = sizeof(BINDINFO);
1158 SET_EXPECT(unk_Release);
1159 pReleaseBindInfo(&bi);
1160 ok(bi.cbSize == sizeof(BINDINFO), "bi.cbSize=%d\n", bi.cbSize);
1161 ok(bi.pUnk == NULL, "bi.pUnk=%p, expected NULL\n", bi.pUnk);
1162 CHECK_CALLED(unk_Release);
1164 memset(&bi, 0, sizeof(bi));
1165 bi.cbSize = offsetof(BINDINFO, pUnk);
1167 pReleaseBindInfo(&bi);
1168 ok(bi.cbSize == offsetof(BINDINFO, pUnk), "bi.cbSize=%d\n", bi.cbSize);
1169 ok(bi.pUnk == &unk, "bi.pUnk=%p, expected %p\n", bi.pUnk, &unk);
1171 memset(&bi, 0, sizeof(bi));
1173 pReleaseBindInfo(&bi);
1174 ok(!bi.cbSize, "bi.cbSize=%d, expected 0\n", bi.cbSize);
1175 ok(bi.pUnk == &unk, "bi.pUnk=%p, expected %p\n", bi.pUnk, &unk);
1178 static void test_CopyStgMedium(void)
1184 static WCHAR fileW[] = {'f','i','l','e',0};
1186 if (!pCopyStgMedium) {
1191 memset(&src, 0xf0, sizeof(src));
1192 memset(&dst, 0xe0, sizeof(dst));
1193 memset(&empty, 0xf0, sizeof(empty));
1194 src.tymed = TYMED_NULL;
1195 src.pUnkForRelease = NULL;
1196 hres = pCopyStgMedium(&src, &dst);
1197 ok(hres == S_OK, "CopyStgMedium failed: %08x\n", hres);
1198 ok(dst.tymed == TYMED_NULL, "tymed=%d\n", dst.tymed);
1199 ok(dst.u.hGlobal == empty, "u=%p\n", dst.u.hGlobal);
1200 ok(!dst.pUnkForRelease, "pUnkForRelease=%p, expected NULL\n", dst.pUnkForRelease);
1202 memset(&dst, 0xe0, sizeof(dst));
1203 src.tymed = TYMED_ISTREAM;
1205 src.pUnkForRelease = NULL;
1206 hres = pCopyStgMedium(&src, &dst);
1207 ok(hres == S_OK, "CopyStgMedium failed: %08x\n", hres);
1208 ok(dst.tymed == TYMED_ISTREAM, "tymed=%d\n", dst.tymed);
1209 ok(!dst.u.pstm, "pstm=%p\n", dst.u.pstm);
1210 ok(!dst.pUnkForRelease, "pUnkForRelease=%p, expected NULL\n", dst.pUnkForRelease);
1212 memset(&dst, 0xe0, sizeof(dst));
1213 src.tymed = TYMED_FILE;
1214 src.u.lpszFileName = fileW;
1215 src.pUnkForRelease = NULL;
1216 hres = pCopyStgMedium(&src, &dst);
1217 ok(hres == S_OK, "CopyStgMedium failed: %08x\n", hres);
1218 ok(dst.tymed == TYMED_FILE, "tymed=%d\n", dst.tymed);
1219 ok(dst.u.lpszFileName && dst.u.lpszFileName != fileW, "lpszFileName=%p\n", dst.u.lpszFileName);
1220 ok(!lstrcmpW(dst.u.lpszFileName, fileW), "wrong file name\n");
1221 ok(!dst.pUnkForRelease, "pUnkForRelease=%p, expected NULL\n", dst.pUnkForRelease);
1223 hres = pCopyStgMedium(&src, NULL);
1224 ok(hres == E_POINTER, "CopyStgMedium failed: %08x, expected E_POINTER\n", hres);
1225 hres = pCopyStgMedium(NULL, &dst);
1226 ok(hres == E_POINTER, "CopyStgMedium failed: %08x, expected E_POINTER\n", hres);
1229 static void test_UrlMkGetSessionOption(void)
1231 DWORD encoding, size;
1235 if (!pUrlMkGetSessionOption) {
1239 size = encoding = 0xdeadbeef;
1240 hres = pUrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING, &encoding,
1241 sizeof(encoding), &size, 0);
1242 ok(hres == S_OK, "UrlMkGetSessionOption failed: %08x\n", hres);
1243 ok(encoding != 0xdeadbeef, "encoding not changed\n");
1244 ok(size == sizeof(encoding), "size=%d\n", size);
1246 size = encoding = 0xdeadbeef;
1247 hres = pUrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING, &encoding,
1248 sizeof(encoding)+1, &size, 0);
1249 ok(hres == S_OK, "UrlMkGetSessionOption failed: %08x\n", hres);
1250 ok(encoding != 0xdeadbeef, "encoding not changed\n");
1251 ok(size == sizeof(encoding), "size=%d\n", size);
1253 size = encoding = 0xdeadbeef;
1254 hres = pUrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING, &encoding,
1255 sizeof(encoding)-1, &size, 0);
1256 ok(hres == E_INVALIDARG, "UrlMkGetSessionOption failed: %08x\n", hres);
1257 ok(encoding == 0xdeadbeef, "encoding = %08x, exepcted 0xdeadbeef\n", encoding);
1258 ok(size == 0xdeadbeef, "size=%d\n", size);
1260 size = encoding = 0xdeadbeef;
1261 hres = pUrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING, NULL,
1262 sizeof(encoding)-1, &size, 0);
1263 ok(hres == E_INVALIDARG, "UrlMkGetSessionOption failed: %08x\n", hres);
1264 ok(encoding == 0xdeadbeef, "encoding = %08x, exepcted 0xdeadbeef\n", encoding);
1265 ok(size == 0xdeadbeef, "size=%d\n", size);
1267 encoding = 0xdeadbeef;
1268 hres = pUrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING, &encoding,
1269 sizeof(encoding)-1, NULL, 0);
1270 ok(hres == E_INVALIDARG, "UrlMkGetSessionOption failed: %08x\n", hres);
1271 ok(encoding == 0xdeadbeef, "encoding = %08x, exepcted 0xdeadbeef\n", encoding);
1274 static void test_user_agent(void)
1276 static const CHAR expected[] = "Mozilla/4.0 (compatible; MSIE ";
1277 static char test_str[] = "test";
1278 static char test2_str[] = "test\0test";
1284 if (!pObtainUserAgentString || !pUrlMkGetSessionOption) {
1288 hres = pObtainUserAgentString(0, NULL, NULL);
1289 ok(hres == E_INVALIDARG, "ObtainUserAgentString failed: %08x\n", hres);
1292 hres = pObtainUserAgentString(0, NULL, &size);
1293 ok(hres == E_INVALIDARG, "ObtainUserAgentString failed: %08x\n", hres);
1294 ok(size == 100, "size=%d, expected %d\n", size, 100);
1297 hres = pObtainUserAgentString(0, str, &size);
1298 ok(hres == E_OUTOFMEMORY, "ObtainUserAgentString failed: %08x\n", hres);
1299 ok(size > 0, "size=%d, expected non-zero\n", size);
1303 hres = pObtainUserAgentString(0, str, &size);
1304 ok(hres == E_OUTOFMEMORY, "ObtainUserAgentString failed: %08x\n", hres);
1305 ok(size > 0, "size=%d, expected non-zero\n", size);
1306 ok(str[0] == 'a', "str[0]=%c, expected 'a'\n", str[0]);
1309 hres = pObtainUserAgentString(1, str, &size);
1310 ok(hres == E_OUTOFMEMORY, "ObtainUserAgentString failed: %08x\n", hres);
1311 ok(size > 0, "size=%d, expected non-zero\n", size);
1313 str2 = HeapAlloc(GetProcessHeap(), 0, (size+20)*sizeof(CHAR));
1315 hres = pObtainUserAgentString(0, str2, &size);
1316 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
1317 ok(size == saved, "size=%d, expected %d\n", size, saved);
1318 ok(strlen(expected) <= strlen(str2) &&
1319 !memcmp(expected, str2, strlen(expected)*sizeof(CHAR)),
1320 "user agent was \"%s\", expected to start with \"%s\"\n",
1324 hres = pObtainUserAgentString(0, str2, &size);
1325 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
1326 ok(size == saved, "size=%d, expected %d\n", size, saved);
1329 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, NULL, 0, &size, 0);
1330 ok(hres == E_OUTOFMEMORY, "UrlMkGetSessionOption failed: %08x\n", hres);
1331 ok(size, "size == 0\n");
1334 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, NULL, 1000, &size, 0);
1335 ok(hres == E_INVALIDARG, "UrlMkGetSessionOption failed: %08x\n", hres);
1336 ok(size, "size == 0\n");
1340 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, str2, saved+10, &size, 0);
1341 ok(hres == E_OUTOFMEMORY, "UrlMkGetSessionOption failed: %08x\n", hres);
1342 ok(size == saved, "size = %d, expected %d\n", size, saved);
1343 ok(sizeof(expected) <= strlen(str2) && !memcmp(expected, str2, sizeof(expected)-1),
1344 "user agent was \"%s\", expected to start with \"%s\"\n",
1349 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, str2, saved, &size, 0);
1350 ok(hres == E_OUTOFMEMORY, "UrlMkGetSessionOption failed: %08x\n", hres);
1351 ok(size == saved, "size = %d, expected %d\n", size, saved);
1352 ok(sizeof(expected) <= strlen(str2) && !memcmp(expected, str2, sizeof(expected)-1),
1353 "user agent was \"%s\", expected to start with \"%s\"\n",
1358 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, str2, saved-1, &size, 0);
1359 ok(hres == E_OUTOFMEMORY, "UrlMkGetSessionOption failed: %08x\n", hres);
1360 ok(size == saved, "size = %d, expected %d\n", size, saved);
1361 ok(!str2[0], "buf changed\n");
1365 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, str2, saved, NULL, 0);
1366 ok(hres == E_INVALIDARG, "UrlMkGetSessionOption failed: %08x\n", hres);
1367 ok(!str2[0], "buf changed\n");
1369 hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, test_str, sizeof(test_str), 0);
1370 ok(hres == S_OK, "UrlMkSetSessionOption failed: %08x\n", hres);
1374 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, str2, saved, &size, 0);
1375 ok(hres == E_OUTOFMEMORY, "UrlMkGetSessionOption failed: %08x\n", hres);
1376 ok(size == sizeof(test_str) && !memcmp(str2, test_str, sizeof(test_str)), "wrong user agent\n");
1378 hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, test2_str, sizeof(test2_str), 0);
1379 ok(hres == S_OK, "UrlMkSetSessionOption failed: %08x\n", hres);
1383 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, str2, saved, &size, 0);
1384 ok(hres == E_OUTOFMEMORY, "UrlMkGetSessionOption failed: %08x\n", hres);
1385 ok(size == sizeof(test_str) && !memcmp(str2, test_str, sizeof(test_str)), "wrong user agent\n");
1387 hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, test_str, 2, 0);
1388 ok(hres == S_OK, "UrlMkSetSessionOption failed: %08x\n", hres);
1392 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, str2, saved, &size, 0);
1393 ok(hres == E_OUTOFMEMORY, "UrlMkGetSessionOption failed: %08x\n", hres);
1394 ok(size == 3 && !strcmp(str2, "te"), "wrong user agent\n");
1396 hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, test_str, 0, 0);
1397 ok(hres == E_INVALIDARG, "UrlMkSetSessionOption failed: %08x\n", hres);
1399 hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, NULL, sizeof(test_str), 0);
1400 ok(hres == E_INVALIDARG, "UrlMkSetSessionOption failed: %08x\n", hres);
1402 hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, NULL, 0, 0);
1403 ok(hres == E_INVALIDARG, "UrlMkSetSessionOption failed: %08x\n", hres);
1405 HeapFree(GetProcessHeap(), 0, str2);
1408 static void test_MkParseDisplayNameEx(void)
1410 IMoniker *mon = NULL;
1417 static const WCHAR clsid_nameW[] = {'c','l','s','i','d',':',
1418 '2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8',
1419 '-','0','8','0','0','2','B','3','0','3','0','9','D',':',0};
1424 LPCWSTR szDisplayName;
1427 } invalid_parameters[] =
1429 {NULL, NULL, NULL, NULL},
1430 {NULL, NULL, NULL, &mon},
1431 {NULL, NULL, &eaten, NULL},
1432 {NULL, NULL, &eaten, &mon},
1433 {NULL, wszEmpty, NULL, NULL},
1434 {NULL, wszEmpty, NULL, &mon},
1435 {NULL, wszEmpty, &eaten, NULL},
1436 {NULL, wszEmpty, &eaten, &mon},
1437 {&bctx, NULL, NULL, NULL},
1438 {&bctx, NULL, NULL, &mon},
1439 {&bctx, NULL, &eaten, NULL},
1440 {&bctx, NULL, &eaten, &mon},
1441 {&bctx, wszEmpty, NULL, NULL},
1442 {&bctx, wszEmpty, NULL, &mon},
1443 {&bctx, wszEmpty, &eaten, NULL},
1444 {&bctx, wszEmpty, &eaten, &mon},
1449 CreateBindCtx(0, &bctx);
1451 for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
1454 mon = (IMoniker *)0xdeadbeef;
1455 hres = MkParseDisplayNameEx(invalid_parameters[i].ppbc ? *invalid_parameters[i].ppbc : NULL,
1456 invalid_parameters[i].szDisplayName,
1457 invalid_parameters[i].pchEaten,
1458 invalid_parameters[i].ppmk);
1459 ok(hres == E_INVALIDARG,
1460 "[%d] Expected MkParseDisplayNameEx to return E_INVALIDARG, got %08x\n", i, hres);
1461 ok(eaten == 0xdeadbeef, "[%d] Expected eaten to be 0xdeadbeef, got %u\n", i, eaten);
1462 ok(mon == (IMoniker *)0xdeadbeef, "[%d] Expected mon to be 0xdeadbeef, got %p\n", i, mon);
1465 hres = MkParseDisplayNameEx(bctx, url9, &eaten, &mon);
1466 ok(hres == S_OK, "MkParseDisplayNameEx failed: %08x\n", hres);
1467 ok(eaten == sizeof(url9)/sizeof(WCHAR)-1, "eaten=%d\n", eaten);
1468 ok(mon != NULL, "mon == NULL\n");
1470 hres = IMoniker_GetDisplayName(mon, NULL, 0, &name);
1471 ok(hres == S_OK, "GetDiasplayName failed: %08x\n", hres);
1472 ok(!lstrcmpW(name, url9), "wrong display name %s\n", wine_dbgstr_w(name));
1473 CoTaskMemFree(name);
1475 hres = IMoniker_IsSystemMoniker(mon, &issys);
1476 ok(hres == S_OK, "IsSystemMoniker failed: %08x\n", hres);
1477 ok(issys == MKSYS_URLMONIKER, "issys=%x\n", issys);
1479 IMoniker_Release(mon);
1481 hres = MkParseDisplayNameEx(bctx, clsid_nameW, &eaten, &mon);
1482 ok(hres == S_OK, "MkParseDisplayNameEx failed: %08x\n", hres);
1483 ok(eaten == sizeof(clsid_nameW)/sizeof(WCHAR)-1, "eaten=%d\n", eaten);
1484 ok(mon != NULL, "mon == NULL\n");
1486 hres = IMoniker_IsSystemMoniker(mon, &issys);
1487 ok(hres == S_OK, "IsSystemMoniker failed: %08x\n", hres);
1488 ok(issys == MKSYS_CLASSMONIKER, "issys=%x\n", issys);
1490 IMoniker_Release(mon);
1492 hres = MkParseDisplayNameEx(bctx, url8, &eaten, &mon);
1493 ok(FAILED(hres), "MkParseDisplayNameEx succeeded: %08x\n", hres);
1495 IBindCtx_Release(bctx);
1498 static void test_IsValidURL(void)
1502 hr = IsValidURL(NULL, 0, 0);
1503 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
1510 OleInitialize(NULL);
1512 hurlmon = GetModuleHandle("urlmon.dll");
1513 pCoInternetCompareUrl = (void *) GetProcAddress(hurlmon, "CoInternetCompareUrl");
1514 pCoInternetGetSecurityUrl = (void*) GetProcAddress(hurlmon, "CoInternetGetSecurityUrl");
1515 pCoInternetGetSession = (void*) GetProcAddress(hurlmon, "CoInternetGetSession");
1516 pCoInternetParseUrl = (void*) GetProcAddress(hurlmon, "CoInternetParseUrl");
1517 pCoInternetQueryInfo = (void*) GetProcAddress(hurlmon, "CoInternetQueryInfo");
1518 pCopyStgMedium = (void*) GetProcAddress(hurlmon, "CopyStgMedium");
1519 pFindMimeFromData = (void*) GetProcAddress(hurlmon, "FindMimeFromData");
1520 pObtainUserAgentString = (void*) GetProcAddress(hurlmon, "ObtainUserAgentString");
1521 pReleaseBindInfo = (void*) GetProcAddress(hurlmon, "ReleaseBindInfo");
1522 pUrlMkGetSessionOption = (void*) GetProcAddress(hurlmon, "UrlMkGetSessionOption");
1524 if (!pCoInternetCompareUrl || !pCoInternetGetSecurityUrl ||
1525 !pCoInternetGetSession || !pCoInternetParseUrl) {
1526 win_skip("Various needed functions not present in IE 4.0\n");
1529 register_protocols();
1531 test_CreateFormatEnum();
1532 test_RegisterFormatEnumerator();
1533 test_CoInternetParseUrl();
1534 test_CoInternetCompareUrl();
1535 test_CoInternetQueryInfo();
1536 test_FindMimeFromData();
1539 test_ReleaseBindInfo();
1540 test_CopyStgMedium();
1541 test_UrlMkGetSessionOption();
1543 test_MkParseDisplayNameEx();