urlmon: Added GetSecurityId implementation.
[wine/wine64.git] / dlls / urlmon / tests / misc.c
blob99b8c6ffbf9cea4b6e3c275c02938e5653cc07fb
1 /*
2 * Copyright 2005 Jacek Caban
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #define COBJMACROS
21 #include <wine/test.h>
22 #include <stdarg.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "ole2.h"
27 #include "urlmon.h"
29 #include "initguid.h"
31 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
33 static void test_CreateFormatEnum(void)
35 IEnumFORMATETC *fenum = NULL, *fenum2 = NULL;
36 FORMATETC fetc[5];
37 ULONG ul;
38 HRESULT hres;
40 static DVTARGETDEVICE dev = {sizeof(dev),0,0,0,0,{0}};
41 static FORMATETC formatetc[] = {
42 {0,&dev,0,0,0},
43 {0,&dev,0,1,0},
44 {0,NULL,0,2,0},
45 {0,NULL,0,3,0},
46 {0,NULL,0,4,0}
49 hres = CreateFormatEnumerator(0, formatetc, &fenum);
50 ok(hres == E_FAIL, "CreateFormatEnumerator failed: %08lx, expected E_FAIL\n", hres);
51 hres = CreateFormatEnumerator(0, formatetc, NULL);
52 ok(hres == E_INVALIDARG, "CreateFormatEnumerator failed: %08lx, expected E_INVALIDARG\n", hres);
53 hres = CreateFormatEnumerator(5, formatetc, NULL);
54 ok(hres == E_INVALIDARG, "CreateFormatEnumerator failed: %08lx, expected E_INVALIDARG\n", hres);
57 hres = CreateFormatEnumerator(5, formatetc, &fenum);
58 ok(hres == S_OK, "CreateFormatEnumerator failed: %08lx\n", hres);
59 if(FAILED(hres))
60 return;
62 hres = IEnumFORMATETC_Next(fenum, 2, NULL, &ul);
63 ok(hres == E_INVALIDARG, "Next failed: %08lx, expected E_INVALIDARG\n", hres);
64 ul = 100;
65 hres = IEnumFORMATETC_Next(fenum, 0, fetc, &ul);
66 ok(hres == S_OK, "Next failed: %08lx\n", hres);
67 ok(ul == 0, "ul=%ld, expected 0\n", ul);
69 hres = IEnumFORMATETC_Next(fenum, 2, fetc, &ul);
70 ok(hres == S_OK, "Next failed: %08lx\n", hres);
71 ok(fetc[0].lindex == 0, "fetc[0].lindex=%ld, expected 0\n", fetc[0].lindex);
72 ok(fetc[1].lindex == 1, "fetc[1].lindex=%ld, expected 1\n", fetc[1].lindex);
73 ok(fetc[0].ptd == &dev, "fetc[0].ptd=%p, expected %p\n", fetc[0].ptd, &dev);
74 ok(ul == 2, "ul=%ld, expected 2\n", ul);
76 hres = IEnumFORMATETC_Skip(fenum, 1);
77 ok(hres == S_OK, "Skip failed: %08lx\n", hres);
79 hres = IEnumFORMATETC_Next(fenum, 4, fetc, &ul);
80 ok(hres == S_FALSE, "Next failed: %08lx, expected S_FALSE\n", hres);
81 ok(fetc[0].lindex == 3, "fetc[0].lindex=%ld, expected 3\n", fetc[0].lindex);
82 ok(fetc[1].lindex == 4, "fetc[1].lindex=%ld, expected 4\n", fetc[1].lindex);
83 ok(fetc[0].ptd == NULL, "fetc[0].ptd=%p, expected NULL\n", fetc[0].ptd);
84 ok(ul == 2, "ul=%ld, expected 2\n", ul);
86 hres = IEnumFORMATETC_Next(fenum, 4, fetc, &ul);
87 ok(hres == S_FALSE, "Next failed: %08lx, expected S_FALSE\n", hres);
88 ok(ul == 0, "ul=%ld, expected 0\n", ul);
89 ul = 100;
90 hres = IEnumFORMATETC_Next(fenum, 0, fetc, &ul);
91 ok(hres == S_OK, "Next failed: %08lx\n", hres);
92 ok(ul == 0, "ul=%ld, expected 0\n", ul);
94 hres = IEnumFORMATETC_Skip(fenum, 3);
95 ok(hres == S_FALSE, "Skip failed: %08lx, expected S_FALSE\n", hres);
97 hres = IEnumFORMATETC_Reset(fenum);
98 ok(hres == S_OK, "Reset failed: %08lx\n", hres);
100 hres = IEnumFORMATETC_Next(fenum, 5, fetc, NULL);
101 ok(hres == S_OK, "Next failed: %08lx\n", hres);
102 ok(fetc[0].lindex == 0, "fetc[0].lindex=%ld, expected 0\n", fetc[0].lindex);
104 hres = IEnumFORMATETC_Reset(fenum);
105 ok(hres == S_OK, "Reset failed: %08lx\n", hres);
107 hres = IEnumFORMATETC_Skip(fenum, 2);
108 ok(hres == S_OK, "Skip failed: %08lx\n", hres);
110 hres = IEnumFORMATETC_Clone(fenum, NULL);
111 ok(hres == E_INVALIDARG, "Clone failed: %08lx, expected E_INVALIDARG\n", hres);
113 hres = IEnumFORMATETC_Clone(fenum, &fenum2);
114 ok(hres == S_OK, "Clone failed: %08lx\n", hres);
116 if(SUCCEEDED(hres)) {
117 ok(fenum != fenum2, "fenum == fenum2\n");
119 hres = IEnumFORMATETC_Next(fenum2, 2, fetc, &ul);
120 ok(hres == S_OK, "Next failed: %08lx\n", hres);
121 ok(fetc[0].lindex == 2, "fetc[0].lindex=%ld, expected 2\n", fetc[0].lindex);
123 IEnumFORMATETC_Release(fenum2);
126 hres = IEnumFORMATETC_Next(fenum, 2, fetc, &ul);
127 ok(hres == S_OK, "Next failed: %08lx\n", hres);
128 ok(fetc[0].lindex == 2, "fetc[0].lindex=%ld, expected 2\n", fetc[0].lindex);
130 hres = IEnumFORMATETC_Skip(fenum, 1);
131 ok(hres == S_OK, "Skip failed: %08lx\n", hres);
133 IEnumFORMATETC_Release(fenum);
136 static void test_RegisterFormatEnumerator(void)
138 IBindCtx *bctx = NULL;
139 IEnumFORMATETC *format = NULL, *format2 = NULL;
140 IUnknown *unk = NULL;
141 HRESULT hres;
143 static FORMATETC formatetc = {0,NULL,0,0,0};
144 static WCHAR wszEnumFORMATETC[] =
145 {'_','E','n','u','m','F','O','R','M','A','T','E','T','C','_',0};
147 CreateBindCtx(0, &bctx);
149 hres = CreateFormatEnumerator(1, &formatetc, &format);
150 ok(hres == S_OK, "CreateFormatEnumerator failed: %08lx\n", hres);
151 if(FAILED(hres))
152 return;
154 hres = RegisterFormatEnumerator(NULL, format, 0);
155 ok(hres == E_INVALIDARG,
156 "RegisterFormatEnumerator failed: %08lx, expected E_INVALIDARG\n", hres);
157 hres = RegisterFormatEnumerator(bctx, NULL, 0);
158 ok(hres == E_INVALIDARG,
159 "RegisterFormatEnumerator failed: %08lx, expected E_INVALIDARG\n", hres);
161 hres = RegisterFormatEnumerator(bctx, format, 0);
162 ok(hres == S_OK, "RegisterFormatEnumerator failed: %08lx\n", hres);
164 hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
165 ok(hres == S_OK, "GetObjectParam failed: %08lx\n", hres);
166 ok(unk == (IUnknown*)format, "unk != format\n");
168 hres = RevokeFormatEnumerator(NULL, format);
169 ok(hres == E_INVALIDARG,
170 "RevokeFormatEnumerator failed: %08lx, expected E_INVALIDARG\n", hres);
172 hres = RevokeFormatEnumerator(bctx, format);
173 ok(hres == S_OK, "RevokeFormatEnumerator failed: %08lx\n", hres);
175 hres = RevokeFormatEnumerator(bctx, format);
176 ok(hres == E_FAIL, "RevokeFormatEnumerator failed: %08lx, expected E_FAIL\n", hres);
178 hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
179 ok(hres == E_FAIL, "GetObjectParam failed: %08lx, expected E_FAIL\n", hres);
181 hres = RegisterFormatEnumerator(bctx, format, 0);
182 ok(hres == S_OK, "RegisterFormatEnumerator failed: %08lx\n", hres);
184 hres = CreateFormatEnumerator(1, &formatetc, &format2);
185 ok(hres == S_OK, "CreateFormatEnumerator failed: %08lx\n", hres);
187 if(SUCCEEDED(hres)) {
188 hres = RevokeFormatEnumerator(bctx, format);
189 ok(hres == S_OK, "RevokeFormatEnumerator failed: %08lx\n", hres);
191 IEnumFORMATETC_Release(format2);
194 hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
195 ok(hres == E_FAIL, "GetObjectParam failed: %08lx, expected E_FAIL\n", hres);
197 IEnumFORMATETC_Release(format);
199 hres = RegisterFormatEnumerator(bctx, format, 0);
200 ok(hres == S_OK, "RegisterFormatEnumerator failed: %08lx\n", hres);
201 hres = RevokeFormatEnumerator(bctx, NULL);
202 ok(hres == S_OK, "RevokeFormatEnumerator failed: %08lx\n", hres);
203 hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
204 ok(hres == E_FAIL, "GetObjectParam failed: %08lx, expected E_FAIL\n", hres);
206 IBindCtx_Release(bctx);
209 static const WCHAR url1[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',
210 '/','b','l','a','n','k','.','h','t','m',0};
211 static const WCHAR url2[] = {'i','n','d','e','x','.','h','t','m',0};
212 static const WCHAR url3[] = {'f','i','l','e',':','c',':','\\','I','n','d','e','x','.','h','t','m',0};
213 static const WCHAR url4[] = {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e',
214 '%','2','e','j','p','g',0};
215 static const WCHAR url5[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
216 '.','o','r','g',0};
217 static const WCHAR url6[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
218 static const WCHAR url7[] = {'f','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g','/',
219 'f','i','l','e','.','t','e','s','t',0};
221 static const WCHAR url4e[] = {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e',
222 '.','j','p','g',0};
224 static const WCHAR path3[] = {'c',':','\\','I','n','d','e','x','.','h','t','m',0};
225 static const WCHAR path4[] = {'s','o','m','e',' ','f','i','l','e','.','j','p','g',0};
227 static const WCHAR wszRes[] = {'r','e','s',0};
228 static const WCHAR wszFile[] = {'f','i','l','e',0};
229 static const WCHAR wszHttp[] = {'h','t','t','p',0};
230 static const WCHAR wszAbout[] = {'a','b','o','u','t',0};
231 static const WCHAR wszEmpty[] = {0};
233 struct parse_test {
234 LPCWSTR url;
235 HRESULT secur_hres;
236 LPCWSTR encoded_url;
237 HRESULT path_hres;
238 LPCWSTR path;
239 LPCWSTR schema;
242 static const struct parse_test parse_tests[] = {
243 {url1, S_OK, url1, E_INVALIDARG, NULL, wszRes},
244 {url2, E_FAIL, url2, E_INVALIDARG, NULL, wszEmpty},
245 {url3, E_FAIL, url3, S_OK, path3, wszFile},
246 {url4, E_FAIL, url4e, S_OK, path4, wszFile},
247 {url5, E_FAIL, url5, E_INVALIDARG, NULL, wszHttp},
248 {url6, S_OK, url6, E_INVALIDARG, NULL, wszAbout}
251 static void test_CoInternetParseUrl(void)
253 HRESULT hres;
254 DWORD size;
255 int i;
257 static WCHAR buf[4096];
259 memset(buf, 0xf0, sizeof(buf));
260 hres = CoInternetParseUrl(parse_tests[0].url, PARSE_SCHEMA, 0, buf,
261 3, &size, 0);
262 ok(hres == E_POINTER, "schema failed: %08lx, expected E_POINTER\n", hres);
264 for(i=0; i < sizeof(parse_tests)/sizeof(parse_tests[0]); i++) {
265 memset(buf, 0xf0, sizeof(buf));
266 hres = CoInternetParseUrl(parse_tests[i].url, PARSE_SECURITY_URL, 0, buf,
267 sizeof(buf)/sizeof(WCHAR), &size, 0);
268 ok(hres == parse_tests[i].secur_hres, "[%d] security url failed: %08lx, expected %08lx\n",
269 i, hres, parse_tests[i].secur_hres);
271 memset(buf, 0xf0, sizeof(buf));
272 hres = CoInternetParseUrl(parse_tests[i].url, PARSE_ENCODE, 0, buf,
273 sizeof(buf)/sizeof(WCHAR), &size, 0);
274 ok(hres == S_OK, "[%d] encoding failed: %08lx\n", i, hres);
275 ok(size == lstrlenW(parse_tests[i].encoded_url), "[%d] wrong size\n", i);
276 ok(!lstrcmpW(parse_tests[i].encoded_url, buf), "[%d] wrong encoded url\n", i);
278 memset(buf, 0xf0, sizeof(buf));
279 hres = CoInternetParseUrl(parse_tests[i].url, PARSE_PATH_FROM_URL, 0, buf,
280 sizeof(buf)/sizeof(WCHAR), &size, 0);
281 ok(hres == parse_tests[i].path_hres, "[%d] path failed: %08lx, expected %08lx\n",
282 i, hres, parse_tests[i].path_hres);
283 if(parse_tests[i].path) {
284 ok(size == lstrlenW(parse_tests[i].path), "[%d] wrong size\n", i);
285 ok(!lstrcmpW(parse_tests[i].path, buf), "[%d] wrong path\n", i);
288 memset(buf, 0xf0, sizeof(buf));
289 hres = CoInternetParseUrl(parse_tests[i].url, PARSE_SCHEMA, 0, buf,
290 sizeof(buf)/sizeof(WCHAR), &size, 0);
291 ok(hres == S_OK, "[%d] schema failed: %08lx\n", i, hres);
292 ok(size == lstrlenW(parse_tests[i].schema), "[%d] wrong size\n", i);
293 ok(!lstrcmpW(parse_tests[i].schema, buf), "[%d] wrong schema\n", i);
297 static const WCHAR mimeTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
298 static const WCHAR mimeTextPlain[] = {'t','e','x','t','/','p','l','a','i','n',0};
299 static const WCHAR mimeAppOctetStream[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
300 'o','c','t','e','t','-','s','t','r','e','a','m',0};
302 static const struct {
303 LPCWSTR url;
304 LPCWSTR mime;
305 } mime_tests[] = {
306 {url1, mimeTextHtml},
307 {url2, mimeTextHtml},
308 {url3, mimeTextHtml},
309 {url4, NULL},
310 {url5, NULL},
311 {url6, NULL},
312 {url7, NULL}
315 static BYTE data1[] = "test data\n";
316 static BYTE data2[] = {31,'t','e','s',0xfa,'t',' ','d','a','t','a','\n',0};
317 static BYTE data3[] = {0,0,0};
318 static BYTE data4[] = {'t','e','s',0xfa,'t',' ','d','a','t','a','\n',0,0};
319 static BYTE data5[] = {0xa,0xa,0xa,'x',32,'x',0};
320 static BYTE data6[] = {0xfa,0xfa,0xfa,0xfa,'\n','\r','\t','x','x','x',1};
322 static const struct {
323 BYTE *data;
324 DWORD size;
325 LPCWSTR mime;
326 } mime_tests2[] = {
327 {data1, sizeof(data1), mimeTextPlain},
328 {data2, sizeof(data2), mimeAppOctetStream},
329 {data3, sizeof(data3), mimeAppOctetStream},
330 {data4, sizeof(data4), mimeAppOctetStream},
331 {data5, sizeof(data5), mimeTextPlain},
332 {data6, sizeof(data6), mimeTextPlain}
335 static void test_FindMimeFromData(void)
337 HRESULT hres;
338 LPWSTR mime;
339 int i;
341 for(i=0; i<sizeof(mime_tests)/sizeof(mime_tests[0]); i++) {
342 mime = (LPWSTR)0xf0f0f0f0;
343 hres = FindMimeFromData(NULL, mime_tests[i].url, NULL, 0, NULL, 0, &mime, 0);
344 if(mime_tests[i].mime) {
345 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08lx\n", i, hres);
346 ok(!lstrcmpW(mime, mime_tests[i].mime), "[%d] wrong mime\n", i);
347 CoTaskMemFree(mime);
348 }else {
349 ok(hres == E_FAIL, "FindMimeFromData failed: %08lx, expected E_FAIL\n", hres);
350 ok(mime == (LPWSTR)0xf0f0f0f0, "[%d] mime != 0xf0f0f0f0\n", i);
353 mime = (LPWSTR)0xf0f0f0f0;
354 hres = FindMimeFromData(NULL, mime_tests[i].url, NULL, 0, mimeTextPlain, 0, &mime, 0);
355 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08lx\n", i, hres);
356 ok(!lstrcmpW(mime, mimeTextPlain), "[%d] wrong mime\n", i);
357 CoTaskMemFree(mime);
359 mime = (LPWSTR)0xf0f0f0f0;
360 hres = FindMimeFromData(NULL, mime_tests[i].url, NULL, 0, mimeAppOctetStream, 0, &mime, 0);
361 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08lx\n", i, hres);
362 ok(!lstrcmpW(mime, mimeAppOctetStream), "[%d] wrong mime\n", i);
363 CoTaskMemFree(mime);
366 for(i=0; i < sizeof(mime_tests2)/sizeof(mime_tests2[0]); i++) {
367 hres = FindMimeFromData(NULL, NULL, mime_tests2[i].data, mime_tests2[i].size,
368 NULL, 0, &mime, 0);
369 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08lx\n", i, hres);
370 ok(!lstrcmpW(mime, mime_tests2[i].mime), "[%d] wrong mime\n", i);
371 CoTaskMemFree(mime);
373 hres = FindMimeFromData(NULL, NULL, mime_tests2[i].data, mime_tests2[i].size,
374 mimeTextHtml, 0, &mime, 0);
375 ok(hres == S_OK, "[%d] FindMimeFromData failed: %08lx\n", i, hres);
376 ok(!lstrcmpW(mime, mimeTextHtml), "[%d] wrong mime\n", i);
377 CoTaskMemFree(mime);
380 hres = FindMimeFromData(NULL, url1, data1, sizeof(data1), NULL, 0, &mime, 0);
381 ok(hres == S_OK, "FindMimeFromData failed: %08lx\n", hres);
382 ok(!lstrcmpW(mime, mimeTextPlain), "wrong mime\n");
383 CoTaskMemFree(mime);
385 hres = FindMimeFromData(NULL, url1, data1, sizeof(data1), mimeAppOctetStream, 0, &mime, 0);
386 ok(hres == S_OK, "FindMimeFromData failed: %08lx\n", hres);
387 ok(!lstrcmpW(mime, mimeTextPlain), "wrong mime\n");
388 CoTaskMemFree(mime);
390 hres = FindMimeFromData(NULL, url4, data1, sizeof(data1), mimeAppOctetStream, 0, &mime, 0);
391 ok(hres == S_OK, "FindMimeFromData failed: %08lx\n", hres);
392 ok(!lstrcmpW(mime, mimeTextPlain), "wrong mime\n");
393 CoTaskMemFree(mime);
395 hres = FindMimeFromData(NULL, NULL, NULL, 0, NULL, 0, &mime, 0);
396 ok(hres == E_INVALIDARG, "FindMimeFromData failed: %08lx, excepted E_INVALIDARG\n", hres);
398 hres = FindMimeFromData(NULL, NULL, NULL, 0, mimeTextPlain, 0, &mime, 0);
399 ok(hres == E_INVALIDARG, "FindMimeFromData failed: %08lx, expected E_INVALIDARG\n", hres);
401 hres = FindMimeFromData(NULL, NULL, data1, 0, NULL, 0, &mime, 0);
402 ok(hres == E_FAIL, "FindMimeFromData failed: %08lx, expected E_FAIL\n", hres);
404 hres = FindMimeFromData(NULL, url1, data1, 0, NULL, 0, &mime, 0);
405 ok(hres == E_FAIL, "FindMimeFromData failed: %08lx, expected E_FAIL\n", hres);
407 hres = FindMimeFromData(NULL, NULL, data1, 0, mimeTextPlain, 0, &mime, 0);
408 ok(hres == S_OK, "FindMimeFromData failed: %08lx\n", hres);
409 ok(!lstrcmpW(mime, mimeTextPlain), "wrong mime\n");
410 CoTaskMemFree(mime);
412 hres = FindMimeFromData(NULL, NULL, data1, 0, mimeTextPlain, 0, NULL, 0);
413 ok(hres == E_INVALIDARG, "FindMimeFromData failed: %08lx, expected E_INVALIDARG\n", hres);
416 static const BYTE secid1[] = {'f','i','l','e',':',0,0,0,0};
417 static const BYTE secid4[] ={'f','i','l','e',':',3,0,0,0};
418 static const BYTE secid5[] = {'h','t','t','p',':','w','w','w','.','w','i','n','e','h','q',
419 '.','o','r','g',3,0,0,0};
420 static const BYTE secid6[] = {'a','b','o','u','t',':','b','l','a','n','k',3,0,0,0};
421 static const BYTE secid7[] = {'f','t','p',':','w','i','n','e','h','q','.','o','r','g',
422 3,0,0,0};
424 static struct secmgr_test {
425 LPCWSTR url;
426 DWORD zone;
427 HRESULT zone_hres;
428 DWORD secid_size;
429 const BYTE *secid;
430 HRESULT secid_hres;
431 } secmgr_tests[] = {
432 {url1, 0, S_OK, sizeof(secid1), secid1, S_OK},
433 {url2, 100, 0x80041001, 0, NULL, E_INVALIDARG},
434 {url3, 0, S_OK, sizeof(secid1), secid1, S_OK},
435 {url4, 3, S_OK, sizeof(secid4), secid4, S_OK},
436 {url5, 3, S_OK, sizeof(secid5), secid5, S_OK},
437 {url6, 3, S_OK, sizeof(secid6), secid6, S_OK},
438 {url7, 3, S_OK, sizeof(secid7), secid7, S_OK}
441 static void test_SecurityManager(void)
443 int i;
444 IInternetSecurityManager *secmgr = NULL;
445 BYTE buf[512];
446 DWORD zone, size;
447 HRESULT hres;
449 hres = CoInternetCreateSecurityManager(NULL, &secmgr, 0);
450 ok(hres == S_OK, "CoInternetCreateSecurityManager failed: %08lx\n", hres);
451 if(FAILED(hres))
452 return;
454 for(i=0; i < sizeof(secmgr_tests)/sizeof(secmgr_tests[0]); i++) {
455 zone = 100;
456 hres = IInternetSecurityManager_MapUrlToZone(secmgr, secmgr_tests[i].url,
457 &zone, 0);
458 ok(hres == secmgr_tests[i].zone_hres,
459 "[%d] MapUrlToZone failed: %08lx, expected %08lx\n",
460 i, hres, secmgr_tests[i].zone_hres);
461 ok(zone == secmgr_tests[i].zone, "[%d] zone=%ld, expected %ld\n", i, zone,
462 secmgr_tests[i].zone);
464 size = sizeof(buf);
465 memset(buf, 0xf0, sizeof(buf));
466 hres = IInternetSecurityManager_GetSecurityId(secmgr, secmgr_tests[i].url,
467 buf, &size, 0);
468 ok(hres == secmgr_tests[i].secid_hres,
469 "[%d] GetSecurityId failed: %08lx, expected %08lx\n",
470 i, hres, secmgr_tests[i].secid_hres);
471 if(secmgr_tests[i].secid) {
472 ok(size == secmgr_tests[i].secid_size, "[%d] size=%ld, expected %ld\n",
473 i, size, secmgr_tests[i].secid_size);
474 ok(!memcmp(buf, secmgr_tests[i].secid, size), "[%d] wrong secid\n", i);
478 zone = 100;
479 hres = IInternetSecurityManager_MapUrlToZone(secmgr, NULL, &zone, 0);
480 ok(hres == E_INVALIDARG, "MapUrlToZone failed: %08lx, expected E_INVALIDARG\n", hres);
482 size = sizeof(buf);
483 hres = IInternetSecurityManager_GetSecurityId(secmgr, NULL, buf, &size, 0);
484 ok(hres == E_INVALIDARG,
485 "GetSecurityId failed: %08lx, expected E_INVALIDARG\n", hres);
486 hres = IInternetSecurityManager_GetSecurityId(secmgr, secmgr_tests[1].url,
487 NULL, &size, 0);
488 ok(hres == E_INVALIDARG,
489 "GetSecurityId failed: %08lx, expected E_INVALIDARG\n", hres);
490 hres = IInternetSecurityManager_GetSecurityId(secmgr, secmgr_tests[1].url,
491 buf, NULL, 0);
492 ok(hres == E_INVALIDARG,
493 "GetSecurityId failed: %08lx, expected E_INVALIDARG\n", hres);
495 IInternetSecurityManager_Release(secmgr);
498 static void test_ZoneManager(void)
500 IInternetZoneManager *zonemgr = NULL;
501 BYTE buf[32];
502 HRESULT hres;
504 hres = CoInternetCreateZoneManager(NULL, &zonemgr, 0);
505 ok(hres == S_OK, "CoInternetCreateZoneManager failed: %08lx\n", hres);
506 if(FAILED(hres))
507 return;
509 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, 0x1a10, buf,
510 sizeof(DWORD), URLZONEREG_DEFAULT);
511 ok(hres == S_OK, "GetZoneActionPolicy failed: %08lx\n", hres);
512 ok(*(DWORD*)buf == 1, "policy=%ld, expected 1\n", *(DWORD*)buf);
514 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, 0x1a10, NULL,
515 sizeof(DWORD), URLZONEREG_DEFAULT);
516 ok(hres == E_INVALIDARG, "GetZoneActionPolicy failed: %08lx, expected E_INVALIDARG\n", hres);
518 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, 0x1a10, buf,
519 2, URLZONEREG_DEFAULT);
520 ok(hres == E_INVALIDARG, "GetZoneActionPolicy failed: %08lx, expected E_INVALIDARG\n", hres);
522 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, 0x1fff, buf,
523 sizeof(DWORD), URLZONEREG_DEFAULT);
524 ok(hres == E_FAIL, "GetZoneActionPolicy failed: %08lx, expected E_FAIL\n", hres);
526 hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 13, 0x1a10, buf,
527 sizeof(DWORD), URLZONEREG_DEFAULT);
528 ok(hres == E_INVALIDARG, "GetZoneActionPolicy failed: %08lx, expected E_INVALIDARG\n", hres);
530 IInternetZoneManager_Release(zonemgr);
533 static void register_protocols(void)
535 IInternetSession *session;
536 IClassFactory *factory;
537 HRESULT hres;
539 static const WCHAR wszAbout[] = {'a','b','o','u','t',0};
541 hres = CoInternetGetSession(0, &session, 0);
542 ok(hres == S_OK, "CoInternetGetSession failed: %08lx\n", hres);
543 if(FAILED(hres))
544 return;
546 hres = CoGetClassObject(&CLSID_AboutProtocol, CLSCTX_INPROC_SERVER, NULL,
547 &IID_IClassFactory, (void**)&factory);
548 ok(hres == S_OK, "Coud not get AboutProtocol factory: %08lx\n", hres);
549 if(FAILED(hres))
550 return;
552 IInternetSession_RegisterNameSpace(session, factory, &CLSID_AboutProtocol,
553 wszAbout, 0, NULL, 0);
554 IClassFactory_Release(factory);
558 START_TEST(misc)
560 OleInitialize(NULL);
562 register_protocols();
564 test_CreateFormatEnum();
565 test_RegisterFormatEnumerator();
566 test_CoInternetParseUrl();
567 test_FindMimeFromData();
568 test_SecurityManager();
569 test_ZoneManager();
571 OleUninitialize();