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
22 #include <wine/test.h>
33 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
35 #define DEFINE_EXPECT(func) \
36 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
38 #define SET_EXPECT(func) \
39 expect_ ## func = TRUE
41 #define CHECK_EXPECT(func) \
43 ok(expect_ ##func, "unexpected call " #func "\n"); \
44 expect_ ## func = FALSE; \
45 called_ ## func = TRUE; \
48 #define CHECK_EXPECT2(func) \
50 ok(expect_ ##func, "unexpected call " #func "\n"); \
51 called_ ## func = TRUE; \
54 #define CHECK_CALLED(func) \
56 ok(called_ ## func, "expected " #func "\n"); \
57 expect_ ## func = called_ ## func = FALSE; \
60 DEFINE_EXPECT(ParseUrl);
61 DEFINE_EXPECT(QI_IInternetProtocolInfo);
62 DEFINE_EXPECT(CreateInstance);
63 DEFINE_EXPECT(unk_Release);
65 static void test_CreateFormatEnum(void)
67 IEnumFORMATETC *fenum = NULL, *fenum2 = NULL;
72 static DVTARGETDEVICE dev = {sizeof(dev),0,0,0,0,{0}};
73 static FORMATETC formatetc[] = {
81 hres = CreateFormatEnumerator(0, formatetc, &fenum);
82 ok(hres == E_FAIL, "CreateFormatEnumerator failed: %08x, expected E_FAIL\n", hres);
83 hres = CreateFormatEnumerator(0, formatetc, NULL);
84 ok(hres == E_INVALIDARG, "CreateFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres);
85 hres = CreateFormatEnumerator(5, formatetc, NULL);
86 ok(hres == E_INVALIDARG, "CreateFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres);
89 hres = CreateFormatEnumerator(5, formatetc, &fenum);
90 ok(hres == S_OK, "CreateFormatEnumerator failed: %08x\n", hres);
94 hres = IEnumFORMATETC_Next(fenum, 2, NULL, &ul);
95 ok(hres == E_INVALIDARG, "Next failed: %08x, expected E_INVALIDARG\n", hres);
97 hres = IEnumFORMATETC_Next(fenum, 0, fetc, &ul);
98 ok(hres == S_OK, "Next failed: %08x\n", hres);
99 ok(ul == 0, "ul=%d, expected 0\n", ul);
101 hres = IEnumFORMATETC_Next(fenum, 2, fetc, &ul);
102 ok(hres == S_OK, "Next failed: %08x\n", hres);
103 ok(fetc[0].lindex == 0, "fetc[0].lindex=%d, expected 0\n", fetc[0].lindex);
104 ok(fetc[1].lindex == 1, "fetc[1].lindex=%d, expected 1\n", fetc[1].lindex);
105 ok(fetc[0].ptd == &dev, "fetc[0].ptd=%p, expected %p\n", fetc[0].ptd, &dev);
106 ok(ul == 2, "ul=%d, expected 2\n", ul);
108 hres = IEnumFORMATETC_Skip(fenum, 1);
109 ok(hres == S_OK, "Skip failed: %08x\n", hres);
111 hres = IEnumFORMATETC_Next(fenum, 4, fetc, &ul);
112 ok(hres == S_FALSE, "Next failed: %08x, expected S_FALSE\n", hres);
113 ok(fetc[0].lindex == 3, "fetc[0].lindex=%d, expected 3\n", fetc[0].lindex);
114 ok(fetc[1].lindex == 4, "fetc[1].lindex=%d, expected 4\n", fetc[1].lindex);
115 ok(fetc[0].ptd == NULL, "fetc[0].ptd=%p, expected NULL\n", fetc[0].ptd);
116 ok(ul == 2, "ul=%d, expected 2\n", ul);
118 hres = IEnumFORMATETC_Next(fenum, 4, fetc, &ul);
119 ok(hres == S_FALSE, "Next failed: %08x, expected S_FALSE\n", hres);
120 ok(ul == 0, "ul=%d, expected 0\n", ul);
122 hres = IEnumFORMATETC_Next(fenum, 0, fetc, &ul);
123 ok(hres == S_OK, "Next failed: %08x\n", hres);
124 ok(ul == 0, "ul=%d, expected 0\n", ul);
126 hres = IEnumFORMATETC_Skip(fenum, 3);
127 ok(hres == S_FALSE, "Skip failed: %08x, expected S_FALSE\n", hres);
129 hres = IEnumFORMATETC_Reset(fenum);
130 ok(hres == S_OK, "Reset failed: %08x\n", hres);
132 hres = IEnumFORMATETC_Next(fenum, 5, fetc, NULL);
133 ok(hres == S_OK, "Next failed: %08x\n", hres);
134 ok(fetc[0].lindex == 0, "fetc[0].lindex=%d, expected 0\n", fetc[0].lindex);
136 hres = IEnumFORMATETC_Reset(fenum);
137 ok(hres == S_OK, "Reset failed: %08x\n", hres);
139 hres = IEnumFORMATETC_Skip(fenum, 2);
140 ok(hres == S_OK, "Skip failed: %08x\n", hres);
142 hres = IEnumFORMATETC_Clone(fenum, NULL);
143 ok(hres == E_INVALIDARG, "Clone failed: %08x, expected E_INVALIDARG\n", hres);
145 hres = IEnumFORMATETC_Clone(fenum, &fenum2);
146 ok(hres == S_OK, "Clone failed: %08x\n", hres);
148 if(SUCCEEDED(hres)) {
149 ok(fenum != fenum2, "fenum == fenum2\n");
151 hres = IEnumFORMATETC_Next(fenum2, 2, fetc, &ul);
152 ok(hres == S_OK, "Next failed: %08x\n", hres);
153 ok(fetc[0].lindex == 2, "fetc[0].lindex=%d, expected 2\n", fetc[0].lindex);
155 IEnumFORMATETC_Release(fenum2);
158 hres = IEnumFORMATETC_Next(fenum, 2, fetc, &ul);
159 ok(hres == S_OK, "Next failed: %08x\n", hres);
160 ok(fetc[0].lindex == 2, "fetc[0].lindex=%d, expected 2\n", fetc[0].lindex);
162 hres = IEnumFORMATETC_Skip(fenum, 1);
163 ok(hres == S_OK, "Skip failed: %08x\n", hres);
165 IEnumFORMATETC_Release(fenum);
168 static void test_RegisterFormatEnumerator(void)
170 IBindCtx *bctx = NULL;
171 IEnumFORMATETC *format = NULL, *format2 = NULL;
172 IUnknown *unk = NULL;
175 static FORMATETC formatetc = {0,NULL,0,0,0};
176 static WCHAR wszEnumFORMATETC[] =
177 {'_','E','n','u','m','F','O','R','M','A','T','E','T','C','_',0};
179 CreateBindCtx(0, &bctx);
181 hres = CreateFormatEnumerator(1, &formatetc, &format);
182 ok(hres == S_OK, "CreateFormatEnumerator failed: %08x\n", hres);
186 hres = RegisterFormatEnumerator(NULL, format, 0);
187 ok(hres == E_INVALIDARG,
188 "RegisterFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres);
189 hres = RegisterFormatEnumerator(bctx, NULL, 0);
190 ok(hres == E_INVALIDARG,
191 "RegisterFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres);
193 hres = RegisterFormatEnumerator(bctx, format, 0);
194 ok(hres == S_OK, "RegisterFormatEnumerator failed: %08x\n", hres);
196 hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
197 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
198 ok(unk == (IUnknown*)format, "unk != format\n");
200 hres = RevokeFormatEnumerator(NULL, format);
201 ok(hres == E_INVALIDARG,
202 "RevokeFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres);
204 hres = RevokeFormatEnumerator(bctx, format);
205 ok(hres == S_OK, "RevokeFormatEnumerator failed: %08x\n", hres);
207 hres = RevokeFormatEnumerator(bctx, format);
208 ok(hres == E_FAIL, "RevokeFormatEnumerator failed: %08x, expected E_FAIL\n", hres);
210 hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
211 ok(hres == E_FAIL, "GetObjectParam failed: %08x, expected E_FAIL\n", hres);
213 hres = RegisterFormatEnumerator(bctx, format, 0);
214 ok(hres == S_OK, "RegisterFormatEnumerator failed: %08x\n", hres);
216 hres = CreateFormatEnumerator(1, &formatetc, &format2);
217 ok(hres == S_OK, "CreateFormatEnumerator failed: %08x\n", hres);
219 if(SUCCEEDED(hres)) {
220 hres = RevokeFormatEnumerator(bctx, format);
221 ok(hres == S_OK, "RevokeFormatEnumerator failed: %08x\n", hres);
223 IEnumFORMATETC_Release(format2);
226 hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
227 ok(hres == E_FAIL, "GetObjectParam failed: %08x, expected E_FAIL\n", hres);
229 IEnumFORMATETC_Release(format);
231 hres = RegisterFormatEnumerator(bctx, format, 0);
232 ok(hres == S_OK, "RegisterFormatEnumerator failed: %08x\n", hres);
233 hres = RevokeFormatEnumerator(bctx, NULL);
234 ok(hres == S_OK, "RevokeFormatEnumerator failed: %08x\n", hres);
235 hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
236 ok(hres == E_FAIL, "GetObjectParam failed: %08x, expected E_FAIL\n", hres);
238 IBindCtx_Release(bctx);
241 static const WCHAR url1[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',
242 '/','b','l','a','n','k','.','h','t','m',0};
243 static const WCHAR url2[] = {'i','n','d','e','x','.','h','t','m',0};
244 static const WCHAR url3[] = {'f','i','l','e',':','c',':','\\','I','n','d','e','x','.','h','t','m',0};
245 static const WCHAR url4[] = {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e',
246 '%','2','e','j','p','g',0};
247 static const WCHAR url5[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
249 static const WCHAR url6[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
250 static const WCHAR url7[] = {'f','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g','/',
251 'f','i','l','e','.','t','e','s','t',0};
252 static const WCHAR url8[] = {'t','e','s','t',':','1','2','3','a','b','c',0};
255 static const WCHAR url4e[] = {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e',
258 static const WCHAR path3[] = {'c',':','\\','I','n','d','e','x','.','h','t','m',0};
259 static const WCHAR path4[] = {'s','o','m','e',' ','f','i','l','e','.','j','p','g',0};
261 static const WCHAR wszRes[] = {'r','e','s',0};
262 static const WCHAR wszFile[] = {'f','i','l','e',0};
263 static const WCHAR wszHttp[] = {'h','t','t','p',0};
264 static const WCHAR wszAbout[] = {'a','b','o','u','t',0};
265 static const WCHAR wszEmpty[] = {0};
276 static const struct parse_test parse_tests[] = {
277 {url1, S_OK, url1, E_INVALIDARG, NULL, wszRes},
278 {url2, E_FAIL, url2, E_INVALIDARG, NULL, wszEmpty},
279 {url3, E_FAIL, url3, S_OK, path3, wszFile},
280 {url4, E_FAIL, url4e, S_OK, path4, wszFile},
281 {url5, E_FAIL, url5, E_INVALIDARG, NULL, wszHttp},
282 {url6, S_OK, url6, E_INVALIDARG, NULL, wszAbout}
285 static void test_CoInternetParseUrl(void)
291 static WCHAR buf[4096];
293 memset(buf, 0xf0, sizeof(buf));
294 hres = CoInternetParseUrl(parse_tests[0].url, PARSE_SCHEMA, 0, buf,
296 ok(hres == E_POINTER, "schema failed: %08x, expected E_POINTER\n", hres);
298 for(i=0; i < sizeof(parse_tests)/sizeof(parse_tests[0]); i++) {
299 memset(buf, 0xf0, sizeof(buf));
300 hres = CoInternetParseUrl(parse_tests[i].url, PARSE_SECURITY_URL, 0, buf,
301 sizeof(buf)/sizeof(WCHAR), &size, 0);
302 ok(hres == parse_tests[i].secur_hres, "[%d] security url failed: %08x, expected %08x\n",
303 i, hres, parse_tests[i].secur_hres);
305 memset(buf, 0xf0, sizeof(buf));
306 hres = CoInternetParseUrl(parse_tests[i].url, PARSE_ENCODE, 0, buf,
307 sizeof(buf)/sizeof(WCHAR), &size, 0);
308 ok(hres == S_OK, "[%d] encoding failed: %08x\n", i, hres);
309 ok(size == lstrlenW(parse_tests[i].encoded_url), "[%d] wrong size\n", i);
310 ok(!lstrcmpW(parse_tests[i].encoded_url, buf), "[%d] wrong encoded url\n", i);
312 memset(buf, 0xf0, sizeof(buf));
313 hres = CoInternetParseUrl(parse_tests[i].url, PARSE_PATH_FROM_URL, 0, buf,
314 sizeof(buf)/sizeof(WCHAR), &size, 0);
315 ok(hres == parse_tests[i].path_hres, "[%d] path failed: %08x, expected %08x\n",
316 i, hres, parse_tests[i].path_hres);
317 if(parse_tests[i].path) {
318 ok(size == lstrlenW(parse_tests[i].path), "[%d] wrong size\n", i);
319 ok(!lstrcmpW(parse_tests[i].path, buf), "[%d] wrong path\n", i);
322 memset(buf, 0xf0, sizeof(buf));
323 hres = CoInternetParseUrl(parse_tests[i].url, PARSE_SCHEMA, 0, buf,
324 sizeof(buf)/sizeof(WCHAR), &size, 0);
325 ok(hres == S_OK, "[%d] schema failed: %08x\n", i, hres);
326 ok(size == lstrlenW(parse_tests[i].schema), "[%d] wrong size\n", i);
327 ok(!lstrcmpW(parse_tests[i].schema, buf), "[%d] wrong schema\n", i);
331 static void test_CoInternetCompareUrl(void)
335 hres = CoInternetCompareUrl(url1, url1, 0);
336 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
338 hres = CoInternetCompareUrl(url1, url3, 0);
339 ok(hres == S_FALSE, "CoInternetParseUrl failed: %08x\n", hres);
341 hres = CoInternetCompareUrl(url3, url1, 0);
342 ok(hres == S_FALSE, "CoInternetParseUrl failed: %08x\n", hres);
345 static const WCHAR mimeTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
346 static const WCHAR mimeTextPlain[] = {'t','e','x','t','/','p','l','a','i','n',0};
347 static const WCHAR mimeAppOctetStream[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
348 'o','c','t','e','t','-','s','t','r','e','a','m',0};
349 static const WCHAR mimeImagePjpeg[] = {'i','m','a','g','e','/','p','j','p','e','g',0};
350 static const WCHAR mimeImageGif[] = {'i','m','a','g','e','/','g','i','f',0};
351 static const WCHAR mimeImageBmp[] = {'i','m','a','g','e','/','b','m','p',0};
352 static const WCHAR mimeImageXPng[] = {'i','m','a','g','e','/','x','-','p','n','g',0};
353 static const WCHAR mimeImageTiff[] = {'i','m','a','g','e','/','t','i','f','f',0};
354 static const WCHAR mimeVideoAvi[] = {'v','i','d','e','o','/','a','v','i',0};
355 static const WCHAR mimeVideoMpeg[] = {'v','i','d','e','o','/','m','p','e','g',0};
356 static const WCHAR mimeAppXCompressed[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
357 'x','-','c','o','m','p','r','e','s','s','e','d',0};
358 static const WCHAR mimeAppXZip[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
359 'x','-','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0};
360 static const WCHAR mimeAppXGzip[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
361 'x','-','g','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0};
362 static const WCHAR mimeAppJava[] = {'a','p','p','l','i','c','a','t','i','o','n','/','j','a','v','a',0};
363 static const WCHAR mimeAppPdf[] = {'a','p','p','l','i','c','a','t','i','o','n','/','p','d','f',0};
364 static const WCHAR mimeAppXMSDownload[] =
365 {'a','p','p','l','i','c','a','t','i','o','n','/','x','-','m','s','d','o','w','n','l','o','a','d',0};
367 static const struct {
371 {url1, mimeTextHtml},
372 {url2, mimeTextHtml},
373 {url3, mimeTextHtml},
380 static BYTE data1[] = "test data\n";
381 static BYTE data2[] = {31,'t','e','s',0xfa,'t',' ','d','a','t','a','\n',0};
382 static BYTE data3[] = {0,0,0};
383 static BYTE data4[] = {'t','e','s',0xfa,'t',' ','d','a','t','a','\n',0,0};
384 static BYTE data5[] = {0xa,0xa,0xa,'x',32,'x',0};
385 static BYTE data6[] = {0xfa,0xfa,0xfa,0xfa,'\n','\r','\t','x','x','x',1};
386 static BYTE data7[] = "<html>blahblah";
387 static BYTE data8[] = {'t','e','s',0xfa,'t',' ','<','h','t','m','l','>','d','a','t','a','\n',0,0};
388 static BYTE data9[] = {'t','e',0,'s',0xfa,'t',' ','<','h','t','m','l','>','d','a','t','a','\n',0,0};
389 static BYTE data10[] = "<HtmL>blahblah";
390 static BYTE data11[] = "blah<HTML>blahblah";
391 static BYTE data12[] = "blah<HTMLblahblah";
392 static BYTE data13[] = "blahHTML>blahblah";
393 static BYTE data14[] = "blah<HTMblahblah";
394 static BYTE data15[] = {0xff,0xd8};
395 static BYTE data16[] = {0xff,0xd8,'h'};
396 static BYTE data17[] = {0,0xff,0xd8};
397 static BYTE data18[] = {0xff,0xd8,'<','h','t','m','l','>'};
398 static BYTE data19[] = {'G','I','F','8','7','a'};
399 static BYTE data20[] = {'G','I','F','8','9','a'};
400 static BYTE data21[] = {'G','I','F','8','7'};
401 static BYTE data22[] = {'G','i','F','8','7','a'};
402 static BYTE data23[] = {'G','i','F','8','8','a'};
403 static BYTE data24[] = {'g','i','f','8','7','a'};
404 static BYTE data25[] = {'G','i','F','8','7','A'};
405 static BYTE data26[] = {'G','i','F','8','7','a','<','h','t','m','l','>'};
406 static BYTE data27[] = {0x30,'G','i','F','8','7','A'};
407 static BYTE data28[] = {0x42,0x4d,0x6e,0x42,0x1c,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00};
408 static BYTE data29[] = {0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'x','x','x','x'};
409 static BYTE data30[] = {0x42,0x4d,'x','x','x','x',0x00,0x01,0x00,0x00,'x','x','x','x'};
410 static BYTE data31[] = {0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'<','h','t','m','l','>'};
411 static BYTE data32[] = {0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'x','x','x'};
412 static BYTE data33[] = {0x00,0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'x','x','x'};
413 static BYTE data34[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'x'};
414 static BYTE data35[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'x','x','x','x',0};
415 static BYTE data36[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,'x','x'};
416 static BYTE data37[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'<','h','t','m','l','>'};
417 static BYTE data38[] = {0x00,0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'x'};
418 static BYTE data39[] = {0x4d,0x4d,0x00,0x2a};
419 static BYTE data40[] = {0x4d,0x4d,0x00,0x2a,'<','h','t','m','l','>',0};
420 static BYTE data41[] = {0x4d,0x4d,0xff};
421 static BYTE data42[] = {0x4d,0x4d};
422 static BYTE data43[] = {0x00,0x4d,0x4d,0x00};
423 static BYTE data44[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x20,0xff};
424 static BYTE data45[] = {'R','I','F','f',0xff,0xff,0xff,0xff,'A','V','I',0x20,0xff};
425 static BYTE data46[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x20};
426 static BYTE data47[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x21,0xff};
427 static BYTE data48[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x20,'<','h','t','m','l','>'};
428 static BYTE data49[] = {'R','I','F','F',0x0f,0x0f,0xf0,0xf0,'A','V','I',0x20,0xf0,0x00};
429 static BYTE data50[] = {0x00,0x00,0x01,0xb3,0xff};
430 static BYTE data51[] = {0x00,0x00,0x01,0xba,0xff};
431 static BYTE data52[] = {0x00,0x00,0x01,0xb8,0xff};
432 static BYTE data53[] = {0x00,0x00,0x01,0xba};
433 static BYTE data54[] = {0x00,0x00,0x01,0xba,'<','h','t','m','l','>'};
434 static BYTE data55[] = {0x1f,0x8b,'x'};
435 static BYTE data56[] = {0x1f};
436 static BYTE data57[] = {0x1f,0x8b,'<','h','t','m','l','>','t','e','s','t',0};
437 static BYTE data58[] = {0x1f,0x8b};
438 static BYTE data59[] = {0x50,0x4b,'x'};
439 static BYTE data60[] = {0x50,0x4b};
440 static BYTE data61[] = {0x50,0x4b,'<','h','t','m','l','>',0};
441 static BYTE data62[] = {0xca,0xfe,0xba,0xbe,'x'};
442 static BYTE data63[] = {0xca,0xfe,0xba,0xbe};
443 static BYTE data64[] = {0xca,0xfe,0xba,0xbe,'<','h','t','m','l','>',0};
444 static BYTE data65[] = {0x25,0x50,0x44,0x46,'x'};
445 static BYTE data66[] = {0x25,0x50,0x44,0x46};
446 static BYTE data67[] = {0x25,0x50,0x44,0x46,'x','<','h','t','m','l','>'};
447 static BYTE data68[] = {'M','Z','x'};
448 static BYTE data69[] = {'M','Z'};
449 static BYTE data70[] = {'M','Z','<','h','t','m','l','>',0xff};
451 static const struct {
456 {data1, sizeof(data1), mimeTextPlain},
457 {data2, sizeof(data2), mimeAppOctetStream},
458 {data3, sizeof(data3), mimeAppOctetStream},
459 {data4, sizeof(data4), mimeAppOctetStream},
460 {data5, sizeof(data5), mimeTextPlain},
461 {data6, sizeof(data6), mimeTextPlain},
462 {data7, sizeof(data7), mimeTextHtml},
463 {data8, sizeof(data8), mimeTextHtml},
464 {data9, sizeof(data9), mimeTextHtml},
465 {data10, sizeof(data10), mimeTextHtml},
466 {data11, sizeof(data11), mimeTextHtml},
467 {data12, sizeof(data12), mimeTextHtml},
468 {data13, sizeof(data13), mimeTextPlain},
469 {data14, sizeof(data14), mimeTextPlain},
470 {data15, sizeof(data15), mimeTextPlain},
471 {data16, sizeof(data16), mimeImagePjpeg},
472 {data17, sizeof(data17), mimeAppOctetStream},
473 {data18, sizeof(data18), mimeTextHtml},
474 {data19, sizeof(data19), mimeImageGif},
475 {data20, sizeof(data20), mimeImageGif},
476 {data21, sizeof(data21), mimeTextPlain},
477 {data22, sizeof(data22), mimeImageGif},
478 {data23, sizeof(data23), mimeTextPlain},
479 {data24, sizeof(data24), mimeImageGif},
480 {data25, sizeof(data25), mimeImageGif},
481 {data26, sizeof(data26), mimeTextHtml},
482 {data27, sizeof(data27), mimeTextPlain},
483 {data28, sizeof(data28), mimeImageBmp},
484 {data29, sizeof(data29), mimeImageBmp},
485 {data30, sizeof(data30), mimeAppOctetStream},
486 {data31, sizeof(data31), mimeTextHtml},
487 {data32, sizeof(data32), mimeAppOctetStream},
488 {data33, sizeof(data33), mimeAppOctetStream},
489 {data34, sizeof(data34), mimeImageXPng},
490 {data35, sizeof(data35), mimeImageXPng},
491 {data36, sizeof(data36), mimeAppOctetStream},
492 {data37, sizeof(data37), mimeTextHtml},
493 {data38, sizeof(data38), mimeAppOctetStream},
494 {data39, sizeof(data39), mimeImageTiff},
495 {data40, sizeof(data40), mimeTextHtml},
496 {data41, sizeof(data41), mimeImageTiff},
497 {data42, sizeof(data42), mimeTextPlain},
498 {data43, sizeof(data43), mimeAppOctetStream},
499 {data44, sizeof(data44), mimeVideoAvi},
500 {data45, sizeof(data45), mimeTextPlain},
501 {data46, sizeof(data46), mimeTextPlain},
502 {data47, sizeof(data47), mimeTextPlain},
503 {data48, sizeof(data48), mimeTextHtml},
504 {data49, sizeof(data49), mimeVideoAvi},
505 {data50, sizeof(data50), mimeVideoMpeg},
506 {data51, sizeof(data51), mimeVideoMpeg},
507 {data52, sizeof(data52), mimeAppOctetStream},
508 {data53, sizeof(data53), mimeAppOctetStream},
509 {data54, sizeof(data54), mimeTextHtml},
510 {data55, sizeof(data55), mimeAppXGzip},
511 {data56, sizeof(data56), mimeTextPlain},
512 {data57, sizeof(data57), mimeTextHtml},
513 {data58, sizeof(data58), mimeAppOctetStream},
514 {data59, sizeof(data59), mimeAppXZip},
515 {data60, sizeof(data60), mimeTextPlain},
516 {data61, sizeof(data61), mimeTextHtml},
517 {data62, sizeof(data62), mimeAppJava},
518 {data63, sizeof(data63), mimeTextPlain},
519 {data64, sizeof(data64), mimeTextHtml},
520 {data65, sizeof(data65), mimeAppPdf},
521 {data66, sizeof(data66), mimeTextPlain},
522 {data67, sizeof(data67), mimeTextHtml},
523 {data68, sizeof(data68), mimeAppXMSDownload},
524 {data69, sizeof(data69), mimeTextPlain},
525 {data70, sizeof(data70), mimeTextHtml}
528 static void test_FindMimeFromData(void)
534 for(i=0; i<sizeof(mime_tests)/sizeof(mime_tests[0]); i++) {
535 mime = (LPWSTR)0xf0f0f0f0;
536 hres = FindMimeFromData(NULL, mime_tests[i].url, NULL, 0, NULL, 0, &mime, 0);
537 if(mime_tests[i].mime) {
538 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
539 ok(!lstrcmpW(mime, mime_tests[i].mime), "[%d] wrong mime\n", i);
542 ok(hres == E_FAIL, "[%d] FindMimeFromData failed: %08x, expected E_FAIL\n", i, hres);
543 ok(mime == (LPWSTR)0xf0f0f0f0, "[%d] mime != 0xf0f0f0f0\n", i);
546 mime = (LPWSTR)0xf0f0f0f0;
547 hres = FindMimeFromData(NULL, mime_tests[i].url, NULL, 0, mimeTextPlain, 0, &mime, 0);
548 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
549 ok(!lstrcmpW(mime, mimeTextPlain), "[%d] wrong mime\n", i);
552 mime = (LPWSTR)0xf0f0f0f0;
553 hres = FindMimeFromData(NULL, mime_tests[i].url, NULL, 0, mimeAppOctetStream, 0, &mime, 0);
554 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
555 ok(!lstrcmpW(mime, mimeAppOctetStream), "[%d] wrong mime\n", i);
559 for(i=0; i < sizeof(mime_tests2)/sizeof(mime_tests2[0]); i++) {
560 hres = FindMimeFromData(NULL, NULL, mime_tests2[i].data, mime_tests2[i].size,
562 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
563 ok(!lstrcmpW(mime, mime_tests2[i].mime), "[%d] wrong mime\n", i);
566 hres = FindMimeFromData(NULL, NULL, mime_tests2[i].data, mime_tests2[i].size,
567 mimeTextHtml, 0, &mime, 0);
568 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
569 if(!lstrcmpW(mimeAppOctetStream, mime_tests2[i].mime)
570 || !lstrcmpW(mimeTextPlain, mime_tests2[i].mime))
571 ok(!lstrcmpW(mime, mimeTextHtml), "[%d] wrong mime\n", i);
573 ok(!lstrcmpW(mime, mime_tests2[i].mime), "[%d] wrong mime\n", i);
575 hres = FindMimeFromData(NULL, NULL, mime_tests2[i].data, mime_tests2[i].size,
576 mimeImagePjpeg, 0, &mime, 0);
577 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
578 if(!lstrcmpW(mimeAppOctetStream, mime_tests2[i].mime) || i == 17)
579 ok(!lstrcmpW(mime, mimeImagePjpeg), "[%d] wrong mime\n", i);
581 ok(!lstrcmpW(mime, mime_tests2[i].mime), "[%d] wrong mime\n", i);
586 hres = FindMimeFromData(NULL, url1, data1, sizeof(data1), NULL, 0, &mime, 0);
587 ok(hres == S_OK, "FindMimeFromData failed: %08x\n", hres);
588 ok(!lstrcmpW(mime, mimeTextPlain), "wrong mime\n");
591 hres = FindMimeFromData(NULL, url1, data1, sizeof(data1), mimeAppOctetStream, 0, &mime, 0);
592 ok(hres == S_OK, "FindMimeFromData failed: %08x\n", hres);
593 ok(!lstrcmpW(mime, mimeTextPlain), "wrong mime\n");
596 hres = FindMimeFromData(NULL, url4, data1, sizeof(data1), mimeAppOctetStream, 0, &mime, 0);
597 ok(hres == S_OK, "FindMimeFromData failed: %08x\n", hres);
598 ok(!lstrcmpW(mime, mimeTextPlain), "wrong mime\n");
601 hres = FindMimeFromData(NULL, NULL, NULL, 0, NULL, 0, &mime, 0);
602 ok(hres == E_INVALIDARG, "FindMimeFromData failed: %08x, excepted E_INVALIDARG\n", hres);
604 hres = FindMimeFromData(NULL, NULL, NULL, 0, mimeTextPlain, 0, &mime, 0);
605 ok(hres == E_INVALIDARG, "FindMimeFromData failed: %08x, expected E_INVALIDARG\n", hres);
607 hres = FindMimeFromData(NULL, NULL, data1, 0, NULL, 0, &mime, 0);
608 ok(hres == E_FAIL, "FindMimeFromData failed: %08x, expected E_FAIL\n", hres);
610 hres = FindMimeFromData(NULL, url1, data1, 0, NULL, 0, &mime, 0);
611 ok(hres == E_FAIL, "FindMimeFromData failed: %08x, expected E_FAIL\n", hres);
613 hres = FindMimeFromData(NULL, NULL, data1, 0, mimeTextPlain, 0, &mime, 0);
614 ok(hres == S_OK, "FindMimeFromData failed: %08x\n", hres);
615 ok(!lstrcmpW(mime, mimeTextPlain), "wrong mime\n");
618 hres = FindMimeFromData(NULL, NULL, data1, 0, mimeTextPlain, 0, NULL, 0);
619 ok(hres == E_INVALIDARG, "FindMimeFromData failed: %08x, expected E_INVALIDARG\n", hres);
622 static const BYTE secid1[] = {'f','i','l','e',':',0,0,0,0};
623 static const BYTE secid4[] ={'f','i','l','e',':',3,0,0,0};
624 static const BYTE secid5[] = {'h','t','t','p',':','w','w','w','.','w','i','n','e','h','q',
625 '.','o','r','g',3,0,0,0};
626 static const BYTE secid6[] = {'a','b','o','u','t',':','b','l','a','n','k',3,0,0,0};
627 static const BYTE secid7[] = {'f','t','p',':','w','i','n','e','h','q','.','o','r','g',
630 static struct secmgr_test {
638 {url1, 0, S_OK, sizeof(secid1), secid1, S_OK},
639 {url2, 100, 0x80041001, 0, NULL, E_INVALIDARG},
640 {url3, 0, S_OK, sizeof(secid1), secid1, S_OK},
641 {url4, 3, S_OK, sizeof(secid4), secid4, S_OK},
642 {url5, 3, S_OK, sizeof(secid5), secid5, S_OK},
643 {url6, 3, S_OK, sizeof(secid6), secid6, S_OK},
644 {url7, 3, S_OK, sizeof(secid7), secid7, S_OK}
647 static void test_SecurityManager(void)
650 IInternetSecurityManager *secmgr = NULL;
655 hres = CoInternetCreateSecurityManager(NULL, &secmgr, 0);
656 ok(hres == S_OK, "CoInternetCreateSecurityManager failed: %08x\n", hres);
660 for(i=0; i < sizeof(secmgr_tests)/sizeof(secmgr_tests[0]); i++) {
662 hres = IInternetSecurityManager_MapUrlToZone(secmgr, secmgr_tests[i].url,
664 ok(hres == secmgr_tests[i].zone_hres,
665 "[%d] MapUrlToZone failed: %08x, expected %08x\n",
666 i, hres, secmgr_tests[i].zone_hres);
668 ok(zone == secmgr_tests[i].zone, "[%d] zone=%d, expected %d\n", i, zone,
669 secmgr_tests[i].zone);
671 ok(zone == secmgr_tests[i].zone || zone == -1, "[%d] zone=%d\n", i, zone);
674 memset(buf, 0xf0, sizeof(buf));
675 hres = IInternetSecurityManager_GetSecurityId(secmgr, secmgr_tests[i].url,
677 ok(hres == secmgr_tests[i].secid_hres,
678 "[%d] GetSecurityId failed: %08x, expected %08x\n",
679 i, hres, secmgr_tests[i].secid_hres);
680 if(secmgr_tests[i].secid) {
681 ok(size == secmgr_tests[i].secid_size, "[%d] size=%d, expected %d\n",
682 i, size, secmgr_tests[i].secid_size);
683 ok(!memcmp(buf, secmgr_tests[i].secid, size), "[%d] wrong secid\n", i);
688 hres = IInternetSecurityManager_MapUrlToZone(secmgr, NULL, &zone, 0);
689 ok(hres == E_INVALIDARG, "MapUrlToZone failed: %08x, expected E_INVALIDARG\n", hres);
690 ok(zone == 100, "zone=%d\n", zone);
693 hres = IInternetSecurityManager_GetSecurityId(secmgr, NULL, buf, &size, 0);
694 ok(hres == E_INVALIDARG,
695 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres);
696 hres = IInternetSecurityManager_GetSecurityId(secmgr, secmgr_tests[1].url,
698 ok(hres == E_INVALIDARG,
699 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres);
700 hres = IInternetSecurityManager_GetSecurityId(secmgr, secmgr_tests[1].url,
702 ok(hres == E_INVALIDARG,
703 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres);
705 IInternetSecurityManager_Release(secmgr);
708 static void test_ZoneManager(void)
710 IInternetZoneManager *zonemgr = NULL;
714 hres = CoInternetCreateZoneManager(NULL, &zonemgr, 0);
715 ok(hres == S_OK, "CoInternetCreateZoneManager failed: %08x\n", hres);
719 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, 0x1a10, buf,
720 sizeof(DWORD), URLZONEREG_DEFAULT);
721 ok(hres == S_OK, "GetZoneActionPolicy failed: %08x\n", hres);
722 ok(*(DWORD*)buf == 1, "policy=%d, expected 1\n", *(DWORD*)buf);
724 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, 0x1a10, NULL,
725 sizeof(DWORD), URLZONEREG_DEFAULT);
726 ok(hres == E_INVALIDARG, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres);
728 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, 0x1a10, buf,
729 2, URLZONEREG_DEFAULT);
730 ok(hres == E_INVALIDARG, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres);
732 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, 0x1fff, buf,
733 sizeof(DWORD), URLZONEREG_DEFAULT);
734 ok(hres == E_FAIL, "GetZoneActionPolicy failed: %08x, expected E_FAIL\n", hres);
736 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 13, 0x1a10, buf,
737 sizeof(DWORD), URLZONEREG_DEFAULT);
738 ok(hres == E_INVALIDARG, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres);
740 IInternetZoneManager_Release(zonemgr);
743 static void register_protocols(void)
745 IInternetSession *session;
746 IClassFactory *factory;
749 static const WCHAR wszAbout[] = {'a','b','o','u','t',0};
751 hres = CoInternetGetSession(0, &session, 0);
752 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
756 hres = CoGetClassObject(&CLSID_AboutProtocol, CLSCTX_INPROC_SERVER, NULL,
757 &IID_IClassFactory, (void**)&factory);
758 ok(hres == S_OK, "Coud not get AboutProtocol factory: %08x\n", hres);
762 IInternetSession_RegisterNameSpace(session, factory, &CLSID_AboutProtocol,
763 wszAbout, 0, NULL, 0);
764 IClassFactory_Release(factory);
768 static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface,
769 REFIID riid, void **ppv)
771 ok(0, "unexpected call\n");
772 return E_NOINTERFACE;
775 static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
780 static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
785 static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
786 PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
787 DWORD *pcchResult, DWORD dwReserved)
789 CHECK_EXPECT(ParseUrl);
793 static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
794 LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags,
795 LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
797 ok(0, "unexpected call\n");
801 static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface,
802 LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
804 ok(0, "unexpected call\n");
808 static HRESULT WINAPI InternetProtocolInfo_QueryInfo(IInternetProtocolInfo *iface,
809 LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer,
810 DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
812 ok(0, "unexpected call\n");
816 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl = {
817 InternetProtocolInfo_QueryInterface,
818 InternetProtocolInfo_AddRef,
819 InternetProtocolInfo_Release,
820 InternetProtocolInfo_ParseUrl,
821 InternetProtocolInfo_CombineUrl,
822 InternetProtocolInfo_CompareUrl,
823 InternetProtocolInfo_QueryInfo
826 static IInternetProtocolInfo protocol_info = { &InternetProtocolInfoVtbl };
828 static HRESULT qiret;
829 static IClassFactory *expect_cf;
831 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
833 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
834 CHECK_EXPECT(QI_IInternetProtocolInfo);
835 ok(iface == expect_cf, "unexpected iface\n");
836 *ppv = &protocol_info;
840 ok(0, "unexpected call\n");
841 return E_NOINTERFACE;
844 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
849 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
854 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
855 REFIID riid, void **ppv)
857 CHECK_EXPECT(CreateInstance);
859 ok(iface == expect_cf, "unexpected iface\n");
860 ok(pOuter == NULL, "pOuter = %p\n", pOuter);
861 ok(IsEqualGUID(&IID_IInternetProtocolInfo, riid), "unexpected riid\n");
862 ok(ppv != NULL, "ppv == NULL\n");
864 *ppv = &protocol_info;
868 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
870 ok(0, "unexpected call\n");
874 static const IClassFactoryVtbl ClassFactoryVtbl = {
875 ClassFactory_QueryInterface,
877 ClassFactory_Release,
878 ClassFactory_CreateInstance,
879 ClassFactory_LockServer
882 static IClassFactory test_protocol_cf = { &ClassFactoryVtbl };
883 static IClassFactory test_protocol_cf2 = { &ClassFactoryVtbl };
885 static void test_NameSpace(void)
887 IInternetSession *session;
892 static const WCHAR wszTest[] = {'t','e','s','t',0};
894 hres = CoInternetGetSession(0, &session, 0);
895 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
899 hres = IInternetSession_RegisterNameSpace(session, NULL, &IID_NULL,
900 wszTest, 0, NULL, 0);
901 ok(hres == E_INVALIDARG, "RegisterNameSpace failed: %08x\n", hres);
903 hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf, &IID_NULL,
905 ok(hres == E_INVALIDARG, "RegisterNameSpace failed: %08x\n", hres);
907 hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf, &IID_NULL,
908 wszTest, 0, NULL, 0);
909 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
911 qiret = E_NOINTERFACE;
912 expect_cf = &test_protocol_cf;
913 SET_EXPECT(QI_IInternetProtocolInfo);
914 SET_EXPECT(CreateInstance);
915 SET_EXPECT(ParseUrl);
917 hres = CoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
919 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
921 CHECK_CALLED(QI_IInternetProtocolInfo);
922 CHECK_CALLED(CreateInstance);
923 CHECK_CALLED(ParseUrl);
926 SET_EXPECT(QI_IInternetProtocolInfo);
927 SET_EXPECT(ParseUrl);
929 hres = CoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
931 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
933 CHECK_CALLED(QI_IInternetProtocolInfo);
934 CHECK_CALLED(ParseUrl);
936 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
937 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
939 hres = CoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
941 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
943 hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf2, &IID_NULL,
944 wszTest, 0, NULL, 0);
945 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
947 hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf, &IID_NULL,
948 wszTest, 0, NULL, 0);
949 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
951 hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf, &IID_NULL,
952 wszTest, 0, NULL, 0);
953 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
955 SET_EXPECT(QI_IInternetProtocolInfo);
956 SET_EXPECT(ParseUrl);
958 hres = CoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
960 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
962 CHECK_CALLED(QI_IInternetProtocolInfo);
963 CHECK_CALLED(ParseUrl);
965 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
966 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
968 SET_EXPECT(QI_IInternetProtocolInfo);
969 SET_EXPECT(ParseUrl);
971 hres = CoInternetParseUrl(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 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
979 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
981 expect_cf = &test_protocol_cf2;
982 SET_EXPECT(QI_IInternetProtocolInfo);
983 SET_EXPECT(ParseUrl);
985 hres = CoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
987 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
989 CHECK_CALLED(QI_IInternetProtocolInfo);
990 CHECK_CALLED(ParseUrl);
992 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
993 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
994 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
995 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
996 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, NULL);
997 ok(hres == E_INVALIDARG, "UnregisterNameSpace failed: %08x\n", hres);
998 hres = IInternetSession_UnregisterNameSpace(session, NULL, wszTest);
999 ok(hres == E_INVALIDARG, "UnregisterNameSpace failed: %08x\n", hres);
1001 hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf2, wszTest);
1002 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
1004 hres = CoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
1006 ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
1008 IInternetSession_Release(session);
1011 static ULONG WINAPI unk_Release(IUnknown *iface)
1013 CHECK_EXPECT(unk_Release);
1017 static const IUnknownVtbl unk_vtbl = {
1023 static void test_ReleaseBindInfo(void)
1026 IUnknown unk = { &unk_vtbl };
1028 ReleaseBindInfo(NULL); /* shouldn't crash */
1030 memset(&bi, 0, sizeof(bi));
1031 bi.cbSize = sizeof(BINDINFO);
1033 SET_EXPECT(unk_Release);
1034 ReleaseBindInfo(&bi);
1035 ok(bi.cbSize == sizeof(BINDINFO), "bi.cbSize=%d\n", bi.cbSize);
1036 ok(bi.pUnk == NULL, "bi.pUnk=%p, expected NULL\n", bi.pUnk);
1037 CHECK_CALLED(unk_Release);
1039 memset(&bi, 0, sizeof(bi));
1040 bi.cbSize = offsetof(BINDINFO, pUnk);
1042 ReleaseBindInfo(&bi);
1043 ok(bi.cbSize == offsetof(BINDINFO, pUnk), "bi.cbSize=%d\n", bi.cbSize);
1044 ok(bi.pUnk == &unk, "bi.pUnk=%p, expected %p\n", bi.pUnk, &unk);
1046 memset(&bi, 0, sizeof(bi));
1048 ReleaseBindInfo(&bi);
1049 ok(!bi.cbSize, "bi.cbSize=%d, expected 0\n", bi.cbSize);
1050 ok(bi.pUnk == &unk, "bi.pUnk=%p, expected %p\n", bi.pUnk, &unk);
1053 static void test_UrlMkGetSessionOption(void)
1055 DWORD encoding, size;
1058 size = encoding = 0xdeadbeef;
1059 hres = UrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING, &encoding,
1060 sizeof(encoding), &size, 0);
1061 ok(hres == S_OK, "UrlMkGetSessionOption failed: %08x\n", hres);
1062 ok(encoding != 0xdeadbeef, "encoding not changed\n");
1063 ok(size == sizeof(encoding), "size=%d\n", size);
1065 size = encoding = 0xdeadbeef;
1066 hres = UrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING, &encoding,
1067 sizeof(encoding)+1, &size, 0);
1068 ok(hres == S_OK, "UrlMkGetSessionOption failed: %08x\n", hres);
1069 ok(encoding != 0xdeadbeef, "encoding not changed\n");
1070 ok(size == sizeof(encoding), "size=%d\n", size);
1072 size = encoding = 0xdeadbeef;
1073 hres = UrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING, &encoding,
1074 sizeof(encoding)-1, &size, 0);
1075 ok(hres == E_INVALIDARG, "UrlMkGetSessionOption failed: %08x\n", hres);
1076 ok(encoding == 0xdeadbeef, "encoding = %08x, exepcted 0xdeadbeef\n", encoding);
1077 ok(size == 0xdeadbeef, "size=%d\n", size);
1079 size = encoding = 0xdeadbeef;
1080 hres = UrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING, NULL,
1081 sizeof(encoding)-1, &size, 0);
1082 ok(hres == E_INVALIDARG, "UrlMkGetSessionOption failed: %08x\n", hres);
1083 ok(encoding == 0xdeadbeef, "encoding = %08x, exepcted 0xdeadbeef\n", encoding);
1084 ok(size == 0xdeadbeef, "size=%d\n", size);
1086 encoding = 0xdeadbeef;
1087 hres = UrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING, &encoding,
1088 sizeof(encoding)-1, NULL, 0);
1089 ok(hres == E_INVALIDARG, "UrlMkGetSessionOption failed: %08x\n", hres);
1090 ok(encoding == 0xdeadbeef, "encoding = %08x, exepcted 0xdeadbeef\n", encoding);
1095 OleInitialize(NULL);
1097 register_protocols();
1099 test_CreateFormatEnum();
1100 test_RegisterFormatEnumerator();
1101 test_CoInternetParseUrl();
1102 test_CoInternetCompareUrl();
1103 test_FindMimeFromData();
1104 test_SecurityManager();
1107 test_ReleaseBindInfo();
1108 test_UrlMkGetSessionOption();