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);
77 static HRESULT (WINAPI *pCompareSecurityIds)(BYTE*,DWORD,BYTE*,DWORD,DWORD);
80 static void test_CreateFormatEnum(void)
82 IEnumFORMATETC *fenum = NULL, *fenum2 = NULL;
87 static DVTARGETDEVICE dev = {sizeof(dev),0,0,0,0,{0}};
88 static FORMATETC formatetc[] = {
96 hres = CreateFormatEnumerator(0, formatetc, &fenum);
97 ok(hres == E_FAIL, "CreateFormatEnumerator failed: %08x, expected E_FAIL\n", hres);
98 hres = CreateFormatEnumerator(0, formatetc, NULL);
99 ok(hres == E_INVALIDARG, "CreateFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres);
100 hres = CreateFormatEnumerator(5, formatetc, NULL);
101 ok(hres == E_INVALIDARG, "CreateFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres);
104 hres = CreateFormatEnumerator(5, formatetc, &fenum);
105 ok(hres == S_OK, "CreateFormatEnumerator failed: %08x\n", hres);
109 hres = IEnumFORMATETC_Next(fenum, 2, NULL, &ul);
110 ok(hres == E_INVALIDARG, "Next failed: %08x, expected E_INVALIDARG\n", hres);
112 hres = IEnumFORMATETC_Next(fenum, 0, fetc, &ul);
113 ok(hres == S_OK, "Next failed: %08x\n", hres);
114 ok(ul == 0, "ul=%d, expected 0\n", ul);
116 hres = IEnumFORMATETC_Next(fenum, 2, fetc, &ul);
117 ok(hres == S_OK, "Next failed: %08x\n", hres);
118 ok(fetc[0].lindex == 0, "fetc[0].lindex=%d, expected 0\n", fetc[0].lindex);
119 ok(fetc[1].lindex == 1, "fetc[1].lindex=%d, expected 1\n", fetc[1].lindex);
120 ok(fetc[0].ptd == &dev, "fetc[0].ptd=%p, expected %p\n", fetc[0].ptd, &dev);
121 ok(ul == 2, "ul=%d, expected 2\n", ul);
123 hres = IEnumFORMATETC_Skip(fenum, 1);
124 ok(hres == S_OK, "Skip failed: %08x\n", hres);
126 hres = IEnumFORMATETC_Next(fenum, 4, fetc, &ul);
127 ok(hres == S_FALSE, "Next failed: %08x, expected S_FALSE\n", hres);
128 ok(fetc[0].lindex == 3, "fetc[0].lindex=%d, expected 3\n", fetc[0].lindex);
129 ok(fetc[1].lindex == 4, "fetc[1].lindex=%d, expected 4\n", fetc[1].lindex);
130 ok(fetc[0].ptd == NULL, "fetc[0].ptd=%p, expected NULL\n", fetc[0].ptd);
131 ok(ul == 2, "ul=%d, expected 2\n", ul);
133 hres = IEnumFORMATETC_Next(fenum, 4, fetc, &ul);
134 ok(hres == S_FALSE, "Next failed: %08x, expected S_FALSE\n", hres);
135 ok(ul == 0, "ul=%d, expected 0\n", ul);
137 hres = IEnumFORMATETC_Next(fenum, 0, fetc, &ul);
138 ok(hres == S_OK, "Next failed: %08x\n", hres);
139 ok(ul == 0, "ul=%d, expected 0\n", ul);
141 hres = IEnumFORMATETC_Skip(fenum, 3);
142 ok(hres == S_FALSE, "Skip failed: %08x, expected S_FALSE\n", hres);
144 hres = IEnumFORMATETC_Reset(fenum);
145 ok(hres == S_OK, "Reset failed: %08x\n", hres);
147 hres = IEnumFORMATETC_Next(fenum, 5, fetc, NULL);
148 ok(hres == S_OK, "Next failed: %08x\n", hres);
149 ok(fetc[0].lindex == 0, "fetc[0].lindex=%d, expected 0\n", fetc[0].lindex);
151 hres = IEnumFORMATETC_Reset(fenum);
152 ok(hres == S_OK, "Reset failed: %08x\n", hres);
154 hres = IEnumFORMATETC_Skip(fenum, 2);
155 ok(hres == S_OK, "Skip failed: %08x\n", hres);
157 hres = IEnumFORMATETC_Clone(fenum, NULL);
158 ok(hres == E_INVALIDARG, "Clone failed: %08x, expected E_INVALIDARG\n", hres);
160 hres = IEnumFORMATETC_Clone(fenum, &fenum2);
161 ok(hres == S_OK, "Clone failed: %08x\n", hres);
163 if(SUCCEEDED(hres)) {
164 ok(fenum != fenum2, "fenum == fenum2\n");
166 hres = IEnumFORMATETC_Next(fenum2, 2, fetc, &ul);
167 ok(hres == S_OK, "Next failed: %08x\n", hres);
168 ok(fetc[0].lindex == 2, "fetc[0].lindex=%d, expected 2\n", fetc[0].lindex);
170 IEnumFORMATETC_Release(fenum2);
173 hres = IEnumFORMATETC_Next(fenum, 2, fetc, &ul);
174 ok(hres == S_OK, "Next failed: %08x\n", hres);
175 ok(fetc[0].lindex == 2, "fetc[0].lindex=%d, expected 2\n", fetc[0].lindex);
177 hres = IEnumFORMATETC_Skip(fenum, 1);
178 ok(hres == S_OK, "Skip failed: %08x\n", hres);
180 IEnumFORMATETC_Release(fenum);
183 static void test_RegisterFormatEnumerator(void)
185 IBindCtx *bctx = NULL;
186 IEnumFORMATETC *format = NULL, *format2 = NULL;
187 IUnknown *unk = NULL;
190 static FORMATETC formatetc = {0,NULL,0,0,0};
191 static WCHAR wszEnumFORMATETC[] =
192 {'_','E','n','u','m','F','O','R','M','A','T','E','T','C','_',0};
194 CreateBindCtx(0, &bctx);
196 hres = CreateFormatEnumerator(1, &formatetc, &format);
197 ok(hres == S_OK, "CreateFormatEnumerator failed: %08x\n", hres);
201 hres = RegisterFormatEnumerator(NULL, format, 0);
202 ok(hres == E_INVALIDARG,
203 "RegisterFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres);
204 hres = RegisterFormatEnumerator(bctx, NULL, 0);
205 ok(hres == E_INVALIDARG,
206 "RegisterFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres);
208 hres = RegisterFormatEnumerator(bctx, format, 0);
209 ok(hres == S_OK, "RegisterFormatEnumerator failed: %08x\n", hres);
211 hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
212 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
213 ok(unk == (IUnknown*)format, "unk != format\n");
215 hres = RevokeFormatEnumerator(NULL, format);
216 ok(hres == E_INVALIDARG,
217 "RevokeFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres);
219 hres = RevokeFormatEnumerator(bctx, format);
220 ok(hres == S_OK, "RevokeFormatEnumerator failed: %08x\n", hres);
222 hres = RevokeFormatEnumerator(bctx, format);
223 ok(hres == E_FAIL, "RevokeFormatEnumerator failed: %08x, expected E_FAIL\n", hres);
225 hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
226 ok(hres == E_FAIL, "GetObjectParam failed: %08x, expected E_FAIL\n", hres);
228 hres = RegisterFormatEnumerator(bctx, format, 0);
229 ok(hres == S_OK, "RegisterFormatEnumerator failed: %08x\n", hres);
231 hres = CreateFormatEnumerator(1, &formatetc, &format2);
232 ok(hres == S_OK, "CreateFormatEnumerator failed: %08x\n", hres);
234 if(SUCCEEDED(hres)) {
235 hres = RevokeFormatEnumerator(bctx, format);
236 ok(hres == S_OK, "RevokeFormatEnumerator failed: %08x\n", hres);
238 IEnumFORMATETC_Release(format2);
241 hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
242 ok(hres == E_FAIL, "GetObjectParam failed: %08x, expected E_FAIL\n", hres);
244 IEnumFORMATETC_Release(format);
246 hres = RegisterFormatEnumerator(bctx, format, 0);
247 ok(hres == S_OK, "RegisterFormatEnumerator failed: %08x\n", hres);
248 hres = RevokeFormatEnumerator(bctx, NULL);
249 ok(hres == S_OK, "RevokeFormatEnumerator failed: %08x\n", hres);
250 hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
251 ok(hres == E_FAIL, "GetObjectParam failed: %08x, expected E_FAIL\n", hres);
253 IEnumFORMATETC_Release(format);
254 IBindCtx_Release(bctx);
257 static const WCHAR url1[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',
258 '/','b','l','a','n','k','.','h','t','m',0};
259 static const WCHAR url2[] = {'i','n','d','e','x','.','h','t','m',0};
260 static const WCHAR url3[] = {'f','i','l','e',':','/','/','c',':','\\','I','n','d','e','x','.','h','t','m',0};
261 static const WCHAR url4[] = {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e',
262 '%','2','e','j','p','g',0};
263 static const WCHAR url5[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
265 static const WCHAR url6[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
266 static const WCHAR url7[] = {'f','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g','/',
267 'f','i','l','e','.','t','e','s','t',0};
268 static const WCHAR url8[] = {'t','e','s','t',':','1','2','3','a','b','c',0};
269 static const WCHAR url9[] =
270 {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',
271 '/','s','i','t','e','/','a','b','o','u','t',0};
272 static const WCHAR url10[] = {'f','i','l','e',':','/','/','s','o','m','e','%','2','0','f','i','l','e',
274 static const WCHAR url11[] = {'h','t','t','p',':','/','/','g','o','o','g','l','e','.','*','.',
276 static const WCHAR url4e[] = {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e',
279 static const WCHAR path3[] = {'c',':','\\','I','n','d','e','x','.','h','t','m',0};
280 static const WCHAR path4[] = {'s','o','m','e',' ','f','i','l','e','.','j','p','g',0};
282 static const WCHAR wszRes[] = {'r','e','s',0};
283 static const WCHAR wszFile[] = {'f','i','l','e',0};
284 static const WCHAR wszHttp[] = {'h','t','t','p',0};
285 static const WCHAR wszAbout[] = {'a','b','o','u','t',0};
286 static const WCHAR wszEmpty[] = {0};
287 static const WCHAR wszGoogle[] = {'g','o','o','g','l','e','.','*','.','c','o','m',0};
289 static const WCHAR wszWineHQ[] = {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
290 static const WCHAR wszHttpWineHQ[] = {'h','t','t','p',':','/','/','w','w','w','.',
291 'w','i','n','e','h','q','.','o','r','g',0};
292 static const WCHAR wszHttpGoogle[] = {'h','t','t','p',':','/','/','g','o','o','g','l','e',
293 '.','*','.','c','o','m',0};
304 LPCWSTR rootdocument;
305 HRESULT rootdocument_hres;
308 static const struct parse_test parse_tests[] = {
309 {url1, S_OK, url1, E_INVALIDARG, NULL, wszRes, NULL, E_FAIL, NULL, E_FAIL},
310 {url2, E_FAIL, url2, E_INVALIDARG, NULL, wszEmpty, NULL, E_FAIL, NULL, E_FAIL},
311 {url3, E_FAIL, url3, S_OK, path3, wszFile, wszEmpty, S_OK, NULL, E_FAIL},
312 {url4, E_FAIL, url4e, S_OK, path4, wszFile, wszEmpty, S_OK, NULL, E_FAIL},
313 {url5, E_FAIL, url5, E_INVALIDARG, NULL, wszHttp, wszWineHQ, S_OK, wszHttpWineHQ, S_OK},
314 {url6, S_OK, url6, E_INVALIDARG, NULL, wszAbout, NULL, E_FAIL, NULL, E_FAIL},
315 {url11, E_FAIL, url11, E_INVALIDARG, NULL, wszHttp, wszGoogle, S_OK, wszHttpGoogle, S_OK}
318 static void test_CoInternetParseUrl(void)
324 static WCHAR buf[4096];
326 memset(buf, 0xf0, sizeof(buf));
327 hres = pCoInternetParseUrl(parse_tests[0].url, PARSE_SCHEMA, 0, buf,
329 ok(hres == E_POINTER, "schema failed: %08x, expected E_POINTER\n", hres);
331 for(i=0; i < sizeof(parse_tests)/sizeof(parse_tests[0]); i++) {
332 memset(buf, 0xf0, sizeof(buf));
333 hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_SECURITY_URL, 0, buf,
334 sizeof(buf)/sizeof(WCHAR), &size, 0);
335 ok(hres == parse_tests[i].secur_hres, "[%d] security url failed: %08x, expected %08x\n",
336 i, hres, parse_tests[i].secur_hres);
338 memset(buf, 0xf0, sizeof(buf));
339 hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_ENCODE, 0, buf,
340 sizeof(buf)/sizeof(WCHAR), &size, 0);
341 ok(hres == S_OK, "[%d] encoding failed: %08x\n", i, hres);
342 ok(size == lstrlenW(parse_tests[i].encoded_url), "[%d] wrong size\n", i);
343 ok(!lstrcmpW(parse_tests[i].encoded_url, buf), "[%d] wrong encoded url\n", i);
345 memset(buf, 0xf0, sizeof(buf));
346 hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_PATH_FROM_URL, 0, buf,
347 sizeof(buf)/sizeof(WCHAR), &size, 0);
348 ok(hres == parse_tests[i].path_hres, "[%d] path failed: %08x, expected %08x\n",
349 i, hres, parse_tests[i].path_hres);
350 if(parse_tests[i].path) {
351 ok(size == lstrlenW(parse_tests[i].path), "[%d] wrong size\n", i);
352 ok(!lstrcmpW(parse_tests[i].path, buf), "[%d] wrong path\n", i);
355 memset(buf, 0xf0, sizeof(buf));
356 hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_SCHEMA, 0, buf,
357 sizeof(buf)/sizeof(WCHAR), &size, 0);
358 ok(hres == S_OK, "[%d] schema failed: %08x\n", i, hres);
359 ok(size == lstrlenW(parse_tests[i].schema), "[%d] wrong size\n", i);
360 ok(!lstrcmpW(parse_tests[i].schema, buf), "[%d] wrong schema\n", i);
362 if(memcmp(parse_tests[i].url, wszRes, 3*sizeof(WCHAR))
363 && memcmp(parse_tests[i].url, wszAbout, 5*sizeof(WCHAR))) {
364 memset(buf, 0xf0, sizeof(buf));
365 hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_DOMAIN, 0, buf,
366 sizeof(buf)/sizeof(WCHAR), &size, 0);
367 ok(hres == parse_tests[i].domain_hres, "[%d] domain failed: %08x\n", i, hres);
368 if(parse_tests[i].domain)
369 ok(!lstrcmpW(parse_tests[i].domain, buf), "[%d] wrong domain, received %s\n", i, wine_dbgstr_w(buf));
372 memset(buf, 0xf0, sizeof(buf));
373 hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_ROOTDOCUMENT, 0, buf,
374 sizeof(buf)/sizeof(WCHAR), &size, 0);
375 ok(hres == parse_tests[i].rootdocument_hres, "[%d] rootdocument failed: %08x\n", i, hres);
376 if(parse_tests[i].rootdocument)
377 ok(!lstrcmpW(parse_tests[i].rootdocument, buf), "[%d] wrong rootdocument, received %s\n", i, wine_dbgstr_w(buf));
381 static void test_CoInternetCompareUrl(void)
385 hres = pCoInternetCompareUrl(url1, url1, 0);
386 ok(hres == S_OK, "CoInternetCompareUrl failed: %08x\n", hres);
388 hres = pCoInternetCompareUrl(url1, url3, 0);
389 ok(hres == S_FALSE, "CoInternetCompareUrl failed: %08x\n", hres);
391 hres = pCoInternetCompareUrl(url3, url1, 0);
392 ok(hres == S_FALSE, "CoInternetCompareUrl failed: %08x\n", hres);
395 static const struct {
398 } query_info_tests[] = {
409 static void test_CoInternetQueryInfo(void)
415 for(i=0; i < sizeof(query_info_tests)/sizeof(query_info_tests[0]); i++) {
417 memset(buf, '?', sizeof(buf));
418 hres = pCoInternetQueryInfo(query_info_tests[0].url, QUERY_USES_NETWORK, 0, buf, sizeof(buf), &cb, 0);
419 ok(hres == S_OK, "[%d] CoInternetQueryInfo failed: %08x\n", i, hres);
420 ok(cb == sizeof(DWORD), "[%d] cb = %d\n", i, cb);
421 ok(*(DWORD*)buf == query_info_tests[i].uses_net, "[%d] ret %x, expected %x\n",
422 i, *(DWORD*)buf, query_info_tests[i].uses_net);
424 hres = pCoInternetQueryInfo(query_info_tests[0].url, QUERY_USES_NETWORK, 0, buf, 3, &cb, 0);
425 ok(hres == E_FAIL, "[%d] CoInternetQueryInfo failed: %08x, expected E_FAIL\n", i, hres);
426 hres = pCoInternetQueryInfo(query_info_tests[0].url, QUERY_USES_NETWORK, 0, NULL, sizeof(buf), &cb, 0);
427 ok(hres == E_FAIL, "[%d] CoInternetQueryInfo failed: %08x, expected E_FAIL\n", i, hres);
429 memset(buf, '?', sizeof(buf));
430 hres = pCoInternetQueryInfo(query_info_tests[0].url, QUERY_USES_NETWORK, 0, buf, sizeof(buf), NULL, 0);
431 ok(hres == S_OK, "[%d] CoInternetQueryInfo failed: %08x\n", i, hres);
432 ok(*(DWORD*)buf == query_info_tests[i].uses_net, "[%d] ret %x, expected %x\n",
433 i, *(DWORD*)buf, query_info_tests[i].uses_net);
437 static const WCHAR mimeTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
438 static const WCHAR mimeTextPlain[] = {'t','e','x','t','/','p','l','a','i','n',0};
439 static const WCHAR mimeTextRichtext[] = {'t','e','x','t','/','r','i','c','h','t','e','x','t',0};
440 static const WCHAR mimeAppOctetStream[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
441 'o','c','t','e','t','-','s','t','r','e','a','m',0};
442 static const WCHAR mimeImagePjpeg[] = {'i','m','a','g','e','/','p','j','p','e','g',0};
443 static const WCHAR mimeImageGif[] = {'i','m','a','g','e','/','g','i','f',0};
444 static const WCHAR mimeImageBmp[] = {'i','m','a','g','e','/','b','m','p',0};
445 static const WCHAR mimeImageXPng[] = {'i','m','a','g','e','/','x','-','p','n','g',0};
446 static const WCHAR mimeImageTiff[] = {'i','m','a','g','e','/','t','i','f','f',0};
447 static const WCHAR mimeVideoAvi[] = {'v','i','d','e','o','/','a','v','i',0};
448 static const WCHAR mimeVideoMpeg[] = {'v','i','d','e','o','/','m','p','e','g',0};
449 static const WCHAR mimeAppPostscript[] =
450 {'a','p','p','l','i','c','a','t','i','o','n','/','p','o','s','t','s','c','r','i','p','t',0};
451 static const WCHAR mimeAppXCompressed[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
452 'x','-','c','o','m','p','r','e','s','s','e','d',0};
453 static const WCHAR mimeAppXZip[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
454 'x','-','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0};
455 static const WCHAR mimeAppXGzip[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
456 'x','-','g','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0};
457 static const WCHAR mimeAppJava[] = {'a','p','p','l','i','c','a','t','i','o','n','/','j','a','v','a',0};
458 static const WCHAR mimeAppPdf[] = {'a','p','p','l','i','c','a','t','i','o','n','/','p','d','f',0};
459 static const WCHAR mimeAppXMSDownload[] =
460 {'a','p','p','l','i','c','a','t','i','o','n','/','x','-','m','s','d','o','w','n','l','o','a','d',0};
461 static const WCHAR mimeAudioWav[] = {'a','u','d','i','o','/','w','a','v',0};
462 static const WCHAR mimeAudioBasic[] = {'a','u','d','i','o','/','b','a','s','i','c',0};
464 static const struct {
469 {url1, mimeTextHtml, S_OK},
470 {url2, mimeTextHtml, S_OK},
471 {url3, mimeTextHtml, S_OK},
472 {url4, NULL, E_FAIL},
473 {url5, NULL, __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)},
474 {url6, NULL, E_FAIL},
475 {url7, NULL, __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)}
478 static BYTE data1[] = "test data\n";
479 static BYTE data2[] = {31,'t','e','s',0xfa,'t',' ','d','a','t','a','\n',0};
480 static BYTE data3[] = {0,0,0};
481 static BYTE data4[] = {'t','e','s',0xfa,'t',' ','d','a','t','a','\n',0,0};
482 static BYTE data5[] = {0xa,0xa,0xa,'x',32,'x',0};
483 static BYTE data6[] = {0xfa,0xfa,0xfa,0xfa,'\n','\r','\t','x','x','x',1};
484 static BYTE data7[] = "<html>blahblah";
485 static BYTE data8[] = {'t','e','s',0xfa,'t',' ','<','h','t','m','l','>','d','a','t','a','\n',0,0};
486 static BYTE data9[] = {'t','e',0,'s',0xfa,'t',' ','<','h','t','m','l','>','d','a','t','a','\n',0,0};
487 static BYTE data10[] = "<HtmL>blahblah";
488 static BYTE data11[] = "blah<HTML>blahblah";
489 static BYTE data12[] = "blah<HTMLblahblah";
490 static BYTE data13[] = "blahHTML>blahblah";
491 static BYTE data14[] = "blah<HTMblahblah";
492 static BYTE data15[] = {0xff,0xd8};
493 static BYTE data16[] = {0xff,0xd8,'h'};
494 static BYTE data17[] = {0,0xff,0xd8};
495 static BYTE data18[] = {0xff,0xd8,'<','h','t','m','l','>'};
496 static BYTE data19[] = {'G','I','F','8','7','a'};
497 static BYTE data20[] = {'G','I','F','8','9','a'};
498 static BYTE data21[] = {'G','I','F','8','7'};
499 static BYTE data22[] = {'G','i','F','8','7','a'};
500 static BYTE data23[] = {'G','i','F','8','8','a'};
501 static BYTE data24[] = {'g','i','f','8','7','a'};
502 static BYTE data25[] = {'G','i','F','8','7','A'};
503 static BYTE data26[] = {'G','i','F','8','7','a','<','h','t','m','l','>'};
504 static BYTE data27[] = {0x30,'G','i','F','8','7','A'};
505 static BYTE data28[] = {0x42,0x4d,0x6e,0x42,0x1c,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00};
506 static BYTE data29[] = {0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'x','x','x','x'};
507 static BYTE data30[] = {0x42,0x4d,'x','x','x','x',0x00,0x01,0x00,0x00,'x','x','x','x'};
508 static BYTE data31[] = {0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'<','h','t','m','l','>'};
509 static BYTE data32[] = {0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'x','x','x'};
510 static BYTE data33[] = {0x00,0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'x','x','x'};
511 static BYTE data34[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'x'};
512 static BYTE data35[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'x','x','x','x',0};
513 static BYTE data36[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,'x','x'};
514 static BYTE data37[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'<','h','t','m','l','>'};
515 static BYTE data38[] = {0x00,0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'x'};
516 static BYTE data39[] = {0x4d,0x4d,0x00,0x2a};
517 static BYTE data40[] = {0x4d,0x4d,0x00,0x2a,'<','h','t','m','l','>',0};
518 static BYTE data41[] = {0x4d,0x4d,0xff};
519 static BYTE data42[] = {0x4d,0x4d};
520 static BYTE data43[] = {0x00,0x4d,0x4d,0x00};
521 static BYTE data44[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x20,0xff};
522 static BYTE data45[] = {'R','I','F','f',0xff,0xff,0xff,0xff,'A','V','I',0x20,0xff};
523 static BYTE data46[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x20};
524 static BYTE data47[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x21,0xff};
525 static BYTE data48[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x20,'<','h','t','m','l','>'};
526 static BYTE data49[] = {'R','I','F','F',0x0f,0x0f,0xf0,0xf0,'A','V','I',0x20,0xf0,0x00};
527 static BYTE data50[] = {0x00,0x00,0x01,0xb3,0xff};
528 static BYTE data51[] = {0x00,0x00,0x01,0xba,0xff};
529 static BYTE data52[] = {0x00,0x00,0x01,0xb8,0xff};
530 static BYTE data53[] = {0x00,0x00,0x01,0xba};
531 static BYTE data54[] = {0x00,0x00,0x01,0xba,'<','h','t','m','l','>'};
532 static BYTE data55[] = {0x1f,0x8b,'x'};
533 static BYTE data56[] = {0x1f};
534 static BYTE data57[] = {0x1f,0x8b,'<','h','t','m','l','>','t','e','s','t',0};
535 static BYTE data58[] = {0x1f,0x8b};
536 static BYTE data59[] = {0x50,0x4b,'x'};
537 static BYTE data60[] = {0x50,0x4b};
538 static BYTE data61[] = {0x50,0x4b,'<','h','t','m','l','>',0};
539 static BYTE data62[] = {0xca,0xfe,0xba,0xbe,'x'};
540 static BYTE data63[] = {0xca,0xfe,0xba,0xbe};
541 static BYTE data64[] = {0xca,0xfe,0xba,0xbe,'<','h','t','m','l','>',0};
542 static BYTE data65[] = {0x25,0x50,0x44,0x46,'x'};
543 static BYTE data66[] = {0x25,0x50,0x44,0x46};
544 static BYTE data67[] = {0x25,0x50,0x44,0x46,'x','<','h','t','m','l','>'};
545 static BYTE data68[] = {'M','Z','x'};
546 static BYTE data69[] = {'M','Z'};
547 static BYTE data70[] = {'M','Z','<','h','t','m','l','>',0xff};
548 static BYTE data71[] = {'{','\\','r','t','f',0};
549 static BYTE data72[] = {'{','\\','r','t','f'};
550 static BYTE data73[] = {' ','{','\\','r','t','f',' '};
551 static BYTE data74[] = {'{','\\','r','t','f','<','h','t','m','l','>',' '};
552 static BYTE data75[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'W','A','V','E',0xff};
553 static BYTE data76[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'W','A','V','E'};
554 static BYTE data77[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'W','A','V',0xff,0xff};
555 static BYTE data78[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'<','h','t','m','l','>',0xff};
556 static BYTE data79[] = {'%','!',0xff};
557 static BYTE data80[] = {'%','!'};
558 static BYTE data81[] = {'%','!','P','S','<','h','t','m','l','>'};
559 static BYTE data82[] = {'.','s','n','d',0};
560 static BYTE data83[] = {'.','s','n','d'};
561 static BYTE data84[] = {'.','s','n','d',0,'<','h','t','m','l','>',1,1};
562 static BYTE data85[] = {'.','S','N','D',0};
564 static const struct {
567 LPCWSTR mime, mime_alt;
569 {data1, sizeof(data1), mimeTextPlain},
570 {data2, sizeof(data2), mimeAppOctetStream},
571 {data3, sizeof(data3), mimeAppOctetStream},
572 {data4, sizeof(data4), mimeAppOctetStream},
573 {data5, sizeof(data5), mimeTextPlain},
574 {data6, sizeof(data6), mimeTextPlain},
575 {data7, sizeof(data7), mimeTextHtml, mimeTextPlain /* IE8 */},
576 {data8, sizeof(data8), mimeTextHtml, mimeTextPlain /* IE8 */},
577 {data9, sizeof(data9), mimeTextHtml, mimeImagePjpeg /* IE8 */},
578 {data10, sizeof(data10), mimeTextHtml, mimeTextPlain /* IE8 */},
579 {data11, sizeof(data11), mimeTextHtml, mimeTextPlain /* IE8 */},
580 {data12, sizeof(data12), mimeTextHtml, mimeTextPlain /* IE8 */},
581 {data13, sizeof(data13), mimeTextPlain},
582 {data14, sizeof(data14), mimeTextPlain},
583 {data15, sizeof(data15), mimeTextPlain},
584 {data16, sizeof(data16), mimeImagePjpeg},
585 {data17, sizeof(data17), mimeAppOctetStream},
586 {data18, sizeof(data18), mimeTextHtml},
587 {data19, sizeof(data19), mimeImageGif},
588 {data20, sizeof(data20), mimeImageGif},
589 {data21, sizeof(data21), mimeTextPlain},
590 {data22, sizeof(data22), mimeImageGif},
591 {data23, sizeof(data23), mimeTextPlain},
592 {data24, sizeof(data24), mimeImageGif},
593 {data25, sizeof(data25), mimeImageGif},
594 {data26, sizeof(data26), mimeTextHtml, mimeImageGif /* IE8 */},
595 {data27, sizeof(data27), mimeTextPlain},
596 {data28, sizeof(data28), mimeImageBmp},
597 {data29, sizeof(data29), mimeImageBmp},
598 {data30, sizeof(data30), mimeAppOctetStream},
599 {data31, sizeof(data31), mimeTextHtml, mimeImageBmp /* IE8 */},
600 {data32, sizeof(data32), mimeAppOctetStream},
601 {data33, sizeof(data33), mimeAppOctetStream},
602 {data34, sizeof(data34), mimeImageXPng},
603 {data35, sizeof(data35), mimeImageXPng},
604 {data36, sizeof(data36), mimeAppOctetStream},
605 {data37, sizeof(data37), mimeTextHtml, mimeImageXPng /* IE8 */},
606 {data38, sizeof(data38), mimeAppOctetStream},
607 {data39, sizeof(data39), mimeImageTiff},
608 {data40, sizeof(data40), mimeTextHtml, mimeImageTiff /* IE8 */},
609 {data41, sizeof(data41), mimeImageTiff},
610 {data42, sizeof(data42), mimeTextPlain},
611 {data43, sizeof(data43), mimeAppOctetStream},
612 {data44, sizeof(data44), mimeVideoAvi},
613 {data45, sizeof(data45), mimeTextPlain},
614 {data46, sizeof(data46), mimeTextPlain},
615 {data47, sizeof(data47), mimeTextPlain},
616 {data48, sizeof(data48), mimeTextHtml, mimeVideoAvi /* IE8 */},
617 {data49, sizeof(data49), mimeVideoAvi},
618 {data50, sizeof(data50), mimeVideoMpeg},
619 {data51, sizeof(data51), mimeVideoMpeg},
620 {data52, sizeof(data52), mimeAppOctetStream},
621 {data53, sizeof(data53), mimeAppOctetStream},
622 {data54, sizeof(data54), mimeTextHtml, mimeVideoMpeg /* IE8 */},
623 {data55, sizeof(data55), mimeAppXGzip},
624 {data56, sizeof(data56), mimeTextPlain},
625 {data57, sizeof(data57), mimeTextHtml, mimeAppXGzip /* IE8 */},
626 {data58, sizeof(data58), mimeAppOctetStream},
627 {data59, sizeof(data59), mimeAppXZip},
628 {data60, sizeof(data60), mimeTextPlain},
629 {data61, sizeof(data61), mimeTextHtml, mimeAppXZip /* IE8 */},
630 {data62, sizeof(data62), mimeAppJava},
631 {data63, sizeof(data63), mimeTextPlain},
632 {data64, sizeof(data64), mimeTextHtml, mimeAppJava /* IE8 */},
633 {data65, sizeof(data65), mimeAppPdf},
634 {data66, sizeof(data66), mimeTextPlain},
635 {data67, sizeof(data67), mimeTextHtml, mimeAppPdf /* IE8 */},
636 {data68, sizeof(data68), mimeAppXMSDownload},
637 {data69, sizeof(data69), mimeTextPlain},
638 {data70, sizeof(data70), mimeTextHtml, mimeAppXMSDownload /* IE8 */},
639 {data71, sizeof(data71), mimeTextRichtext},
640 {data72, sizeof(data72), mimeTextPlain},
641 {data73, sizeof(data73), mimeTextPlain},
642 {data74, sizeof(data74), mimeTextHtml, mimeTextRichtext /* IE8 */},
643 {data75, sizeof(data75), mimeAudioWav},
644 {data76, sizeof(data76), mimeTextPlain},
645 {data77, sizeof(data77), mimeTextPlain},
646 {data78, sizeof(data78), mimeTextHtml, mimeTextPlain /* IE8 */},
647 {data79, sizeof(data79), mimeAppPostscript},
648 {data80, sizeof(data80), mimeTextPlain},
649 {data81, sizeof(data81), mimeTextHtml, mimeAppPostscript /* IE8 */},
650 {data82, sizeof(data82), mimeAudioBasic},
651 {data83, sizeof(data83), mimeTextPlain},
652 {data84, sizeof(data84), mimeTextHtml, mimeAudioBasic /* IE8 */},
653 {data85, sizeof(data85), mimeTextPlain}
656 static void test_FindMimeFromData(void)
662 for(i=0; i<sizeof(mime_tests)/sizeof(mime_tests[0]); i++) {
663 mime = (LPWSTR)0xf0f0f0f0;
664 hres = pFindMimeFromData(NULL, mime_tests[i].url, NULL, 0, NULL, 0, &mime, 0);
665 if(mime_tests[i].mime) {
666 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
667 ok(!lstrcmpW(mime, mime_tests[i].mime), "[%d] wrong mime\n", i);
670 ok(hres == E_FAIL || hres == mime_tests[i].hres,
671 "[%d] FindMimeFromData failed: %08x, expected %08x\n",
672 i, hres, mime_tests[i].hres);
673 ok(mime == (LPWSTR)0xf0f0f0f0, "[%d] mime != 0xf0f0f0f0\n", i);
676 mime = (LPWSTR)0xf0f0f0f0;
677 hres = pFindMimeFromData(NULL, mime_tests[i].url, NULL, 0, mimeTextPlain, 0, &mime, 0);
678 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
679 ok(!lstrcmpW(mime, mimeTextPlain), "[%d] wrong mime\n", i);
682 mime = (LPWSTR)0xf0f0f0f0;
683 hres = pFindMimeFromData(NULL, mime_tests[i].url, NULL, 0, mimeAppOctetStream, 0, &mime, 0);
684 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
685 ok(!lstrcmpW(mime, mimeAppOctetStream), "[%d] wrong mime\n", i);
689 for(i=0; i < sizeof(mime_tests2)/sizeof(mime_tests2[0]); i++) {
690 hres = pFindMimeFromData(NULL, NULL, mime_tests2[i].data, mime_tests2[i].size,
692 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
693 ok(!lstrcmpW(mime, mime_tests2[i].mime), "[%d] wrong mime: %s\n", i, wine_dbgstr_w(mime));
696 hres = pFindMimeFromData(NULL, NULL, mime_tests2[i].data, mime_tests2[i].size,
697 mimeTextHtml, 0, &mime, 0);
698 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
699 if(!lstrcmpW(mimeAppOctetStream, mime_tests2[i].mime)
700 || !lstrcmpW(mimeTextPlain, mime_tests2[i].mime))
701 ok(!lstrcmpW(mime, mimeTextHtml), "[%d] wrong mime\n", i);
703 ok(!lstrcmpW(mime, mime_tests2[i].mime), "[%d] wrong mime\n", i);
706 hres = pFindMimeFromData(NULL, NULL, mime_tests2[i].data, mime_tests2[i].size,
707 mimeImagePjpeg, 0, &mime, 0);
708 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
709 if(!lstrcmpW(mimeAppOctetStream, mime_tests2[i].mime) || i == 17)
710 ok(!lstrcmpW(mime, mimeImagePjpeg), "[%d] wrong mime\n", i);
712 ok(!lstrcmpW(mime, mime_tests2[i].mime) ||
713 (mime_tests2[i].mime_alt && !lstrcmpW(mime, mime_tests2[i].mime_alt)),
714 "[%d] wrong mime, got %s\n", i, wine_dbgstr_w(mime));
719 hres = pFindMimeFromData(NULL, url1, data1, sizeof(data1), NULL, 0, &mime, 0);
720 ok(hres == S_OK, "FindMimeFromData failed: %08x\n", hres);
721 ok(!lstrcmpW(mime, mimeTextPlain), "wrong mime\n");
724 hres = pFindMimeFromData(NULL, url1, data1, sizeof(data1), mimeAppOctetStream, 0, &mime, 0);
725 ok(hres == S_OK, "FindMimeFromData failed: %08x\n", hres);
726 ok(!lstrcmpW(mime, mimeTextPlain), "wrong mime\n");
729 hres = pFindMimeFromData(NULL, url4, data1, sizeof(data1), mimeAppOctetStream, 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, NULL, NULL, 0, NULL, 0, &mime, 0);
735 ok(hres == E_INVALIDARG, "FindMimeFromData failed: %08x, excepted E_INVALIDARG\n", hres);
737 hres = pFindMimeFromData(NULL, NULL, NULL, 0, mimeTextPlain, 0, &mime, 0);
738 ok(hres == E_INVALIDARG, "FindMimeFromData failed: %08x, expected E_INVALIDARG\n", hres);
740 hres = pFindMimeFromData(NULL, NULL, data1, 0, NULL, 0, &mime, 0);
741 ok(hres == E_FAIL, "FindMimeFromData failed: %08x, expected E_FAIL\n", hres);
743 hres = pFindMimeFromData(NULL, url1, data1, 0, NULL, 0, &mime, 0);
744 ok(hres == E_FAIL, "FindMimeFromData failed: %08x, expected E_FAIL\n", hres);
746 hres = pFindMimeFromData(NULL, NULL, data1, 0, mimeTextPlain, 0, &mime, 0);
747 ok(hres == S_OK, "FindMimeFromData failed: %08x\n", hres);
748 ok(!lstrcmpW(mime, mimeTextPlain), "wrong mime\n");
751 hres = pFindMimeFromData(NULL, NULL, data1, 0, mimeTextPlain, 0, NULL, 0);
752 ok(hres == E_INVALIDARG, "FindMimeFromData failed: %08x, expected E_INVALIDARG\n", hres);
755 static void register_protocols(void)
757 IInternetSession *session;
758 IClassFactory *factory;
761 static const WCHAR wszAbout[] = {'a','b','o','u','t',0};
763 hres = pCoInternetGetSession(0, &session, 0);
764 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
768 hres = CoGetClassObject(&CLSID_AboutProtocol, CLSCTX_INPROC_SERVER, NULL,
769 &IID_IClassFactory, (void**)&factory);
770 ok(hres == S_OK, "Coud not get AboutProtocol factory: %08x\n", hres);
774 IInternetSession_RegisterNameSpace(session, factory, &CLSID_AboutProtocol,
775 wszAbout, 0, NULL, 0);
776 IClassFactory_Release(factory);
778 IInternetSession_Release(session);
781 static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface,
782 REFIID riid, void **ppv)
784 ok(0, "unexpected call\n");
785 return E_NOINTERFACE;
788 static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
793 static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
798 static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
799 PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
800 DWORD *pcchResult, DWORD dwReserved)
802 CHECK_EXPECT2(ParseUrl);
804 if(ParseAction == PARSE_SECURITY_URL) {
806 *pcchResult = sizeof(url1)/sizeof(WCHAR);
808 if(cchResult<sizeof(url1)/sizeof(WCHAR))
811 memcpy(pwzResult, url1, sizeof(url1));
818 static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
819 LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags,
820 LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
822 ok(0, "unexpected call\n");
826 static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface,
827 LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
829 ok(0, "unexpected call\n");
833 static HRESULT WINAPI InternetProtocolInfo_QueryInfo(IInternetProtocolInfo *iface,
834 LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer,
835 DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
837 ok(0, "unexpected call\n");
841 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl = {
842 InternetProtocolInfo_QueryInterface,
843 InternetProtocolInfo_AddRef,
844 InternetProtocolInfo_Release,
845 InternetProtocolInfo_ParseUrl,
846 InternetProtocolInfo_CombineUrl,
847 InternetProtocolInfo_CompareUrl,
848 InternetProtocolInfo_QueryInfo
851 static IInternetProtocolInfo protocol_info = { &InternetProtocolInfoVtbl };
853 static HRESULT qiret;
854 static IClassFactory *expect_cf;
856 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
858 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
859 CHECK_EXPECT2(QI_IInternetProtocolInfo);
860 ok(iface == expect_cf, "unexpected iface\n");
861 *ppv = &protocol_info;
865 ok(0, "unexpected call\n");
866 return E_NOINTERFACE;
869 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
874 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
879 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
880 REFIID riid, void **ppv)
882 ok(0, "unexpected call\n");
886 static HRESULT WINAPI ProtocolCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
887 REFIID riid, void **ppv)
889 CHECK_EXPECT(CreateInstance);
891 ok(iface == expect_cf, "unexpected iface\n");
892 ok(pOuter == NULL, "pOuter = %p\n", pOuter);
893 ok(IsEqualGUID(&IID_IInternetProtocolInfo, riid), "unexpected riid\n");
894 ok(ppv != NULL, "ppv == NULL\n");
896 *ppv = &protocol_info;
900 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
902 ok(0, "unexpected call\n");
906 static const IClassFactoryVtbl ClassFactoryVtbl = {
907 ClassFactory_QueryInterface,
909 ClassFactory_Release,
910 ClassFactory_CreateInstance,
911 ClassFactory_LockServer
914 static const IClassFactoryVtbl ProtocolCFVtbl = {
915 ClassFactory_QueryInterface,
917 ClassFactory_Release,
918 ProtocolCF_CreateInstance,
919 ClassFactory_LockServer
922 static IClassFactory test_protocol_cf = { &ProtocolCFVtbl };
923 static IClassFactory test_protocol_cf2 = { &ProtocolCFVtbl };
924 static IClassFactory test_cf = { &ClassFactoryVtbl };
926 static void test_NameSpace(void)
928 IInternetSession *session;
934 static const WCHAR wszTest[] = {'t','e','s','t',0};
936 hres = pCoInternetGetSession(0, &session, 0);
937 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
941 hres = IInternetSession_RegisterNameSpace(session, NULL, &IID_NULL,
942 wszTest, 0, NULL, 0);
943 ok(hres == E_INVALIDARG, "RegisterNameSpace failed: %08x\n", hres);
945 hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf, &IID_NULL,
947 ok(hres == E_INVALIDARG, "RegisterNameSpace failed: %08x\n", hres);
949 hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf, &IID_NULL,
950 wszTest, 0, NULL, 0);
951 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
953 qiret = E_NOINTERFACE;
954 expect_cf = &test_protocol_cf;
955 SET_EXPECT(QI_IInternetProtocolInfo);
956 SET_EXPECT(CreateInstance);
957 SET_EXPECT(ParseUrl);
959 hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
961 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
963 CHECK_CALLED(QI_IInternetProtocolInfo);
964 CHECK_CALLED(CreateInstance);
965 CHECK_CALLED(ParseUrl);
968 SET_EXPECT(QI_IInternetProtocolInfo);
969 SET_EXPECT(ParseUrl);
971 hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
973 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
975 CHECK_CALLED(QI_IInternetProtocolInfo);
976 CHECK_CALLED(ParseUrl);
978 SET_EXPECT(QI_IInternetProtocolInfo);
979 SET_EXPECT(ParseUrl);
981 hres = pCoInternetParseUrl(url8, PARSE_SECURITY_URL, 0, buf,
982 sizeof(buf)/sizeof(WCHAR), &size, 0);
983 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
984 ok(size == sizeof(url1)/sizeof(WCHAR), "Size = %d\n", size);
985 if(size == sizeof(url1)/sizeof(WCHAR))
986 ok(!memcmp(buf, url1, sizeof(url1)), "Encoded url = %s\n", wine_dbgstr_w(buf));
988 CHECK_CALLED(QI_IInternetProtocolInfo);
989 CHECK_CALLED(ParseUrl);
991 SET_EXPECT(QI_IInternetProtocolInfo);
992 SET_EXPECT(ParseUrl);
994 if (pCoInternetGetSecurityUrl) {
995 hres = pCoInternetGetSecurityUrl(url8, &sec_url, PSU_SECURITY_URL_ONLY, 0);
996 ok(hres == S_OK, "CoInternetGetSecurityUrl failed: %08x\n", hres);
998 ok(lstrlenW(sec_url)>sizeof(wszFile)/sizeof(WCHAR) &&
999 !memcmp(sec_url, wszFile, sizeof(wszFile)-sizeof(WCHAR)),
1000 "Encoded url = %s\n", wine_dbgstr_w(sec_url));
1001 CoTaskMemFree(sec_url);
1004 CHECK_CALLED(QI_IInternetProtocolInfo);
1005 CHECK_CALLED(ParseUrl);
1008 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
1009 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
1011 hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
1013 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
1015 hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf2, &IID_NULL,
1016 wszTest, 0, NULL, 0);
1017 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
1019 hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf, &IID_NULL,
1020 wszTest, 0, NULL, 0);
1021 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
1023 hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf, &IID_NULL,
1024 wszTest, 0, NULL, 0);
1025 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
1027 SET_EXPECT(QI_IInternetProtocolInfo);
1028 SET_EXPECT(ParseUrl);
1030 hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
1032 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
1034 CHECK_CALLED(QI_IInternetProtocolInfo);
1035 CHECK_CALLED(ParseUrl);
1037 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
1038 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
1040 SET_EXPECT(QI_IInternetProtocolInfo);
1041 SET_EXPECT(ParseUrl);
1043 hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
1045 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
1047 CHECK_CALLED(QI_IInternetProtocolInfo);
1048 CHECK_CALLED(ParseUrl);
1050 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
1051 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
1053 expect_cf = &test_protocol_cf2;
1054 SET_EXPECT(QI_IInternetProtocolInfo);
1055 SET_EXPECT(ParseUrl);
1057 hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
1059 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
1061 CHECK_CALLED(QI_IInternetProtocolInfo);
1062 CHECK_CALLED(ParseUrl);
1064 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
1065 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
1066 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
1067 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
1068 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, NULL);
1069 ok(hres == E_INVALIDARG, "UnregisterNameSpace failed: %08x\n", hres);
1070 hres = IInternetSession_UnregisterNameSpace(session, NULL, wszTest);
1071 ok(hres == E_INVALIDARG, "UnregisterNameSpace failed: %08x\n", hres);
1073 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf2, wszTest);
1074 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
1076 hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
1078 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
1080 IInternetSession_Release(session);
1083 static void test_MimeFilter(void)
1085 IInternetSession *session;
1088 static const WCHAR mimeW[] = {'t','e','s','t','/','m','i','m','e',0};
1090 hres = pCoInternetGetSession(0, &session, 0);
1091 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
1095 hres = IInternetSession_RegisterMimeFilter(session, &test_cf, &IID_NULL, mimeW);
1096 ok(hres == S_OK, "RegisterMimeFilter failed: %08x\n", hres);
1098 hres = IInternetSession_UnregisterMimeFilter(session, &test_cf, mimeW);
1099 ok(hres == S_OK, "UnregisterMimeFilter failed: %08x\n", hres);
1101 hres = IInternetSession_UnregisterMimeFilter(session, &test_cf, mimeW);
1102 ok(hres == S_OK, "UnregisterMimeFilter failed: %08x\n", hres);
1104 hres = IInternetSession_UnregisterMimeFilter(session, (void*)0xdeadbeef, mimeW);
1105 ok(hres == S_OK, "UnregisterMimeFilter failed: %08x\n", hres);
1107 IInternetSession_Release(session);
1110 static ULONG WINAPI unk_Release(IUnknown *iface)
1112 CHECK_EXPECT(unk_Release);
1116 static const IUnknownVtbl unk_vtbl = {
1122 static void test_ReleaseBindInfo(void)
1125 IUnknown unk = { &unk_vtbl };
1127 pReleaseBindInfo(NULL); /* shouldn't crash */
1129 memset(&bi, 0, sizeof(bi));
1130 bi.cbSize = sizeof(BINDINFO);
1132 SET_EXPECT(unk_Release);
1133 pReleaseBindInfo(&bi);
1134 ok(bi.cbSize == sizeof(BINDINFO), "bi.cbSize=%d\n", bi.cbSize);
1135 ok(bi.pUnk == NULL, "bi.pUnk=%p, expected NULL\n", bi.pUnk);
1136 CHECK_CALLED(unk_Release);
1138 memset(&bi, 0, sizeof(bi));
1139 bi.cbSize = offsetof(BINDINFO, pUnk);
1141 pReleaseBindInfo(&bi);
1142 ok(bi.cbSize == offsetof(BINDINFO, pUnk), "bi.cbSize=%d\n", bi.cbSize);
1143 ok(bi.pUnk == &unk, "bi.pUnk=%p, expected %p\n", bi.pUnk, &unk);
1145 memset(&bi, 0, sizeof(bi));
1147 pReleaseBindInfo(&bi);
1148 ok(!bi.cbSize, "bi.cbSize=%d, expected 0\n", bi.cbSize);
1149 ok(bi.pUnk == &unk, "bi.pUnk=%p, expected %p\n", bi.pUnk, &unk);
1152 static void test_CopyStgMedium(void)
1158 static WCHAR fileW[] = {'f','i','l','e',0};
1160 memset(&src, 0xf0, sizeof(src));
1161 memset(&dst, 0xe0, sizeof(dst));
1162 memset(&empty, 0xf0, sizeof(empty));
1163 src.tymed = TYMED_NULL;
1164 src.pUnkForRelease = NULL;
1165 hres = pCopyStgMedium(&src, &dst);
1166 ok(hres == S_OK, "CopyStgMedium failed: %08x\n", hres);
1167 ok(dst.tymed == TYMED_NULL, "tymed=%d\n", dst.tymed);
1168 ok(dst.u.hGlobal == empty, "u=%p\n", dst.u.hGlobal);
1169 ok(!dst.pUnkForRelease, "pUnkForRelease=%p, expected NULL\n", dst.pUnkForRelease);
1171 memset(&dst, 0xe0, sizeof(dst));
1172 src.tymed = TYMED_ISTREAM;
1174 src.pUnkForRelease = NULL;
1175 hres = pCopyStgMedium(&src, &dst);
1176 ok(hres == S_OK, "CopyStgMedium failed: %08x\n", hres);
1177 ok(dst.tymed == TYMED_ISTREAM, "tymed=%d\n", dst.tymed);
1178 ok(!dst.u.pstm, "pstm=%p\n", dst.u.pstm);
1179 ok(!dst.pUnkForRelease, "pUnkForRelease=%p, expected NULL\n", dst.pUnkForRelease);
1181 memset(&dst, 0xe0, sizeof(dst));
1182 src.tymed = TYMED_FILE;
1183 src.u.lpszFileName = fileW;
1184 src.pUnkForRelease = NULL;
1185 hres = pCopyStgMedium(&src, &dst);
1186 ok(hres == S_OK, "CopyStgMedium failed: %08x\n", hres);
1187 ok(dst.tymed == TYMED_FILE, "tymed=%d\n", dst.tymed);
1188 ok(dst.u.lpszFileName && dst.u.lpszFileName != fileW, "lpszFileName=%p\n", dst.u.lpszFileName);
1189 ok(!lstrcmpW(dst.u.lpszFileName, fileW), "wrong file name\n");
1190 ok(!dst.pUnkForRelease, "pUnkForRelease=%p, expected NULL\n", dst.pUnkForRelease);
1191 ReleaseStgMedium(&dst);
1193 hres = pCopyStgMedium(&src, NULL);
1194 ok(hres == E_POINTER, "CopyStgMedium failed: %08x, expected E_POINTER\n", hres);
1195 hres = pCopyStgMedium(NULL, &dst);
1196 ok(hres == E_POINTER, "CopyStgMedium failed: %08x, expected E_POINTER\n", hres);
1199 static void test_UrlMkGetSessionOption(void)
1201 DWORD encoding, size;
1204 size = encoding = 0xdeadbeef;
1205 hres = pUrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING, &encoding,
1206 sizeof(encoding), &size, 0);
1207 ok(hres == S_OK, "UrlMkGetSessionOption failed: %08x\n", hres);
1208 ok(encoding != 0xdeadbeef, "encoding not changed\n");
1209 ok(size == sizeof(encoding), "size=%d\n", size);
1211 size = encoding = 0xdeadbeef;
1212 hres = pUrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING, &encoding,
1213 sizeof(encoding)+1, &size, 0);
1214 ok(hres == S_OK, "UrlMkGetSessionOption failed: %08x\n", hres);
1215 ok(encoding != 0xdeadbeef, "encoding not changed\n");
1216 ok(size == sizeof(encoding), "size=%d\n", size);
1218 size = encoding = 0xdeadbeef;
1219 hres = pUrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING, &encoding,
1220 sizeof(encoding)-1, &size, 0);
1221 ok(hres == E_INVALIDARG, "UrlMkGetSessionOption failed: %08x\n", hres);
1222 ok(encoding == 0xdeadbeef, "encoding = %08x, exepcted 0xdeadbeef\n", encoding);
1223 ok(size == 0xdeadbeef, "size=%d\n", size);
1225 size = encoding = 0xdeadbeef;
1226 hres = pUrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING, NULL,
1227 sizeof(encoding)-1, &size, 0);
1228 ok(hres == E_INVALIDARG, "UrlMkGetSessionOption failed: %08x\n", hres);
1229 ok(encoding == 0xdeadbeef, "encoding = %08x, exepcted 0xdeadbeef\n", encoding);
1230 ok(size == 0xdeadbeef, "size=%d\n", size);
1232 encoding = 0xdeadbeef;
1233 hres = pUrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING, &encoding,
1234 sizeof(encoding)-1, NULL, 0);
1235 ok(hres == E_INVALIDARG, "UrlMkGetSessionOption failed: %08x\n", hres);
1236 ok(encoding == 0xdeadbeef, "encoding = %08x, exepcted 0xdeadbeef\n", encoding);
1239 static void test_user_agent(void)
1241 static const CHAR expected[] = "Mozilla/4.0 (compatible; MSIE ";
1242 static char test_str[] = "test";
1243 static char test2_str[] = "test\0test";
1249 hres = pObtainUserAgentString(0, NULL, NULL);
1250 ok(hres == E_INVALIDARG, "ObtainUserAgentString failed: %08x\n", hres);
1253 hres = pObtainUserAgentString(0, NULL, &size);
1254 ok(hres == E_INVALIDARG, "ObtainUserAgentString failed: %08x\n", hres);
1255 ok(size == 100, "size=%d, expected %d\n", size, 100);
1258 hres = pObtainUserAgentString(0, str, &size);
1259 ok(hres == E_OUTOFMEMORY, "ObtainUserAgentString failed: %08x\n", hres);
1260 ok(size > 0, "size=%d, expected non-zero\n", size);
1264 hres = pObtainUserAgentString(0, str, &size);
1265 ok(hres == E_OUTOFMEMORY, "ObtainUserAgentString failed: %08x\n", hres);
1266 ok(size > 0, "size=%d, expected non-zero\n", size);
1267 ok(str[0] == 'a', "str[0]=%c, expected 'a'\n", str[0]);
1270 hres = pObtainUserAgentString(1, str, &size);
1271 ok(hres == E_OUTOFMEMORY, "ObtainUserAgentString failed: %08x\n", hres);
1272 ok(size > 0, "size=%d, expected non-zero\n", size);
1274 str2 = HeapAlloc(GetProcessHeap(), 0, (size+20)*sizeof(CHAR));
1276 hres = pObtainUserAgentString(0, str2, &size);
1277 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
1278 ok(size == saved, "size=%d, expected %d\n", size, saved);
1279 ok(strlen(expected) <= strlen(str2) &&
1280 !memcmp(expected, str2, strlen(expected)*sizeof(CHAR)),
1281 "user agent was \"%s\", expected to start with \"%s\"\n",
1285 hres = pObtainUserAgentString(0, str2, &size);
1286 ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
1287 ok(size == saved, "size=%d, expected %d\n", size, saved);
1290 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, NULL, 0, &size, 0);
1291 ok(hres == E_OUTOFMEMORY, "UrlMkGetSessionOption failed: %08x\n", hres);
1292 ok(size, "size == 0\n");
1295 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, NULL, 1000, &size, 0);
1296 ok(hres == E_INVALIDARG, "UrlMkGetSessionOption failed: %08x\n", hres);
1297 ok(size, "size == 0\n");
1301 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, str2, saved+10, &size, 0);
1302 ok(hres == E_OUTOFMEMORY, "UrlMkGetSessionOption failed: %08x\n", hres);
1303 ok(size == saved, "size = %d, expected %d\n", size, saved);
1304 ok(sizeof(expected) <= strlen(str2) && !memcmp(expected, str2, sizeof(expected)-1),
1305 "user agent was \"%s\", expected to start with \"%s\"\n",
1310 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, str2, saved, &size, 0);
1311 ok(hres == E_OUTOFMEMORY, "UrlMkGetSessionOption failed: %08x\n", hres);
1312 ok(size == saved, "size = %d, expected %d\n", size, saved);
1313 ok(sizeof(expected) <= strlen(str2) && !memcmp(expected, str2, sizeof(expected)-1),
1314 "user agent was \"%s\", expected to start with \"%s\"\n",
1319 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, str2, saved-1, &size, 0);
1320 ok(hres == E_OUTOFMEMORY, "UrlMkGetSessionOption failed: %08x\n", hres);
1321 ok(size == saved, "size = %d, expected %d\n", size, saved);
1322 ok(!str2[0], "buf changed\n");
1326 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, str2, saved, NULL, 0);
1327 ok(hres == E_INVALIDARG, "UrlMkGetSessionOption failed: %08x\n", hres);
1328 ok(!str2[0], "buf changed\n");
1330 hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, test_str, sizeof(test_str), 0);
1331 ok(hres == S_OK, "UrlMkSetSessionOption failed: %08x\n", hres);
1335 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, str2, saved, &size, 0);
1336 ok(hres == E_OUTOFMEMORY, "UrlMkGetSessionOption failed: %08x\n", hres);
1337 ok(size == sizeof(test_str) && !memcmp(str2, test_str, sizeof(test_str)), "wrong user agent\n");
1339 hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, test2_str, sizeof(test2_str), 0);
1340 ok(hres == S_OK, "UrlMkSetSessionOption failed: %08x\n", hres);
1344 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, str2, saved, &size, 0);
1345 ok(hres == E_OUTOFMEMORY, "UrlMkGetSessionOption failed: %08x\n", hres);
1346 ok(size == sizeof(test_str) && !memcmp(str2, test_str, sizeof(test_str)), "wrong user agent\n");
1348 hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, test_str, 2, 0);
1349 ok(hres == S_OK, "UrlMkSetSessionOption failed: %08x\n", hres);
1353 hres = pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT, str2, saved, &size, 0);
1354 ok(hres == E_OUTOFMEMORY, "UrlMkGetSessionOption failed: %08x\n", hres);
1355 ok(size == 3 && !strcmp(str2, "te"), "wrong user agent\n");
1357 hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, test_str, 0, 0);
1358 ok(hres == E_INVALIDARG, "UrlMkSetSessionOption failed: %08x\n", hres);
1360 hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, NULL, sizeof(test_str), 0);
1361 ok(hres == E_INVALIDARG, "UrlMkSetSessionOption failed: %08x\n", hres);
1363 hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, NULL, 0, 0);
1364 ok(hres == E_INVALIDARG, "UrlMkSetSessionOption failed: %08x\n", hres);
1366 HeapFree(GetProcessHeap(), 0, str2);
1369 static void test_MkParseDisplayNameEx(void)
1371 IMoniker *mon = NULL;
1378 static const WCHAR clsid_nameW[] = {'c','l','s','i','d',':',
1379 '2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8',
1380 '-','0','8','0','0','2','B','3','0','3','0','9','D',':',0};
1385 LPCWSTR szDisplayName;
1388 } invalid_parameters[] =
1390 {NULL, NULL, NULL, NULL},
1391 {NULL, NULL, NULL, &mon},
1392 {NULL, NULL, &eaten, NULL},
1393 {NULL, NULL, &eaten, &mon},
1394 {NULL, wszEmpty, NULL, NULL},
1395 {NULL, wszEmpty, NULL, &mon},
1396 {NULL, wszEmpty, &eaten, NULL},
1397 {NULL, wszEmpty, &eaten, &mon},
1398 {&bctx, NULL, NULL, NULL},
1399 {&bctx, NULL, NULL, &mon},
1400 {&bctx, NULL, &eaten, NULL},
1401 {&bctx, NULL, &eaten, &mon},
1402 {&bctx, wszEmpty, NULL, NULL},
1403 {&bctx, wszEmpty, NULL, &mon},
1404 {&bctx, wszEmpty, &eaten, NULL},
1405 {&bctx, wszEmpty, &eaten, &mon},
1410 CreateBindCtx(0, &bctx);
1412 for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
1415 mon = (IMoniker *)0xdeadbeef;
1416 hres = MkParseDisplayNameEx(invalid_parameters[i].ppbc ? *invalid_parameters[i].ppbc : NULL,
1417 invalid_parameters[i].szDisplayName,
1418 invalid_parameters[i].pchEaten,
1419 invalid_parameters[i].ppmk);
1420 ok(hres == E_INVALIDARG,
1421 "[%d] Expected MkParseDisplayNameEx to return E_INVALIDARG, got %08x\n", i, hres);
1422 ok(eaten == 0xdeadbeef, "[%d] Expected eaten to be 0xdeadbeef, got %u\n", i, eaten);
1423 ok(mon == (IMoniker *)0xdeadbeef, "[%d] Expected mon to be 0xdeadbeef, got %p\n", i, mon);
1426 hres = MkParseDisplayNameEx(bctx, url9, &eaten, &mon);
1427 ok(hres == S_OK, "MkParseDisplayNameEx failed: %08x\n", hres);
1428 ok(eaten == sizeof(url9)/sizeof(WCHAR)-1, "eaten=%d\n", eaten);
1429 ok(mon != NULL, "mon == NULL\n");
1431 hres = IMoniker_GetDisplayName(mon, NULL, 0, &name);
1432 ok(hres == S_OK, "GetDiasplayName failed: %08x\n", hres);
1433 ok(!lstrcmpW(name, url9), "wrong display name %s\n", wine_dbgstr_w(name));
1434 CoTaskMemFree(name);
1436 hres = IMoniker_IsSystemMoniker(mon, &issys);
1437 ok(hres == S_OK, "IsSystemMoniker failed: %08x\n", hres);
1438 ok(issys == MKSYS_URLMONIKER, "issys=%x\n", issys);
1440 IMoniker_Release(mon);
1442 hres = MkParseDisplayNameEx(bctx, clsid_nameW, &eaten, &mon);
1443 ok(hres == S_OK, "MkParseDisplayNameEx failed: %08x\n", hres);
1444 ok(eaten == sizeof(clsid_nameW)/sizeof(WCHAR)-1, "eaten=%d\n", eaten);
1445 ok(mon != NULL, "mon == NULL\n");
1447 hres = IMoniker_IsSystemMoniker(mon, &issys);
1448 ok(hres == S_OK, "IsSystemMoniker failed: %08x\n", hres);
1449 ok(issys == MKSYS_CLASSMONIKER, "issys=%x\n", issys);
1451 IMoniker_Release(mon);
1453 hres = MkParseDisplayNameEx(bctx, url8, &eaten, &mon);
1454 ok(FAILED(hres), "MkParseDisplayNameEx succeeded: %08x\n", hres);
1456 IBindCtx_Release(bctx);
1459 static void test_IsValidURL(void)
1462 IBindCtx *bctx = NULL;
1464 hr = IsValidURL(NULL, 0, 0);
1465 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
1467 hr = IsValidURL(NULL, wszHttpWineHQ, 0);
1468 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1470 CreateBindCtx(0, &bctx);
1472 hr = IsValidURL(bctx, wszHttpWineHQ, 0);
1473 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1475 IBindCtx_Release(bctx);
1482 hurlmon = GetModuleHandle("urlmon.dll");
1483 pCoInternetCompareUrl = (void *) GetProcAddress(hurlmon, "CoInternetCompareUrl");
1484 pCoInternetGetSecurityUrl = (void*) GetProcAddress(hurlmon, "CoInternetGetSecurityUrl");
1485 pCoInternetGetSession = (void*) GetProcAddress(hurlmon, "CoInternetGetSession");
1486 pCoInternetParseUrl = (void*) GetProcAddress(hurlmon, "CoInternetParseUrl");
1487 pCoInternetQueryInfo = (void*) GetProcAddress(hurlmon, "CoInternetQueryInfo");
1488 pCopyStgMedium = (void*) GetProcAddress(hurlmon, "CopyStgMedium");
1489 pFindMimeFromData = (void*) GetProcAddress(hurlmon, "FindMimeFromData");
1490 pObtainUserAgentString = (void*) GetProcAddress(hurlmon, "ObtainUserAgentString");
1491 pReleaseBindInfo = (void*) GetProcAddress(hurlmon, "ReleaseBindInfo");
1492 pUrlMkGetSessionOption = (void*) GetProcAddress(hurlmon, "UrlMkGetSessionOption");
1493 pCompareSecurityIds = (void*) GetProcAddress(hurlmon, "CompareSecurityIds");
1495 if (!pCoInternetCompareUrl || !pCoInternetGetSecurityUrl ||
1496 !pCoInternetGetSession || !pCoInternetParseUrl || !pCompareSecurityIds) {
1497 win_skip("Various needed functions not present, too old IE\n");
1501 OleInitialize(NULL);
1503 register_protocols();
1505 test_CreateFormatEnum();
1506 test_RegisterFormatEnumerator();
1507 test_CoInternetParseUrl();
1508 test_CoInternetCompareUrl();
1509 test_CoInternetQueryInfo();
1510 test_FindMimeFromData();
1513 test_ReleaseBindInfo();
1514 test_CopyStgMedium();
1515 test_UrlMkGetSessionOption();
1517 test_MkParseDisplayNameEx();