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 const char *debugstr_w(LPCWSTR str
)
67 static char buf
[1024];
68 WideCharToMultiByte(CP_ACP
, 0, str
, -1, buf
, sizeof(buf
), NULL
, NULL
);
72 static void test_CreateFormatEnum(void)
74 IEnumFORMATETC
*fenum
= NULL
, *fenum2
= NULL
;
79 static DVTARGETDEVICE dev
= {sizeof(dev
),0,0,0,0,{0}};
80 static FORMATETC formatetc
[] = {
88 hres
= CreateFormatEnumerator(0, formatetc
, &fenum
);
89 ok(hres
== E_FAIL
, "CreateFormatEnumerator failed: %08x, expected E_FAIL\n", hres
);
90 hres
= CreateFormatEnumerator(0, formatetc
, NULL
);
91 ok(hres
== E_INVALIDARG
, "CreateFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres
);
92 hres
= CreateFormatEnumerator(5, formatetc
, NULL
);
93 ok(hres
== E_INVALIDARG
, "CreateFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres
);
96 hres
= CreateFormatEnumerator(5, formatetc
, &fenum
);
97 ok(hres
== S_OK
, "CreateFormatEnumerator failed: %08x\n", hres
);
101 hres
= IEnumFORMATETC_Next(fenum
, 2, NULL
, &ul
);
102 ok(hres
== E_INVALIDARG
, "Next failed: %08x, expected E_INVALIDARG\n", hres
);
104 hres
= IEnumFORMATETC_Next(fenum
, 0, fetc
, &ul
);
105 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
106 ok(ul
== 0, "ul=%d, expected 0\n", ul
);
108 hres
= IEnumFORMATETC_Next(fenum
, 2, fetc
, &ul
);
109 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
110 ok(fetc
[0].lindex
== 0, "fetc[0].lindex=%d, expected 0\n", fetc
[0].lindex
);
111 ok(fetc
[1].lindex
== 1, "fetc[1].lindex=%d, expected 1\n", fetc
[1].lindex
);
112 ok(fetc
[0].ptd
== &dev
, "fetc[0].ptd=%p, expected %p\n", fetc
[0].ptd
, &dev
);
113 ok(ul
== 2, "ul=%d, expected 2\n", ul
);
115 hres
= IEnumFORMATETC_Skip(fenum
, 1);
116 ok(hres
== S_OK
, "Skip failed: %08x\n", hres
);
118 hres
= IEnumFORMATETC_Next(fenum
, 4, fetc
, &ul
);
119 ok(hres
== S_FALSE
, "Next failed: %08x, expected S_FALSE\n", hres
);
120 ok(fetc
[0].lindex
== 3, "fetc[0].lindex=%d, expected 3\n", fetc
[0].lindex
);
121 ok(fetc
[1].lindex
== 4, "fetc[1].lindex=%d, expected 4\n", fetc
[1].lindex
);
122 ok(fetc
[0].ptd
== NULL
, "fetc[0].ptd=%p, expected NULL\n", fetc
[0].ptd
);
123 ok(ul
== 2, "ul=%d, expected 2\n", ul
);
125 hres
= IEnumFORMATETC_Next(fenum
, 4, fetc
, &ul
);
126 ok(hres
== S_FALSE
, "Next failed: %08x, expected S_FALSE\n", hres
);
127 ok(ul
== 0, "ul=%d, expected 0\n", ul
);
129 hres
= IEnumFORMATETC_Next(fenum
, 0, fetc
, &ul
);
130 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
131 ok(ul
== 0, "ul=%d, expected 0\n", ul
);
133 hres
= IEnumFORMATETC_Skip(fenum
, 3);
134 ok(hres
== S_FALSE
, "Skip failed: %08x, expected S_FALSE\n", hres
);
136 hres
= IEnumFORMATETC_Reset(fenum
);
137 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
139 hres
= IEnumFORMATETC_Next(fenum
, 5, fetc
, NULL
);
140 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
141 ok(fetc
[0].lindex
== 0, "fetc[0].lindex=%d, expected 0\n", fetc
[0].lindex
);
143 hres
= IEnumFORMATETC_Reset(fenum
);
144 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
146 hres
= IEnumFORMATETC_Skip(fenum
, 2);
147 ok(hres
== S_OK
, "Skip failed: %08x\n", hres
);
149 hres
= IEnumFORMATETC_Clone(fenum
, NULL
);
150 ok(hres
== E_INVALIDARG
, "Clone failed: %08x, expected E_INVALIDARG\n", hres
);
152 hres
= IEnumFORMATETC_Clone(fenum
, &fenum2
);
153 ok(hres
== S_OK
, "Clone failed: %08x\n", hres
);
155 if(SUCCEEDED(hres
)) {
156 ok(fenum
!= fenum2
, "fenum == fenum2\n");
158 hres
= IEnumFORMATETC_Next(fenum2
, 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 IEnumFORMATETC_Release(fenum2
);
165 hres
= IEnumFORMATETC_Next(fenum
, 2, fetc
, &ul
);
166 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
167 ok(fetc
[0].lindex
== 2, "fetc[0].lindex=%d, expected 2\n", fetc
[0].lindex
);
169 hres
= IEnumFORMATETC_Skip(fenum
, 1);
170 ok(hres
== S_OK
, "Skip failed: %08x\n", hres
);
172 IEnumFORMATETC_Release(fenum
);
175 static void test_RegisterFormatEnumerator(void)
177 IBindCtx
*bctx
= NULL
;
178 IEnumFORMATETC
*format
= NULL
, *format2
= NULL
;
179 IUnknown
*unk
= NULL
;
182 static FORMATETC formatetc
= {0,NULL
,0,0,0};
183 static WCHAR wszEnumFORMATETC
[] =
184 {'_','E','n','u','m','F','O','R','M','A','T','E','T','C','_',0};
186 CreateBindCtx(0, &bctx
);
188 hres
= CreateFormatEnumerator(1, &formatetc
, &format
);
189 ok(hres
== S_OK
, "CreateFormatEnumerator failed: %08x\n", hres
);
193 hres
= RegisterFormatEnumerator(NULL
, format
, 0);
194 ok(hres
== E_INVALIDARG
,
195 "RegisterFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres
);
196 hres
= RegisterFormatEnumerator(bctx
, NULL
, 0);
197 ok(hres
== E_INVALIDARG
,
198 "RegisterFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres
);
200 hres
= RegisterFormatEnumerator(bctx
, format
, 0);
201 ok(hres
== S_OK
, "RegisterFormatEnumerator failed: %08x\n", hres
);
203 hres
= IBindCtx_GetObjectParam(bctx
, wszEnumFORMATETC
, &unk
);
204 ok(hres
== S_OK
, "GetObjectParam failed: %08x\n", hres
);
205 ok(unk
== (IUnknown
*)format
, "unk != format\n");
207 hres
= RevokeFormatEnumerator(NULL
, format
);
208 ok(hres
== E_INVALIDARG
,
209 "RevokeFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres
);
211 hres
= RevokeFormatEnumerator(bctx
, format
);
212 ok(hres
== S_OK
, "RevokeFormatEnumerator failed: %08x\n", hres
);
214 hres
= RevokeFormatEnumerator(bctx
, format
);
215 ok(hres
== E_FAIL
, "RevokeFormatEnumerator failed: %08x, expected E_FAIL\n", hres
);
217 hres
= IBindCtx_GetObjectParam(bctx
, wszEnumFORMATETC
, &unk
);
218 ok(hres
== E_FAIL
, "GetObjectParam failed: %08x, expected E_FAIL\n", hres
);
220 hres
= RegisterFormatEnumerator(bctx
, format
, 0);
221 ok(hres
== S_OK
, "RegisterFormatEnumerator failed: %08x\n", hres
);
223 hres
= CreateFormatEnumerator(1, &formatetc
, &format2
);
224 ok(hres
== S_OK
, "CreateFormatEnumerator failed: %08x\n", hres
);
226 if(SUCCEEDED(hres
)) {
227 hres
= RevokeFormatEnumerator(bctx
, format
);
228 ok(hres
== S_OK
, "RevokeFormatEnumerator failed: %08x\n", hres
);
230 IEnumFORMATETC_Release(format2
);
233 hres
= IBindCtx_GetObjectParam(bctx
, wszEnumFORMATETC
, &unk
);
234 ok(hres
== E_FAIL
, "GetObjectParam failed: %08x, expected E_FAIL\n", hres
);
236 IEnumFORMATETC_Release(format
);
238 hres
= RegisterFormatEnumerator(bctx
, format
, 0);
239 ok(hres
== S_OK
, "RegisterFormatEnumerator failed: %08x\n", hres
);
240 hres
= RevokeFormatEnumerator(bctx
, NULL
);
241 ok(hres
== S_OK
, "RevokeFormatEnumerator failed: %08x\n", hres
);
242 hres
= IBindCtx_GetObjectParam(bctx
, wszEnumFORMATETC
, &unk
);
243 ok(hres
== E_FAIL
, "GetObjectParam failed: %08x, expected E_FAIL\n", hres
);
245 IEnumFORMATETC_Release(format
);
246 IBindCtx_Release(bctx
);
249 static const WCHAR url1
[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',
250 '/','b','l','a','n','k','.','h','t','m',0};
251 static const WCHAR url2
[] = {'i','n','d','e','x','.','h','t','m',0};
252 static const WCHAR url3
[] = {'f','i','l','e',':','c',':','\\','I','n','d','e','x','.','h','t','m',0};
253 static const WCHAR url4
[] = {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e',
254 '%','2','e','j','p','g',0};
255 static const WCHAR url5
[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
257 static const WCHAR url6
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
258 static const WCHAR url7
[] = {'f','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g','/',
259 'f','i','l','e','.','t','e','s','t',0};
260 static const WCHAR url8
[] = {'t','e','s','t',':','1','2','3','a','b','c',0};
263 static const WCHAR url4e
[] = {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e',
266 static const WCHAR path3
[] = {'c',':','\\','I','n','d','e','x','.','h','t','m',0};
267 static const WCHAR path4
[] = {'s','o','m','e',' ','f','i','l','e','.','j','p','g',0};
269 static const WCHAR wszRes
[] = {'r','e','s',0};
270 static const WCHAR wszFile
[] = {'f','i','l','e',0};
271 static const WCHAR wszHttp
[] = {'h','t','t','p',0};
272 static const WCHAR wszAbout
[] = {'a','b','o','u','t',0};
273 static const WCHAR wszEmpty
[] = {0};
284 static const struct parse_test parse_tests
[] = {
285 {url1
, S_OK
, url1
, E_INVALIDARG
, NULL
, wszRes
},
286 {url2
, E_FAIL
, url2
, E_INVALIDARG
, NULL
, wszEmpty
},
287 {url3
, E_FAIL
, url3
, S_OK
, path3
, wszFile
},
288 {url4
, E_FAIL
, url4e
, S_OK
, path4
, wszFile
},
289 {url5
, E_FAIL
, url5
, E_INVALIDARG
, NULL
, wszHttp
},
290 {url6
, S_OK
, url6
, E_INVALIDARG
, NULL
, wszAbout
}
293 static void test_CoInternetParseUrl(void)
299 static WCHAR buf
[4096];
301 memset(buf
, 0xf0, sizeof(buf
));
302 hres
= CoInternetParseUrl(parse_tests
[0].url
, PARSE_SCHEMA
, 0, buf
,
304 ok(hres
== E_POINTER
, "schema failed: %08x, expected E_POINTER\n", hres
);
306 for(i
=0; i
< sizeof(parse_tests
)/sizeof(parse_tests
[0]); i
++) {
307 memset(buf
, 0xf0, sizeof(buf
));
308 hres
= CoInternetParseUrl(parse_tests
[i
].url
, PARSE_SECURITY_URL
, 0, buf
,
309 sizeof(buf
)/sizeof(WCHAR
), &size
, 0);
310 ok(hres
== parse_tests
[i
].secur_hres
, "[%d] security url failed: %08x, expected %08x\n",
311 i
, hres
, parse_tests
[i
].secur_hres
);
313 memset(buf
, 0xf0, sizeof(buf
));
314 hres
= CoInternetParseUrl(parse_tests
[i
].url
, PARSE_ENCODE
, 0, buf
,
315 sizeof(buf
)/sizeof(WCHAR
), &size
, 0);
316 ok(hres
== S_OK
, "[%d] encoding failed: %08x\n", i
, hres
);
317 ok(size
== lstrlenW(parse_tests
[i
].encoded_url
), "[%d] wrong size\n", i
);
318 ok(!lstrcmpW(parse_tests
[i
].encoded_url
, buf
), "[%d] wrong encoded url\n", i
);
320 memset(buf
, 0xf0, sizeof(buf
));
321 hres
= CoInternetParseUrl(parse_tests
[i
].url
, PARSE_PATH_FROM_URL
, 0, buf
,
322 sizeof(buf
)/sizeof(WCHAR
), &size
, 0);
323 ok(hres
== parse_tests
[i
].path_hres
, "[%d] path failed: %08x, expected %08x\n",
324 i
, hres
, parse_tests
[i
].path_hres
);
325 if(parse_tests
[i
].path
) {
326 ok(size
== lstrlenW(parse_tests
[i
].path
), "[%d] wrong size\n", i
);
327 ok(!lstrcmpW(parse_tests
[i
].path
, buf
), "[%d] wrong path\n", i
);
330 memset(buf
, 0xf0, sizeof(buf
));
331 hres
= CoInternetParseUrl(parse_tests
[i
].url
, PARSE_SCHEMA
, 0, buf
,
332 sizeof(buf
)/sizeof(WCHAR
), &size
, 0);
333 ok(hres
== S_OK
, "[%d] schema failed: %08x\n", i
, hres
);
334 ok(size
== lstrlenW(parse_tests
[i
].schema
), "[%d] wrong size\n", i
);
335 ok(!lstrcmpW(parse_tests
[i
].schema
, buf
), "[%d] wrong schema\n", i
);
339 static void test_CoInternetCompareUrl(void)
343 hres
= CoInternetCompareUrl(url1
, url1
, 0);
344 ok(hres
== S_OK
, "CoInternetParseUrl failed: %08x\n", hres
);
346 hres
= CoInternetCompareUrl(url1
, url3
, 0);
347 ok(hres
== S_FALSE
, "CoInternetParseUrl failed: %08x\n", hres
);
349 hres
= CoInternetCompareUrl(url3
, url1
, 0);
350 ok(hres
== S_FALSE
, "CoInternetParseUrl failed: %08x\n", hres
);
353 static const struct {
356 } query_info_tests
[] = {
367 static void test_CoInternetQueryInfo(void)
373 for(i
=0; i
< sizeof(query_info_tests
)/sizeof(query_info_tests
[0]); i
++) {
375 memset(buf
, '?', sizeof(buf
));
376 hres
= CoInternetQueryInfo(query_info_tests
[0].url
, QUERY_USES_NETWORK
, 0, buf
, sizeof(buf
), &cb
, 0);
377 ok(hres
== S_OK
, "[%d] CoInternetQueryInfo failed: %08x\n", i
, hres
);
378 ok(cb
== sizeof(DWORD
), "[%d] cb = %d\n", i
, cb
);
379 ok(*(DWORD
*)buf
== query_info_tests
[i
].uses_net
, "[%d] ret %x, expected %x\n",
380 i
, *(DWORD
*)buf
, query_info_tests
[i
].uses_net
);
382 hres
= CoInternetQueryInfo(query_info_tests
[0].url
, QUERY_USES_NETWORK
, 0, buf
, 3, &cb
, 0);
383 ok(hres
== E_FAIL
, "[%d] CoInternetQueryInfo failed: %08x, expected E_FAIL\n", i
, hres
);
384 hres
= CoInternetQueryInfo(query_info_tests
[0].url
, QUERY_USES_NETWORK
, 0, NULL
, sizeof(buf
), &cb
, 0);
385 ok(hres
== E_FAIL
, "[%d] CoInternetQueryInfo failed: %08x, expected E_FAIL\n", i
, hres
);
387 memset(buf
, '?', sizeof(buf
));
388 hres
= CoInternetQueryInfo(query_info_tests
[0].url
, QUERY_USES_NETWORK
, 0, buf
, sizeof(buf
), NULL
, 0);
389 ok(hres
== S_OK
, "[%d] CoInternetQueryInfo failed: %08x\n", i
, hres
);
390 ok(*(DWORD
*)buf
== query_info_tests
[i
].uses_net
, "[%d] ret %x, expected %x\n",
391 i
, *(DWORD
*)buf
, query_info_tests
[i
].uses_net
);
395 static const WCHAR mimeTextHtml
[] = {'t','e','x','t','/','h','t','m','l',0};
396 static const WCHAR mimeTextPlain
[] = {'t','e','x','t','/','p','l','a','i','n',0};
397 static const WCHAR mimeTextRichtext
[] = {'t','e','x','t','/','r','i','c','h','t','e','x','t',0};
398 static const WCHAR mimeAppOctetStream
[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
399 'o','c','t','e','t','-','s','t','r','e','a','m',0};
400 static const WCHAR mimeImagePjpeg
[] = {'i','m','a','g','e','/','p','j','p','e','g',0};
401 static const WCHAR mimeImageGif
[] = {'i','m','a','g','e','/','g','i','f',0};
402 static const WCHAR mimeImageBmp
[] = {'i','m','a','g','e','/','b','m','p',0};
403 static const WCHAR mimeImageXPng
[] = {'i','m','a','g','e','/','x','-','p','n','g',0};
404 static const WCHAR mimeImageTiff
[] = {'i','m','a','g','e','/','t','i','f','f',0};
405 static const WCHAR mimeVideoAvi
[] = {'v','i','d','e','o','/','a','v','i',0};
406 static const WCHAR mimeVideoMpeg
[] = {'v','i','d','e','o','/','m','p','e','g',0};
407 static const WCHAR mimeAppPostscript
[] =
408 {'a','p','p','l','i','c','a','t','i','o','n','/','p','o','s','t','s','c','r','i','p','t',0};
409 static const WCHAR mimeAppXCompressed
[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
410 'x','-','c','o','m','p','r','e','s','s','e','d',0};
411 static const WCHAR mimeAppXZip
[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
412 'x','-','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0};
413 static const WCHAR mimeAppXGzip
[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
414 'x','-','g','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0};
415 static const WCHAR mimeAppJava
[] = {'a','p','p','l','i','c','a','t','i','o','n','/','j','a','v','a',0};
416 static const WCHAR mimeAppPdf
[] = {'a','p','p','l','i','c','a','t','i','o','n','/','p','d','f',0};
417 static const WCHAR mimeAppXMSDownload
[] =
418 {'a','p','p','l','i','c','a','t','i','o','n','/','x','-','m','s','d','o','w','n','l','o','a','d',0};
419 static const WCHAR mimeAudioWav
[] = {'a','u','d','i','o','/','w','a','v',0};
421 static const struct {
426 {url1
, mimeTextHtml
, S_OK
},
427 {url2
, mimeTextHtml
, S_OK
},
428 {url3
, mimeTextHtml
, S_OK
},
429 {url4
, NULL
, E_FAIL
},
430 {url5
, NULL
, __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
)},
431 {url6
, NULL
, E_FAIL
},
432 {url7
, NULL
, __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
)}
435 static BYTE data1
[] = "test data\n";
436 static BYTE data2
[] = {31,'t','e','s',0xfa,'t',' ','d','a','t','a','\n',0};
437 static BYTE data3
[] = {0,0,0};
438 static BYTE data4
[] = {'t','e','s',0xfa,'t',' ','d','a','t','a','\n',0,0};
439 static BYTE data5
[] = {0xa,0xa,0xa,'x',32,'x',0};
440 static BYTE data6
[] = {0xfa,0xfa,0xfa,0xfa,'\n','\r','\t','x','x','x',1};
441 static BYTE data7
[] = "<html>blahblah";
442 static BYTE data8
[] = {'t','e','s',0xfa,'t',' ','<','h','t','m','l','>','d','a','t','a','\n',0,0};
443 static BYTE data9
[] = {'t','e',0,'s',0xfa,'t',' ','<','h','t','m','l','>','d','a','t','a','\n',0,0};
444 static BYTE data10
[] = "<HtmL>blahblah";
445 static BYTE data11
[] = "blah<HTML>blahblah";
446 static BYTE data12
[] = "blah<HTMLblahblah";
447 static BYTE data13
[] = "blahHTML>blahblah";
448 static BYTE data14
[] = "blah<HTMblahblah";
449 static BYTE data15
[] = {0xff,0xd8};
450 static BYTE data16
[] = {0xff,0xd8,'h'};
451 static BYTE data17
[] = {0,0xff,0xd8};
452 static BYTE data18
[] = {0xff,0xd8,'<','h','t','m','l','>'};
453 static BYTE data19
[] = {'G','I','F','8','7','a'};
454 static BYTE data20
[] = {'G','I','F','8','9','a'};
455 static BYTE data21
[] = {'G','I','F','8','7'};
456 static BYTE data22
[] = {'G','i','F','8','7','a'};
457 static BYTE data23
[] = {'G','i','F','8','8','a'};
458 static BYTE data24
[] = {'g','i','f','8','7','a'};
459 static BYTE data25
[] = {'G','i','F','8','7','A'};
460 static BYTE data26
[] = {'G','i','F','8','7','a','<','h','t','m','l','>'};
461 static BYTE data27
[] = {0x30,'G','i','F','8','7','A'};
462 static BYTE data28
[] = {0x42,0x4d,0x6e,0x42,0x1c,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00};
463 static BYTE data29
[] = {0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'x','x','x','x'};
464 static BYTE data30
[] = {0x42,0x4d,'x','x','x','x',0x00,0x01,0x00,0x00,'x','x','x','x'};
465 static BYTE data31
[] = {0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'<','h','t','m','l','>'};
466 static BYTE data32
[] = {0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'x','x','x'};
467 static BYTE data33
[] = {0x00,0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'x','x','x'};
468 static BYTE data34
[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'x'};
469 static BYTE data35
[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'x','x','x','x',0};
470 static BYTE data36
[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,'x','x'};
471 static BYTE data37
[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'<','h','t','m','l','>'};
472 static BYTE data38
[] = {0x00,0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'x'};
473 static BYTE data39
[] = {0x4d,0x4d,0x00,0x2a};
474 static BYTE data40
[] = {0x4d,0x4d,0x00,0x2a,'<','h','t','m','l','>',0};
475 static BYTE data41
[] = {0x4d,0x4d,0xff};
476 static BYTE data42
[] = {0x4d,0x4d};
477 static BYTE data43
[] = {0x00,0x4d,0x4d,0x00};
478 static BYTE data44
[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x20,0xff};
479 static BYTE data45
[] = {'R','I','F','f',0xff,0xff,0xff,0xff,'A','V','I',0x20,0xff};
480 static BYTE data46
[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x20};
481 static BYTE data47
[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x21,0xff};
482 static BYTE data48
[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x20,'<','h','t','m','l','>'};
483 static BYTE data49
[] = {'R','I','F','F',0x0f,0x0f,0xf0,0xf0,'A','V','I',0x20,0xf0,0x00};
484 static BYTE data50
[] = {0x00,0x00,0x01,0xb3,0xff};
485 static BYTE data51
[] = {0x00,0x00,0x01,0xba,0xff};
486 static BYTE data52
[] = {0x00,0x00,0x01,0xb8,0xff};
487 static BYTE data53
[] = {0x00,0x00,0x01,0xba};
488 static BYTE data54
[] = {0x00,0x00,0x01,0xba,'<','h','t','m','l','>'};
489 static BYTE data55
[] = {0x1f,0x8b,'x'};
490 static BYTE data56
[] = {0x1f};
491 static BYTE data57
[] = {0x1f,0x8b,'<','h','t','m','l','>','t','e','s','t',0};
492 static BYTE data58
[] = {0x1f,0x8b};
493 static BYTE data59
[] = {0x50,0x4b,'x'};
494 static BYTE data60
[] = {0x50,0x4b};
495 static BYTE data61
[] = {0x50,0x4b,'<','h','t','m','l','>',0};
496 static BYTE data62
[] = {0xca,0xfe,0xba,0xbe,'x'};
497 static BYTE data63
[] = {0xca,0xfe,0xba,0xbe};
498 static BYTE data64
[] = {0xca,0xfe,0xba,0xbe,'<','h','t','m','l','>',0};
499 static BYTE data65
[] = {0x25,0x50,0x44,0x46,'x'};
500 static BYTE data66
[] = {0x25,0x50,0x44,0x46};
501 static BYTE data67
[] = {0x25,0x50,0x44,0x46,'x','<','h','t','m','l','>'};
502 static BYTE data68
[] = {'M','Z','x'};
503 static BYTE data69
[] = {'M','Z'};
504 static BYTE data70
[] = {'M','Z','<','h','t','m','l','>',0xff};
505 static BYTE data71
[] = {'{','\\','r','t','f',0};
506 static BYTE data72
[] = {'{','\\','r','t','f'};
507 static BYTE data73
[] = {' ','{','\\','r','t','f',' '};
508 static BYTE data74
[] = {'{','\\','r','t','f','<','h','t','m','l','>',' '};
509 static BYTE data75
[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'W','A','V','E',0xff};
510 static BYTE data76
[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'W','A','V','E'};
511 static BYTE data77
[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'W','A','V',0xff,0xff};
512 static BYTE data78
[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'<','h','t','m','l','>',0xff};
513 static BYTE data79
[] = {'%','!',0xff};
514 static BYTE data80
[] = {'%','!'};
515 static BYTE data81
[] = {'%','!','P','S','<','h','t','m','l','>'};
517 static const struct {
522 {data1
, sizeof(data1
), mimeTextPlain
},
523 {data2
, sizeof(data2
), mimeAppOctetStream
},
524 {data3
, sizeof(data3
), mimeAppOctetStream
},
525 {data4
, sizeof(data4
), mimeAppOctetStream
},
526 {data5
, sizeof(data5
), mimeTextPlain
},
527 {data6
, sizeof(data6
), mimeTextPlain
},
528 {data7
, sizeof(data7
), mimeTextHtml
},
529 {data8
, sizeof(data8
), mimeTextHtml
},
530 {data9
, sizeof(data9
), mimeTextHtml
},
531 {data10
, sizeof(data10
), mimeTextHtml
},
532 {data11
, sizeof(data11
), mimeTextHtml
},
533 {data12
, sizeof(data12
), mimeTextHtml
},
534 {data13
, sizeof(data13
), mimeTextPlain
},
535 {data14
, sizeof(data14
), mimeTextPlain
},
536 {data15
, sizeof(data15
), mimeTextPlain
},
537 {data16
, sizeof(data16
), mimeImagePjpeg
},
538 {data17
, sizeof(data17
), mimeAppOctetStream
},
539 {data18
, sizeof(data18
), mimeTextHtml
},
540 {data19
, sizeof(data19
), mimeImageGif
},
541 {data20
, sizeof(data20
), mimeImageGif
},
542 {data21
, sizeof(data21
), mimeTextPlain
},
543 {data22
, sizeof(data22
), mimeImageGif
},
544 {data23
, sizeof(data23
), mimeTextPlain
},
545 {data24
, sizeof(data24
), mimeImageGif
},
546 {data25
, sizeof(data25
), mimeImageGif
},
547 {data26
, sizeof(data26
), mimeTextHtml
},
548 {data27
, sizeof(data27
), mimeTextPlain
},
549 {data28
, sizeof(data28
), mimeImageBmp
},
550 {data29
, sizeof(data29
), mimeImageBmp
},
551 {data30
, sizeof(data30
), mimeAppOctetStream
},
552 {data31
, sizeof(data31
), mimeTextHtml
},
553 {data32
, sizeof(data32
), mimeAppOctetStream
},
554 {data33
, sizeof(data33
), mimeAppOctetStream
},
555 {data34
, sizeof(data34
), mimeImageXPng
},
556 {data35
, sizeof(data35
), mimeImageXPng
},
557 {data36
, sizeof(data36
), mimeAppOctetStream
},
558 {data37
, sizeof(data37
), mimeTextHtml
},
559 {data38
, sizeof(data38
), mimeAppOctetStream
},
560 {data39
, sizeof(data39
), mimeImageTiff
},
561 {data40
, sizeof(data40
), mimeTextHtml
},
562 {data41
, sizeof(data41
), mimeImageTiff
},
563 {data42
, sizeof(data42
), mimeTextPlain
},
564 {data43
, sizeof(data43
), mimeAppOctetStream
},
565 {data44
, sizeof(data44
), mimeVideoAvi
},
566 {data45
, sizeof(data45
), mimeTextPlain
},
567 {data46
, sizeof(data46
), mimeTextPlain
},
568 {data47
, sizeof(data47
), mimeTextPlain
},
569 {data48
, sizeof(data48
), mimeTextHtml
},
570 {data49
, sizeof(data49
), mimeVideoAvi
},
571 {data50
, sizeof(data50
), mimeVideoMpeg
},
572 {data51
, sizeof(data51
), mimeVideoMpeg
},
573 {data52
, sizeof(data52
), mimeAppOctetStream
},
574 {data53
, sizeof(data53
), mimeAppOctetStream
},
575 {data54
, sizeof(data54
), mimeTextHtml
},
576 {data55
, sizeof(data55
), mimeAppXGzip
},
577 {data56
, sizeof(data56
), mimeTextPlain
},
578 {data57
, sizeof(data57
), mimeTextHtml
},
579 {data58
, sizeof(data58
), mimeAppOctetStream
},
580 {data59
, sizeof(data59
), mimeAppXZip
},
581 {data60
, sizeof(data60
), mimeTextPlain
},
582 {data61
, sizeof(data61
), mimeTextHtml
},
583 {data62
, sizeof(data62
), mimeAppJava
},
584 {data63
, sizeof(data63
), mimeTextPlain
},
585 {data64
, sizeof(data64
), mimeTextHtml
},
586 {data65
, sizeof(data65
), mimeAppPdf
},
587 {data66
, sizeof(data66
), mimeTextPlain
},
588 {data67
, sizeof(data67
), mimeTextHtml
},
589 {data68
, sizeof(data68
), mimeAppXMSDownload
},
590 {data69
, sizeof(data69
), mimeTextPlain
},
591 {data70
, sizeof(data70
), mimeTextHtml
},
592 {data71
, sizeof(data71
), mimeTextRichtext
},
593 {data72
, sizeof(data72
), mimeTextPlain
},
594 {data73
, sizeof(data73
), mimeTextPlain
},
595 {data74
, sizeof(data74
), mimeTextHtml
},
596 {data75
, sizeof(data75
), mimeAudioWav
},
597 {data76
, sizeof(data76
), mimeTextPlain
},
598 {data77
, sizeof(data77
), mimeTextPlain
},
599 {data78
, sizeof(data78
), mimeTextHtml
},
600 {data79
, sizeof(data79
), mimeAppPostscript
},
601 {data80
, sizeof(data80
), mimeTextPlain
},
602 {data81
, sizeof(data81
), mimeTextHtml
}
605 static void test_FindMimeFromData(void)
611 for(i
=0; i
<sizeof(mime_tests
)/sizeof(mime_tests
[0]); i
++) {
612 mime
= (LPWSTR
)0xf0f0f0f0;
613 hres
= FindMimeFromData(NULL
, mime_tests
[i
].url
, NULL
, 0, NULL
, 0, &mime
, 0);
614 if(mime_tests
[i
].mime
) {
615 ok(hres
== S_OK
, "[%d] FindMimeFromData failed: %08x\n", i
, hres
);
616 ok(!lstrcmpW(mime
, mime_tests
[i
].mime
), "[%d] wrong mime\n", i
);
619 ok(hres
== E_FAIL
|| hres
== mime_tests
[i
].hres
,
620 "[%d] FindMimeFromData failed: %08x, expected %08x\n",
621 i
, hres
, mime_tests
[i
].hres
);
622 ok(mime
== (LPWSTR
)0xf0f0f0f0, "[%d] mime != 0xf0f0f0f0\n", i
);
625 mime
= (LPWSTR
)0xf0f0f0f0;
626 hres
= FindMimeFromData(NULL
, mime_tests
[i
].url
, NULL
, 0, mimeTextPlain
, 0, &mime
, 0);
627 ok(hres
== S_OK
, "[%d] FindMimeFromData failed: %08x\n", i
, hres
);
628 ok(!lstrcmpW(mime
, mimeTextPlain
), "[%d] wrong mime\n", i
);
631 mime
= (LPWSTR
)0xf0f0f0f0;
632 hres
= FindMimeFromData(NULL
, mime_tests
[i
].url
, NULL
, 0, mimeAppOctetStream
, 0, &mime
, 0);
633 ok(hres
== S_OK
, "[%d] FindMimeFromData failed: %08x\n", i
, hres
);
634 ok(!lstrcmpW(mime
, mimeAppOctetStream
), "[%d] wrong mime\n", i
);
638 for(i
=0; i
< sizeof(mime_tests2
)/sizeof(mime_tests2
[0]); i
++) {
639 hres
= FindMimeFromData(NULL
, NULL
, mime_tests2
[i
].data
, mime_tests2
[i
].size
,
641 ok(hres
== S_OK
, "[%d] FindMimeFromData failed: %08x\n", i
, hres
);
642 ok(!lstrcmpW(mime
, mime_tests2
[i
].mime
), "[%d] wrong mime: %s\n", i
, debugstr_w(mime
));
645 hres
= FindMimeFromData(NULL
, NULL
, mime_tests2
[i
].data
, mime_tests2
[i
].size
,
646 mimeTextHtml
, 0, &mime
, 0);
647 ok(hres
== S_OK
, "[%d] FindMimeFromData failed: %08x\n", i
, hres
);
648 if(!lstrcmpW(mimeAppOctetStream
, mime_tests2
[i
].mime
)
649 || !lstrcmpW(mimeTextPlain
, mime_tests2
[i
].mime
))
650 ok(!lstrcmpW(mime
, mimeTextHtml
), "[%d] wrong mime\n", i
);
652 ok(!lstrcmpW(mime
, mime_tests2
[i
].mime
), "[%d] wrong mime\n", i
);
655 hres
= FindMimeFromData(NULL
, NULL
, mime_tests2
[i
].data
, mime_tests2
[i
].size
,
656 mimeImagePjpeg
, 0, &mime
, 0);
657 ok(hres
== S_OK
, "[%d] FindMimeFromData failed: %08x\n", i
, hres
);
658 if(!lstrcmpW(mimeAppOctetStream
, mime_tests2
[i
].mime
) || i
== 17)
659 ok(!lstrcmpW(mime
, mimeImagePjpeg
), "[%d] wrong mime\n", i
);
661 ok(!lstrcmpW(mime
, mime_tests2
[i
].mime
), "[%d] wrong mime\n", i
);
666 hres
= FindMimeFromData(NULL
, url1
, data1
, sizeof(data1
), NULL
, 0, &mime
, 0);
667 ok(hres
== S_OK
, "FindMimeFromData failed: %08x\n", hres
);
668 ok(!lstrcmpW(mime
, mimeTextPlain
), "wrong mime\n");
671 hres
= FindMimeFromData(NULL
, url1
, data1
, sizeof(data1
), mimeAppOctetStream
, 0, &mime
, 0);
672 ok(hres
== S_OK
, "FindMimeFromData failed: %08x\n", hres
);
673 ok(!lstrcmpW(mime
, mimeTextPlain
), "wrong mime\n");
676 hres
= FindMimeFromData(NULL
, url4
, data1
, sizeof(data1
), mimeAppOctetStream
, 0, &mime
, 0);
677 ok(hres
== S_OK
, "FindMimeFromData failed: %08x\n", hres
);
678 ok(!lstrcmpW(mime
, mimeTextPlain
), "wrong mime\n");
681 hres
= FindMimeFromData(NULL
, NULL
, NULL
, 0, NULL
, 0, &mime
, 0);
682 ok(hres
== E_INVALIDARG
, "FindMimeFromData failed: %08x, excepted E_INVALIDARG\n", hres
);
684 hres
= FindMimeFromData(NULL
, NULL
, NULL
, 0, mimeTextPlain
, 0, &mime
, 0);
685 ok(hres
== E_INVALIDARG
, "FindMimeFromData failed: %08x, expected E_INVALIDARG\n", hres
);
687 hres
= FindMimeFromData(NULL
, NULL
, data1
, 0, NULL
, 0, &mime
, 0);
688 ok(hres
== E_FAIL
, "FindMimeFromData failed: %08x, expected E_FAIL\n", hres
);
690 hres
= FindMimeFromData(NULL
, url1
, data1
, 0, NULL
, 0, &mime
, 0);
691 ok(hres
== E_FAIL
, "FindMimeFromData failed: %08x, expected E_FAIL\n", hres
);
693 hres
= FindMimeFromData(NULL
, NULL
, data1
, 0, mimeTextPlain
, 0, &mime
, 0);
694 ok(hres
== S_OK
, "FindMimeFromData failed: %08x\n", hres
);
695 ok(!lstrcmpW(mime
, mimeTextPlain
), "wrong mime\n");
698 hres
= FindMimeFromData(NULL
, NULL
, data1
, 0, mimeTextPlain
, 0, NULL
, 0);
699 ok(hres
== E_INVALIDARG
, "FindMimeFromData failed: %08x, expected E_INVALIDARG\n", hres
);
702 static const BYTE secid1
[] = {'f','i','l','e',':',0,0,0,0};
703 static const BYTE secid4
[] ={'f','i','l','e',':',3,0,0,0};
704 static const BYTE secid5
[] = {'h','t','t','p',':','w','w','w','.','w','i','n','e','h','q',
705 '.','o','r','g',3,0,0,0};
706 static const BYTE secid6
[] = {'a','b','o','u','t',':','b','l','a','n','k',3,0,0,0};
707 static const BYTE secid7
[] = {'f','t','p',':','w','i','n','e','h','q','.','o','r','g',
710 static struct secmgr_test
{
718 {url1
, 0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
719 {url2
, 100, 0x80041001, 0, NULL
, E_INVALIDARG
},
720 {url3
, 0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
721 {url4
, 3, S_OK
, sizeof(secid4
), secid4
, S_OK
},
722 {url5
, 3, S_OK
, sizeof(secid5
), secid5
, S_OK
},
723 {url6
, 3, S_OK
, sizeof(secid6
), secid6
, S_OK
},
724 {url7
, 3, S_OK
, sizeof(secid7
), secid7
, S_OK
}
727 static void test_SecurityManager(void)
730 IInternetSecurityManager
*secmgr
= NULL
;
735 hres
= CoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
736 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
740 for(i
=0; i
< sizeof(secmgr_tests
)/sizeof(secmgr_tests
[0]); i
++) {
742 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, secmgr_tests
[i
].url
,
744 ok(hres
== secmgr_tests
[i
].zone_hres
,
745 "[%d] MapUrlToZone failed: %08x, expected %08x\n",
746 i
, hres
, secmgr_tests
[i
].zone_hres
);
748 ok(zone
== secmgr_tests
[i
].zone
, "[%d] zone=%d, expected %d\n", i
, zone
,
749 secmgr_tests
[i
].zone
);
751 ok(zone
== secmgr_tests
[i
].zone
|| zone
== -1, "[%d] zone=%d\n", i
, zone
);
754 memset(buf
, 0xf0, sizeof(buf
));
755 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[i
].url
,
757 ok(hres
== secmgr_tests
[i
].secid_hres
,
758 "[%d] GetSecurityId failed: %08x, expected %08x\n",
759 i
, hres
, secmgr_tests
[i
].secid_hres
);
760 if(secmgr_tests
[i
].secid
) {
761 ok(size
== secmgr_tests
[i
].secid_size
, "[%d] size=%d, expected %d\n",
762 i
, size
, secmgr_tests
[i
].secid_size
);
763 ok(!memcmp(buf
, secmgr_tests
[i
].secid
, size
), "[%d] wrong secid\n", i
);
768 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, NULL
, &zone
, 0);
769 ok(hres
== E_INVALIDARG
, "MapUrlToZone failed: %08x, expected E_INVALIDARG\n", hres
);
770 ok(zone
== 100 || zone
== -1, "zone=%d\n", zone
);
773 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, NULL
, buf
, &size
, 0);
774 ok(hres
== E_INVALIDARG
,
775 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
776 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[1].url
,
778 ok(hres
== E_INVALIDARG
,
779 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
780 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[1].url
,
782 ok(hres
== E_INVALIDARG
,
783 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
785 IInternetSecurityManager_Release(secmgr
);
788 static void test_ZoneManager(void)
790 IInternetZoneManager
*zonemgr
= NULL
;
794 hres
= CoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
795 ok(hres
== S_OK
, "CoInternetCreateZoneManager failed: %08x\n", hres
);
799 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, 0x1a10, buf
,
800 sizeof(DWORD
), URLZONEREG_DEFAULT
);
801 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
802 ok(*(DWORD
*)buf
== 1, "policy=%d, expected 1\n", *(DWORD
*)buf
);
804 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, 0x1a10, NULL
,
805 sizeof(DWORD
), URLZONEREG_DEFAULT
);
806 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
808 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, 0x1a10, buf
,
809 2, URLZONEREG_DEFAULT
);
810 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
812 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, 0x1fff, buf
,
813 sizeof(DWORD
), URLZONEREG_DEFAULT
);
814 ok(hres
== E_FAIL
, "GetZoneActionPolicy failed: %08x, expected E_FAIL\n", hres
);
816 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 13, 0x1a10, buf
,
817 sizeof(DWORD
), URLZONEREG_DEFAULT
);
818 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
820 IInternetZoneManager_Release(zonemgr
);
823 static void register_protocols(void)
825 IInternetSession
*session
;
826 IClassFactory
*factory
;
829 static const WCHAR wszAbout
[] = {'a','b','o','u','t',0};
831 hres
= CoInternetGetSession(0, &session
, 0);
832 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
836 hres
= CoGetClassObject(&CLSID_AboutProtocol
, CLSCTX_INPROC_SERVER
, NULL
,
837 &IID_IClassFactory
, (void**)&factory
);
838 ok(hres
== S_OK
, "Coud not get AboutProtocol factory: %08x\n", hres
);
842 IInternetSession_RegisterNameSpace(session
, factory
, &CLSID_AboutProtocol
,
843 wszAbout
, 0, NULL
, 0);
844 IClassFactory_Release(factory
);
846 IInternetSession_Release(session
);
849 static HRESULT WINAPI
InternetProtocolInfo_QueryInterface(IInternetProtocolInfo
*iface
,
850 REFIID riid
, void **ppv
)
852 ok(0, "unexpected call\n");
853 return E_NOINTERFACE
;
856 static ULONG WINAPI
InternetProtocolInfo_AddRef(IInternetProtocolInfo
*iface
)
861 static ULONG WINAPI
InternetProtocolInfo_Release(IInternetProtocolInfo
*iface
)
866 static HRESULT WINAPI
InternetProtocolInfo_ParseUrl(IInternetProtocolInfo
*iface
, LPCWSTR pwzUrl
,
867 PARSEACTION ParseAction
, DWORD dwParseFlags
, LPWSTR pwzResult
, DWORD cchResult
,
868 DWORD
*pcchResult
, DWORD dwReserved
)
870 CHECK_EXPECT(ParseUrl
);
874 static HRESULT WINAPI
InternetProtocolInfo_CombineUrl(IInternetProtocolInfo
*iface
,
875 LPCWSTR pwzBaseUrl
, LPCWSTR pwzRelativeUrl
, DWORD dwCombineFlags
,
876 LPWSTR pwzResult
, DWORD cchResult
, DWORD
*pcchResult
, DWORD dwReserved
)
878 ok(0, "unexpected call\n");
882 static HRESULT WINAPI
InternetProtocolInfo_CompareUrl(IInternetProtocolInfo
*iface
,
883 LPCWSTR pwzUrl1
, LPCWSTR pwzUrl2
, DWORD dwCompareFlags
)
885 ok(0, "unexpected call\n");
889 static HRESULT WINAPI
InternetProtocolInfo_QueryInfo(IInternetProtocolInfo
*iface
,
890 LPCWSTR pwzUrl
, QUERYOPTION OueryOption
, DWORD dwQueryFlags
, LPVOID pBuffer
,
891 DWORD cbBuffer
, DWORD
*pcbBuf
, DWORD dwReserved
)
893 ok(0, "unexpected call\n");
897 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl
= {
898 InternetProtocolInfo_QueryInterface
,
899 InternetProtocolInfo_AddRef
,
900 InternetProtocolInfo_Release
,
901 InternetProtocolInfo_ParseUrl
,
902 InternetProtocolInfo_CombineUrl
,
903 InternetProtocolInfo_CompareUrl
,
904 InternetProtocolInfo_QueryInfo
907 static IInternetProtocolInfo protocol_info
= { &InternetProtocolInfoVtbl
};
909 static HRESULT qiret
;
910 static IClassFactory
*expect_cf
;
912 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
914 if(IsEqualGUID(&IID_IInternetProtocolInfo
, riid
)) {
915 CHECK_EXPECT(QI_IInternetProtocolInfo
);
916 ok(iface
== expect_cf
, "unexpected iface\n");
917 *ppv
= &protocol_info
;
921 ok(0, "unexpected call\n");
922 return E_NOINTERFACE
;
925 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
930 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
935 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
936 REFIID riid
, void **ppv
)
938 ok(0, "unexpected call\n");
942 static HRESULT WINAPI
ProtocolCF_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
943 REFIID riid
, void **ppv
)
945 CHECK_EXPECT(CreateInstance
);
947 ok(iface
== expect_cf
, "unexpected iface\n");
948 ok(pOuter
== NULL
, "pOuter = %p\n", pOuter
);
949 ok(IsEqualGUID(&IID_IInternetProtocolInfo
, riid
), "unexpected riid\n");
950 ok(ppv
!= NULL
, "ppv == NULL\n");
952 *ppv
= &protocol_info
;
956 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
958 ok(0, "unexpected call\n");
962 static const IClassFactoryVtbl ClassFactoryVtbl
= {
963 ClassFactory_QueryInterface
,
965 ClassFactory_Release
,
966 ClassFactory_CreateInstance
,
967 ClassFactory_LockServer
970 static const IClassFactoryVtbl ProtocolCFVtbl
= {
971 ClassFactory_QueryInterface
,
973 ClassFactory_Release
,
974 ProtocolCF_CreateInstance
,
975 ClassFactory_LockServer
978 static IClassFactory test_protocol_cf
= { &ProtocolCFVtbl
};
979 static IClassFactory test_protocol_cf2
= { &ProtocolCFVtbl
};
980 static IClassFactory test_cf
= { &ClassFactoryVtbl
};
982 static void test_NameSpace(void)
984 IInternetSession
*session
;
989 static const WCHAR wszTest
[] = {'t','e','s','t',0};
991 hres
= CoInternetGetSession(0, &session
, 0);
992 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
996 hres
= IInternetSession_RegisterNameSpace(session
, NULL
, &IID_NULL
,
997 wszTest
, 0, NULL
, 0);
998 ok(hres
== E_INVALIDARG
, "RegisterNameSpace failed: %08x\n", hres
);
1000 hres
= IInternetSession_RegisterNameSpace(session
, &test_protocol_cf
, &IID_NULL
,
1002 ok(hres
== E_INVALIDARG
, "RegisterNameSpace failed: %08x\n", hres
);
1004 hres
= IInternetSession_RegisterNameSpace(session
, &test_protocol_cf
, &IID_NULL
,
1005 wszTest
, 0, NULL
, 0);
1006 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
1008 qiret
= E_NOINTERFACE
;
1009 expect_cf
= &test_protocol_cf
;
1010 SET_EXPECT(QI_IInternetProtocolInfo
);
1011 SET_EXPECT(CreateInstance
);
1012 SET_EXPECT(ParseUrl
);
1014 hres
= CoInternetParseUrl(url8
, PARSE_ENCODE
, 0, buf
, sizeof(buf
)/sizeof(WCHAR
),
1016 ok(hres
== S_OK
, "CoInternetParseUrl failed: %08x\n", hres
);
1018 CHECK_CALLED(QI_IInternetProtocolInfo
);
1019 CHECK_CALLED(CreateInstance
);
1020 CHECK_CALLED(ParseUrl
);
1023 SET_EXPECT(QI_IInternetProtocolInfo
);
1024 SET_EXPECT(ParseUrl
);
1026 hres
= CoInternetParseUrl(url8
, PARSE_ENCODE
, 0, buf
, sizeof(buf
)/sizeof(WCHAR
),
1028 ok(hres
== S_OK
, "CoInternetParseUrl failed: %08x\n", hres
);
1030 CHECK_CALLED(QI_IInternetProtocolInfo
);
1031 CHECK_CALLED(ParseUrl
);
1033 hres
= IInternetSession_UnregisterNameSpace(session
, &test_protocol_cf
, wszTest
);
1034 ok(hres
== S_OK
, "UnregisterNameSpace failed: %08x\n", hres
);
1036 hres
= CoInternetParseUrl(url8
, PARSE_ENCODE
, 0, buf
, sizeof(buf
)/sizeof(WCHAR
),
1038 ok(hres
== S_OK
, "CoInternetParseUrl failed: %08x\n", hres
);
1040 hres
= IInternetSession_RegisterNameSpace(session
, &test_protocol_cf2
, &IID_NULL
,
1041 wszTest
, 0, NULL
, 0);
1042 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
1044 hres
= IInternetSession_RegisterNameSpace(session
, &test_protocol_cf
, &IID_NULL
,
1045 wszTest
, 0, NULL
, 0);
1046 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
1048 hres
= IInternetSession_RegisterNameSpace(session
, &test_protocol_cf
, &IID_NULL
,
1049 wszTest
, 0, NULL
, 0);
1050 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
1052 SET_EXPECT(QI_IInternetProtocolInfo
);
1053 SET_EXPECT(ParseUrl
);
1055 hres
= CoInternetParseUrl(url8
, PARSE_ENCODE
, 0, buf
, sizeof(buf
)/sizeof(WCHAR
),
1057 ok(hres
== S_OK
, "CoInternetParseUrl failed: %08x\n", hres
);
1059 CHECK_CALLED(QI_IInternetProtocolInfo
);
1060 CHECK_CALLED(ParseUrl
);
1062 hres
= IInternetSession_UnregisterNameSpace(session
, &test_protocol_cf
, wszTest
);
1063 ok(hres
== S_OK
, "UnregisterNameSpace failed: %08x\n", hres
);
1065 SET_EXPECT(QI_IInternetProtocolInfo
);
1066 SET_EXPECT(ParseUrl
);
1068 hres
= CoInternetParseUrl(url8
, PARSE_ENCODE
, 0, buf
, sizeof(buf
)/sizeof(WCHAR
),
1070 ok(hres
== S_OK
, "CoInternetParseUrl failed: %08x\n", hres
);
1072 CHECK_CALLED(QI_IInternetProtocolInfo
);
1073 CHECK_CALLED(ParseUrl
);
1075 hres
= IInternetSession_UnregisterNameSpace(session
, &test_protocol_cf
, wszTest
);
1076 ok(hres
== S_OK
, "UnregisterNameSpace failed: %08x\n", hres
);
1078 expect_cf
= &test_protocol_cf2
;
1079 SET_EXPECT(QI_IInternetProtocolInfo
);
1080 SET_EXPECT(ParseUrl
);
1082 hres
= CoInternetParseUrl(url8
, PARSE_ENCODE
, 0, buf
, sizeof(buf
)/sizeof(WCHAR
),
1084 ok(hres
== S_OK
, "CoInternetParseUrl failed: %08x\n", hres
);
1086 CHECK_CALLED(QI_IInternetProtocolInfo
);
1087 CHECK_CALLED(ParseUrl
);
1089 hres
= IInternetSession_UnregisterNameSpace(session
, &test_protocol_cf
, wszTest
);
1090 ok(hres
== S_OK
, "UnregisterNameSpace failed: %08x\n", hres
);
1091 hres
= IInternetSession_UnregisterNameSpace(session
, &test_protocol_cf
, wszTest
);
1092 ok(hres
== S_OK
, "UnregisterNameSpace failed: %08x\n", hres
);
1093 hres
= IInternetSession_UnregisterNameSpace(session
, &test_protocol_cf
, NULL
);
1094 ok(hres
== E_INVALIDARG
, "UnregisterNameSpace failed: %08x\n", hres
);
1095 hres
= IInternetSession_UnregisterNameSpace(session
, NULL
, wszTest
);
1096 ok(hres
== E_INVALIDARG
, "UnregisterNameSpace failed: %08x\n", hres
);
1098 hres
= IInternetSession_UnregisterNameSpace(session
, &test_protocol_cf2
, wszTest
);
1099 ok(hres
== S_OK
, "UnregisterNameSpace failed: %08x\n", hres
);
1101 hres
= CoInternetParseUrl(url8
, PARSE_ENCODE
, 0, buf
, sizeof(buf
)/sizeof(WCHAR
),
1103 ok(hres
== S_OK
, "CoInternetParseUrl failed: %08x\n", hres
);
1105 IInternetSession_Release(session
);
1108 static void test_MimeFilter(void)
1110 IInternetSession
*session
;
1113 static const WCHAR mimeW
[] = {'t','e','s','t','/','m','i','m','e',0};
1115 hres
= CoInternetGetSession(0, &session
, 0);
1116 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
1120 hres
= IInternetSession_RegisterMimeFilter(session
, &test_cf
, &IID_NULL
, mimeW
);
1121 ok(hres
== S_OK
, "RegisterMimeFilter failed: %08x\n", hres
);
1123 hres
= IInternetSession_UnregisterMimeFilter(session
, &test_cf
, mimeW
);
1124 ok(hres
== S_OK
, "UnregisterMimeFilter failed: %08x\n", hres
);
1126 hres
= IInternetSession_UnregisterMimeFilter(session
, &test_cf
, mimeW
);
1127 ok(hres
== S_OK
, "UnregisterMimeFilter failed: %08x\n", hres
);
1129 hres
= IInternetSession_UnregisterMimeFilter(session
, (void*)0xdeadbeef, mimeW
);
1130 ok(hres
== S_OK
, "UnregisterMimeFilter failed: %08x\n", hres
);
1132 IInternetSession_Release(session
);
1135 static ULONG WINAPI
unk_Release(IUnknown
*iface
)
1137 CHECK_EXPECT(unk_Release
);
1141 static const IUnknownVtbl unk_vtbl
= {
1147 static void test_ReleaseBindInfo(void)
1150 IUnknown unk
= { &unk_vtbl
};
1152 ReleaseBindInfo(NULL
); /* shouldn't crash */
1154 memset(&bi
, 0, sizeof(bi
));
1155 bi
.cbSize
= sizeof(BINDINFO
);
1157 SET_EXPECT(unk_Release
);
1158 ReleaseBindInfo(&bi
);
1159 ok(bi
.cbSize
== sizeof(BINDINFO
), "bi.cbSize=%d\n", bi
.cbSize
);
1160 ok(bi
.pUnk
== NULL
, "bi.pUnk=%p, expected NULL\n", bi
.pUnk
);
1161 CHECK_CALLED(unk_Release
);
1163 memset(&bi
, 0, sizeof(bi
));
1164 bi
.cbSize
= offsetof(BINDINFO
, pUnk
);
1166 ReleaseBindInfo(&bi
);
1167 ok(bi
.cbSize
== offsetof(BINDINFO
, pUnk
), "bi.cbSize=%d\n", bi
.cbSize
);
1168 ok(bi
.pUnk
== &unk
, "bi.pUnk=%p, expected %p\n", bi
.pUnk
, &unk
);
1170 memset(&bi
, 0, sizeof(bi
));
1172 ReleaseBindInfo(&bi
);
1173 ok(!bi
.cbSize
, "bi.cbSize=%d, expected 0\n", bi
.cbSize
);
1174 ok(bi
.pUnk
== &unk
, "bi.pUnk=%p, expected %p\n", bi
.pUnk
, &unk
);
1177 static void test_UrlMkGetSessionOption(void)
1179 DWORD encoding
, size
;
1182 size
= encoding
= 0xdeadbeef;
1183 hres
= UrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING
, &encoding
,
1184 sizeof(encoding
), &size
, 0);
1185 ok(hres
== S_OK
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1186 ok(encoding
!= 0xdeadbeef, "encoding not changed\n");
1187 ok(size
== sizeof(encoding
), "size=%d\n", size
);
1189 size
= encoding
= 0xdeadbeef;
1190 hres
= UrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING
, &encoding
,
1191 sizeof(encoding
)+1, &size
, 0);
1192 ok(hres
== S_OK
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1193 ok(encoding
!= 0xdeadbeef, "encoding not changed\n");
1194 ok(size
== sizeof(encoding
), "size=%d\n", size
);
1196 size
= encoding
= 0xdeadbeef;
1197 hres
= UrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING
, &encoding
,
1198 sizeof(encoding
)-1, &size
, 0);
1199 ok(hres
== E_INVALIDARG
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1200 ok(encoding
== 0xdeadbeef, "encoding = %08x, exepcted 0xdeadbeef\n", encoding
);
1201 ok(size
== 0xdeadbeef, "size=%d\n", size
);
1203 size
= encoding
= 0xdeadbeef;
1204 hres
= UrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING
, NULL
,
1205 sizeof(encoding
)-1, &size
, 0);
1206 ok(hres
== E_INVALIDARG
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1207 ok(encoding
== 0xdeadbeef, "encoding = %08x, exepcted 0xdeadbeef\n", encoding
);
1208 ok(size
== 0xdeadbeef, "size=%d\n", size
);
1210 encoding
= 0xdeadbeef;
1211 hres
= UrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING
, &encoding
,
1212 sizeof(encoding
)-1, NULL
, 0);
1213 ok(hres
== E_INVALIDARG
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1214 ok(encoding
== 0xdeadbeef, "encoding = %08x, exepcted 0xdeadbeef\n", encoding
);
1217 static void test_ObtainUserAgentString(void)
1219 static const CHAR expected
[] = "Mozilla/4.0 (compatible; MSIE ";
1225 hres
= ObtainUserAgentString(0, NULL
, NULL
);
1226 ok(hres
== E_INVALIDARG
, "ObtainUserAgentString failed: %08x\n", hres
);
1229 hres
= ObtainUserAgentString(0, NULL
, &size
);
1230 ok(hres
== E_INVALIDARG
, "ObtainUserAgentString failed: %08x\n", hres
);
1231 ok(size
== 100, "size=%d, expected %d\n", size
, 100);
1234 hres
= ObtainUserAgentString(0, str
, &size
);
1235 ok(hres
== E_OUTOFMEMORY
, "ObtainUserAgentString failed: %08x\n", hres
);
1236 ok(size
> 0, "size=%d, expected non-zero\n", size
);
1240 hres
= ObtainUserAgentString(0, str
, &size
);
1241 ok(hres
== E_OUTOFMEMORY
, "ObtainUserAgentString failed: %08x\n", hres
);
1242 ok(size
> 0, "size=%d, expected non-zero\n", size
);
1243 ok(str
[0] == 'a', "str[0]=%c, expected 'a'\n", str
[0]);
1246 hres
= ObtainUserAgentString(1, str
, &size
);
1247 ok(hres
== E_OUTOFMEMORY
, "ObtainUserAgentString failed: %08x\n", hres
);
1248 ok(size
> 0, "size=%d, expected non-zero\n", size
);
1250 str2
= HeapAlloc(GetProcessHeap(), 0, (size
+20)*sizeof(CHAR
));
1253 skip("skipping rest of ObtainUserAgent tests, out of memory\n");
1258 hres
= ObtainUserAgentString(0, str2
, &size
);
1259 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
1260 ok(size
== saved
, "size=%d, expected %d\n", size
, saved
);
1261 ok(strlen(expected
) <= strlen(str2
) &&
1262 !memcmp(expected
, str2
, strlen(expected
)*sizeof(CHAR
)),
1263 "user agent was \"%s\", expected to start with \"%s\"\n",
1267 hres
= ObtainUserAgentString(0, str2
, &size
);
1268 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
1269 ok(size
== saved
, "size=%d, expected %d\n", size
, saved
);
1271 HeapFree(GetProcessHeap(), 0, str2
);
1276 OleInitialize(NULL
);
1278 register_protocols();
1280 test_CreateFormatEnum();
1281 test_RegisterFormatEnumerator();
1282 test_CoInternetParseUrl();
1283 test_CoInternetCompareUrl();
1284 test_CoInternetQueryInfo();
1285 test_FindMimeFromData();
1286 test_SecurityManager();
1290 test_ReleaseBindInfo();
1291 test_UrlMkGetSessionOption();
1292 test_ObtainUserAgentString();